Bug 1681457 - Allow non-auxiliary BrowsingContexts created by script to close themselves, r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D211792
This commit is contained in:
Nika Layzell
2024-05-31 17:27:15 +00:00
parent dbd72c849d
commit 7025bc892e
13 changed files with 88 additions and 25 deletions

View File

@@ -1056,7 +1056,8 @@ nsresult ContentChild::ProvideWindowCommon(
RefPtr<BrowsingContext> browsingContext = BrowsingContext::CreateDetached(
nullptr, openerBC, nullptr, aName, BrowsingContext::Type::Content,
aIsPopupRequested);
{.isPopupRequested = aIsPopupRequested,
.topLevelCreatedByWebContent = true});
MOZ_ALWAYS_SUCCEEDS(browsingContext->SetRemoteTabs(true));
MOZ_ALWAYS_SUCCEEDS(browsingContext->SetRemoteSubframes(useRemoteSubframes));
MOZ_ALWAYS_SUCCEEDS(browsingContext->SetOriginAttributes(
@@ -1181,9 +1182,11 @@ nsresult ContentChild::ProvideWindowCommon(
if (aForceNoOpener || !parent) {
MOZ_DIAGNOSTIC_ASSERT(!browsingContext->HadOriginalOpener());
MOZ_DIAGNOSTIC_ASSERT(browsingContext->GetTopLevelCreatedByWebContent());
MOZ_DIAGNOSTIC_ASSERT(browsingContext->GetOpenerId() == 0);
} else {
MOZ_DIAGNOSTIC_ASSERT(browsingContext->HadOriginalOpener());
MOZ_DIAGNOSTIC_ASSERT(browsingContext->GetTopLevelCreatedByWebContent());
MOZ_DIAGNOSTIC_ASSERT(browsingContext->GetOpenerId() == parent->Id());
}