mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:07:34 +00:00
LibWeb: Add a basic MessageChannel test
This commit is contained in:
parent
fef7571931
commit
512624f31a
2 changed files with 31 additions and 0 deletions
|
@ -0,0 +1,7 @@
|
||||||
|
FIXME: Order of messages is incorrect
|
||||||
|
Port1: "Hello"
|
||||||
|
Port1: {"foo":"bar","baz":[1,2,3,4]}
|
||||||
|
Port1: "DONE"
|
||||||
|
Port2: "Hello"
|
||||||
|
Port2: {"foo":"bar","baz":[1,2,3,4]}
|
||||||
|
Port2: "DONE"
|
|
@ -0,0 +1,24 @@
|
||||||
|
<script src="../include.js"></script>
|
||||||
|
<script>
|
||||||
|
asyncTest(done => {
|
||||||
|
let channel = new MessageChannel();
|
||||||
|
|
||||||
|
channel.port1.onmessage = (event) => {
|
||||||
|
println("Port1: " + JSON.stringify(event.data));
|
||||||
|
channel.port1.postMessage(event.data);
|
||||||
|
};
|
||||||
|
|
||||||
|
channel.port2.onmessage = (event) => {
|
||||||
|
println("Port2: " + JSON.stringify(event.data));
|
||||||
|
if (event.data === "DONE") {
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// FIXME: These should be output in the order: Port1: A, Port2: A, Port1: B, Port2: B, ...
|
||||||
|
println("FIXME: Order of messages is incorrect");
|
||||||
|
channel.port2.postMessage("Hello");
|
||||||
|
channel.port2.postMessage({ foo: "bar", baz: [ 1, 2, 3, 4 ] });
|
||||||
|
channel.port2.postMessage("DONE");
|
||||||
|
});
|
||||||
|
</script>
|
Loading…
Add table
Add a link
Reference in a new issue