Backed out 5 changesets (bug 1599579) for twinopen failures. CLOSED TREE
authorNarcis Beleuzu <nbeleuzu@mozilla.com>
Tue, 23 Jun 2020 02:23:48 +0300
changeset 536672 b1146cce5053bf690a8b19f8da7ca97b1f37438d
parent 536671 cf5c3215d284170b530470e4d6c79bfbaccca28e
child 536673 db4a486d69aca37f97be1d86e7933bbc124f82f1
push id119614
push usernbeleuzu@mozilla.com
push dateMon, 22 Jun 2020 23:25:09 +0000
treeherderautoland@b1146cce5053 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1599579
milestone79.0a1
backs out053229a30ef18e1896aa4dd88cee7183735a3c4f
c2828aec4cafaee2c906c082481cc5a5da8380c0
085558fe56dc2e2c6f234bcc2ab5923827985dce
a4e7334f8ce62b8f9a20a69c9f6f9c298a8fb854
9ebd2eb155da908ebaaf6835979193d9eeee3325
first release with
nightly linux32
b1146cce5053 / 79.0a1 / 20200623034439 / files
nightly linux64
b1146cce5053 / 79.0a1 / 20200623034439 / files
nightly mac
b1146cce5053 / 79.0a1 / 20200623034439 / files
nightly win32
b1146cce5053 / 79.0a1 / 20200623034439 / files
nightly win64
b1146cce5053 / 79.0a1 / 20200623034439 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out 5 changesets (bug 1599579) for twinopen failures. CLOSED TREE Backed out changeset 053229a30ef1 (bug 1599579) Backed out changeset c2828aec4caf (bug 1599579) Backed out changeset 085558fe56dc (bug 1599579) Backed out changeset a4e7334f8ce6 (bug 1599579) Backed out changeset 9ebd2eb155da (bug 1599579)
browser/components/extensions/test/browser/browser_ext_getViews.js
docshell/base/BrowsingContext.cpp
docshell/base/BrowsingContext.h
docshell/base/CanonicalBrowsingContext.cpp
docshell/base/CanonicalBrowsingContext.h
dom/base/nsFrameLoader.cpp
dom/base/nsFrameLoader.h
dom/base/nsFrameLoaderOwner.cpp
dom/base/nsFrameLoaderOwner.h
dom/chrome-webidl/BrowsingContext.webidl
dom/ipc/ContentChild.cpp
dom/ipc/WindowGlobalParent.h
netwerk/ipc/DocumentLoadListener.cpp
toolkit/components/extensions/WebExtensionPolicy.cpp
toolkit/components/extensions/WebExtensionPolicy.h
--- a/browser/components/extensions/test/browser/browser_ext_getViews.js
+++ b/browser/components/extensions/test/browser/browser_ext_getViews.js
@@ -7,18 +7,16 @@ function genericChecker() {
   let path = window.location.pathname;
   if (path.includes("popup")) {
     kind = "popup";
   } else if (path.includes("tab")) {
     kind = "tab";
   }
   window.kind = kind;
 
-  let bcGroupId = SpecialPowers.wrap(window).browsingContext.group.id;
-
   browser.test.onMessage.addListener((msg, ...args) => {
     if (msg == kind + "-check-views") {
       let counts = {
         background: 0,
         tab: 0,
         popup: 0,
         kind: 0,
       };
@@ -33,27 +31,16 @@ function genericChecker() {
         counts[view.kind]++;
         if (view.kind == "background") {
           browser.test.assertTrue(
             view === browser.extension.getBackgroundPage(),
             "background page is correct"
           );
           background = view;
         }
-
-        // FIXME(bug 1646817): Extension documents loaded outside of tabs don't
-        // perform process switches using DocumentLoadListener, meaning that
-        // they may have the wrong BrowsingContextGroup.
-        if (kind == "tab" && view.kind == "tab") {
-          browser.test.assertEq(
-            bcGroupId,
-            SpecialPowers.wrap(view).browsingContext.group.id,
-            "browsing context group is correct"
-          );
-        }
       }
       if (background) {
         browser.runtime.getBackgroundPage().then(view => {
           browser.test.assertEq(
             background,
             view,
             "runtime.getBackgroundPage() is correct"
           );
--- a/docshell/base/BrowsingContext.cpp
+++ b/docshell/base/BrowsingContext.cpp
@@ -184,18 +184,17 @@ bool BrowsingContext::SameOriginWithTop(
   nsIPrincipal* topPrincipal = topDoc->NodePrincipal();
 
   return principal->Equals(topPrincipal);
 }
 
 /* static */
 already_AddRefed<BrowsingContext> BrowsingContext::CreateDetached(
     nsGlobalWindowInner* aParent, BrowsingContext* aOpener,
-    BrowsingContextGroup* aSpecificGroup, const nsAString& aName, Type aType,
-    uint64_t aBrowserId) {
+    const nsAString& aName, Type aType, uint64_t aBrowserId) {
   if (aParent) {
     MOZ_DIAGNOSTIC_ASSERT(aParent->GetWindowContext());
     MOZ_DIAGNOSTIC_ASSERT(aParent->GetBrowsingContext()->mType == aType);
     MOZ_DIAGNOSTIC_ASSERT(aParent->GetBrowsingContext()->GetBrowserId() == 0 ||
                           aParent->GetBrowsingContext()->GetBrowserId() ==
                               aBrowserId);
   }
 
@@ -208,23 +207,20 @@ already_AddRefed<BrowsingContext> Browsi
            XRE_IsParentProcess() ? "Parent" : "Child"));
 
   RefPtr<BrowsingContext> parentBC =
       aParent ? aParent->GetBrowsingContext() : nullptr;
   RefPtr<WindowContext> parentWC =
       aParent ? aParent->GetWindowContext() : nullptr;
 
   // Determine which BrowsingContextGroup this context should be created in.
-  RefPtr<BrowsingContextGroup> group = aSpecificGroup;
-  if (aType == Type::Chrome) {
-    MOZ_DIAGNOSTIC_ASSERT(!group);
-    group = BrowsingContextGroup::GetChromeGroup();
-  } else if (!group) {
-    group = BrowsingContextGroup::Select(parentWC, aOpener);
-  }
+  RefPtr<BrowsingContextGroup> group =
+      (aType == Type::Chrome)
+          ? do_AddRef(BrowsingContextGroup::GetChromeGroup())
+          : BrowsingContextGroup::Select(parentWC, aOpener);
 
   RefPtr<BrowsingContext> context;
   if (XRE_IsParentProcess()) {
     context =
         new CanonicalBrowsingContext(parentWC, group, id,
                                      /* aOwnerProcessId */ 0,
                                      /* aEmbedderProcessId */ 0, aType, {});
   } else {
@@ -337,18 +333,18 @@ already_AddRefed<BrowsingContext> Browsi
 
   return context.forget();
 }
 
 already_AddRefed<BrowsingContext> BrowsingContext::CreateIndependent(
     Type aType) {
   uint64_t browserId =
       aType == Type::Content ? nsContentUtils::GenerateBrowserId() : 0;
-  RefPtr<BrowsingContext> bc(CreateDetached(nullptr, nullptr, nullptr,
-                                            EmptyString(), aType, browserId));
+  RefPtr<BrowsingContext> bc(
+      CreateDetached(nullptr, nullptr, EmptyString(), aType, browserId));
   bc->mWindowless = bc->IsContent();
   bc->EnsureAttached();
   return bc.forget();
 }
 
 void BrowsingContext::EnsureAttached() {
   if (!mEverAttached) {
     Register(this);
--- a/docshell/base/BrowsingContext.h
+++ b/docshell/base/BrowsingContext.h
@@ -200,18 +200,17 @@ class BrowsingContext : public nsILoadCo
   // Create a brand-new BrowsingContext object, but does not immediately attach
   // it. State such as OriginAttributes and PrivateBrowsingId may be customized
   // to configure the BrowsingContext before it is attached.
   //
   // `EnsureAttached()` must be called before the BrowsingContext is used for a
   // DocShell, BrowserParent, or BrowserBridgeChild.
   static already_AddRefed<BrowsingContext> CreateDetached(
       nsGlobalWindowInner* aParent, BrowsingContext* aOpener,
-      BrowsingContextGroup* aSpecificGroup, const nsAString& aName, Type aType,
-      uint64_t aBrowserId);
+      const nsAString& aName, Type aType, uint64_t aBrowserId);
 
   void EnsureAttached();
 
   bool EverAttached() const { return mEverAttached; }
 
   // Cast this object to a canonical browsing context, and return it.
   CanonicalBrowsingContext* Canonical();
 
--- a/docshell/base/CanonicalBrowsingContext.cpp
+++ b/docshell/base/CanonicalBrowsingContext.cpp
@@ -476,26 +476,21 @@ void CanonicalBrowsingContext::PendingRe
 
     // Some frontend code checks the value of the `remote` attribute on the
     // browser to determine if it is remote, so update the value.
     browserElement->SetAttr(
         kNameSpaceID_None, nsGkAtoms::remote,
         mContentParent ? NS_LITERAL_STRING("true") : NS_LITERAL_STRING("false"),
         /* notify */ true);
 
-    RefPtr<BrowsingContextGroup> specificGroup;
-    if (mSpecificGroupId != 0) {
-      specificGroup = BrowsingContextGroup::GetOrCreate(mSpecificGroupId);
-    }
-
     // The process has been created, hand off to nsFrameLoaderOwner to finish
     // the process switch.
     ErrorResult error;
-    frameLoaderOwner->ChangeRemotenessToProcess(
-        mContentParent, mReplaceBrowsingContext, specificGroup, error);
+    frameLoaderOwner->ChangeRemotenessToProcess(mContentParent,
+                                                mReplaceBrowsingContext, error);
     if (error.Failed()) {
       Cancel(error.StealNSResult());
       return;
     }
 
     // Tell frontend the load is done.
     bool loadResumed = false;
     rv = browser->FinishChangeRemoteness(mPendingSwitchId, &loadResumed);
@@ -671,43 +666,38 @@ void CanonicalBrowsingContext::PendingRe
 
   mPromise = nullptr;
   mTarget = nullptr;
   mPrepareToChangePromise = nullptr;
 }
 
 CanonicalBrowsingContext::PendingRemotenessChange::PendingRemotenessChange(
     CanonicalBrowsingContext* aTarget, RemotenessPromise::Private* aPromise,
-    uint64_t aPendingSwitchId, bool aReplaceBrowsingContext,
-    uint64_t aSpecificGroupId)
+    uint64_t aPendingSwitchId, bool aReplaceBrowsingContext)
     : mTarget(aTarget),
       mPromise(aPromise),
       mPendingSwitchId(aPendingSwitchId),
-      mSpecificGroupId(aSpecificGroupId),
       mReplaceBrowsingContext(aReplaceBrowsingContext) {}
 
 CanonicalBrowsingContext::PendingRemotenessChange::~PendingRemotenessChange() {
   MOZ_ASSERT(!mPromise && !mTarget,
              "should've already been Cancel() or Complete()-ed");
 }
 
 RefPtr<CanonicalBrowsingContext::RemotenessPromise>
 CanonicalBrowsingContext::ChangeRemoteness(const nsAString& aRemoteType,
                                            uint64_t aPendingSwitchId,
-                                           bool aReplaceBrowsingContext,
-                                           uint64_t aSpecificGroupId) {
+                                           bool aReplaceBrowsingContext) {
   MOZ_DIAGNOSTIC_ASSERT(IsContent(),
                         "cannot change the process of chrome contexts");
   MOZ_DIAGNOSTIC_ASSERT(
       IsTop() == IsEmbeddedInProcess(0),
       "toplevel content must be embedded in the parent process");
   MOZ_DIAGNOSTIC_ASSERT(!aReplaceBrowsingContext || IsTop(),
                         "Cannot replace BrowsingContext for subframes");
-  MOZ_DIAGNOSTIC_ASSERT(aSpecificGroupId == 0 || aReplaceBrowsingContext,
-                        "Cannot specify group ID unless replacing BC");
 
   // Ensure our embedder hasn't been destroyed already.
   RefPtr<WindowGlobalParent> embedderWindowGlobal = GetEmbedderWindowGlobal();
   if (!embedderWindowGlobal) {
     NS_WARNING("Non-embedded BrowsingContext");
     return RemotenessPromise::CreateAndReject(NS_ERROR_UNEXPECTED, __func__);
   }
 
@@ -750,19 +740,18 @@ CanonicalBrowsingContext::ChangeRemotene
     MOZ_DIAGNOSTIC_ASSERT(!aRemoteType.IsEmpty());
     SetOwnerProcessId(embedderBrowser->Manager()->ChildID());
     Unused << embedderWindowGlobal->SendMakeFrameLocal(this, aPendingSwitchId);
     return RemotenessPromise::CreateAndResolve(embedderBrowser, __func__);
   }
 
   // Switching to remote. Wait for new process to launch before switch.
   auto promise = MakeRefPtr<RemotenessPromise::Private>(__func__);
-  RefPtr<PendingRemotenessChange> change =
-      new PendingRemotenessChange(this, promise, aPendingSwitchId,
-                                  aReplaceBrowsingContext, aSpecificGroupId);
+  RefPtr<PendingRemotenessChange> change = new PendingRemotenessChange(
+      this, promise, aPendingSwitchId, aReplaceBrowsingContext);
   mPendingRemotenessChange = change;
 
   // Call `prepareToChangeRemoteness` in parallel with starting a new process
   // for <browser> loads.
   if (IsTop() && GetEmbedderElement()) {
     nsCOMPtr<nsIBrowser> browser = GetEmbedderElement()->AsBrowser();
     if (!browser) {
       change->Cancel(NS_ERROR_FAILURE);
--- a/docshell/base/CanonicalBrowsingContext.h
+++ b/docshell/base/CanonicalBrowsingContext.h
@@ -138,18 +138,17 @@ class CanonicalBrowsingContext final : p
   // Internal method to change which process a BrowsingContext is being loaded
   // in. The returned promise will resolve when the process switch is completed.
   //
   // A VoidString() aRemoteType argument will perform a process switch into the
   // parent process, and the method will resolve with a null BrowserParent.
   using RemotenessPromise = MozPromise<RefPtr<BrowserParent>, nsresult, false>;
   RefPtr<RemotenessPromise> ChangeRemoteness(const nsAString& aRemoteType,
                                              uint64_t aPendingSwitchId,
-                                             bool aReplaceBrowsingContext,
-                                             uint64_t aSpecificGroupId);
+                                             bool aReplaceBrowsingContext);
 
   // Return a media controller from the top-level browsing context that can
   // control all media belonging to this browsing context tree. Return nullptr
   // if the top-level browsing context has been discarded.
   MediaController* GetMediaController();
 
   bool AttemptLoadURIInParent(nsDocShellLoadState* aLoadState,
                               uint32_t* aLoadIdentifier);
@@ -193,18 +192,17 @@ class CanonicalBrowsingContext final : p
 
   class PendingRemotenessChange {
    public:
     NS_INLINE_DECL_REFCOUNTING(PendingRemotenessChange)
 
     PendingRemotenessChange(CanonicalBrowsingContext* aTarget,
                             RemotenessPromise::Private* aPromise,
                             uint64_t aPendingSwitchId,
-                            bool aReplaceBrowsingContext,
-                            uint64_t aSpecificGroupId);
+                            bool aReplaceBrowsingContext);
 
     void Cancel(nsresult aRv);
 
    private:
     friend class CanonicalBrowsingContext;
 
     ~PendingRemotenessChange();
     void ProcessReady();
@@ -212,17 +210,16 @@ class CanonicalBrowsingContext final : p
     void Clear();
 
     RefPtr<CanonicalBrowsingContext> mTarget;
     RefPtr<RemotenessPromise::Private> mPromise;
     RefPtr<GenericPromise> mPrepareToChangePromise;
     RefPtr<ContentParent> mContentParent;
 
     uint64_t mPendingSwitchId;
-    uint64_t mSpecificGroupId;
     bool mReplaceBrowsingContext;
   };
 
   friend class net::DocumentLoadListener;
   // Called when a DocumentLoadListener is created to start a load for
   // this browsing context.
   void StartDocumentLoad(net::DocumentLoadListener* aLoad);
   // Called once DocumentLoadListener completes handling a load, and it
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -261,20 +261,17 @@ static bool IsTopContent(BrowsingContext
 
   // If we're in a chrome context, we want to start a new tree if we are an
   // element with a `type="content"` marker.
   return aOwner->AttrValueIs(kNameSpaceID_None, TypeAttrName(aOwner),
                              nsGkAtoms::content, eIgnoreCase);
 }
 
 static already_AddRefed<BrowsingContext> CreateBrowsingContext(
-    Element* aOwner, nsIOpenWindowInfo* aOpenWindowInfo,
-    BrowsingContextGroup* aSpecificGroup) {
-  MOZ_ASSERT(!aOpenWindowInfo || !aSpecificGroup);
-
+    Element* aOwner, nsIOpenWindowInfo* aOpenWindowInfo) {
   // If we've got a pending BrowserParent from the content process, use the
   // BrowsingContext which was created for it.
   if (aOpenWindowInfo && aOpenWindowInfo->GetNextRemoteBrowser()) {
     MOZ_ASSERT(XRE_IsParentProcess());
     return do_AddRef(
         aOpenWindowInfo->GetNextRemoteBrowser()->GetBrowsingContext());
   }
 
@@ -324,33 +321,30 @@ static already_AddRefed<BrowsingContext>
       browserId = nsContentUtils::GenerateBrowserId();
       if (owner) {
         owner->SetBrowserId(browserId);
       }
     }
 
     // Create toplevel content without a parent & as Type::Content.
     return BrowsingContext::CreateDetached(
-        nullptr, opener, aSpecificGroup, frameName,
-        BrowsingContext::Type::Content, browserId);
+        nullptr, opener, frameName, BrowsingContext::Type::Content, browserId);
   }
 
   MOZ_ASSERT(!aOpenWindowInfo,
              "Can't have openWindowInfo for non-toplevel context");
 
   if (owner) {
     MOZ_DIAGNOSTIC_ASSERT(owner->GetBrowserId() == 0 ||
                           owner->GetBrowserId() == browserId);
     owner->SetBrowserId(browserId);
   }
 
-  MOZ_ASSERT(!aSpecificGroup,
-             "Can't force BrowsingContextGroup for non-toplevel context");
-  return BrowsingContext::CreateDetached(
-      parentInner, nullptr, nullptr, frameName, parentBC->GetType(), browserId);
+  return BrowsingContext::CreateDetached(parentInner, nullptr, frameName,
+                                         parentBC->GetType(), browserId);
 }
 
 static bool InitialLoadIsRemote(Element* aOwner) {
   if (PR_GetEnv("MOZ_DISABLE_OOP_TABS") ||
       Preferences::GetBool("dom.ipc.tabs.disabled", false)) {
     return false;
   }
 
@@ -441,50 +435,48 @@ already_AddRefed<nsFrameLoader> nsFrameL
   // since for a static document we know aOwner will end up in a document and
   // the nsFrameLoader will be used for its docShell.)
   //
   NS_ENSURE_TRUE(!doc->IsResourceDoc() &&
                      ((!doc->IsLoadedAsData() && aOwner->IsInComposedDoc()) ||
                       doc->IsStaticDocument()),
                  nullptr);
 
-  RefPtr<BrowsingContext> context = CreateBrowsingContext(
-      aOwner, aOpenWindowInfo, /* specificGroup */ nullptr);
+  RefPtr<BrowsingContext> context =
+      CreateBrowsingContext(aOwner, aOpenWindowInfo);
   NS_ENSURE_TRUE(context, nullptr);
 
   bool isRemoteFrame = InitialLoadIsRemote(aOwner);
   RefPtr<nsFrameLoader> fl =
       new nsFrameLoader(aOwner, context, isRemoteFrame, aNetworkCreated);
   fl->mOpenWindowInfo = aOpenWindowInfo;
   if (isRemoteFrame) {
     GetInitialRemoteTypeAndProcess(aOwner, fl->mRemoteType, &fl->mChildID);
   }
   return fl.forget();
 }
 
 /* static */
 already_AddRefed<nsFrameLoader> nsFrameLoader::Recreate(
-    mozilla::dom::Element* aOwner, BrowsingContext* aContext,
-    BrowsingContextGroup* aSpecificGroup, bool aIsRemote, bool aNetworkCreated,
-    bool aPreserveContext) {
+    mozilla::dom::Element* aOwner, BrowsingContext* aContext, bool aIsRemote,
+    bool aNetworkCreated, bool aPreserveContext) {
   NS_ENSURE_TRUE(aOwner, nullptr);
 
 #ifdef DEBUG
   // This version of Create is only called for Remoteness updates, so we can
   // assume we need a FrameLoader here and skip the check in the other Create.
   Document* doc = aOwner->OwnerDoc();
   MOZ_ASSERT(!doc->IsResourceDoc());
   MOZ_ASSERT((!doc->IsLoadedAsData() && aOwner->IsInComposedDoc()) ||
              doc->IsStaticDocument());
 #endif
 
   RefPtr<BrowsingContext> context = aContext;
   if (!context || !aPreserveContext) {
-    context = CreateBrowsingContext(aOwner, /* openWindowInfo */ nullptr,
-                                    aSpecificGroup);
+    context = CreateBrowsingContext(aOwner, /* openWindowInfo */ nullptr);
     if (aContext) {
       MOZ_ASSERT(
           XRE_IsParentProcess(),
           "Recreating browing contexts only supported in the parent process");
       aContext->Canonical()->ReplacedBy(context->Canonical());
     }
   }
   NS_ENSURE_TRUE(context, nullptr);
--- a/dom/base/nsFrameLoader.h
+++ b/dom/base/nsFrameLoader.h
@@ -94,29 +94,30 @@ class nsFrameLoader final : public nsStu
   friend class AutoResetInShow;
   friend class AutoResetInFrameSwap;
   friend class nsFrameLoaderOwner;
   typedef mozilla::dom::Document Document;
   typedef mozilla::dom::Element Element;
   typedef mozilla::dom::BrowserParent BrowserParent;
   typedef mozilla::dom::BrowserBridgeChild BrowserBridgeChild;
   typedef mozilla::dom::BrowsingContext BrowsingContext;
-  typedef mozilla::dom::BrowsingContextGroup BrowsingContextGroup;
 
  public:
   // Called by Frame Elements to create a new FrameLoader.
   static already_AddRefed<nsFrameLoader> Create(
       Element* aOwner, bool aNetworkCreated,
       nsIOpenWindowInfo* aOpenWindowInfo = nullptr);
 
   // Called by nsFrameLoaderOwner::ChangeRemoteness when switching out
   // FrameLoaders.
-  static already_AddRefed<nsFrameLoader> Recreate(
-      Element* aOwner, BrowsingContext* aContext, BrowsingContextGroup* aGroup,
-      bool aIsRemote, bool aNetworkCreated, bool aPreserveContext);
+  static already_AddRefed<nsFrameLoader> Recreate(Element* aOwner,
+                                                  BrowsingContext* aContext,
+                                                  bool aIsRemote,
+                                                  bool aNetworkCreated,
+                                                  bool aPreserveContext);
 
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_FRAMELOADER_IID)
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsFrameLoader)
 
   NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
   nsresult CheckForRecursiveLoad(nsIURI* aURI);
--- a/dom/base/nsFrameLoaderOwner.cpp
+++ b/dom/base/nsFrameLoaderOwner.cpp
@@ -81,20 +81,18 @@ nsFrameLoaderOwner::ShouldPreserveBrowsi
       StaticPrefs::fission_preserve_browsing_contexts()) {
     return ChangeRemotenessContextType::PRESERVE;
   }
   return ChangeRemotenessContextType::DONT_PRESERVE;
 }
 
 void nsFrameLoaderOwner::ChangeRemotenessCommon(
     const ChangeRemotenessContextType& aContextType,
-    bool aSwitchingInProgressLoad, bool aIsRemote, BrowsingContextGroup* aGroup,
+    bool aSwitchingInProgressLoad, bool aIsRemote,
     std::function<void()>& aFrameLoaderInit, mozilla::ErrorResult& aRv) {
-  MOZ_ASSERT_IF(aGroup, aContextType != ChangeRemotenessContextType::PRESERVE);
-
   RefPtr<mozilla::dom::BrowsingContext> bc;
   bool networkCreated = false;
 
   // In this case, we're not reparenting a frameloader, we're just destroying
   // our current one and creating a new one, so we can use ourselves as the
   // owner.
   RefPtr<Element> owner = do_QueryObject(this);
   MOZ_ASSERT(owner);
@@ -126,17 +124,17 @@ void nsFrameLoaderOwner::ChangeRemotenes
       // Preserve the networkCreated status, as nsDocShells created after a
       // process swap may shouldn't change their dynamically-created status.
       networkCreated = mFrameLoader->IsNetworkCreated();
       mFrameLoader->Destroy(aSwitchingInProgressLoad);
       mFrameLoader = nullptr;
     }
 
     mFrameLoader = nsFrameLoader::Recreate(
-        owner, bc, aGroup, aIsRemote, networkCreated,
+        owner, bc, aIsRemote, networkCreated,
         aContextType == ChangeRemotenessContextType::PRESERVE);
     if (NS_WARN_IF(!mFrameLoader)) {
       aRv.Throw(NS_ERROR_FAILURE);
       return;
     }
 
     // Invoke the frame loader initialization callback to perform setup on our
     // new nsFrameLoader. This may cause our ErrorResult to become errored, so
