Bug 1506852 - Make sure to also clear opener in BrowsingContext. r=peterv
☠☠ backed out by d5bbdd582025 ☠ ☠
authorAndreas Farre <farre@mozilla.com>
Mon, 19 Nov 2018 15:57:27 +0000
changeset 503442 87037e14247bbd23e32dd9084262b5aabe9bbf8d
parent 503441 17edafa646aef9ba5f1bb13d5dbff7cba3145700
child 503443 a50839e591523919115247c6bc8290c505fede76
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs1506852
milestone65.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 1506852 - Make sure to also clear opener in BrowsingContext. r=peterv When calling nsGlobalWindowOuter::SetOpenerWindow with null we should make sure to also clear BrowsingContext::mOpener. Differential Revision: https://phabricator.services.mozilla.com/D11769
dom/base/nsGlobalWindowOuter.cpp
--- a/dom/base/nsGlobalWindowOuter.cpp
+++ b/dom/base/nsGlobalWindowOuter.cpp
@@ -2243,16 +2243,20 @@ nsGlobalWindowOuter::DetachFromDocShell(
   MaybeForgiveSpamCount();
   CleanUp();
 }
 
 void
 nsGlobalWindowOuter::SetOpenerWindow(nsPIDOMWindowOuter* aOpener,
                                      bool aOriginalOpener)
 {
+  MOZ_DIAGNOSTIC_ASSERT(!aOpener || aOpener->GetBrowsingContext());
+  MOZ_DIAGNOSTIC_ASSERT(!mOpener || GetBrowsingContext() && GetBrowsingContext()->GetOpener());
+  MOZ_DIAGNOSTIC_ASSERT(mDocShell);
+
   nsWeakPtr opener = do_GetWeakReference(aOpener);
   if (opener == mOpener) {
     MOZ_DIAGNOSTIC_ASSERT(
       !aOpener || !aOpener->GetDocShell() ||
       (GetBrowsingContext() &&
        GetBrowsingContext()->GetOpener() == aOpener->GetBrowsingContext()));
     return;
   }
@@ -2261,21 +2265,21 @@ nsGlobalWindowOuter::SetOpenerWindow(nsP
                "aOriginalOpener is true, but not first call to "
                "SetOpenerWindow!");
   NS_ASSERTION(aOpener || !aOriginalOpener,
                "Shouldn't set mHadOriginalOpener if aOpener is null");
 
   mOpener = opener.forget();
   NS_ASSERTION(mOpener || !aOpener, "Opener must support weak references!");
 
-  if (mDocShell && aOpener) {
+  if (mDocShell) {
     // TODO(farre): Here we really wish to only consider the case
     // where 'aOriginalOpener' is false, and we also really want to
     // move opener entirely to BrowsingContext. See bug 1502330.
-    GetBrowsingContext()->SetOpener(aOpener->GetBrowsingContext());
+    GetBrowsingContext()->SetOpener(aOpener ? aOpener->GetBrowsingContext() : nullptr);
   }
 
   // Check that the js visible opener matches! We currently don't depend on this
   // being true outside of nightly, so we disable the assertion in optimized
   // release / beta builds.
   nsPIDOMWindowOuter* contentOpener = GetSanitizedOpener(aOpener);
 
   // contentOpener is not used when the DIAGNOSTIC_ASSERT is compiled out.