diff --git a/browser/base/content/test/general/browser_customize_popupNotification.js b/browser/base/content/test/general/browser_customize_popupNotification.js index 8d7737249cc0..4dea7b497607 100644 --- a/browser/base/content/test/general/browser_customize_popupNotification.js +++ b/browser/base/content/test/general/browser_customize_popupNotification.js @@ -1,41 +1,35 @@ -/* 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 */); +function test() { + waitForExplicitFinish(); + let newWin = OpenBrowserWindow(); + registerCleanupFunction(() => { + newWin.close() + newWin = null; + }); + whenDelayedStartupFinished(newWin, function () { + // Remove the URL bar + newWin.gURLBar.parentNode.removeChild(newWin.gURLBar); - // Remove the navigation toolbar. - win.document.getElementById("nav-bar").remove(); - - 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; - - 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); + 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); }); }