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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
/* 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/. */
"use strict";
/* import-globals-from ../../mochitest/role.js */
/* import-globals-from ../../mochitest/states.js */
loadScripts(
{ name: "role.js", dir: MOCHITESTS_DIR },
{ name: "states.js", dir: MOCHITESTS_DIR }
);
// Test dropdown select element
addAccessibleTask(
`<select id="select" aria-label="Choose a number">
<option id="one" selected>One</option>
<option id="two">Two</option>
<option id="three">Three</option>
<option id="four" disabled>Four</option>
</select>`,
async (browser, accDoc) => {
// Test combobox
let select = getNativeInterface(accDoc, "select");
is(
select.getAttributeValue("AXRole"),
"AXPopUpButton",
"select has AXPopupButton role"
);
ok(select.attributeNames.includes("AXValue"), "select advertises AXValue");
is(
select.getAttributeValue("AXValue"),
"One",
"select has correctt initial value"
);
ok(
!select.attributeNames.includes("AXHasPopup"),
"select does not advertise AXHasPopup"
);
is(
select.getAttributeValue("AXHasPopup"),
null,
"select does not provide value for AXHasPopup"
);
ok(select.actionNames.includes("AXPress"), "Selectt has press action");
// These four events happen in quick succession when select is pressed
let events = Promise.all([
waitForMacEvent("AXMenuOpened"),
waitForMacEvent("AXSelectedChildrenChanged"),
waitForMacEvent(
"AXFocusedUIElementChanged",
e => e.getAttributeValue("AXRole") == "AXPopUpButton"
),
waitForMacEvent(
"AXFocusedUIElementChanged",
e => e.getAttributeValue("AXRole") == "AXMenuItem"
),
]);
select.performAction("AXPress");
// Only capture the target of AXMenuOpened (first element)
let [menu] = await events;
is(menu.getAttributeValue("AXRole"), "AXMenu", "dropdown has AXMenu role");
is(
menu.getAttributeValue("AXSelectedChildren").length,
1,
"dropdown has single selected child"
);
let selectedChildren = menu.getAttributeValue("AXSelectedChildren");
is(selectedChildren.length, 1, "Only one child is selected");
is(selectedChildren[0].getAttributeValue("AXRole"), "AXMenuItem");
is(selectedChildren[0].getAttributeValue("AXTitle"), "One");
let menuParent = menu.getAttributeValue("AXParent");
is(
menuParent.getAttributeValue("AXRole"),
"AXPopUpButton",
"dropdown parent is a popup button"
);
let menuItems = menu.getAttributeValue("AXChildren").map(c => {
return [
c.getAttributeValue("AXMenuItemMarkChar"),
c.getAttributeValue("AXRole"),
c.getAttributeValue("AXTitle"),
c.getAttributeValue("AXEnabled"),
];
});
Assert.deepEqual(
menuItems,
[
["✓", "AXMenuItem", "One", true],
[null, "AXMenuItem", "Two", true],
[null, "AXMenuItem", "Three", true],
[null, "AXMenuItem", "Four", false],
],
"Menu items have correct checkmark on current value, correctt roles, correct titles, and correct AXEnabled value"
);
events = Promise.all([
waitForMacEvent("AXSelectedChildrenChanged"),
waitForMacEvent("AXFocusedUIElementChanged"),
]);
EventUtils.synthesizeKey("KEY_ArrowDown");
let [, menuItem] = await events;
is(
menuItem.getAttributeValue("AXTitle"),
"Two",
"Focused menu item has correct title"
);
selectedChildren = menu.getAttributeValue("AXSelectedChildren");
is(selectedChildren.length, 1, "Only one child is selected");
is(
selectedChildren[0].getAttributeValue("AXTitle"),
"Two",
"Selected child matches focused item"
);
events = Promise.all([
waitForMacEvent("AXSelectedChildrenChanged"),
waitForMacEvent("AXFocusedUIElementChanged"),
]);
EventUtils.synthesizeKey("KEY_ArrowDown");
[, menuItem] = await events;
is(
menuItem.getAttributeValue("AXTitle"),
"Three",
"Focused menu item has correct title"
);
selectedChildren = menu.getAttributeValue("AXSelectedChildren");
is(selectedChildren.length, 1, "Only one child is selected");
is(
selectedChildren[0].getAttributeValue("AXTitle"),
"Three",
"Selected child matches focused item"
);
events = Promise.all([
waitForMacEvent("AXMenuClosed"),
waitForMacEvent("AXFocusedUIElementChanged"),
waitForMacEvent("AXSelectedChildrenChanged"),
]);
menuItem.performAction("AXPress");
let [, newFocus] = await events;
is(
newFocus.getAttributeValue("AXRole"),
"AXPopUpButton",
"Newly focused element is AXPopupButton"
);
is(
newFocus.getAttributeValue("AXDOMIdentifier"),
"select",
"Should return focus to select"
);
is(
newFocus.getAttributeValue("AXValue"),
"Three",
"select has correct new value"
);
}
);
|