1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/style/test/test_units_length.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,59 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<head> 1.7 + <title>Test for serialization and equivalence of length units</title> 1.8 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.9 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.10 +</head> 1.11 +<body> 1.12 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a> 1.13 +<p id="display"></p> 1.14 +<div id="content" style="display: none"> 1.15 + 1.16 +</div> 1.17 +<pre id="test"> 1.18 +<script type="application/javascript"> 1.19 + 1.20 +/** Test for serialization and equivalence of length units **/ 1.21 + 1.22 +/** 1.23 + * We test that for each of the following: 1.24 + * + they reserialize to exactly what is given 1.25 + * + if a mapping is provided, they compute to the same result as the mapping 1.26 + */ 1.27 +var tests = { 1.28 + "1in": "72pt", 1.29 + "20mm": "2cm", 1.30 + "2.54cm": "1in", 1.31 + "36pt": "0.5in", 1.32 + "4pc": "48pt", 1.33 + "1em": null, 1.34 + "3ex": null, 1.35 + "57px": null, 1.36 + "5rem": null 1.37 +}; 1.38 + 1.39 +var p = document.getElementById("display"); 1.40 + 1.41 +for (var test in tests) { 1.42 + p.setAttribute("style", "margin-left: " + test); 1.43 + is(p.style.getPropertyValue("margin-left"), test, 1.44 + test + " serializes to exactly itself"); 1.45 + var equiv = tests[test]; 1.46 + if (equiv) { 1.47 + var cm1 = getComputedStyle(p, "").marginLeft; 1.48 + p.style.marginLeft = equiv; 1.49 + var cm2 = getComputedStyle(p, "").marginLeft; 1.50 + is(cm1, cm2, test + " should compute to the same as " + equiv); 1.51 + } 1.52 +} 1.53 + 1.54 +// Bug 393910 1.55 +p.setAttribute("style", "margin-left: 0"); 1.56 +is(p.style.getPropertyValue("margin-left"), "0px", 1.57 + "0 serializes to 0px"); 1.58 + 1.59 +</script> 1.60 +</pre> 1.61 +</body> 1.62 +</html>