cssom-view-img-attributes-001.html (1841B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>CSS Test: HTMLImageElement x and y attributes</title> 5 <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=""> 8 <link rel="help" href="https://drafts.csswg.org/cssom-view/#excensions-to-the-htmlimageelement-interface"> 9 <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 = [ 33 ["x", false, 10], 34 ["y", false, 10], 35 ["x", true, 0], 36 ["y", true, 0], 37 ]; 38 39 imgAttributes.forEach(function(test_data) { 40 test (function() { assert_equals(testIMGAttributes(test_data[0], test_data[1]), test_data[2])}, 41 "test " + test_data[0] + " with display " + test_data[1]) 42 } 43 ); 44 </script> 45 </body> 46 </html>