Bug 1436659 - Move finishing tests to timing-model; r?hiro
These tests are not testing the interface so much as the 'finish an animation'
procedure.
This patch simply moves the tests as-is. They will be simplified in the next
patch in this series.
MozReview-Commit-ID: 5nloB5GtxHv
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -358643,22 +358643,16 @@
]
],
"web-animations/interfaces/Animation/effect.html": [
[
"/web-animations/interfaces/Animation/effect.html",
{}
]
],
- "web-animations/interfaces/Animation/finish.html": [
- [
- "/web-animations/interfaces/Animation/finish.html",
- {}
- ]
- ],
"web-animations/interfaces/Animation/finished.html": [
[
"/web-animations/interfaces/Animation/finished.html",
{}
]
],
"web-animations/interfaces/Animation/id.html": [
[
@@ -591520,20 +591514,16 @@
"web-animations/interfaces/Animation/constructor.html": [
"f4dc4fdca61255557ed346412e134745bce1a3ed",
"testharness"
],
"web-animations/interfaces/Animation/effect.html": [
"4445fc8bd2120fb1e212dfc6a1fcf786a531ee6f",
"testharness"
],
- "web-animations/interfaces/Animation/finish.html": [
- "64acecec8528b4d241d5dcb9248ef82eafa02810",
- "testharness"
- ],
"web-animations/interfaces/Animation/finished.html": [
"ffcba3379db7094455a7798e4d5972d8e52caec5",
"testharness"
],
"web-animations/interfaces/Animation/id.html": [
"4e3dd92351d76c5c7d09ddd1ca025520f4c8875d",
"testharness"
],
@@ -591713,17 +591703,17 @@
"602fe7e6880e0b18329262699872c696f451d744",
"testharness"
],
"web-animations/timing-model/animations/canceling-an-animation.html": [
"e03baa30d438529a0ebe39f0f623563aa9850d74",
"testharness"
],
"web-animations/timing-model/animations/finishing-an-animation.html": [
- "0debe6efc8608778c81a88608284a45077ec3276",
+ "360d8a6f15b16cf8dc4decc71217db132e0f276d",
"testharness"
],
"web-animations/timing-model/animations/pausing-an-animation.html": [
"982440e635a0c5a437febac0e53a6eb7442db495",
"testharness"
],
"web-animations/timing-model/animations/play-states.html": [
"0ab2fa3a464001272d1af541ea769fa967490c3b",
deleted file mode 100644
--- a/testing/web-platform/tests/web-animations/interfaces/Animation/finish.html
+++ /dev/null
@@ -1,246 +0,0 @@
-<!DOCTYPE html>
-<meta charset=utf-8>
-<title>Animation.finish</title>
-<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animation-finish">
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script src="../../testcommon.js"></script>
-<body>
-<div id="log"></div>
-<script>
-'use strict';
-
-const gKeyFrames = { 'marginLeft': ['100px', '200px'] };
-
-test(t => {
- const div = createDiv(t);
- const animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
- animation.playbackRate = 0;
-
- assert_throws({name: 'InvalidStateError'}, () => {
- animation.finish();
- });
-}, 'Test exceptions when finishing non-running animation');
-
-test(t => {
- const div = createDiv(t);
- const animation = div.animate(gKeyFrames,
- { duration : 100 * MS_PER_SEC,
- iterations : Infinity });
-
- assert_throws({name: 'InvalidStateError'}, () => {
- animation.finish();
- });
-}, 'Test exceptions when finishing infinite animation');
-
-test(t => {
- const div = createDiv(t);
- const 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(t => {
- const div = createDiv(t);
- const 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(t => {
- const div = createDiv(t);
- const animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
- animation.currentTime = 100 * MS_PER_SEC;
- return animation.finished.then(() => {
- 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(t => {
- const div = createDiv(t);
- const animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
- animation.currentTime = 100 * MS_PER_SEC;
- return animation.finished.then(() => {
- 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(t => {
- const div = createDiv(t);
- const animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
- animation.pause();
- return animation.ready.then(() => {
- animation.finish();
-
- assert_equals(animation.playState, 'finished',
- 'The play state of a paused animation should become ' +
- '"finished" after finish() is called');
- assert_times_equal(animation.startTime,
- animation.timeline.currentTime - 100 * MS_PER_SEC,
- 'The start time of a paused animation should be set ' +
- 'after calling finish()');
- });
-}, 'Test finish() while paused');
-
-test(t => {
- const div = createDiv(t);
- const 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_times_equal(animation.startTime,
- animation.timeline.currentTime - 100 * MS_PER_SEC / 2,
- 'The start time of a pause-pending animation should ' +
- 'be set after calling finish()');
-}, 'Test finish() while pause-pending with positive playbackRate');
-
-test(t => {
- const div = createDiv(t);
- const 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(t => {
- const div = createDiv(t);
- const 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_times_equal(animation.startTime,
- animation.timeline.currentTime - 100 * MS_PER_SEC / 0.5,
- '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(t => {
- const div = createDiv(t);
- const animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
- return animation.ready.then(() => {
- 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(t => {
- const div = createDiv(t);
- div.style.marginLeft = '10px';
- const animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
- return animation.ready.then(() => {
- animation.finish();
- const 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(t => {
- const div = createDiv(t);
- const animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
- let resolvedFinished = false;
- animation.finished.then(() => {
- resolvedFinished = true;
- });
-
- return animation.ready.then(() => {
- animation.finish();
- }).then(() => {
- assert_true(resolvedFinished,
- 'Animation.finished should be resolved soon after ' +
- 'Animation.finish()');
- });
-}, 'Test finish() resolves finished promise synchronously');
-
-promise_test(t => {
- const effect = new KeyframeEffectReadOnly(null, gKeyFrames, 100 * MS_PER_SEC);
- const animation = new Animation(effect, document.timeline);
- let resolvedFinished = false;
- animation.finished.then(() => {
- resolvedFinished = true;
- });
-
- return animation.ready.then(() => {
- animation.finish();
- }).then(() => {
- assert_true(resolvedFinished,
- 'Animation.finished should be resolved soon after ' +
- 'Animation.finish()');
- });
-}, 'Test finish() resolves finished promise synchronously with an animation ' +
- 'without a target');
-
-promise_test(t => {
- const effect = new KeyframeEffectReadOnly(null, gKeyFrames, 100 * MS_PER_SEC);
- const animation = new Animation(effect, document.timeline);
- animation.play();
-
- let resolvedFinished = false;
- animation.finished.then(() => {
- resolvedFinished = true;
- });
-
- return animation.ready.then(() => {
- animation.currentTime = animation.effect.getComputedTiming().endTime - 1;
- return waitForAnimationFrames(2);
- }).then(() => {
- assert_true(resolvedFinished,
- 'Animation.finished should be resolved soon after ' +
- 'Animation finishes normally');
- });
-}, 'Test normally finished animation resolves finished promise synchronously ' +
- 'with an animation without a target');
-
-</script>
-</body>
--- a/testing/web-platform/tests/web-animations/timing-model/animations/finishing-an-animation.html
+++ b/testing/web-platform/tests/web-animations/timing-model/animations/finishing-an-animation.html
@@ -6,16 +6,248 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../testcommon.js"></script>
<body>
<div id="log"></div>
<script>
'use strict';
+const gKeyFrames = { 'marginLeft': ['100px', '200px'] };
+
+test(t => {
+ const div = createDiv(t);
+ const animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
+ animation.playbackRate = 0;
+
+ assert_throws({name: 'InvalidStateError'}, () => {
+ animation.finish();
+ });
+}, 'Test exceptions when finishing non-running animation');
+
+test(t => {
+ const div = createDiv(t);
+ const animation = div.animate(gKeyFrames,
+ { duration : 100 * MS_PER_SEC,
+ iterations : Infinity });
+
+ assert_throws({name: 'InvalidStateError'}, () => {
+ animation.finish();
+ });
+}, 'Test exceptions when finishing infinite animation');
+
+test(t => {
+ const div = createDiv(t);
+ const 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(t => {
+ const div = createDiv(t);
+ const 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(t => {
+ const div = createDiv(t);
+ const animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
+ animation.currentTime = 100 * MS_PER_SEC;
+ return animation.finished.then(() => {
+ 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(t => {
+ const div = createDiv(t);
+ const animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
+ animation.currentTime = 100 * MS_PER_SEC;
+ return animation.finished.then(() => {
+ 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(t => {
+ const div = createDiv(t);
+ const animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
+ animation.pause();
+ return animation.ready.then(() => {
+ animation.finish();
+
+ assert_equals(animation.playState, 'finished',
+ 'The play state of a paused animation should become ' +
+ '"finished" after finish() is called');
+ assert_times_equal(animation.startTime,
+ animation.timeline.currentTime - 100 * MS_PER_SEC,
+ 'The start time of a paused animation should be set ' +
+ 'after calling finish()');
+ });
+}, 'Test finish() while paused');
+
+test(t => {
+ const div = createDiv(t);
+ const 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_times_equal(animation.startTime,
+ animation.timeline.currentTime - 100 * MS_PER_SEC / 2,
+ 'The start time of a pause-pending animation should ' +
+ 'be set after calling finish()');
+}, 'Test finish() while pause-pending with positive playbackRate');
+
+test(t => {
+ const div = createDiv(t);
+ const 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(t => {
+ const div = createDiv(t);
+ const 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_times_equal(animation.startTime,
+ animation.timeline.currentTime - 100 * MS_PER_SEC / 0.5,
+ '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(t => {
+ const div = createDiv(t);
+ const animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
+ return animation.ready.then(() => {
+ 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(t => {
+ const div = createDiv(t);
+ div.style.marginLeft = '10px';
+ const animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
+ return animation.ready.then(() => {
+ animation.finish();
+ const 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(t => {
+ const div = createDiv(t);
+ const animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
+ let resolvedFinished = false;
+ animation.finished.then(() => {
+ resolvedFinished = true;
+ });
+
+ return animation.ready.then(() => {
+ animation.finish();
+ }).then(() => {
+ assert_true(resolvedFinished,
+ 'Animation.finished should be resolved soon after ' +
+ 'Animation.finish()');
+ });
+}, 'Test finish() resolves finished promise synchronously');
+
+promise_test(t => {
+ const effect = new KeyframeEffectReadOnly(null, gKeyFrames, 100 * MS_PER_SEC);
+ const animation = new Animation(effect, document.timeline);
+ let resolvedFinished = false;
+ animation.finished.then(() => {
+ resolvedFinished = true;
+ });
+
+ return animation.ready.then(() => {
+ animation.finish();
+ }).then(() => {
+ assert_true(resolvedFinished,
+ 'Animation.finished should be resolved soon after ' +
+ 'Animation.finish()');
+ });
+}, 'Test finish() resolves finished promise synchronously with an animation ' +
+ 'without a target');
+
+promise_test(t => {
+ const effect = new KeyframeEffectReadOnly(null, gKeyFrames, 100 * MS_PER_SEC);
+ const animation = new Animation(effect, document.timeline);
+ animation.play();
+
+ let resolvedFinished = false;
+ animation.finished.then(() => {
+ resolvedFinished = true;
+ });
+
+ return animation.ready.then(() => {
+ animation.currentTime = animation.effect.getComputedTiming().endTime - 1;
+ return waitForAnimationFrames(2);
+ }).then(() => {
+ assert_true(resolvedFinished,
+ 'Animation.finished should be resolved soon after ' +
+ 'Animation finishes normally');
+ });
+}, 'Test normally finished animation resolves finished promise synchronously ' +
+ 'with an animation without a target');
+
promise_test(async t => {
const animation = createDiv(t).animate(null, 100 * MS_PER_SEC);
const promise = animation.ready;
let readyResolved = false;
animation.finish();
animation.ready.then(() => { readyResolved = true; });