@@ -202,17 +200,17 @@ void nsFrameLoaderOwner::ChangeRemotenes
     } else {
       mFrameLoader->LoadFrame(false);
     }
   };
 
   auto shouldPreserve = ShouldPreserveBrowsingContext(
       isRemote, /* replaceBrowsingContext */ false);
   ChangeRemotenessCommon(shouldPreserve, aOptions.mSwitchingInProgressLoad,
-                         isRemote, /* group */ nullptr, frameLoaderInit, rv);
+                         isRemote, frameLoaderInit, rv);
 }
 
 void nsFrameLoaderOwner::ChangeRemotenessWithBridge(BrowserBridgeChild* aBridge,
                                                     mozilla::ErrorResult& rv) {
   MOZ_ASSERT(XRE_IsContentProcess());
   if (NS_WARN_IF(!mFrameLoader)) {
     rv.Throw(NS_ERROR_UNEXPECTED);
     return;
@@ -222,25 +220,23 @@ void nsFrameLoaderOwner::ChangeRemotenes
     RefPtr<BrowserBridgeHost> host = aBridge->FinishInit(mFrameLoader);
     mFrameLoader->mPendingBrowsingContext->SetEmbedderElement(
         mFrameLoader->GetOwnerContent());
     mFrameLoader->mRemoteBrowser = host;
   };
 
   ChangeRemotenessCommon(ChangeRemotenessContextType::PRESERVE,
                          /* inProgress */ true,
-                         /* isRemote */ true, /* group */ nullptr,
-                         frameLoaderInit, rv);
+                         /* isRemote */ true, frameLoaderInit, rv);
 }
 
 void nsFrameLoaderOwner::ChangeRemotenessToProcess(
     ContentParent* aContentParent, bool aReplaceBrowsingContext,
-    BrowsingContextGroup* aGroup, mozilla::ErrorResult& rv) {
+    mozilla::ErrorResult& rv) {
   MOZ_ASSERT(XRE_IsParentProcess());
-  MOZ_ASSERT_IF(aGroup, aReplaceBrowsingContext);
   bool isRemote = aContentParent != nullptr;
 
   std::function<void()> frameLoaderInit = [&] {
     if (isRemote) {
       mFrameLoader->ConfigRemoteProcess(aContentParent->GetRemoteType(),
                                         aContentParent);
     }
 
@@ -252,17 +248,17 @@ void nsFrameLoaderOwner::ChangeRemotenes
     // behaviour, and <browser> elements created by tabbrowser don't have the
     // `src` attribute specified.
     mFrameLoader->LoadFrame(false);
   };
 
   auto shouldPreserve =
       ShouldPreserveBrowsingContext(isRemote, aReplaceBrowsingContext);
   ChangeRemotenessCommon(shouldPreserve, /* inProgress */ true, isRemote,
-                         aGroup, frameLoaderInit, rv);
+                         frameLoaderInit, rv);
 }
 
 void nsFrameLoaderOwner::SubframeCrashed() {
   MOZ_ASSERT(XRE_IsContentProcess());
 
   std::function<void()> frameLoaderInit = [&] {
     RefPtr<nsFrameLoader> frameLoader = mFrameLoader;
     nsContentUtils::AddScriptRunner(NS_NewRunnableFunction(
@@ -280,17 +276,17 @@ void nsFrameLoaderOwner::SubframeCrashed
           }
           bool displayed = false;
           docShell->DisplayLoadError(NS_ERROR_FRAME_CRASHED, uri,
                                      u"about:blank", nullptr, &displayed);
         }));
   };
 
   ChangeRemotenessCommon(ChangeRemotenessContextType::PRESERVE,
-                         /* inProgress */ false, /* isRemote */ false,
-                         /* group */ nullptr, frameLoaderInit, IgnoreErrors());
+                         /* inProgress */ false,
+                         /* isRemote */ false, frameLoaderInit, IgnoreErrors());
 }
 
 void nsFrameLoaderOwner::UnbindFromTree() {
   // If we're being adopted into a different document, we'll want to inherit a
   // browser ID from our new BrowsingContext, so clear our current ID here.
   mBrowserId = 0;
 }
