Bug 1335801 - Wait for the right events. r=Felipe,krizsa
☠☠ backed out by 07a4c8ff3830 ☠ ☠
authorBlake Kaplan <mrbkap@gmail.com>
Thu, 23 Feb 2017 11:32:33 -0800
changeset 489443 20e91e72e991503d24dfbe7e373ebceef60f00e6
parent 489442 b30e076b9d1562078772c877c4bad77f349079bb
child 489444 86c5b56e42f622716028f93ed5475e94c42920c4
push id46822
push userbmo:emilio+bugs@crisal.io
push dateFri, 24 Feb 2017 20:50:08 +0000
reviewersFelipe, krizsa
bugs1335801
milestone54.0a1
Bug 1335801 - Wait for the right events. r=Felipe,krizsa MozReview-Commit-ID: JL0AdE8XB2n
browser/base/content/test/referrer/head.js
--- a/browser/base/content/test/referrer/head.js
+++ b/browser/base/content/test/referrer/head.js
@@ -135,29 +135,17 @@ function delayedStartupFinished(aWindow)
 
 /**
  * Waits for some (any) tab to load. The caller triggers the load.
  * @param aWindow The window where to wait for a tab to load.
  * @return {Promise}
  * @resolves With the tab once it's loaded.
  */
 function someTabLoaded(aWindow) {
-  return new Promise(function(resolve) {
-    aWindow.gBrowser.addEventListener("load", function onLoad(aEvent) {
-      if (aWindow.location.href === "about:blank") {
-        return;
-      }
-      let tab = aWindow.gBrowser._getTabForContentWindow(
-          aEvent.target.defaultView.top);
-      if (tab) {
-        aWindow.gBrowser.removeEventListener("load", onLoad, true);
-        resolve(tab);
-      }
-    }, true);
-  });
+  return BrowserTestUtils.waitForNewTab(aWindow.gBrowser);
 }
 
 /**
  * Waits for a new window to open and load. The caller triggers the open.
  * @return {Promise}
  * @resolves With the new window once it's open and loaded.
  */
 function newWindowOpened() {