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

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

Issue 2650733002: Revert of Update json_schema_compiler to handle the Automation extension API (Closed)
Patch Set: Created 3 years, 11 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
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 mockFeedback.expectSpeech('a') 256 mockFeedback.expectSpeech('a')
257 .expectSpeech('Link'); 257 .expectSpeech('Link');
258 mockFeedback.replay(); 258 mockFeedback.replay();
259 }); 259 });
260 }); 260 });
261 261
262 TEST_F('BackgroundTest', 'AriaLabel', function() { 262 TEST_F('BackgroundTest', 'AriaLabel', function() {
263 var mockFeedback = this.createMockFeedback(); 263 var mockFeedback = this.createMockFeedback();
264 this.runWithLoadedTree('<a aria-label="foo" href="a">a</a>', 264 this.runWithLoadedTree('<a aria-label="foo" href="a">a</a>',
265 function(rootNode) { 265 function(rootNode) {
266 rootNode.find({role: RoleType.LINK}).focus(); 266 rootNode.find({role: RoleType.link}).focus();
267 mockFeedback.expectSpeech('foo') 267 mockFeedback.expectSpeech('foo')
268 .expectSpeech('Link') 268 .expectSpeech('Link')
269 .expectBraille('foo lnk'); 269 .expectBraille('foo lnk');
270 mockFeedback.replay(); 270 mockFeedback.replay();
271 } 271 }
272 ); 272 );
273 }); 273 });
274 274
275 TEST_F('BackgroundTest', 'ShowContextMenu', function() { 275 TEST_F('BackgroundTest', 'ShowContextMenu', function() {
276 var mockFeedback = this.createMockFeedback(); 276 var mockFeedback = this.createMockFeedback();
277 this.runWithLoadedTree('<p>before</p><a href="a">a</a>', 277 this.runWithLoadedTree('<p>before</p><a href="a">a</a>',
278 function(rootNode) { 278 function(rootNode) {
279 var go = rootNode.find({ role: RoleType.LINK }); 279 var go = rootNode.find({ role: RoleType.link });
280 // Menus no longer nest a message loop, so we can launch menu and confirm 280 // Menus no longer nest a message loop, so we can launch menu and confirm
281 // expected speech. The menu will not block test shutdown. 281 // expected speech. The menu will not block test shutdown.
282 mockFeedback.call(go.focus.bind(go)) 282 mockFeedback.call(go.focus.bind(go))
283 .expectSpeech('a', 'Link') 283 .expectSpeech('a', 'Link')
284 .call(doCmd('contextMenu')) 284 .call(doCmd('contextMenu'))
285 .expectSpeech(/menu opened/); 285 .expectSpeech(/menu opened/);
286 mockFeedback.replay(); 286 mockFeedback.replay();
287 }.bind(this)); 287 }.bind(this));
288 }); 288 });
289 289
(...skipping 13 matching lines...) Expand all
303 <button id="btn2">Focus me</button> 303 <button id="btn2">Focus me</button>
304 <p>Some more text</p> 304 <p>Some more text</p>
305 <input type="text" id ="text" value="Edit me"> 305 <input type="text" id ="text" value="Edit me">
306 <script> 306 <script>
307 document.getElementById('btn1').addEventListener('click', function() { 307 document.getElementById('btn1').addEventListener('click', function() {
308 document.getElementById('btn2').focus(); 308 document.getElementById('btn2').focus();
309 }, false); 309 }, false);
310 </script> 310 </script>
311 */}, 311 */},
312 function(rootNode) { 312 function(rootNode) {
313 var button1 = rootNode.find({role: RoleType.BUTTON, 313 var button1 = rootNode.find({role: RoleType.button,
314 attributes: { name: 'Click me' }}); 314 attributes: { name: 'Click me' }});
315 var textField = rootNode.find( 315 var textField = rootNode.find(
316 {role: RoleType.TEXT_FIELD}); 316 {role: RoleType.textField});
317 mockFeedback.expectBraille('start') 317 mockFeedback.expectBraille('start')
318 .call(button1.focus.bind(button1)) 318 .call(button1.focus.bind(button1))
319 .expectBraille(/^Click me btn/) 319 .expectBraille(/^Click me btn/)
320 .call(route.bind(null, 5)) 320 .call(route.bind(null, 5))
321 .expectBraille(/Focus me btn/) 321 .expectBraille(/Focus me btn/)
322 .call(textField.focus.bind(textField)) 322 .call(textField.focus.bind(textField))
323 .expectBraille('Edit me ed', {startIndex: 0}) 323 .expectBraille('Edit me ed', {startIndex: 0})
324 .call(route.bind(null, 3)) 324 .call(route.bind(null, 3))
325 .expectBraille('Edit me ed', {startIndex: 3}) 325 .expectBraille('Edit me ed', {startIndex: 3})
326 .call(function() { 326 .call(function() {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 }); 369 });
370 var assertDoesntExist = this.newCallback(function (evt) { 370 var assertDoesntExist = this.newCallback(function (evt) {
371 assertTrue( 371 assertTrue(
372 !ChromeVoxState.desktopAutomationHandler.editableTextHandler_); 372 !ChromeVoxState.desktopAutomationHandler.editableTextHandler_);
373 evt.stopPropagation(); 373 evt.stopPropagation();
374 374
375 // Focus the other text field here to make this test not racey. 375 // Focus the other text field here to make this test not racey.
376 editable.focus(); 376 editable.focus();
377 }); 377 });
378 378
379 var editable = rootNode.find({ role: RoleType.TEXT_FIELD }); 379 var editable = rootNode.find({ role: RoleType.textField });
380 var nonEditable = rootNode.find({ role: RoleType.PARAGRAPH }); 380 var nonEditable = rootNode.find({ role: RoleType.paragraph });
381 381
382 this.listenOnce(nonEditable, 'focus', assertDoesntExist); 382 this.listenOnce(nonEditable, 'focus', assertDoesntExist);
383 this.listenOnce(editable, 'focus', assertExists); 383 this.listenOnce(editable, 'focus', assertExists);
384 384
385 nonEditable.focus(); 385 nonEditable.focus();
386 }.bind(this)); 386 }.bind(this));
387 }); 387 });
388 388
389 TEST_F('BackgroundTest', 'EarconsForControls', function() { 389 TEST_F('BackgroundTest', 'EarconsForControls', function() {
390 var mockFeedback = this.createMockFeedback(); 390 var mockFeedback = this.createMockFeedback();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 // Flaky, see http://crbug.com/635032 465 // Flaky, see http://crbug.com/635032
466 TEST_F('BackgroundTest', 'DISABLED_ActiveOrInactive', function() { 466 TEST_F('BackgroundTest', 'DISABLED_ActiveOrInactive', function() {
467 var mockFeedback = this.createMockFeedback(); 467 var mockFeedback = this.createMockFeedback();
468 this.runWithLoadedTree(function() {/*! 468 this.runWithLoadedTree(function() {/*!
469 <a href="a">a</a> 469 <a href="a">a</a>
470 <button>b</button> 470 <button>b</button>
471 <input type="text"></input> 471 <input type="text"></input>
472 */}, 472 */},
473 function(rootNode) { 473 function(rootNode) {
474 var focusButton = function() { 474 var focusButton = function() {
475 rootNode.find({role: RoleType.BUTTON}).focus(); 475 rootNode.find({role: RoleType.button}).focus();
476 }; 476 };
477 var on = function() { cvox.ChromeVox.isActive = true; }; 477 var on = function() { cvox.ChromeVox.isActive = true; };
478 var off = function() { cvox.ChromeVox.isActive = false; }; 478 var off = function() { cvox.ChromeVox.isActive = false; };
479 479
480 function focusThen(toFocus, then) { 480 function focusThen(toFocus, then) {
481 toFocus.addEventListener('focus', function innerFocus(e) { 481 toFocus.addEventListener('focus', function innerFocus(e) {
482 if (e.target != toFocus) 482 if (e.target != toFocus)
483 return; 483 return;
484 rootNode.removeEventListener('focus', innerFocus, true); 484 rootNode.removeEventListener('focus', innerFocus, true);
485 then && then(); 485 then && then();
486 }, true); 486 }, true);
487 toFocus.focus(); 487 toFocus.focus();
488 } 488 }
489 489
490 mockFeedback.call(focusButton) 490 mockFeedback.call(focusButton)
491 .expectSpeech('b').expectSpeech('Button') 491 .expectSpeech('b').expectSpeech('Button')
492 .call(off) 492 .call(off)
493 .call(focusThen.bind(this, rootNode.find( 493 .call(focusThen.bind(this, rootNode.find(
494 { role: RoleType.LINK }), on)) 494 { role: RoleType.link }), on))
495 .call(focusThen.bind(this, rootNode.find( 495 .call(focusThen.bind(this, rootNode.find(
496 { role: RoleType.TEXT_FIELD }))) 496 { role: RoleType.textField })))
497 .expectNextSpeechUtteranceIsNot('a') 497 .expectNextSpeechUtteranceIsNot('a')
498 .expectSpeech('Edit text'); 498 .expectSpeech('Edit text');
499 499
500 mockFeedback.replay(); 500 mockFeedback.replay();
501 }); 501 });
502 }); 502 });
503 503
504 TEST_F('BackgroundTest', 'ModeSwitching', function() { 504 TEST_F('BackgroundTest', 'ModeSwitching', function() {
505 this.runWithLoadedTree('<button></button>', function(root) { 505 this.runWithLoadedTree('<button></button>', function(root) {
506 var fakeDesktop = {}; 506 var fakeDesktop = {};
507 fakeDesktop.role = 'desktop'; 507 fakeDesktop.role = 'desktop';
508 fakeDesktop.root = fakeDesktop; 508 fakeDesktop.root = fakeDesktop;
509 509
510 var fakeWebRoot = {}; 510 var fakeWebRoot = {};
511 fakeWebRoot.root = fakeWebRoot; 511 fakeWebRoot.root = fakeWebRoot;
512 fakeWebRoot.parent = fakeDesktop; 512 fakeWebRoot.parent = fakeDesktop;
513 fakeWebRoot.role = RoleType.ROOT_WEB_AREA; 513 fakeWebRoot.role = RoleType.rootWebArea;
514 fakeWebRoot.makeVisible = function() {}; 514 fakeWebRoot.makeVisible = function() {};
515 fakeWebRoot.location = {left: 1, top: 1, width: 1, height: 1}; 515 fakeWebRoot.location = {left: 1, top: 1, width: 1, height: 1};
516 var fakeSubRoot = {}; 516 var fakeSubRoot = {};
517 fakeSubRoot.root = fakeSubRoot; 517 fakeSubRoot.root = fakeSubRoot;
518 fakeSubRoot.parent = fakeWebRoot; 518 fakeSubRoot.parent = fakeWebRoot;
519 fakeSubRoot.role = RoleType.ROOT_WEB_AREA; 519 fakeSubRoot.role = RoleType.rootWebArea;
520 fakeSubRoot.makeVisible = function() {}; 520 fakeSubRoot.makeVisible = function() {};
521 fakeSubRoot.location = {left: 1, top: 1, width: 1, height: 1}; 521 fakeSubRoot.location = {left: 1, top: 1, width: 1, height: 1};
522 var bk = ChromeVoxState.instance; 522 var bk = ChromeVoxState.instance;
523 523
524 // Tests default to force next mode. 524 // Tests default to force next mode.
525 assertEquals('force_next', bk.mode); 525 assertEquals('force_next', bk.mode);
526 526
527 // Force next mode stays set regardless of where the range lands. 527 // Force next mode stays set regardless of where the range lands.
528 fakeWebRoot.docUrl = 'http://google.com'; 528 fakeWebRoot.docUrl = 'http://google.com';
529 bk.setCurrentRange(cursors.Range.fromNode(fakeWebRoot)); 529 bk.setCurrentRange(cursors.Range.fromNode(fakeWebRoot));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 bk.setCurrentRange(cursors.Range.fromNode(fakeWebRoot)); 571 bk.setCurrentRange(cursors.Range.fromNode(fakeWebRoot));
572 assertEquals('force_next', bk.mode); 572 assertEquals('force_next', bk.mode);
573 }.bind(this)); 573 }.bind(this));
574 }); 574 });
575 575
576 TEST_F('BackgroundTest', 'ShouldNotFocusIframe', function() { 576 TEST_F('BackgroundTest', 'ShouldNotFocusIframe', function() {
577 this.runWithLoadedTree( function() {/*! 577 this.runWithLoadedTree( function() {/*!
578 <iframe tabindex=0 src="data:text/html,<p>Inside</p>"></iframe> 578 <iframe tabindex=0 src="data:text/html,<p>Inside</p>"></iframe>
579 <button>outside</button> 579 <button>outside</button>
580 */}, function(root) { 580 */}, function(root) {
581 var iframe = root.find({role: RoleType.IFRAME}); 581 var iframe = root.find({role: RoleType.iframe});
582 var button = root.find({role: RoleType.BUTTON}); 582 var button = root.find({role: RoleType.button});
583 583
584 assertEquals('iframe', iframe.role); 584 assertEquals('iframe', iframe.role);
585 assertEquals('button', button.role); 585 assertEquals('button', button.role);
586 586
587 var didFocus = false; 587 var didFocus = false;
588 iframe.addEventListener('focus', function() { 588 iframe.addEventListener('focus', function() {
589 didFocus = true; 589 didFocus = true;
590 }); 590 });
591 var b = ChromeVoxState.instance; 591 var b = ChromeVoxState.instance;
592 b.currentRange_ = cursors.Range.fromNode(button); 592 b.currentRange_ = cursors.Range.fromNode(button);
593 doCmd('previousElement'); 593 doCmd('previousElement');
594 assertFalse(didFocus); 594 assertFalse(didFocus);
595 }.bind(this)); 595 }.bind(this));
596 }); 596 });
597 597
598 TEST_F('BackgroundTest', 'ShouldFocusLink', function() { 598 TEST_F('BackgroundTest', 'ShouldFocusLink', function() {
599 this.runWithLoadedTree( function() {/*! 599 this.runWithLoadedTree( function() {/*!
600 <div><a href="#">mylink</a></div> 600 <div><a href="#">mylink</a></div>
601 <button>after</button> 601 <button>after</button>
602 */}, function(root) { 602 */}, function(root) {
603 var link = root.find({role: RoleType.LINK}); 603 var link = root.find({role: RoleType.link});
604 var button = root.find({role: RoleType.BUTTON}); 604 var button = root.find({role: RoleType.button});
605 605
606 assertEquals('link', link.role); 606 assertEquals('link', link.role);
607 assertEquals('button', button.role); 607 assertEquals('button', button.role);
608 608
609 var didFocus = false; 609 var didFocus = false;
610 link.addEventListener('focus', this.newCallback(function() { 610 link.addEventListener('focus', this.newCallback(function() {
611 // Success 611 // Success
612 })); 612 }));
613 var b = ChromeVoxState.instance; 613 var b = ChromeVoxState.instance;
614 b.currentRange_ = cursors.Range.fromNode(button); 614 b.currentRange_ = cursors.Range.fromNode(button);
615 doCmd('previousElement'); 615 doCmd('previousElement');
616 }); 616 });
617 }); 617 });
618 618
619 TEST_F('BackgroundTest', 'NoisySlider', function() { 619 TEST_F('BackgroundTest', 'NoisySlider', function() {
620 var mockFeedback = this.createMockFeedback(); 620 var mockFeedback = this.createMockFeedback();
621 this.runWithLoadedTree( function() {/*! 621 this.runWithLoadedTree( function() {/*!
622 <button id="go">go</button> 622 <button id="go">go</button>
623 <div id="slider" tabindex=0 role="slider"></div> 623 <div id="slider" tabindex=0 role="slider"></div>
624 <script> 624 <script>
625 function update() { 625 function update() {
626 var s = document.getElementById('slider'); 626 var s = document.getElementById('slider');
627 s.setAttribute('aria-valuetext', 'noisy'); 627 s.setAttribute('aria-valuetext', 'noisy');
628 setTimeout(update, 500); 628 setTimeout(update, 500);
629 } 629 }
630 update(); 630 update();
631 </script> 631 </script>
632 */}, function(root) { 632 */}, function(root) {
633 var go = root.find({role: RoleType.BUTTON}); 633 var go = root.find({role: RoleType.button});
634 var slider = root.find({role: RoleType.SLIDER}); 634 var slider = root.find({role: RoleType.slider});
635 var focusButton = go.focus.bind(go); 635 var focusButton = go.focus.bind(go);
636 var focusSlider = slider.focus.bind(slider); 636 var focusSlider = slider.focus.bind(slider);
637 mockFeedback.call(focusButton) 637 mockFeedback.call(focusButton)
638 .expectNextSpeechUtteranceIsNot('noisy') 638 .expectNextSpeechUtteranceIsNot('noisy')
639 .call(focusSlider) 639 .call(focusSlider)
640 .expectSpeech('noisy') 640 .expectSpeech('noisy')
641 .expectSpeech('noisy') 641 .expectSpeech('noisy')
642 .replay(); 642 .replay();
643 }.bind(this)); 643 }.bind(this));
644 }); 644 });
645 645
646 TEST_F('BackgroundTest', 'Checkbox', function() { 646 TEST_F('BackgroundTest', 'Checkbox', function() {
647 var mockFeedback = this.createMockFeedback(); 647 var mockFeedback = this.createMockFeedback();
648 this.runWithLoadedTree(function() {/*! 648 this.runWithLoadedTree(function() {/*!
649 <div id="go" role="checkbox">go</div> 649 <div id="go" role="checkbox">go</div>
650 <script> 650 <script>
651 var go = document.getElementById('go'); 651 var go = document.getElementById('go');
652 var isChecked = true; 652 var isChecked = true;
653 go.addEventListener('click', function(e) { 653 go.addEventListener('click', function(e) {
654 if (isChecked) 654 if (isChecked)
655 go.setAttribute('aria-checked', true); 655 go.setAttribute('aria-checked', true);
656 else 656 else
657 go.removeAttribute('aria-checked'); 657 go.removeAttribute('aria-checked');
658 isChecked = !isChecked; 658 isChecked = !isChecked;
659 }); 659 });
660 </script> 660 </script>
661 */}, function(root) { 661 */}, function(root) {
662 var cbx = root.find({role: RoleType.CHECK_BOX}); 662 var cbx = root.find({role: RoleType.checkBox});
663 var click = cbx.doDefault.bind(cbx); 663 var click = cbx.doDefault.bind(cbx);
664 var focus = cbx.focus.bind(cbx); 664 var focus = cbx.focus.bind(cbx);
665 mockFeedback.call(focus) 665 mockFeedback.call(focus)
666 .expectSpeech('go') 666 .expectSpeech('go')
667 .expectSpeech('Check box') 667 .expectSpeech('Check box')
668 .expectSpeech('Not checked') 668 .expectSpeech('Not checked')
669 .call(click) 669 .call(click)
670 .expectSpeech('go') 670 .expectSpeech('go')
671 .expectSpeech('Check box') 671 .expectSpeech('Check box')
672 .expectSpeech('Checked') 672 .expectSpeech('Checked')
(...skipping 17 matching lines...) Expand all
690 /** Tests navigating into and out of iframes using nextButton */ 690 /** Tests navigating into and out of iframes using nextButton */
691 TEST_F('BackgroundTest', 'ForwardNavigationThroughIframeButtons', function() { 691 TEST_F('BackgroundTest', 'ForwardNavigationThroughIframeButtons', function() {
692 var mockFeedback = this.createMockFeedback(); 692 var mockFeedback = this.createMockFeedback();
693 693
694 var running = false; 694 var running = false;
695 var runTestIfIframeIsLoaded = function(rootNode) { 695 var runTestIfIframeIsLoaded = function(rootNode) {
696 if (running) 696 if (running)
697 return; 697 return;
698 698
699 // Return if the iframe hasn't loaded yet. 699 // Return if the iframe hasn't loaded yet.
700 var iframe = rootNode.find({role: RoleType.IFRAME}); 700 var iframe = rootNode.find({role: RoleType.iframe});
701 var childDoc = iframe.firstChild; 701 var childDoc = iframe.firstChild;
702 if (!childDoc || childDoc.children.length == 0) 702 if (!childDoc || childDoc.children.length == 0)
703 return; 703 return;
704 704
705 running = true; 705 running = true;
706 var beforeButton = rootNode.find({role: RoleType.BUTTON, 706 var beforeButton = rootNode.find({role: RoleType.button,
707 name: 'Before'}); 707 name: 'Before'});
708 beforeButton.focus(); 708 beforeButton.focus();
709 mockFeedback.expectSpeech('Before', 'Button'); 709 mockFeedback.expectSpeech('Before', 'Button');
710 mockFeedback.call(doCmd('nextButton')) 710 mockFeedback.call(doCmd('nextButton'))
711 .expectSpeech('Inside', 'Button'); 711 .expectSpeech('Inside', 'Button');
712 mockFeedback.call(doCmd('nextButton')) 712 mockFeedback.call(doCmd('nextButton'))
713 .expectSpeech('After', 'Button'); 713 .expectSpeech('After', 'Button');
714 mockFeedback.call(doCmd('previousButton')) 714 mockFeedback.call(doCmd('previousButton'))
715 .expectSpeech('Inside', 'Button'); 715 .expectSpeech('Inside', 'Button');
716 mockFeedback.call(doCmd('previousButton')) 716 mockFeedback.call(doCmd('previousButton'))
(...skipping 21 matching lines...) Expand all
738 if (running) 738 if (running)
739 return; 739 return;
740 740
741 // Return if the iframe hasn't loaded yet. 741 // Return if the iframe hasn't loaded yet.
742 var iframe = rootNode.find({role: 'iframe'}); 742 var iframe = rootNode.find({role: 'iframe'});
743 var childDoc = iframe.firstChild; 743 var childDoc = iframe.firstChild;
744 if (!childDoc || childDoc.children.length == 0) 744 if (!childDoc || childDoc.children.length == 0)
745 return; 745 return;
746 746
747 running = true; 747 running = true;
748 var beforeButton = rootNode.find({role: RoleType.BUTTON, 748 var beforeButton = rootNode.find({role: RoleType.button,
749 name: 'Before'}); 749 name: 'Before'});
750 beforeButton.focus(); 750 beforeButton.focus();
751 mockFeedback.expectSpeech('Before', 'Button'); 751 mockFeedback.expectSpeech('Before', 'Button');
752 mockFeedback.call(doCmd('nextObject')) 752 mockFeedback.call(doCmd('nextObject'))
753 .expectSpeech('Inside', 'Button'); 753 .expectSpeech('Inside', 'Button');
754 mockFeedback.call(doCmd('nextObject')) 754 mockFeedback.call(doCmd('nextObject'))
755 .expectSpeech('Inside', 'Heading 1'); 755 .expectSpeech('Inside', 'Heading 1');
756 mockFeedback.call(doCmd('nextObject')) 756 mockFeedback.call(doCmd('nextObject'))
757 .expectSpeech('After', 'Button'); 757 .expectSpeech('After', 'Button');
758 mockFeedback.call(doCmd('previousObject')) 758 mockFeedback.call(doCmd('previousObject'))
(...skipping 18 matching lines...) Expand all
777 777
778 TEST_F('BackgroundTest', 'SelectOptionSelected', function() { 778 TEST_F('BackgroundTest', 'SelectOptionSelected', function() {
779 var mockFeedback = this.createMockFeedback(); 779 var mockFeedback = this.createMockFeedback();
780 this.runWithLoadedTree(function() {/*! 780 this.runWithLoadedTree(function() {/*!
781 <select> 781 <select>
782 <option>apple 782 <option>apple
783 <option>banana 783 <option>banana
784 <option>grapefruit 784 <option>grapefruit
785 </select> 785 </select>
786 */}, function(root) { 786 */}, function(root) {
787 var select = root.find({role: RoleType.POP_UP_BUTTON}); 787 var select = root.find({role: RoleType.popUpButton});
788 var clickSelect = select.doDefault.bind(select); 788 var clickSelect = select.doDefault.bind(select);
789 var lastOption = select.lastChild.lastChild; 789 var lastOption = select.lastChild.lastChild;
790 var selectLastOption = lastOption.doDefault.bind(lastOption); 790 var selectLastOption = lastOption.doDefault.bind(lastOption);
791 791
792 mockFeedback.call(clickSelect) 792 mockFeedback.call(clickSelect)
793 .expectSpeech('apple') 793 .expectSpeech('apple')
794 .expectSpeech('Button') 794 .expectSpeech('Button')
795 .call(selectLastOption) 795 .call(selectLastOption)
796 .expectNextSpeechUtteranceIsNot('apple') 796 .expectNextSpeechUtteranceIsNot('apple')
797 .expectSpeech('grapefruit') 797 .expectSpeech('grapefruit')
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 this.runWithLoadedTree(function() {/*! 847 this.runWithLoadedTree(function() {/*!
848 <div aria-label="Group" role="group" tabindex=0> 848 <div aria-label="Group" role="group" tabindex=0>
849 <input type="text"></input> 849 <input type="text"></input>
850 </div> 850 </div>
851 <ul> 851 <ul>
852 <li tabindex=0> 852 <li tabindex=0>
853 <button>ok</button> 853 <button>ok</button>
854 </li> 854 </li>
855 </ul> 855 </ul>
856 */}, function(root) { 856 */}, function(root) {
857 var listItem = root.find({role: RoleType.LIST_ITEM}); 857 var listItem = root.find({role: RoleType.listItem});
858 858
859 mockFeedback.call(listItem.focus.bind(listItem)) 859 mockFeedback.call(listItem.focus.bind(listItem))
860 .expectSpeech('List item') 860 .expectSpeech('List item')
861 .call(this.doCmd('nextObject')) 861 .call(this.doCmd('nextObject'))
862 .expectSpeech('Button') 862 .expectSpeech('Button')
863 .call(this.doCmd('previousObject')) 863 .call(this.doCmd('previousObject'))
864 .expectSpeech('List item') 864 .expectSpeech('List item')
865 .call(this.doCmd('previousObject')) 865 .call(this.doCmd('previousObject'))
866 .expectSpeech('Edit text') 866 .expectSpeech('Edit text')
867 .call(this.doCmd('previousObject')) 867 .call(this.doCmd('previousObject'))
868 .expectSpeech('Group') 868 .expectSpeech('Group')
869 .replay(); 869 .replay();
870 }); 870 });
871 }); 871 });
872 872
873 /** Tests that navigation works when the current object disappears. */ 873 /** Tests that navigation works when the current object disappears. */
874 TEST_F('BackgroundTest', 'DisappearingObject', function() { 874 TEST_F('BackgroundTest', 'DisappearingObject', function() {
875 var mockFeedback = this.createMockFeedback(); 875 var mockFeedback = this.createMockFeedback();
876 this.runWithLoadedTree(this.disappearingObjectDoc, function(rootNode) { 876 this.runWithLoadedTree(this.disappearingObjectDoc, function(rootNode) {
877 var deleteButton = rootNode.find({role: RoleType.BUTTON, 877 var deleteButton = rootNode.find({role: RoleType.button,
878 attributes: { name: 'Delete' }}); 878 attributes: { name: 'Delete' }});
879 var pressDelete = deleteButton.doDefault.bind(deleteButton); 879 var pressDelete = deleteButton.doDefault.bind(deleteButton);
880 mockFeedback.expectSpeech('start').expectBraille('start'); 880 mockFeedback.expectSpeech('start').expectBraille('start');
881 881
882 mockFeedback.call(doCmd('nextObject')) 882 mockFeedback.call(doCmd('nextObject'))
883 .expectSpeech('Before1') 883 .expectSpeech('Before1')
884 .call(doCmd('nextObject')) 884 .call(doCmd('nextObject'))
885 .expectSpeech('Before2') 885 .expectSpeech('Before2')
886 .call(doCmd('nextObject')) 886 .call(doCmd('nextObject'))
887 .expectSpeech('Before3') 887 .expectSpeech('Before3')
(...skipping 12 matching lines...) Expand all
900 900
901 mockFeedback.replay(); 901 mockFeedback.replay();
902 }); 902 });
903 }); 903 });
904 904
905 TEST_F('BackgroundTest', 'ButtonNameValueDescription', function() { 905 TEST_F('BackgroundTest', 'ButtonNameValueDescription', function() {
906 var mockFeedback = this.createMockFeedback(); 906 var mockFeedback = this.createMockFeedback();
907 this.runWithLoadedTree(function(root) {/*! 907 this.runWithLoadedTree(function(root) {/*!
908 <input type="submit" aria-label="foo" value="foo"></input> 908 <input type="submit" aria-label="foo" value="foo"></input>
909 */}, function(root) { 909 */}, function(root) {
910 var btn = root.find({role: RoleType.BUTTON}); 910 var btn = root.find({role: RoleType.button});
911 mockFeedback.call(btn.focus.bind(btn)) 911 mockFeedback.call(btn.focus.bind(btn))
912 .expectSpeech('foo') 912 .expectSpeech('foo')
913 .expectSpeech('Button') 913 .expectSpeech('Button')
914 .replay(); 914 .replay();
915 }); 915 });
916 }); 916 });
917 917
918 TEST_F('BackgroundTest', 'NameFromHeadingLink', function() { 918 TEST_F('BackgroundTest', 'NameFromHeadingLink', function() {
919 var mockFeedback = this.createMockFeedback(); 919 var mockFeedback = this.createMockFeedback();
920 this.runWithLoadedTree(function(root) {/*! 920 this.runWithLoadedTree(function(root) {/*!
921 <p>before</p> 921 <p>before</p>
922 <h1><a href="google.com">go</a><p>here</p></h1> 922 <h1><a href="google.com">go</a><p>here</p></h1>
923 */}, function(root) { 923 */}, function(root) {
924 var link = root.find({role: RoleType.LINK}); 924 var link = root.find({role: RoleType.link});
925 mockFeedback.call(link.focus.bind(link)) 925 mockFeedback.call(link.focus.bind(link))
926 .expectSpeech('go') 926 .expectSpeech('go')
927 .expectSpeech('Link') 927 .expectSpeech('Link')
928 .expectSpeech('Heading 1') 928 .expectSpeech('Heading 1')
929 .replay(); 929 .replay();
930 }); 930 });
931 }); 931 });
932 932
933 TEST_F('BackgroundTest', 'OptionChildIndexCount', function() { 933 TEST_F('BackgroundTest', 'OptionChildIndexCount', function() {
934 var mockFeedback = this.createMockFeedback(); 934 var mockFeedback = this.createMockFeedback();
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 }); 1193 });
1194 }); 1194 });
1195 1195
1196 TEST_F('BackgroundTest', 'NavigationMovesFocus', function() { 1196 TEST_F('BackgroundTest', 'NavigationMovesFocus', function() {
1197 this.runWithLoadedTree(function(root) {/*! 1197 this.runWithLoadedTree(function(root) {/*!
1198 <p>start</p> 1198 <p>start</p>
1199 <input type="text"></input> 1199 <input type="text"></input>
1200 */}, function(root) { 1200 */}, function(root) {
1201 this.listenOnce(root, 'focus', function(e) { 1201 this.listenOnce(root, 'focus', function(e) {
1202 var focus = ChromeVoxState.instance.currentRange.start.node; 1202 var focus = ChromeVoxState.instance.currentRange.start.node;
1203 assertEquals(RoleType.TEXT_FIELD, focus.role); 1203 assertEquals(RoleType.textField, focus.role);
1204 assertTrue(focus.state.focused); 1204 assertTrue(focus.state.focused);
1205 }); 1205 });
1206 doCmd('nextEditText')(); 1206 doCmd('nextEditText')();
1207 }); 1207 });
1208 }); 1208 });
1209 1209
1210 TEST_F('BackgroundTest', 'BrailleCaretNavigation', function() { 1210 TEST_F('BackgroundTest', 'BrailleCaretNavigation', function() {
1211 var mockFeedback = this.createMockFeedback(); 1211 var mockFeedback = this.createMockFeedback();
1212 this.runWithLoadedTree(function(root) {/*! 1212 this.runWithLoadedTree(function(root) {/*!
1213 <p>This is a<em>test</em> of inline braille<br>with a second line</p> 1213 <p>This is a<em>test</em> of inline braille<br>with a second line</p>
1214 */}, function(root) { 1214 */}, function(root) {
1215 var text = 'This is a'; 1215 var text = 'This is a';
1216 mockFeedback.call(doCmd('nextCharacter')) 1216 mockFeedback.call(doCmd('nextCharacter'))
1217 .expectBraille(text, {startIndex: 1, endIndex: 2}) // h 1217 .expectBraille(text, {startIndex: 1, endIndex: 2}) // h
1218 .call(doCmd('nextCharacter')) 1218 .call(doCmd('nextCharacter'))
1219 .expectBraille(text, {startIndex: 2, endIndex: 3}) // i 1219 .expectBraille(text, {startIndex: 2, endIndex: 3}) // i
1220 .call(doCmd('nextWord')) 1220 .call(doCmd('nextWord'))
1221 .expectBraille(text, {startIndex: 5, endIndex: 7}) // is 1221 .expectBraille(text, {startIndex: 5, endIndex: 7}) // is
1222 .call(doCmd('previousWord')) 1222 .call(doCmd('previousWord'))
1223 .expectBraille(text, {startIndex: 0, endIndex: 4}) // This 1223 .expectBraille(text, {startIndex: 0, endIndex: 4}) // This
1224 .call(doCmd('nextLine')) 1224 .call(doCmd('nextLine'))
1225 // Ensure nothing is selected when the range covers the entire line. 1225 // Ensure nothing is selected when the range covers the entire line.
1226 .expectBraille('with a second line', {startIndex: -1, endIndex: -1}) 1226 .expectBraille('with a second line', {startIndex: -1, endIndex: -1})
1227 .replay(); 1227 .replay();
1228 }); 1228 });
1229 }); 1229 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698