|
1 <html> |
|
2 |
|
3 <head> |
|
4 <title>AccessFu tests for live regions support</title> |
|
5 |
|
6 <link rel="stylesheet" type="text/css" |
|
7 href="chrome://mochikit/content/tests/SimpleTest/test.css" /> |
|
8 <script type="application/javascript" |
|
9 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
10 <script type="application/javascript" |
|
11 src="../common.js"></script> |
|
12 <script type="application/javascript" |
|
13 src="./jsatcommon.js"></script> |
|
14 <script type="application/javascript"> |
|
15 |
|
16 function startAccessFu() { |
|
17 SpecialPowers.setIntPref("accessibility.accessfu.activate", 1); |
|
18 AccessFuTest.once_log("EventManager.start", AccessFuTest.nextTest); |
|
19 } |
|
20 |
|
21 function stopAccessFu() { |
|
22 SpecialPowers.setIntPref("accessibility.accessfu.activate", 0); |
|
23 AccessFuTest.once_log("EventManager.stop", AccessFuTest.finish); |
|
24 } |
|
25 |
|
26 function hide(id) { |
|
27 var element = document.getElementById(id); |
|
28 element.style.display = "none"; |
|
29 } |
|
30 |
|
31 function show(id) { |
|
32 var element = document.getElementById(id); |
|
33 element.style.display = "block"; |
|
34 } |
|
35 |
|
36 function udpate(id, text, property) { |
|
37 var element = document.getElementById(id); |
|
38 element[property] = text; |
|
39 } |
|
40 |
|
41 function updateText(id, text) { |
|
42 udpate(id, text, "textContent"); |
|
43 } |
|
44 |
|
45 function updateHTML(id, text) { |
|
46 udpate(id, text, "innerHTML"); |
|
47 } |
|
48 |
|
49 var tests = [{ |
|
50 expected: [{ |
|
51 "method": "speak", |
|
52 "data": "hidden I will be hidden", |
|
53 "options": { |
|
54 "enqueue": true |
|
55 } |
|
56 }], |
|
57 action: function action() { |
|
58 [hide(id) for (id of ["to_hide1", "to_hide2", "to_hide3", "to_hide4"])]; |
|
59 } |
|
60 }, { |
|
61 expected: [{ |
|
62 "method": "speak", |
|
63 "data": "hidden I will be hidden", |
|
64 "options": { |
|
65 "enqueue": true |
|
66 } |
|
67 }], |
|
68 action: function action() { |
|
69 [hide(id) for (id of ["to_hide_descendant1", "to_hide_descendant2", |
|
70 "to_hide_descendant3", "to_hide_descendant4"])]; |
|
71 } |
|
72 }, { |
|
73 expected: [{ |
|
74 "method": "speak", |
|
75 "data": "I will be shown", |
|
76 "options": { |
|
77 "enqueue": true |
|
78 } |
|
79 }], |
|
80 action: function action() { |
|
81 [show(id) for (id of ["to_show1", "to_show2", "to_show3", "to_show4"])]; |
|
82 } |
|
83 }, { |
|
84 expected: [{ |
|
85 "method": "speak", |
|
86 "data": "I will be shown", |
|
87 "options": { |
|
88 "enqueue": true |
|
89 } |
|
90 }], |
|
91 action: function action() { |
|
92 [show(id) for (id of ["to_show_descendant1", "to_show_descendant2", |
|
93 "to_show_descendant3", "to_show_descendant4"])]; |
|
94 } |
|
95 }, { |
|
96 expected: [{ |
|
97 "method": "speak", |
|
98 "data": "hidden I will be hidden", |
|
99 "options": { |
|
100 "enqueue": false |
|
101 } |
|
102 }], |
|
103 action: function action() { |
|
104 hide("to_hide_live_assertive"); |
|
105 } |
|
106 }, { |
|
107 expected: [{ |
|
108 "method": "speak", |
|
109 "data": "I will be shown", |
|
110 "options": { |
|
111 "enqueue": false |
|
112 } |
|
113 }], |
|
114 action: function action() { |
|
115 [show(id) for (id of ["to_show_live_off", "to_show_live_assertive"])]; |
|
116 } |
|
117 }, { |
|
118 expected: [{ |
|
119 "method": "speak", |
|
120 "data": "Text Added", |
|
121 "options": { |
|
122 "enqueue": false |
|
123 } |
|
124 }], |
|
125 action: function action() { |
|
126 updateText("text_add", "Text Added"); |
|
127 } |
|
128 }, { |
|
129 expected: [{ |
|
130 "method": "speak", |
|
131 "data": "Text Added", |
|
132 "options": { |
|
133 "enqueue": false |
|
134 } |
|
135 }], |
|
136 action: function action() { |
|
137 updateHTML("text_add", "Text Added"); |
|
138 } |
|
139 }, { |
|
140 expected: [{ |
|
141 "method": "speak", |
|
142 "data": "hidden Text Removed", |
|
143 "options": { |
|
144 "enqueue": true |
|
145 } |
|
146 }], |
|
147 action: function action() { |
|
148 updateText("text_remove", ""); |
|
149 } |
|
150 }, { |
|
151 expected: [{ |
|
152 "method": "speak", |
|
153 "data": "Descendant Text Added", |
|
154 "options": { |
|
155 "enqueue": false |
|
156 } |
|
157 }], |
|
158 action: function action() { |
|
159 updateText("text_add_descendant", "Descendant Text Added"); |
|
160 } |
|
161 }, { |
|
162 expected: [{ |
|
163 "method": "speak", |
|
164 "data": "Descendant Text Added", |
|
165 "options": { |
|
166 "enqueue": false |
|
167 } |
|
168 }], |
|
169 action: function action() { |
|
170 updateHTML("text_add_descendant", "Descendant Text Added"); |
|
171 } |
|
172 }, { |
|
173 expected: [{ |
|
174 "method": "speak", |
|
175 "data": "hidden Descendant Text Removed", |
|
176 "options": { |
|
177 "enqueue": true |
|
178 } |
|
179 }], |
|
180 action: function action() { |
|
181 updateText("text_remove_descendant", ""); |
|
182 } |
|
183 }, { |
|
184 expected: [{ |
|
185 "method": "speak", |
|
186 "data": "Descendant Text Added", |
|
187 "options": { |
|
188 "enqueue": false |
|
189 } |
|
190 }], |
|
191 action: function action() { |
|
192 updateText("text_add_descendant2", "Descendant Text Added"); |
|
193 } |
|
194 }, { |
|
195 expected: [{ |
|
196 "method": "speak", |
|
197 "data": "Descendant Text Added", |
|
198 "options": { |
|
199 "enqueue": false |
|
200 } |
|
201 }], |
|
202 action: function action() { |
|
203 updateHTML("text_add_descendant2", "Descendant Text Added"); |
|
204 } |
|
205 }, { |
|
206 expected: [{ |
|
207 "method": "speak", |
|
208 "data": "hidden Descendant Text Removed", |
|
209 "options": { |
|
210 "enqueue": true |
|
211 } |
|
212 }], |
|
213 action: function action() { |
|
214 updateText("text_remove_descendant2", ""); |
|
215 } |
|
216 }, { |
|
217 expected: [{ |
|
218 "method": "speak", |
|
219 "data": "I am replaced main", |
|
220 "options": { |
|
221 "enqueue": true |
|
222 } |
|
223 }], |
|
224 action: function action() { |
|
225 var region = document.getElementById("to_replace_region"); |
|
226 var child = document.getElementById("to_replace"); |
|
227 child.setAttribute("role", "main"); |
|
228 } |
|
229 }, { |
|
230 expected: [{ |
|
231 "method": "speak", |
|
232 "data": "I am a replaced text", |
|
233 "options": { |
|
234 "enqueue": false |
|
235 } |
|
236 }], |
|
237 action: function action() { |
|
238 updateText("to_replace_text", "I am a replaced text"); |
|
239 } |
|
240 }, { |
|
241 expected: [{ |
|
242 "method": "speak", |
|
243 "data": "I am a replaced text", |
|
244 "options": { |
|
245 "enqueue": false |
|
246 } |
|
247 }], |
|
248 action: function action() { |
|
249 updateHTML("to_replace_text", "I am a replaced text"); |
|
250 } |
|
251 }]; |
|
252 |
|
253 function doTest() { |
|
254 AccessFuTest.addFunc(startAccessFu); |
|
255 tests.forEach(function addTest(test) { |
|
256 AccessFuTest.addFunc(function () { |
|
257 AccessFuTest.once(test.expected, AccessFuTest.nextTest); |
|
258 test.action(); |
|
259 }); |
|
260 }); |
|
261 AccessFuTest.addFunc(stopAccessFu); |
|
262 AccessFuTest.waitForExplicitFinish(); |
|
263 AccessFuTest.runTests(); |
|
264 } |
|
265 |
|
266 SimpleTest.waitForExplicitFinish(); |
|
267 addA11yLoadEvent(doTest); |
|
268 </script> |
|
269 |
|
270 </head> |
|
271 <body> |
|
272 <a target="_blank" |
|
273 href="https://bugzilla.mozilla.org/show_bug.cgi?id=795957" |
|
274 title="[AccessFu] Support live regions"> |
|
275 Mozilla Bug 795957 |
|
276 </a> |
|
277 <div id="root"> |
|
278 <p id="display"></p> |
|
279 <div id="content" style="display: none"></div> |
|
280 <pre id="test"></pre> |
|
281 |
|
282 <p id="to_hide1">I should not be announced 1</p> |
|
283 <p id="to_hide2" aria-live="polite">I should not be announced 2</p> |
|
284 <p id="to_hide3" aria-live="assertive" aria-relevant="text">I should not be announced 3</p> |
|
285 <p id="to_hide4" aria-live="polite" aria-relevant="all">I will be hidden</p> |
|
286 |
|
287 <div> |
|
288 <p id="to_hide_descendant1">I should not be announced 1</p> |
|
289 </div> |
|
290 <div aria-live="polite"> |
|
291 <p id="to_hide_descendant2">I should not be announced 2</p> |
|
292 </div> |
|
293 <div aria-live="assertive" aria-relevant="text"> |
|
294 <p id="to_hide_descendant3">I should not be announced 3</p> |
|
295 </div> |
|
296 <div aria-live="polite" aria-relevant="all"> |
|
297 <p id="to_hide_descendant4">I will be hidden</p> |
|
298 </div> |
|
299 |
|
300 <p id="to_show1" style="display: none">I should not be announced 1</p> |
|
301 <p id="to_show2" aria-live="assertive" aria-relevant="text" style="display: none">I should not be announced 2</p> |
|
302 <p id="to_show3" aria-live="polite" aria-relevant="removals" style="display: none">I should not be announced 3</p> |
|
303 <p id="to_show4" aria-live="polite" aria-relevant="all" style="display: none">I will be shown</p> |
|
304 |
|
305 <div> |
|
306 <p id="to_show_descendant1" style="display: none">I should not be announced 1</p> |
|
307 </div> |
|
308 <div aria-live="polite" aria-relevant="removals"> |
|
309 <p id="to_show_descendant2" style="display: none">I should not be announced 2</p> |
|
310 </div> |
|
311 <div aria-live="assertive" aria-relevant="text"> |
|
312 <p id="to_show_descendant3" style="display: none">I should not be announced 3</p> |
|
313 </div> |
|
314 <div aria-live="polite" aria-relevant="all"> |
|
315 <p id="to_show_descendant4" style="display: none">I will be shown</p> |
|
316 </div> |
|
317 |
|
318 <div aria-live="assertive" aria-relevant="all"> |
|
319 <p id="to_hide_live_assertive">I will be hidden</p> |
|
320 </div> |
|
321 <p id="to_show_live_assertive" aria-live="assertive" style="display: none">I will be shown</p> |
|
322 |
|
323 <p id="to_show_live_off" aria-live="off" style="display: none">I will not be shown</p> |
|
324 |
|
325 <div id="to_replace_region" aria-live="polite" aria-relevant="all"> |
|
326 <p id="to_replace">I am replaced</p> |
|
327 </div> |
|
328 |
|
329 <p id="to_replace_text" aria-live="assertive" aria-relevant="text">I am going to be replaced</p> |
|
330 |
|
331 <p id="text_add" aria-live="assertive" aria-relevant="text"></p> |
|
332 <p id="text_remove" aria-live="polite" aria-relevant="all">Text Removed</p> |
|
333 |
|
334 <div aria-live="assertive" aria-relevant="all"> |
|
335 <p id="text_add_descendant"></p> |
|
336 </div> |
|
337 <div aria-live="polite" aria-relevant="text"> |
|
338 <p id="text_remove_descendant">Descendant Text Removed</p> |
|
339 </div> |
|
340 <div aria-live="assertive" aria-relevant="text"> |
|
341 <p id="text_add_descendant2"></p> |
|
342 </div> |
|
343 <div aria-live="polite" aria-relevant="all"> |
|
344 <p id="text_remove_descendant2">Descendant Text Removed</p> |
|
345 </div> |
|
346 </div> |
|
347 </body> |
|
348 </html> |