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

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

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

Powered by Google App Engine
This is Rietveld 408576698