Bug 1442150 - Move startsRightNow into testcommon.js and rename it to animationStartsRightNow. r?birtles
MozReview-Commit-ID: 58umbOjy4di
--- a/dom/animation/test/mozilla/file_restyles.html
+++ b/dom/animation/test/mozilla/file_restyles.html
@@ -91,26 +91,16 @@ function waitForWheelEvent(aTarget) {
sendWheelAndPaintNoFlush(aTarget, centerX, centerY,
{ deltaMode: WheelEvent.DOM_DELTA_PIXEL,
deltaY: targetRect.height },
resolve);
});
}
-// Returns true if |aAnimation| begins at the current timeline time. We
-// sometimes need to detect this case because if we started an animation
-// asynchronously (e.g. using play()) and then ended up running the next frame
-// at precisely the time the animation started (due to aligning with vsync
-// refresh rate) then we won't end up restyling in that frame.
-function startsRightNow(aAnimation) {
- return aAnimation.startTime === aAnimation.timeline.currentTime &&
- aAnimation.currentTime === 0;
-}
-
function tweakExpectedRestyleCount(aAnimation, aExpectedRestyleCount) {
// Normally we expect one restyling for each requestAnimationFrame (as
// called by observeRestyling) PLUS one for the last frame because of bug
// 1193394. However, we won't observe that initial restyling unless BOTH of
// the following two conditions hold:
//
// 1. We are running *before* restyling happens.
// 2. The animation actually needs a restyle because it started prior to
@@ -118,20 +108,20 @@ function tweakExpectedRestyleCount(aAnim
// the refresh driver, the animation fame in which the ready promise is
// resolved happens to coincide perfectly with the start time of the
// animation. In this case no restyling is needed so we won't observe
// an additional restyle.
if (hasConformantPromiseHandling) {
// If we have the conformant Promise handling and |aAnimation| begins at
// the current timeline time, we will not process restyling in the initial
// frame.
- if (startsRightNow(aAnimation)) {
+ if (animationStartsRightNow(aAnimation)) {
return aExpectedRestyleCount - 1;
}
- } else if (!startsRightNow(aAnimation)) {
+ } else if (!animationStartsRightNow(aAnimation)) {
// If we don't have the conformant Promise handling and |aAnimation|
// doesn't begin at the current timeline time, we will see an additional
// restyling in the last frame.
return aExpectedRestyleCount + 1;
}
return aExpectedRestyleCount;
}
--- a/dom/animation/test/testcommon.js
+++ b/dom/animation/test/testcommon.js
@@ -414,8 +414,19 @@ function getDistance(target, prop, v1, v
* A promise wrapper for waiting MozAfterPaint.
*/
function waitForPaints() {
// FIXME: Bug 1415065. Instead waiting for two requestAnimationFrames, we
// should wait for MozAfterPaint once after MozAfterPaint is fired properly
// (bug 1341294).
return waitForAnimationFrames(2);
}
+
+// Returns true if |aAnimation| begins at the current timeline time. We
+// sometimes need to detect this case because if we started an animation
+// asynchronously (e.g. using play()) and then ended up running the next frame
+// at precisely the time the animation started (due to aligning with vsync
+// refresh rate) then we won't end up restyling in that frame.
+function animationStartsRightNow(aAnimation) {
+ return aAnimation.startTime === aAnimation.timeline.currentTime &&
+ aAnimation.currentTime === 0;
+}
+