Bug 1413817 - Add a another variant of restyling_transform_animations_in_scrolled_out_element for the conformant Promise handling. r?birtles draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Thu, 09 Nov 2017 08:06:38 +0900
changeset 695303 9639e5647a44f48ed16ac9a826fe9e317f8447db
parent 695302 c6d142f1289b19e68e18ef7191f7c5334625d17c
child 695304 ce78d4e647d8a5598d9a95e0a0534383a7ddc734
push id88383
push userhikezoe@mozilla.com
push dateThu, 09 Nov 2017 00:26:11 +0000
reviewersbirtles
bugs1413817
milestone58.0a1
Bug 1413817 - Add a another variant of restyling_transform_animations_in_scrolled_out_element for the conformant Promise handling. r?birtles I did intentionally add the forked version of the function with the same name since branching depending on the conformant flag inside the original function will we be hard to understand and also we can easily remove the original version once we have the conformant Promise handling. FWIW, here is the diff between them: @@ -365,6 +365,9 @@ waitForAllPaints(() => { 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, @@ -379,13 +382,17 @@ waitForAllPaints(() => { 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) { + // If the current time has elapsed over 200ms since the animation was + // created, it means that the animation should have already + // unthrottled in this tick, let's see what observes in this tick's + // restyling process. + markers = await observeStyling(1); break; } + markers = await observeStyling(1); is(markers.length, 0, 'Transform animation running on the element which is scrolled out ' + 'should be throttled until 200ms is elapsed'); MozReview-Commit-ID: 3WfY6aVnsXk
dom/animation/test/mozilla/file_restyles.html
--- a/dom/animation/test/mozilla/file_restyles.html
+++ b/dom/animation/test/mozilla/file_restyles.html
@@ -354,16 +354,20 @@ waitForAllPaints(() => {
        'Animations running on the compositor for elements ' +
        'which are scrolled out should never cause restyles');
 
     await ensureElementRemoval(parentElement);
   });
 
   add_task(
     async function restyling_transform_animations_in_scrolled_out_element() {
+      if (hasConformantPromiseHandling) {
+        return;
+      }
+
       if (!offscreenThrottlingEnabled) {
         return;
       }
 
       await SpecialPowers.pushPrefEnv({ set: [["ui.showHideScrollbars", 1]] });
 
       var parentElement = addDiv(null,
         { style: 'overflow-y: scroll; height: 20px;' });
@@ -395,16 +399,70 @@ waitForAllPaints(() => {
          '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;
+      }
+
+      if (!offscreenThrottlingEnabled) {
+        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,
+        { style: 'animation: rotate 100s; 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) {
+        now = document.timeline.currentTime;
+        if ((now - timeAtStart) >= 200) {
+          // If the current time has elapsed over 200ms since the animation was
+          // created, it means that the animation should have already
+          // unthrottled in this tick, let's see what observes in this tick's
+          // restyling process.
+          markers = await observeStyling(1);
+          break;
+        }
+
+        markers = await observeStyling(1);
+        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_main_thread_animations_in_scrolled_out_element() {
     if (!offscreenThrottlingEnabled) {
       return;
     }
 
     /*
      On Android throttled animations are left behind on the main thread in some
      frames, We will fix this in bug 1247800.