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 allTests = [ | 5 var allTests = [ |
6 function testCloseTab() { | 6 function testCloseTab() { |
7 getUrlFromConfig('index.html', function(url) { | 7 getUrlFromConfig('index.html', function(url) { |
8 chrome.tabs.create({'url': url}, function(tab) { | 8 chrome.tabs.create({'url': url}, function(tab) { |
9 chrome.automation.getTree(function(rootNode) { | 9 chrome.automation.getTree(function(rootNode) { |
10 var button = rootNode.find({role: 'button'}); | 10 var button = rootNode.find({role: 'button'}); |
11 assertEq(rootNode, button.root); | 11 assertEq(rootNode, button.root); |
12 | 12 |
13 rootNode.addEventListener(EventType.destroyed, function() { | 13 rootNode.addEventListener('destroyed', function() { |
14 // Poll until the root node doesn't have a role anymore | 14 // Poll until the root node doesn't have a role anymore |
15 // indicating that it really did get cleaned up. | 15 // indicating that it really did get cleaned up. |
16 function checkSuccess() { | 16 function checkSuccess() { |
17 if (rootNode.role === undefined && rootNode.root === null) { | 17 if (rootNode.role === undefined && rootNode.root === null) { |
18 assertEq(null, button.root); | 18 assertEq(null, button.root); |
19 chrome.test.succeed(); | 19 chrome.test.succeed(); |
20 } | 20 } |
21 else | 21 else |
22 window.setTimeout(checkSuccess, 10); | 22 window.setTimeout(checkSuccess, 10); |
23 } | 23 } |
24 checkSuccess(); | 24 checkSuccess(); |
25 }); | 25 }); |
26 chrome.tabs.remove(tab.id); | 26 chrome.tabs.remove(tab.id); |
27 }); | 27 }); |
28 }); | 28 }); |
29 }); | 29 }); |
30 } | 30 } |
31 ] | 31 ] |
32 chrome.test.runTests(allTests); | 32 chrome.test.runTests(allTests); |
OLD | NEW |