Bug 1195295 - Fix browser_tab_detach_restore.js and browser_popupNotifications_4.js r=felipe
authorMike Conley <mconley@mozilla.com>
Thu, 10 Dec 2015 17:44:26 -0500
changeset 310213 5d5885a15ca7ec5649ab207e39a1ba589d3985bb
parent 310212 18eec0849a1f53377704d2602593561ef631a50a
child 310214 05b98fe2ac4f8d4aade367623f2931b652f543d0
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfelipe
bugs1195295
milestone45.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 1195295 - Fix browser_tab_detach_restore.js and browser_popupNotifications_4.js r=felipe These tests seemed to rely on the synchronous infrastructure that the now defunct SyncHandler for SessionStore provided. This moves them to safer, more modern alternatives.
browser/base/content/test/general/browser_tab_detach_restore.js
browser/base/content/test/popupNotifications/head.js
--- a/browser/base/content/test/general/browser_tab_detach_restore.js
+++ b/browser/base/content/test/general/browser_tab_detach_restore.js
@@ -14,17 +14,17 @@ add_task(function*() {
   yield BrowserTestUtils.browserLoaded(tab.linkedBrowser);
   yield TabStateFlusher.flush(tab.linkedBrowser);
 
   let key = tab.linkedBrowser.permanentKey;
   let win = gBrowser.replaceTabWithWindow(tab);
   yield new Promise(resolve => whenDelayedStartupFinished(win, resolve));
 
   is(win.gBrowser.selectedBrowser.permanentKey, key, "Should have properly copied the permanentKey");
-  yield promiseWindowClosed(win);
+  yield BrowserTestUtils.closeWindow(win);
 
   is(SessionStore.getClosedWindowCount(), 1, "Should have restore data for the closed window");
 
   win = SessionStore.undoCloseWindow(0);
   yield BrowserTestUtils.waitForEvent(win, "load");
   yield BrowserTestUtils.waitForEvent(win.gBrowser.tabs[0], "SSTabRestored");
 
   is(win.gBrowser.tabs.length, 1, "Should have restored one tab");
--- a/browser/base/content/test/popupNotifications/head.js
+++ b/browser/base/content/test/popupNotifications/head.js
@@ -41,51 +41,29 @@ function promiseTopicObserved(topic)
 /**
  * Waits for a load (or custom) event to finish in a given tab. If provided
  * load an uri into the tab.
  *
  * @param tab
  *        The tab to load into.
  * @param [optional] url
  *        The url to load, or the current url.
- * @param [optional] event
- *        The load event type to wait for.  Defaults to "load".
  * @return {Promise} resolved when the event is handled.
  * @resolves to the received event
  * @rejects if a valid load event is not received within a meaningful interval
  */
-function promiseTabLoadEvent(tab, url, eventType="load")
+function promiseTabLoadEvent(tab, url)
 {
-  let deferred = Promise.defer();
-  info("Wait tab event: " + eventType);
+  let browser = tab.linkedBrowser;
 
-  function handle(event) {
-    if (event.originalTarget != tab.linkedBrowser.contentDocument ||
-        event.target.location.href == "about:blank" ||
-        (url && event.target.location.href != url)) {
-      info("Skipping spurious '" + eventType + "'' event" +
-           " for " + event.target.location.href);
-      return;
-    }
-    clearTimeout(timeout);
-    tab.linkedBrowser.removeEventListener(eventType, handle, true);
-    info("Tab event received: " + eventType);
-    deferred.resolve(event);
+  if (url) {
+    browser.loadURI(url);
   }
 
-  let timeout = setTimeout(() => {
-    if (tab.linkedBrowser)
-      tab.linkedBrowser.removeEventListener(eventType, handle, true);
-    deferred.reject(new Error("Timed out while waiting for a '" + eventType + "'' event"));
-  }, 30000);
-
-  tab.linkedBrowser.addEventListener(eventType, handle, true, true);
-  if (url)
-    tab.linkedBrowser.loadURI(url);
-  return deferred.promise;
+  return BrowserTestUtils.browserLoaded(browser, false, url);
 }
 
 const PREF_SECURITY_DELAY_INITIAL = Services.prefs.getIntPref("security.notification_enable_delay");
 
 function setup() {
   // Disable transitions as they slow the test down and we want to click the
   // mouse buttons in a predictable location.