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