summaryrefslogtreecommitdiffstats
path: root/browser/components/customizableui/test/browser_panelUINotifications_modals.js
diff options
context:
space:
mode:
Diffstat (limited to 'browser/components/customizableui/test/browser_panelUINotifications_modals.js')
-rw-r--r--browser/components/customizableui/test/browser_panelUINotifications_modals.js87
1 files changed, 87 insertions, 0 deletions
diff --git a/browser/components/customizableui/test/browser_panelUINotifications_modals.js b/browser/components/customizableui/test/browser_panelUINotifications_modals.js
new file mode 100644
index 0000000000..87be14fcee
--- /dev/null
+++ b/browser/components/customizableui/test/browser_panelUINotifications_modals.js
@@ -0,0 +1,87 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const { AppMenuNotifications } = ChromeUtils.importESModule(
+ "resource://gre/modules/AppMenuNotifications.sys.mjs"
+);
+
+add_task(async function testModals() {
+ await SpecialPowers.pushPrefEnv({
+ set: [["prompts.windowPromptSubDialog", true]],
+ });
+
+ is(
+ PanelUI.notificationPanel.state,
+ "closed",
+ "update-manual doorhanger is closed."
+ );
+ let mainActionCalled = false;
+ let mainAction = {
+ callback: () => {
+ mainActionCalled = true;
+ },
+ };
+ AppMenuNotifications.showNotification("update-manual", mainAction);
+
+ isnot(
+ PanelUI.notificationPanel.state,
+ "closed",
+ "update-manual doorhanger is showing."
+ );
+ let notifications = [...PanelUI.notificationPanel.children].filter(
+ n => !n.hidden
+ );
+ is(
+ notifications.length,
+ 1,
+ "PanelUI doorhanger is only displaying one notification."
+ );
+ let doorhanger = notifications[0];
+ is(
+ doorhanger.id,
+ "appMenu-update-manual-notification",
+ "PanelUI is displaying the update-manual notification."
+ );
+
+ let popuphiddenPromise = BrowserTestUtils.waitForEvent(
+ PanelUI.notificationPanel,
+ "popuphidden"
+ );
+
+ let dialogPromise = BrowserTestUtils.promiseAlertDialogOpen("accept");
+ Services.prompt.asyncAlert(
+ window.browsingContext,
+ Services.prompt.MODAL_TYPE_INTERNAL_WINDOW,
+ "Test alert",
+ "Test alert description"
+ );
+ await popuphiddenPromise;
+ is(
+ PanelUI.notificationPanel.state,
+ "closed",
+ "update-manual doorhanger is closed."
+ );
+
+ let popupshownPromise = BrowserTestUtils.waitForEvent(
+ PanelUI.notificationPanel,
+ "popupshown"
+ );
+
+ await dialogPromise;
+ await popupshownPromise;
+ isnot(
+ PanelUI.notificationPanel.state,
+ "closed",
+ "update-manual doorhanger is showing."
+ );
+
+ doorhanger.button.click();
+ ok(mainActionCalled, "Main action callback was called");
+ is(
+ PanelUI.notificationPanel.state,
+ "closed",
+ "update-manual doorhanger is closed."
+ );
+});