mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-19 10:20:22 +00:00
One MessagePort can be entangled with another MessagePort, either in the same agent, or in another agent. In the same-agent case, the MessagePort objects point to each other via the MessagePort::m_remote_port field. In the separate-agent case, they live in separate processes entirely and thus can't point at each other. In both cases, the MessagePorts have an underlying transport channel, which means they are "entangled". However, we can't assume that being entangled means having a non-null m_remote_port. This patch simply adds a missing null check for m_remote_port and thus makes https://vscode.dev/ stop crashing with a null dereference.
27 lines
819 B
HTML
27 lines
819 B
HTML
<!doctype html>
|
|
<script src="../include.js"></script>
|
|
<script>
|
|
asyncTest(done => {
|
|
function onFirst(e) {
|
|
const port = (e.data && e.data.port) || (e.ports && e.ports[0]);
|
|
if (!port) return;
|
|
|
|
println("first receipt: re-transferring same port");
|
|
window.removeEventListener("message", onFirst);
|
|
window.addEventListener("message", onSecond);
|
|
window.postMessage({ port }, "*", [port]);
|
|
}
|
|
|
|
function onSecond(e) {
|
|
println("we good");
|
|
done();
|
|
}
|
|
|
|
window.addEventListener("message", onFirst);
|
|
|
|
const { port1, port2 } = new MessageChannel();
|
|
port1.onmessage = e => println("main saw: " + e.data);
|
|
|
|
window.postMessage({ port: port2 }, "*", [port2]);
|
|
});
|
|
</script>
|