blob: 2f42288104150cf8417bb5b12b07e88c4d20ef4b [file] [log] [blame]
Alan Stearnsdcee9102014-03-16 19:35:141<!DOCTYPE html>
2<html>
3 <head>
Alan Stearnsaffe81d2014-03-18 21:11:054 <title>CSS Test: HTMLImageElement x and y attributes</title>
Alan Stearnsdcee9102014-03-16 19:35:145 <link rel="author" title="Adobe" href="http://html.adobe.com/">
6 <link rel="author" title="Alan Stearns" href="mailto:stearns@adobe.com">
7 <link rel="reviewer" title="" href="">
Peter Linssa6e041e2015-08-20 02:38:018 <link rel="help" href="https://drafts.csswg.org/cssom-view/#excensions-to-the-htmlimageelement-interface">
Alan Stearnsdcee9102014-03-16 19:35:149 <meta name="assert" content="HTMLImageElement attributes give x and y position of CSS layout box">
10 <meta name="flags" content="dom">
11 <script src="/resources/testharness.js"></script>
12 <script src="/resources/testharnessreport.js"></script>
13 </head>
14 <body>
15 <div id="log"></div>
16 <script type="text/javascript">
17
18 function testIMGAttributes(attribute_name, display_none) {
19 var element = document.createElement("img");
20 document.body.appendChild(element);
21 element.style.setProperty("position", "absolute");
22 element.style.setProperty("left", "10px");
23 element.style.setProperty("top", "10px");
24 if (display_none) {
25 element.style.setProperty("display", "none");
26 }
27 var attributeValue = element[attribute_name];
28 document.body.removeChild(element);
29 return attributeValue;
30 }
31
32 var imgAttributes = [
Geoffrey Sneddon55a44122015-12-07 15:39:5133 ["x", false, 10],
Alan Stearnsdcee9102014-03-16 19:35:1434 ["y", false, 10],
Geoffrey Sneddon55a44122015-12-07 15:39:5135 ["x", true, 0],
Alan Stearnsdcee9102014-03-16 19:35:1436 ["y", true, 0],
37 ];
38
39 imgAttributes.forEach(function(test_data) {
Geoffrey Sneddon55a44122015-12-07 15:39:5140 test (function() { assert_equals(testIMGAttributes(test_data[0], test_data[1]), test_data[2])},
41 "test " + test_data[0] + " with display " + test_data[1])
Alan Stearnsdcee9102014-03-16 19:35:1442 }
43 );
44 </script>
45 </body>
46</html>