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 // These attributes are set when element is img or canvas. |
| 44 imageWidth: Number(element.width), |
| 45 imageHeight: Number(element.height), |
| 46 // These attributes are set in any element. |
| 47 renderedWidth: size.width, |
| 48 renderedHeight: size.height |
42 }; | 49 }; |
43 } | 50 } |
44 | 51 |
45 /** | 52 /** |
46 * Namespace for test utility functions. | 53 * Namespace for test utility functions. |
47 * | 54 * |
48 * Public functions in the test.util.sync and the test.util.async namespaces are | 55 * 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 | 56 * 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 | 57 * arguments are serialized as JSON internally. If application ID is passed to |
51 * callRemoteTestUtil, the content window of the application is added as the | 58 * 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; | 577 return true; |
571 } else if (test.util.sync[request.func]) { | 578 } else if (test.util.sync[request.func]) { |
572 sendResponse(test.util.sync[request.func].apply(null, args)); | 579 sendResponse(test.util.sync[request.func].apply(null, args)); |
573 return false; | 580 return false; |
574 } else { | 581 } else { |
575 console.error('Invalid function name.'); | 582 console.error('Invalid function name.'); |
576 return false; | 583 return false; |
577 } | 584 } |
578 }); | 585 }); |
579 }; | 586 }; |
OLD | NEW |