Bug 1540839 - Add pref for preserving browsing contexts; r=nika
☠☠ backed out by 0d1fd6730856 ☠ ☠
authorKyle Machulis <kyle@nonpolynomial.com>
Thu, 09 May 2019 12:24:10 -0700
changeset 532528 f7e477858ab7bc94193910e0d7fc5a11920729a7
parent 532527 55e841a0f005be12b407ed25afaaf3e84e01bb09
child 532529 0d1fd673085631fce1bad6e3aeeeb4b559c57493
push id11268
push usercsabou@mozilla.com
push dateTue, 14 May 2019 15:24:22 +0000
treeherdermozilla-beta@5fb7fcd568d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnika
bugs1540839, 1550571
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1540839 - Add pref for preserving browsing contexts; r=nika Still having lots of issues with tests failing, but need to get this landed for various reasons. Followup to pref on at Bug 1550571. Differential Revision: https://phabricator.services.mozilla.com/D30563
docshell/base/BrowsingContext.cpp
docshell/base/BrowsingContext.h
dom/base/nsFrameLoaderOwner.cpp
modules/libpref/init/all.js
toolkit/components/remotebrowserutils/tests/browser/browser_oopProcessSwap.js
--- a/docshell/base/BrowsingContext.cpp
+++ b/docshell/base/BrowsingContext.cpp
@@ -808,16 +808,31 @@ void BrowsingContext::Transaction::Apply
     aBrowsingContext->WillSet##name(*m##name, aSource); \
     aBrowsingContext->m##name = std::move(*m##name);    \
     aBrowsingContext->DidSet##name(aSource);            \
     m##name.reset();                                    \
   }
 #include "mozilla/dom/BrowsingContextFieldList.h"
 }
 
+BrowsingContext::IPCInitializer BrowsingContext::GetIPCInitializer() {
+  MOZ_ASSERT(
+      !Preferences::GetBool("fission.preserve_browsing_contexts", false) ||
+      IsContent());
+
+  IPCInitializer init;
+  init.mId = Id();
+  init.mParentId = mParent ? mParent->Id() : 0;
+  init.mCached = IsCached();
+
+#define MOZ_BC_FIELD(name, type) init.m##name = m##name;
+#include "mozilla/dom/BrowsingContextFieldList.h"
+  return init;
+}
+
 already_AddRefed<BrowsingContext> BrowsingContext::IPCInitializer::GetParent() {
   RefPtr<BrowsingContext> parent;
   if (mParentId != 0) {
     parent = BrowsingContext::Get(mParentId);
     MOZ_RELEASE_ASSERT(parent);
   }
   return parent.forget();
 }
--- a/docshell/base/BrowsingContext.h
+++ b/docshell/base/BrowsingContext.h
@@ -342,27 +342,17 @@ class BrowsingContext : public nsWrapper
     bool mCached;
     // Include each field, skipping mOpener, as we want to handle it
     // separately.
 #define MOZ_BC_FIELD(name, type) type m##name;
 #include "mozilla/dom/BrowsingContextFieldList.h"
   };
 
   // Create an IPCInitializer object for this BrowsingContext.
-  IPCInitializer GetIPCInitializer() {
-    MOZ_ASSERT(IsContent());
-    IPCInitializer init;
-    init.mId = Id();
-    init.mParentId = mParent ? mParent->Id() : 0;
-    init.mCached = IsCached();
-
-#define MOZ_BC_FIELD(name, type) init.m##name = m##name;
-#include "mozilla/dom/BrowsingContextFieldList.h"
-    return init;
-  }
+  IPCInitializer GetIPCInitializer();
 
   // Create a BrowsingContext object from over IPC.
   static already_AddRefed<BrowsingContext> CreateFromIPC(
       IPCInitializer&& aInitializer, BrowsingContextGroup* aGroup,
       ContentParent* aOriginProcess);
 
  protected:
   virtual ~BrowsingContext();
--- a/dom/base/nsFrameLoaderOwner.cpp
+++ b/dom/base/nsFrameLoaderOwner.cpp
@@ -40,18 +40,18 @@ void nsFrameLoaderOwner::ChangeRemotenes
     // is changing from remote to local.
     bool isChromeRemoteToLocal =
         XRE_IsParentProcess() && (!aOptions.mRemoteType.WasPassed() ||
                                   aOptions.mRemoteType.Value().IsVoid());
 
     // If this is a process switch due to a difference in Cross Origin Opener
     // Policy, do not preserve the browsing context. Otherwise, save off the
     // browsing context and use it when creating our new FrameLoader.
-    if (!aOptions.mReplaceBrowsingContext &&
-        !isChromeRemoteToLocal) {
+    if (!aOptions.mReplaceBrowsingContext && !isChromeRemoteToLocal &&
+        Preferences::GetBool("fission.preserve_browsing_contexts", false)) {
       bc = mFrameLoader->GetBrowsingContext();
       mFrameLoader->SkipBrowsingContextDetach();
     }
 
     mFrameLoader->Destroy();
     mFrameLoader = nullptr;
   }
 
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -6036,14 +6036,18 @@ pref("dom.datatransfer.mozAtAPIs", true)
 
 // External.AddSearchProvider is deprecated and it will be removed in the next
 // cycles.
 pref("dom.sidebar.enabled", true);
 
 // Turn on fission frameloader swapping
 pref("fission.rebuild_frameloaders_on_remoteness_change", true);
 
+// If true, preserve browsing contexts between process swaps. Should be set to
+// true in bug 1550571.
+pref("fission.preserve_browsing_contexts", false);
+
 // Support for legacy customizations that rely on checking the
 // user profile directory for these stylesheets:
 //  * userContent.css
 //  * userChrome.css
 pref("toolkit.legacyUserProfileCustomizations.stylesheets", false);
 
--- a/toolkit/components/remotebrowserutils/tests/browser/browser_oopProcessSwap.js
+++ b/toolkit/components/remotebrowserutils/tests/browser/browser_oopProcessSwap.js
@@ -40,17 +40,20 @@ add_task(async function oopProcessSwap()
 
       return {
         location: data.location,
         browsingContextId: iframe.browsingContext.id,
       };
     });
 
     is(browser.browsingContext.getChildren().length, 1);
-    is(frameId, oopinfo.browsingContextId, `BrowsingContext should not have changed (${frameId} != ${oopinfo.browsingContextId})`);
+
+    if (Services.prefs.getBoolPref("fission.preserve_browsing_contexts")) {
+      is(frameId, oopinfo.browsingContextId, `BrowsingContext should not have changed (${frameId} != ${oopinfo.browsingContextId})`);
+    }
     is(oopinfo.location, WEB, "correct location");
   });
 
   await BrowserTestUtils.closeWindow(win);
 });
 
 add_task(async function oopOriginProcessSwap() {
   const COM_DUMMY = httpURL("dummy_page.html", "https://example.com/");
@@ -94,15 +97,17 @@ add_task(async function oopOriginProcess
 
       return {
         location: data.location,
         browsingContextId: iframe.browsingContext.id,
       };
     });
 
     is(browser.browsingContext.getChildren().length, 1);
-    is(frameId, oopinfo.browsingContextId, `BrowsingContext should not have changed (${frameId} != ${oopinfo.browsingContextId})`);
+    if (Services.prefs.getBoolPref("fission.preserve_browsing_contexts")) {
+      is(frameId, oopinfo.browsingContextId, `BrowsingContext should not have changed (${frameId} != ${oopinfo.browsingContextId})`);
+    }
     is(oopinfo.location, ORG_POSTMSG, "correct location");
   });
 
   await BrowserTestUtils.closeWindow(win);
 });