mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:17:44 +00:00
Tests: Add test for loading module scripts in Workers
This commit is contained in:
parent
f67bc591a0
commit
f9f98016e2
3 changed files with 22 additions and 0 deletions
1
Tests/LibWeb/Text/expected/Worker/Worker-module.txt
Normal file
1
Tests/LibWeb/Text/expected/Worker/Worker-module.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Message from worker: Worker responding to: Hello :^)
|
18
Tests/LibWeb/Text/input/Worker/Worker-module.html
Normal file
18
Tests/LibWeb/Text/input/Worker/Worker-module.html
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<script src="../include.js"></script>
|
||||||
|
<script>
|
||||||
|
asyncTest((done) => {
|
||||||
|
let work = new Worker('worker.mjs', { type: 'module' });
|
||||||
|
work.onmessage = (e) => {
|
||||||
|
println(`Message from worker: ${e.data}`);
|
||||||
|
work.onmessage = null;
|
||||||
|
work.terminate();
|
||||||
|
done();
|
||||||
|
};
|
||||||
|
|
||||||
|
work.onerror = (e) => {
|
||||||
|
println(`Worker error: ${e.message}`);
|
||||||
|
};
|
||||||
|
|
||||||
|
work.postMessage('Hello :^)');
|
||||||
|
});
|
||||||
|
</script>
|
3
Tests/LibWeb/Text/input/Worker/worker.mjs
Normal file
3
Tests/LibWeb/Text/input/Worker/worker.mjs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
self.onmessage = ({ data }) => {
|
||||||
|
self.postMessage(`Worker responding to: ${data}`);
|
||||||
|
};
|
Loading…
Add table
Add a link
Reference in a new issue