Fri, 16 Jan 2015 04:50:19 +0100
Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32
michael@0 | 1 | <!DOCTYPE html> |
michael@0 | 2 | <!-- |
michael@0 | 3 | Any copyright is dedicated to the Public Domain. |
michael@0 | 4 | http://creativecommons.org/licenses/publicdomain/ |
michael@0 | 5 | |
michael@0 | 6 | Tests if getComputedStyle() works on -moz-image-rect() and formats the |
michael@0 | 7 | output correctly. |
michael@0 | 8 | --> |
michael@0 | 9 | <html> |
michael@0 | 10 | <head> |
michael@0 | 11 | <title>Testcases: -moz-image-rect() [bug 113577]</title> |
michael@0 | 12 | <style> |
michael@0 | 13 | div.wrapper { |
michael@0 | 14 | width: 32px; |
michael@0 | 15 | height: 32px; |
michael@0 | 16 | margin: 10px; |
michael@0 | 17 | background-color: red; |
michael@0 | 18 | } |
michael@0 | 19 | div.wrapper div { |
michael@0 | 20 | width: 32px; |
michael@0 | 21 | height: 32px; |
michael@0 | 22 | background: no-repeat; |
michael@0 | 23 | } |
michael@0 | 24 | </style> |
michael@0 | 25 | <script> |
michael@0 | 26 | var curdir = location.href.replace(/[^/]+$/, ""); |
michael@0 | 27 | // Tests a common usage |
michael@0 | 28 | var test1 = "-moz-image-rect(url(green-16x16-in-blue-32x32.png), 0, 16, 16, 0)"; |
michael@0 | 29 | var testRef1 = "-moz-image-rect(url(\"" + curdir + "green-16x16-in-blue-32x32.png\"), 0, 16, 16, 0)"; |
michael@0 | 30 | // Tests an irregular but valid usage |
michael@0 | 31 | var test2 = "-moz-image-rect( 'green-16x16-in-blue-32x32.png' , 0.0% , 50.5% , 49.5% , 0.0% )"; |
michael@0 | 32 | var testRef2 = "-moz-image-rect(url(\"" + curdir + "green-16x16-in-blue-32x32.png\"), 0%, 50.5%, 49.5%, 0%)"; |
michael@0 | 33 | // Tests a wrong syntax (negative value) |
michael@0 | 34 | var test3 = "-moz-image-rect(url(green-16x16-in-blue-32x32.png), 0%, -50%, 50%, 0%)"; |
michael@0 | 35 | var testRef3 = "none"; |
michael@0 | 36 | // Checks if I didn't break the default url() notation. |
michael@0 | 37 | var test4 = "url( green-16x16-in-blue-32x32.png )"; |
michael@0 | 38 | var testRef4 = "url(\"" + curdir + "green-16x16-in-blue-32x32.png\")"; |
michael@0 | 39 | |
michael@0 | 40 | function equalComputedDOMIO(domInput, domOutputRef, targetId) { |
michael@0 | 41 | var targetObj = document.getElementById(targetId); |
michael@0 | 42 | targetObj.style.backgroundImage = domInput; |
michael@0 | 43 | var domOutput = getComputedStyle(targetObj, null).getPropertyValue("background-image"); |
michael@0 | 44 | document.write(domOutput == domOutputRef ? "SUCCESS" : ("FAIL: " + domOutput)); |
michael@0 | 45 | } |
michael@0 | 46 | </script> |
michael@0 | 47 | </head> |
michael@0 | 48 | <body> |
michael@0 | 49 | <div class="wrapper"><div id="test1"></div></div> |
michael@0 | 50 | <script> |
michael@0 | 51 | equalComputedDOMIO(test1, testRef1, "test1"); |
michael@0 | 52 | </script> |
michael@0 | 53 | <div class="wrapper"><div id="test2"></div></div> |
michael@0 | 54 | <script> |
michael@0 | 55 | equalComputedDOMIO(test2, testRef2, "test2"); |
michael@0 | 56 | </script> |
michael@0 | 57 | <div class="wrapper"><div id="test3"></div></div> |
michael@0 | 58 | <script> |
michael@0 | 59 | equalComputedDOMIO(test3, testRef3, "test3"); |
michael@0 | 60 | </script> |
michael@0 | 61 | <div class="wrapper"><div id="test4"></div></div> |
michael@0 | 62 | <script> |
michael@0 | 63 | equalComputedDOMIO(test4, testRef4, "test4"); |
michael@0 | 64 | </script> |
michael@0 | 65 | </body> |
michael@0 | 66 | </html> |