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