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