Commit 6caba6d0 authored by Kevin Ellis's avatar Kevin Ellis Committed by Commit Bot

Add tests for resuming a canceled animation.

Bug: 1015083
Change-Id: I8d8137d85ccdf9a6fe68f6be1b12a483ef0eabea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2023191Reviewed-by: default avatarXida Chen <xidachen@chromium.org>
Commit-Queue: Kevin Ellis <kevers@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735899}
parent f1e6a830
......@@ -300,5 +300,31 @@ promise_test(async t => {
'finish event should be fired for the animation on an orphaned element');
}, 'Finishing an animation fires finish event on orphaned element');
promise_test(async t => {
const animation = createDiv(t).animate(null, 100 * MS_PER_SEC);
await animation.ready;
const originalFinishPromise = animation.finished;
animation.cancel();
assert_equals(animation.startTime, null);
assert_equals(animation.currentTime, null);
const resolvedFinishPromise = animation.finished;
assert_true(originalFinishPromise != resolvedFinishPromise,
'Canceling an animation should create a new finished promise');
animation.finish();
assert_equals(animation.playState, 'finished',
'The play state of a canceled animation should become ' +
'"finished"');
assert_times_equal(animation.startTime,
animation.timeline.currentTime - 100 * MS_PER_SEC,
'The start time of a finished animation should be set');
assert_times_equal(animation.currentTime, 100000,
'Hold time should be set to end boundary of the animation');
}, 'Finishing a canceled animation sets the current and start times');
</script>
</body>
......@@ -89,5 +89,31 @@ promise_test(async t => {
'Animation.currentTime is unchanged after pausing');
}, 'The animation\'s current time remains fixed after pausing');
promise_test(async t => {
const animation = createDiv(t).animate(null, 100 * MS_PER_SEC);
const originalReadyPromise = animation.ready;
animation.cancel();
assert_equals(animation.startTime, null);
assert_equals(animation.currentTime, null);
const readyPromise = animation.ready;
assert_true(originalReadyPromise != readyPromise,
'Canceling an animation should create a new ready promise');
animation.pause();
assert_equals(animation.playState, 'paused',
'Pausing a canceled animation should update the play state');
assert_true(animation.pending, 'animation should be pause-pending');
await animation.ready;
assert_false(animation.pending,
'animation should no longer be pause-pending');
assert_equals(animation.startTime, null, 'start time should be unresolved');
assert_equals(animation.currentTime, 0, 'current time should be set to zero');
}, 'Pausing a canceled animation sets the current time');
</script>
</body>
......@@ -138,5 +138,40 @@ promise_test(async t => {
assert_time_equals_literal(animation.currentTime, 100 * MS_PER_SEC);
}, 'A pending playback rate is used when determining auto-rewind behavior');
promise_test(async t => {
const animation = createDiv(t).animate(null, 100 * MS_PER_SEC);
animation.cancel();
assert_equals(animation.startTime, null,
'Start time should be unresolved');
animation.play();
assert_true(animation.pending, 'Animation should be play-pending');
await animation.ready;
assert_false(animation.pending, 'animation should no longer be pending');
assert_times_equal(animation.startTime, animation.timeline.currentTime,
'The start time of the playing animation should be set');
}, 'Playing a canceled animation sets the start time');
promise_test(async t => {
const animation = createDiv(t).animate(null, 100 * MS_PER_SEC);
animation.playbackRate = -1;
// animation.currentTime = 100 * MS_PER_SEC;
animation.cancel();
assert_equals(animation.startTime, null,
'Start time should be unresolved');
animation.play();
assert_true(animation.pending, 'Animation should be play-pending');
await animation.ready;
assert_false(animation.pending, 'Animation should no longer be pending');
assert_times_equal(animation.startTime,
animation.timeline.currentTime + 100 * MS_PER_SEC,
'The start time of a playing animation should be set');
}, 'Playing a canceled animation backwards sets the start time');
</script>
</body>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment