Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 /** | 5 /** |
| 6 * Namespace for test related things. | 6 * Namespace for test related things. |
| 7 */ | 7 */ |
| 8 var test = test || {}; | 8 var test = test || {}; |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 attributes[element.attributes[i].nodeName] = | 24 attributes[element.attributes[i].nodeName] = |
| 25 element.attributes[i].nodeValue; | 25 element.attributes[i].nodeValue; |
| 26 } | 26 } |
| 27 var styles = {}; | 27 var styles = {}; |
| 28 var styleNames = opt_styleNames || []; | 28 var styleNames = opt_styleNames || []; |
| 29 var computedStyles = contentWindow.getComputedStyle(element); | 29 var computedStyles = contentWindow.getComputedStyle(element); |
| 30 for (var i = 0; i < styleNames.length; i++) { | 30 for (var i = 0; i < styleNames.length; i++) { |
| 31 styles[styleNames[i]] = computedStyles[styleNames[i]]; | 31 styles[styleNames[i]] = computedStyles[styleNames[i]]; |
| 32 } | 32 } |
| 33 var text = element.textContent; | 33 var text = element.textContent; |
| 34 var size = element.getBoundingClientRect(); | |
| 34 return { | 35 return { |
| 35 attributes: attributes, | 36 attributes: attributes, |
| 36 text: text, | 37 text: text, |
| 37 value: element.value, | 38 value: element.value, |
| 38 styles: styles, | 39 styles: styles, |
| 39 // The hidden attribute is not in the element.attributes even if | 40 // The hidden attribute is not in the element.attributes even if |
| 40 // element.hasAttribute('hidden') is true. | 41 // element.hasAttribute('hidden') is true. |
| 41 hidden: !!element.hidden | 42 hidden: !!element.hidden, |
| 43 width: Number(element.width), | |
|
yawano
2016/01/22 05:03:12
Why don't you simply use renderedWidth? I don't th
ryoh
2016/01/22 05:20:49
It's needed to check both "size":
- "width/height
yawano
2016/01/22 05:52:04
I get it. Thank you!
nit: many of other elements
ryoh
2016/01/22 06:46:03
Done.
yawano
2016/01/22 07:02:49
nit: 0 will be set even if the element doesn't hav
| |
| 44 height: Number(element.height), | |
| 45 renderedWidth: size.width, | |
| 46 renderedHeight: size.height | |
| 42 }; | 47 }; |
| 43 } | 48 } |
| 44 | 49 |
| 45 /** | 50 /** |
| 46 * Namespace for test utility functions. | 51 * Namespace for test utility functions. |
| 47 * | 52 * |
| 48 * Public functions in the test.util.sync and the test.util.async namespaces are | 53 * Public functions in the test.util.sync and the test.util.async namespaces are |
| 49 * published to test cases and can be called by using callRemoteTestUtil. The | 54 * published to test cases and can be called by using callRemoteTestUtil. The |
| 50 * arguments are serialized as JSON internally. If application ID is passed to | 55 * arguments are serialized as JSON internally. If application ID is passed to |
| 51 * callRemoteTestUtil, the content window of the application is added as the | 56 * callRemoteTestUtil, the content window of the application is added as the |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 570 return true; | 575 return true; |
| 571 } else if (test.util.sync[request.func]) { | 576 } else if (test.util.sync[request.func]) { |
| 572 sendResponse(test.util.sync[request.func].apply(null, args)); | 577 sendResponse(test.util.sync[request.func].apply(null, args)); |
| 573 return false; | 578 return false; |
| 574 } else { | 579 } else { |
| 575 console.error('Invalid function name.'); | 580 console.error('Invalid function name.'); |
| 576 return false; | 581 return false; |
| 577 } | 582 } |
| 578 }); | 583 }); |
| 579 }; | 584 }; |
| OLD | NEW |