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
3 // found in the LICENSE file.
5 // Include test fixture.
6 GEN_INCLUDE(['chromevox_e2e_test_base.js']);
9 * Base test fixture for ChromeVox Next end to end tests.
11 * These tests are identical to ChromeVoxE2ETests except for performing the
12 * necessary setup to run ChromeVox Next.
14 * @extends {ChromeVoxE2ETest}
16 function ChromeVoxNextE2ETest() {
17 ChromeVoxE2ETest
.call(this);
20 ChromeVoxNextE2ETest
.prototype = {
21 __proto__
: ChromeVoxE2ETest
.prototype,
24 * Gets the desktop from the automation API and Launches a new tab with
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.
30 * @param {function() : void} doc Snippet wrapped inside of a function.
31 * @param {function(chrome.automation.AutomationNode)} callback
32 * Called once the document is ready.
34 runWithLoadedTree: function(doc
, callback
) {
35 callback
= this.newCallback(callback
);
36 chrome
.automation
.getDesktop(function(r
) {
37 var listener = function(evt
) {
38 if (!evt
.target
.docUrl
||
39 evt
.target
.docUrl
.indexOf('test') == -1)
42 r
.removeEventListener(listener
);
43 callback
&& callback(evt
.target
);
46 r
.addEventListener('loadComplete', listener
, true);
51 listenOnce: function(node
, eventType
, callback
, capture
) {
52 var innerCallback
= this.newCallback(function() {
53 node
.removeEventListener(eventType
, innerCallback
, capture
);
56 node
.addEventListener(eventType
, innerCallback
, capture
);