Bug 1466031 - Tidy up test_animation-ready.html; r?hiro
Although many of these tests are similar to tests in the Web Animations
web-platform-tests test suite they focus on the interaction with
animation-play-state and so are probably worth keeping.
There are two exceptions that I felt were worth changing:
* The test for the handling of a ready promise on an aborted pause. I could not
find a similar test in the Web Animations wpt and it the test is not really
particular to CSS animations so this patch moves it to Web Animations wpt.
* The test for the resolution value of the ready promise for a paused animation
is covered by the "A pending ready promise should be resolved and not replaced
when the animation is paused" in pausing-an-animation.html in the Web
Animations wpt (although peripherally) and that seems like the better place
for this test anyway (it is not specific to CSS animations) so I have simply
deleted it from this file.
MozReview-Commit-ID: 6BdzuIwCOKb
--- a/dom/animation/test/css-animations/test_animation-ready.html
+++ b/dom/animation/test/css-animations/test_animation-ready.html
@@ -36,23 +36,18 @@ promise_test(async t => {
const animation = div.getAnimations()[0];
assert_true(animation.pending, 'Animation is initially pending');
const readyPromise = animation.ready;
// Cancel the animation and flush styles
div.style.animation = '';
getComputedStyle(div).animation;
- try {
- await readyPromise;
- assert_unreached('ready promise is fulfilled');
- } catch(err) {
- assert_equals(err.name, 'AbortError',
- 'ready promise is rejected with AbortError');
- }
+ await promise_rejects(t, 'AbortError', readyPromise,
+ 'ready promise is rejected with AbortError');
}, 'ready promise is rejected when an animation is canceled by resetting'
+ ' the animation property');
promise_test(async t => {
const div = addDiv(t);
// As before, but this time instead of removing all animations, simply update
// the list of animations. At least for Firefox, updating is a different
@@ -63,23 +58,18 @@ promise_test(async t => {
const animation = div.getAnimations()[0];
assert_true(animation.pending, 'Animation is initially pending');
const readyPromise = animation.ready;
// Update the animation and flush styles
div.style.animation = 'def 100s';
getComputedStyle(div).animation;
- try {
- await readyPromise;
- assert_unreached('ready promise is fulfilled');
- } catch(err) {
- assert_equals(err.name, 'AbortError',
- 'ready promise is rejected with AbortError');
- }
+ await promise_rejects(t, 'AbortError', readyPromise,
+ 'ready promise is rejected with AbortError');
}, 'ready promise is rejected when an animation is canceled by updating'
+ ' the animation property');
promise_test(async t => {
const div = addDiv(t, { style: 'animation: abc 100s' });
const animation = div.getAnimations()[0];
const originalReadyPromise = animation.ready;
@@ -99,51 +89,10 @@ promise_test(async t => {
div.style.animationPlayState = 'paused';
const firstReadyPromise = animation.ready;
animation.pause();
assert_equals(animation.ready, firstReadyPromise,
'Ready promise objects are identical after redundant pause');
}, 'Pausing twice re-uses the same Promise');
-promise_test(async t => {
- const div = addDiv(t, { style: 'animation: abc 100s' });
- const animation = div.getAnimations()[0];
-
- await animation.ready;
-
- div.style.animationPlayState = 'paused';
-
- // Flush style and verify we're pending at the same time
- assert_true(animation.pending, 'Animation is pending');
- const pauseReadyPromise = animation.ready;
-
- // Now play again immediately
- div.style.animationPlayState = 'running';
- assert_true(animation.pending, 'Animation is still pending');
- assert_equals(animation.ready, pauseReadyPromise,
- 'The pause Promise is re-used when playing while waiting'
- + ' to pause');
-
- await animation.ready;
-
- assert_true(!animation.pending && animation.playState === 'running',
- 'Animation is running after aborting a pause');
-}, 'If a pause operation is interrupted, the ready promise is reused');
-
-promise_test(async t => {
- const div = addDiv(t, { style: 'animation: abc 100s' });
- const animation = div.getAnimations()[0];
-
- await animation.ready;
-
- div.style.animationPlayState = 'paused';
-
- const resolvedAnimation = await animation.ready;
-
- assert_equals(resolvedAnimation, animation,
- 'Promise received when ready Promise for a pause operation'
- + ' is completed is the animation on which the pause was'
- + ' performed');
-}, 'When a pause is complete the Promise callback gets the correct animation');
-
</script>
</body>
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -615892,17 +615892,17 @@
"27e4132548fc430fae19f3bab9cc8dc8c5a263ca",
"testharness"
],
"web-animations/timing-model/animations/play-states.html": [
"0ab2fa3a464001272d1af541ea769fa967490c3b",
"testharness"
],
"web-animations/timing-model/animations/playing-an-animation.html": [
- "386ed5ae920f51b80b9f7dc3a0fdf4526081817f",
+ "f6c36cc2370b08037e5a99009e6def67df84a4a7",
"testharness"
],
"web-animations/timing-model/animations/reversing-an-animation.html": [
"72b89e78ca7dac261af8de370389d89c810b3718",
"testharness"
],
"web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation.html": [
"a7e28aa0b40a39b00da257e347cb6ecf8d1d2882",
--- a/testing/web-platform/tests/web-animations/timing-model/animations/playing-an-animation.html
+++ b/testing/web-platform/tests/web-animations/timing-model/animations/playing-an-animation.html
@@ -67,16 +67,38 @@ promise_test(async t => {
const promise = animation.ready;
const promiseResult = await promise;
assert_equals(promiseResult, animation);
assert_equals(animation.ready, promise);
}, 'A pending ready promise should be resolved and not replaced when the'
+ ' animation enters the running state');
promise_test(async t => {
+ const animation = createDiv(t).animate(null, 100 * MS_PER_SEC);
+ await animation.ready;
+
+ // Go to pause-pending state
+ animation.pause();
+ assert_true(animation.pending, 'Animation is pending');
+ const pauseReadyPromise = animation.ready;
+
+ // Now play again immediately (abort the pause)
+ animation.play();
+ assert_true(animation.pending, 'Animation is still pending');
+ assert_equals(animation.ready, pauseReadyPromise,
+ 'The pause Promise is re-used when playing while waiting'
+ + ' to pause');
+
+ // Sanity check: Animation proceeds to running state
+ await animation.ready;
+ assert_true(!animation.pending && animation.playState === 'running',
+ 'Animation is running after aborting a pause');
+}, 'If a pause operation is interrupted, the ready promise is reused');
+
+promise_test(async t => {
// Seek animation beyond target end
const animation = createDiv(t).animate(null, 100 * MS_PER_SEC);
animation.currentTime = -100 * MS_PER_SEC;
await animation.ready;
// Set pending playback rate to the opposite direction
animation.updatePlaybackRate(-1);
assert_true(animation.pending);