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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 if (tabId == tab.id && changeInfo.status == 'complete') { | 66 if (tabId == tab.id && changeInfo.status == 'complete') { |
67 callback(tabId); | 67 callback(tabId); |
68 } | 68 } |
69 }); | 69 }); |
70 }); | 70 }); |
71 }, | 71 }, |
72 | 72 |
73 /** | 73 /** |
74 * Launches the given document in a new tab. | 74 * Launches the given document in a new tab. |
75 * @param {function() : void} doc Snippet wrapped inside of a function. | 75 * @param {function() : void} doc Snippet wrapped inside of a function. |
76 * @param {function()} opt_callback Called once the document is created. | 76 * @param {function(url: string)} opt_callback Called once the |
| 77 * document is created. |
77 */ | 78 */ |
78 runWithTab: function(doc, opt_callback) { | 79 runWithTab: function(doc, opt_callback) { |
79 var docString = TestUtils.extractHtmlFromCommentEncodedString(doc); | 80 var docString = TestUtils.extractHtmlFromCommentEncodedString(doc); |
80 var url = 'data:text/html,<!doctype html>' + | 81 var url = 'data:text/html,<!doctype html>' + |
81 docString + | 82 docString + |
82 '<!-- chromevox_next_test -->'; | 83 '<!-- chromevox_next_test -->'; |
83 var createParams = { | 84 var createParams = { |
84 active: true, | 85 active: true, |
85 url: url | 86 url: url |
86 }; | 87 }; |
87 chrome.tabs.create(createParams, opt_callback); | 88 chrome.tabs.create(createParams, function(tab) { |
| 89 if (opt_callback) |
| 90 opt_callback(tab.url); |
| 91 }); |
88 }, | 92 }, |
89 | 93 |
90 /** | 94 /** |
91 * Send a key to the page. | 95 * Send a key to the page. |
92 * @param {number} tabId Of the page. | 96 * @param {number} tabId Of the page. |
93 * @param {string} key Name of the key (e.g. Down). | 97 * @param {string} key Name of the key (e.g. Down). |
94 * @param {string} elementQueryString | 98 * @param {string} elementQueryString |
95 */ | 99 */ |
96 sendKeyToElement: function(tabId, key, elementQueryString) { | 100 sendKeyToElement: function(tabId, key, elementQueryString) { |
97 var code = TestUtils.extractHtmlFromCommentEncodedString(function() {/*! | 101 var code = TestUtils.extractHtmlFromCommentEncodedString(function() {/*! |
(...skipping 13 matching lines...) Expand all Loading... |
111 * called. If this method is called one or more times, then | 115 * called. If this method is called one or more times, then |
112 * {@code testDone()} will be called when all callbacks have been called. | 116 * {@code testDone()} will be called when all callbacks have been called. |
113 * @param {Function=} opt_callback Wrapped callback that will have its this | 117 * @param {Function=} opt_callback Wrapped callback that will have its this |
114 * reference bound to the test fixture. | 118 * reference bound to the test fixture. |
115 * @return {Function} | 119 * @return {Function} |
116 */ | 120 */ |
117 newCallback: function(opt_callback) { | 121 newCallback: function(opt_callback) { |
118 return this.callbackHelper_.wrap(opt_callback); | 122 return this.callbackHelper_.wrap(opt_callback); |
119 } | 123 } |
120 }; | 124 }; |
OLD | NEW |