undefined reference to 'JSC::B3::BasicBlock::fallThrough() const
[WebKit-https.git] / LayoutTests / imported / w3c / web-platform-tests / web-animations / timing-model / time-transformations / transformed-progress.html
1 <!DOCTYPE html>
2 <meta charset=utf-8>
3 <title>Transformed progress</title>
4 <link rel="help" href="https://drafts.csswg.org/web-animations/#calculating-the-transformed-progress">
5 <script src="/resources/testharness.js"></script>
6 <script src="/resources/testharnessreport.js"></script>
7 <script src="../../testcommon.js"></script>
8 <script src="../../resources/easing-tests.js"></script>
9 <body>
10 <div id="log"></div>
11 <div id="target"></div>
12 <script>
13 'use strict';
14
15 for (const params of gEasingTests) {
16   test(t => {
17     const target = createDiv(t);
18     const anim   = target.animate(null, { duration: 1000,
19                                           fill: 'forwards',
20                                           easing: params.easing });
21
22     for (const sampleTime of [0, 250, 500, 750, 1000]) {
23       anim.currentTime = sampleTime;
24       const portion = sampleTime / anim.effect.getComputedTiming().duration;
25       const expectedProgress = params.easingFunction(portion);
26       assert_approx_equals(anim.effect.getComputedTiming().progress,
27                            expectedProgress,
28                            0.01,
29                            'The progress should be approximately ' +
30                            `${expectedProgress} at ${sampleTime}ms`);
31     }
32   }, `Transformed progress for ${params.desc}`);
33 }
34
35 // Additional tests for various boundary conditions of step timing functions and
36 // frames timing functions.
37
38 const gStepAndFramesTimingFunctionTests = [
39   {
40     description: 'Test bounds point of step-start easing',
41     effect:     {
42                   delay: 1000,
43                   duration: 1000,
44                   fill: 'both',
45                   easing: 'steps(2, start)'
46                 },
47     conditions: [
48                   { currentTime: 0,    progress: 0 },
49                   { currentTime: 999,  progress: 0 },
50                   { currentTime: 1000, progress: 0.5 },
51                   { currentTime: 1499, progress: 0.5 },
52                   { currentTime: 1500, progress: 1 },
53                   { currentTime: 2000, progress: 1 }
54                 ]
55   },
56   {
57     description: 'Test bounds point of step-start easing with reverse direction',
58     effect:     {
59                   delay: 1000,
60                   duration: 1000,
61                   fill: 'both',
62                   direction: 'reverse',
63                   easing: 'steps(2, start)'
64                 },
65     conditions: [
66                   { currentTime: 0,    progress: 1 },
67                   { currentTime: 1001, progress: 1 },
68                   { currentTime: 1500, progress: 1 },
69                   { currentTime: 1501, progress: 0.5 },
70                   { currentTime: 2000, progress: 0 },
71                   { currentTime: 2500, progress: 0 }
72                 ]
73   },
74   {
75     description: 'Test bounds point of step-start easing ' +
76                  'with iterationStart not at a transition point',
77     effect:     {
78                   delay: 1000,
79                   duration: 1000,
80                   fill: 'both',
81                   iterationStart: 0.25,
82                   easing: 'steps(2, start)'
83                 },
84     conditions: [
85                   { currentTime: 0,    progress: 0.5 },
86                   { currentTime: 999,  progress: 0.5 },
87                   { currentTime: 1000, progress: 0.5 },
88                   { currentTime: 1249, progress: 0.5 },
89                   { currentTime: 1250, progress: 1 },
90                   { currentTime: 1749, progress: 1 },
91                   { currentTime: 1750, progress: 0.5 },
92                   { currentTime: 2000, progress: 0.5 },
93                   { currentTime: 2500, progress: 0.5 },
94                 ]
95   },
96   {
97     description: 'Test bounds point of step-start easing ' +
98                  'with iterationStart and delay',
99     effect:     {
100                   delay: 1000,
101                   duration: 1000,
102                   fill: 'both',
103                   iterationStart: 0.5,
104                   easing: 'steps(2, start)'
105                 },
106     conditions: [
107                   { currentTime: 0,    progress: 0.5 },
108                   { currentTime: 999,  progress: 0.5 },
109                   { currentTime: 1000, progress: 1 },
110                   { currentTime: 1499, progress: 1 },
111                   { currentTime: 1500, progress: 0.5 },
112                   { currentTime: 2000, progress: 1 }
113                 ]
114   },
115   {
116     description: 'Test bounds point of step-start easing ' +
117                  'with iterationStart and reverse direction',
118     effect:     {
119                   delay: 1000,
120                   duration: 1000,
121                   fill: 'both',
122                   iterationStart: 0.5,
123                   direction: 'reverse',
124                   easing: 'steps(2, start)'
125                 },
126     conditions: [
127                   { currentTime: 0,    progress: 1 },
128                   { currentTime: 1000, progress: 1 },
129                   { currentTime: 1001, progress: 0.5 },
130                   { currentTime: 1499, progress: 0.5 },
131                   { currentTime: 1500, progress: 1 },
132                   { currentTime: 1999, progress: 1 },
133                   { currentTime: 2000, progress: 0.5 },
134                   { currentTime: 2500, progress: 0.5 }
135                 ]
136   },
137   {
138     description: 'Test bounds point of step(4, start) easing ' +
139                  'with iterationStart 0.75 and delay',
140     effect:     {
141                   duration: 1000,
142                   fill: 'both',
143                   delay: 1000,
144                   iterationStart: 0.75,
145                   easing: 'steps(4, start)'
146                 },
147     conditions: [
148                   { currentTime: 0,    progress: 0.75 },
149                   { currentTime: 999,  progress: 0.75 },
150                   { currentTime: 1000, progress: 1 },
151                   { currentTime: 2000, progress: 1 },
152                   { currentTime: 2500, progress: 1 }
153                 ]
154   },
155   {
156     description: 'Test bounds point of step-start easing ' +
157                  'with alternate direction',
158     effect:     {
159                   duration: 1000,
160                   fill: 'both',
161                   delay: 1000,
162                   iterations: 2,
163                   iterationStart: 1.5,
164                   direction: 'alternate',
165                   easing: 'steps(2, start)'
166                 },
167     conditions: [
168                   { currentTime: 0,    progress: 1 },
169                   { currentTime: 1000, progress: 1 },
170                   { currentTime: 1001, progress: 0.5 },
171                   { currentTime: 2999, progress: 1 },
172                   { currentTime: 3000, progress: 0.5 },
173                   { currentTime: 3500, progress: 0.5 }
174                 ]
175   },
176   {
177     description: 'Test bounds point of step-start easing ' +
178                  'with alternate-reverse direction',
179     effect:     {
180                   duration: 1000,
181                   fill: 'both',
182                   delay: 1000,
183                   iterations: 2,
184                   iterationStart: 0.5,
185                   direction: 'alternate-reverse',
186                   easing: 'steps(2, start)'
187                 },
188     conditions: [
189                   { currentTime: 0,    progress: 1 },
190                   { currentTime: 1000, progress: 1 },
191                   { currentTime: 1001, progress: 0.5 },
192                   { currentTime: 2999, progress: 1 },
193                   { currentTime: 3000, progress: 0.5 },
194                   { currentTime: 3500, progress: 0.5 }
195                 ]
196   },
197   {
198     description: 'Test bounds point of step-end easing',
199     effect:     {
200                   delay: 1000,
201                   duration: 1000,
202                   fill: 'both',
203                   easing: 'steps(2, end)'
204                 },
205     conditions: [
206                   { currentTime: 0,    progress: 0 },
207                   { currentTime: 999,  progress: 0 },
208                   { currentTime: 1000, progress: 0 },
209                   { currentTime: 1499, progress: 0 },
210                   { currentTime: 1500, progress: 0.5 },
211                   { currentTime: 2000, progress: 1 }
212                 ]
213   },
214   {
215     description: 'Test bounds point of step-end easing ' +
216                  'with iterationStart and delay',
217     effect:     {
218                   duration: 1000,
219                   fill: 'both',
220                   delay: 1000,
221                   iterationStart: 0.5,
222                   easing: 'steps(2, end)'
223                 },
224     conditions: [
225                   { currentTime: 0,    progress: 0 },
226                   { currentTime: 999,  progress: 0 },
227                   { currentTime: 1000, progress: 0.5 },
228                   { currentTime: 1499, progress: 0.5 },
229                   { currentTime: 1500, progress: 0 },
230                   { currentTime: 1999, progress: 0 },
231                   { currentTime: 2000, progress: 0.5 },
232                   { currentTime: 2500, progress: 0.5 }
233                 ]
234   },
235   {
236     description: 'Test bounds point of step-end easing ' +
237                  'with iterationStart not at a transition point',
238     effect:     {
239                   delay: 1000,
240                   duration: 1000,
241                   fill: 'both',
242                   iterationStart: 0.75,
243                   easing: 'steps(2, end)'
244                 },
245     conditions: [
246                   { currentTime: 0,    progress: 0.5 },
247                   { currentTime: 999,  progress: 0.5 },
248                   { currentTime: 1000, progress: 0.5 },
249                   { currentTime: 1249, progress: 0.5 },
250                   { currentTime: 1250, progress: 0 },
251                   { currentTime: 1749, progress: 0 },
252                   { currentTime: 1750, progress: 0.5 },
253                   { currentTime: 2000, progress: 0.5 },
254                   { currentTime: 2500, progress: 0.5 },
255                 ]
256   },
257   {
258     description: 'Test bounds point of frames easing',
259     effect:     {
260                   delay: 1000,
261                   duration: 1000,
262                   fill: 'both',
263                   easing: 'frames(2)'
264                 },
265     conditions: [
266                   { currentTime: 0,    progress: 0 },
267                   { currentTime: 1000, progress: 0 },
268                   { currentTime: 1499, progress: 0 },
269                   { currentTime: 1500, progress: 1 },
270                   { currentTime: 2000, progress: 1 }
271                 ]
272   },
273   {
274     description: 'Test bounds point of frames easing ' +
275                  'with iterationStart and delay',
276     effect:     {
277                   delay: 1000,
278                   duration: 1000,
279                   fill: 'both',
280                   iterationStart: 0.5,
281                   easing: 'frames(2)'
282                 },
283     conditions: [
284                   { currentTime: 0,    progress: 1 },
285                   { currentTime: 1000, progress: 1 },
286                   { currentTime: 1499, progress: 1 },
287                   { currentTime: 1500, progress: 0 },
288                   { currentTime: 1999, progress: 0 },
289                   { currentTime: 2000, progress: 1 }
290                 ]
291   }
292 ];
293
294 for (const options of gStepAndFramesTimingFunctionTests) {
295   test(t => {
296     const target = createDiv(t);
297     const animation = target.animate(null, options.effect);
298     for (const condition of options.conditions) {
299       animation.currentTime = condition.currentTime;
300       assert_equals(animation.effect.getComputedTiming().progress,
301                     condition.progress,
302                     `Progress at ${animation.currentTime}ms`);
303     }
304   }, options.description);
305 }
306
307 </script>
308 </body>