mirror of
https://github.com/classilla/tenfourfox.git
synced 2025-01-08 07:31:32 +00:00
106 lines
3.2 KiB
HTML
106 lines
3.2 KiB
HTML
<!doctype html>
|
|
<meta charset=utf-8>
|
|
<script src="../testcommon.js"></script>
|
|
<style>
|
|
div {
|
|
/* Make it easier to calculate expected values: */
|
|
animation-timing-function: linear ! important;
|
|
}
|
|
|
|
@keyframes anim {
|
|
from { margin-left: 100px; }
|
|
to { margin-left: 200px; }
|
|
}
|
|
</style>
|
|
<body>
|
|
<script>
|
|
'use strict';
|
|
|
|
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);
|
|
}
|
|
|
|
async_test(function(t) {
|
|
var div = addDiv(test, {'style': 'animation: anim 10s'});
|
|
var animation = div.getAnimations()[0];
|
|
|
|
animation.ready.then(t.step_func_done(function() {
|
|
animation.currentTime = 7000; // ms
|
|
animation.playbackRate = 0.5;
|
|
|
|
assert_equals(animation.currentTime, 7000,
|
|
'Reducing Animation.playbackRate should not change the currentTime ' +
|
|
'of a playing animation');
|
|
|
|
animation.playbackRate = 2;
|
|
|
|
assert_equals(animation.currentTime, 7000,
|
|
'Increasing Animation.playbackRate should not change the currentTime ' +
|
|
'of a playing animation');
|
|
}));
|
|
}, 'Test the initial effect of setting playbackRate on currentTime');
|
|
|
|
async_test(function(t) {
|
|
var div = addDiv(test, {'style': 'animation: anim 100s'});
|
|
var animation = div.getAnimations()[0];
|
|
|
|
animation.playbackRate = 2;
|
|
|
|
var previousTimelineCurrentTime;
|
|
var previousAnimationCurrentTime;
|
|
|
|
animation.ready.then(function() {
|
|
previousAnimationCurrentTime = animation.currentTime;
|
|
previousTimelineCurrentTime = animation.timeline.currentTime;
|
|
return waitForFrame();
|
|
}).then(t.step_func_done(function() {
|
|
assert_playbackrate(animation,
|
|
previousAnimationCurrentTime,
|
|
previousTimelineCurrentTime,
|
|
'animation.currentTime should be 10 times faster than timeline.');
|
|
}));
|
|
}, 'Test the effect of setting playbackRate on currentTime');
|
|
|
|
async_test(function(t) {
|
|
var div = addDiv(test, {'style': 'animation: anim 100s'});
|
|
var animation = div.getAnimations()[0];
|
|
|
|
animation.playbackRate = 2;
|
|
|
|
var previousTimelineCurrentTime;
|
|
var previousAnimationCurrentTime;
|
|
|
|
animation.ready.then(function() {
|
|
previousAnimationCurrentTime = animation.currentTime;
|
|
previousTimelineCurrentTime = animation.timeline.currentTime;
|
|
|
|
animation.playbackRate = 1;
|
|
|
|
return waitForFrame();
|
|
}).then(t.step_func_done(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');
|
|
|
|
done();
|
|
</script>
|
|
</body>
|