|
1 <?xml version="1.0"?> |
|
2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
|
3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" |
|
4 type="text/css"?> |
|
5 <?xml-stylesheet href="general.css" |
|
6 type="text/css"?> |
|
7 |
|
8 |
|
9 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
|
10 title="Accessibility Name Calculating Test."> |
|
11 |
|
12 <script type="application/javascript" |
|
13 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> |
|
14 |
|
15 <script type="application/javascript" |
|
16 src="../common.js"></script> |
|
17 <script type="application/javascript" |
|
18 src="../role.js"></script> |
|
19 <script type="application/javascript" |
|
20 src="../name.js"></script> |
|
21 |
|
22 <script type="application/javascript"> |
|
23 <![CDATA[ |
|
24 function doTest() |
|
25 { |
|
26 // aria-label |
|
27 |
|
28 // Simple label provided via ARIA |
|
29 testName("btn_simple_aria_label", "I am a button"); |
|
30 |
|
31 // aria-label and aria-labelledby, expect aria-labelledby |
|
32 testName("btn_both_aria_labels", "text I am a button, two"); |
|
33 |
|
34 ////////////////////////////////////////////////////////////////////////// |
|
35 // aria-labelledby |
|
36 |
|
37 // Single relation. The value of 'aria-labelledby' contains the ID of |
|
38 // an element. Gets the name from text node of that element. |
|
39 testName("btn_labelledby_text", "text"); |
|
40 |
|
41 // Multiple relations. The value of 'aria-labelledby' contains the IDs |
|
42 // of elements. Gets the name from text nodes of those elements. |
|
43 testName("btn_labelledby_texts", "text1 text2"); |
|
44 |
|
45 // Trick cases. Self and recursive referencing. |
|
46 testName("rememberHistoryDays", "Remember 3 days"); |
|
47 testName("historyDays", "Remember 3 days"); |
|
48 testName("rememberAfter", null); // XUL labels doesn't allow name from subtree |
|
49 |
|
50 // Anonymous content (see name.xbl#third) |
|
51 var anonBtn = getAccessible("labelledby_box_anon").lastChild; |
|
52 testName(anonBtn, "It's a cool button"); |
|
53 |
|
54 ////////////////////////////////////////////////////////////////////////// |
|
55 // Name from subtree (single relation labelled_by). |
|
56 |
|
57 // Gets the name from text nodes contained by nested elements. |
|
58 testName("btn_labelledby_mixed", "nomore text"); |
|
59 |
|
60 // Gets the name from text nodes and selected item of menulist |
|
61 // (other items are ignored). |
|
62 testName("btn_labelledby_mixed_menulist", |
|
63 "nomore text selected item more text"); |
|
64 |
|
65 // Gets the name from text nodes contained by nested elements, ignores |
|
66 // hidden elements (bug 443081). |
|
67 testName("btn_labelledby_mixed_hidden_child", "nomore text2"); |
|
68 |
|
69 // Gets the name from hidden text nodes contained by nested elements, |
|
70 // (label element is hidden entirely), (bug 443081) |
|
71 testName("btn_labelledby_mixed_hidden", "lala more hidden text"); |
|
72 |
|
73 |
|
74 ////////////////////////////////////////////////////////////////////////// |
|
75 // Name for nsIDOMXULLabeledControlElement. |
|
76 |
|
77 // Gets the name from @label attribute. |
|
78 testName("btn_nsIDOMXULLabeledControlElement", "labeled element"); |
|
79 |
|
80 |
|
81 ////////////////////////////////////////////////////////////////////////// |
|
82 // Name for nsIDOMXULSelectControlItemElement. |
|
83 |
|
84 // Gets the name from @label attribute. |
|
85 testName("li_nsIDOMXULSelectControlItemElement", "select control item"); |
|
86 |
|
87 |
|
88 ////////////////////////////////////////////////////////////////////////// |
|
89 // Name if the XUL element doesn't implement nsIDOMXULSelectControlElement |
|
90 // and has @label attribute. |
|
91 |
|
92 testName("box_not_nsIDOMXULSelectControlElement", "box"); |
|
93 |
|
94 |
|
95 ////////////////////////////////////////////////////////////////////////// |
|
96 // Name from the label element. |
|
97 |
|
98 // The label and button are placed on 2nd level relative common parent. |
|
99 testName("btn_label_1", "label1"); |
|
100 |
|
101 // The label is on 1st, the button is on 5th level relative common parent. |
|
102 testName("btn_label_2", "label2"); |
|
103 |
|
104 // The label and button are siblings. |
|
105 testName("btn_label_3", "label3"); |
|
106 |
|
107 // Multiple labels for single button: XUL button takes the last one. |
|
108 testName("btn_label_4", "label5"); |
|
109 |
|
110 |
|
111 ////////////////////////////////////////////////////////////////////////// |
|
112 // Name from the label element in anonymous content (see bug 362365). |
|
113 |
|
114 // Get the name from anonymous label element for anonymous textbox |
|
115 // (@anonid is used). |
|
116 var ID = "box_label_anon1"; |
|
117 var box1Acc = testName(ID, null); |
|
118 if (box1Acc) { |
|
119 var textboxAcc = box1Acc.firstChild; |
|
120 is(textboxAcc.name, "Label", |
|
121 "Wrong label for anonymous textbox of " + ID); |
|
122 } |
|
123 |
|
124 // Get the name from anonymous label element for anonymous textbox |
|
125 // (@anonid is used). Nested bindings. |
|
126 ID = "box_label_anon2"; |
|
127 var box2Acc = testName(ID, null); |
|
128 if (box2Acc) { |
|
129 var textboxAcc = box2Acc.firstChild; |
|
130 is(textboxAcc.name, "Label", |
|
131 "Wrong label for anonymous textbox of " + ID); |
|
132 |
|
133 var topTextboxAcc = box2Acc.lastChild; |
|
134 is(topTextboxAcc.name, "Top textbox", |
|
135 "Wrong label for anonymous textbox of " + ID); |
|
136 } |
|
137 |
|
138 |
|
139 ////////////////////////////////////////////////////////////////////////// |
|
140 // tooltiptext (if nothing above isn't presented then tooltiptext is used) |
|
141 testName("box_tooltiptext", "tooltiptext label"); |
|
142 |
|
143 |
|
144 ////////////////////////////////////////////////////////////////////////// |
|
145 // Name from the @title attribute of <toolbaritem/> (original bug 237249). |
|
146 |
|
147 // Direct child of toolbaritem. |
|
148 var textboxAcc = testName("toolbaritem_textbox", "ooospspss"); |
|
149 |
|
150 // Element from anonymous content of direct child of toolbaritem. |
|
151 var entryAcc = textboxAcc.firstChild; |
|
152 testRole(entryAcc, ROLE_ENTRY); |
|
153 is(entryAcc.name, "ooospspss", |
|
154 "Wrong name for text entry of autocomplete textbox 'toolbaritem_textbox'."); |
|
155 |
|
156 // Child from subtree of toolbaritem. |
|
157 testName("toolbaritem_hboxbutton", "ooospspss"); |
|
158 |
|
159 |
|
160 ////////////////////////////////////////////////////////////////////////// |
|
161 // Name from children |
|
162 |
|
163 // ARIA role button is presented allowing the name calculation from |
|
164 // children. |
|
165 testName("box_children", "14"); |
|
166 |
|
167 // ARIA role option is presented allowing the name calculation from |
|
168 // the visible children (bug 443081) |
|
169 testName("lb_opt1_children_hidden", "i am visible"); |
|
170 |
|
171 |
|
172 ////////////////////////////////////////////////////////////////////////// |
|
173 // Name from aria-labelledby: menuitem label+ listitem label |
|
174 testName("li_labelledby", "Show an Alert The moment the event starts"); |
|
175 |
|
176 SimpleTest.finish(); |
|
177 } |
|
178 |
|
179 SimpleTest.waitForExplicitFinish(); |
|
180 addA11yLoadEvent(doTest); |
|
181 ]]> |
|
182 </script> |
|
183 |
|
184 <hbox flex="1" style="overflow: auto;"> |
|
185 |
|
186 <body xmlns="http://www.w3.org/1999/xhtml"> |
|
187 <a target="_blank" |
|
188 href="https://bugzilla.mozilla.org/show_bug.cgi?id=444279" |
|
189 title="mochitest for accessible name calculating"> |
|
190 Mozilla Bug 444279 |
|
191 </a> |
|
192 <a target="_blank" |
|
193 href="https://bugzilla.mozilla.org/show_bug.cgi?id=441991" |
|
194 title="nsXULListitemAccessible::GetName prefers label \ |
|
195 attribute over aria-labelledby and doesn't allow recursion"> |
|
196 Mozilla Bug 441991 |
|
197 </a> |
|
198 <p id="display"></p> |
|
199 <div id="content" style="display: none"> |
|
200 </div> |
|
201 <pre id="test"> |
|
202 </pre> |
|
203 </body> |
|
204 |
|
205 <vbox flex="1"> |
|
206 |
|
207 <!-- aria-label, simple label --> |
|
208 <button id="btn_simple_aria_label" aria-label="I am a button"/> |
|
209 |
|
210 <!-- aria-label plus aria-labelledby --> |
|
211 <button id="btn_both_aria_labels" aria-label="I am a button, two" |
|
212 aria-labelledby="labelledby_text btn_both_aria_labels"/> |
|
213 |
|
214 <!-- aria-labelledby, single relation --> |
|
215 <description id="labelledby_text">text</description> |
|
216 <button id="btn_labelledby_text" |
|
217 aria-labelledby="labelledby_text"/> |
|
218 |
|
219 <!-- aria-labelledby, multiple relations --> |
|
220 <description id="labelledby_text1">text1</description> |
|
221 <description id="labelledby_text2">text2</description> |
|
222 <button id="btn_labelledby_texts" |
|
223 aria-labelledby="labelledby_text1 labelledby_text2"/> |
|
224 |
|
225 <!-- aria-labelledby, multiple relations --> |
|
226 <box class="third" id="labelledby_box_anon" role="group" /> |
|
227 |
|
228 <!-- trick aria-labelledby --> |
|
229 <checkbox id="rememberHistoryDays" |
|
230 label="Remember " |
|
231 aria-labelledby="rememberHistoryDays historyDays rememberAfter"/> |
|
232 <textbox id="historyDays" type="number" size="3" value="3" |
|
233 aria-labelledby="rememberHistoryDays historyDays rememberAfter"/> |
|
234 <label id="rememberAfter">days</label> |
|
235 |
|
236 <!-- the name from subtree, mixed content --> |
|
237 <description id="labelledby_mixed"> |
|
238 no<description>more text</description> |
|
239 </description> |
|
240 <button id="btn_labelledby_mixed" |
|
241 aria-labelledby="labelledby_mixed"/> |
|
242 |
|
243 <!-- the name from subtree, mixed/hidden content --> |
|
244 <description id="labelledby_mixed_hidden_child">no<description>more <description hidden="true">hidden</description>text2</description></description> |
|
245 <button id="btn_labelledby_mixed_hidden_child" |
|
246 aria-labelledby="labelledby_mixed_hidden_child"/> |
|
247 |
|
248 <!-- the name from subtree, mixed/completely hidden content --> |
|
249 <description id="labelledby_mixed_hidden" |
|
250 hidden="true">lala <description>more hidden </description>text</description> |
|
251 <button id="btn_labelledby_mixed_hidden" |
|
252 aria-labelledby="labelledby_mixed_hidden"/> |
|
253 <br/> |
|
254 |
|
255 <!-- the name from subtree, mixed content, ignore items of menulist --> |
|
256 <description id="labelledby_mixed_menulist"> |
|
257 no<description>more text</description> |
|
258 <menulist> |
|
259 <menupopup> |
|
260 <menuitem label="selected item"/> |
|
261 <menuitem label="item"/> |
|
262 </menupopup> |
|
263 </menulist> |
|
264 more text |
|
265 </description> |
|
266 <button id="btn_labelledby_mixed_menulist" |
|
267 aria-labelledby="labelledby_mixed_menulist"/> |
|
268 |
|
269 <!-- nsIDOMXULLabeledControlElement --> |
|
270 <button id="btn_nsIDOMXULLabeledControlElement" |
|
271 label="labeled element"/> |
|
272 |
|
273 <!-- nsIDOMXULSelectControlItemElement --> |
|
274 <listbox> |
|
275 <listitem id="li_nsIDOMXULSelectControlItemElement" |
|
276 label="select control item"/> |
|
277 </listbox> |
|
278 |
|
279 <!-- not nsIDOMXULSelectControlElement --> |
|
280 <box id="box_not_nsIDOMXULSelectControlElement" role="group" label="box"/> |
|
281 |
|
282 <!-- label element --> |
|
283 <hbox> |
|
284 <box> |
|
285 <label control="btn_label_1">label1</label> |
|
286 </box> |
|
287 <label control="btn_label_2">label2</label> |
|
288 <box> |
|
289 <button id="btn_label_1"/> |
|
290 <box> |
|
291 <box> |
|
292 <box> |
|
293 <button id="btn_label_2"/> |
|
294 </box> |
|
295 </box> |
|
296 </box> |
|
297 </box> |
|
298 <label control="btn_label_3">label3</label> |
|
299 <button id="btn_label_3"/> |
|
300 |
|
301 <label control="btn_label_4">label4</label> |
|
302 <label control="btn_label_4">label5</label> |
|
303 <button id="btn_label_4"/> |
|
304 </hbox> |
|
305 |
|
306 <!-- label element, anonymous content --> |
|
307 <box id="box_label_anon1" |
|
308 class="first" |
|
309 role="group"/> |
|
310 |
|
311 <box id="box_label_anon2" |
|
312 class="second" |
|
313 role="group"/> |
|
314 |
|
315 <!-- tooltiptext --> |
|
316 <box id="box_tooltiptext" |
|
317 role="group" |
|
318 tooltiptext="tooltiptext label"/> |
|
319 |
|
320 <!-- the name from @title of toolbaritem --> |
|
321 <toolbar> |
|
322 <toolbaritem title="ooospspss"> |
|
323 <textbox id="toolbaritem_textbox" |
|
324 flex="1" |
|
325 type="autocomplete" |
|
326 enablehistory="true"> |
|
327 <hbox role="button" id="toolbaritem_hboxbutton"> |
|
328 <description value="button"/> |
|
329 </hbox> |
|
330 </textbox> |
|
331 </toolbaritem> |
|
332 </toolbar> |
|
333 |
|
334 <!-- name from children --> |
|
335 <box id="box_children" role="button">14</box> |
|
336 |
|
337 <!-- name from children, hidden children --> |
|
338 <vbox role="listbox" tabindex="0"> |
|
339 <hbox id="lb_opt1_children_hidden" role="option" tabindex="0"> |
|
340 <description>i am visible</description> |
|
341 <description style="display:none">i am hidden</description> |
|
342 </hbox> |
|
343 </vbox> |
|
344 |
|
345 <!-- bug 441991; create name from other menuitem label listitem's own label --> |
|
346 <hbox> |
|
347 <listbox> |
|
348 <listitem id="li_labelledby" |
|
349 label="The moment the event starts" |
|
350 aria-labelledby="menuitem-DISPLAY li_labelledby"/> |
|
351 </listbox> |
|
352 <menulist> |
|
353 <menupopup> |
|
354 <menuitem id="menuitem-DISPLAY" |
|
355 value="DISPLAY" |
|
356 label="Show an Alert"/> |
|
357 <menuitem id="menuitem-EMAIL" |
|
358 value="EMAIL" |
|
359 label="Send an E-mail"/> |
|
360 </menupopup> |
|
361 </menulist> |
|
362 </hbox> |
|
363 |
|
364 </vbox> <!-- close tests area --> |
|
365 </hbox> <!-- close main area --> |
|
366 </window> |
|
367 |