| OLD | NEW |
| 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 html = '<button>alpha</button><input type="text">hello</input>'; | 5 var html = '<button>alpha</button><input type="text">hello</input>'; |
| 6 | 6 |
| 7 function getAllWebViews() { | 7 function getAllWebViews() { |
| 8 function findAllWebViews(node, nodes) { | 8 function findAllWebViews(node, nodes) { |
| 9 if (node.role == chrome.automation.RoleType.WEB_VIEW) | 9 if (node.role == chrome.automation.RoleType.webView) |
| 10 nodes.push(node); | 10 nodes.push(node); |
| 11 | 11 |
| 12 var children = node.children; | 12 var children = node.children; |
| 13 for (var i = 0; i < children.length; i++) { | 13 for (var i = 0; i < children.length; i++) { |
| 14 var child = findAllWebViews(children[i], nodes); | 14 var child = findAllWebViews(children[i], nodes); |
| 15 } | 15 } |
| 16 } | 16 } |
| 17 | 17 |
| 18 var webViews = []; | 18 var webViews = []; |
| 19 findAllWebViews(rootNode, webViews); | 19 findAllWebViews(rootNode, webViews); |
| 20 return webViews; | 20 return webViews; |
| 21 } | 21 } |
| 22 | 22 |
| 23 var allTests = [ | 23 var allTests = [ |
| 24 function testLoadTabs() { | 24 function testLoadTabs() { |
| 25 runWithDocument(html, function() { | 25 runWithDocument(html, function() { |
| 26 var webViews = getAllWebViews(); | 26 var webViews = getAllWebViews(); |
| 27 assertEq(2, webViews.length); | 27 assertEq(2, webViews.length); |
| 28 var subroot = webViews[1].firstChild; | 28 var subroot = webViews[1].firstChild; |
| 29 assertEq(webViews[1], subroot.parent); | 29 assertEq(webViews[1], subroot.parent); |
| 30 assertEq(subroot, subroot.parent.children[0]); | 30 assertEq(subroot, subroot.parent.children[0]); |
| 31 var button = subroot.firstChild.firstChild; | 31 var button = subroot.firstChild.firstChild; |
| 32 assertEq(chrome.automation.RoleType.BUTTON, button.role); | 32 assertEq(chrome.automation.RoleType.button, button.role); |
| 33 var input = subroot.firstChild.lastChild.previousSibling; | 33 var input = subroot.firstChild.lastChild.previousSibling; |
| 34 assertEq(chrome.automation.RoleType.TEXT_FIELD, input.role); | 34 assertEq(chrome.automation.RoleType.textField, input.role); |
| 35 chrome.test.succeed(); | 35 chrome.test.succeed(); |
| 36 }); | 36 }); |
| 37 }, | 37 }, |
| 38 | 38 |
| 39 function testSubevents() { | 39 function testSubevents() { |
| 40 runWithDocument(html, function(subroot) { | 40 runWithDocument(html, function(subroot) { |
| 41 var button = null; | 41 var button = null; |
| 42 | 42 |
| 43 rootNode.addEventListener(chrome.automation.EventType.FOCUS, | 43 rootNode.addEventListener(chrome.automation.EventType.focus, |
| 44 function(evt) { | 44 function(evt) { |
| 45 assertEq(button, evt.target); | 45 assertEq(button, evt.target); |
| 46 chrome.test.succeed(); | 46 chrome.test.succeed(); |
| 47 }, | 47 }, |
| 48 false); | 48 false); |
| 49 | 49 |
| 50 button = subroot.firstChild.firstChild; | 50 button = subroot.firstChild.firstChild; |
| 51 button.focus(); | 51 button.focus(); |
| 52 }); | 52 }); |
| 53 } | 53 } |
| 54 ]; | 54 ]; |
| 55 | 55 |
| 56 setUpAndRunTests(allTests); | 56 setUpAndRunTests(allTests); |
| OLD | NEW |