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(['chrome/browser/resources/chromeos/chromevox/testing/' + | 6 GEN_INCLUDE(['chrome/browser/resources/chromeos/chromevox/testing/' + |
7 'chromevox_e2e_test_base.js']); | 7 'chromevox_e2e_test_base.js']); |
8 | 8 |
9 /** | 9 /** |
10 * Base test fixture for ChromeVox Next end to end tests. | 10 * Base test fixture for ChromeVox Next end to end tests. |
11 * | 11 * |
12 * These tests are identical to ChromeVoxE2ETests except for performing the | 12 * These tests are identical to ChromeVoxE2ETests except for performing the |
13 * necessary setup to run ChromeVox Next. | 13 * necessary setup to run ChromeVox Next. |
14 * @constructor | 14 * @constructor |
15 * @extends {ChromeVoxE2ETest} | 15 * @extends {ChromeVoxE2ETest} |
16 */ | 16 */ |
17 function ChromeVoxNextE2ETest() {} | 17 function ChromeVoxNextE2ETest() { |
| 18 ChromeVoxE2ETest.call(this); |
| 19 } |
18 | 20 |
19 ChromeVoxNextE2ETest.prototype = { | 21 ChromeVoxNextE2ETest.prototype = { |
20 __proto__: ChromeVoxE2ETest.prototype, | 22 __proto__: ChromeVoxE2ETest.prototype, |
21 | 23 |
22 /** | 24 /** |
23 * This method is called without |this| bound to an instance of | |
24 * ChromeVoxNextE2ETest. | |
25 * @override | |
26 */ | |
27 testGenCppIncludes: function() { | |
28 ChromeVoxE2ETest.prototype.testGenCppIncludes.call(this); | |
29 GEN('#include "base/command_line.h"'); | |
30 }, | |
31 | |
32 /** | |
33 * Launches a new tab with the given document, and runs callback when a load | 25 * Launches a new tab with the given document, and runs callback when a load |
34 * complete fires. | 26 * complete fires. |
35 * @param {function() : void} doc Snippet wrapped inside of a function. | 27 * @param {function() : void} doc Snippet wrapped inside of a function. |
36 * @param {function()} opt_callback Called once the document is ready. | 28 * @param {function()} opt_callback Called once the document is ready. |
37 */ | 29 */ |
38 runWithLoadedTree: function(doc, callback) { | 30 runWithLoadedTree: function(doc, callback) { |
| 31 callback = this.newCallback(callback); |
39 chrome.automation.getDesktop(function(r) { | 32 chrome.automation.getDesktop(function(r) { |
40 function callbackInternal(evt) { | 33 var listener = function(evt) { |
41 if (!evt.target.attributes.url || | 34 if (!evt.target.attributes.url || |
42 evt.target.attributes.url.indexOf('test') == -1) | 35 evt.target.attributes.url.indexOf('test') == -1) |
43 return; | 36 return; |
44 | 37 |
45 r.removeEventListener(callbackInternal); | 38 r.removeEventListener(listener); |
46 callback(evt.target); | 39 callback && callback(evt.target); |
47 } | 40 callback = null; |
48 r.addEventListener('loadComplete', callbackInternal, true); | 41 }; |
| 42 r.addEventListener('loadComplete', listener, true); |
49 this.runWithTab(doc); | 43 this.runWithTab(doc); |
50 }.bind(this)); | 44 }.bind(this)); |
51 } | 45 } |
52 }; | 46 }; |
OLD | NEW |