Bug 1338753 - Attempt to address intermittent failures due to rounding errors. r=baku, a=test-only
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 13 Feb 2017 12:18:56 -0500
changeset 376185 da3502add096266361b9d7bf6adc667a27847296
parent 376184 df0a213dad6c60547835b26e980deb2e4ad8c250
child 376186 e1ce5ca55bfd8b41d71adb8987c76132d5ffad39
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku, test-only
bugs1338753
milestone53.0a2
Bug 1338753 - Attempt to address intermittent failures due to rounding errors. r=baku, a=test-only
dom/base/test/browser_timeout_throttling_with_audio_playback.js
--- a/dom/base/test/browser_timeout_throttling_with_audio_playback.js
+++ b/dom/base/test/browser_timeout_throttling_with_audio_playback.js
@@ -31,22 +31,24 @@ function* runTest(url) {
   // Put the tab in the background.
   yield BrowserTestUtils.switchTab(gBrowser, currentTab);
 
   let timeout = yield ContentTask.spawn(newBrowser, {}, function() {
     return new Promise(resolve => {
       let before = new Date();
       content.window.setTimeout(function() {
         let after = new Date();
-        resolve(after - before);
+        // Sometimes due to rounding errors, we may get a result of 9ms here, so
+        // let's round up by 1 to protect against such intermittent failures.
+        resolve(after - before + 1);
       }, 0);
     });
   });
   ok(timeout >= kMinTimeoutForeground &&
-     timeout <= kMinTimeoutBackground, `Got the correct timeout (${timeout})`);
+     timeout <  kMinTimeoutBackground, `Got the correct timeout (${timeout})`);
 
   // All done.
   yield BrowserTestUtils.removeTab(newTab);
 }
 
 add_task(function* setup() {
   yield SpecialPowers.pushPrefEnv({"set": [
     ["dom.min_timeout_value", kMinTimeoutForeground],