Bug 1145246, part 7 - Add more CSS animation tests to check currentTime clamping. r=birtles

This commit is contained in:
Jonathan Watt 2015-03-23 13:23:19 +00:00
parent a985df248c
commit 785f13213f
2 changed files with 44 additions and 1 deletions

View File

@ -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

View File

@ -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');
</script>
</body>
</html>