--- a/dom/base/nsFrameLoaderOwner.h
+++ b/dom/base/nsFrameLoaderOwner.h
@@ -65,17 +65,16 @@ class nsFrameLoaderOwner : public nsISup
   // Like `ChangeRemoteness`, but switches into an already-created
   // `ContentParent`. This method is used when performing toplevel process
   // switches. If `aContentParent` is nullptr, switches into the parent process.
   //
   // If `aReplaceBrowsingContext` is set, BrowsingContext preservation will be
   // disabled for this process switch.
   void ChangeRemotenessToProcess(mozilla::dom::ContentParent* aContentParent,
                                  bool aReplaceBrowsingContext,
-                                 mozilla::dom::BrowsingContextGroup* aGroup,
                                  mozilla::ErrorResult& rv);
 
   void SubframeCrashed();
 
   // Prepare for a frame to be removed from its current DOM tree.
   void UnbindFromTree();
 
   uint64_t GetBrowserId() { return mBrowserId; }
@@ -94,17 +93,16 @@ class nsFrameLoaderOwner : public nsISup
     DONT_PRESERVE = 0,
     PRESERVE = 1,
   };
   ChangeRemotenessContextType ShouldPreserveBrowsingContext(
       bool aIsRemote, bool aReplaceBrowsingContext);
 
   void ChangeRemotenessCommon(const ChangeRemotenessContextType& aContextType,
                               bool aSwitchingInProgressLoad, bool aIsRemote,
-                              mozilla::dom::BrowsingContextGroup* aGroup,
                               std::function<void()>& aFrameLoaderInit,
                               mozilla::ErrorResult& aRv);
 
   uint64_t mBrowserId = 0;
 
  protected:
   virtual ~nsFrameLoaderOwner() = default;
   RefPtr<nsFrameLoader> mFrameLoader;
