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

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

Issue 1040863002: Revert "Enable chrome.automation.getDesktop on all aura platforms." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
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 function getAllWebViews() { 5 function getAllWebViews() {
6 function findAllWebViews(node, nodes) { 6 function findAllWebViews(node, nodes) {
7 if (node.role == chrome.automation.RoleType.webView) 7 if (node.role == chrome.automation.RoleType.webView)
8 nodes.push(node); 8 nodes.push(node);
9 9
10 var children = node.children; 10 var children = node.children;
11 for (var i = 0; i < children.length; i++) { 11 for (var i = 0; i < children.length; i++) {
12 var child = findAllWebViews(children[i], nodes); 12 var child = findAllWebViews(children[i], nodes);
13 } 13 }
14 } 14 }
15 15
16 var webViews = []; 16 var webViews = [];
17 findAllWebViews(rootNode, webViews); 17 findAllWebViews(rootNode, webViews);
18 return webViews; 18 return webViews;
19 }; 19 };
20 20
21 var allTests = [ 21 var allTests = [
22 function testLoadTabs() { 22 function testLoadTabs() {
23 var webViews = getAllWebViews(); 23 var webViews = getAllWebViews();
24 assertEq(2, webViews.length); 24 assertEq(2, webViews.length);
25 var subroot = webViews[1].firstChild; 25
26 assertEq(webViews[1], subroot.parent); 26 // Test spins up more quickly than the load; listen for the childrenChanged
27 assertEq(subroot, subroot.parent.children[0]); 27 // event.
28 var button = subroot.firstChild.firstChild; 28 function childrenChangedListener(evt) {
29 assertEq(chrome.automation.RoleType.button, button.role); 29 var subroot = webViews[1].firstChild;
30 var input = subroot.firstChild.lastChild.previousSibling; 30 assertEq(evt.target, subroot.parent);
31 assertEq(chrome.automation.RoleType.textField, input.role); 31 assertEq(subroot, subroot.parent.children[0]);
32 chrome.test.succeed(); 32
33 var button = subroot.firstChild.firstChild;
34 assertEq(chrome.automation.RoleType.button, button.role);
35
36 var input = subroot.firstChild.lastChild.previousSibling;
37 assertEq(chrome.automation.RoleType.textField, input.role);
38 webViews[1].removeEventListener(
39 chrome.automation.EventType.childrenChanged,
40 childrenChangedListener), true;
41 chrome.test.succeed();
42 }
43 webViews[1].addEventListener(
44 chrome.automation.EventType.childrenChanged,
45 childrenChangedListener,
46 true);
33 }, 47 },
34 48
35 function testSubevents() { 49 function testSubevents() {
36 var button = null; 50 var button = null;
37 var webViews = getAllWebViews(); 51 var webViews = getAllWebViews();
38 var subroot = webViews[1].firstChild; 52 var subroot = webViews[1].firstChild;
39 53
40 rootNode.addEventListener(chrome.automation.EventType.focus, 54 rootNode.addEventListener(chrome.automation.EventType.focus,
41 function(evt) { 55 function(evt) {
42 assertEq(button, evt.target); 56 assertEq(button, evt.target);
43 chrome.test.succeed(); 57 chrome.test.succeed();
44 }, 58 },
45 false); 59 false);
46 60
47 button = subroot.firstChild.firstChild; 61 button = subroot.firstChild.firstChild;
48 button.focus(); 62 button.focus();
49 } 63 }
50 ]; 64 ];
51 65
52 setupAndRunTests(allTests, 66 setupAndRunTests(allTests,
53 '<button>alpha</button><input type="text">hello</input>'); 67 '<button>alpha</button><input type="text">hello</input>');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698