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

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

Issue 667713006: Implement automatic load of composed/embedded automation trees (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Created 6 years, 1 month 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
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 rootNode = null; 13 var rootNode = null;
14 14
15 function findAutomationNode(root, condition) { 15 function findAutomationNode(root, condition) {
16 if (condition(root)) 16 if (condition(root))
17 return root; 17 return root;
18 18
19 var children = root.children(); 19 var children = root.children();
20 for (var i = 0; i < children.length; i++) { 20 for (var i = 0; i < children.length; i++) {
21 var result = findAutomationNode(children[i], condition); 21 var result = findAutomationNode(children[i], condition);
22 if (result) 22 if (result)
23 return result; 23 return result;
24 } 24 }
25 return null; 25 return null;
26 } 26 }
27 27
28 function setupAndRunTests(allTests) { 28 function runWithDocument(docString, callback) {
29 chrome.automation.getDesktop(function(rootNodeArg) { 29 var url = 'data:text/html,<!doctype html>' + docString;
30 rootNode = rootNodeArg; 30 var createParams = {
31 chrome.test.runTests(allTests); 31 active: true,
32 url: url
33 };
34 chrome.tabs.create(createParams, function(tab) {
35 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo) {
36 if (tabId == tab.id && changeInfo.status == 'complete') {
37 callback();
38 }
39 });
32 }); 40 });
33 } 41 }
42
43 function setupAndRunTests(allTests, opt_docString) {
44 function runTestInternal() {
45 chrome.automation.getDesktop(function(rootNodeArg) {
46 rootNode = rootNodeArg;
47 chrome.test.runTests(allTests);
48 });
49 }
50
51 if (opt_docString)
52 runWithDocument(opt_docString, runTestInternal);
53 else
54 runTestInternal();
55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698