mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
The way this test was written didn't guarantee a deterministic message order, resulting in different output in Chromium and Firefox. This change slightly rearranges the message order to make it deterministic. This change is necessary as a prepartion for upcoming change that makes MessagePort post messages from a separate thread, which would've revealed the non-deterministic message order.
34 lines
1.0 KiB
HTML
34 lines
1.0 KiB
HTML
<!DOCTYPE html>
|
|
<script src="../include.js"></script>
|
|
<script>
|
|
asyncTest(done => {
|
|
let channel = new MessageChannel();
|
|
|
|
channel.port1.onmessage = (event) => {
|
|
println("Port1: " + JSON.stringify(event.data));
|
|
if (event.ports.length > 0) {
|
|
event.ports[0].postMessage("Hello from the transferred port");
|
|
return;
|
|
}
|
|
channel.port1.postMessage(event.data);
|
|
};
|
|
|
|
channel.port2.onmessage = (event) => {
|
|
println("Port2: " + JSON.stringify(event.data));
|
|
if (event.data === "DONE") {
|
|
done();
|
|
}
|
|
};
|
|
|
|
let channel2 = new MessageChannel();
|
|
|
|
channel2.port2.onmessage = (event) => {
|
|
println("Port3: " + JSON.stringify(event.data));
|
|
channel.port2.postMessage("DONE");
|
|
}
|
|
|
|
channel.port2.postMessage("Hello");
|
|
channel.port2.postMessage({ foo: channel2.port1 }, { transfer: [channel2.port1] });
|
|
});
|
|
</script>
|