| 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 GEN_INCLUDE([ | 5 GEN_INCLUDE([ |
| 6 'common.js', | 6 'common.js', |
| 7 'callback_helper.js']); | 7 'callback_helper.js']); |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Base test fixture for ChromeVox end to end tests. | 10 * Base test fixture for ChromeVox end to end tests. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 active: true, | 82 active: true, |
| 83 url: url | 83 url: url |
| 84 }; | 84 }; |
| 85 chrome.tabs.create(createParams, function(tab) { | 85 chrome.tabs.create(createParams, function(tab) { |
| 86 if (opt_callback) | 86 if (opt_callback) |
| 87 opt_callback(tab.url); | 87 opt_callback(tab.url); |
| 88 }); | 88 }); |
| 89 }, | 89 }, |
| 90 | 90 |
| 91 /** | 91 /** |
| 92 * Send a key to the page. | 92 * Increment the selected index of a select control. |
| 93 * @param {number} tabId Of the page. | 93 * @param {number} tabId Of the page. |
| 94 * @param {string} key Name of the key (e.g. ArrowDown). | |
| 95 * @param {string} elementQueryString | 94 * @param {string} elementQueryString |
| 96 */ | 95 */ |
| 97 sendKeyToElement: function(tabId, key, elementQueryString) { | 96 incrementSelectedIndex: function(tabId, elementQueryString) { |
| 98 var code = TestUtils.extractHtmlFromCommentEncodedString(function() {/*! | 97 var code = TestUtils.extractHtmlFromCommentEncodedString(function() {/*! |
| 99 var target = document.body.querySelector('$1'); | 98 var target = document.body.querySelector('$0'); |
| 100 target.focus(); | 99 target.focus(); |
| 101 var evt = new KeyboardEvent('keydown', {key: '$0'}); | 100 target.selectedIndex++; |
| 102 document.activeElement.dispatchEvent(evt); | 101 */}, [elementQueryString]); |
| 103 */}, [key, elementQueryString]); | |
| 104 | 102 |
| 105 chrome.tabs.executeScript(tabId, {code: code}); | 103 chrome.tabs.executeScript(tabId, {code: code}); |
| 106 }, | 104 }, |
| 107 | 105 |
| 108 /** | 106 /** |
| 109 * Creates a callback that optionally calls {@code opt_callback} when | 107 * Creates a callback that optionally calls {@code opt_callback} when |
| 110 * called. If this method is called one or more times, then | 108 * called. If this method is called one or more times, then |
| 111 * {@code testDone()} will be called when all callbacks have been called. | 109 * {@code testDone()} will be called when all callbacks have been called. |
| 112 * @param {Function=} opt_callback Wrapped callback that will have its this | 110 * @param {Function=} opt_callback Wrapped callback that will have its this |
| 113 * reference bound to the test fixture. | 111 * reference bound to the test fixture. |
| 114 * @return {Function} | 112 * @return {Function} |
| 115 */ | 113 */ |
| 116 newCallback: function(opt_callback) { | 114 newCallback: function(opt_callback) { |
| 117 return this.callbackHelper_.wrap(opt_callback); | 115 return this.callbackHelper_.wrap(opt_callback); |
| 118 } | 116 } |
| 119 }; | 117 }; |
| OLD | NEW |