1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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."
);
});
|