Bug 1458841 - Remove test code for the old microtask behavior. r?birtles draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Wed, 30 May 2018 09:39:18 +0900
changeset 801280 d0bb48c634984edbc1e3b1f05faff25e3df81e66
parent 801214 89d79c2258be1c420153e1adc54338b0165fc88e
child 801281 0d3599591370d08a8ccb8bda36ff14072071b848
push id111625
push userhikezoe@mozilla.com
push dateWed, 30 May 2018 00:51:30 +0000
reviewersbirtles
bugs1458841
milestone62.0a1
Bug 1458841 - Remove test code for the old microtask behavior. r?birtles MozReview-Commit-ID: ACNgQ0EWrKI
dom/animation/test/mozilla/file_restyles.html
--- a/dom/animation/test/mozilla/file_restyles.html
+++ b/dom/animation/test/mozilla/file_restyles.html
@@ -128,82 +128,44 @@ function waitForWheelEvent(aTarget) {
     sendWheelAndPaintNoFlush(aTarget, centerX, centerY,
                              { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
                                deltaY: targetRect.height },
                              resolve);
   });
 }
 
 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
-  //    this frame.  Even if (1) is true, in some cases due to aligning with
-  //    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 (animationStartsRightNow(aAnimation)) {
-      return aExpectedRestyleCount - 1;
-    }
-  } 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;
+  // If |aAnimation| begins at the current timeline time, we will not process
+  // restyling in the initial frame because of aligning with the refresh driver,
+  // the animation frame 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 (animationStartsRightNow(aAnimation)) {
+    return aExpectedRestyleCount - 1;
   }
   return aExpectedRestyleCount;
 }
 
 var omtaEnabled = isOMTAEnabled();
 
 var isAndroid = !!navigator.userAgent.includes("Android");
-var hasConformantPromiseHandling;
 const isWebRender =
   SpecialPowers.DOMWindowUtils.layerManagerType == 'WebRender';
 
 function add_task_if_omta_enabled(test) {
   if (!omtaEnabled) {
     info(test.name + " is skipped because OMTA is disabled");
     return;
   }
   add_task(test);
 }
 
