Bug 1373708 - Part 2: Wait until all tabs are closed. r=billm
authorLiang-Heng Chen <xeonchen@gmail.com>
Thu, 07 Sep 2017 18:16:00 -0400
changeset 452931 a30d2216e0b9c8fc902f5e1704eafabab828fcff
parent 452930 d31af7725e65299edc1b16f11fee0a3963f6f57f
child 452932 aca79713b901610cec0bce7dfac13d4c500f4b9d
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs1373708
milestone59.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 1373708 - Part 2: Wait until all tabs are closed. r=billm MozReview-Commit-ID: 2Ky8t2jpDyY
browser/components/sessionstore/test/browser_354894_perwindowpb.js
--- a/browser/components/sessionstore/test/browser_354894_perwindowpb.js
+++ b/browser/components/sessionstore/test/browser_354894_perwindowpb.js
@@ -136,17 +136,17 @@ let setupTest = async function(options, 
 
   for (let o in observing) {
     Services.obs.addObserver(observer, o);
   }
 
   let private = options.private || false;
   let newWin = await promiseNewWindowLoaded({ private });
 
-  injectTestTabs(newWin);
+  await injectTestTabs(newWin);
 
   await testFunction(newWin, observing);
 
   let count = getBrowserWindowsCount();
   is(count.open, 0, "Got right number of open windows");
   is(count.winstates, 1, "Got right number of stored window states");
 
   for (let o in observing) {
@@ -158,19 +158,19 @@ let setupTest = async function(options, 
 
 /**
  * Loads a TEST_URLS into a browser window.
  *
  * @param win (Window)
  *        The browser window to load the tabs in
  */
 function injectTestTabs(win) {
-  TEST_URLS.forEach(function(url) {
-    win.gBrowser.addTab(url);
-  });
+  let promises = TEST_URLS.map(url => win.gBrowser.addTab(url))
+                          .map(tab => BrowserTestUtils.browserLoaded(tab.linkedBrowser));
+  return Promise.all(promises);
 }
 
 /**
  * Attempts to close a window via BrowserTryToCloseWindow so that
  * we get the browser-lastwindow-close-requested and
  * browser-lastwindow-close-granted observer notifications.
  *
  * @param win (Window)