Bug 1379515 - Unify test cases that checks animation are/were in scrolled out elements. r?birtles draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Mon, 30 Oct 2017 09:42:56 +0900
changeset 688368 e3056394e59a58a9ef9ff8a6fb8aad0b8121d63f
parent 688299 c83100c88242aba3593102b99ece7f8073f93177
child 688369 74c92e02094c313a45e75f2fedb473f0541a17b9
push id86728
push userhikezoe@mozilla.com
push dateMon, 30 Oct 2017 01:20:23 +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 sense 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,39 @@ 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');
 
+    // Get the scrollable parent element position in this window coordinate
+    // system to send a wheel event to the element.
+    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: parentRect.height });
+    });
+
+    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 +351,36 @@ 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');
 
+    // Get the scrollable parent element position in this window coordinate
+    // system to send a wheel event to the element.
+    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: parentRect.height });
+    });
+
+    // 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 +390,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.