Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/keyframe-effect/getComputedTiming.html

Issue 1985313003: Move the web-animations directory from web-platform-tests/ to wpt/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <meta charset=utf-8>
3 <title>KeyframeEffectReadOnly getComputedTiming() tests</title>
4 <link rel="help" href="https://w3c.github.io/web-animations/#dom-animationeffect readonly-getcomputedtiming">
5 <link rel="author" title="Boris Chiou" href="mailto:boris.chiou@gmail.com">
6 <script src="../../../../resources/testharness.js"></script>
7 <script src="../../../../resources/testharnessreport.js"></script>
8 <script src="../testcommon.js"></script>
9 <body>
10 <div id="log"></div>
11 <div id="target"></div>
12 <script>
13 "use strict";
14
15 var target = document.getElementById("target");
16
17 test(function(t) {
18 var effect = new KeyframeEffectReadOnly(target,
19 { left: ["10px", "20px"] });
20
21 var ct = effect.getComputedTiming();
22 assert_equals(ct.delay, 0, "computed delay");
23 assert_equals(ct.fill, "none", "computed fill");
24 assert_equals(ct.iterations, 1.0, "computed iterations");
25 assert_equals(ct.duration, 0, "computed duration");
26 assert_equals(ct.direction, "normal", "computed direction");
27 }, "values of getComputedTiming() when a KeyframeEffectReadOnly is " +
28 "constructed without any KeyframeEffectOptions object");
29
30 var gGetComputedTimingTests = [
31 { desc: "an empty KeyframeEffectOptions object",
32 input: { },
33 expected: { } },
34 { desc: "a normal KeyframeEffectOptions object",
35 input: { delay: 1000,
36 fill: "auto",
37 iterations: 5.5,
38 duration: "auto",
39 direction: "alternate" },
40 expected: { delay: 1000,
41 fill: "none",
42 iterations: 5.5,
43 duration: 0,
44 direction: "alternate" } },
45 { desc: "a double value",
46 input: 3000,
47 timing: { duration: 3000 },
48 expected: { delay: 0,
49 fill: "none",
50 iterations: 1,
51 duration: 3000,
52 direction: "normal" } },
53 { desc: "+Infinity",
54 input: Infinity,
55 expected: { duration: Infinity } },
56 { desc: "an Infinity duration",
57 input: { duration: Infinity },
58 expected: { duration: Infinity } },
59 { desc: "an auto duration",
60 input: { duration: "auto" },
61 expected: { duration: 0 } },
62 { desc: "an Infinity iterations",
63 input: { iterations: Infinity },
64 expected: { iterations: Infinity } },
65 { desc: "an auto fill",
66 input: { fill: "auto" },
67 expected: { fill: "none" } },
68 { desc: "a forwards fill",
69 input: { fill: "forwards" },
70 expected: { fill: "forwards" } }
71 ];
72
73 gGetComputedTimingTests.forEach(function(stest) {
74 test(function(t) {
75 var effect = new KeyframeEffectReadOnly(target,
76 { left: ["10px", "20px"] },
77 stest.input);
78
79 // Helper function to provide default expected values when the test does
80 // not supply them.
81 var expected = function(field, defaultValue) {
82 return field in stest.expected ? stest.expected[field] : defaultValue;
83 };
84
85 var ct = effect.getComputedTiming();
86 assert_equals(ct.delay, expected("delay", 0),
87 "computed delay");
88 assert_equals(ct.fill, expected("fill", "none"),
89 "computed fill");
90 assert_equals(ct.iterations, expected("iterations", 1),
91 "computed iterations");
92 assert_equals(ct.duration, expected("duration", 0),
93 "computed duration");
94 assert_equals(ct.direction, expected("direction", "normal"),
95 "computed direction");
96
97 }, "values of getComputedTiming() when a KeyframeEffectReadOnly is " +
98 "constructed by " + stest.desc);
99 });
100
101 var gActiveDurationTests = [
102 { desc: "an empty KeyframeEffectOptions object",
103 input: { },
104 expected: 0 },
105 { desc: "a non-zero duration and default iteration count",
106 input: { duration: 1000 },
107 expected: 1000 },
108 { desc: "a non-zero duration and integral iteration count",
109 input: { duration: 1000, iterations: 7 },
110 expected: 7000 },
111 { desc: "a non-zero duration and fractional iteration count",
112 input: { duration: 1000, iterations: 2.5 },
113 expected: 2500 },
114 { desc: "an non-zero duration and infinite iteration count",
115 input: { duration: 1000, iterations: Infinity },
116 expected: Infinity },
117 { desc: "an non-zero duration and zero iteration count",
118 input: { duration: 1000, iterations: 0 },
119 expected: 0 },
120 { desc: "a zero duration and default iteration count",
121 input: { duration: 0 },
122 expected: 0 },
123 { desc: "a zero duration and fractional iteration count",
124 input: { duration: 0, iterations: 2.5 },
125 expected: 0 },
126 { desc: "a zero duration and infinite iteration count",
127 input: { duration: 0, iterations: Infinity },
128 expected: 0 },
129 { desc: "a zero duration and zero iteration count",
130 input: { duration: 0, iterations: 0 },
131 expected: 0 },
132 { desc: "an infinite duration and default iteration count",
133 input: { duration: Infinity },
134 expected: Infinity },
135 { desc: "an infinite duration and zero iteration count",
136 input: { duration: Infinity, iterations: 0 },
137 expected: 0 },
138 { desc: "an infinite duration and fractional iteration count",
139 input: { duration: Infinity, iterations: 2.5 },
140 expected: Infinity },
141 { desc: "an infinite duration and infinite iteration count",
142 input: { duration: Infinity, iterations: Infinity },
143 expected: Infinity },
144 { desc: "an infinite duration and zero iteration count",
145 input: { duration: Infinity, iterations: 0 },
146 expected: 0 }
147 ];
148
149 gActiveDurationTests.forEach(function(stest) {
150 test(function(t) {
151 var effect = new KeyframeEffectReadOnly(target,
152 { left: ["10px", "20px"] },
153 stest.input);
154
155 assert_equals(effect.getComputedTiming().activeDuration,
156 stest.expected);
157
158 }, "getComputedTiming().activeDuration for " + stest.desc);
159 });
160
161 var gEndTimeTests = [
162 { desc: "an empty KeyframeEffectOptions object",
163 input: { },
164 expected: 0 },
165 { desc: "a non-zero duration and default iteration count",
166 input: { duration: 1000 },
167 expected: 1000 },
168 { desc: "a non-zero duration and non-default iteration count",
169 input: { duration: 1000, iterations: 2.5 },
170 expected: 2500 },
171 { desc: "a non-zero duration and non-zero delay",
172 input: { duration: 1000, delay: 1500 },
173 expected: 2500 },
174 { desc: "a non-zero duration, non-zero delay and non-default iteration",
175 input: { duration: 1000, delay: 1500, iterations: 2 },
176 expected: 3500 },
177 { desc: "an infinite iteration count",
178 input: { duration: 1000, iterations: Infinity },
179 expected: Infinity },
180 { desc: "an infinite duration",
181 input: { duration: Infinity, iterations: 10 },
182 expected: Infinity },
183 { desc: "an infinite duration and delay",
184 input: { duration: Infinity, iterations: 10, delay: 1000 },
185 expected: Infinity },
186 { desc: "an infinite duration and negative delay",
187 input: { duration: Infinity, iterations: 10, delay: -1000 },
188 expected: Infinity },
189 { desc: "an non-zero duration and negative delay",
190 input: { duration: 1000, iterations: 2, delay: -1000 },
191 expected: 1000 },
192 { desc: "an non-zero duration and negative delay greater than active " +
193 "duration",
194 input: { duration: 1000, iterations: 2, delay: -3000 },
195 expected: -1000 },
196 { desc: "a zero duration and negative delay",
197 input: { duration: 0, iterations: 2, delay: -1000 },
198 expected: -1000 }
199 ];
200
201 gEndTimeTests.forEach(function(stest) {
202 test(function(t) {
203 var effect = new KeyframeEffectReadOnly(target,
204 { left: ["10px", "20px"] },
205 stest.input);
206
207 assert_equals(effect.getComputedTiming().endTime,
208 stest.expected);
209
210 }, "getComputedTiming().endTime for " + stest.desc);
211 });
212
213 done();
214 </script>
215 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698