word-spacing-computed-001.html (2299B)
1 <!DOCTYPE html> 2 3 <meta charset="UTF-8"> 4 5 <title>CSS Text Test: computed value of 'word-spacing: normal' and of various <length></title> 6 7 <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/"> 8 <link rel="help" href="https://www.w3.org/TR/css-text-3/#word-spacing-property"> 9 10 <meta content="This test checks that the computed value of 'normal' for the property word-spacing is '0px'. We also check the computed value of various <length>." name="assert"> 11 12 <script src="/resources/testharness.js"></script> 13 14 <script src="/resources/testharnessreport.js"></script> 15 16 <style> 17 div#target 18 { 19 font-size: 20px; 20 } 21 </style> 22 23 <div id="target">A Z</div> 24 25 <div id="log"></div> 26 27 <script> 28 function startTesting() 29 { 30 31 var targetElement = document.getElementById("target"); 32 33 function verifyComputedStyle(property_name, specified_value, expected_value) 34 { 35 36 test(function() 37 { 38 39 targetElement.style.setProperty(property_name, "91px"); 40 41 /* 42 The purpose of setting the property to an arbitrary value 43 is to act as a fallback value in case the specified value 44 fails. Since we are running 12 consecutive tests on the 45 same element, then it is necessary to 'reset' its property 46 to an arbitrary value. 47 */ 48 49 targetElement.style.setProperty(property_name, specified_value); 50 51 assert_equals(getComputedStyle(targetElement)[property_name], expected_value); 52 53 }, `testing ${property_name}: ${specified_value}`); 54 } 55 56 verifyComputedStyle("word-spacing", "normal", "0px"); 57 58 verifyComputedStyle("word-spacing", "0", "0px"); 59 60 verifyComputedStyle("word-spacing", "1.27cm", "48px"); 61 62 verifyComputedStyle("word-spacing", "1em", "20px"); 63 64 verifyComputedStyle("word-spacing", "0.5in", "48px"); 65 66 verifyComputedStyle("word-spacing", "25.4mm", "96px"); 67 68 verifyComputedStyle("word-spacing", "5pc", "80px"); 69 70 verifyComputedStyle("word-spacing", "18pt", "24px"); 71 72 verifyComputedStyle("word-spacing", "7px", "7px"); 73 74 verifyComputedStyle("word-spacing", "101.6Q", "96px"); 75 76 verifyComputedStyle("word-spacing", "3rem", "48px"); 77 78 verifyComputedStyle("word-spacing", "0ch", "0px"); 79 } 80 81 startTesting(); 82 83 </script>