Bug 1379515 - Unify test cases that checks animation are/were in scrolled out elements. r?birtles draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Sat, 28 Oct 2017 18:37:36 +0900
changeset 688155 5a79b887c2123e9b1cf40abaa4dcc8beb41d14f1
parent 688154 c16bc8097c102cdd2b70d8e7db3656222455a6ed
child 688156 c0e0406bddccdde06aee71c43d24f464bb5cc514
push id86669
push userhikezoe@mozilla.com
push dateSat, 28 Oct 2017 10:13:18 +0000
reviewersbirtles
bugs1379515
milestone58.0a1
Bug 1379515 - Unify test cases that checks animation are/were in scrolled out elements. r?birtles It much makes more sence to check the animation in out-of-view is throttled and unthrottled once it got visible in a single test. MozReview-Commit-ID: AZY5Xc0cbDF
dom/animation/test/chrome/test_restyles.html
--- a/dom/animation/test/chrome/test_restyles.html
+++ b/dom/animation/test/chrome/test_restyles.html
@@ -269,17 +269,17 @@ waitForAllPaints(function() {
 
     is(markers.length, 0,
        'Animations running on the compositor for elements ' +
        'which are scrolled out should never cause restyles');
 
     await ensureElementRemoval(parentElement);
   });
 
-  add_task(async function no_restyling_main_thread_animations_in_scrolled_out_element() {
+  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.
      */
@@ -296,20 +296,37 @@ waitForAllPaints(function() {
 
     await animation.ready;
     var markers = await observeStyling(5);
 
     is(markers.length, 0,
        'Animations running on the main-thread for elements ' +
        'which are scrolled out should never cause restyles');
 
+    var parentRect = parentElement.getBoundingClientRect();
+    var centerX = parentRect.left + parentRect.width / 2;
+    var centerY = parentRect.top + parentRect.height / 2;
+
+    var markers = await observeStyling(1, function() {
+      // We can't use synthesizeWheel here since synthesizeWheel causes
+      // layout flush.
+      synthesizeWheelAtPoint(centerX, centerY,
+                             { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
+                               deltaY: 100 });
+    });
+
+    is(markers.length, 1,
+       'Animations running on the main-thread which were in scrolled out ' +
+       'elements should update restyling soon after the element moved in ' +
+       'view by scrolling');
+
     await ensureElementRemoval(parentElement);
   });
 
-  add_task(async function no_restyling_main_thread_animations_in_nested_scrolled_out_element() {
+  add_task(async function restyling_main_thread_animations_in_nested_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.
      */
@@ -332,16 +349,34 @@ waitForAllPaints(function() {
 
     await animation.ready;
     var markers = await observeStyling(5);
 
     is(markers.length, 0,
        'Animations running on the main-thread which are in nested elements ' +
        'which are scrolled out should never cause restyles');
 
+    var parentRect = grandParent.getBoundingClientRect();
+    var centerX = parentRect.left + parentRect.width / 2;
+    var centerY = parentRect.top + parentRect.height / 2;
+
+    var markers = await observeStyling(1, function() {
+      // We can't use synthesizeWheel here since synthesizeWheel causes
+      // layout flush.
+      synthesizeWheelAtPoint(centerX, centerY,
+                             { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
+                               deltaY: 100 });
+    });
+
+    // FIXME: We should reduce a redundant restyle here.
+    ok(markers.length >= 1,
+       'Animations running on the main-thread which were in nested scrolled ' +
+       'out elements should update restyle soon after the element moved ' +
+       'in view by scrolling');
+
     await ensureElementRemoval(grandParent);
   });
 
   add_task_if_omta_enabled(async function no_restyling_compositor_animations_in_visiblily_hidden_element() {
     var div = addDiv(null,
      { style: 'animation: opacity 100s; visibility: hidden' });
     var animation = div.getAnimations()[0];
 
@@ -351,96 +386,16 @@ waitForAllPaints(function() {
     var markers = await observeStyling(5);
 
     todo_is(markers.length, 0,
             'Bug 1237454: Animations running on the compositor in ' +
             'visibility hidden element should never cause restyles');
     await ensureElementRemoval(div);
   });
 
-  add_task(async function restyling_main_thread_animations_moved_in_view_by_scrolling() {
-    if (!offscreenThrottlingEnabled) {
-      return;
-    }
-
-    /*
-     On Android throttled animations are left behind on the main thread in some
-     frames, We will fix this in bug 1247800.
-     */
-    if (isAndroid) {
-      return;
-    }
-
-    var parentElement = addDiv(null,
-      { style: 'overflow-y: scroll; height: 20px;' });
-    var div = addDiv(null,
-      { style: 'animation: background-color 100s; position: relative; top: 100px;' });
-    parentElement.appendChild(div);
-    var animation = div.getAnimations()[0];
-
-    var parentRect = parentElement.getBoundingClientRect();
-    var centerX = parentRect.left + parentRect.width / 2;
-    var centerY = parentRect.top + parentRect.height / 2;
-
-    await animation.ready;
-
-    var markers = await observeStyling(1, function() {
-      // We can't use synthesizeWheel here since synthesizeWheel causes
-      // layout flush.
-      synthesizeWheelAtPoint(centerX, centerY,
-                             { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
-                               deltaY: 100 });
-    });
-
-    is(markers.length, 1,
-       'Animations running on the main-thread which were in scrolled out ' +
-       'elements should update restyling soon after the element moved in ' +
-       'view by scrolling');
-
-    await ensureElementRemoval(parentElement);
-  });
-
-  add_task(async function restyling_main_thread_animations_moved_in_view_by_scrolling() {
-    if (!offscreenThrottlingEnabled) {
-      return;
-    }
-
-    var grandParent = addDiv(null,
-      { style: 'overflow-y: scroll; height: 20px;' });
-    var parentElement = addDiv(null,
-      { style: 'overflow-y: scroll; height: 200px;' });
-    var div = addDiv(null,
-      { style: 'animation: background-color 100s; position: relative; top: 100px;' });
-    grandParent.appendChild(parentElement);
-    parentElement.appendChild(div);
-    var animation = div.getAnimations()[0];
-
-    var parentRect = grandParent.getBoundingClientRect();
-    var centerX = parentRect.left + parentRect.width / 2;
-    var centerY = parentRect.top + parentRect.height / 2;
-
-    await animation.ready;
-
-    var markers = await observeStyling(1, function() {
-      // We can't use synthesizeWheel here since synthesizeWheel causes
-      // layout flush.
-      synthesizeWheelAtPoint(centerX, centerY,
-                             { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
-                               deltaY: 100 });
-    });
-
-    // FIXME: We should reduce a redundant restyle here.
-    ok(markers.length >= 1,
-       'Animations running on the main-thread which were in nested scrolled ' +
-       'out elements should update restyle soon after the element moved ' +
-       'in view by scrolling');
-
-    await ensureElementRemoval(grandParent);
-  });
-
   add_task(async function restyling_main_thread_animations_move_out_of_view_by_scrolling() {
     if (!offscreenThrottlingEnabled) {
       return;
     }
 
     /*
      On Android throttled animations are left behind on the main thread in some
      frames, We will fix this in bug 1247800.