Bug 1474247 - Call ReschedulePendingtasks when we set a new target to KeyframeEffect. r?birtles draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Wed, 11 Jul 2018 11:39:31 +0900
changeset 816369 fadf38c85f1b9305890c6af597c12a11de10178b
parent 816368 2217664e292d51d266dc9b0a8397977246f75cbb
child 816370 6fc3248fa45d77ef5dd483e58ae8cf939500840a
push id115815
push userhikezoe@mozilla.com
push dateWed, 11 Jul 2018 02:48:59 +0000
reviewersbirtles
bugs1474247
milestone63.0a1
Bug 1474247 - Call ReschedulePendingtasks when we set a new target to KeyframeEffect. r?birtles MozReview-Commit-ID: ECgi8amaoxU
dom/animation/KeyframeEffect.cpp
dom/animation/test/mozilla/test_pending_animation_tracker.html
--- 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>