undefined reference to 'JSC::B3::BasicBlock::fallThrough() const
[WebKit-https.git] / LayoutTests / http / wpt / web-animations / interfaces / Animation / playbackRate.html
1 <!DOCTYPE html>
2 <meta charset=utf-8>
3 <title>Animation.playbackRate</title>
4 <link rel="help" href="https://w3c.github.io/web-animations/#dom-animation-playbackrate">
5 <script src="/resources/testharness.js"></script>
6 <script src="/resources/testharnessreport.js"></script>
7 <script src="../../testcommon.js"></script>
8 <body>
9 <div id="log"></div>
10 <script>
11 "use strict";
12
13 function assert_playbackrate(animation,
14                              previousAnimationCurrentTime,
15                              previousTimelineCurrentTime,
16                              description) {
17   var accuracy = 0.001; /* accuracy of DOMHighResTimeStamp */
18   var animationCurrentTimeDifference =
19     animation.currentTime - previousAnimationCurrentTime;
20   var timelineCurrentTimeDifference =
21     animation.timeline.currentTime - previousTimelineCurrentTime;
22
23   assert_approx_equals(animationCurrentTimeDifference,
24                        timelineCurrentTimeDifference * animation.playbackRate,
25                        accuracy,
26                        description);
27 }
28
29 promise_test(function(t) {
30   var div = createDiv(t);
31   var animation = div.animate(null, 100 * MS_PER_SEC);
32   return animation.ready.then(function() {
33     animation.currentTime = 7 * MS_PER_SEC; // ms
34     animation.playbackRate = 0.5;
35
36     assert_equals(animation.currentTime, 7 * MS_PER_SEC,
37       'Reducing Animation.playbackRate should not change the currentTime ' +
38       'of a playing animation');
39     animation.playbackRate = 2;
40     assert_equals(animation.currentTime, 7 * MS_PER_SEC,
41       'Increasing Animation.playbackRate should not change the currentTime ' +
42       'of a playing animation');
43   });
44 }, 'Test the initial effect of setting playbackRate on currentTime');
45
46 promise_test(function(t) {
47   var div = createDiv(t);
48   var animation = div.animate(null, 100 * MS_PER_SEC);
49   animation.playbackRate = 2;
50   var previousTimelineCurrentTime;
51   var previousAnimationCurrentTime;
52   return animation.ready.then(function() {
53     previousAnimationCurrentTime = animation.currentTime;
54     previousTimelineCurrentTime = animation.timeline.currentTime;
55     return waitForAnimationFrames(1);
56   }).then(function() {
57     assert_playbackrate(animation,
58       previousAnimationCurrentTime,
59       previousTimelineCurrentTime,
60       'animation.currentTime should be 2 times faster than timeline.');
61   });
62 }, 'Test the effect of setting playbackRate on currentTime');
63
64 promise_test(function(t) {
65   var div = createDiv(t);
66   var animation = div.animate(null, 100 * MS_PER_SEC);
67   animation.playbackRate = 2;
68   var previousTimelineCurrentTime;
69   var previousAnimationCurrentTime;
70   return animation.ready.then(function() {
71     previousAnimationCurrentTime = animation.currentTime;
72     previousTimelineCurrentTime = animation.timeline.currentTime;
73     animation.playbackRate = 1;
74     return waitForAnimationFrames(1);
75   }).then(function() {
76     assert_equals(animation.playbackRate, 1,
77       'sanity check: animation.playbackRate is still 1.');
78     assert_playbackrate(animation,
79       previousAnimationCurrentTime,
80       previousTimelineCurrentTime,
81       'animation.currentTime should be the same speed as timeline now.');
82   });
83 }, 'Test the effect of setting playbackRate while playing animation');
84
85 </script>
86 </body>