Bug 1474247 - Call ReschedulePendingtasks when we set a new target to KeyframeEffect. r?birtles
MozReview-Commit-ID: ECgi8amaoxU
--- a/dom/animation/KeyframeEffect.cpp
+++ b/dom/animation/KeyframeEffect.cpp
@@ -967,16 +967,17 @@ KeyframeEffect::SetTarget(const Nullable
MaybeUpdateFrameForCompositor();
RequestRestyle(EffectCompositor::RestyleType::Layer);
nsAutoAnimationMutationBatch mb(mTarget->mElement->OwnerDoc());
if (mAnimation) {
nsNodeUtils::AnimationAdded(mAnimation);
+ mAnimation->ReschedulePendingTasks();
}
}
}
static void
CreatePropertyValue(nsCSSPropertyID aProperty,
float aOffset,
const Maybe<ComputedTimingFunction>& aTimingFunction,
--- a/dom/animation/test/mozilla/test_pending_animation_tracker.html
+++ b/dom/animation/test/mozilla/test_pending_animation_tracker.html
@@ -156,10 +156,27 @@ test(t => {
anim.effect.target = null;
assert_false(anim.pending, 'The animation should not be pending');
assert_false(SpecialPowers.DOMWindowUtils.isAnimationPending(anim),
'The animation should NOT be tracked by the tracker');
}, 'Setting null target removes the animation from the tracker');
+test(t => {
+ const effect = new KeyframeEffect(null, null);
+ const anim = new Animation(effect);
+ anim.play();
+ assert_true(anim.pending, 'The orphaned animation should be pending');
+ assert_false(SpecialPowers.DOMWindowUtils.isAnimationPending(anim),
+ 'The orphaned animation should NOT be tracked by tracker');
+
+ const target = addDiv(t);
+ anim.effect.target = target;
+
+ assert_true(anim.pending, 'The animation should be still pending');
+ assert_true(SpecialPowers.DOMWindowUtils.isAnimationPending(anim),
+ 'The animation should be now tracked by tracker');
+}, 'Setting target element to the orphaned animation starts being tracked ' +
+ 'by the tracker');
+
</script>
</body>