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
3 // found in the LICENSE file.
5 function getAllWebViews() {
6 function findAllWebViews(node, nodes) {
7 if (node.role == chrome.automation.RoleType.webView)
10 var children = node.children();
11 for (var i = 0; i < children.length; i++) {
12 var child = findAllWebViews(children[i], nodes);
17 findAllWebViews(rootNode, webViews);
22 function testLoadTabs() {
23 var webViews = getAllWebViews();
24 assertEq(2, webViews.length);
26 // Test spins up more quickly than the load; listen for the childrenChanged
28 webViews[1].addEventListener(chrome.automation.EventType.childrenChanged,
30 var subroot = webViews[1].firstChild();
31 assertEq(evt.target, subroot.parent());
33 var button = subroot.firstChild().firstChild();
34 assertEq(chrome.automation.RoleType.button, button.role);
36 var input = subroot.firstChild().lastChild().previousSibling();
37 assertEq(chrome.automation.RoleType.textField, input.role);
38 chrome.test.succeed();
42 function testSubevents() {
44 var webViews = getAllWebViews();
45 var subroot = webViews[1].firstChild();
47 rootNode.addEventListener(chrome.automation.EventType.focus,
49 assertEq(button, evt.target);
50 chrome.test.succeed();
54 button = subroot.firstChild().firstChild();
59 setupAndRunTests(allTests,
60 '<button>alpha</button><input type="text">hello</input>');