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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
|
/* 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/states.js */
loadScripts({ name: "states.js", dir: MOCHITESTS_DIR });
/**
* Test outline, outline rows with computed properties
*/
addAccessibleTask(
`
<h3 id="tree1">
Foods
</h3>
<ul role="tree" aria-labelledby="tree1" id="outline">
<li role="treeitem" aria-expanded="false">
<span>
Fruits
</span>
<ul>
<li role="none">Oranges</li>
<li role="treeitem" aria-expanded="true">
<span>
Apples
</span>
<ul role="group">
<li role="none">Honeycrisp</li>
<li role="none">Granny Smith</li>
</ul>
</li>
</ul>
</li>
<li id="vegetables" role="treeitem" aria-expanded="false">
<span>
Vegetables
</span>
<ul role="group">
<li role="treeitem" aria-expanded="true">
<span>
Podded Vegetables
</span>
<ul role="group">
<li role="none">Lentil</li>
<li role="none">Pea</li>
</ul>
</li>
</ul>
</li>
</ul>
`,
async (browser, accDoc) => {
const outline = getNativeInterface(accDoc, "outline");
is(
outline.getAttributeValue("AXRole"),
"AXOutline",
"Correct role for outline"
);
const outChildren = outline.getAttributeValue("AXChildren");
is(outChildren.length, 2, "Outline has two direct children");
is(outChildren[0].getAttributeValue("AXSubrole"), "AXOutlineRow");
is(outChildren[1].getAttributeValue("AXSubrole"), "AXOutlineRow");
const outRows = outline.getAttributeValue("AXRows");
is(outRows.length, 4, "Outline has four rows");
is(
outRows[0].getAttributeValue("AXDisclosing"),
0,
"Row is not disclosing"
);
is(
outRows[0].getAttributeValue("AXDisclosedByRow"),
null,
"Row is direct child of outline"
);
is(
outRows[0].getAttributeValue("AXDisclosedRows").length,
0,
"Row has no row children, only group"
);
is(
outRows[0].getAttributeValue("AXDisclosureLevel"),
0,
"Row is level zero"
);
is(outRows[1].getAttributeValue("AXDisclosing"), 1, "Row is disclosing");
is(
outRows[1].getAttributeValue("AXDisclosedByRow"),
null,
"Row is direct child of group"
);
is(
outRows[1].getAttributeValue("AXDisclosedRows").length,
0,
"Row has no row children"
);
is(
outRows[1].getAttributeValue("AXDisclosureLevel"),
0,
"Row is level zero"
);
is(
outRows[2].getAttributeValue("AXDisclosing"),
0,
"Row is not disclosing"
);
is(
outRows[2].getAttributeValue("AXDisclosedByRow"),
null,
"Row is direct child of outline"
);
is(
outRows[2].getAttributeValue("AXDisclosedRows").length,
1,
"Row has one row child"
);
is(
outRows[2].getAttributeValue("AXDisclosureLevel"),
0,
"Row is level zero"
);
is(outRows[3].getAttributeValue("AXDisclosing"), 1, "Row is disclosing");
is(
outRows[3]
.getAttributeValue("AXDisclosedByRow")
.getAttributeValue("AXDescription"),
outRows[2].getAttributeValue("AXDescription"),
"Row is direct child of row[2]"
);
is(
outRows[3].getAttributeValue("AXDisclosedRows").length,
0,
"Row has no row children"
);
is(
outRows[3].getAttributeValue("AXDisclosureLevel"),
1,
"Row is level one"
);
let evt = waitForMacEvent("AXRowExpanded", "vegetables");
await SpecialPowers.spawn(browser, [], () => {
content.document
.getElementById("vegetables")
.setAttribute("aria-expanded", "true");
});
await evt;
is(
outRows[2].getAttributeValue("AXDisclosing"),
1,
"Row is disclosing after being expanded"
);
evt = waitForMacEvent("AXRowCollapsed", "vegetables");
await SpecialPowers.spawn(browser, [], () => {
content.document
.getElementById("vegetables")
.setAttribute("aria-expanded", "false");
});
await evt;
is(
outRows[2].getAttributeValue("AXDisclosing"),
0,
"Row is not disclosing after being collapsed again"
);
}
);
/**
* Test outline, outline rows with declared properties
*/
addAccessibleTask(
`
<h3 id="tree1">
Foods
</h3>
<ul role="tree" aria-labelledby="tree1" id="outline">
<li role="treeitem"
aria-level="1"
aria-setsize="2"
aria-posinset="1"
aria-expanded="false">
<span>
Fruits
</span>
<ul>
<li role="treeitem"
aria-level="3"
aria-setsize="2"
aria-posinset="1">
Oranges
</li>
<li role="treeitem"
aria-level="2"
aria-setsize="2"
aria-posinset="2"
aria-expanded="true">
<span>
Apples
</span>
<ul role="group">
<li role="treeitem"
aria-level="3"
aria-setsize="2"
aria-posinset="1">
Honeycrisp
</li>
<li role="treeitem"
aria-level="3"
aria-setsize="2"
aria-posinset="2">
Granny Smith
</li>
</ul>
</li>
</ul>
</li>
<li role="treeitem"
aria-level="1"
aria-setsize="2"
aria-posinset="2"
aria-expanded="false">
<span>
Vegetables
</span>
<ul role="group">
<li role="treeitem"
aria-level="2"
aria-setsize="1"
aria-posinset="1"
aria-expanded="true">
<span>
Podded Vegetables
</span>
<ul role="group">
<li role="treeitem"
aria-level="3"
aria-setsize="2"
aria-posinset="1">
Lentil
</li>
<li role="treeitem"
aria-level="3"
aria-setsize="2"
aria-posinset="2">
Pea
</li>
</ul>
</li>
</ul>
</li>
</ul>
`,
async (browser, accDoc) => {
const outline = getNativeInterface(accDoc, "outline");
is(
outline.getAttributeValue("AXRole"),
"AXOutline",
"Correct role for outline"
);
const outChildren = outline.getAttributeValue("AXChildren");
is(outChildren.length, 2, "Outline has two direct children");
is(outChildren[0].getAttributeValue("AXSubrole"), "AXOutlineRow");
is(outChildren[1].getAttributeValue("AXSubrole"), "AXOutlineRow");
const outRows = outline.getAttributeValue("AXRows");
is(outRows.length, 9, "Outline has nine rows");
is(
outRows[0].getAttributeValue("AXDisclosing"),
0,
"Row is not disclosing"
);
is(
outRows[0].getAttributeValue("AXDisclosedByRow"),
null,
"Row is direct child of outline"
);
is(
outRows[0].getAttributeValue("AXDisclosedRows").length,
0,
"Row has no direct row children, has list"
);
is(
outRows[0].getAttributeValue("AXDisclosureLevel"),
0,
"Row is level zero"
);
is(outRows[2].getAttributeValue("AXDisclosing"), 1, "Row is disclosing");
is(
outRows[2].getAttributeValue("AXDisclosedByRow"),
null,
"Row is direct child of group"
);
is(
outRows[2].getAttributeValue("AXDisclosedRows").length,
2,
"Row has two row children"
);
is(
outRows[2].getAttributeValue("AXDisclosureLevel"),
1,
"Row is level one"
);
is(
outRows[3].getAttributeValue("AXDisclosing"),
0,
"Row is not disclosing"
);
is(
outRows[3]
.getAttributeValue("AXDisclosedByRow")
.getAttributeValue("AXDescription"),
outRows[2].getAttributeValue("AXDescription"),
"Row is direct child of row 2"
);
is(
outRows[3].getAttributeValue("AXDisclosedRows").length,
0,
"Row has no row children"
);
is(
outRows[3].getAttributeValue("AXDisclosureLevel"),
2,
"Row is level two"
);
is(
outRows[5].getAttributeValue("AXDisclosing"),
0,
"Row is not disclosing"
);
is(
outRows[5].getAttributeValue("AXDisclosedByRow"),
null,
"Row is direct child of outline"
);
is(
outRows[5].getAttributeValue("AXDisclosedRows").length,
1,
"Row has no one row child"
);
is(
outRows[5].getAttributeValue("AXDisclosureLevel"),
0,
"Row is level zero"
);
is(outRows[6].getAttributeValue("AXDisclosing"), 1, "Row is disclosing");
is(
outRows[6]
.getAttributeValue("AXDisclosedByRow")
.getAttributeValue("AXDescription"),
outRows[5].getAttributeValue("AXDescription"),
"Row is direct child of row 5"
);
is(
outRows[6].getAttributeValue("AXDisclosedRows").length,
2,
"Row has two row children"
);
is(
outRows[6].getAttributeValue("AXDisclosureLevel"),
1,
"Row is level one"
);
is(
outRows[7].getAttributeValue("AXDisclosing"),
0,
"Row is not disclosing"
);
is(
outRows[7]
.getAttributeValue("AXDisclosedByRow")
.getAttributeValue("AXDescription"),
outRows[6].getAttributeValue("AXDescription"),
"Row is direct child of row 6"
);
is(
outRows[7].getAttributeValue("AXDisclosedRows").length,
0,
"Row has no row children"
);
is(
outRows[7].getAttributeValue("AXDisclosureLevel"),
2,
"Row is level two"
);
}
);
// Test outline that isn't built with li/uls gets correct desc
addAccessibleTask(
`
<div role="tree" id="tree" tabindex="0" aria-label="My drive" aria-activedescendant="myfiles">
<div id="myfiles" role="treeitem" aria-label="My files" aria-selected="true" aria-expanded="false">My files</div>
<div role="treeitem" aria-label="Shared items" aria-selected="false" aria-expanded="false">Shared items</div>
</div>
`,
async (browser, accDoc) => {
const tree = getNativeInterface(accDoc, "tree");
is(tree.getAttributeValue("AXRole"), "AXOutline", "Correct role for tree");
const treeItems = tree.getAttributeValue("AXChildren");
is(treeItems.length, 2, "Outline has two direct children");
is(treeItems[0].getAttributeValue("AXSubrole"), "AXOutlineRow");
is(treeItems[1].getAttributeValue("AXSubrole"), "AXOutlineRow");
const outRows = tree.getAttributeValue("AXRows");
is(outRows.length, 2, "Outline has two rows");
is(
outRows[0].getAttributeValue("AXDescription"),
"My files",
"files labelled correctly"
);
is(
outRows[1].getAttributeValue("AXDescription"),
"Shared items",
"shared items labelled correctly"
);
}
);
// Test outline registers AXDisclosed attr as settable
addAccessibleTask(
`
<div role="tree" id="tree" tabindex="0" aria-label="My drive" aria-activedescendant="myfiles">
<div id="myfiles" role="treeitem" aria-label="My files" aria-selected="true" aria-expanded="false">My files</div>
<div role="treeitem" aria-label="Shared items" aria-selected="false" aria-expanded="true">Shared items</div>
</div>
`,
async (browser, accDoc) => {
const tree = getNativeInterface(accDoc, "tree");
const treeItems = tree.getAttributeValue("AXChildren");
is(treeItems.length, 2, "Outline has two direct children");
is(treeItems[0].getAttributeValue("AXDisclosing"), 0);
is(treeItems[1].getAttributeValue("AXDisclosing"), 1);
is(treeItems[0].isAttributeSettable("AXDisclosing"), true);
is(treeItems[1].isAttributeSettable("AXDisclosing"), true);
// attempt to change attribute values
treeItems[0].setAttributeValue("AXDisclosing", 1);
treeItems[0].setAttributeValue("AXDisclosing", 0);
// verify they're unchanged
is(treeItems[0].getAttributeValue("AXDisclosing"), 0);
is(treeItems[1].getAttributeValue("AXDisclosing"), 1);
}
);
// Test outline rows correctly expose checkable, checked/unchecked/mixed status
addAccessibleTask(
`
<div role="tree" id="tree">
<div role="treeitem" aria-checked="false" id="l1">
Leaf 1
</div>
<div role="treeitem" aria-checked="true" id="l2">
Leaf 2
</div>
<div role="treeitem" id="l3">
Leaf 3
</div>
<div role="treeitem" aria-checked="mixed" id="l4">
Leaf 4
</div>
</div>
`,
async (browser, accDoc) => {
const tree = getNativeInterface(accDoc, "tree");
const treeItems = tree.getAttributeValue("AXChildren");
is(treeItems.length, 4, "Outline has four direct children");
is(
treeItems[0].getAttributeValue("AXValue"),
0,
"Child one is not checked"
);
is(treeItems[1].getAttributeValue("AXValue"), 1, "Child two is checked");
is(
treeItems[2].getAttributeValue("AXValue"),
null,
"Child three is not checkable and has no val"
);
is(treeItems[3].getAttributeValue("AXValue"), 2, "Child four is mixed");
let stateChanged = Promise.all([
waitForMacEvent("AXValueChanged", "l1"),
waitForStateChange("l1", STATE_CHECKED, true),
]);
// We should get a state change event for checked.
await SpecialPowers.spawn(browser, [], () => {
content.document
.getElementById("l1")
.setAttribute("aria-checked", "true");
});
await stateChanged;
is(treeItems[0].getAttributeValue("AXValue"), 1, "Child one is checked");
stateChanged = Promise.all([
waitForMacEvent("AXValueChanged", "l2"),
waitForMacEvent("AXValueChanged", "l2"),
waitForStateChange("l2", STATE_CHECKED, false),
waitForStateChange("l2", STATE_CHECKABLE, false),
]);
// We should get a state change event for both checked and checkable,
// and value changes for both.
await SpecialPowers.spawn(browser, [], () => {
content.document.getElementById("l2").removeAttribute("aria-checked");
});
await stateChanged;
is(
treeItems[1].getAttributeValue("AXValue"),
null,
"Child two is not checkable and has no val"
);
stateChanged = Promise.all([
waitForMacEvent("AXValueChanged", "l3"),
waitForMacEvent("AXValueChanged", "l3"),
waitForStateChange("l3", STATE_CHECKED, true),
waitForStateChange("l3", STATE_CHECKABLE, true),
]);
// We should get a state change event for both checked and checkable,
// and value changes for each.
await SpecialPowers.spawn(browser, [], () => {
content.document
.getElementById("l3")
.setAttribute("aria-checked", "true");
});
await stateChanged;
is(treeItems[2].getAttributeValue("AXValue"), 1, "Child three is checked");
stateChanged = Promise.all([
waitForMacEvent("AXValueChanged", "l4"),
waitForMacEvent("AXValueChanged", "l4"),
waitForStateChange("l4", STATE_MIXED, false),
waitForStateChange("l4", STATE_CHECKABLE, false),
]);
// We should get a state change event for both mixed and checkable,
// and value changes for each.
await SpecialPowers.spawn(browser, [], () => {
content.document.getElementById("l4").removeAttribute("aria-checked");
});
await stateChanged;
is(
treeItems[3].getAttributeValue("AXValue"),
null,
"Child four is not checkable and has no value"
);
}
);
|