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