1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/tests/mochitest/jsat/test_live_regions.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,348 @@ 1.4 +<html> 1.5 + 1.6 +<head> 1.7 + <title>AccessFu tests for live regions support</title> 1.8 + 1.9 + <link rel="stylesheet" type="text/css" 1.10 + href="chrome://mochikit/content/tests/SimpleTest/test.css" /> 1.11 + <script type="application/javascript" 1.12 + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.13 + <script type="application/javascript" 1.14 + src="../common.js"></script> 1.15 + <script type="application/javascript" 1.16 + src="./jsatcommon.js"></script> 1.17 + <script type="application/javascript"> 1.18 + 1.19 + function startAccessFu() { 1.20 + SpecialPowers.setIntPref("accessibility.accessfu.activate", 1); 1.21 + AccessFuTest.once_log("EventManager.start", AccessFuTest.nextTest); 1.22 + } 1.23 + 1.24 + function stopAccessFu() { 1.25 + SpecialPowers.setIntPref("accessibility.accessfu.activate", 0); 1.26 + AccessFuTest.once_log("EventManager.stop", AccessFuTest.finish); 1.27 + } 1.28 + 1.29 + function hide(id) { 1.30 + var element = document.getElementById(id); 1.31 + element.style.display = "none"; 1.32 + } 1.33 + 1.34 + function show(id) { 1.35 + var element = document.getElementById(id); 1.36 + element.style.display = "block"; 1.37 + } 1.38 + 1.39 + function udpate(id, text, property) { 1.40 + var element = document.getElementById(id); 1.41 + element[property] = text; 1.42 + } 1.43 + 1.44 + function updateText(id, text) { 1.45 + udpate(id, text, "textContent"); 1.46 + } 1.47 + 1.48 + function updateHTML(id, text) { 1.49 + udpate(id, text, "innerHTML"); 1.50 + } 1.51 + 1.52 + var tests = [{ 1.53 + expected: [{ 1.54 + "method": "speak", 1.55 + "data": "hidden I will be hidden", 1.56 + "options": { 1.57 + "enqueue": true 1.58 + } 1.59 + }], 1.60 + action: function action() { 1.61 + [hide(id) for (id of ["to_hide1", "to_hide2", "to_hide3", "to_hide4"])]; 1.62 + } 1.63 + }, { 1.64 + expected: [{ 1.65 + "method": "speak", 1.66 + "data": "hidden I will be hidden", 1.67 + "options": { 1.68 + "enqueue": true 1.69 + } 1.70 + }], 1.71 + action: function action() { 1.72 + [hide(id) for (id of ["to_hide_descendant1", "to_hide_descendant2", 1.73 + "to_hide_descendant3", "to_hide_descendant4"])]; 1.74 + } 1.75 + }, { 1.76 + expected: [{ 1.77 + "method": "speak", 1.78 + "data": "I will be shown", 1.79 + "options": { 1.80 + "enqueue": true 1.81 + } 1.82 + }], 1.83 + action: function action() { 1.84 + [show(id) for (id of ["to_show1", "to_show2", "to_show3", "to_show4"])]; 1.85 + } 1.86 + }, { 1.87 + expected: [{ 1.88 + "method": "speak", 1.89 + "data": "I will be shown", 1.90 + "options": { 1.91 + "enqueue": true 1.92 + } 1.93 + }], 1.94 + action: function action() { 1.95 + [show(id) for (id of ["to_show_descendant1", "to_show_descendant2", 1.96 + "to_show_descendant3", "to_show_descendant4"])]; 1.97 + } 1.98 + }, { 1.99 + expected: [{ 1.100 + "method": "speak", 1.101 + "data": "hidden I will be hidden", 1.102 + "options": { 1.103 + "enqueue": false 1.104 + } 1.105 + }], 1.106 + action: function action() { 1.107 + hide("to_hide_live_assertive"); 1.108 + } 1.109 + }, { 1.110 + expected: [{ 1.111 + "method": "speak", 1.112 + "data": "I will be shown", 1.113 + "options": { 1.114 + "enqueue": false 1.115 + } 1.116 + }], 1.117 + action: function action() { 1.118 + [show(id) for (id of ["to_show_live_off", "to_show_live_assertive"])]; 1.119 + } 1.120 + }, { 1.121 + expected: [{ 1.122 + "method": "speak", 1.123 + "data": "Text Added", 1.124 + "options": { 1.125 + "enqueue": false 1.126 + } 1.127 + }], 1.128 + action: function action() { 1.129 + updateText("text_add", "Text Added"); 1.130 + } 1.131 + }, { 1.132 + expected: [{ 1.133 + "method": "speak", 1.134 + "data": "Text Added", 1.135 + "options": { 1.136 + "enqueue": false 1.137 + } 1.138 + }], 1.139 + action: function action() { 1.140 + updateHTML("text_add", "Text Added"); 1.141 + } 1.142 + }, { 1.143 + expected: [{ 1.144 + "method": "speak", 1.145 + "data": "hidden Text Removed", 1.146 + "options": { 1.147 + "enqueue": true 1.148 + } 1.149 + }], 1.150 + action: function action() { 1.151 + updateText("text_remove", ""); 1.152 + } 1.153 + }, { 1.154 + expected: [{ 1.155 + "method": "speak", 1.156 + "data": "Descendant Text Added", 1.157 + "options": { 1.158 + "enqueue": false 1.159 + } 1.160 + }], 1.161 + action: function action() { 1.162 + updateText("text_add_descendant", "Descendant Text Added"); 1.163 + } 1.164 + }, { 1.165 + expected: [{ 1.166 + "method": "speak", 1.167 + "data": "Descendant Text Added", 1.168 + "options": { 1.169 + "enqueue": false 1.170 + } 1.171 + }], 1.172 + action: function action() { 1.173 + updateHTML("text_add_descendant", "Descendant Text Added"); 1.174 + } 1.175 + }, { 1.176 + expected: [{ 1.177 + "method": "speak", 1.178 + "data": "hidden Descendant Text Removed", 1.179 + "options": { 1.180 + "enqueue": true 1.181 + } 1.182 + }], 1.183 + action: function action() { 1.184 + updateText("text_remove_descendant", ""); 1.185 + } 1.186 + }, { 1.187 + expected: [{ 1.188 + "method": "speak", 1.189 + "data": "Descendant Text Added", 1.190 + "options": { 1.191 + "enqueue": false 1.192 + } 1.193 + }], 1.194 + action: function action() { 1.195 + updateText("text_add_descendant2", "Descendant Text Added"); 1.196 + } 1.197 + }, { 1.198 + expected: [{ 1.199 + "method": "speak", 1.200 + "data": "Descendant Text Added", 1.201 + "options": { 1.202 + "enqueue": false 1.203 + } 1.204 + }], 1.205 + action: function action() { 1.206 + updateHTML("text_add_descendant2", "Descendant Text Added"); 1.207 + } 1.208 + }, { 1.209 + expected: [{ 1.210 + "method": "speak", 1.211 + "data": "hidden Descendant Text Removed", 1.212 + "options": { 1.213 + "enqueue": true 1.214 + } 1.215 + }], 1.216 + action: function action() { 1.217 + updateText("text_remove_descendant2", ""); 1.218 + } 1.219 + }, { 1.220 + expected: [{ 1.221 + "method": "speak", 1.222 + "data": "I am replaced main", 1.223 + "options": { 1.224 + "enqueue": true 1.225 + } 1.226 + }], 1.227 + action: function action() { 1.228 + var region = document.getElementById("to_replace_region"); 1.229 + var child = document.getElementById("to_replace"); 1.230 + child.setAttribute("role", "main"); 1.231 + } 1.232 + }, { 1.233 + expected: [{ 1.234 + "method": "speak", 1.235 + "data": "I am a replaced text", 1.236 + "options": { 1.237 + "enqueue": false 1.238 + } 1.239 + }], 1.240 + action: function action() { 1.241 + updateText("to_replace_text", "I am a replaced text"); 1.242 + } 1.243 + }, { 1.244 + expected: [{ 1.245 + "method": "speak", 1.246 + "data": "I am a replaced text", 1.247 + "options": { 1.248 + "enqueue": false 1.249 + } 1.250 + }], 1.251 + action: function action() { 1.252 + updateHTML("to_replace_text", "I am a replaced text"); 1.253 + } 1.254 + }]; 1.255 + 1.256 + function doTest() { 1.257 + AccessFuTest.addFunc(startAccessFu); 1.258 + tests.forEach(function addTest(test) { 1.259 + AccessFuTest.addFunc(function () { 1.260 + AccessFuTest.once(test.expected, AccessFuTest.nextTest); 1.261 + test.action(); 1.262 + }); 1.263 + }); 1.264 + AccessFuTest.addFunc(stopAccessFu); 1.265 + AccessFuTest.waitForExplicitFinish(); 1.266 + AccessFuTest.runTests(); 1.267 + } 1.268 + 1.269 + SimpleTest.waitForExplicitFinish(); 1.270 + addA11yLoadEvent(doTest); 1.271 + </script> 1.272 + 1.273 +</head> 1.274 +<body> 1.275 + <a target="_blank" 1.276 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=795957" 1.277 + title="[AccessFu] Support live regions"> 1.278 + Mozilla Bug 795957 1.279 + </a> 1.280 + <div id="root"> 1.281 + <p id="display"></p> 1.282 + <div id="content" style="display: none"></div> 1.283 + <pre id="test"></pre> 1.284 + 1.285 + <p id="to_hide1">I should not be announced 1</p> 1.286 + <p id="to_hide2" aria-live="polite">I should not be announced 2</p> 1.287 + <p id="to_hide3" aria-live="assertive" aria-relevant="text">I should not be announced 3</p> 1.288 + <p id="to_hide4" aria-live="polite" aria-relevant="all">I will be hidden</p> 1.289 + 1.290 + <div> 1.291 + <p id="to_hide_descendant1">I should not be announced 1</p> 1.292 + </div> 1.293 + <div aria-live="polite"> 1.294 + <p id="to_hide_descendant2">I should not be announced 2</p> 1.295 + </div> 1.296 + <div aria-live="assertive" aria-relevant="text"> 1.297 + <p id="to_hide_descendant3">I should not be announced 3</p> 1.298 + </div> 1.299 + <div aria-live="polite" aria-relevant="all"> 1.300 + <p id="to_hide_descendant4">I will be hidden</p> 1.301 + </div> 1.302 + 1.303 + <p id="to_show1" style="display: none">I should not be announced 1</p> 1.304 + <p id="to_show2" aria-live="assertive" aria-relevant="text" style="display: none">I should not be announced 2</p> 1.305 + <p id="to_show3" aria-live="polite" aria-relevant="removals" style="display: none">I should not be announced 3</p> 1.306 + <p id="to_show4" aria-live="polite" aria-relevant="all" style="display: none">I will be shown</p> 1.307 + 1.308 + <div> 1.309 + <p id="to_show_descendant1" style="display: none">I should not be announced 1</p> 1.310 + </div> 1.311 + <div aria-live="polite" aria-relevant="removals"> 1.312 + <p id="to_show_descendant2" style="display: none">I should not be announced 2</p> 1.313 + </div> 1.314 + <div aria-live="assertive" aria-relevant="text"> 1.315 + <p id="to_show_descendant3" style="display: none">I should not be announced 3</p> 1.316 + </div> 1.317 + <div aria-live="polite" aria-relevant="all"> 1.318 + <p id="to_show_descendant4" style="display: none">I will be shown</p> 1.319 + </div> 1.320 + 1.321 + <div aria-live="assertive" aria-relevant="all"> 1.322 + <p id="to_hide_live_assertive">I will be hidden</p> 1.323 + </div> 1.324 + <p id="to_show_live_assertive" aria-live="assertive" style="display: none">I will be shown</p> 1.325 + 1.326 + <p id="to_show_live_off" aria-live="off" style="display: none">I will not be shown</p> 1.327 + 1.328 + <div id="to_replace_region" aria-live="polite" aria-relevant="all"> 1.329 + <p id="to_replace">I am replaced</p> 1.330 + </div> 1.331 + 1.332 + <p id="to_replace_text" aria-live="assertive" aria-relevant="text">I am going to be replaced</p> 1.333 + 1.334 + <p id="text_add" aria-live="assertive" aria-relevant="text"></p> 1.335 + <p id="text_remove" aria-live="polite" aria-relevant="all">Text Removed</p> 1.336 + 1.337 + <div aria-live="assertive" aria-relevant="all"> 1.338 + <p id="text_add_descendant"></p> 1.339 + </div> 1.340 + <div aria-live="polite" aria-relevant="text"> 1.341 + <p id="text_remove_descendant">Descendant Text Removed</p> 1.342 + </div> 1.343 + <div aria-live="assertive" aria-relevant="text"> 1.344 + <p id="text_add_descendant2"></p> 1.345 + </div> 1.346 + <div aria-live="polite" aria-relevant="all"> 1.347 + <p id="text_remove_descendant2">Descendant Text Removed</p> 1.348 + </div> 1.349 + </div> 1.350 +</body> 1.351 +</html> 1.352 \ No newline at end of file