| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Include test fixture. | 5 // Include test fixture. |
| 6 GEN_INCLUDE(['../../testing/chromevox_next_e2e_test_base.js', | 6 GEN_INCLUDE(['../../testing/chromevox_next_e2e_test_base.js', |
| 7 '../../testing/assert_additions.js']); | 7 '../../testing/assert_additions.js']); |
| 8 | 8 |
| 9 GEN_INCLUDE(['../../testing/mock_feedback.js']); | 9 GEN_INCLUDE(['../../testing/mock_feedback.js']); |
| 10 | 10 |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 <button id="go">Go</button> | 225 <button id="go">Go</button> |
| 226 <script> | 226 <script> |
| 227 document.getElementById('go').addEventListener('click', function() { | 227 document.getElementById('go').addEventListener('click', function() { |
| 228 document.getElementById('live').innerHTML = 'Hello, world'; | 228 document.getElementById('live').innerHTML = 'Hello, world'; |
| 229 }, false); | 229 }, false); |
| 230 </script> | 230 </script> |
| 231 */}, | 231 */}, |
| 232 function(rootNode) { | 232 function(rootNode) { |
| 233 var go = rootNode.find({ role: RoleType.button }); | 233 var go = rootNode.find({ role: RoleType.button }); |
| 234 mockFeedback.call(go.doDefault.bind(go)) | 234 mockFeedback.call(go.doDefault.bind(go)) |
| 235 .expectSpeech('Hello, world'); | 235 .expectCategoryFlush('Hello, world'); |
| 236 mockFeedback.replay(); | 236 mockFeedback.replay(); |
| 237 }); | 237 }); |
| 238 }); | 238 }); |
| 239 | 239 |
| 240 TEST_F('BackgroundTest', 'LiveRegionRemoveElement', function() { | 240 TEST_F('BackgroundTest', 'LiveRegionRemoveElement', function() { |
| 241 var mockFeedback = this.createMockFeedback(); | 241 var mockFeedback = this.createMockFeedback(); |
| 242 this.runWithLoadedTree( | 242 this.runWithLoadedTree( |
| 243 function() {/*! | 243 function() {/*! |
| 244 <h1>Document with live region</h1> | 244 <h1>Document with live region</h1> |
| 245 <p id="live" aria-live="polite" aria-relevant="removals">Hello, world</p> | 245 <p id="live" aria-live="polite" aria-relevant="removals">Hello, world</p> |
| 246 <button id="go">Go</button> | 246 <button id="go">Go</button> |
| 247 <script> | 247 <script> |
| 248 document.getElementById('go').addEventListener('click', function() { | 248 document.getElementById('go').addEventListener('click', function() { |
| 249 document.getElementById('live').innerHTML = ''; | 249 document.getElementById('live').innerHTML = ''; |
| 250 }, false); | 250 }, false); |
| 251 </script> | 251 </script> |
| 252 */}, | 252 */}, |
| 253 function(rootNode) { | 253 function(rootNode) { |
| 254 var go = rootNode.find({ role: RoleType.button }); | 254 var go = rootNode.find({ role: RoleType.button }); |
| 255 go.doDefault(); | 255 go.doDefault(); |
| 256 mockFeedback.expectSpeech('removed:') | 256 mockFeedback.expectCategoryFlush('removed:') |
| 257 .expectSpeech('Hello, world'); | 257 .expectQueue('Hello, world'); |
| 258 mockFeedback.replay(); | 258 mockFeedback.replay(); |
| 259 }); | 259 }); |
| 260 }); | 260 }); |
| 261 |
| 262 TEST_F('BackgroundTest', 'LiveRegionChangeAtomic', function() { |
| 263 var mockFeedback = this.createMockFeedback(); |
| 264 this.runWithLoadedTree( |
| 265 function() {/*! |
| 266 <div id="live" aria-live="polite" aria-atomic="true"> |
| 267 <div id="a"></div><div id="b">Bravo</div><div id="c"></div> |
| 268 </div> |
| 269 <button id="go">Go</button> |
| 270 <script> |
| 271 document.getElementById('go').addEventListener('click', function() { |
| 272 document.getElementById('c').textContent = 'Charlie'; |
| 273 document.getElementById('a').textContent = 'Alpha'; |
| 274 }, false); |
| 275 </script> |
| 276 */}, |
| 277 function(rootNode) { |
| 278 var go = rootNode.find({ role: RoleType.button }); |
| 279 mockFeedback.call(go.doDefault.bind(go)) |
| 280 .expectQueue('Alpha') |
| 281 .expectQueue('Bravo') |
| 282 .expectQueue('Charlie'); |
| 283 mockFeedback.replay(); |
| 284 }); |
| 285 }); |
| 286 |
| 287 TEST_F('BackgroundTest', 'LiveRegionChangeImageAlt', function() { |
| 288 var mockFeedback = this.createMockFeedback(); |
| 289 this.runWithLoadedTree( |
| 290 function() {/*! |
| 291 <div id="live" aria-live="polite"> |
| 292 <img id="img" src="#" alt="Before"> |
| 293 </div> |
| 294 <button id="go">Go</button> |
| 295 <script> |
| 296 document.getElementById('go').addEventListener('click', function() { |
| 297 document.getElementById('img').setAttribute('alt', 'After'); |
| 298 }, false); |
| 299 </script> |
| 300 */}, |
| 301 function(rootNode) { |
| 302 var go = rootNode.find({ role: RoleType.button }); |
| 303 mockFeedback.call(go.doDefault.bind(go)) |
| 304 .expectCategoryFlush('After') |
| 305 .expectQueue('Image'); |
| 306 mockFeedback.replay(); |
| 307 }); |
| 308 }); |
| 309 |
| 310 TEST_F('BackgroundTest', 'LiveRegionThenFocus', function() { |
| 311 var mockFeedback = this.createMockFeedback(); |
| 312 this.runWithLoadedTree( |
| 313 function() {/*! |
| 314 <div id="live" aria-live="polite"></div> |
| 315 <button id="go">Go</button> |
| 316 <button id="focus">Focus</button> |
| 317 <script> |
| 318 document.getElementById('go').addEventListener('click', function() { |
| 319 document.getElementById('live').textContent = 'Live'; |
| 320 window.setTimeout(function() { |
| 321 document.getElementById('focus').focus(); |
| 322 }, 50); |
| 323 }, false); |
| 324 </script> |
| 325 */}, |
| 326 function(rootNode) { |
| 327 var go = rootNode.find({ role: RoleType.button }); |
| 328 mockFeedback.call(go.doDefault.bind(go)) |
| 329 .expectCategoryFlush('Live') |
| 330 .expectQueue('Focus'); |
| 331 mockFeedback.replay(); |
| 332 }); |
| 333 }); |
| 334 |
| 335 TEST_F('BackgroundTest', 'FocusThenLiveRegion', function() { |
| 336 var mockFeedback = this.createMockFeedback(); |
| 337 this.runWithLoadedTree( |
| 338 function() {/*! |
| 339 <div id="live" aria-live="polite"></div> |
| 340 <button id="go">Go</button> |
| 341 <button id="focus">Focus</button> |
| 342 <script> |
| 343 document.getElementById('go').addEventListener('click', function() { |
| 344 document.getElementById('focus').focus(); |
| 345 window.setTimeout(function() { |
| 346 document.getElementById('live').textContent = 'Live'; |
| 347 }, 50); |
| 348 }, false); |
| 349 </script> |
| 350 */}, |
| 351 function(rootNode) { |
| 352 var go = rootNode.find({ role: RoleType.button }); |
| 353 mockFeedback.call(go.doDefault.bind(go)) |
| 354 .expectQueue('Focus') |
| 355 .expectCategoryFlush('Live'); |
| 356 mockFeedback.replay(); |
| 357 }); |
| 358 }); |
| 359 |
| 360 TEST_F('BackgroundTest', 'LiveRegionCategoryFlush', function() { |
| 361 var mockFeedback = this.createMockFeedback(); |
| 362 this.runWithLoadedTree( |
| 363 function() {/*! |
| 364 <div id="live1" aria-live="polite"></div> |
| 365 <div id="live2" aria-live="polite"></div> |
| 366 <button id="go">Go</button> |
| 367 <button id="focus">Focus</button> |
| 368 <script> |
| 369 document.getElementById('go').addEventListener('click', function() { |
| 370 document.getElementById('live1').textContent = 'Live1'; |
| 371 window.setTimeout(function() { |
| 372 document.getElementById('live2').textContent = 'Live2'; |
| 373 }, 1000); |
| 374 }, false); |
| 375 </script> |
| 376 */}, |
| 377 function(rootNode) { |
| 378 var go = rootNode.find({ role: RoleType.button }); |
| 379 mockFeedback.call(go.doDefault.bind(go)) |
| 380 .expectCategoryFlush('Live1') |
| 381 .expectCategoryFlush('Live2'); |
| 382 mockFeedback.replay(); |
| 383 }); |
| 384 }); |
| 261 | 385 |
| 262 TEST_F('BackgroundTest', 'InitialFocus', function() { | 386 TEST_F('BackgroundTest', 'InitialFocus', function() { |
| 263 var mockFeedback = this.createMockFeedback(); | 387 var mockFeedback = this.createMockFeedback(); |
| 264 this.runWithLoadedTree('<a href="a">a</a>', | 388 this.runWithLoadedTree('<a href="a">a</a>', |
| 265 function(rootNode) { | 389 function(rootNode) { |
| 266 mockFeedback.expectSpeech('a') | 390 mockFeedback.expectSpeech('a') |
| 267 .expectSpeech('Link'); | 391 .expectSpeech('Link'); |
| 268 mockFeedback.replay(); | 392 mockFeedback.replay(); |
| 269 }); | 393 }); |
| 270 }); | 394 }); |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 .call(off) | 627 .call(off) |
| 504 .call(focusThen.bind(this, rootNode.find({ role: 'link' }), on)) | 628 .call(focusThen.bind(this, rootNode.find({ role: 'link' }), on)) |
| 505 .call(focusThen.bind(this, rootNode.find({ role: 'textField' }))) | 629 .call(focusThen.bind(this, rootNode.find({ role: 'textField' }))) |
| 506 .expectNextSpeechUtteranceIsNot('a') | 630 .expectNextSpeechUtteranceIsNot('a') |
| 507 .expectSpeech('Edit text'); | 631 .expectSpeech('Edit text'); |
| 508 | 632 |
| 509 mockFeedback.replay(); | 633 mockFeedback.replay(); |
| 510 } | 634 } |
| 511 ); | 635 ); |
| 512 }); | 636 }); |
| OLD | NEW |