mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 10:38:13 +00:00
LibWeb: Post all MessagePort messages over their LocalSockets
This is to allow future changes to do cross-process MessagePorts in an implementation-agnostic way. Add some tests for this behavior. Delivering messages that were posted to a MessagePort just before it was transferred is not yet implemented still.
This commit is contained in:
parent
6e3b816763
commit
c0f50b12a4
7 changed files with 301 additions and 52 deletions
|
@ -0,0 +1,32 @@
|
|||
<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("Hello");
|
||||
channel.port2.postMessage({ foo: channel2.port1 }, { transfer: [channel2.port1] });
|
||||
channel.port2.postMessage("DONE");
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue