Bug 1499234 - wait for focus and activate events when opening browser windows on Linux, r=dao
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 17 Oct 2018 09:18:05 +0000
changeset 500151 fe67b30d8534c6a843ea7cc8a496abc2b5a506b9
parent 500150 30a7005f36e433c8bfe8b0938e996a60f2618731
child 500152 fd7038210e70cbd56468c5577edfb6fd5c84b986
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdao
bugs1499234
milestone64.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 1499234 - wait for focus and activate events when opening browser windows on Linux, r=dao Differential Revision: https://phabricator.services.mozilla.com/D8790
testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm
--- a/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm
+++ b/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm
@@ -721,29 +721,32 @@ var BrowserTestUtils = {
    */
   async openNewBrowserWindow(options = {}) {
     let currentWin = BrowserWindowTracker.getTopWindow({private: false});
     if (!currentWin) {
       throw new Error("Can't open a new browser window from this helper if no non-private window is open.");
     }
     let win = currentWin.OpenBrowserWindow(options);
 
+    let promises = [this.waitForEvent(win, "focus"), this.waitForEvent(win, "activate")];
+
     // Wait for browser-delayed-startup-finished notification, it indicates
     // that the window has loaded completely and is ready to be used for
     // testing.
-    let startupPromise =
+    promises.push(
       TestUtils.topicObserved("browser-delayed-startup-finished",
-                              subject => subject == win).then(() => win);
+                              subject => subject == win).then(() => win)
+    );
+
 
-    let loadPromise = this.firstBrowserLoaded(win, !options.waitForTabURL, browser => {
+    promises.push(this.firstBrowserLoaded(win, !options.waitForTabURL, browser => {
       return !options.waitForTabURL || options.waitForTabURL == browser.currentURI.spec;
-    });
+    }));
 
-    await startupPromise;
-    await loadPromise;
+    await Promise.all(promises);
 
     return win;
   },
 
   /**
    * Closes a window.
    *
    * @param {Window}