layout/reftests/image-rect/dom-api.html

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

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 the DOM interface of -moz-image-rect() works 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 // Tests a common usage
michael@0 27 var test1 = "-moz-image-rect(url(green-16x16-in-blue-32x32.png), 0, 16, 16, 0)";
michael@0 28 var testRef1 = "-moz-image-rect(url(\"green-16x16-in-blue-32x32.png\"), 0, 16, 16, 0)";
michael@0 29 // Tests an irregular but valid usage
michael@0 30 var test2 = "-moz-image-rect( 'green-16x16-in-blue-32x32.png' , 0.0% , 50.5% , 49.5% , 0.0% )";
michael@0 31 var testRef2 = "-moz-image-rect(url(\"green-16x16-in-blue-32x32.png\"), 0%, 50.5%, 49.5%, 0%)";
michael@0 32 // Tests a wrong syntax (negative value)
michael@0 33 var test3 = "-moz-image-rect(url(green-16x16-in-blue-32x32.png), 0%, -50%, 50%, 0%)";
michael@0 34 var testRef3 = "";
michael@0 35 // Checks if I didn't break the default url() notation.
michael@0 36 var test4 = "url( green-16x16-in-blue-32x32.png )";
michael@0 37 var testRef4 = "url(\"green-16x16-in-blue-32x32.png\")";
michael@0 38
michael@0 39 function equalDOMIO(domInput, domOutputRef, targetId) {
michael@0 40 var targetObj = document.getElementById(targetId);
michael@0 41 targetObj.style.backgroundImage = domInput;
michael@0 42 var domOutput = targetObj.style.backgroundImage;
michael@0 43 document.write(domOutput == domOutputRef ? "SUCCESS" : ("FAIL: " + domOutput));
michael@0 44 }
michael@0 45 </script>
michael@0 46 </head>
michael@0 47 <body>
michael@0 48 <div class="wrapper"><div id="test1"></div></div>
michael@0 49 <script>
michael@0 50 equalDOMIO(test1, testRef1, "test1");
michael@0 51 </script>
michael@0 52 <div class="wrapper"><div id="test2"></div></div>
michael@0 53 <script>
michael@0 54 equalDOMIO(test2, testRef2, "test2");
michael@0 55 </script>
michael@0 56 <div class="wrapper"><div id="test3"></div></div>
michael@0 57 <script>
michael@0 58 equalDOMIO(test3, testRef3, "test3");
michael@0 59 </script>
michael@0 60 <div class="wrapper"><div id="test4"></div></div>
michael@0 61 <script>
michael@0 62 equalDOMIO(test4, testRef4, "test4");
michael@0 63 </script>
michael@0 64 </body>
michael@0 65 </html>

mercurial