diff --git a/dom/broadcastchannel/BroadcastChannel.cpp b/dom/broadcastchannel/BroadcastChannel.cpp index 5df8903a3dd9..fdfa6c8e1148 100644 --- a/dom/broadcastchannel/BroadcastChannel.cpp +++ b/dom/broadcastchannel/BroadcastChannel.cpp @@ -271,21 +271,17 @@ already_AddRefed BroadcastChannel::Constructor( void BroadcastChannel::PostMessage(JSContext* aCx, JS::Handle aMessage, ErrorResult& aRv) { + nsCOMPtr global = GetOwnerGlobal(); + if (!global || !global->IsEligibleForMessaging()) { + return; + } + if (mState != StateActive) { aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); return; } - Maybe agentClusterId; - nsCOMPtr global = GetOwnerGlobal(); - MOZ_ASSERT(global); - if (global) { - agentClusterId = global->GetAgentClusterId(); - } - - if (!global->IsEligibleForMessaging()) { - return; - } + Maybe agentClusterId = global->GetAgentClusterId(); RefPtr data = new SharedMessageBody( StructuredCloneHolder::TransferringNotSupported, agentClusterId); @@ -364,6 +360,11 @@ void BroadcastChannel::DisconnectFromOwner() { } void BroadcastChannel::MessageReceived(const MessageData& aData) { + nsCOMPtr global = GetOwnerGlobal(); + if (!global || !global->IsEligibleForMessaging()) { + return; + } + if (NS_FAILED(CheckCurrentGlobalCorrectness())) { RemoveDocFromBFCache(); return; diff --git a/testing/web-platform/meta/webmessaging/broadcastchannel/detached-iframe.html.ini b/testing/web-platform/meta/webmessaging/broadcastchannel/detached-iframe.html.ini index e6740f1a65b1..fb6c1f28f1fa 100644 --- a/testing/web-platform/meta/webmessaging/broadcastchannel/detached-iframe.html.ini +++ b/testing/web-platform/meta/webmessaging/broadcastchannel/detached-iframe.html.ini @@ -1,11 +1,3 @@ [detached-iframe.html] expected: if (os == "android") and fission: [OK, TIMEOUT] - [BroadcastChannel messages from detached iframe to parent should be ignored (BC created before detaching)] - expected: FAIL - - [BroadcastChannel messages within detached iframe should be ignored (BCs created before detaching)] - expected: FAIL - - [BroadcastChannel messages within detached iframe should be ignored (BCs created after detaching)] - expected: FAIL