--- a/dom/chrome-webidl/BrowsingContext.webidl
+++ b/dom/chrome-webidl/BrowsingContext.webidl
@@ -172,11 +172,9 @@ interface CanonicalBrowsingContext : Bro
   readonly attribute nsISHistory? sessionHistory;
 
   readonly attribute MediaController? mediaController;
 };
 
 [Exposed=Window, ChromeOnly]
 interface BrowsingContextGroup {
   sequence<BrowsingContext> getToplevels();
-
-  readonly attribute unsigned long long id;
 };
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -946,18 +946,17 @@ nsresult ContentChild::ProvideWindowComm
   // proper TabGroup for that actor.
   RefPtr<BrowsingContext> openerBC;
   if (!aForceNoOpener) {
     openerBC = parent;
   }
 
   uint64_t browserId(nsContentUtils::GenerateBrowserId());
   RefPtr<BrowsingContext> browsingContext = BrowsingContext::CreateDetached(
-      nullptr, openerBC, nullptr, aName, BrowsingContext::Type::Content,
-      browserId);
+      nullptr, openerBC, aName, BrowsingContext::Type::Content, browserId);
   MOZ_ALWAYS_SUCCEEDS(browsingContext->SetRemoteTabs(true));
   MOZ_ALWAYS_SUCCEEDS(browsingContext->SetRemoteSubframes(useRemoteSubframes));
   MOZ_ALWAYS_SUCCEEDS(browsingContext->SetOriginAttributes(
       aOpenWindowInfo->GetOriginAttributes()));
   browsingContext->EnsureAttached();
 
   browsingContext->SetPendingInitialization(true);
   auto unsetPending = MakeScopeExit([browsingContext]() {
--- a/dom/ipc/WindowGlobalParent.h
+++ b/dom/ipc/WindowGlobalParent.h
@@ -191,19 +191,18 @@ class WindowGlobalParent final : public 
 
   uint32_t HttpsOnlyStatus() { return mHttpsOnlyStatus; }
 
   void AddMixedContentSecurityState(uint32_t aStateFlags);
   uint32_t GetMixedContentSecurityFlags() { return mMixedContentSecurityState; }
 
   nsITransportSecurityInfo* GetSecurityInfo() { return mSecurityInfo; }
 
+ protected:
   const nsAString& GetRemoteType() override;
-
- protected:
   JSActor::Type GetSide() override { return JSActor::Type::Parent; }
 
   // IPC messages
   mozilla::ipc::IPCResult RecvLoadURI(
       const MaybeDiscarded<dom::BrowsingContext>& aTargetBC,
       nsDocShellLoadState* aLoadState, bool aSetNavigating);
   mozilla::ipc::IPCResult RecvInternalLoad(
       const MaybeDiscarded<dom::BrowsingContext>& aTargetBC,
--- a/netwerk/ipc/DocumentLoadListener.cpp
+++ b/netwerk/ipc/DocumentLoadListener.cpp
@@ -39,17 +39,16 @@
 #include "nsMimeTypes.h"
 #include "nsRedirectHistoryEntry.h"
 #include "nsSandboxFlags.h"
 #include "nsURILoader.h"
 #include "nsWebNavigationInfo.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/RemoteWebProgress.h"
 #include "mozilla/dom/RemoteWebProgressRequest.h"
-#include "mozilla/ExtensionPolicyService.h"
 
 #ifdef ANDROID
 #  include "mozilla/widget/nsWindow.h"
 #endif /* ANDROID */
 
 mozilla::LazyLogModule gDocumentChannelLog("DocumentChannel");
 #define LOG(fmt) MOZ_LOG(gDocumentChannelLog, mozilla::LogLevel::Verbose, fmt)
 
@@ -1110,41 +1109,52 @@ static bool IsLargeAllocationLoad(Canoni
   // and has to be force-enabled using `dom.largeAllocation.forceEnable`.
 #if defined(XP_WIN) && defined(_X86_)
   return true;
 #else
   return StaticPrefs::dom_largeAllocation_forceEnable();
 #endif
 }
 
-static bool ContextCanProcessSwitch(
-    CanonicalBrowsingContext* aBrowsingContext) {
-  if (NS_WARN_IF(!aBrowsingContext)) {
+bool DocumentLoadListener::MaybeTriggerProcessSwitch(
+    bool* aWillSwitchToRemote) {
+  MOZ_ASSERT(XRE_IsParentProcess());
+  MOZ_DIAGNOSTIC_ASSERT(!mDoingProcessSwitch,
+                        "Already in the middle of switching?");
+  MOZ_DIAGNOSTIC_ASSERT(mChannel);
+  MOZ_DIAGNOSTIC_ASSERT(mParentChannelListener);
+  MOZ_DIAGNOSTIC_ASSERT(aWillSwitchToRemote);
+
+  LOG(("DocumentLoadListener MaybeTriggerProcessSwitch [this=%p]", this));
+
+  // Get the BrowsingContext which will be switching processes.
+  RefPtr<CanonicalBrowsingContext> browsingContext =
+      mParentChannelListener->GetBrowsingContext();
+  if (NS_WARN_IF(!browsingContext)) {
     LOG(("Process Switch Abort: no browsing context"));
     return false;
   }
-  if (!aBrowsingContext->IsContent()) {
+  if (!browsingContext->IsContent()) {
     LOG(("Process Switch Abort: non-content browsing context"));
     return false;
   }
-  if (aBrowsingContext->GetParent() &&
-      !aBrowsingContext->UseRemoteSubframes()) {
+  if (browsingContext->GetParent() && !browsingContext->UseRemoteSubframes()) {
     LOG(("Process Switch Abort: remote subframes disabled"));
     return false;
   }
 
-  if (aBrowsingContext->GetParentWindowContext() &&
-      aBrowsingContext->GetParentWindowContext()->IsInProcess()) {
+  if (browsingContext->GetParentWindowContext() &&
+      browsingContext->GetParentWindowContext()->IsInProcess()) {
     LOG(("Process Switch Abort: Subframe with in-process parent"));
     return false;
   }
 
   // Determine what process switching behaviour is being requested by the root
   // <browser> element.
-  Element* browserElement = aBrowsingContext->Top()->GetEmbedderElement();
+  Element* browserElement = browsingContext->Top()->GetEmbedderElement();
   if (!browserElement) {
     LOG(("Process Switch Abort: cannot get embedder element"));
     return false;
   }
   nsCOMPtr<nsIBrowser> browser = browserElement->AsBrowser();
   if (!browser) {
     LOG(("Process Switch Abort: not loaded within nsIBrowser"));
     return false;
@@ -1161,202 +1171,142 @@ static bool ContextCanProcessSwitch(
   }
 
   // Check if the process switch we're considering is disabled by the
   // <browser>'s process behavior.
   if (processBehavior == nsIBrowser::PROCESS_BEHAVIOR_DISABLED) {
     LOG(("Process Switch Abort: switch disabled by <browser>"));
     return false;
   }
-  if (aBrowsingContext->IsTop() &&
+  if (browsingContext->IsTop() &&
       processBehavior == nsIBrowser::PROCESS_BEHAVIOR_SUBFRAME_ONLY) {
     LOG(("Process Switch Abort: toplevel switch disabled by <browser>"));
     return false;
   }
 
-  return true;
-}
+  bool isPreloadSwitch = false;
+  nsAutoString isPreloadBrowserStr;
+  if (browserElement->GetAttr(kNameSpaceID_None, nsGkAtoms::preloadedState,
+                              isPreloadBrowserStr) &&
+      isPreloadBrowserStr.EqualsLiteral("consumed")) {
+    nsCOMPtr<nsIURI> originalURI;
+    if (NS_SUCCEEDED(mChannel->GetOriginalURI(getter_AddRefs(originalURI))) &&
+        !originalURI->GetSpecOrDefault().EqualsLiteral("about:newtab")) {
+      LOG(("Process Switch: leaving preloaded browser"));
+      isPreloadSwitch = true;
+      browserElement->UnsetAttr(kNameSpaceID_None, nsGkAtoms::preloadedState,
+                                true);
+    }
+  }
 
-bool DocumentLoadListener::MaybeTriggerProcessSwitch(
-    bool* aWillSwitchToRemote) {
-  MOZ_ASSERT(XRE_IsParentProcess());
-  MOZ_DIAGNOSTIC_ASSERT(!mDoingProcessSwitch,
-                        "Already in the middle of switching?");
-  MOZ_DIAGNOSTIC_ASSERT(mChannel);
-  MOZ_DIAGNOSTIC_ASSERT(mParentChannelListener);
-  MOZ_DIAGNOSTIC_ASSERT(aWillSwitchToRemote);
-
-  LOG(("DocumentLoadListener MaybeTriggerProcessSwitch [this=%p]", this));
-
-  // Get the BrowsingContext which will be switching processes.
-  RefPtr<CanonicalBrowsingContext> browsingContext =
-      mParentChannelListener->GetBrowsingContext();
-  if (!ContextCanProcessSwitch(browsingContext)) {
-    return false;
+  // Get information about the current document loaded in our BrowsingContext.
+  nsCOMPtr<nsIPrincipal> currentPrincipal;
+  if (RefPtr<WindowGlobalParent> wgp =
+          browsingContext->GetCurrentWindowGlobal()) {
+    currentPrincipal = wgp->DocumentPrincipal();
   }
+  RefPtr<ContentParent> contentParent = browsingContext->GetContentParent();
+  MOZ_ASSERT(!OtherPid() || contentParent,
+             "Only PPDC is allowed to not have an existing ContentParent");
 
   // Get the final principal, used to select which process to load into.
   nsCOMPtr<nsIPrincipal> resultPrincipal;
-  nsresult rv = nsContentUtils::GetSecurityManager()->GetChannelResultPrincipal(
+  rv = nsContentUtils::GetSecurityManager()->GetChannelResultPrincipal(
       mChannel, getter_AddRefs(resultPrincipal));
   if (NS_FAILED(rv)) {
     LOG(("Process Switch Abort: failed to get channel result principal"));
     return false;
   }
 
-  nsAutoString currentRemoteType(VoidString());
-  if (RefPtr<ContentParent> contentParent =
-          browsingContext->GetContentParent()) {
-    currentRemoteType = contentParent->GetRemoteType();
-  }
-  MOZ_ASSERT_IF(currentRemoteType.IsEmpty(), !OtherPid());
-
-  // Determine what type of content process this load should finish in.
-  nsAutoString preferredRemoteType(currentRemoteType);
-  bool replaceBrowsingContext = false;
-  uint64_t specificGroupId = 0;
-
-  // If we're in a preloaded browser, force browsing context replacement to
-  // ensure the current process is re-selected.
-  {
-    Element* browserElement = browsingContext->Top()->GetEmbedderElement();
-
-    nsAutoString isPreloadBrowserStr;
-    if (browserElement->GetAttr(kNameSpaceID_None, nsGkAtoms::preloadedState,
-                                isPreloadBrowserStr) &&
-        isPreloadBrowserStr.EqualsLiteral("consumed")) {
-      nsCOMPtr<nsIURI> originalURI;
-      if (NS_SUCCEEDED(mChannel->GetOriginalURI(getter_AddRefs(originalURI))) &&
-          !originalURI->GetSpecOrDefault().EqualsLiteral("about:newtab")) {
-        LOG(("Process Switch: leaving preloaded browser"));
-        replaceBrowsingContext = true;
-        browserElement->UnsetAttr(kNameSpaceID_None, nsGkAtoms::preloadedState,
-                                  true);
-      }
-    }
+  // Determine our COOP status, which will be used to determine our preferred
+  // remote type.
+  bool isCOOPSwitch = HasCrossOriginOpenerPolicyMismatch();
+  nsILoadInfo::CrossOriginOpenerPolicy coop =
+      nsILoadInfo::OPENER_POLICY_UNSAFE_NONE;
+  if (!browsingContext->IsTop()) {
+    coop = browsingContext->Top()->GetOpenerPolicy();
+  } else if (nsCOMPtr<nsIHttpChannelInternal> httpChannel =
+                 do_QueryInterface(mChannel)) {
+    MOZ_ALWAYS_SUCCEEDS(httpChannel->GetCrossOriginOpenerPolicy(&coop));
   }
 
-  // Update the preferred final process for our load based on the
-  // Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy headers.
-  {
-    bool isCOOPSwitch = HasCrossOriginOpenerPolicyMismatch();
-    replaceBrowsingContext |= isCOOPSwitch;
-
-    // Determine our COOP status, which will be used to determine our preferred
-    // remote type.
-    nsILoadInfo::CrossOriginOpenerPolicy coop =
-        nsILoadInfo::OPENER_POLICY_UNSAFE_NONE;
-    if (!browsingContext->IsTop()) {
-      coop = browsingContext->Top()->GetOpenerPolicy();
-    } else if (nsCOMPtr<nsIHttpChannelInternal> httpChannel =
-                   do_QueryInterface(mChannel)) {
-      MOZ_ALWAYS_SUCCEEDS(httpChannel->GetCrossOriginOpenerPolicy(&coop));
-    }
-
-    if (coop ==
-        nsILoadInfo::OPENER_POLICY_SAME_ORIGIN_EMBEDDER_POLICY_REQUIRE_CORP) {
-      // We want documents with SAME_ORIGIN_EMBEDDER_POLICY_REQUIRE_CORP COOP
-      // policy to be loaded in a separate process in which we can enable
-      // high-resolution timers.
-      nsAutoCString siteOrigin;
-      resultPrincipal->GetSiteOrigin(siteOrigin);
-      preferredRemoteType =
-          NS_LITERAL_STRING(WITH_COOP_COEP_REMOTE_TYPE_PREFIX);
-      AppendUTF8toUTF16(siteOrigin, preferredRemoteType);
-    } else if (isCOOPSwitch) {
-      // If we're doing a COOP switch, we do not need any affinity to the
-      // current remote type. Clear it back to the default value.
-      preferredRemoteType = NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE);
-    }
+  nsAutoString currentRemoteType;
+  if (contentParent) {
+    currentRemoteType = contentParent->GetRemoteType();
+  } else {
+    currentRemoteType = VoidString();
   }
+  nsAutoString preferredRemoteType = currentRemoteType;
 
   // If we're performing a large allocation load, override the remote type
   // with `LARGE_ALLOCATION_REMOTE_TYPE` to move it into an exclusive content
   // process. If we're already in one, and don't otherwise we force ourselves
   // out of that content process.
+  bool isLargeAllocSwitch = false;
   if (browsingContext->IsTop() &&
       browsingContext->Group()->Toplevels().Length() == 1) {
     if (IsLargeAllocationLoad(browsingContext, mChannel)) {
-      preferredRemoteType = NS_LITERAL_STRING(LARGE_ALLOCATION_REMOTE_TYPE);
-      replaceBrowsingContext = true;
+      preferredRemoteType.Assign(
+          NS_LITERAL_STRING(LARGE_ALLOCATION_REMOTE_TYPE));
+      isLargeAllocSwitch = true;
     } else if (preferredRemoteType.EqualsLiteral(
                    LARGE_ALLOCATION_REMOTE_TYPE)) {
-      preferredRemoteType = NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE);
-      replaceBrowsingContext = true;
+      preferredRemoteType.Assign(NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE));
+      isLargeAllocSwitch = true;
     }
   }
 
-  // Put toplevel BrowsingContexts which load within the extension process into
-  // a specific BrowsingContextGroup.
-  if (auto* addonPolicy = BasePrincipal::Cast(resultPrincipal)->AddonPolicy()) {
-    if (browsingContext->IsTop()) {
-      // Toplevel extension BrowsingContexts must be loaded in the extension
-      // browsing context group, within the extension content process.
-      if (ExtensionPolicyService::GetSingleton().UseRemoteExtensions()) {
-        preferredRemoteType = NS_LITERAL_STRING(EXTENSION_REMOTE_TYPE);
-      } else {
-        preferredRemoteType = VoidString();
-      }
-
-      if (browsingContext->Group()->Id() !=
-          addonPolicy->GetBrowsingContextGroupId()) {
-        replaceBrowsingContext = true;
-        specificGroupId = addonPolicy->GetBrowsingContextGroupId();
-      }
-    } else {
-      // As a temporary measure, extension iframes must be loaded within the
-      // same process as their parent document.
-      preferredRemoteType =
-          browsingContext->GetParentWindowContext()->GetRemoteType();
-    }
+  if (coop ==
+      nsILoadInfo::OPENER_POLICY_SAME_ORIGIN_EMBEDDER_POLICY_REQUIRE_CORP) {
+    // We want documents with SAME_ORIGIN_EMBEDDER_POLICY_REQUIRE_CORP COOP
+    // policy to be loaded in a separate process in which we can enable
+    // high-resolution timers.
+    nsAutoCString siteOrigin;
+    resultPrincipal->GetSiteOrigin(siteOrigin);
+    preferredRemoteType.Assign(
+        NS_LITERAL_STRING(WITH_COOP_COEP_REMOTE_TYPE_PREFIX));
+    preferredRemoteType.Append(NS_ConvertUTF8toUTF16(siteOrigin));
+  } else if (isCOOPSwitch) {
+    // If we're doing a COOP switch, we do not need any affinity to the current
+    // remote type. Clear it back to the default value.
+    preferredRemoteType.Assign(NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE));
   }
+  MOZ_DIAGNOSTIC_ASSERT(!contentParent || !preferredRemoteType.IsEmpty(),
+                        "Unexpected empty remote type!");
 
   LOG(
       ("DocumentLoadListener GetRemoteTypeForPrincipal "
        "[this=%p, contentParent=%s, preferredRemoteType=%s]",
        this, NS_ConvertUTF16toUTF8(currentRemoteType).get(),
        NS_ConvertUTF16toUTF8(preferredRemoteType).get()));
 
   nsCOMPtr<nsIE10SUtils> e10sUtils =
       do_ImportModule("resource://gre/modules/E10SUtils.jsm", "E10SUtils");
   if (!e10sUtils) {
     LOG(("Process Switch Abort: Could not import E10SUtils"));
     return false;
   }
 
-  // Get information about the current document loaded in our BrowsingContext.
-  nsCOMPtr<nsIPrincipal> currentPrincipal;
-  if (auto* wgp = browsingContext->GetCurrentWindowGlobal()) {
-    currentPrincipal = wgp->DocumentPrincipal();
-  }
-
   nsAutoString remoteType;
   rv = e10sUtils->GetRemoteTypeForPrincipal(
       resultPrincipal, mChannelCreationURI, browsingContext->UseRemoteTabs(),
       browsingContext->UseRemoteSubframes(), preferredRemoteType,
       currentPrincipal, browsingContext->GetParent(), remoteType);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     LOG(("Process Switch Abort: getRemoteTypeForPrincipal threw an exception"));
     return false;
   }
 
-  // If the final decision is to switch from an 'extension' remote type to any
-  // other remote type, ensure the browsing context is replaced so that we leave
-  // the extension-specific BrowsingContextGroup.
-  if (browsingContext->IsTop() && currentRemoteType != remoteType &&
-      currentRemoteType.EqualsLiteral(EXTENSION_REMOTE_TYPE)) {
-    replaceBrowsingContext = true;
-  }
-
   LOG(("GetRemoteTypeForPrincipal -> current:%s remoteType:%s",
        NS_ConvertUTF16toUTF8(currentRemoteType).get(),
        NS_ConvertUTF16toUTF8(remoteType).get()));
 
   // Check if a process switch is needed.
-  if (currentRemoteType == remoteType && !replaceBrowsingContext) {
+  if (currentRemoteType == remoteType && !isCOOPSwitch && !isPreloadSwitch &&
+      !isLargeAllocSwitch) {
     LOG(("Process Switch Abort: type (%s) is compatible",
          NS_ConvertUTF16toUTF8(remoteType).get()));
     return false;
   }
   if (NS_WARN_IF(remoteType.IsEmpty())) {
     LOG(("Process Switch Abort: non-remote target process"));
     return false;
   }
@@ -1370,17 +1320,17 @@ bool DocumentLoadListener::MaybeTriggerP
   // XXX: This is super hacky, and we should be able to do something better.
   static uint64_t sNextCrossProcessRedirectIdentifier = 0;
   mCrossProcessRedirectIdentifier = ++sNextCrossProcessRedirectIdentifier;
   mDoingProcessSwitch = true;
 
   LOG(("Process Switch: Calling ChangeRemoteness"));
   browsingContext
       ->ChangeRemoteness(remoteType, mCrossProcessRedirectIdentifier,
-                         replaceBrowsingContext, specificGroupId)
+                         isCOOPSwitch || isLargeAllocSwitch)
       ->Then(
           GetMainThreadSerialEventTarget(), __func__,
           [self = RefPtr{this}](BrowserParent* aBrowserParent) {
             MOZ_DIAGNOSTIC_ASSERT(
                 aBrowserParent,
                 "Shouldn't have switched into the parent process, as we check "
                 "!remoteType.IsEmpty() earlier in MaybeTriggerProcessSwitch");
             MOZ_ASSERT(self->mChannel,
--- a/toolkit/components/extensions/WebExtensionPolicy.cpp
+++ b/toolkit/components/extensions/WebExtensionPolicy.cpp
@@ -6,17 +6,16 @@
 #include "mozilla/ExtensionPolicyService.h"
 #include "mozilla/extensions/DocumentObserver.h"
 #include "mozilla/extensions/WebExtensionContentScript.h"
 #include "mozilla/extensions/WebExtensionPolicy.h"
 
 #include "mozilla/AddonManagerWebAPI.h"
 #include "mozilla/ResultExtensions.h"
 #include "mozilla/StaticPrefs_extensions.h"
-#include "nsContentUtils.h"
 #include "nsEscape.h"
 #include "nsIObserver.h"
 #include "nsISubstitutingProtocolHandler.h"
 #include "nsNetUtil.h"
 #include "nsPrintfCString.h"
 
 namespace mozilla {
 namespace extensions {
@@ -244,21 +243,16 @@ void WebExtensionPolicy::SetActive(bool 
 
 bool WebExtensionPolicy::Enable() {
   MOZ_ASSERT(!mActive);
 
   if (!EPS().RegisterExtension(*this)) {
     return false;
   }
 
-  if (XRE_IsParentProcess()) {
-    // Reserve a BrowsingContextGroup ID for use by this WebExtensionPolicy.
-    mBrowsingContextGroupId = nsContentUtils::GenerateBrowsingContextId();
-  }
-
   Unused << Proto()->SetSubstitution(MozExtensionHostname(), mBaseURI);
 
   mActive = true;
   return true;
 }
 
 bool WebExtensionPolicy::Disable() {
   MOZ_ASSERT(mActive);
@@ -486,21 +480,16 @@ void WebExtensionPolicy::GetReadyPromise
     JSContext* aCx, JS::MutableHandleObject aResult) const {
   if (mReadyPromise) {
     aResult.set(mReadyPromise->PromiseObj());
   } else {
     aResult.set(nullptr);
   }
 }
 
-uint64_t WebExtensionPolicy::GetBrowsingContextGroupId() const {
-  MOZ_ASSERT(XRE_IsParentProcess() && mActive);
-  return mBrowsingContextGroupId;
-}
-
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_WEAK_PTR(WebExtensionPolicy, mParent,
                                                mLocalizeCallback,
                                                mHostPermissions,
                                                mWebAccessiblePaths,
                                                mContentScripts)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WebExtensionPolicy)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
--- a/toolkit/components/extensions/WebExtensionPolicy.h
+++ b/toolkit/components/extensions/WebExtensionPolicy.h
@@ -137,18 +137,16 @@ class WebExtensionPolicy final : public 
 
   bool CanAccessContext(nsILoadContext* aContext) const;
 
   bool CanAccessWindow(const dom::WindowProxyHolder& aWindow) const;
 
   void GetReadyPromise(JSContext* aCx, JS::MutableHandleObject aResult) const;
   dom::Promise* ReadyPromise() const { return mReadyPromise; }
 
-  uint64_t GetBrowsingContextGroupId() const;
-
   static void GetActiveExtensions(
       dom::GlobalObject& aGlobal,
       nsTArray<RefPtr<WebExtensionPolicy>>& aResults);
 
   static already_AddRefed<WebExtensionPolicy> GetByID(
       dom::GlobalObject& aGlobal, const nsAString& aID);
 
   static already_AddRefed<WebExtensionPolicy> GetByHostname(
@@ -184,18 +182,16 @@ class WebExtensionPolicy final : public 
   RefPtr<nsAtom> mId;
   nsCString mHostname;
   nsCOMPtr<nsIURI> mBaseURI;
 
   nsString mName;
   nsString mExtensionPageCSP;
   nsString mContentScriptCSP;
 
-  uint64_t mBrowsingContextGroupId = 0;
-
   bool mActive = false;
   bool mAllowPrivateBrowsingByDefault = true;
 
   RefPtr<WebExtensionLocalizeCallback> mLocalizeCallback;
 
   bool mIsPrivileged;
   RefPtr<AtomSet> mPermissions;
   RefPtr<MatchPatternSet> mHostPermissions;