Bug 1118279 - Fix intermittent browser_customize_popupNotification.js failures r=gavin
☠☠ backed out by 7099b4cceabb ☠ ☠
authorTim Taubert <ttaubert@mozilla.com>
Thu, 05 Feb 2015 21:44:13 +0100
changeset 227845 470368b135b7f0b9cbc636732e307fe850d7ea3d
parent 227844 946346db74bb3216ac5fa472d34f97706e75e218
child 227846 14fb809d31b740d60b140c669dcabdb21125ea69
push id55248
push userryanvm@gmail.com
push dateFri, 06 Feb 2015 16:36:11 +0000
treeherdermozilla-inbound@d14b8770825d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin
bugs1118279
milestone38.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 1118279 - Fix intermittent browser_customize_popupNotification.js failures r=gavin
browser/base/content/test/general/browser_customize_popupNotification.js
--- a/browser/base/content/test/general/browser_customize_popupNotification.js
+++ b/browser/base/content/test/general/browser_customize_popupNotification.js
@@ -1,35 +1,41 @@
-/*
-Any copyright is dedicated to the Public Domain.
-http://creativecommons.org/publicdomain/zero/1.0/
-*/
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+add_task(function* () {
+  let win = yield promiseOpenAndLoadWindow({}, true /* wait for delayed startup */);
+
+  // Remove the navigation toolbar.
+  win.document.getElementById("nav-bar").remove();
 
-function test() {
-  waitForExplicitFinish();
-  let newWin = OpenBrowserWindow();
-  registerCleanupFunction(() => {
-    newWin.close()
-    newWin = null;
-  });
-  whenDelayedStartupFinished(newWin, function () {
-    // Remove the URL bar
-    newWin.gURLBar.parentNode.removeChild(newWin.gURLBar);
+  yield new Promise(resolve => waitForFocus(resolve, win));
+  yield promiseBrowserLoaded(win.gBrowser.browsers[0]);
+
+  try {
+    let PN = win.PopupNotifications;
+    let panelPromise = promisePopupShown(PN.panel);
+    let notification = PN.show(win.gBrowser.selectedBrowser, "some-notification", "Some message");
+    ok(notification, "show() succeeded");
+    yield panelPromise;
 
-    waitForFocus(function () {
-      let PN = newWin.PopupNotifications;
-      try {
-        let panelPromise = promisePopupShown(PN.panel);
-        let notification = PN.show(newWin.gBrowser.selectedBrowser, "some-notification", "Some message");
-        panelPromise.then(function() {
-          ok(notification, "showed the notification");
-          ok(PN.isPanelOpen, "panel is open");
-          is(PN.panel.anchorNode, newWin.gBrowser.selectedTab, "notification is correctly anchored to the tab");
-          PN.panel.hidePopup();
-          finish();
-        });
-      } catch (ex) {
-        ok(false, "threw exception: " + ex);
-        finish();
-      }
-    }, newWin);
+    ok(PN.isPanelOpen, "panel is open");
+    is(PN.panel.anchorNode, win.gBrowser.selectedTab, "notification is correctly anchored to the tab");
+    PN.panel.hidePopup();
+  } catch (ex) {
+    ok(false, "threw exception: " + ex);
+  }
+
+  yield promiseWindowClosed(win);
+});
+
+function promiseBrowserLoaded(browser) {
+  if (browser.contentDocument.readyState == "complete") {
+    return Promise.resolve();
+  }
+
+  return new Promise(resolve => {
+    browser.addEventListener("load", function onLoad() {
+      browser.removeEventListener("load", onLoad, true);
+      resolve();
+    }, true);
   });
 }