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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
|
/* 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/selectable.js */
/* import-globals-from ../../mochitest/states.js */
// ////////////////////////////////////////////////////////////////////////
// select@size="1" aka combobox
addAccessibleTask(
`<select id="combobox">
<option id="item1">option1</option>
<option id="item2">option2</option>
</select>`,
async function (browser, docAcc) {
info("select@size='1' aka combobox");
let combobox = findAccessibleChildByID(docAcc, "combobox");
let comboboxList = combobox.firstChild;
ok(
isAccessible(comboboxList, [nsIAccessibleSelectable]),
"No selectable accessible for combobox"
);
let select = getAccessible(comboboxList, [nsIAccessibleSelectable]);
testSelectableSelection(select, ["item1"]);
// select 2nd item
let promise = Promise.all([
waitForStateChange("item2", STATE_SELECTED, true),
waitForStateChange("item1", STATE_SELECTED, false),
]);
select.addItemToSelection(1);
await promise;
testSelectableSelection(select, ["item2"], "addItemToSelection(1): ");
// unselect 2nd item, 1st item gets selected automatically
promise = Promise.all([
waitForStateChange("item2", STATE_SELECTED, false),
waitForStateChange("item1", STATE_SELECTED, true),
]);
select.removeItemFromSelection(1);
await promise;
testSelectableSelection(select, ["item1"], "removeItemFromSelection(1): ");
// doesn't change selection
is(select.selectAll(), false, "No way to select all items in combobox");
testSelectableSelection(select, ["item1"], "selectAll: ");
// doesn't change selection
select.unselectAll();
testSelectableSelection(select, ["item1"], "unselectAll: ");
},
{
chrome: true,
topLevel: true,
iframe: true,
remoteIframe: true,
}
);
// ////////////////////////////////////////////////////////////////////////
// select@size="1" with optgroups
addAccessibleTask(
`<select id="combobox">
<option id="item1">option1</option>
<optgroup>optgroup
<option id="item2">option2</option>
</optgroup>
</select>`,
async function (browser, docAcc) {
info("select@size='1' with optgroups");
let combobox = findAccessibleChildByID(docAcc, "combobox");
let comboboxList = combobox.firstChild;
ok(
isAccessible(comboboxList, [nsIAccessibleSelectable]),
"No selectable accessible for combobox"
);
let select = getAccessible(comboboxList, [nsIAccessibleSelectable]);
testSelectableSelection(select, ["item1"]);
let promise = Promise.all([
waitForStateChange("item2", STATE_SELECTED, true),
waitForStateChange("item1", STATE_SELECTED, false),
]);
select.addItemToSelection(1);
await promise;
testSelectableSelection(select, ["item2"], "addItemToSelection(1): ");
promise = Promise.all([
waitForStateChange("item2", STATE_SELECTED, false),
waitForStateChange("item1", STATE_SELECTED, true),
]);
select.removeItemFromSelection(1);
await promise;
testSelectableSelection(select, ["item1"], "removeItemFromSelection(1): ");
is(select.selectAll(), false, "No way to select all items in combobox");
testSelectableSelection(select, ["item1"]);
select.unselectAll();
testSelectableSelection(select, ["item1"]);
},
{
chrome: true,
topLevel: true,
iframe: true,
remoteIframe: true,
}
);
// ////////////////////////////////////////////////////////////////////////
// select@size="4" aka single selectable listbox
addAccessibleTask(
`<select id="listbox" size="4">
<option id="item1">option1</option>
<option id="item2">option2</option>
</select>`,
async function (browser, docAcc) {
info("select@size='4' aka single selectable listbox");
let select = findAccessibleChildByID(docAcc, "listbox", [
nsIAccessibleSelectable,
]);
testSelectableSelection(select, []);
// select 2nd item
let promise = waitForStateChange("item2", STATE_SELECTED, true);
select.addItemToSelection(1);
await promise;
testSelectableSelection(select, ["item2"], "addItemToSelection(1): ");
// unselect 2nd item, 1st item gets selected automatically
promise = waitForStateChange("item2", STATE_SELECTED, false);
select.removeItemFromSelection(1);
await promise;
testSelectableSelection(select, [], "removeItemFromSelection(1): ");
// doesn't change selection
is(
select.selectAll(),
false,
"No way to select all items in single selectable listbox"
);
testSelectableSelection(select, [], "selectAll: ");
// doesn't change selection
select.unselectAll();
testSelectableSelection(select, [], "unselectAll: ");
},
{
chrome: true,
topLevel: true,
iframe: true,
remoteIframe: true,
}
);
// ////////////////////////////////////////////////////////////////////////
// select@size="4" with optgroups, single selectable
addAccessibleTask(
`<select id="listbox" size="4">
<option id="item1">option1</option>
<optgroup>optgroup>
<option id="item2">option2</option>
</optgroup>
</select>`,
async function (browser, docAcc) {
info("select@size='4' with optgroups, single selectable");
let select = findAccessibleChildByID(docAcc, "listbox", [
nsIAccessibleSelectable,
]);
testSelectableSelection(select, []);
let promise = waitForStateChange("item2", STATE_SELECTED, true);
select.addItemToSelection(1);
await promise;
testSelectableSelection(select, ["item2"]);
promise = waitForStateChange("item2", STATE_SELECTED, false);
select.removeItemFromSelection(1);
await promise;
testSelectableSelection(select, []);
is(
select.selectAll(),
false,
"No way to select all items in single selectable listbox"
);
testSelectableSelection(select, []);
select.unselectAll();
testSelectableSelection(select, []);
},
{
chrome: true,
topLevel: true,
iframe: true,
remoteIframe: true,
}
);
// ////////////////////////////////////////////////////////////////////////
// select@size="4" multiselect aka listbox
addAccessibleTask(
`<select id="listbox" size="4" multiple="true">
<option id="item1">option1</option>
<option id="item2">option2</option>
</select>`,
async function (browser, docAcc) {
info("select@size='4' multiselect aka listbox");
let select = findAccessibleChildByID(docAcc, "listbox", [
nsIAccessibleSelectable,
]);
await testMultiSelectable(
select,
["item1", "item2"],
"select@size='4' multiselect aka listbox "
);
},
{
chrome: true,
topLevel: true,
iframe: true,
remoteIframe: true,
}
);
// ////////////////////////////////////////////////////////////////////////
// select@size="4" multiselect with optgroups
addAccessibleTask(
`<select id="listbox" size="4" multiple="true">
<option id="item1">option1</option>
<optgroup>optgroup>
<option id="item2">option2</option>
</optgroup>
</select>`,
async function (browser, docAcc) {
info("select@size='4' multiselect with optgroups");
let select = findAccessibleChildByID(docAcc, "listbox", [
nsIAccessibleSelectable,
]);
await testMultiSelectable(
select,
["item1", "item2"],
"select@size='4' multiselect aka listbox "
);
},
{
chrome: true,
topLevel: true,
iframe: true,
remoteIframe: true,
}
);
// ////////////////////////////////////////////////////////////////////////
// multiselect with coalesced selection event
addAccessibleTask(
`<select id="listbox" size="4" multiple="true">
<option id="item1">option1</option>
<option id="item2">option2</option>
<option id="item3">option3</option>
<option id="item4">option4</option>
<option id="item5">option5</option>
<option id="item6">option6</option>
<option id="item7">option7</option>
<option id="item8">option8</option>
<option id="item9">option9</option>
</select>`,
async function (browser, docAcc) {
info("select@size='4' multiselect with coalesced selection event");
let select = findAccessibleChildByID(docAcc, "listbox", [
nsIAccessibleSelectable,
]);
await testMultiSelectable(
select,
[
"item1",
"item2",
"item3",
"item4",
"item5",
"item6",
"item7",
"item8",
"item9",
],
"select@size='4' multiselect with coalesced selection event "
);
},
{
chrome: false,
topLevel: true,
iframe: false,
remoteIframe: false,
}
);
/**
* Ensure that we don't assert when dealing with defunct items in selection
* events dropped due to coalescence (bug 1800755).
*/
addAccessibleTask(
`
<form id="form">
<select id="select">
<option>
<optgroup id="optgroup">
<option>
</optgroup>
</select>
</form>
`,
async function (browser, docAcc) {
let selected = waitForEvent(EVENT_SELECTION_WITHIN, "select");
await invokeContentTask(browser, [], () => {
const form = content.document.getElementById("form");
const select = content.document.getElementById("select");
const optgroup = content.document.getElementById("optgroup");
form.reset();
select.selectedIndex = 1;
select.add(optgroup);
select.item(0).remove();
});
await selected;
}
);
|