Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(610)

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/background_test.extjs

Issue 2007183002: Make ChromeVox cursor robust to deleted nodes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 /** 11 /**
12 * Test fixture for Background. 12 * Test fixture for Background.
13 * @constructor 13 * @constructor
14 * @extends {ChromeVoxNextE2ETest} 14 * @extends {ChromeVoxNextE2ETest}
15 */ 15 */
16 function BackgroundTest() { 16 function BackgroundTest() {
17 ChromeVoxNextE2ETest.call(this); 17 ChromeVoxNextE2ETest.call(this);
18 } 18 }
19 19
20 BackgroundTest.prototype = { 20 BackgroundTest.prototype = {
21 __proto__: ChromeVoxNextE2ETest.prototype, 21 __proto__: ChromeVoxNextE2ETest.prototype,
22 22
23 /** @override */ 23 /** @override */
24 setUp: function() { 24 setUp: function() {
25 global.backgroundObj.forceChromeVoxNextActive(); 25 global.backgroundObj.forceChromeVoxNextActive();
26 window.RoleType = chrome.automation.RoleType; 26 window.RoleType = chrome.automation.RoleType;
27 window.doCmd = this.doCmd;
27 }, 28 },
28 29
29 /** 30 /**
30 * @return {!MockFeedback} 31 * @return {!MockFeedback}
31 */ 32 */
32 createMockFeedback: function() { 33 createMockFeedback: function() {
33 var mockFeedback = new MockFeedback(this.newCallback(), 34 var mockFeedback = new MockFeedback(this.newCallback(),
34 this.newCallback.bind(this)); 35 this.newCallback.bind(this));
35 mockFeedback.install(); 36 mockFeedback.install();
36 return mockFeedback; 37 return mockFeedback;
(...skipping 30 matching lines...) Expand all
67 <option> banana</option> 68 <option> banana</option>
68 </select> 69 </select>
69 */}, 70 */},
70 71
71 iframesDoc: function() {/*! 72 iframesDoc: function() {/*!
72 <p>start</p> 73 <p>start</p>
73 <button>Before</button> 74 <button>Before</button>
74 <iframe srcdoc="<button>Inside</button><h1>Inside</h1>"></iframe> 75 <iframe srcdoc="<button>Inside</button><h1>Inside</h1>"></iframe>
75 <button>After</button> 76 <button>After</button>
76 */}, 77 */},
78
79 disappearingObjectDoc: function() {/*!
80 <p>start</p>
81 <article>
82 <p>Before1</p>
83 <p>Before2</p>
84 <p>Before3</p>
85 </article>
86 <article>
87 <p id="disappearing">Disappearing</p>
88 </article>
89 <article>
90 <p>After1</p>
91 <p>After2</p>
92 <p>After3</p>
93 </article>
94 </div>
95 <div id="live" aria-live="polite"></div>
96 <div id="delete" role="button">Delete</div>
97 <script>
98 document.getElementById('delete').addEventListener('click', function() {
99 var d = document.getElementById('disappearing');
100 d.parentElement.removeChild(d);
101 document.getElementById('live').innerText = 'Deleted';
102 });
103 </script>
104 */},
77 }; 105 };
78 106
79 /** Tests that ChromeVox classic is in this context. */ 107 /** Tests that ChromeVox classic is in this context. */
80 SYNC_TEST_F('BackgroundTest', 'ClassicNamespaces', function() { 108 SYNC_TEST_F('BackgroundTest', 'ClassicNamespaces', function() {
81 assertEquals('object', typeof(cvox)); 109 assertEquals('object', typeof(cvox));
82 assertEquals('function', typeof(cvox.ChromeVoxBackground)); 110 assertEquals('function', typeof(cvox.ChromeVoxBackground));
83 }); 111 });
84 112
85 /** Tests that ChromeVox next is in this context. */ 113 /** Tests that ChromeVox next is in this context. */
86 SYNC_TEST_F('BackgroundTest', 'NextNamespaces', function() { 114 SYNC_TEST_F('BackgroundTest', 'NextNamespaces', function() {
87 assertEquals('function', typeof(Background)); 115 assertEquals('function', typeof(Background));
88 }); 116 });
89 117
90 /** Tests consistency of navigating forward and backward. */ 118 /** Tests consistency of navigating forward and backward. */
91 TEST_F('BackgroundTest', 'ForwardBackwardNavigation', function() { 119 TEST_F('BackgroundTest', 'ForwardBackwardNavigation', function() {
92 var mockFeedback = this.createMockFeedback(); 120 var mockFeedback = this.createMockFeedback();
93 this.runWithLoadedTree(this.linksAndHeadingsDoc, function() { 121 this.runWithLoadedTree(this.linksAndHeadingsDoc, function() {
94 var doCmd = this.doCmd.bind(this);
95
96 mockFeedback.expectSpeech('start').expectBraille('start'); 122 mockFeedback.expectSpeech('start').expectBraille('start');
97 123
98 mockFeedback.call(doCmd('nextLink')) 124 mockFeedback.call(doCmd('nextLink'))
99 .expectSpeech('alpha', 'Link') 125 .expectSpeech('alpha', 'Link')
100 .expectBraille('alpha lnk'); 126 .expectBraille('alpha lnk');
101 mockFeedback.call(doCmd('nextLink')) 127 mockFeedback.call(doCmd('nextLink'))
102 .expectSpeech('beta', 'Link') 128 .expectSpeech('beta', 'Link')
103 .expectBraille('beta lnk'); 129 .expectBraille('beta lnk');
104 mockFeedback.call(doCmd('nextLink')) 130 mockFeedback.call(doCmd('nextLink'))
105 .expectSpeech('delta', 'Link') 131 .expectSpeech('delta', 'Link')
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 .expectBraille('of test'); 170 .expectBraille('of test');
145 171
146 mockFeedback.replay(); 172 mockFeedback.replay();
147 }); 173 });
148 }); 174 });
149 175
150 TEST_F('BackgroundTest', 'CaretNavigation', function() { 176 TEST_F('BackgroundTest', 'CaretNavigation', function() {
151 // TODO(plundblad): Add braille expectaions when crbug.com/523285 is fixed. 177 // TODO(plundblad): Add braille expectaions when crbug.com/523285 is fixed.
152 var mockFeedback = this.createMockFeedback(); 178 var mockFeedback = this.createMockFeedback();
153 this.runWithLoadedTree(this.linksAndHeadingsDoc, function() { 179 this.runWithLoadedTree(this.linksAndHeadingsDoc, function() {
154 var doCmd = this.doCmd.bind(this);
155
156 mockFeedback.expectSpeech('start'); 180 mockFeedback.expectSpeech('start');
157 mockFeedback.call(doCmd('nextCharacter')) 181 mockFeedback.call(doCmd('nextCharacter'))
158 .expectSpeech('t'); 182 .expectSpeech('t');
159 mockFeedback.call(doCmd('nextCharacter')) 183 mockFeedback.call(doCmd('nextCharacter'))
160 .expectSpeech('a'); 184 .expectSpeech('a');
161 mockFeedback.call(doCmd('nextWord')) 185 mockFeedback.call(doCmd('nextWord'))
162 .expectSpeech('alpha', 'Link'); 186 .expectSpeech('alpha', 'Link');
163 mockFeedback.call(doCmd('nextWord')) 187 mockFeedback.call(doCmd('nextWord'))
164 .expectSpeech('beta', 'Link'); 188 .expectSpeech('beta', 'Link');
165 mockFeedback.call(doCmd('nextWord')) 189 mockFeedback.call(doCmd('nextWord'))
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 .expectSpeech('banana', /3 of 3/) 230 .expectSpeech('banana', /3 of 3/)
207 .expectBraille('banana mnuitm 3/3'); 231 .expectBraille('banana mnuitm 3/3');
208 mockFeedback.replay(); 232 mockFeedback.replay();
209 }); 233 });
210 }); 234 });
211 235
212 TEST_F('BackgroundTest', 'ContinuousRead', function() { 236 TEST_F('BackgroundTest', 'ContinuousRead', function() {
213 var mockFeedback = this.createMockFeedback(); 237 var mockFeedback = this.createMockFeedback();
214 this.runWithLoadedTree(this.linksAndHeadingsDoc, function() { 238 this.runWithLoadedTree(this.linksAndHeadingsDoc, function() {
215 mockFeedback.expectSpeech('start') 239 mockFeedback.expectSpeech('start')
216 .call(this.doCmd('readFromHere')) 240 .call(doCmd('readFromHere'))
217 .expectSpeech( 241 .expectSpeech(
218 'start', 242 'start',
219 'alpha', 'Link', 243 'alpha', 'Link',
220 'beta', 'Link', 244 'beta', 'Link',
221 'charlie', 'Heading 1'); 245 'charlie', 'Heading 1');
222 mockFeedback.replay(); 246 mockFeedback.replay();
223 }); 247 });
224 }); 248 });
225 249
226 TEST_F('BackgroundTest', 'InitialFocus', function() { 250 TEST_F('BackgroundTest', 'InitialFocus', function() {
227 var mockFeedback = this.createMockFeedback(); 251 var mockFeedback = this.createMockFeedback();
228 this.runWithLoadedTree('<a href="a">a</a>', 252 this.runWithLoadedTree('<a href="a">a</a>',
229 function(rootNode) { 253 function(rootNode) {
230 mockFeedback.expectSpeech('data:text/html,<!doctype html>' + 254 mockFeedback.expectSpeech('data:text/html,<!doctype html>' +
231 '<a href="a">a</a>') 255 '<a href="a">a</a>')
232 .expectSpeech('a') 256 .expectSpeech('a')
233 .expectSpeech('Link'); 257 .expectSpeech('Link');
234 mockFeedback.replay(); 258 mockFeedback.replay();
235 }); 259 });
236 }); 260 });
237 261
238 TEST_F('BackgroundTest', 'AriaLabel', function() { 262 TEST_F('BackgroundTest', 'AriaLabel', function() {
239 var mockFeedback = this.createMockFeedback(); 263 var mockFeedback = this.createMockFeedback();
240 this.runWithLoadedTree('<a aria-label="foo" href="a">a</a>', 264 this.runWithLoadedTree('<a aria-label="foo" href="a">a</a>',
241 function(rootNode) { 265 function(rootNode) {
242 rootNode.find({role: 'link'}).focus(); 266 rootNode.find({role: RoleType.link}).focus();
243 mockFeedback.expectSpeech('foo') 267 mockFeedback.expectSpeech('foo')
244 .expectSpeech('Link') 268 .expectSpeech('Link')
245 .expectBraille('foo lnk'); 269 .expectBraille('foo lnk');
246 mockFeedback.replay(); 270 mockFeedback.replay();
247 } 271 }
248 ); 272 );
249 }); 273 });
250 274
251 TEST_F('BackgroundTest', 'ShowContextMenu', function() { 275 TEST_F('BackgroundTest', 'ShowContextMenu', function() {
252 var mockFeedback = this.createMockFeedback(); 276 var mockFeedback = this.createMockFeedback();
253 this.runWithLoadedTree('<a href="a">a</a>', 277 this.runWithLoadedTree('<a href="a">a</a>',
254 function(rootNode) { 278 function(rootNode) {
255 mockFeedback.expectSpeech(/menu opened/) 279 mockFeedback.expectSpeech(/menu opened/)
256 .call(function() { 280 .call(function() {
257 // When shown, the context menu pushes a new message loop so test 281 // When shown, the context menu pushes a new message loop so test
258 // messages sent to the browser do not get processed. Ensure we 282 // messages sent to the browser do not get processed. Ensure we
259 // exit the context menu here. 283 // exit the context menu here.
260 go.showContextMenu(); 284 go.showContextMenu();
261 }); 285 });
262 mockFeedback.replay(); 286 mockFeedback.replay();
263 287
264 var go = rootNode.find({ role: RoleType.link }); 288 var go = rootNode.find({ role: RoleType.link });
265 this.listenOnce(go, 'focus', function(e) { 289 this.listenOnce(go, 'focus', function(e) {
266 this.doCmd('contextMenu')(); 290 doCmd('contextMenu')();
267 }.bind(this), true); 291 }.bind(this), true);
268 go.focus(); 292 go.focus();
269 }.bind(this)); 293 }.bind(this));
270 }); 294 });
271 295
272 TEST_F('BackgroundTest', 'BrailleRouting', function() { 296 TEST_F('BackgroundTest', 'BrailleRouting', function() {
273 var mockFeedback = this.createMockFeedback(); 297 var mockFeedback = this.createMockFeedback();
274 var route = function(position) { 298 var route = function(position) {
275 assertTrue(global.backgroundObj.onBrailleKeyEvent( 299 assertTrue(global.backgroundObj.onBrailleKeyEvent(
276 {command: cvox.BrailleKeyCommand.ROUTING, 300 {command: cvox.BrailleKeyCommand.ROUTING,
277 displayPosition: position}, 301 displayPosition: position},
278 mockFeedback.lastMatchedBraille)); 302 mockFeedback.lastMatchedBraille));
279 }; 303 };
280 this.runWithLoadedTree( 304 this.runWithLoadedTree(
281 function() {/*! 305 function() {/*!
282 <p>start</p> 306 <p>start</p>
283 <button id="btn1">Click me</button> 307 <button id="btn1">Click me</button>
284 <p>Some text</p> 308 <p>Some text</p>
285 <button id="btn2">Focus me</button> 309 <button id="btn2">Focus me</button>
286 <p>Some more text</p> 310 <p>Some more text</p>
287 <input type="text" id ="text" value="Edit me"> 311 <input type="text" id ="text" value="Edit me">
288 <script> 312 <script>
289 document.getElementById('btn1').addEventListener('click', function() { 313 document.getElementById('btn1').addEventListener('click', function() {
290 document.getElementById('btn2').focus(); 314 document.getElementById('btn2').focus();
291 }, false); 315 }, false);
292 </script> 316 </script>
293 */}, 317 */},
294 function(rootNode) { 318 function(rootNode) {
295 var button1 = rootNode.find({role: RoleType.button, 319 var button1 = rootNode.find({role: RoleType.button,
296 name: 'Click me'}); 320 attributes: { name: 'Click me' }});
297 var textField = rootNode.find( 321 var textField = rootNode.find(
298 {role: RoleType.textField}); 322 {role: RoleType.textField});
299 mockFeedback.expectBraille('start') 323 mockFeedback.expectBraille('start')
300 .call(button1.focus.bind(button1)) 324 .call(button1.focus.bind(button1))
301 .expectBraille(/^Click me btn/) 325 .expectBraille(/^Click me btn/)
302 .call(route.bind(null, 5)) 326 .call(route.bind(null, 5))
303 .expectBraille(/Focus me btn/) 327 .expectBraille(/Focus me btn/)
304 .call(textField.focus.bind(textField)) 328 .call(textField.focus.bind(textField))
305 .expectBraille('Edit me ed', {startIndex: 0}) 329 .expectBraille('Edit me ed', {startIndex: 0})
306 .call(route.bind(null, 3)) 330 .call(route.bind(null, 3))
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 <a href="#">MyLink</a> 396 <a href="#">MyLink</a>
373 <button>MyButton</button> 397 <button>MyButton</button>
374 <input type=checkbox> 398 <input type=checkbox>
375 <input type=checkbox checked> 399 <input type=checkbox checked>
376 <input> 400 <input>
377 <select multiple><option>1</option></select> 401 <select multiple><option>1</option></select>
378 <select><option>2</option></select> 402 <select><option>2</option></select>
379 <input type=range value=5> 403 <input type=range value=5>
380 */}, 404 */},
381 function(rootNode) { 405 function(rootNode) {
382 var doCmd = this.doCmd.bind(this);
383
384 mockFeedback.call(doCmd('nextObject')) 406 mockFeedback.call(doCmd('nextObject'))
385 .expectSpeech('MyLink') 407 .expectSpeech('MyLink')
386 .expectEarcon(cvox.Earcon.LINK) 408 .expectEarcon(cvox.Earcon.LINK)
387 .call(doCmd('nextObject')) 409 .call(doCmd('nextObject'))
388 .expectSpeech('MyButton') 410 .expectSpeech('MyButton')
389 .expectEarcon(cvox.Earcon.BUTTON) 411 .expectEarcon(cvox.Earcon.BUTTON)
390 .call(doCmd('nextObject')) 412 .call(doCmd('nextObject'))
391 .expectSpeech('Check box') 413 .expectSpeech('Check box')
392 .expectEarcon(cvox.Earcon.CHECK_OFF) 414 .expectEarcon(cvox.Earcon.CHECK_OFF)
393 .call(doCmd('nextObject')) 415 .call(doCmd('nextObject'))
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 }); 465 });
444 466
445 TEST_F('BackgroundTest', 'ActiveOrInactive', function() { 467 TEST_F('BackgroundTest', 'ActiveOrInactive', function() {
446 var mockFeedback = this.createMockFeedback(); 468 var mockFeedback = this.createMockFeedback();
447 this.runWithLoadedTree(function() {/*! 469 this.runWithLoadedTree(function() {/*!
448 <a href="a">a</a> 470 <a href="a">a</a>
449 <button>b</button> 471 <button>b</button>
450 <input type="text"></input> 472 <input type="text"></input>
451 */}, 473 */},
452 function(rootNode) { 474 function(rootNode) {
453 var focusButton = function() { rootNode.find({role: 'button'}).focus(); }; 475 var focusButton = function() {
476 rootNode.find({role: RoleType.button}).focus();
477 };
454 var on = function() { cvox.ChromeVox.isActive = true; }; 478 var on = function() { cvox.ChromeVox.isActive = true; };
455 var off = function() { cvox.ChromeVox.isActive = false; }; 479 var off = function() { cvox.ChromeVox.isActive = false; };
456 480
457 function focusThen(toFocus, then) { 481 function focusThen(toFocus, then) {
458 toFocus.addEventListener('focus', function innerFocus(e) { 482 toFocus.addEventListener('focus', function innerFocus(e) {
459 if (e.target != toFocus) 483 if (e.target != toFocus)
460 return; 484 return;
461 rootNode.removeEventListener('focus', innerFocus, true); 485 rootNode.removeEventListener('focus', innerFocus, true);
462 then && then(); 486 then && then();
463 }, true); 487 }, true);
464 toFocus.focus(); 488 toFocus.focus();
465 } 489 }
466 490
467 mockFeedback.call(focusButton) 491 mockFeedback.call(focusButton)
468 .expectSpeech('b').expectSpeech('Button') 492 .expectSpeech('b').expectSpeech('Button')
469 .call(off) 493 .call(off)
470 .call(focusThen.bind(this, rootNode.find({ role: 'link' }), on)) 494 .call(focusThen.bind(this, rootNode.find(
471 .call(focusThen.bind(this, rootNode.find({ role: 'textField' }))) 495 { role: RoleType.link }), on))
496 .call(focusThen.bind(this, rootNode.find(
497 { role: RoleType.textField })))
472 .expectNextSpeechUtteranceIsNot('a') 498 .expectNextSpeechUtteranceIsNot('a')
473 .expectSpeech('Edit text'); 499 .expectSpeech('Edit text');
474 500
475 mockFeedback.replay(); 501 mockFeedback.replay();
476 }); 502 });
477 }); 503 });
478 504
479 TEST_F('BackgroundTest', 'ModeSwitching', function() { 505 TEST_F('BackgroundTest', 'ModeSwitching', function() {
480 this.runWithLoadedTree('<button></button>', function(root) { 506 this.runWithLoadedTree('<button></button>', function(root) {
481 var fakeDesktop = {}; 507 var fakeDesktop = {};
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 global.backgroundObj.refreshMode(fakeSubRoot); 560 global.backgroundObj.refreshMode(fakeSubRoot);
535 assertEquals('next', global.backgroundObj.mode); 561 assertEquals('next', global.backgroundObj.mode);
536 }.bind(this)); 562 }.bind(this));
537 }); 563 });
538 564
539 TEST_F('BackgroundTest', 'FocusIframe', function() { 565 TEST_F('BackgroundTest', 'FocusIframe', function() {
540 this.runWithLoadedTree( function() {/*! 566 this.runWithLoadedTree( function() {/*!
541 <iframe tabindex=0 src="data:text/html,<p>Inside</p>"></iframe> 567 <iframe tabindex=0 src="data:text/html,<p>Inside</p>"></iframe>
542 <button>outside</button> 568 <button>outside</button>
543 */}, function(root) { 569 */}, function(root) {
544 var iframe = root.find({role: 'iframe'}); 570 var iframe = root.find({role: RoleType.iframe});
545 var button = root.find({role: 'button'}); 571 var button = root.find({role: RoleType.button});
546 572
547 assertEquals('iframe', iframe.role); 573 assertEquals('iframe', iframe.role);
548 assertEquals('button', button.role); 574 assertEquals('button', button.role);
549 575
550 var didFocus = false; 576 var didFocus = false;
551 iframe.focus = function() { 577 iframe.focus = function() {
552 didFocus = true; 578 didFocus = true;
553 }; 579 };
554 var b = global.backgroundObj; 580 var b = global.backgroundObj;
555 b.currentRange_ = cursors.Range.fromNode(button); 581 b.currentRange_ = cursors.Range.fromNode(button);
556 b.onGotCommand('previousElement'); 582 b.onGotCommand('previousElement');
557 assertFalse(didFocus); 583 assertFalse(didFocus);
558 }.bind(this)); 584 }.bind(this));
559 }); 585 });
560 586
561 TEST_F('BackgroundTest', 'NoisySlider', function() { 587 TEST_F('BackgroundTest', 'NoisySlider', function() {
562 var mockFeedback = this.createMockFeedback(); 588 var mockFeedback = this.createMockFeedback();
563 this.runWithLoadedTree( function() {/*! 589 this.runWithLoadedTree( function() {/*!
564 <button id="go">go</button> 590 <button id="go">go</button>
565 <div id="slider" tabindex=0 role="slider"></div> 591 <div id="slider" tabindex=0 role="slider"></div>
566 <script> 592 <script>
567 function update() { 593 function update() {
568 var s = document.getElementById('slider'); 594 var s = document.getElementById('slider');
569 s.setAttribute('aria-valuetext', 'noisy'); 595 s.setAttribute('aria-valuetext', 'noisy');
570 setTimeout(update, 500); 596 setTimeout(update, 500);
571 } 597 }
572 update(); 598 update();
573 </script> 599 </script>
574 */}, function(root) { 600 */}, function(root) {
575 var go = root.find({role: 'button'}); 601 var go = root.find({role: RoleType.button});
576 var slider = root.find({role: 'slider'}); 602 var slider = root.find({role: RoleType.slider});
577 var focusButton = go.focus.bind(go); 603 var focusButton = go.focus.bind(go);
578 var focusSlider = slider.focus.bind(slider); 604 var focusSlider = slider.focus.bind(slider);
579 mockFeedback.call(focusButton) 605 mockFeedback.call(focusButton)
580 .expectNextSpeechUtteranceIsNot('noisy') 606 .expectNextSpeechUtteranceIsNot('noisy')
581 .call(focusSlider) 607 .call(focusSlider)
582 .expectSpeech('noisy') 608 .expectSpeech('noisy')
583 .expectSpeech('noisy') 609 .expectSpeech('noisy')
584 .replay(); 610 .replay();
585 }.bind(this)); 611 }.bind(this));
586 }); 612 });
587 613
588 TEST_F('BackgroundTest', 'Checkbox', function() { 614 TEST_F('BackgroundTest', 'Checkbox', function() {
589 var mockFeedback = this.createMockFeedback(); 615 var mockFeedback = this.createMockFeedback();
590 this.runWithLoadedTree(function() {/*! 616 this.runWithLoadedTree(function() {/*!
591 <div id="go" role="checkbox">go</div> 617 <div id="go" role="checkbox">go</div>
592 <script> 618 <script>
593 var go = document.getElementById('go'); 619 var go = document.getElementById('go');
594 var isChecked = true; 620 var isChecked = true;
595 go.addEventListener('click', function(e) { 621 go.addEventListener('click', function(e) {
596 if (isChecked) 622 if (isChecked)
597 go.setAttribute('aria-checked', true); 623 go.setAttribute('aria-checked', true);
598 else 624 else
599 go.removeAttribute('aria-checked'); 625 go.removeAttribute('aria-checked');
600 isChecked = !isChecked; 626 isChecked = !isChecked;
601 }); 627 });
602 </script> 628 </script>
603 */}, function(root) { 629 */}, function(root) {
604 var cbx = root.find({role: 'checkBox'}); 630 var cbx = root.find({role: RoleType.checkBox});
605 var click = cbx.doDefault.bind(cbx); 631 var click = cbx.doDefault.bind(cbx);
606 mockFeedback.call(click) 632 mockFeedback.call(click)
607 .expectSpeech('go') 633 .expectSpeech('go')
608 .expectSpeech('Check box') 634 .expectSpeech('Check box')
609 .expectSpeech('checked') 635 .expectSpeech('checked')
610 .call(click) 636 .call(click)
611 .expectSpeech('go') 637 .expectSpeech('go')
612 .expectSpeech('Check box') 638 .expectSpeech('Check box')
613 .expectSpeech('not checked') 639 .expectSpeech('not checked')
614 .replay(); 640 .replay();
615 }); 641 });
616 }); 642 });
617 643
618 /** Tests navigating into and out of iframes using nextButton */ 644 /** Tests navigating into and out of iframes using nextButton */
619 TEST_F('BackgroundTest', 'ForwardNavigationThroughIframeButtons', function() { 645 TEST_F('BackgroundTest', 'ForwardNavigationThroughIframeButtons', function() {
620 var mockFeedback = this.createMockFeedback(); 646 var mockFeedback = this.createMockFeedback();
621 647
622 var running = false; 648 var running = false;
623 var runTestIfIframeIsLoaded = function(rootNode) { 649 var runTestIfIframeIsLoaded = function(rootNode) {
624 if (running) 650 if (running)
625 return; 651 return;
626 652
627 // Return if the iframe hasn't loaded yet. 653 // Return if the iframe hasn't loaded yet.
628 var iframe = rootNode.find({role: 'iframe'}); 654 var iframe = rootNode.find({role: RoleType.iframe});
629 var childDoc = iframe.firstChild; 655 var childDoc = iframe.firstChild;
630 if (!childDoc || childDoc.children.length == 0) 656 if (!childDoc || childDoc.children.length == 0)
631 return; 657 return;
632 658
633 running = true; 659 running = true;
634 var doCmd = this.doCmd.bind(this);
635
636 var beforeButton = rootNode.find({role: RoleType.button, 660 var beforeButton = rootNode.find({role: RoleType.button,
637 name: 'Before'}); 661 name: 'Before'});
638 beforeButton.focus(); 662 beforeButton.focus();
639 mockFeedback.expectSpeech('Before', 'Button'); 663 mockFeedback.expectSpeech('Before', 'Button');
640 mockFeedback.call(doCmd('nextButton')) 664 mockFeedback.call(doCmd('nextButton'))
641 .expectSpeech('Inside', 'Button'); 665 .expectSpeech('Inside', 'Button');
642 mockFeedback.call(doCmd('nextButton')) 666 mockFeedback.call(doCmd('nextButton'))
643 .expectSpeech('After', 'Button'); 667 .expectSpeech('After', 'Button');
644 mockFeedback.call(doCmd('previousButton')) 668 mockFeedback.call(doCmd('previousButton'))
645 .expectSpeech('Inside', 'Button'); 669 .expectSpeech('Inside', 'Button');
(...skipping 22 matching lines...) Expand all
668 if (running) 692 if (running)
669 return; 693 return;
670 694
671 // Return if the iframe hasn't loaded yet. 695 // Return if the iframe hasn't loaded yet.
672 var iframe = rootNode.find({role: 'iframe'}); 696 var iframe = rootNode.find({role: 'iframe'});
673 var childDoc = iframe.firstChild; 697 var childDoc = iframe.firstChild;
674 if (!childDoc || childDoc.children.length == 0) 698 if (!childDoc || childDoc.children.length == 0)
675 return; 699 return;
676 700
677 running = true; 701 running = true;
678 var doCmd = this.doCmd.bind(this);
679
680 var beforeButton = rootNode.find({role: RoleType.button, 702 var beforeButton = rootNode.find({role: RoleType.button,
681 name: 'Before'}); 703 name: 'Before'});
682 beforeButton.focus(); 704 beforeButton.focus();
683 mockFeedback.expectSpeech('Before', 'Button'); 705 mockFeedback.expectSpeech('Before', 'Button');
684 mockFeedback.call(doCmd('nextObject')) 706 mockFeedback.call(doCmd('nextObject'))
685 .expectSpeech('Inside', 'Button'); 707 .expectSpeech('Inside', 'Button');
686 mockFeedback.call(doCmd('nextObject')) 708 mockFeedback.call(doCmd('nextObject'))
687 .expectSpeech('Inside', 'Heading 1'); 709 .expectSpeech('Inside', 'Heading 1');
688 mockFeedback.call(doCmd('nextObject')) 710 mockFeedback.call(doCmd('nextObject'))
689 .expectSpeech('After', 'Button'); 711 .expectSpeech('After', 'Button');
(...skipping 19 matching lines...) Expand all
709 731
710 TEST_F('BackgroundTest', 'SelectOptionSelected', function() { 732 TEST_F('BackgroundTest', 'SelectOptionSelected', function() {
711 var mockFeedback = this.createMockFeedback(); 733 var mockFeedback = this.createMockFeedback();
712 this.runWithLoadedTree(function() {/*! 734 this.runWithLoadedTree(function() {/*!
713 <select> 735 <select>
714 <option>apple 736 <option>apple
715 <option>banana 737 <option>banana
716 <option>grapefruit 738 <option>grapefruit
717 </select> 739 </select>
718 */}, function(root) { 740 */}, function(root) {
719 var select = root.find({role: 'popUpButton'}); 741 var select = root.find({role: RoleType.popUpButton});
720 var clickSelect = select.doDefault.bind(select); 742 var clickSelect = select.doDefault.bind(select);
721 var lastOption = select.lastChild.lastChild; 743 var lastOption = select.lastChild.lastChild;
722 var selectLastOption = lastOption.doDefault.bind(lastOption); 744 var selectLastOption = lastOption.doDefault.bind(lastOption);
723 745
724 mockFeedback.call(clickSelect) 746 mockFeedback.call(clickSelect)
725 .expectSpeech('apple') 747 .expectSpeech('apple')
726 .expectSpeech('Button') 748 .expectSpeech('Button')
727 .call(selectLastOption) 749 .call(selectLastOption)
728 .expectNextSpeechUtteranceIsNot('apple') 750 .expectNextSpeechUtteranceIsNot('apple')
729 .expectSpeech('grapefruit') 751 .expectSpeech('grapefruit')
(...skipping 27 matching lines...) Expand all
757 .replay(); 779 .replay();
758 }); 780 });
759 }); 781 });
760 782
761 TEST_F('BackgroundTest', 'EditText', function() { 783 TEST_F('BackgroundTest', 'EditText', function() {
762 var mockFeedback = this.createMockFeedback(); 784 var mockFeedback = this.createMockFeedback();
763 this.runWithLoadedTree(function() {/*! 785 this.runWithLoadedTree(function() {/*!
764 <input type="text"></input> 786 <input type="text"></input>
765 <input role="combobox" type="text"></input> 787 <input role="combobox" type="text"></input>
766 */}, function(root) { 788 */}, function(root) {
767 var nextEditText = this.doCmd('nextEditText'); 789 var nextEditText = doCmd('nextEditText');
768 var previousEditText = this.doCmd('previousEditText'); 790 var previousEditText = doCmd('previousEditText');
769 mockFeedback.call(nextEditText) 791 mockFeedback.call(nextEditText)
770 .expectSpeech('Combo box') 792 .expectSpeech('Combo box')
771 .call(previousEditText) 793 .call(previousEditText)
772 .expectSpeech('Edit text') 794 .expectSpeech('Edit text')
773 .replay(); 795 .replay();
774 }); 796 });
775 }); 797 });
776 798
777 TEST_F('BackgroundTest', 'BackwardForwardSync', function() { 799 TEST_F('BackgroundTest', 'BackwardForwardSync', function() {
778 var mockFeedback = this.createMockFeedback(); 800 var mockFeedback = this.createMockFeedback();
(...skipping 17 matching lines...) Expand all
796 .expectSpeech('•') 818 .expectSpeech('•')
797 .call(this.doCmd('previousObject')) 819 .call(this.doCmd('previousObject'))
798 .expectSpeech('List item') 820 .expectSpeech('List item')
799 .call(this.doCmd('previousObject')) 821 .call(this.doCmd('previousObject'))
800 .expectSpeech('Edit text') 822 .expectSpeech('Edit text')
801 .call(this.doCmd('previousObject')) 823 .call(this.doCmd('previousObject'))
802 .expectSpeech('Group') 824 .expectSpeech('Group')
803 .replay(); 825 .replay();
804 }); 826 });
805 }); 827 });
828
829 /** Tests that navigation works when the current object disappears. */
830 TEST_F('BackgroundTest', 'DisappearingObject', function() {
831 var mockFeedback = this.createMockFeedback();
832 this.runWithLoadedTree(this.disappearingObjectDoc, function(rootNode) {
833 var deleteButton = rootNode.find({role: RoleType.button,
834 attributes: { name: 'Delete' }});
835 var pressDelete = deleteButton.doDefault.bind(deleteButton);
836 mockFeedback.expectSpeech('start').expectBraille('start');
837
838 mockFeedback.call(doCmd('nextObject'))
839 .expectSpeech('Before1')
840 .call(doCmd('nextObject'))
841 .expectSpeech('Before2')
842 .call(doCmd('nextObject'))
843 .expectSpeech('Before3')
844 .call(doCmd('nextObject'))
845 .expectSpeech('Disappearing')
846 .call(pressDelete)
847 .expectSpeech('Deleted')
848 .call(doCmd('nextObject'))
849 .expectSpeech('After1')
850 .call(doCmd('nextObject'))
851 .expectSpeech('After2')
852 .call(doCmd('previousObject'))
853 .expectSpeech('After1')
854 .call(doCmd('previousObject'))
855 .expectSpeech('Before3');
856
857 mockFeedback.replay();
858 });
859 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698