";
window.addEventListener("message", t.step_func(e => {
assert_equals(e.data.workerMessageOrigin, "null");
assert_equals(e.data.messageOrigin, "null");
resolve();
}), {once: true});
t.add_cleanup(() => { document.body.removeChild(ifr) });
document.body.appendChild(ifr);
});
}, "Opaque origin should be serialized to \"null\"");
const iframe_src = (channel_name, iframe_name) => `data:text/html,`;
promise_test(t => {
return new Promise((resolve, reject) => {
const channel_name = "opaque-origin-test-2";
const bc1 = new BroadcastChannel(channel_name);
bc1.onmessage = t.unreached_func("Received message from an opaque origin");
// We'll create an iframe and have it send a BroadcastChannel message
// between two instances. Once the message is received, it will postMessage
// back and we'll repeat this with another iframe. If the first
// BroadcastChannel message is received by `bc1`, or if the second
// BroadcastChannel message is received by `bc1` or `bc2` in the first
// iframe, then the test should fail.
window.addEventListener("message", e => {
if(e.data == "iframe1-done") {
let iframe2 = document.createElement("iframe");
iframe2.src = iframe_src(channel_name, "iframe2");
t.add_cleanup(() => { document.body.removeChild(iframe2) });
document.body.appendChild(iframe2);
} else if(e.data == "iframe2-done") {
resolve();
} else if(e.data == "fail") {
reject("One opaque origin received a message from the other");
} else {
reject("An unexpected error occurred");
}
});
let iframe1 = document.createElement("iframe");
iframe1.src = iframe_src(channel_name, "iframe1");
t.add_cleanup(() => { document.body.removeChild(iframe1) });
document.body.appendChild(iframe1);
});
}, "BroadcastChannel messages from opaque origins should be self-contained");
//-->