Bug 1211270 - Fix CPOW bug in browser_onbeforeunload_navigation.js. r=mrbkap, a=test-only
authorBill McCloskey <billm@mozilla.com>
Tue, 18 Oct 2016 15:58:27 -0700
changeset 350755 00f11e7650b184162dbedf9c82a7917b5c07d216
parent 350754 e4e6022059e5c35d3b1bbc731b1f68f266302be3
child 350756 1ad4ab26875c6512b577f8f6974260fcd76d35b6
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap, test-only
bugs1211270
milestone50.0
Bug 1211270 - Fix CPOW bug in browser_onbeforeunload_navigation.js. r=mrbkap, a=test-only
docshell/test/browser/browser_onbeforeunload_navigation.js
--- a/docshell/test/browser/browser_onbeforeunload_navigation.js
+++ b/docshell/test/browser/browser_onbeforeunload_navigation.js
@@ -111,25 +111,30 @@ function runNextTest() {
   currentTest++;
   if (currentTest >= testsLength) {
     if (!stayingOnPage) {
       finish();
       return;
     }
     // Run the same tests again, but this time let the navigation happen:
     stayingOnPage = false;
+    // Remove onbeforeunload handler, or this load will trigger the dialog...
+    contentWindow.onbeforeunload = null;
     currentTest = 0;
   }
 
 
   if (!stayingOnPage) {
+    // Right now we're on the data: page. Null contentWindow out to
+    // avoid CPOW errors when contentWindow is no longer the correct
+    // outer window proxy object.
+    contentWindow = null;
+
     onAfterPageLoad = runCurrentTest;
     loadExpected = TEST_PAGE;
-    // Remove onbeforeunload handler, or this load will trigger the dialog...
-    contentWindow.onbeforeunload = null;
     testTab.linkedBrowser.loadURI(TEST_PAGE);
   } else {
     runCurrentTest();
   }
 }
 
 function runCurrentTest() {
   // Reset things so we're sure the previous tests failings don't influence this one: