Bug 1237454 - Test for an animation on visibility: hidden element which has grandchild. r?boris draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Fri, 09 Feb 2018 10:43:10 +0900
changeset 752908 00e9b906be02cea0eca5abc1e21f0bc2ac4ba873
parent 752907 dde7ec2c2fa27642a92f695240c907f8fe7839a1
child 752909 8f88656d4bef12a61385680fde4b7ff490dc80d6
push id98428
push userbmo:hikezoe@mozilla.com
push dateFri, 09 Feb 2018 10:01:48 +0000
reviewersboris
bugs1237454
milestone60.0a1
Bug 1237454 - Test for an animation on visibility: hidden element which has grandchild. r?boris MozReview-Commit-ID: C0yLy4clwbY
dom/animation/test/mozilla/file_restyles.html
--- a/dom/animation/test/mozilla/file_restyles.html
+++ b/dom/animation/test/mozilla/file_restyles.html
@@ -831,16 +831,143 @@ waitForAllPaints(() => {
       todo_is(markers.length, 0,
               'Animations running on visibility hidden element should throttle ' +
               'restyling again after all visible descendants were removed');
 
       await ensureElementRemoval(div);
     }
   );
 
+  add_task(
+    async function restyling_animations_on_visibility_hidden_element_having_grandchild() {
+      // element tree:
+      //
+      //        root(visibility:hidden)
+      //       /                       \
+      //    childA                   childB
+      //    /     \                 /      \
+      //  AA       AB             BA        BB
+
+      var div = addDiv(null,
+       { style: 'animation: background-color 100s; visibility: hidden' });
+
+      var childA = addDiv(null);
+      div.appendChild(childA);
+      var childB = addDiv(null);
+      div.appendChild(childB);
+
+      var grandchildAA = addDiv(null);
+      childA.appendChild(grandchildAA);
+      var grandchildAB = addDiv(null);
+      childA.appendChild(grandchildAB);
+
+      var grandchildBA = addDiv(null);
+      childB.appendChild(grandchildBA);
+      var grandchildBB = addDiv(null);
+      childB.appendChild(grandchildBB);
+
+      var animation = div.getAnimations()[0];
+
+      await animation.ready;
+      var markers = await observeStyling(5);
+      todo_is(markers.length, 0,
+              'Animations on visibility hidden element having no visible ' +
+              'descendants should never cause restyles');
+
+      childA.style.visibility = 'visible';
+      grandchildAA.style.visibility = 'visible';
+      grandchildAB.style.visibility = 'visible';
+      await waitForNextFrame();
+
+      var markers = await observeStyling(5);
+      is(markers.length, 5,
+         'Animations running on visibility hidden element but the element has ' +
+         'visible children should not throttle restyling');
+
+      // Make childA hidden again but both of grandchildAA and grandchildAB are
+      // still visible.
+      childA.style.visibility = 'hidden';
+      await waitForNextFrame();
+
+      var markers = await observeStyling(5);
+      is(markers.length, 5,
+         'Animations running on visibility hidden element that a child has ' +
+         'become invisible again but there are still visible children should ' +
+         'not throttle restyling');
+
+      // Make grandchildAA hidden but grandchildAB is still visible.
+      grandchildAA.style.visibility = 'hidden';
+      await waitForNextFrame();
+
+      var markers = await observeStyling(5);
+      is(markers.length, 5,
+         'Animations running on visibility hidden element that a grandchild ' +
+         'become invisible again but another grandchild is still visible ' +
+         'should not throttle restyling');
+
+
+      // Make childB and grandchildBA visible.
+      childB.style.visibility = 'visible';
+      grandchildBA.style.visibility = 'visible';
+      await waitForNextFrame();
+
+      var markers = await observeStyling(5);
+      is(markers.length, 5,
+         'Animations running on visibility hidden element but the element has ' +
+         'visible descendants should not throttle restyling');
+
+      // Make childB hidden but grandchildAB and grandchildBA are still visible.
+      childB.style.visibility = 'hidden';
+      await waitForNextFrame();
+
+      var markers = await observeStyling(5);
+      is(markers.length, 5,
+         'Animations running on visibility hidden element but the element has ' +
+         'visible grandchildren should not throttle restyling');
+
+      // Make grandchildAB hidden but grandchildBA is still visible.
+      grandchildAB.style.visibility = 'hidden';
+      await waitForNextFrame();
+
+      var markers = await observeStyling(5);
+      is(markers.length, 5,
+         'Animations running on visibility hidden element but the element has ' +
+         'a visible grandchild should not throttle restyling');
+
+      // Make grandchildBA hidden. Now all descedants are invisible.
+      grandchildBA.style.visibility = 'hidden';
+      await waitForNextFrame();
+
+      var markers = await observeStyling(5);
+      todo_is(markers.length, 0,
+              'Animations on visibility hidden element that all descendants have ' +
+              'become invisible again should never cause restyles');
+
+      // Make childB visible.
+      childB.style.visibility = 'visible';
+      await waitForNextFrame();
+
+      var markers = await observeStyling(5);
+      is(markers.length, 5,
+         'Animations on visibility hidden element that has a visible child ' +
+         'should never cause restyles');
+
+      // Make childB invisible again
+      childB.style.visibility = 'hidden';
+      await waitForNextFrame();
+
+      var markers = await observeStyling(5);
+      todo_is(markers.length, 0,
+              'Animations on visibility hidden element that the visible child ' +
+              'has become invisible again should never cause restyles');
+
+      await ensureElementRemoval(div);
+    }
+  );
+
   add_task_if_omta_enabled(async function no_restyling_compositor_animations_after_pause_is_called() {
     var div = addDiv(null, { style: 'animation: opacity 100s' });
     var animation = div.getAnimations()[0];
 
     await animation.ready;
     ok(SpecialPowers.wrap(animation).isRunningOnCompositor);
 
     animation.pause();