calc-time-values.html (3471B)
1 <!DOCTYPE html> 2 3 <meta charset="UTF-8"> 4 5 <title>CSS Values and Units Test: calc() function with time values</title> 6 7 <!-- 8 9 Original test is: 10 11 https://chromium.googlesource.com/chromium/src/+/c825d655f6aaf73484f9d56e9012793f5b9668cc/third_party/WebKit/LayoutTests/css3/calc/calc-with-time-angle-and-frequency-values.html 12 13 Issue 917718: [css-values] calc-with-time-angle-and-frequency-values 14 test is highly unreliable, transition-delay testing causes side effects 15 https://bugs.chromium.org/p/chromium/issues/detail?id=917718 16 17 --> 18 19 <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/"> 20 <link rel="help" href="https://www.w3.org/TR/css-values-3/#calc-computed-value"> 21 <link rel="help" href="https://www.w3.org/TR/css-values-3/#time"> 22 23 <meta content="This test checks that additions, substractions, multiplications and divisions in calc() function when applied to time units." name="assert"> 24 25 <script src="/resources/testharness.js"></script> 26 27 <script src="/resources/testharnessreport.js"></script> 28 29 <div id="log"></div> 30 31 <div id="target"></div> 32 33 <script> 34 function startTesting() 35 { 36 37 var targetElement = document.getElementById("target"); 38 39 function compareValue(property_name, calcValue, expectedValue, description) 40 { 41 42 test(function() 43 { 44 45 targetElement.style.setProperty(property_name, "inherit"); 46 47 /* 48 Since we are running many consecutive tests on the same 49 element, then it is necessary to 'reset' its property 50 to an initial value before actually re-testing it. 51 */ 52 53 targetElement.style.setProperty(property_name, calcValue); 54 55 var computedCalcValue = getComputedStyle(targetElement)[property_name]; 56 57 targetElement.style.setProperty(property_name, expectedValue); 58 59 var computedExpectedValue = getComputedStyle(targetElement)[property_name]; 60 61 assert_equals(computedCalcValue, computedExpectedValue); 62 63 }, description); 64 65 } 66 67 68 /* Testing time units */ 69 70 /* compareValue(property_name, calcValue, expectedValue, description) */ 71 72 compareValue("transition-delay", "calc(4s + 1s)", "5s", "addition of 2 time units: s plus s"); 73 74 compareValue("transition-delay", "calc(4s + 1ms)", "4.001s", "addition of 2 time units: s plus ms"); 75 76 compareValue("transition-delay", "calc(4ms + 1ms)", "0.005s", "addition of 2 time units: ms plus ms"); 77 78 compareValue("transition-delay", "calc(4s - 1s)", "3s", "substraction of time unit: s minus s"); 79 80 compareValue("transition-delay", "calc(4s - 1ms)", "3.999s", "substraction of time unit: s minus ms"); 81 82 compareValue("transition-delay", "calc(4 * 1s)", "4s", "multiplication of integer with a time unit: int multiplied by s"); 83 84 compareValue("transition-delay", "calc(4 * 1ms)", "0.004s", "multiplication of integer with a time unit: int multiplied by ms"); 85 86 compareValue("transition-delay", "calc(4s / 2)", "2s", "division of time unit with integer: s divided by int"); 87 88 compareValue("transition-delay", "calc(4ms / 2)", "0.002s", "division of time unit with integer: ms divided by int"); 89 90 /* compareValue(property_name, calcValue, expectedValue, description) */ 91 92 93 94 /* Testing conversion of time unit */ 95 96 /* compareValue(property_name, calcValue, expectedValue, description) */ 97 98 compareValue("transition-delay", "calc(4000ms)", "4s", "conversion of time unit: ms into s"); 99 100 } 101 102 startTesting(); 103 104 </script>