Skip to content

Commit 493ddd6

Browse files
committed
Add tests for wasm
Signed-off-by: Kohei Tokunaga <[email protected]>
1 parent 53f3a13 commit 493ddd6

File tree

101 files changed

+77718
-30
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+77718
-30
lines changed

.github/workflows/lockdown.yml

-30
This file was deleted.

.github/workflows/tests.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Tests
2+
on:
3+
push:
4+
branches:
5+
- sync-upstream
6+
pull_request:
7+
8+
env:
9+
DOCKER_BUILDKIT: 1
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-24.04
14+
name: Test
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
arch: ["x86_64", "riscv64", "aarch64", "arm"]
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: test
22+
run: |
23+
cd examples/tests
24+
./run.sh "${{ matrix.arch }}"

examples/tests/Dockerfile.node-chrome

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM selenium/node-chrome:132.0
2+
COPY --from=test-page /usr/local/apache2/conf/server.crt ./server.crt
3+
RUN certutil -d sql:$HOME/.pki/nssdb -A -t "P,," -n testing -i ./server.crt

examples/tests/Dockerfile.node-edge

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM selenium/node-edge:132.0
2+
COPY --from=test-page /usr/local/apache2/conf/server.crt ./server.crt
3+
RUN certutil -d sql:$HOME/.pki/nssdb -A -t "P,," -n testing -i ./server.crt
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM selenium/node-firefox:136.0
2+
COPY --from=test-page /usr/local/apache2/conf/server.crt ./server.crt
3+
RUN certutil -d sql:$HOME/.pki/nssdb -A -t "P,," -n testing -i ./server.crt

examples/tests/Dockerfile.runner

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM python:3.12
2+
RUN apt-get update && apt-get install -y expect
3+
COPY ./script/requirements.txt /
4+
RUN pip install -r /requirements.txt
5+
COPY ./script/run.py /

examples/tests/Dockerfile.testpage

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM ubuntu:24.04 AS cert-dev
2+
RUN apt-get update && apt-get install -y openssl
3+
RUN openssl req -subj "/CN=testpage" -addext "subjectAltName = DNS:testpage" \
4+
-newkey rsa:2048 -nodes -keyout /server.key \
5+
-x509 -days 365 -out /server.crt
6+
7+
FROM httpd
8+
9+
RUN echo "Include conf/extra/xterm-pty.conf" >> /usr/local/apache2/conf/httpd.conf
10+
RUN echo "LoadModule ssl_module modules/mod_ssl.so" >> /usr/local/apache2/conf/httpd.conf
11+
RUN echo "LoadModule socache_shmcb_module modules/mod_socache_shmcb.so" >> /usr/local/apache2/conf/httpd.conf
12+
RUN echo "Include conf/extra/httpd-ssl.conf" >> /usr/local/apache2/conf/httpd.conf
13+
14+
COPY --from=cert-dev /server.key /usr/local/apache2/conf/server.key
15+
COPY --from=cert-dev /server.crt /usr/local/apache2/conf/server.crt
16+
COPY ./xterm-pty.conf /usr/local/apache2/conf/extra/xterm-pty.conf
17+
COPY ./htdocs /usr/local/apache2/htdocs
18+
COPY --from=htdocsassets / /usr/local/apache2/htdocs/

examples/tests/docker-compose.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
services:
2+
chrome:
3+
image: test-node-chrome
4+
shm_size: 2gb
5+
depends_on:
6+
- selenium-hub
7+
environment:
8+
- SE_EVENT_BUS_HOST=selenium-hub
9+
- SE_EVENT_BUS_PUBLISH_PORT=4442
10+
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
11+
firefox:
12+
image: test-node-firefox
13+
shm_size: 2gb
14+
depends_on:
15+
- selenium-hub
16+
environment:
17+
- SE_EVENT_BUS_HOST=selenium-hub
18+
- SE_EVENT_BUS_PUBLISH_PORT=4442
19+
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
20+
edge:
21+
image: test-node-edge
22+
shm_size: 2gb
23+
depends_on:
24+
- selenium-hub
25+
environment:
26+
- SE_EVENT_BUS_HOST=selenium-hub
27+
- SE_EVENT_BUS_PUBLISH_PORT=4442
28+
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
29+
selenium-hub:
30+
image: selenium/hub:4.28
31+
container_name: selenium-hub
32+
hostname: selenium-hub
33+
testpage:
34+
image: test-page
35+
runner:
36+
build:
37+
context: .
38+
dockerfile: Dockerfile.runner
39+
environment:
40+
SELENIUM_URL: http://selenium-hub:4444/wd/hub
41+
init: true
42+
command: sleep infinity

