Bug 1474247 - Call ReschedulePendingtasks when we set a new target to KeyframeEffect. r?birtles draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Thu, 12 Jul 2018 17:05:50 +0900
changeset 817228 ed8c7f697f3585ddf79e2f224c04239092009ce1
parent 817227 eab044f9156aaa35cd4fafb2652671cea8a4c222
push id115993
push userhikezoe@mozilla.com
push dateThu, 12 Jul 2018 08:06:50 +0000
reviewersbirtles
bugs1474247
milestone63.0a1
Bug 1474247 - Call ReschedulePendingtasks when we set a new target to KeyframeEffect. r?birtles MozReview-Commit-ID: 1n5I6RPKAM5
dom/animation/KeyframeEffect.cpp
dom/animation/test/mozilla/test_pending_animation_tracker.html
--- a/dom/animation/KeyframeEffect.cpp
+++ b/dom/animation/KeyframeEffect.cpp
@@ -953,16 +953,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
@@ -98,10 +98,25 @@ test(t => {
               'The animation should be tracked by tracker');
 
   anim.effect.target = anotherTarget;
 
   assert_true(SpecialPowers.DOMWindowUtils.isAnimationInPendingTracker(anim),
               'The animation should be still tracked by tracker');
 }, 'Setting another target keeps the pending animation in the tracker');
 
+test(t => {
+  const effect = new KeyframeEffect(null, null);
+  const anim = new Animation(effect);
+  anim.play();
+  assert_false(SpecialPowers.DOMWindowUtils.isAnimationInPendingTracker(anim),
+               'The orphaned animation should NOT be tracked by tracker');
+
+  const target = addDiv(t);
+  anim.effect.target = target;
+
+  assert_true(SpecialPowers.DOMWindowUtils.isAnimationInPendingTracker(anim),
+              'The animation should be now tracked by tracker');
+}, 'Setting target element to the orphaned animation starts being tracked ' +
+   'by the tracker');
+
 </script>
 </body>