Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: chrome/test/data/extensions/api_test/automation/tests/tabs/common.js

Issue 308003003: Allow requesting Automation tree by tabId (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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;
11 var StateType = chrome.automation.StateType; 11 var StateType = chrome.automation.StateType;
12 12
13 var tree = null; 13 var tree = null;
14 14
15 function createTab(url, callback) {
16 chrome.tabs.create({"url": url}, function(tab) {
17 callback(tab);
18 });
19 }
20
15 function setUpAndRunTests(allTests) { 21 function setUpAndRunTests(allTests) {
22 getUrlFromConfig(function(url) {
23 createTab(url, function(unused_tab) {
24 chrome.automation.getTree(function (returnedTree) {
25 tree = returnedTree;
26 tree.addEventListener('loadComplete', function() {
27 chrome.test.runTests(allTests);
28 });
29 });
30 });
31 });
32 }
33
34 function getUrlFromConfig(callback) {
16 chrome.test.getConfig(function(config) { 35 chrome.test.getConfig(function(config) {
17 assertTrue('testServer' in config, 'Expected testServer in config'); 36 assertTrue('testServer' in config, 'Expected testServer in config');
18 var url = 'http://a.com:PORT/index.html' 37 var url = 'http://a.com:PORT/index.html'
19 .replace(/PORT/, config.testServer.port); 38 .replace(/PORT/, config.testServer.port);
20 39 callback(url)
21 function gotTree(returnedTree) {
22 tree = returnedTree;
23 tree.addEventListener('loadComplete', function() {
24 chrome.test.runTests(allTests);
25 });
26 }
27 chrome.tabs.create({ 'url': url }, function() {
28 chrome.automation.getTree(gotTree);
29 });
30 }); 40 });
31 } 41 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698