mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-19 15:32:31 +00:00
33 lines
1,007 B
HTML
33 lines
1,007 B
HTML
<!DOCTYPE html>
|
|
<script src="../include.js"></script>
|
|
<script>
|
|
asyncTest((done) => {
|
|
let work = new Worker("worker.js");
|
|
let channel = new MessageChannel();
|
|
|
|
function finishTest() {
|
|
println("DONE");
|
|
work.onmessage = null;
|
|
work.terminate();
|
|
channel.port2.onmessage = null;
|
|
done();
|
|
}
|
|
let count = 0;
|
|
work.onmessage = (evt) => {
|
|
println("Got message from worker: " + JSON.stringify(evt.data));
|
|
count++;
|
|
if (count === 3) {
|
|
finishTest();
|
|
}
|
|
};
|
|
channel.port2.onmessage = (evt) => {
|
|
println("Got message from port: " + JSON.stringify(evt.data));
|
|
channel.port2.postMessage("Hello from port2");
|
|
count++;
|
|
if (count === 3) {
|
|
finishTest();
|
|
}
|
|
};
|
|
work.postMessage({ port: channel.port1 }, { transfer : [channel.port1]});
|
|
});
|
|
</script>
|