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 allTests = [ | 5 var allTests = [ |
6 function testLocation() { | 6 function testLocation() { |
7 function assertOkButtonLocation(event) { | 7 function assertOkButtonLocation(event) { |
8 var okButton = rootNode.find({ role: RoleType.BUTTON, | 8 var okButton = rootNode.find({ role: RoleType.button, |
9 attributes: { name: 'Ok' }}); | 9 attributes: { name: 'Ok' }}); |
10 assertTrue('location' in okButton); | 10 assertTrue('location' in okButton); |
11 | 11 |
12 // We can't assert the left and top positions because they're | 12 // We can't assert the left and top positions because they're |
13 // returned in global screen coordinates. Just check the width and | 13 // returned in global screen coordinates. Just check the width and |
14 // height. | 14 // height. |
15 assertEq(300, okButton.location.width); | 15 assertEq(300, okButton.location.width); |
16 assertEq(400, okButton.location.height); | 16 assertEq(400, okButton.location.height); |
17 chrome.test.succeed(); | 17 chrome.test.succeed(); |
18 }; | 18 }; |
19 | 19 |
20 var okButton = rootNode.firstChild.firstChild; | 20 var okButton = rootNode.firstChild.firstChild; |
21 assertTrue('location' in okButton, 'no location in okButton'); | 21 assertTrue('location' in okButton, 'no location in okButton'); |
22 assertTrue('left' in okButton.location, 'no left in location'); | 22 assertTrue('left' in okButton.location, 'no left in location'); |
23 assertTrue('top' in okButton.location, 'no top in location'); | 23 assertTrue('top' in okButton.location, 'no top in location'); |
24 assertTrue('height' in okButton.location, 'no height in location'); | 24 assertTrue('height' in okButton.location, 'no height in location'); |
25 assertTrue('width' in okButton.location, 'no width in location'); | 25 assertTrue('width' in okButton.location, 'no width in location'); |
26 | 26 |
27 rootNode.addEventListener( | 27 rootNode.addEventListener( |
28 EventType.CHILDREN_CHANGED, assertOkButtonLocation); | 28 EventType.childrenChanged, assertOkButtonLocation); |
29 chrome.tabs.executeScript({ 'code': | 29 chrome.tabs.executeScript({ 'code': |
30 'document.querySelector("button")' + | 30 'document.querySelector("button")' + |
31 '.setAttribute("style", "position: absolute; left: 100; top: 200; ' + | 31 '.setAttribute("style", "position: absolute; left: 100; top: 200; ' + |
32 'width: 300; height: 400;");' }); | 32 'width: 300; height: 400;");' }); |
33 } | 33 } |
34 ]; | 34 ]; |
35 | 35 |
36 setUpAndRunTests(allTests); | 36 setUpAndRunTests(allTests); |
OLD | NEW |