From 785f13213fee78b39102c69acf5685c0341c6cd5 Mon Sep 17 00:00:00 2001 From: Jonathan Watt Date: Mon, 23 Mar 2015 13:23:19 +0000 Subject: [PATCH] Bug 1145246, part 7 - Add more CSS animation tests to check currentTime clamping. r=birtles --- dom/animation/AnimationPlayer.cpp | 4 +- .../test_animation-player-currenttime.html | 41 +++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/dom/animation/AnimationPlayer.cpp b/dom/animation/AnimationPlayer.cpp index 01431cd5636..65f2dbf5b57 100644 --- a/dom/animation/AnimationPlayer.cpp +++ b/dom/animation/AnimationPlayer.cpp @@ -588,7 +588,9 @@ AnimationPlayer::UpdateFinishedState(bool aSeekFlag) mFinished = nullptr; } mIsPreviousStateFinished = currentFinishedState; - mPreviousCurrentTime = currentTime; + // We must recalculate the current time to take account of any mHoldTime + // changes the code above made. + mPreviousCurrentTime = GetCurrentTime(); } void diff --git a/dom/animation/test/css-animations/test_animation-player-currenttime.html b/dom/animation/test/css-animations/test_animation-player-currenttime.html index 44d5da7ae58..b5debd158ff 100644 --- a/dom/animation/test/css-animations/test_animation-player-currenttime.html +++ b/dom/animation/test/css-animations/test_animation-player-currenttime.html @@ -611,6 +611,47 @@ async_test(function(t) { }); }, 'Animation.currentTime after pausing'); +async_test(function(t) { + var div = addDiv(t, {'class': 'animated-div'}); + div.style.animation = ANIM_PROPERTY_VAL; + + var animation = div.getAnimations()[0]; + + animation.ready.then(function() { + // just before animation ends: + animation.currentTime = ANIM_DELAY_MS + ANIM_DUR_MS - 1; + + return waitForTwoAnimationFrames(); + }).then(t.step_func(function() { + assert_equals(animation.currentTime, ANIM_DELAY_MS + ANIM_DUR_MS, + 'Animation.currentTime should not continue to increase after the ' + + 'animation has finished'); + t.done(); + })); +}, 'Test Animation.currentTime clamping'); + +async_test(function(t) { + var div = addDiv(t, {'class': 'animated-div'}); + div.style.animation = ANIM_PROPERTY_VAL; + + var animation = div.getAnimations()[0]; + + animation.ready.then(function() { + // play backwards: + animation.playbackRate = -1; + + // just before animation ends (at the "start"): + animation.currentTime = 1; + + return waitForTwoAnimationFrames(); + }).then(t.step_func(function() { + assert_equals(animation.currentTime, 0, + 'Animation.currentTime should not continue to decrease after an ' + + 'animation running in reverse has finished and currentTime is zero'); + t.done(); + })); +}, 'Test Animation.currentTime clamping for reversed animation'); +