Bug 1167579 - Fix intermittent browser_sessionStorage.js failures caused by non-monotonous closedAt=Date.now(). r=billm, a=test-only
authorTim Taubert <ttaubert@mozilla.com>
Fri, 29 May 2015 19:22:49 +0200
changeset 274952 f25907a388cc868f6fd2cb64999414c26980b150
parent 274951 fd63e1ef8cbda12ed3429e6dbb2f62cbf0d42631
child 274953 3638d506ca0b35c06422fd145918a01426231590
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm, test-only
bugs1167579
milestone40.0a2
Bug 1167579 - Fix intermittent browser_sessionStorage.js failures caused by non-monotonous closedAt=Date.now(). r=billm, a=test-only
browser/components/sessionstore/test/browser_sessionStorage.js
--- a/browser/components/sessionstore/test/browser_sessionStorage.js
+++ b/browser/components/sessionstore/test/browser_sessionStorage.js
@@ -159,16 +159,23 @@ add_task(function respect_privacy_level(
   let tab2 = gBrowser.duplicateTab(tab);
   yield promiseTabRestored(tab2);
   yield promiseRemoveTab(tab);
 
   // With privacy_level=2 the |tab| shouldn't have any sessionStorage data.
   [{state: {storage}}] = JSON.parse(ss.getClosedTabData(window));
   ok(!storage, "sessionStorage data has *not* been saved");
 
+  // Remove all closed tabs before continuing with the next test.
+  // As Date.now() isn't monotonic we might sometimes check
+  // the wrong closedTabData entry.
+  while (ss.getClosedTabCount(window) > 0) {
+    ss.forgetClosedTab(window, 0);
+  }
+
   // Restore the default privacy level and close the duplicated tab.
   Services.prefs.clearUserPref("browser.sessionstore.privacy_level");
   yield promiseRemoveTab(tab2);
 
   // With privacy_level=0 the duplicated |tab2| should persist all data.
   [{state: {storage}}] = JSON.parse(ss.getClosedTabData(window));
   is(storage["http://mochi.test:8888"].test, OUTER_VALUE,
     "http sessionStorage data has been saved");