Bug 1540839 - Don't reuse BCs on top level windows being made local; r=nika
authorKyle Machulis <kyle@nonpolynomial.com>
Thu, 18 Apr 2019 17:31:41 -0700
changeset 532666 5863b49f009a640f3820e8b31d029cfc61b1636c
parent 532665 955bbe4b223ebf67260b928365d0ac49bbba54cf
child 532667 5159fa6d6d40f136411f1a98b79f0e96bfd9fedd
push id11270
push userrgurzau@mozilla.com
push dateWed, 15 May 2019 15:07:19 +0000
treeherdermozilla-beta@571bc76da583 [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
@@ -32,20 +32,27 @@ nsFrameLoaderOwner::GetBrowsingContext()
 
 void nsFrameLoaderOwner::ChangeRemoteness(
     const mozilla::dom::RemotenessOptions& aOptions, mozilla::ErrorResult& rv) {
   RefPtr<mozilla::dom::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;
   }