Bug 864533 - test helper addTab should use pageShowPromise. r=sfoster
authorJim Mathies <jmathies@mozilla.com>
Tue, 23 Apr 2013 08:51:03 -0500
changeset 140579 854986de615aa18a70faaecaac13fe21c1a822af
parent 140578 e220c750ec35aaf66e8618fbc7f7a2f1ce6fae29
child 140580 21bfc7e0effd0c538d27f7eb3d0952bf5f9494b4
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfoster
bugs864533
milestone23.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 864533 - test helper addTab should use pageShowPromise. r=sfoster
browser/metro/base/tests/mochitest/head.js
--- a/browser/metro/base/tests/mochitest/head.js
+++ b/browser/metro/base/tests/mochitest/head.js
@@ -179,17 +179,17 @@ function fireAppBarDisplayEvent()
  *
  * @param aUrl the URL to load
  * @returns a task that resolves to the new tab object after the URL is loaded.
  */
 function addTab(aUrl) {
   return Task.spawn(function() {
     info("Opening "+aUrl+" in a new tab");
     let tab = Browser.addTab(aUrl, true);
-    yield waitForEvent(tab.browser, "pageshow");
+    yield tab.pageShowPromise;
 
     is(tab.browser.currentURI.spec, aUrl, aUrl + " is loaded");
     registerCleanupFunction(function() Browser.closeTab(tab));
     throw new Task.Result(tab);
   });
 }
 
 /**
@@ -208,17 +208,16 @@ function addTab(aUrl) {
  *    }
  *
  * @param aSubject the element that should receive the event
  * @param aEventName the event to wait for
  * @param aTimeoutMs the number of miliseconds to wait before giving up
  * @returns a Promise that resolves to the received event, or to an Error
  */
 function waitForEvent(aSubject, aEventName, aTimeoutMs) {
-  info("waitForEvent: on " + aSubject + " event: " + aEventName);
   let eventDeferred = Promise.defer();
   let timeoutMs = aTimeoutMs || kDefaultWait;
   let timerID = setTimeout(function wfe_canceller() {
     aSubject.removeEventListener(aEventName, onEvent);
     eventDeferred.reject( new Error(aEventName+" event timeout") );
   }, timeoutMs);
 
   function onEvent(aEvent) {