Bug 1500543 - Only inform windows that their parent is changing when being removed from their parent. r=bzbarsky, a=RyanVM
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 29 Oct 2018 19:15:32 +0000
changeset 501029 cc953fc99e9be4330c20d053af897f264f6a4170
parent 501028 560ec5d63826c4a8b510fa08a4510564f575ee2b
child 501030 1597b2e3a491dedf4ce87d91ef89c63b5da476c2
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky, RyanVM
bugs1500543
milestone64.0
Bug 1500543 - Only inform windows that their parent is changing when being removed from their parent. r=bzbarsky, a=RyanVM Differential Revision: https://phabricator.services.mozilla.com/D10085
docshell/base/nsDocShell.cpp
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -2983,18 +2983,20 @@ nsDocShell::SetDocLoaderParent(nsDocLoad
   nsCOMPtr<nsIURIContentListener> parentURIListener(do_GetInterface(parent));
   if (parentURIListener) {
     mContentListener->SetParentContentListener(parentURIListener);
   }
 
   // Our parent has changed. Recompute scriptability.
   RecomputeCanExecuteScripts();
 
-  nsCOMPtr<nsPIDOMWindowOuter> window = GetWindow();
-  if (window) {
+  // Inform windows when they're being removed from their parent.
+  if (!aParent && mScriptGlobal) {
+    nsCOMPtr<nsPIDOMWindowOuter> window = mScriptGlobal->AsOuter();
+    MOZ_ASSERT(window);
     auto* win = nsGlobalWindowOuter::Cast(window);
     win->ParentWindowChanged();
   }
 
   NS_ASSERTION(mInheritPrivateBrowsingId || wasPrivate == UsePrivateBrowsing(),
                "Private browsing state changed while inheritance was disabled");
 
   return NS_OK;