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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 active: true, | 85 active: true, |
86 url: url | 86 url: url |
87 }; | 87 }; |
88 chrome.tabs.create(createParams, function(tab) { | 88 chrome.tabs.create(createParams, function(tab) { |
89 if (opt_callback) | 89 if (opt_callback) |
90 opt_callback(tab.url); | 90 opt_callback(tab.url); |
91 }); | 91 }); |
92 }, | 92 }, |
93 | 93 |
94 /** | 94 /** |
95 * Send a key to the page. | |
96 * @param {number} tabId Of the page. | |
97 * @param {string} key Name of the key (e.g. Down). | |
98 * @param {string} elementQueryString | |
99 */ | |
100 sendKeyToElement: function(tabId, key, elementQueryString) { | |
101 var code = TestUtils.extractHtmlFromCommentEncodedString(function() {/*! | |
102 var target = document.body.querySelector('$1'); | |
103 target.focus(); | |
104 var evt = document.createEvent('KeyboardEvent'); | |
105 evt.initKeyboardEvent('keydown', true, true, window, '$0', 0, false, | |
106 false, false, false); | |
107 document.activeElement.dispatchEvent(evt); | |
108 */}, [key, elementQueryString]); | |
109 | |
110 chrome.tabs.executeScript(tabId, {code: code}); | |
111 }, | |
112 | |
113 /** | |
114 * Creates a callback that optionally calls {@code opt_callback} when | 95 * Creates a callback that optionally calls {@code opt_callback} when |
115 * called. If this method is called one or more times, then | 96 * called. If this method is called one or more times, then |
116 * {@code testDone()} will be called when all callbacks have been called. | 97 * {@code testDone()} will be called when all callbacks have been called. |
117 * @param {Function=} opt_callback Wrapped callback that will have its this | 98 * @param {Function=} opt_callback Wrapped callback that will have its this |
118 * reference bound to the test fixture. | 99 * reference bound to the test fixture. |
119 * @return {Function} | 100 * @return {Function} |
120 */ | 101 */ |
121 newCallback: function(opt_callback) { | 102 newCallback: function(opt_callback) { |
122 return this.callbackHelper_.wrap(opt_callback); | 103 return this.callbackHelper_.wrap(opt_callback); |
123 } | 104 } |
124 }; | 105 }; |
OLD | NEW |