Bug 874847 - Fix intermittent failure in browser_lastAccessedTab.js by including some fudge in the Date.now comparison. r=ttaubert, a=test-only
authorDrew Willcoxon <adw@mozilla.com>
Fri, 27 Sep 2013 23:47:18 -0700
changeset 160482 d9f5ddccb15ebfbe2ff6fb3225ea07c4c406db95
parent 160481 891eaf3a213e096f86bc2c49602f3d1aee8b6185
child 160483 f75dbfe92bcc1a2ddcf37f5e236795bf2f5e96d1
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersttaubert, test-only
bugs874847
milestone26.0a2
Bug 874847 - Fix intermittent failure in browser_lastAccessedTab.js by including some fudge in the Date.now comparison. r=ttaubert, a=test-only
browser/base/content/test/browser_lastAccessedTab.js
--- a/browser/base/content/test/browser_lastAccessedTab.js
+++ b/browser/base/content/test/browser_lastAccessedTab.js
@@ -12,13 +12,15 @@
 
 function test() {
   let originalTab = gBrowser.selectedTab;
   let newTab = gBrowser.addTab("about:blank", {skipAnimation: true});
   is(newTab.lastAccessed, 0, "Timestamp on the new tab is 0.");
   gBrowser.selectedTab = newTab;
   let newTabAccessedDate = newTab.lastAccessed;
   ok(newTabAccessedDate > 0, "Timestamp on the selected tab is more than 0.");
-  ok(newTabAccessedDate <= Date.now(), "Timestamp less than or equal current Date.");
+  // Date.now is not guaranteed to be monotonic, so include one second of fudge.
+  let now = Date.now() + 1000;
+  ok(newTabAccessedDate <= now, "Timestamp less than or equal current Date: " + newTabAccessedDate + " <= " + now);
   gBrowser.selectedTab = originalTab;
   is(newTab.lastAccessed, newTabAccessedDate, "New tab's timestamp remains the same.");
   gBrowser.removeTab(newTab);
 }