Bug 1474247 - Check mPendingState instead of mPendingReadyTime in Animation::ReschedulePendingTasks(). r?birtles
When the pending animation having no target element sets a new effect having
a target element associated with a document, PendingAnimationTracker has to
start tracking the animation regardless of mPendingReadyTime.
MozReview-Commit-ID: DxmbXtLhjCT
--- a/dom/animation/Animation.cpp
+++ b/dom/animation/Animation.cpp
@@ -1459,29 +1459,31 @@ Animation::ResetPendingTasks()
mReady->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
mReady = nullptr;
}
}
void
Animation::ReschedulePendingTasks()
{
- if (mPendingReadyTime.IsNull()) {
+ if (mPendingState == PendingState::NotPending) {
return;
}
mPendingReadyTime.SetNull();
nsIDocument* doc = GetRenderedDocument();
if (doc) {
PendingAnimationTracker* tracker =
doc->GetOrCreatePendingAnimationTracker();
- if (mPendingState == PendingState::PlayPending) {
+ if (mPendingState == PendingState::PlayPending &&
+ !tracker->IsWaitingToPlay(*this)) {
tracker->AddPlayPending(*this);
- } else {
+ } else if (mPendingState == PendingState::PausePending &&
+ !tracker->IsWaitingToPause(*this)) {
tracker->AddPausePending(*this);
}
}
}
bool
Animation::IsPossiblyOrphanedPendingAnimation() const
{
--- a/dom/animation/test/mozilla/test_pending_animation_tracker.html
+++ b/dom/animation/test/mozilla/test_pending_animation_tracker.html
@@ -32,16 +32,32 @@ test(t => {
const newEffect = new KeyframeEffect(target, null);
anim.effect = newEffect;
assert_true(SpecialPowers.DOMWindowUtils.isAnimationInPendingTracker(anim),
'The animation should be still tracked by tracker');
}, 'Setting another effect 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);
+ const newEffect = new KeyframeEffect(target, null);
+ anim.effect = newEffect;
+
+ assert_true(SpecialPowers.DOMWindowUtils.isAnimationInPendingTracker(anim),
+ 'The animation should be now tracked by tracker');
+}, 'Setting effect having target element starts being tracked by the ' +
+ 'tracker');
+
+test(t => {
const target = addDiv(t);
const anim = target.animate(null, 100 * MS_PER_SEC);
assert_true(SpecialPowers.DOMWindowUtils.isAnimationInPendingTracker(anim),
'The animation should be tracked by tracker');
anim.cancel();
assert_false(SpecialPowers.DOMWindowUtils.isAnimationInPendingTracker(anim),