Tests: Rearrange message order in Messaging-post-channel-over-channel

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.
This commit is contained in:
Aliaksandr Kalenik 2025-04-08 16:41:45 +02:00 committed by Alexander Kalenik
commit af2dae63d1
Notes: github-actions[bot] 2025-04-08 19:10:37 +00:00
2 changed files with 3 additions and 3 deletions

View file

@ -1,6 +1,6 @@
Port1: "Hello" Port1: "Hello"
Port1: {"foo":{}} Port1: {"foo":{}}
Port1: "DONE"
Port2: "Hello" Port2: "Hello"
Port3: "Hello from the transferred port" Port3: "Hello from the transferred port"
Port1: "DONE"
Port2: "DONE" Port2: "DONE"

View file

@ -23,11 +23,11 @@
let channel2 = new MessageChannel(); let channel2 = new MessageChannel();
channel2.port2.onmessage = (event) => { channel2.port2.onmessage = (event) => {
println("Port3: " + JSON.stringify(event.data)) println("Port3: " + JSON.stringify(event.data));
channel.port2.postMessage("DONE");
} }
channel.port2.postMessage("Hello"); channel.port2.postMessage("Hello");
channel.port2.postMessage({ foo: channel2.port1 }, { transfer: [channel2.port1] }); channel.port2.postMessage({ foo: channel2.port1 }, { transfer: [channel2.port1] });
channel.port2.postMessage("DONE");
}); });
</script> </script>