| 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 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 bk.setCurrentRange(cursors.Range.fromNode(fakeWebRoot)); | 566 bk.setCurrentRange(cursors.Range.fromNode(fakeWebRoot)); |
| 567 assertEquals('next_compat', bk.mode); | 567 assertEquals('next_compat', bk.mode); |
| 568 | 568 |
| 569 // And, back to force next. | 569 // And, back to force next. |
| 570 fakeWebRoot.docUrl = 'http://google.com/'; | 570 fakeWebRoot.docUrl = 'http://google.com/'; |
| 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', 'FocusIframe', 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.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() { |
| 599 this.runWithLoadedTree( function() {/*! |
| 600 <div><a href="#">mylink</a></div> |
| 601 <button>after</button> |
| 602 */}, function(root) { |
| 603 var link = root.find({role: RoleType.link}); |
| 604 var button = root.find({role: RoleType.button}); |
| 605 |
| 606 assertEquals('link', link.role); |
| 607 assertEquals('button', button.role); |
| 608 |
| 609 var didFocus = false; |
| 610 link.addEventListener('focus', this.newCallback(function() { |
| 611 // Success |
| 612 })); |
| 613 var b = ChromeVoxState.instance; |
| 614 b.currentRange_ = cursors.Range.fromNode(button); |
| 615 doCmd('previousElement'); |
| 616 }); |
| 617 }); |
| 618 |
| 598 TEST_F('BackgroundTest', 'NoisySlider', function() { | 619 TEST_F('BackgroundTest', 'NoisySlider', function() { |
| 599 var mockFeedback = this.createMockFeedback(); | 620 var mockFeedback = this.createMockFeedback(); |
| 600 this.runWithLoadedTree( function() {/*! | 621 this.runWithLoadedTree( function() {/*! |
| 601 <button id="go">go</button> | 622 <button id="go">go</button> |
| 602 <div id="slider" tabindex=0 role="slider"></div> | 623 <div id="slider" tabindex=0 role="slider"></div> |
| 603 <script> | 624 <script> |
| 604 function update() { | 625 function update() { |
| 605 var s = document.getElementById('slider'); | 626 var s = document.getElementById('slider'); |
| 606 s.setAttribute('aria-valuetext', 'noisy'); | 627 s.setAttribute('aria-valuetext', 'noisy'); |
| 607 setTimeout(update, 500); | 628 setTimeout(update, 500); |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1169 <input type="text"></input> | 1190 <input type="text"></input> |
| 1170 */}, function(root) { | 1191 */}, function(root) { |
| 1171 this.listenOnce(root, 'focus', function(e) { | 1192 this.listenOnce(root, 'focus', function(e) { |
| 1172 var focus = ChromeVoxState.instance.currentRange.start.node; | 1193 var focus = ChromeVoxState.instance.currentRange.start.node; |
| 1173 assertEquals(RoleType.textField, focus.role); | 1194 assertEquals(RoleType.textField, focus.role); |
| 1174 assertTrue(focus.state.focused); | 1195 assertTrue(focus.state.focused); |
| 1175 }); | 1196 }); |
| 1176 doCmd('nextEditText')(); | 1197 doCmd('nextEditText')(); |
| 1177 }); | 1198 }); |
| 1178 }); | 1199 }); |
| OLD | NEW |