Bug 1453568 - Add test case that animationcancel or transitioncancel event is not dispatched when setting null timeline in idle state. r?birtles
MozReview-Commit-ID: 3gXh5WcmWlY
--- a/dom/animation/test/css-animations/test_event-dispatch.html
+++ b/dom/animation/test/css-animations/test_event-dispatch.html
@@ -131,16 +131,35 @@ promise_test(async t => {
// Make idle
animation.timeline = null;
const event = await watcher.wait_for('animationcancel');
assert_time_equals_literal(event.elapsedTime, 0.1);
}, 'Active -> Idle, setting Animation.timeline = null');
promise_test(async t => {
+ const { animation, watcher, div, handler } = setupAnimation(t, 'anim 100s');
+
+ await watcher.wait_for('animationstart');
+ animation.currentTime = 100.0;
+ // Make idle
+ animation.timeline = null;
+ const event = await watcher.wait_for('animationcancel');
+
+ assert_time_equals_literal(event.elapsedTime, 0.1);
+
+ handler.clear();
+
+ animation.timeline = null;
+ await waitForAnimationFrames(2);
+
+ assert_no_animation_event_received(handler);
+}, 'Idle -> Idle, setting Animation.timeline = null again');
+
+promise_test(async t => {
// we should NOT pause animation since calling cancel synchronously.
const { animation, watcher, div } = setupAnimation(t, 'anim 100s');
await watcher.wait_for('animationstart');
animation.currentTime = 50.0;
animation.cancel();
const event = await watcher.wait_for('animationcancel');
assert_time_equals_literal(event.elapsedTime, 0.05);
--- a/dom/animation/test/css-transitions/test_event-dispatch.html
+++ b/dom/animation/test/css-transitions/test_event-dispatch.html
@@ -131,16 +131,35 @@ promise_test(async t => {
await Promise.all([ watcher.wait_for('transitionrun'), transition.ready ]);
// Make idle
transition.timeline = null;
const event = await watcher.wait_for('transitioncancel');
assert_equals(event.elapsedTime, 0.0);
}, 'Before -> Idle (Animation.timeline = null)');
promise_test(async t => {
+ const { transition, watcher, handler } =
+ setupTransition(t, 'margin-left 100s 100s');
+
+ await Promise.all([ watcher.wait_for('transitionrun'), transition.ready ]);
+ // Make idle
+ transition.timeline = null;
+
+ const event = await watcher.wait_for('transitioncancel');
+ assert_equals(event.elapsedTime, 0.0);
+
+ handler.clear();
+
+ transition.timeline = null;
+ await waitForAnimationFrames(2);
+
+ assert_no_transition_event_received(handler);
+}, 'Idle -> Idle (Animation.timeline = null again)');
+
+promise_test(async t => {
const { transition, watcher } =
setupTransition(t, 'margin-left 100s 100s');
await Promise.all([ watcher.wait_for('transitionrun'), transition.ready ]);
transition.currentTime = 100 * MS_PER_SEC;
const event = await watcher.wait_for('transitionstart');
assert_equals(event.elapsedTime, 0.0);
}, 'Before -> Active');