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);
25 var subroot = webViews[1].firstChild;
26 assertEq(webViews[1], subroot.parent);
27 assertEq(subroot, subroot.parent.children[0]);
28 var button = subroot.firstChild.firstChild;
29 assertEq(chrome.automation.RoleType.button, button.role);
30 var input = subroot.firstChild.lastChild.previousSibling;
31 assertEq(chrome.automation.RoleType.textField, input.role);
32 chrome.test.succeed();
35 function testSubevents() {
37 var webViews = getAllWebViews();
38 var subroot = webViews[1].firstChild;
40 rootNode.addEventListener(chrome.automation.EventType.focus,
42 assertEq(button, evt.target);
43 chrome.test.succeed();
47 button = subroot.firstChild.firstChild;
52 setupAndRunTests(allTests,
53 '<button>alpha</button><input type="text">hello</input>');