Bug 1442150 - Move startsRightNow into testcommon.js and rename it to animationStartsRightNow. r?birtles draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Tue, 06 Mar 2018 10:35:26 +0900
changeset 763476 f8ef2eb237f9890d1b910b0b1556822a867215c9
parent 763475 f41cd84598aa8d8adfb2e2e760140cf38ad946b5
child 763477 a7d5733195825781c410fe8ef4d90a6234ce0ab2
child 763481 d65c5de431cfc729096882500eeec2526ff6209e
push id101465
push userhikezoe@mozilla.com
push dateTue, 06 Mar 2018 01:40:23 +0000
reviewersbirtles
bugs1442150
milestone60.0a1
Bug 1442150 - Move startsRightNow into testcommon.js and rename it to animationStartsRightNow. r?birtles MozReview-Commit-ID: 58umbOjy4di
dom/animation/test/mozilla/file_restyles.html
dom/animation/test/testcommon.js
--- 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;
+}
+