Bug 1450266 P4 Rebind DETH objects to the new global when document.open() is called. r=smaug
authorBen Kelly <ben@wanderview.com>
Tue, 03 Apr 2018 17:10:16 -0700
changeset 411583 cda31f55d8ca1e84bee52d9b5ca2f6820c08cf50
parent 411582 ab5238cc7816e544ddb5c2b35a4e508799862c82
child 411584 2c4fc9d3b1f681876d086796dd6a2ed6d628021a
push id101693
push userbkelly@mozilla.com
push dateWed, 04 Apr 2018 00:10:26 +0000
treeherdermozilla-inbound@cc66bed8784f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1450266
milestone61.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 1450266 P4 Rebind DETH objects to the new global when document.open() is called. r=smaug
dom/base/nsGlobalWindowOuter.cpp
--- a/dom/base/nsGlobalWindowOuter.cpp
+++ b/dom/base/nsGlobalWindowOuter.cpp
@@ -1845,16 +1845,25 @@ nsGlobalWindowOuter::SetNewDocument(nsID
         currentInner->AsInner()->CreatePerformanceObjectIfNeeded();
         if (currentInner->mPerformance) {
           newInnerWindow->mPerformance =
             Performance::CreateForMainThread(newInnerWindow->AsInner(),
                                              aDocument->NodePrincipal(),
                                              currentInner->mPerformance->GetDOMTiming(),
                                              currentInner->mPerformance->GetChannel());
         }
+
+        // Rebind DETH objects to the new global created by document.open().
+        // XXX: Is this correct?  We should consider if the spec and our
+        //      implementation should change to match other browsers by
+        //      just reusing the current window.  (Bug 1449992)
+        currentInner->ForEachEventTargetObject(
+          [&] (DOMEventTargetHelper* aDETH, bool* aDoneOut) {
+            aDETH->BindToOwner(newInnerWindow->AsGlobal());
+          });
       }
 
       // Don't free objects on our current inner window if it's going to be
       // held in the bfcache.
       if (!currentInner->IsFrozen()) {
         currentInner->FreeInnerObjects();
       }
     }