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 var assertEq = chrome.test.assertEq; | 5 var assertEq = chrome.test.assertEq; |
6 var assertFalse = chrome.test.assertFalse; | 6 var assertFalse = chrome.test.assertFalse; |
7 var assertTrue = chrome.test.assertTrue; | 7 var assertTrue = chrome.test.assertTrue; |
8 | 8 |
9 var EventType = chrome.automation.EventType; | 9 var EventType = chrome.automation.EventType; |
10 var RoleType = chrome.automation.RoleType; | 10 var RoleType = chrome.automation.RoleType; |
(...skipping 24 matching lines...) Expand all Loading... |
35 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo) { | 35 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo) { |
36 if (tabId == tab.id && changeInfo.status == 'complete') { | 36 if (tabId == tab.id && changeInfo.status == 'complete') { |
37 callback(); | 37 callback(); |
38 } | 38 } |
39 }); | 39 }); |
40 }); | 40 }); |
41 } | 41 } |
42 | 42 |
43 function setupAndRunTests(allTests, opt_docString) { | 43 function setupAndRunTests(allTests, opt_docString) { |
44 function runTestInternal() { | 44 function runTestInternal() { |
45 chrome.automation.getDesktop(function(rootNodeArg) { | 45 chrome.test.runTests(allTests); |
46 rootNode = rootNodeArg; | |
47 chrome.test.runTests(allTests); | |
48 }); | |
49 } | 46 } |
50 | 47 |
51 if (opt_docString) | 48 chrome.automation.getDesktop(function(rootNodeArg) { |
52 runWithDocument(opt_docString, runTestInternal); | 49 rootNode = rootNodeArg; |
53 else | 50 |
54 runTestInternal(); | 51 // Only run the test when the window containing the new tab loads. |
| 52 rootNodeArg.addEventListener( |
| 53 chrome.automation.EventType.childrenChanged, |
| 54 function(evt) { |
| 55 var subroot = evt.target.firstChild; |
| 56 if (!opt_docString || !subroot) |
| 57 return; |
| 58 |
| 59 if (subroot.role == 'rootWebArea' && |
| 60 subroot.attributes.docUrl.indexOf(opt_docString) != -1) |
| 61 runTestInternal(); |
| 62 }, |
| 63 true); |
| 64 if (opt_docString) |
| 65 runWithDocument(opt_docString, null); |
| 66 else |
| 67 runTestInternal(); |
| 68 }); |
55 } | 69 } |
OLD | NEW |