1 <!DOCTYPE html>
2 <html><head>
3 <meta charset="utf-8">
4 <title>CSS Transitions Test: Parsing transition-duration</title>
5 <meta content="Test checks that transition-duration values are parsed properly" name="assert">
6 <link href="http://www.w3.org/TR/css3-transitions/#transition-duration-property" rel="help" title="2.2. The 'transition-duration' Property">
7 <link href="http://www.w3.org/TR/css3-values/#time" rel="help" title="CSS Values and Units Module Level 3 - 6.2. Times: the ‘<time>’ type and ‘s’, ‘ms’ units">
8 <link href="http://rodneyrehm.de/en/" rel="author" title="Rodney Rehm">
9 <meta content="dom" name="flags">
10
11 <script src="/resources/testharness.js" type="text/javascript"></script>
12 <script src="/resources/testharnessreport.js" type="text/javascript"></script>
13
14 <script src="./support/vendorPrefix.js" type="text/javascript"></script>
15 <script src="./support/helper.js" type="text/javascript"></script>
16
17 <script id="metadata_cache">/*
18 {
19 "parse '10.2s'": {},
20 "parse '1s'": {},
21 "parse '0.1s'": {},
22 "parse '0.01s'": {},
23 "parse '0.001s'": {},
24 "parse '0.009s'": {},
25 "parse '0s'": {},
26 "parse '.0s'": {},
27 "parse '0.0s'": {},
28 "parse '.3s'": {},
29 "parse '-5s'": { "flags": "invalid" },
30 "parse '10200ms'": {},
31 "parse '1000ms'": {},
32 "parse '100ms'": {},
33 "parse '10ms'": {},
34 "parse '9ms'": {},
35 "parse '1ms'": {},
36 "parse '0ms'": {},
37 "parse '-500ms'": { "flags": "invalid" },
38 "parse '1s, 0.1s, 10ms'": {},
39 "parse 'foobar'": { "flags": "invalid" }
40 }
41 */</script>
42 </head>
43 <body>
44 <!-- required by testharnessreport.js -->
45 <div id="log"></div>
46 <!-- elements used for testing -->
47 <div id="container">
48 <div id="transition"></div>
49 </div>
50
51 <script>
52 var transition = document.getElementById('transition');
53 // <time> [, <time>]*
54 var values = {
55 // seconds
56 '10.2s': '10.2s',
57 '1s': '1s',
58 '0.1s': '0.1s',
59 '0.01s': '0.01s',
60 '0.001s': '0.001s',
61 '0.009s': '0.009s',
62 '0s': '0s',
63 '.0s': '0s',
64 '0.0s': '0s',
65 '.3s': '0.3s',
66 '-5s' : '0s',
67 // milliseconds
68 '10200ms': '10.2s',
69 '1000ms': '1s',
70 '100ms': '0.1s',
71 '10ms': '0.01s',
72 '9ms': '0.009s',
73 '1ms': '0.001s',
74 '0ms': '0s',
75 '-500ms' : '0s',
76 // combination
77 '1s, 0.1s, 10ms': '1s, 0.1s, 0.01s',
78 // invalid
79 'foobar': '0s'
80 };
81
82 // these tests are supposed to fail and
83 // possibly make the engine issue a parser warning
84 var invalidTests = {
85 '-5s': true,
86 '-500ms': true,
87 'foobar': true
88 };
89
90 for (var key in values) {
91 if (Object.prototype.hasOwnProperty.call(values, key)) {
92 test(function() {
93 setStyle('#transition', {
94 'transition-duration': key
95 });
96 var result = computedStyle(transition, 'transition-duration');
97 assert_equals(result, values[key], "Expected computed value");
98 }, "parse '" + key + "'",
99 {
100 // mark tests that fail as such
101 flags: invalidTests[key] ? "invalid" : ""
102 });
103 }
104 }
105 </script>
106
107
108 </body></html>