Bug 1524726 - Fix a race condition in a SessionStore test. r=florian
authorJason Orendorff <jorendorff@mozilla.com>
Thu, 28 Feb 2019 20:45:33 +0000
changeset 519928 efec51b1aaf2bab63edb2eced66637eb1e030a17
parent 519927 e4a6fcff18b3681aea9d9288af3a30db83f8df71
child 519929 86fe7556c9af2059d858e9eb0c7afca4c1ba65d0
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflorian
bugs1524726
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1524726 - Fix a race condition in a SessionStore test. r=florian The test uses some custom code to wait for the new window, probably just because the test is old. The fix is to use the BrowserUtils method instead. Differential Revision: https://phabricator.services.mozilla.com/D18478
browser/components/sessionstore/test/browser_aboutSessionRestore.js
--- a/browser/components/sessionstore/test/browser_aboutSessionRestore.js
+++ b/browser/components/sessionstore/test/browser_aboutSessionRestore.js
@@ -31,27 +31,22 @@ add_task(async function() {
 
   let tree = browser.contentDocument.getElementById("tabList");
   let view = tree.view;
   ok(view.isContainer(0), "first entry is the window");
   let titleColumn = tree.columns.title;
   is(view.getCellProperties(1, titleColumn), "icon",
     "second entry is the tab and has a favicon");
 
+  let newWindowOpened = BrowserTestUtils.waitForNewWindow();
+
   browser.messageManager.loadFrameScript(FRAME_SCRIPT, true);
 
   // Wait until the new window was restored.
-  let win = await waitForNewWindow();
+  let win = await newWindowOpened;
+
+  BrowserTestUtils.removeTab(tab);
   await BrowserTestUtils.closeWindow(win);
 
   let [{tabs: [{entries: [{url}]}]}] = JSON.parse(ss.getClosedWindowData());
   is(url, CRASH_URL, "session was restored correctly");
   ss.forgetClosedWindow(0);
 });
-
-function waitForNewWindow() {
-  return new Promise(resolve => {
-    Services.obs.addObserver(function observe(win, topic) {
-      Services.obs.removeObserver(observe, topic);
-      resolve(win);
-    }, "browser-delayed-startup-finished");
-  });
-}