Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 function getAllWebViews() { | |
| 6 function findAllWebViews(node, nodes) { | |
| 7 if (node.role == chrome.automation.RoleType.webView) | |
| 8 nodes.push(node); | |
| 9 | |
| 10 var children = node.children(); | |
| 11 for (var i = 0; i < children.length; i++) { | |
| 12 var child = findAllWebViews(children[i], nodes); | |
| 13 } | |
| 14 } | |
| 15 | |
| 16 var webViews = []; | |
| 17 findAllWebViews(rootNode, webViews); | |
| 18 return webViews; | |
| 19 }; | |
| 20 | |
| 21 var allTests = [ | |
| 22 function testLoadTabs() { | |
| 23 var webViews = getAllWebViews(); | |
| 24 assertEq(2, webViews.length); | |
| 25 | |
| 26 // Test spins up more quickly than the load; listen for the childrenChanged | |
| 27 // event. | |
| 28 webViews[1].addEventListener(chrome.automation.EventType.childrenChanged, | |
| 29 function(evt) { | |
| 30 var subroot = webViews[1].firstChild(); | |
| 31 assertEq(chrome.automation.RoleType.rootWebArea, subroot.role); | |
| 32 assertEq(evt.target, subroot.parent()); | |
|
aboxhall
2014/11/03 19:40:18
Do we not want to test this any more?
David Tseng
2014/11/03 19:55:51
Exported toJSON to get around circular stringifica
David Tseng
2014/11/03 19:55:51
We can't re: JSON.stringify on that parent node re
| |
| 33 | |
| 34 var button = subroot.firstChild().firstChild(); | |
| 35 assertEq(chrome.automation.RoleType.button, button.role); | |
| 36 | |
| 37 var input = subroot.firstChild().lastChild().previousSibling(); | |
| 38 assertEq(chrome.automation.RoleType.textField, input.role); | |
| 39 chrome.test.succeed(); | |
| 40 }, true); | |
| 41 }, | |
| 42 | |
| 43 function testSubevents() { | |
| 44 var button = null; | |
| 45 var webViews = getAllWebViews(); | |
| 46 var subroot = webViews[1].firstChild(); | |
| 47 | |
| 48 rootNode.addEventListener(chrome.automation.EventType.focus, | |
| 49 function(evt) { | |
| 50 assertEq(button, evt.target); | |
| 51 chrome.test.succeed(); | |
| 52 }, | |
| 53 false); | |
| 54 | |
| 55 button = subroot.firstChild().firstChild(); | |
| 56 button.focus(); | |
| 57 } | |
| 58 ]; | |
| 59 | |
| 60 setupAndRunTests(allTests, | |
| 61 '<button>alpha</button><input type="text">hello</input>'); | |
| OLD | NEW |