1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/reftests/image-rect/dom-api-computed-style.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,66 @@ 1.4 +<!DOCTYPE html> 1.5 +<!-- 1.6 + Any copyright is dedicated to the Public Domain. 1.7 + http://creativecommons.org/licenses/publicdomain/ 1.8 + 1.9 + Tests if getComputedStyle() works on -moz-image-rect() and formats the 1.10 + output correctly. 1.11 +--> 1.12 +<html> 1.13 + <head> 1.14 + <title>Testcases: -moz-image-rect() [bug 113577]</title> 1.15 + <style> 1.16 + div.wrapper { 1.17 + width: 32px; 1.18 + height: 32px; 1.19 + margin: 10px; 1.20 + background-color: red; 1.21 + } 1.22 + div.wrapper div { 1.23 + width: 32px; 1.24 + height: 32px; 1.25 + background: no-repeat; 1.26 + } 1.27 + </style> 1.28 + <script> 1.29 + var curdir = location.href.replace(/[^/]+$/, ""); 1.30 + // Tests a common usage 1.31 + var test1 = "-moz-image-rect(url(green-16x16-in-blue-32x32.png), 0, 16, 16, 0)"; 1.32 + var testRef1 = "-moz-image-rect(url(\"" + curdir + "green-16x16-in-blue-32x32.png\"), 0, 16, 16, 0)"; 1.33 + // Tests an irregular but valid usage 1.34 + var test2 = "-moz-image-rect( 'green-16x16-in-blue-32x32.png' , 0.0% , 50.5% , 49.5% , 0.0% )"; 1.35 + var testRef2 = "-moz-image-rect(url(\"" + curdir + "green-16x16-in-blue-32x32.png\"), 0%, 50.5%, 49.5%, 0%)"; 1.36 + // Tests a wrong syntax (negative value) 1.37 + var test3 = "-moz-image-rect(url(green-16x16-in-blue-32x32.png), 0%, -50%, 50%, 0%)"; 1.38 + var testRef3 = "none"; 1.39 + // Checks if I didn't break the default url() notation. 1.40 + var test4 = "url( green-16x16-in-blue-32x32.png )"; 1.41 + var testRef4 = "url(\"" + curdir + "green-16x16-in-blue-32x32.png\")"; 1.42 + 1.43 + function equalComputedDOMIO(domInput, domOutputRef, targetId) { 1.44 + var targetObj = document.getElementById(targetId); 1.45 + targetObj.style.backgroundImage = domInput; 1.46 + var domOutput = getComputedStyle(targetObj, null).getPropertyValue("background-image"); 1.47 + document.write(domOutput == domOutputRef ? "SUCCESS" : ("FAIL: " + domOutput)); 1.48 + } 1.49 + </script> 1.50 + </head> 1.51 + <body> 1.52 + <div class="wrapper"><div id="test1"></div></div> 1.53 + <script> 1.54 + equalComputedDOMIO(test1, testRef1, "test1"); 1.55 + </script> 1.56 + <div class="wrapper"><div id="test2"></div></div> 1.57 + <script> 1.58 + equalComputedDOMIO(test2, testRef2, "test2"); 1.59 + </script> 1.60 + <div class="wrapper"><div id="test3"></div></div> 1.61 + <script> 1.62 + equalComputedDOMIO(test3, testRef3, "test3"); 1.63 + </script> 1.64 + <div class="wrapper"><div id="test4"></div></div> 1.65 + <script> 1.66 + equalComputedDOMIO(test4, testRef4, "test4"); 1.67 + </script> 1.68 + </body> 1.69 +</html>