Bug 1301575 - Make browser_crash_previous_frameloader.js more reliable by removing a race. r?Mossop draft
authorMike Conley <mconley@mozilla.com>
Thu, 19 Jan 2017 14:57:21 -0500
changeset 464370 30b6268cb03e02d89ddb5bad0668cd3eda748c04
parent 463681 a3978751f45108ff1ae002ecebdc0fa23fc52b84
child 542906 f1d4ac6237046285d868b3eb7b4cae2fdd92d333
push id42339
push usermconley@mozilla.com
push dateFri, 20 Jan 2017 21:39:19 +0000
reviewersMossop
bugs1301575
milestone53.0a1
Bug 1301575 - Make browser_crash_previous_frameloader.js more reliable by removing a race. r?Mossop MozReview-Commit-ID: E87jEJg86pf
toolkit/content/tests/browser/browser_crash_previous_frameloader.js
--- a/toolkit/content/tests/browser/browser_crash_previous_frameloader.js
+++ b/toolkit/content/tests/browser/browser_crash_previous_frameloader.js
@@ -86,29 +86,23 @@ add_task(function* test_crash_in_previou
 
       let dies = function() {
         privateNoteIntentionalCrash();
         let zero = new ctypes.intptr_t(8);
         let badptr = ctypes.cast(zero, ctypes.PointerType(ctypes.int32_t));
         badptr.contents
       };
 
-      // Use a timeout to give the parent a little extra time
-      // to flip the remoteness of the browser. This has the
-      // potential to be a bit race-y, since in theory, the
-      // setTimeout could complete before the parent finishes
-      // the remoteness flip, which would mean we'd get the
-      // oop-browser-crashed event, and we'll fail here.
-      // Unfortunately, I can't find a way around that right
-      // now, since you cannot send a frameloader a message
-      // once its been replaced.
-      setTimeout(() => {
+      // When the parent flips the remoteness of the browser, the
+      // page should receive the pagehide event, which we'll then
+      // use to crash the frameloader.
+      addEventListener("pagehide", function() {
         dump("\nEt tu, Brute?\n");
         dies();
-      }, 0);
+      });
     });
 
     gBrowser.updateBrowserRemoteness(browser, false);
     info("Waiting for content process to go away.");
     let [subject /* , data */] = yield contentProcessGone;
 
     // If we don't clean up the minidump, the harness will
     // complain.