mirror of
https://github.com/RGBCube/serenity
synced 2025-05-15 17:54:57 +00:00

This aligns Workers and Window and MessagePorts to all use the same mechanism for transferring serialized messages across realms. It also allows transferring more message ports into a worker. Re-enable the Worker-echo test, as none of the MessagePort tests have themselves been flaky, and those are now using the same underlying implementation.
14 lines
385 B
JavaScript
14 lines
385 B
JavaScript
let extraPort = null;
|
|
|
|
onmessage = evt => {
|
|
if (evt.ports.length > 0) {
|
|
extraPort = evt.ports[0];
|
|
extraPort.onmessage = evt => {
|
|
extraPort.postMessage("Extra Port got message: " + JSON.stringify(evt.data));
|
|
};
|
|
extraPort.postMessage("Worker got message port!");
|
|
} else {
|
|
postMessage(evt.data);
|
|
}
|
|
};
|
|
postMessage("loaded");
|