examples/tests/htdocs/index.html

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<html>
2+
<head>
3+
<title>QEMU on browser</title>
4+
<link rel="stylesheet" href="./vendor/xterm.css" />
5+
</head>
6+
<body>
7+
<div id="terminal"></div>
8+
<script src="./load.js"></script>
9+
<script type="module">
10+
import 'https://unpkg.com/@xterm/[email protected]/lib/xterm.js';
11+
import 'https://unpkg.com/xterm-pty/index.js';
12+
import './module.js'
13+
import initEmscriptenModule from './out.js';
14+
15+
let xterm = new Terminal();
16+
xterm.open(document.getElementById("terminal"));
17+
18+
const { master, slave } = openpty();
19+
20+
window.xterm = xterm;
21+
window.hookOutput = (f) => {
22+
let orgWrite = slave.write;
23+
slave.write = (c) => {
24+
f(c);
25+
orgWrite.apply(slave, [c]);
26+
};
27+
}
28+
window.input = (c) => {
29+
let decodedChar = atob(c);
30+
xterm.input(decodedChar);
31+
}
32+
33+
xterm.loadAddon(master);
34+
35+
Module.pty = slave;
36+
Module['mainScriptUrlOrBlob'] = location.origin + "/out.js";
37+
(async () => {
38+
const instance = await initEmscriptenModule(Module);
39+
40+
var oldPoll = Module['TTY'].stream_ops.poll;
41+
var pty = Module['pty'];
42+
Module['TTY'].stream_ops.poll = function(stream, timeout){
43+
if (!pty.readable) {
44+
return (pty.readable ? 1 : 0) | (pty.writable ? 4 : 0);
45+
}
46+
return oldPoll.call(stream, timeout);
47+
}
48+
})();
49+
</script>
50+
</body>
51+
</html>
+209
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
/**
2+
* Copyright (c) 2014 The xterm.js authors. All rights reserved.
3+
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
4+
* https://github.com/chjj/term.js
5+
* @license MIT
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*
25+
* Originally forked from (with the author's permission):
26+
* Fabrice Bellard's javascript vt100 for jslinux:
27+
* http://bellard.org/jslinux/
28+
* Copyright (c) 2011 Fabrice Bellard
29+
* The original design remains. The terminal itself
30+
* has been extended to include xterm CSI codes, among
31+
* other features.
32+
*/
33+
34+
/**
35+
* Default styles for xterm.js
36+
*/
37+
38+
.xterm {
39+
cursor: text;
40+
position: relative;
41+
user-select: none;
42+
-ms-user-select: none;
43+
-webkit-user-select: none;
44+
}
45+
46+
.xterm.focus,
47+
.xterm:focus {
48+
outline: none;
49+
}
50+
51+
.xterm .xterm-helpers {
52+
position: absolute;
53+
top: 0;
54+
/**
55+
* The z-index of the helpers must be higher than the canvases in order for
56+
* IMEs to appear on top.
57+
*/
58+
z-index: 5;
59+
}
60+
61+
.xterm .xterm-helper-textarea {
62+
padding: 0;
63+
border: 0;
64+
margin: 0;
65+
/* Move textarea out of the screen to the far left, so that the cursor is not visible */
66+
position: absolute;
67+
opacity: 0;
68+
left: -9999em;
69+
top: 0;
70+
width: 0;
71+
height: 0;
72+
z-index: -5;
73+
/** Prevent wrapping so the IME appears against the textarea at the correct position */
74+
white-space: nowrap;
75+
overflow: hidden;
76+
resize: none;
77+
}
78+
79+
.xterm .composition-view {
80+
/* TODO: Composition position got messed up somewhere */
81+
background: #000;
82+
color: #FFF;
83+
display: none;
84+
position: absolute;
85+
white-space: nowrap;
86+
z-index: 1;
87+
}
88+
89+
.xterm .composition-view.active {
90+
display: block;
91+
}
92+
93+
.xterm .xterm-viewport {
94+
/* On OS X this is required in order for the scroll bar to appear fully opaque */
95+
background-color: #000;
96+
overflow-y: scroll;
97+
cursor: default;
98+
position: absolute;
99+
right: 0;
100+
left: 0;
101+
top: 0;
102+
bottom: 0;
103+
}
104+
105+
.xterm .xterm-screen {
106+
position: relative;
107+
}
108+
109+
.xterm .xterm-screen canvas {
110+
position: absolute;
111+
left: 0;
112+
top: 0;
113+
}
114+
115+
.xterm .xterm-scroll-area {
116+
visibility: hidden;
117+
}
118+
119+
.xterm-char-measure-element {
120+
display: inline-block;
121+
visibility: hidden;
122+
position: absolute;
123+
top: 0;
124+
left: -9999em;
125+
line-height: normal;
126+
}
127+
128+
.xterm.enable-mouse-events {
129+
/* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */
130+
cursor: default;
131+
}
132+
133+
.xterm.xterm-cursor-pointer,
134+
.xterm .xterm-cursor-pointer {
135+
cursor: pointer;
136+
}
137+
138+
.xterm.column-select.focus {
139+
/* Column selection mode */
140+
cursor: crosshair;
141+
}
142+
143+
.xterm .xterm-accessibility,
144+
.xterm .xterm-message {
145+
position: absolute;
146+
left: 0;
147+
top: 0;
148+
bottom: 0;
149+
right: 0;
150+
z-index: 10;
151+
color: transparent;
152+
pointer-events: none;
153+
}
154+
155+
.xterm .live-region {
156+
position: absolute;
157+
left: -9999px;
158+
width: 1px;
159+
height: 1px;
160+
overflow: hidden;
161+
}
162+
163+
.xterm-dim {
164+
/* Dim should not apply to background, so the opacity of the foreground color is applied
165+
* explicitly in the generated class and reset to 1 here */
166+
opacity: 1 !important;
167+
}
168+
169+
.xterm-underline-1 { text-decoration: underline; }
170+
.xterm-underline-2 { text-decoration: double underline; }
171+
.xterm-underline-3 { text-decoration: wavy underline; }
172+
.xterm-underline-4 { text-decoration: dotted underline; }
173+
.xterm-underline-5 { text-decoration: dashed underline; }
174+
175+
.xterm-overline {
176+
text-decoration: overline;
177+
}
178+
179+
.xterm-overline.xterm-underline-1 { text-decoration: overline underline; }
180+
.xterm-overline.xterm-underline-2 { text-decoration: overline double underline; }
181+
.xterm-overline.xterm-underline-3 { text-decoration: overline wavy underline; }
182+
.xterm-overline.xterm-underline-4 { text-decoration: overline dotted underline; }
183+
.xterm-overline.xterm-underline-5 { text-decoration: overline dashed underline; }
184+
185+
.xterm-strikethrough {
186+
text-decoration: line-through;
187+
}
188+
189+
.xterm-screen .xterm-decoration-container .xterm-decoration {
190+
z-index: 6;
191+
position: absolute;
192+
}
193+
194+
.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer {
195+
z-index: 7;
196+
}
197+
198+
.xterm-decoration-overview-ruler {
199+
z-index: 8;
200+
position: absolute;
201+
top: 0;
202+
right: 0;
203+
pointer-events: none;
204+
}
205+
206+
.xterm-decoration-top {
207+
z-index: 2;
208+
position: relative;
209+
}

0 commit comments

Comments
 (0)