diff --git a/dom/animation/AnimationTimeline.h b/dom/animation/AnimationTimeline.h index 85b37125569..1cac868b630 100644 --- a/dom/animation/AnimationTimeline.h +++ b/dom/animation/AnimationTimeline.h @@ -65,9 +65,10 @@ public: // be a no-op. void FastForward(const TimeStamp& aTimeStamp); + nsRefreshDriver* GetRefreshDriver() const; + protected: TimeStamp GetCurrentTimeStamp() const; - nsRefreshDriver* GetRefreshDriver() const; nsCOMPtr mDocument; diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index fba378ad0ff..6a4b2a12859 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -424,6 +424,23 @@ AddAnimationsForProperty(nsIFrame* aFrame, nsCSSProperty aProperty, player->IsRunning())) { continue; } + + // Don't add animations that are pending when their corresponding + // refresh driver is under test control. This is because any pending + // animations on layers will have their start time updated with the + // current timestamp but when the refresh driver is under test control + // its refresh times are unrelated to timestamp values. + // + // Instead we leave the animation running on the main thread and the + // next time the refresh driver is advanced it will trigger any pending + // animations. + if (player->PlayState() == AnimationPlayState::Pending) { + nsRefreshDriver* driver = player->Timeline()->GetRefreshDriver(); + if (driver && driver->IsTestControllingRefreshesEnabled()) { + continue; + } + } + AddAnimationForProperty(aFrame, aProperty, player, aLayer, aData, aPending); player->SetIsRunningOnCompositor(); }