mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 01:51:03 +09:00
Tests: Rearrange log order in Messaging-post-channel-over-channel.html
When a message is posted to multiple ports at once, the order in which the callbacks for these messages are invoked is non-deterministic. To account for this, the test has been rewritten to accumulate logs for each port separately, and then print them grouped by port.
This commit is contained in:
parent
f07a3fe6da
commit
87bffe7d22
Notes:
github-actions[bot]
2025-04-11 15:14:07 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 87bffe7d22
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4320
Reviewed-by: https://github.com/ADKaster ✅
2 changed files with 15 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
||||||
Port1: "Hello"
|
Port1: "Hello"
|
||||||
Port1: {"foo":{}}
|
Port1: {"foo":{}}
|
||||||
Port2: "Hello"
|
|
||||||
Port3: "Hello from the transferred port"
|
|
||||||
Port1: "DONE"
|
Port1: "DONE"
|
||||||
|
Port2: "Hello"
|
||||||
Port2: "DONE"
|
Port2: "DONE"
|
||||||
|
Port3: "Hello from the transferred port"
|
||||||
|
|
|
@ -4,8 +4,12 @@
|
||||||
asyncTest(done => {
|
asyncTest(done => {
|
||||||
let channel = new MessageChannel();
|
let channel = new MessageChannel();
|
||||||
|
|
||||||
|
const port1Logs = [];
|
||||||
|
const port2Logs = [];
|
||||||
|
const port3Logs = [];
|
||||||
|
|
||||||
channel.port1.onmessage = (event) => {
|
channel.port1.onmessage = (event) => {
|
||||||
println("Port1: " + JSON.stringify(event.data));
|
port1Logs.push("Port1: " + JSON.stringify(event.data));
|
||||||
if (event.ports.length > 0) {
|
if (event.ports.length > 0) {
|
||||||
event.ports[0].postMessage("Hello from the transferred port");
|
event.ports[0].postMessage("Hello from the transferred port");
|
||||||
return;
|
return;
|
||||||
|
@ -14,8 +18,14 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
channel.port2.onmessage = (event) => {
|
channel.port2.onmessage = (event) => {
|
||||||
println("Port2: " + JSON.stringify(event.data));
|
port2Logs.push("Port2: " + JSON.stringify(event.data));
|
||||||
if (event.data === "DONE") {
|
if (event.data === "DONE") {
|
||||||
|
for (let log of port1Logs)
|
||||||
|
println(log);
|
||||||
|
for (let log of port2Logs)
|
||||||
|
println(log);
|
||||||
|
for (let log of port3Logs)
|
||||||
|
println(log);
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -23,7 +33,7 @@
|
||||||
let channel2 = new MessageChannel();
|
let channel2 = new MessageChannel();
|
||||||
|
|
||||||
channel2.port2.onmessage = (event) => {
|
channel2.port2.onmessage = (event) => {
|
||||||
println("Port3: " + JSON.stringify(event.data));
|
port3Logs.push("Port3: " + JSON.stringify(event.data));
|
||||||
channel.port2.postMessage("DONE");
|
channel.port2.postMessage("DONE");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue