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
|
/* 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";
/**
* Test document with no single group child
*/
addAccessibleTask(
`<p id="p1">hello</p><p>world</p>`,
async (browser, accDoc) => {
let doc = accDoc.nativeInterface.QueryInterface(
Ci.nsIAccessibleMacInterface
);
let docChildren = doc.getAttributeValue("AXChildren");
is(docChildren.length, 1, "The document contains a root group");
let rootGroup = docChildren[0];
is(
rootGroup.getAttributeValue("AXIdentifier"),
"root-group",
"Is generated root group"
);
is(
rootGroup.getAttributeValue("AXChildren").length,
2,
"Root group has two children"
);
// From bottom-up
let p1 = getNativeInterface(accDoc, "p1");
rootGroup = p1.getAttributeValue("AXParent");
is(
rootGroup.getAttributeValue("AXIdentifier"),
"root-group",
"Is generated root group"
);
}
);
/**
* Test document with a top-level group
*/
addAccessibleTask(
`<div role="grouping" id="group"><p>hello</p><p>world</p></div>`,
async (browser, accDoc) => {
let doc = accDoc.nativeInterface.QueryInterface(
Ci.nsIAccessibleMacInterface
);
let docChildren = doc.getAttributeValue("AXChildren");
is(docChildren.length, 1, "The document contains a root group");
let rootGroup = docChildren[0];
is(
rootGroup.getAttributeValue("AXDOMIdentifier"),
"group",
"Root group is a document element"
);
// Adding an 'application' role to the body should
// create a root group with an application subrole.
let evt = waitForMacEvent("AXMozRoleChanged");
await SpecialPowers.spawn(browser, [], () => {
content.document.body.setAttribute("role", "application");
});
await evt;
is(
doc.getAttributeValue("AXRole"),
"AXWebArea",
"doc still has web area role"
);
is(
doc.getAttributeValue("AXRoleDescription"),
"HTML Content",
"doc has correct role description"
);
ok(
!doc.attributeNames.includes("AXSubrole"),
"sub role not available on web area"
);
rootGroup = doc.getAttributeValue("AXChildren")[0];
is(
rootGroup.getAttributeValue("AXIdentifier"),
"root-group",
"Is generated root group"
);
is(
rootGroup.getAttributeValue("AXRole"),
"AXGroup",
"root group has AXGroup role"
);
is(
rootGroup.getAttributeValue("AXSubrole"),
"AXLandmarkApplication",
"root group has application subrole"
);
is(
rootGroup.getAttributeValue("AXRoleDescription"),
"application",
"root group has application role description"
);
}
);
/**
* Test document with body[role=application] and a top-level group
*/
addAccessibleTask(
`<div role="grouping" id="group"><p>hello</p><p>world</p></div>`,
async (browser, accDoc) => {
let doc = accDoc.nativeInterface.QueryInterface(
Ci.nsIAccessibleMacInterface
);
is(
doc.getAttributeValue("AXRole"),
"AXWebArea",
"doc still has web area role"
);
is(
doc.getAttributeValue("AXRoleDescription"),
"HTML Content",
"doc has correct role description"
);
ok(
!doc.attributeNames.includes("AXSubrole"),
"sub role not available on web area"
);
let rootGroup = doc.getAttributeValue("AXChildren")[0];
is(
rootGroup.getAttributeValue("AXIdentifier"),
"root-group",
"Is generated root group"
);
is(
rootGroup.getAttributeValue("AXRole"),
"AXGroup",
"root group has AXGroup role"
);
is(
rootGroup.getAttributeValue("AXSubrole"),
"AXLandmarkApplication",
"root group has application subrole"
);
is(
rootGroup.getAttributeValue("AXRoleDescription"),
"application",
"root group has application role description"
);
},
{ contentDocBodyAttrs: { role: "application" } }
);
/**
* Test document with a single button
*/
addAccessibleTask(
`<button id="button">I am a button</button>`,
async (browser, accDoc) => {
let doc = accDoc.nativeInterface.QueryInterface(
Ci.nsIAccessibleMacInterface
);
let docChildren = doc.getAttributeValue("AXChildren");
is(docChildren.length, 1, "The document contains a root group");
let rootGroup = docChildren[0];
is(
rootGroup.getAttributeValue("AXIdentifier"),
"root-group",
"Is generated root group"
);
let rootGroupChildren = rootGroup.getAttributeValue("AXChildren");
is(rootGroupChildren.length, 1, "Root group has one children");
is(
rootGroupChildren[0].getAttributeValue("AXRole"),
"AXButton",
"Button is child of root group"
);
// From bottom-up
let button = getNativeInterface(accDoc, "button");
rootGroup = button.getAttributeValue("AXParent");
is(
rootGroup.getAttributeValue("AXIdentifier"),
"root-group",
"Is generated root group"
);
}
);
|