Chromium Code Reviews| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 * NOTE: Callbacks creatd instide |opt_callback| must be wrapped with | 42 * NOTE: Callbacks creatd instide |opt_callback| must be wrapped with |
| 43 * |this.newCallback| if passed to asynchonous calls. Otherwise, the test | 43 * |this.newCallback| if passed to asynchonous calls. Otherwise, the test |
| 44 * will be finished prematurely. | 44 * will be finished prematurely. |
| 45 * @param {function() : void} doc Snippet wrapped inside of a function. | 45 * @param {function() : void} doc Snippet wrapped inside of a function. |
| 46 * @param {function(chrome.automation.AutomationNode)} callback | 46 * @param {function(chrome.automation.AutomationNode)} callback |
| 47 * Called once the document is ready. | 47 * Called once the document is ready. |
| 48 */ | 48 */ |
| 49 runWithLoadedTree: function(doc, callback) { | 49 runWithLoadedTree: function(doc, callback) { |
| 50 callback = this.newCallback(callback); | 50 callback = this.newCallback(callback); |
| 51 chrome.automation.getDesktop(function(r) { | 51 chrome.automation.getDesktop(function(r) { |
| 52 this.runWithTab(doc, function(newTabUrl) { | 52 var listener = function(evt) { |
| 53 var listener = function(evt) { | 53 if (evt.target.url.indexOf('data') != 0) |
| 54 if (!evt.target.docUrl || evt.target.docUrl != newTabUrl) | 54 return; |
|
dmazzoni
2016/05/25 15:18:00
I think making this change could break tests with
David Tseng
2016/05/25 16:08:23
I'm a little surprised this worked before because
dmazzoni
2016/05/25 16:10:35
That's true, it'd probably be better to register t
David Tseng
2016/05/25 17:27:28
Added the ability to wait for a specific url and a
David Tseng
2016/05/26 20:50:19
FYI; I filed
crbug.com/615192>
| |
| 55 return; | |
| 56 | 55 |
| 57 r.removeEventListener('loadComplete', listener, true); | 56 r.removeEventListener('loadComplete', listener, true); |
| 58 global.backgroundObj.onGotCommand('nextObject'); | 57 global.backgroundObj.onGotCommand('nextObject'); |
| 59 callback && callback(evt.target); | 58 callback && callback(evt.target); |
| 60 callback = null; | 59 callback = null; |
| 61 }; | 60 }; |
| 62 r.addEventListener('loadComplete', listener, true); | 61 r.addEventListener('loadComplete', listener, true); |
| 63 }.bind(this)); | 62 this.runWithTab(doc); |
| 64 }.bind(this)); | 63 }.bind(this)); |
| 65 }, | 64 }, |
| 66 | 65 |
| 67 listenOnce: function(node, eventType, callback, capture) { | 66 listenOnce: function(node, eventType, callback, capture) { |
| 68 var innerCallback = this.newCallback(function() { | 67 var innerCallback = this.newCallback(function() { |
| 69 node.removeEventListener(eventType, innerCallback, capture); | 68 node.removeEventListener(eventType, innerCallback, capture); |
| 70 callback.apply(this, arguments); | 69 callback.apply(this, arguments); |
| 71 }); | 70 }); |
| 72 node.addEventListener(eventType, innerCallback, capture); | 71 node.addEventListener(eventType, innerCallback, capture); |
| 73 } | 72 } |
| 74 }; | 73 }; |
| OLD | NEW |