layout/style/test/test_units_length.html

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <head>
     4   <title>Test for serialization and equivalence of length units</title>
     5   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     6   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     7 </head>
     8 <body>
     9 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
    10 <p id="display"></p>
    11 <div id="content" style="display: none">
    13 </div>
    14 <pre id="test">
    15 <script type="application/javascript">
    17 /** Test for serialization and equivalence of length units **/
    19 /**
    20  * We test that for each of the following:
    21  *  + they reserialize to exactly what is given
    22  *  + if a mapping is provided, they compute to the same result as the mapping
    23  */
    24 var tests = {
    25   "1in": "72pt",
    26   "20mm": "2cm",
    27   "2.54cm": "1in",
    28   "36pt": "0.5in",
    29   "4pc": "48pt",
    30   "1em": null,
    31   "3ex": null,
    32   "57px": null,
    33   "5rem": null
    34 };
    36 var p = document.getElementById("display");
    38 for (var test in tests) {
    39   p.setAttribute("style", "margin-left: " + test);
    40   is(p.style.getPropertyValue("margin-left"), test,
    41      test + " serializes to exactly itself");
    42   var equiv = tests[test];
    43   if (equiv) {
    44     var cm1 = getComputedStyle(p, "").marginLeft;
    45     p.style.marginLeft = equiv;
    46     var cm2 = getComputedStyle(p, "").marginLeft;
    47     is(cm1, cm2, test + " should compute to the same as " + equiv);
    48   }
    49 }
    51 // Bug 393910
    52 p.setAttribute("style", "margin-left: 0");
    53 is(p.style.getPropertyValue("margin-left"), "0px",
    54   "0 serializes to 0px");
    56 </script>
    57 </pre>
    58 </body>
    59 </html>

mercurial