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 * |
(...skipping 21 matching lines...) Expand all Loading... |
32 * Called once the document is ready. | 32 * Called once the document is ready. |
33 */ | 33 */ |
34 runWithLoadedTree: function(doc, callback) { | 34 runWithLoadedTree: function(doc, callback) { |
35 callback = this.newCallback(callback); | 35 callback = this.newCallback(callback); |
36 chrome.automation.getDesktop(function(r) { | 36 chrome.automation.getDesktop(function(r) { |
37 var listener = function(evt) { | 37 var listener = function(evt) { |
38 if (!evt.target.docUrl || | 38 if (!evt.target.docUrl || |
39 evt.target.docUrl.indexOf('test') == -1) | 39 evt.target.docUrl.indexOf('test') == -1) |
40 return; | 40 return; |
41 | 41 |
42 r.removeEventListener(listener); | 42 r.removeEventListener('loadComplete', listener, true); |
43 callback && callback(evt.target); | 43 callback && callback(evt.target); |
44 callback = null; | 44 callback = null; |
45 }; | 45 }; |
46 r.addEventListener('loadComplete', listener, true); | 46 r.addEventListener('loadComplete', listener, true); |
47 this.runWithTab(doc); | 47 this.runWithTab(doc); |
48 }.bind(this)); | 48 }.bind(this)); |
49 }, | 49 }, |
50 | 50 |
51 listenOnce: function(node, eventType, callback, capture) { | 51 listenOnce: function(node, eventType, callback, capture) { |
52 var innerCallback = this.newCallback(function() { | 52 var innerCallback = this.newCallback(function() { |
53 node.removeEventListener(eventType, innerCallback, capture); | 53 node.removeEventListener(eventType, innerCallback, capture); |
54 callback.apply(this, arguments); | 54 callback.apply(this, arguments); |
55 }); | 55 }); |
56 node.addEventListener(eventType, innerCallback, capture); | 56 node.addEventListener(eventType, innerCallback, capture); |
57 } | 57 } |
58 }; | 58 }; |
OLD | NEW |