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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/playbackRate.html

Issue 1999243002: Import wpt@5df9b57edb3307a87d5187804b29c8ddd2aa14e1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add expectations files (using run-webkit-tests --new-baseline) Created 4 years, 6 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>Animation.playbackRate</title>
4 <link rel="help" href="https://w3c.github.io/web-animations/#dom-animation-playb ackrate">
5 <script src="../../../../resources/testharness.js"></script>
6 <script src="../../../../resources/testharnessreport.js"></script>
7 <script src="../testcommon.js"></script>
8 <link rel="stylesheet" href="../../../../resources/testharness.css">
9 <body>
10 <div id="log"></div>
11 <script>
12 "use strict";
13
14 function assert_playbackrate(animation,
15 previousAnimationCurrentTime,
16 previousTimelineCurrentTime,
17 description) {
18 var accuracy = 0.001; /* accuracy of DOMHighResTimeStamp */
19 var animationCurrentTimeDifference =
20 animation.currentTime - previousAnimationCurrentTime;
21 var timelineCurrentTimeDifference =
22 animation.timeline.currentTime - previousTimelineCurrentTime;
23
24 assert_approx_equals(animationCurrentTimeDifference,
25 timelineCurrentTimeDifference * animation.playbackRate,
26 accuracy,
27 description);
28 }
29
30 promise_test(function(t) {
31 var div = createDiv(t);
32 var animation = div.animate(null, 100 * MS_PER_SEC);
33 return animation.ready.then(function() {
34 animation.currentTime = 7 * MS_PER_SEC; // ms
35 animation.playbackRate = 0.5;
36
37 assert_equals(animation.currentTime, 7 * MS_PER_SEC,
38 'Reducing Animation.playbackRate should not change the currentTime ' +
39 'of a playing animation');
40 animation.playbackRate = 2;
41 assert_equals(animation.currentTime, 7 * MS_PER_SEC,
42 'Increasing Animation.playbackRate should not change the currentTime ' +
43 'of a playing animation');
44 });
45 }, 'Test the initial effect of setting playbackRate on currentTime');
46
47 promise_test(function(t) {
48 var div = createDiv(t);
49 var animation = div.animate(null, 100 * MS_PER_SEC);
50 animation.playbackRate = 2;
51 var previousTimelineCurrentTime;
52 var previousAnimationCurrentTime;
53 return animation.ready.then(function() {
54 previousAnimationCurrentTime = animation.currentTime;
55 previousTimelineCurrentTime = animation.timeline.currentTime;
56 return waitForAnimationFrames(1);
57 }).then(function() {
58 assert_playbackrate(animation,
59 previousAnimationCurrentTime,
60 previousTimelineCurrentTime,
61 'animation.currentTime should be 2 times faster than timeline.');
62 });
63 }, 'Test the effect of setting playbackRate on currentTime');
64
65 promise_test(function(t) {
66 var div = createDiv(t);
67 var animation = div.animate(null, 100 * MS_PER_SEC);
68 animation.playbackRate = 2;
69 var previousTimelineCurrentTime;
70 var previousAnimationCurrentTime;
71 return animation.ready.then(function() {
72 previousAnimationCurrentTime = animation.currentTime;
73 previousTimelineCurrentTime = animation.timeline.currentTime;
74 animation.playbackRate = 1;
75 return waitForAnimationFrames(1);
76 }).then(function() {
77 assert_equals(animation.playbackRate, 1,
78 'sanity check: animation.playbackRate is still 1.');
79 assert_playbackrate(animation,
80 previousAnimationCurrentTime,
81 previousTimelineCurrentTime,
82 'animation.currentTime should be the same speed as timeline now.');
83 });
84 }, 'Test the effect of setting playbackRate while playing animation');
85
86 </script>
87 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698