Index: chrome/test/data/extensions/api_test/automation/tests/tabs/common.js |
diff --git a/chrome/test/data/extensions/api_test/automation/tests/tabs/common.js b/chrome/test/data/extensions/api_test/automation/tests/tabs/common.js |
index d6396cece50596bc1e0a399f465a82ef9aed3545..753899fd4303a9a4023eb391bab161a219d113c4 100644 |
--- a/chrome/test/data/extensions/api_test/automation/tests/tabs/common.js |
+++ b/chrome/test/data/extensions/api_test/automation/tests/tabs/common.js |
@@ -12,20 +12,30 @@ var StateType = chrome.automation.StateType; |
var tree = null; |
+function createTab(url, callback) { |
+ chrome.tabs.create({"url": url}, function(tab) { |
+ callback(tab); |
+ }); |
+} |
+ |
function setUpAndRunTests(allTests) { |
+ getUrlFromConfig(function(url) { |
+ createTab(url, function(unused_tab) { |
+ chrome.automation.getTree(function (returnedTree) { |
+ tree = returnedTree; |
+ tree.addEventListener('loadComplete', function() { |
+ chrome.test.runTests(allTests); |
+ }); |
+ }); |
+ }); |
+ }); |
+} |
+ |
+function getUrlFromConfig(callback) { |
chrome.test.getConfig(function(config) { |
assertTrue('testServer' in config, 'Expected testServer in config'); |
var url = 'http://a.com:PORT/index.html' |
.replace(/PORT/, config.testServer.port); |
- |
- function gotTree(returnedTree) { |
- tree = returnedTree; |
- tree.addEventListener('loadComplete', function() { |
- chrome.test.runTests(allTests); |
- }); |
- } |
- chrome.tabs.create({ 'url': url }, function() { |
- chrome.automation.getTree(gotTree); |
- }); |
+ callback(url) |
}); |
} |