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