mirror of
https://github.com/servo/servo.git
synced 2025-08-11 16:35:33 +01:00
Update web-platform-tests to revision d011702f368b88b3bae86e7a8fd2ddd22e18b33c
This commit is contained in:
parent
f9608022ca
commit
299ad0f9d0
573 changed files with 38776 additions and 14942 deletions
|
@ -0,0 +1,61 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>Animation.cancel()</title>
|
||||
<link rel="help" href="https://w3c.github.io/web-animations/#dom-animation-cancel">
|
||||
<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';
|
||||
|
||||
promise_test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var animation = div.animate({transform: ['none', 'translate(100px)']},
|
||||
100 * MS_PER_SEC);
|
||||
return animation.ready.then(function() {
|
||||
assert_not_equals(getComputedStyle(div).transform, 'none',
|
||||
'transform style is animated before cancelling');
|
||||
animation.cancel();
|
||||
assert_equals(getComputedStyle(div).transform, 'none',
|
||||
'transform style is no longer animated after cancelling');
|
||||
});
|
||||
}, 'Animated style is cleared after calling Animation.cancel()');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var animation = div.animate({marginLeft: ['0px', '100px']},
|
||||
100 * MS_PER_SEC);
|
||||
animation.effect.timing.easing = 'linear';
|
||||
animation.cancel();
|
||||
assert_equals(getComputedStyle(div).marginLeft, '0px',
|
||||
'margin-left style is not animated after cancelling');
|
||||
|
||||
animation.currentTime = 50 * MS_PER_SEC;
|
||||
assert_equals(getComputedStyle(div).marginLeft, '50px',
|
||||
'margin-left style is updated when cancelled animation is'
|
||||
+ ' seeked');
|
||||
}, 'After cancelling an animation, it can still be seeked');
|
||||
|
||||
promise_test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var animation = div.animate({marginLeft:['100px', '200px']},
|
||||
100 * MS_PER_SEC);
|
||||
return animation.ready.then(function() {
|
||||
animation.cancel();
|
||||
assert_equals(getComputedStyle(div).marginLeft, '0px',
|
||||
'margin-left style is not animated after cancelling');
|
||||
animation.play();
|
||||
assert_equals(getComputedStyle(div).marginLeft, '100px',
|
||||
'margin-left style is animated after re-starting animation');
|
||||
return animation.ready;
|
||||
}).then(function() {
|
||||
assert_equals(animation.playState, 'running',
|
||||
'Animation succeeds in running after being re-started');
|
||||
});
|
||||
}, 'After cancelling an animation, it can still be re-used');
|
||||
|
||||
</script>
|
||||
</body>
|
|
@ -0,0 +1,210 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>Animation.finish()</title>
|
||||
<link rel="help" href="https://w3c.github.io/web-animations/#dom-animation-finish">
|
||||
<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 gKeyFrames = { 'marginLeft': ['100px', '200px'] };
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
|
||||
animation.playbackRate = 0;
|
||||
|
||||
assert_throws({name: 'InvalidStateError'}, function() {
|
||||
animation.finish();
|
||||
});
|
||||
}, 'Test exceptions when finishing non-running animation');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var animation = div.animate(gKeyFrames,
|
||||
{duration : 100 * MS_PER_SEC,
|
||||
iterations : Infinity});
|
||||
|
||||
assert_throws({name: 'InvalidStateError'}, function() {
|
||||
animation.finish();
|
||||
});
|
||||
}, 'Test exceptions when finishing infinite animation');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
|
||||
animation.finish();
|
||||
|
||||
assert_equals(animation.currentTime, 100 * MS_PER_SEC,
|
||||
'After finishing, the currentTime should be set to the end ' +
|
||||
'of the active duration');
|
||||
}, 'Test finishing of animation');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
|
||||
// 1s past effect end
|
||||
animation.currentTime =
|
||||
animation.effect.getComputedTiming().endTime + 1 * MS_PER_SEC;
|
||||
animation.finish();
|
||||
|
||||
assert_equals(animation.currentTime, 100 * MS_PER_SEC,
|
||||
'After finishing, the currentTime should be set back to the ' +
|
||||
'end of the active duration');
|
||||
}, 'Test finishing of animation with a current time past the effect end');
|
||||
|
||||
promise_test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
|
||||
animation.currentTime = 100 * MS_PER_SEC;
|
||||
return animation.finished.then(function() {
|
||||
animation.playbackRate = -1;
|
||||
animation.finish();
|
||||
|
||||
assert_equals(animation.currentTime, 0,
|
||||
'After finishing a reversed animation the currentTime ' +
|
||||
'should be set to zero');
|
||||
});
|
||||
}, 'Test finishing of reversed animation');
|
||||
|
||||
promise_test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
|
||||
animation.currentTime = 100 * MS_PER_SEC;
|
||||
return animation.finished.then(function() {
|
||||
animation.playbackRate = -1;
|
||||
animation.currentTime = -1000;
|
||||
animation.finish();
|
||||
|
||||
assert_equals(animation.currentTime, 0,
|
||||
'After finishing a reversed animation the currentTime ' +
|
||||
'should be set back to zero');
|
||||
});
|
||||
}, 'Test finishing of reversed animation with a current time less than zero');
|
||||
|
||||
promise_test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
|
||||
animation.pause();
|
||||
return animation.ready.then(function() {
|
||||
animation.finish();
|
||||
|
||||
assert_equals(animation.playState, 'finished',
|
||||
'The play state of a paused animation should become ' +
|
||||
'"finished" after finish() is called');
|
||||
assert_approx_equals(animation.startTime,
|
||||
animation.timeline.currentTime - 100 * MS_PER_SEC,
|
||||
0.0001,
|
||||
'The start time of a paused animation should be set ' +
|
||||
'after calling finish()');
|
||||
});
|
||||
}, 'Test finish() while paused');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
|
||||
animation.pause();
|
||||
// Update playbackRate so we can test that the calculated startTime
|
||||
// respects it
|
||||
animation.playbackRate = 2;
|
||||
// While animation is still pause-pending call finish()
|
||||
animation.finish();
|
||||
|
||||
assert_equals(animation.playState, 'finished',
|
||||
'The play state of a pause-pending animation should become ' +
|
||||
'"finished" after finish() is called');
|
||||
assert_approx_equals(animation.startTime,
|
||||
animation.timeline.currentTime - 100 * MS_PER_SEC / 2,
|
||||
0.0001,
|
||||
'The start time of a pause-pending animation should ' +
|
||||
'be set after calling finish()');
|
||||
}, 'Test finish() while pause-pending with positive playbackRate');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
|
||||
animation.pause();
|
||||
animation.playbackRate = -2;
|
||||
animation.finish();
|
||||
|
||||
assert_equals(animation.playState, 'finished',
|
||||
'The play state of a pause-pending animation should become ' +
|
||||
'"finished" after finish() is called');
|
||||
assert_equals(animation.startTime, animation.timeline.currentTime,
|
||||
'The start time of a pause-pending animation should be ' +
|
||||
'set after calling finish()');
|
||||
}, 'Test finish() while pause-pending with negative playbackRate');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
|
||||
animation.playbackRate = 0.5;
|
||||
animation.finish();
|
||||
|
||||
assert_equals(animation.playState, 'finished',
|
||||
'The play state of a play-pending animation should become ' +
|
||||
'"finished" after finish() is called');
|
||||
assert_approx_equals(animation.startTime,
|
||||
animation.timeline.currentTime - 100 * MS_PER_SEC / 0.5,
|
||||
0.0001,
|
||||
'The start time of a play-pending animation should ' +
|
||||
'be set after calling finish()');
|
||||
}, 'Test finish() while play-pending');
|
||||
|
||||
// FIXME: Add a test for when we are play-pending without an active timeline.
|
||||
// - In that case even after calling finish() we should still be pending but
|
||||
// the current time should be updated
|
||||
|
||||
promise_test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
|
||||
return animation.ready.then(function() {
|
||||
animation.pause();
|
||||
animation.play();
|
||||
// We are now in the unusual situation of being play-pending whilst having
|
||||
// a resolved start time. Check that finish() still triggers a transition
|
||||
// to the finished state immediately.
|
||||
animation.finish();
|
||||
|
||||
assert_equals(animation.playState, 'finished',
|
||||
'After aborting a pause then calling finish() the play ' +
|
||||
'state of an animation should become "finished" immediately');
|
||||
});
|
||||
}, 'Test finish() during aborted pause');
|
||||
|
||||
promise_test(function(t) {
|
||||
var div = createDiv(t);
|
||||
div.style.marginLeft = '10px';
|
||||
var animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
|
||||
return animation.ready.then(function() {
|
||||
animation.finish();
|
||||
var marginLeft = parseFloat(getComputedStyle(div).marginLeft);
|
||||
|
||||
assert_equals(marginLeft, 10,
|
||||
'The computed style should be reset when finish() is ' +
|
||||
'called');
|
||||
});
|
||||
}, 'Test resetting of computed style');
|
||||
|
||||
promise_test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
|
||||
var resolvedFinished = false;
|
||||
animation.finished.then(function() {
|
||||
resolvedFinished = true;
|
||||
});
|
||||
|
||||
return animation.ready.then(function() {
|
||||
animation.finish();
|
||||
}).then(function() {
|
||||
assert_true(resolvedFinished,
|
||||
'Animation.finished should be resolved soon after ' +
|
||||
'Animation.finish()');
|
||||
});
|
||||
}, 'Test finish() resolves finished promise synchronously');
|
||||
</script>
|
||||
</body>
|
|
@ -0,0 +1,35 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>Animation.play()</title>
|
||||
<link rel="help" href="https://w3c.github.io/web-animations/#dom-animation-play">
|
||||
<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';
|
||||
|
||||
promise_test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var animation = div.animate({ transform: ['none', 'translate(10px)']},
|
||||
{ duration : 100 * MS_PER_SEC,
|
||||
iterations : Infinity});
|
||||
return animation.ready.then(function() {
|
||||
// Seek to a time outside the active range so that play() will have to
|
||||
// snap back to the start
|
||||
animation.currentTime = -5 * MS_PER_SEC;
|
||||
animation.playbackRate = -1;
|
||||
|
||||
assert_throws('InvalidStateError',
|
||||
function () { animation.play(); },
|
||||
'Expected InvalidStateError exception on calling play() ' +
|
||||
'with a negative playbackRate and infinite-duration ' +
|
||||
'animation');
|
||||
});
|
||||
}, 'play() throws when seeking an infinite-duration animation played in ' +
|
||||
'reverse');
|
||||
|
||||
</script>
|
||||
</body>
|
|
@ -0,0 +1,54 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>Animation.playState</title>
|
||||
<link rel="help" href="https://w3c.github.io/web-animations/#dom-animation-playstate">
|
||||
<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';
|
||||
|
||||
promise_test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var animation = div.animate({}, 100 * MS_PER_SEC);
|
||||
|
||||
assert_equals(animation.playState, 'pending');
|
||||
return animation.ready.then(function() {
|
||||
assert_equals(animation.playState, 'running');
|
||||
});
|
||||
}, 'Animation.playState reports \'pending\'->\'running\' when initially ' +
|
||||
'played');
|
||||
|
||||
promise_test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var animation = div.animate({}, 100 * MS_PER_SEC);
|
||||
animation.pause();
|
||||
|
||||
assert_equals(animation.playState, 'pending');
|
||||
return animation.ready.then(function() {
|
||||
assert_equals(animation.playState, 'paused');
|
||||
});
|
||||
}, 'Animation.playState reports \'pending\'->\'paused\' when pausing');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var animation = div.animate({}, 100 * MS_PER_SEC);
|
||||
animation.cancel();
|
||||
assert_equals(animation.playState, 'idle');
|
||||
}, 'Animation.playState is \'idle\' when canceled.');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var animation = div.animate({}, 100 * MS_PER_SEC);
|
||||
animation.cancel();
|
||||
animation.currentTime = 50 * MS_PER_SEC;
|
||||
assert_equals(animation.playState, 'paused',
|
||||
'After seeking an idle animation, it is effectively paused');
|
||||
}, 'Animation.playState is \'paused\' after cancelling an animation, ' +
|
||||
'seeking it makes it paused');
|
||||
|
||||
</script>
|
||||
</body>
|
|
@ -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>
|
Loading…
Add table
Add a link
Reference in a new issue