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 356227 6502acd51a449dc05f52a41e3e8933334e948178
parent 356226 6f60e5a233b811c9a5b143781010e41c12c25c08
child 356228 39299d2a7f1abbce866a25e2b64b60e639de4f8a
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap, test-only
bugs1211270
milestone51.0a2
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: