Bug 1452762 - Avoid interrupting the wrong script in watchdog tests. r=arai, a=test-only
authorBobby Holley <bobbyholley@gmail.com>
Tue, 17 Jul 2018 03:16:12 +0000
changeset 480504 0ebbe8b5e0ca59c24192681d77a6c1c028c36a54
parent 480503 0b6675cbc84468c2fcfb12bce6484485381d7be6
child 480505 96eae22132b119824b5c87b3bc9b4a5902398eab
push id1757
push userffxbld-merge
push dateFri, 24 Aug 2018 17:02:43 +0000
treeherdermozilla-release@736023aebdb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai, test-only
bugs1452762
milestone62.0
Bug 1452762 - Avoid interrupting the wrong script in watchdog tests. r=arai, a=test-only My best guess as to the failures here is that we're not actually reaching the busyWait call by the time the interrupt callback fires, and thus we're killing unrelated scripts. MozReview-Commit-ID: GvCJzBcJlXm Differential Revision: https://phabricator.services.mozilla.com/D2162
js/xpconnect/tests/unit/head_watchdog.js
--- a/js/xpconnect/tests/unit/head_watchdog.js
+++ b/js/xpconnect/tests/unit/head_watchdog.js
@@ -65,33 +65,41 @@ function executeSoon(fn) {
 // We wait 3 seconds, just to be safe.
 //
 
 function checkWatchdog(expectInterrupt) {
   var oldTimeout = setScriptTimeout(1);
   var lastWatchdogWakeup = Cu.getWatchdogTimestamp("WatchdogWakeup");
 
   return new Promise(resolve => {
+    let inBusyWait = false;
     setInterruptCallback(function() {
       // If the watchdog didn't actually trigger the operation callback, ignore
       // this call. This allows us to test the actual watchdog behavior without
       // interference from other sites where we trigger the operation callback.
       if (lastWatchdogWakeup == Cu.getWatchdogTimestamp("WatchdogWakeup")) {
         return true;
       }
+      if (!inBusyWait) {
+        Assert.ok(true, "Not in busy wait, ignoring interrupt callback");
+        return true;
+      }
+
       Assert.ok(expectInterrupt, "Interrupt callback fired");
       setInterruptCallback(undefined);
       setScriptTimeout(oldTimeout);
       // Schedule the promise for resolution before we kill this script.
       executeSoon(resolve);
       return false;
     });
 
     executeSoon(function() {
+      inBusyWait = true;
       busyWait(3000);
+      inBusyWait = false;
       Assert.ok(!expectInterrupt, "Interrupt callback didn't fire");
       setInterruptCallback(undefined);
       setScriptTimeout(oldTimeout);
       resolve();
     });
   });
 }