mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 08:12:05 +00:00
Bug 1739779 - Check if the global is eligible for messaging before sending/receiving BroadcastChannel messages, r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D224030
This commit is contained in:
parent
a7281f816e
commit
ee1f5ecbde
@ -271,21 +271,17 @@ already_AddRefed<BroadcastChannel> BroadcastChannel::Constructor(
|
||||
void BroadcastChannel::PostMessage(JSContext* aCx,
|
||||
JS::Handle<JS::Value> aMessage,
|
||||
ErrorResult& aRv) {
|
||||
nsCOMPtr<nsIGlobalObject> global = GetOwnerGlobal();
|
||||
if (!global || !global->IsEligibleForMessaging()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mState != StateActive) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
Maybe<nsID> agentClusterId;
|
||||
nsCOMPtr<nsIGlobalObject> global = GetOwnerGlobal();
|
||||
MOZ_ASSERT(global);
|
||||
if (global) {
|
||||
agentClusterId = global->GetAgentClusterId();
|
||||
}
|
||||
|
||||
if (!global->IsEligibleForMessaging()) {
|
||||
return;
|
||||
}
|
||||
Maybe<nsID> agentClusterId = global->GetAgentClusterId();
|
||||
|
||||
RefPtr<SharedMessageBody> data = new SharedMessageBody(
|
||||
StructuredCloneHolder::TransferringNotSupported, agentClusterId);
|
||||
@ -364,6 +360,11 @@ void BroadcastChannel::DisconnectFromOwner() {
|
||||
}
|
||||
|
||||
void BroadcastChannel::MessageReceived(const MessageData& aData) {
|
||||
nsCOMPtr<nsIGlobalObject> global = GetOwnerGlobal();
|
||||
if (!global || !global->IsEligibleForMessaging()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (NS_FAILED(CheckCurrentGlobalCorrectness())) {
|
||||
RemoveDocFromBFCache();
|
||||
return;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user