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
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
function test() {
waitForExplicitFinish();
ok(PopupNotifications, "PopupNotifications object exists");
ok(PopupNotifications.panel, "PopupNotifications panel exists");
setup();
}
var tests = [
// Test that for persistent notifications,
// the secondary action is triggered by pressing the escape key.
{ id: "Test#1",
run() {
this.notifyObj = new BasicNotification(this.id);
this.notifyObj.options.persistent = true;
showNotification(this.notifyObj);
},
onShown(popup) {
checkPopup(popup, this.notifyObj);
EventUtils.synthesizeKey("VK_ESCAPE", {});
},
onHidden(popup) {
ok(!this.notifyObj.mainActionClicked, "mainAction was not clicked");
ok(this.notifyObj.secondaryActionClicked, "secondaryAction was clicked");
ok(!this.notifyObj.dismissalCallbackTriggered, "dismissal callback wasn't triggered");
ok(this.notifyObj.removedCallbackTriggered, "removed callback triggered");
}
},
// Test that for non-persistent notifications, the escape key dismisses the notification.
{ id: "Test#2",
*run() {
yield waitForWindowReadyForPopupNotifications(window);
this.notifyObj = new BasicNotification(this.id);
this.notification = showNotification(this.notifyObj);
},
onShown(popup) {
checkPopup(popup, this.notifyObj);
EventUtils.synthesizeKey("VK_ESCAPE", {});
},
onHidden(popup) {
ok(!this.notifyObj.mainActionClicked, "mainAction was not clicked");
ok(!this.notifyObj.secondaryActionClicked, "secondaryAction was not clicked");
ok(this.notifyObj.dismissalCallbackTriggered, "dismissal callback triggered");
ok(!this.notifyObj.removedCallbackTriggered, "removed callback was not triggered");
this.notification.remove();
}
},
// Test that the space key on an anchor element focuses an active notification
{ id: "Test#3",
*run() {
this.notifyObj = new BasicNotification(this.id);
this.notifyObj.anchorID = "geo-notification-icon";
this.notifyObj.addOptions({
persistent: true
});
this.notification = showNotification(this.notifyObj);
},
*onShown(popup) {
checkPopup(popup, this.notifyObj);
let anchor = document.getElementById(this.notifyObj.anchorID);
anchor.focus();
is(document.activeElement, anchor);
EventUtils.synthesizeKey(" ", {});
is(document.activeElement, popup.childNodes[0].button);
this.notification.remove();
},
onHidden(popup) { }
},
];
|