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(['chromevox_e2e_test_base.js']); | 6 GEN_INCLUDE(['chromevox_e2e_test_base.js']); |
7 | 7 |
8 /** | 8 /** |
9 * Base test fixture for ChromeVox Next end to end tests. | 9 * Base test fixture for ChromeVox Next end to end tests. |
10 * | 10 * |
11 * These tests are identical to ChromeVoxE2ETests except for performing the | 11 * These tests are identical to ChromeVoxE2ETests except for performing the |
12 * necessary setup to run ChromeVox Next. | 12 * necessary setup to run ChromeVox Next. |
13 * @constructor | 13 * @constructor |
14 * @extends {ChromeVoxE2ETest} | 14 * @extends {ChromeVoxE2ETest} |
15 */ | 15 */ |
16 function ChromeVoxNextE2ETest() { | 16 function ChromeVoxNextE2ETest() { |
17 ChromeVoxE2ETest.call(this); | 17 ChromeVoxE2ETest.call(this); |
18 } | 18 } |
19 | 19 |
20 ChromeVoxNextE2ETest.prototype = { | 20 ChromeVoxNextE2ETest.prototype = { |
21 __proto__: ChromeVoxE2ETest.prototype, | 21 __proto__: ChromeVoxE2ETest.prototype, |
22 | 22 |
23 /** | 23 /** |
24 * Launches a new tab with the given document, and runs callback when a load | 24 * Gets the desktop from the automation API and Launches a new tab with |
25 * complete fires. | 25 * the given document, and runs |callback| when a load complete fires. |
| 26 * Arranges to call |testDone()| after |callback| returns. |
| 27 * NOTE: Callbacks creatd instide |opt_callback| must be wrapped with |
| 28 * |this.newCallback| if passed to asynchonous calls. Otherwise, the test |
| 29 * will be finished prematurely. |
26 * @param {function() : void} doc Snippet wrapped inside of a function. | 30 * @param {function() : void} doc Snippet wrapped inside of a function. |
27 * @param {function()} opt_callback Called once the document is ready. | 31 * @param {function(chrome.automation.AutomationNode)} callback |
| 32 * Called once the document is ready. |
28 */ | 33 */ |
29 runWithLoadedTree: function(doc, callback) { | 34 runWithLoadedTree: function(doc, callback) { |
30 callback = this.newCallback(callback); | 35 callback = this.newCallback(callback); |
31 chrome.automation.getDesktop(function(r) { | 36 chrome.automation.getDesktop(function(r) { |
32 var listener = function(evt) { | 37 var listener = function(evt) { |
33 if (!evt.target.docUrl || | 38 if (!evt.target.docUrl || |
34 evt.target.docUrl.indexOf('test') == -1) | 39 evt.target.docUrl.indexOf('test') == -1) |
35 return; | 40 return; |
36 | 41 |
37 r.removeEventListener(listener); | 42 r.removeEventListener(listener); |
38 callback && callback(evt.target); | 43 callback && callback(evt.target); |
39 callback = null; | 44 callback = null; |
40 }; | 45 }; |
41 r.addEventListener('loadComplete', listener, true); | 46 r.addEventListener('loadComplete', listener, true); |
42 this.runWithTab(doc); | 47 this.runWithTab(doc); |
43 }.bind(this)); | 48 }.bind(this)); |
44 } | 49 } |
45 }; | 50 }; |
OLD | NEW |