-function isConformant() {
-  return new Promise(resolve => {
-    let resolvedPromise = false;
-    requestAnimationFrame(() => {
-      Promise.resolve().then(() => {
-        resolvedPromise = true;
-      });
-    });
-
-    requestAnimationFrame(() => {
-      resolve(resolvedPromise);
-    });
-  });
-}
-
 // We need to wait for all paints before running tests to avoid contaminations
 // from styling of this document itself.
 waitForAllPaints(() => {
-  // Drop this once we have the conformant Promise handling(bug 1193394).
-  add_task(async function check_conformant_promise_handling() {
-    hasConformantPromiseHandling = await isConformant();
-  });
-
   add_task(async function restyling_for_main_thread_animations() {
     var div = addDiv(null, { style: 'animation: background-color 100s' });
     var animation = div.getAnimations()[0];
 
     await animation.ready;
     ok(!SpecialPowers.wrap(animation).isRunningOnCompositor);
 
     // We need to tweak expected restyle count depending on animation state and
@@ -268,30 +230,24 @@ waitForAllPaints(() => {
     var animation = div.getAnimations()[0];
 
     await animation.ready;
     ok(SpecialPowers.wrap(animation).isRunningOnCompositor);
 
     animation.finish();
 
     var markers = await observeStyling(1);
-    if (!hasConformantPromiseHandling) {
-      todo_is(markers.length, 1,
-              'Bug 1415457: Animations running on the compositor should only ' +
-              'update style once after finish() is called');
-    } else {
-      is(markers.length, 1,
-         'Animations running on the compositor should only update style once ' +
-         'after finish() is called');
+    is(markers.length, 1,
+       'Animations running on the compositor should only update style once ' +
+       'after finish() is called');
 
-      markers = await observeStyling(1);
-      todo_is(markers.length, 0,
-              'Bug 1415457: Animations running on the compositor should only ' +
-              'update style once after finish() is called');
-    }
+    markers = await observeStyling(1);
+    todo_is(markers.length, 0,
+            'Bug 1415457: Animations running on the compositor should only ' +
+            'update style once after finish() is called');
 
     markers = await observeStyling(5);
     is(markers.length, 0,
        'Finished animations should never update style after one ' +
        'restyle happened for finish()');
 
     await ensureElementRemoval(div);
   });
@@ -419,71 +375,16 @@ waitForAllPaints(() => {
          'restyles even if the animation has missing keyframes');
 
       await ensureElementRemoval(parentElement);
     }
   );
 
   add_task(
     async function restyling_transform_animations_in_scrolled_out_element() {
-      if (hasConformantPromiseHandling) {
-        return;
-      }
-
-      // Skip this test on Android since this test have been failing
-      // intermittently.
-      // Bug 1413817: We should audit this test still fails once we have the
-      // conformant Promise micro task.
-      if (isAndroid) {
-        return;
-      }
-
-      await SpecialPowers.pushPrefEnv({ set: [["ui.showHideScrollbars", 1]] });
-
-      var parentElement = addDiv(null,
-        { style: 'overflow-y: scroll; height: 20px;' });
-      var div = addDiv(null,
-        { style: 'animation: rotate 100s infinite; position: relative; top: 100px;' });
-      parentElement.appendChild(div);
-      var animation = div.getAnimations()[0];
-      var timeAtStart = document.timeline.currentTime;
-
-      ok(!animation.isRunningOnCompositor,
-         'The transform animation is not running on the compositor');
-
-      var markers;
-      var now;
-      while (true) {
-        markers = await observeStyling(1);
-        // Check restyle markers until 200ms is elapsed.
-        now = document.timeline.currentTime;
-        if ((now - timeAtStart) >= 200) {
-          break;
-        }
-
-        is(markers.length, 0,
-           'Transform animation running on the element which is scrolled out ' +
-           'should be throttled until 200ms is elapsed');
-      }
-
-      is(markers.length, 1,
-         'Transform animation running on the element which is scrolled out ' +
-         'should be unthrottled after around 200ms have elapsed. now: ' +
-         now + ' start time: ' + timeAtStart);
-
-      await ensureElementRemoval(parentElement);
-    }
-  );
-
-  add_task(
-    async function restyling_transform_animations_in_scrolled_out_element() {
-      if (!hasConformantPromiseHandling) {
-        return;
-      }
-
       await SpecialPowers.pushPrefEnv({ set: [["ui.showHideScrollbars", 1]] });
 
       // Make sure we start from the state right after requestAnimationFrame.
       await waitForFrame();
 
       var parentElement = addDiv(null,
         { style: 'overflow-y: scroll; height: 20px;' });
       var div = addDiv(null,
@@ -520,70 +421,16 @@ waitForAllPaints(() => {
          now + ' start time: ' + timeAtStart);
 
       await ensureElementRemoval(parentElement);
     }
   );
 
   add_task(
     async function restyling_out_of_view_transform_animations_in_another_element() {
-      if (hasConformantPromiseHandling) {
-        return;
-      }
-
-      // Skip this test on Android since this test have been failing
-      // intermittently.
-      // Bug 1413817: We should audit this test still fails once we have the
-      // conformant Promise micro task.
-      if (isAndroid) {
-        return;
-      }
-
-      var parentElement = addDiv(null,
-        { style: 'overflow: hidden;' });
-      var div = addDiv(null,
-        { style: 'animation: move-in 100s infinite;' });
-      parentElement.appendChild(div);
-      var animation = div.getAnimations()[0];
-      var timeAtStart = document.timeline.currentTime;
-
-      ok(!animation.isRunningOnCompositor,
-         'The transform animation on out of view element ' +
-         'is not running on the compositor');
-
-      var markers;
-      var now;
-      while (true) {
-        markers = await observeStyling(1);
-        // Check restyle markers until 200ms is elapsed.
-        now = document.timeline.currentTime;
-        if ((now - timeAtStart) >= 200) {
-          break;
-        }
-
-        is(markers.length, 0,
-           'Transform animation running on out of view element ' +
-           'should be throttled until 200ms is elapsed');
-      }
-
-      is(markers.length, 1,
-         'Transform animation running on out of view element ' +
-         'should be unthrottled after around 200ms have elapsed. now: ' +
-         now + ' start time: ' + timeAtStart);
-
-      await ensureElementRemoval(parentElement);
-    }
-  );
-
-  add_task(
-    async function restyling_out_of_view_transform_animations_in_another_element() {
-      if (!hasConformantPromiseHandling) {
-        return;
-      }
-
       // Make sure we start from the state right after requestAnimationFrame.
       await waitForFrame();
 
       var parentElement = addDiv(null,
         { style: 'overflow: hidden;' });
       var div = addDiv(null,
         { style: 'animation: move-in 100s infinite;' });
       parentElement.appendChild(div);