Bug 1540839 - Don't reuse BCs on top level windows being made local; r=nika
☠☠ backed out by 0d1fd6730856 ☠ ☠
authorKyle Machulis <kyle@nonpolynomial.com>
Thu, 18 Apr 2019 17:31:41 -0700
changeset 473699 8ff2ff524489f0ae67d90ed4ce2c6d2fe4986d5d
parent 473698 27492a30286c2cc22509e7ccdd84ff22f1425841
child 473700 b34c4d71f20230205d4d676445e60a643108b94a
push id36010
push userapavel@mozilla.com
push dateTue, 14 May 2019 04:11:16 +0000
treeherdermozilla-central@e0a622476b77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnika
bugs1540839
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 - Don't reuse BCs on top level windows being made local; r=nika Don't preserve contexts when we have a chrome window that's being made local. Differential Revision: https://phabricator.services.mozilla.com/D29044
dom/base/nsFrameLoaderOwner.cpp
--- a/dom/base/nsFrameLoaderOwner.cpp
+++ b/dom/base/nsFrameLoaderOwner.cpp
@@ -31,20 +31,27 @@ nsFrameLoaderOwner::GetBrowsingContext()
 }
 
 void nsFrameLoaderOwner::ChangeRemoteness(
     const mozilla::dom::RemotenessOptions& aOptions, mozilla::ErrorResult& rv) {
   RefPtr<BrowsingContext> bc;
   // If we already have a Frameloader, destroy it, possibly preserving its
   // browsing context.
   if (mFrameLoader) {
+    // Don't preserve contexts if this is a chrome (parent process) window that
+    // 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) {
+    if (!aOptions.mReplaceBrowsingContext &&
+        !isChromeRemoteToLocal) {
       bc = mFrameLoader->GetBrowsingContext();
       mFrameLoader->SkipBrowsingContextDetach();
     }
 
     mFrameLoader->Destroy();
     mFrameLoader = nullptr;
   }