creating a BroadcastChannel in a detached iframe #7219
Closed
Description
Currently the spec checks for a fully active context when determining which contexts should receive messages. See step 4 here:
https://html.spec.whatwg.org/#dom-broadcastchannel-postmessage
But it does not check for a fully active context when creating or sending a message. So in theory this should work:
<html>
<body>
<iframe id="iframe1" src="about:blank"></iframe>
<script>
var i_bc = iframe1.contentWindow.BroadcastChannel;
iframe1.remove();
a = new i_bc('test');
b = new BroadcastChannel('test');
b.onmessage = e => {alert(e)};
a.postMessage('asdf');
</script>
</body>
</html>
This feels a bit weird. Its also causing us implementation problems for our BroadcastChannel partitioning efforts.
Would other browsers be open to causing new BroadcastChannel()
to throw InvalidStateException? And bc.postMessage()
to have no effect?
Also note, it appears neither firefox or chrome currently prevent delivery of BC messages to detached iframes today. We would like to implement that as well.