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

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

Issue 1899623002: Import latest web-platform-tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: handle new failures Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/playbackRate.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/playbackRate.html b/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/playbackRate.html
new file mode 100644
index 0000000000000000000000000000000000000000..7e3712a56ff491a1eae13edee35f8b141072708e
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/playbackRate.html
@@ -0,0 +1,89 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>Animation.playbackRate</title>
+<link rel="help" href="https://w3c.github.io/web-animations/#dom-animation-playbackrate">
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<script src="../testcommon.js"></script>
+<link rel="stylesheet" href="../../../../resources/testharness.css">
+<body>
+<div id="log"></div>
+<script>
+"use strict";
+
+var keyFrames = { 'marginLeft': ['100px', '200px'] };
+
+function assert_playbackrate(animation,
+ previousAnimationCurrentTime,
+ previousTimelineCurrentTime,
+ description) {
+ var accuracy = 0.001; /* accuracy of DOMHighResTimeStamp */
+ var animationCurrentTimeDifference =
+ animation.currentTime - previousAnimationCurrentTime;
+ var timelineCurrentTimeDifference =
+ animation.timeline.currentTime - previousTimelineCurrentTime;
+
+ assert_approx_equals(animationCurrentTimeDifference,
+ timelineCurrentTimeDifference * animation.playbackRate,
+ accuracy,
+ description);
+}
+
+promise_test(function(t) {
+ var div = createDiv(t);
+ var animation = div.animate({keyFrames}, 100 * MS_PER_SEC);
+ return animation.ready.then(function() {
+ animation.currentTime = 7 * MS_PER_SEC; // ms
+ animation.playbackRate = 0.5;
+
+ assert_equals(animation.currentTime, 7 * MS_PER_SEC,
+ 'Reducing Animation.playbackRate should not change the currentTime ' +
+ 'of a playing animation');
+ animation.playbackRate = 2;
+ assert_equals(animation.currentTime, 7 * MS_PER_SEC,
+ 'Increasing Animation.playbackRate should not change the currentTime ' +
+ 'of a playing animation');
+ });
+}, 'Test the initial effect of setting playbackRate on currentTime');
+
+promise_test(function(t) {
+ var div = createDiv(t);
+ var animation = div.animate({keyFrames}, 100 * MS_PER_SEC);
+ animation.playbackRate = 2;
+ var previousTimelineCurrentTime;
+ var previousAnimationCurrentTime;
+ return animation.ready.then(function() {
+ previousAnimationCurrentTime = animation.currentTime;
+ previousTimelineCurrentTime = animation.timeline.currentTime;
+ return waitForAnimationFrames(1);
+ }).then(function() {
+ assert_playbackrate(animation,
+ previousAnimationCurrentTime,
+ previousTimelineCurrentTime,
+ 'animation.currentTime should be 2 times faster than timeline.');
+ });
+}, 'Test the effect of setting playbackRate on currentTime');
+
+promise_test(function(t) {
+ var div = createDiv(t);
+ var animation = div.animate({keyFrames}, 100 * MS_PER_SEC);
+ animation.playbackRate = 2;
+ var previousTimelineCurrentTime;
+ var previousAnimationCurrentTime;
+ return animation.ready.then(function() {
+ previousAnimationCurrentTime = animation.currentTime;
+ previousTimelineCurrentTime = animation.timeline.currentTime;
+ animation.playbackRate = 1;
+ return waitForAnimationFrames(1);
+ }).then(function() {
+ assert_equals(animation.playbackRate, 1,
+ 'sanity check: animation.playbackRate is still 1.');
+ assert_playbackrate(animation,
+ previousAnimationCurrentTime,
+ previousTimelineCurrentTime,
+ 'animation.currentTime should be the same speed as timeline now.');
+ });
+}, 'Test the effect of setting playbackRate while playing animation');
+
+</script>
+</body>

Powered by Google App Engine
This is Rietveld 408576698