diff --git a/browser/base/content/tabbrowser.js b/browser/base/content/tabbrowser.js index 1d9f5eeb2ae8..b28ace56a3db 100644 --- a/browser/base/content/tabbrowser.js +++ b/browser/base/content/tabbrowser.js @@ -1970,6 +1970,7 @@ uriIsAboutBlank, userContextId, skipLoad, + initiallyActive, } = {}) { let b = document.createXULElement("browser"); // Use the JSM global to create the permanentKey, so that if the @@ -2002,6 +2003,10 @@ b.setAttribute(attribute, defaultBrowserAttributes[attribute]); } + if (!initiallyActive) { + b.setAttribute("initiallyactive", "false"); + } + if (userContextId) { b.setAttribute("usercontextid", userContextId); } diff --git a/docshell/base/BrowsingContext.cpp b/docshell/base/BrowsingContext.cpp index 421bf132a1c3..7e24ec241e36 100644 --- a/docshell/base/BrowsingContext.cpp +++ b/docshell/base/BrowsingContext.cpp @@ -344,8 +344,19 @@ already_AddRefed BrowsingContext::CreateDetached( } nsContentUtils::GenerateUUIDInPlace(fields.mHistoryID); - fields.mExplicitActive = - parentBC ? ExplicitActiveStatus::None : ExplicitActiveStatus::Active; + fields.mExplicitActive = [&] { + if (parentBC) { + // Non-root browsing-contexts inherit their status from its parent. + return ExplicitActiveStatus::None; + } + if (aType == Type::Content) { + // Content gets managed by the chrome front-end / embedder element and + // starts as inactive. + return ExplicitActiveStatus::Inactive; + } + // Chrome starts as active. + return ExplicitActiveStatus::Active; + }(); fields.mFullZoom = parentBC ? parentBC->FullZoom() : 1.0f; fields.mTextZoom = parentBC ? parentBC->TextZoom() : 1.0f; @@ -576,6 +587,14 @@ bool BrowsingContext::IsActive() const { return false; } +void BrowsingContext::SetInitiallyActive() { + MOZ_DIAGNOSTIC_ASSERT(!EverAttached()); + MOZ_DIAGNOSTIC_ASSERT(IsContent()); + MOZ_DIAGNOSTIC_ASSERT(IsTop()); + + mFields.SetWithoutSyncing(ExplicitActiveStatus::Active); +} + bool BrowsingContext::GetIsActiveBrowserWindow() { if (!XRE_IsParentProcess()) { return Top()->GetIsActiveBrowserWindowInternal(); @@ -633,8 +652,7 @@ void BrowsingContext::SetEmbedderElement(Element* aEmbedder) { if (XRE_IsParentProcess() && IsTopContent()) { nsAutoString messageManagerGroup; if (aEmbedder->IsXULElement()) { - aEmbedder->GetAttr(kNameSpaceID_None, nsGkAtoms::messagemanagergroup, - messageManagerGroup); + aEmbedder->GetAttr(nsGkAtoms::messagemanagergroup, messageManagerGroup); } txn.SetMessageManagerGroup(messageManagerGroup); diff --git a/docshell/base/BrowsingContext.h b/docshell/base/BrowsingContext.h index 4b09798e01f5..3058e49ad7c1 100644 --- a/docshell/base/BrowsingContext.h +++ b/docshell/base/BrowsingContext.h @@ -498,6 +498,8 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache { aRv); } + void SetInitiallyActive(); + bool AuthorStyleDisabledDefault() const { return GetAuthorStyleDisabledDefault(); } diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index 0de8a59b28f4..6ba4b2325574 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -3745,14 +3745,16 @@ bool nsFrameLoader::EnsureBrowsingContextAttached() { // Inherit the `use` flags from our parent BrowsingContext. bool usePrivateBrowsing = parentContext->UsePrivateBrowsing(); - bool useRemoteSubframes = parentContext->UseRemoteSubframes(); - bool useRemoteTabs = parentContext->UseRemoteTabs(); + const bool useRemoteSubframes = parentContext->UseRemoteSubframes(); + const bool useRemoteTabs = parentContext->UseRemoteTabs(); + + const bool isContent = mPendingBrowsingContext->IsContent(); // Determine the exact OriginAttributes which should be used for our // BrowsingContext. This will be used to initialize OriginAttributes if the // BrowsingContext has not already been created. OriginAttributes attrs; - if (mPendingBrowsingContext->IsContent()) { + if (isContent) { if (mPendingBrowsingContext->GetParent()) { MOZ_ASSERT(mPendingBrowsingContext->GetParent() == parentContext); parentContext->GetOriginAttributes(attrs); @@ -3784,8 +3786,7 @@ bool nsFrameLoader::EnsureBrowsingContextAttached() { //