Bug 1330822 - Remove CPOWs from customizableui/head.js. r=Gijs draft
authorBlake Kaplan <mrbkap@gmail.com>
Thu, 12 Jan 2017 15:33:43 -0800
changeset 463348 fc5158ab34dbe9fb469a7a8a171a8e30b1dbff54
parent 463347 be1d00ff9e58fe0ac7bd5442ea6cf5e0a73fb592
child 463349 5e8a882e4661052e26f65991e2b61cd65f2acf62
push id42038
push userbmo:mrbkap@mozilla.com
push dateWed, 18 Jan 2017 23:45:52 +0000
reviewersGijs
bugs1330822
milestone53.0a1
Bug 1330822 - Remove CPOWs from customizableui/head.js. r=Gijs MozReview-Commit-ID: eycB4S9ANq
browser/components/customizableui/test/head.js
--- a/browser/components/customizableui/test/head.js
+++ b/browser/components/customizableui/test/head.js
@@ -358,39 +358,21 @@ function waitFor(aTimeout = 100) {
 /**
  * Starts a load in an existing tab and waits for it to finish (via some event).
  *
  * @param aTab       The tab to load into.
  * @param aUrl       The url to load.
  * @param aEventType The load event type to wait for.  Defaults to "load".
  * @return {Promise} resolved when the event is handled.
  */
-function promiseTabLoadEvent(aTab, aURL, aEventType = "load") {
-  let deferred = Promise.defer();
-  info("Wait for tab event: " + aEventType);
-
-  let timeoutId = setTimeout(() => {
-    aTab.linkedBrowser.removeEventListener(aEventType, onTabLoad, true);
-    deferred.reject("TabSelect did not happen within " + kTabEventFailureTimeoutInMs + "ms");
-  }, kTabEventFailureTimeoutInMs);
+function promiseTabLoadEvent(aTab, aURL) {
+  let browser = aTab.linkedBrowser;
 
-  function onTabLoad(event) {
-    if (event.originalTarget != aTab.linkedBrowser.contentDocument ||
-        event.target.location.href == "about:blank") {
-      info("skipping spurious load event");
-      return;
-    }
-    clearTimeout(timeoutId);
-    aTab.linkedBrowser.removeEventListener(aEventType, onTabLoad, true);
-    info("Tab event received: " + aEventType);
-    deferred.resolve();
-  }
-  aTab.linkedBrowser.addEventListener(aEventType, onTabLoad, true, true);
-  aTab.linkedBrowser.loadURI(aURL);
-  return deferred.promise;
+  BrowserTestUtils.loadURI(browser, aURL);
+  return BrowserTestUtils.browserLoaded(browser);
 }
 
 /**
  * Navigate back or forward in tab history and wait for it to finish.
  *
  * @param aDirection   Number to indicate to move backward or forward in history.
  * @param aConditionFn Function that returns the result of an evaluated condition
  *                     that needs to be `true` to resolve the promise.