Bug 1241692 - Part 1: Ensure that element which is added in each test is removed before subsequent test is processed. r?dholbert draft
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Sat, 06 Feb 2016 20:38:12 +0900
changeset 329415 c77f030fda0541c1cef06dda31c51dfa06fafeca
parent 329353 4295f9951e9331a2f2bd0a8ea8c4ad73af141a7b
child 329416 390b0bb74fe55286d47f299071dd51300bfa754a
push id10521
push userhiikezoe@mozilla-japan.org
push dateSat, 06 Feb 2016 22:03:17 +0000
reviewersdholbert
bugs1241692
milestone47.0a1
Bug 1241692 - Part 1: Ensure that element which is added in each test is removed before subsequent test is processed. r?dholbert Before this fix, sometimes an element which was removed in a prior test would still visible when subsequent test starts. We should wait for paints to complete after the element has been removed.
dom/animation/test/chrome/test_restyles.html
--- a/dom/animation/test/chrome/test_restyles.html
+++ b/dom/animation/test/chrome/test_restyles.html
@@ -48,16 +48,23 @@ function observeStyling(frameCount, onFr
       var stylingMarkers = markers.filter(function(marker, index) {
         return marker.name == 'Styles';
       });
       resolve(stylingMarkers);
     });
   });
 }
 
+function ensureElementRemoval(aElement) {
+  return new Promise(function(resolve) {
+    aElement.remove();
+    waitForAllPaintsFlushed(resolve);
+  });
+}
+
 SimpleTest.waitForExplicitFinish();
 
 const OMTAPrefKey = 'layers.offmainthreadcomposition.async-animations';
 var omtaEnabled = SpecialPowers.DOMWindowUtils.layerManagerRemote &&
                   SpecialPowers.getBoolPref(OMTAPrefKey);
 
 function add_task_if_omta_enabled(test) {
   if (!omtaEnabled) {
@@ -76,66 +83,66 @@ waitForAllPaints(function() {
 
     yield animation.ready;
     ok(animation.isRunningOnCompositor);
 
     var markers = yield observeStyling(5);
     is(markers.length, 0,
        'CSS animations running on the compositor should not update style ' +
        'on the main thread');
-    div.remove();
+    yield ensureElementRemoval(div);
   });
 
   add_task_if_omta_enabled(function* no_restyling_for_compositor_transitions() {
     var div = addDiv(null, { style: 'transition: opacity 100s; opacity: 0' });
     getComputedStyle(div).opacity;
     div.style.opacity = 1;
 
     var animation = div.getAnimations()[0];
 
     yield animation.ready;
     ok(animation.isRunningOnCompositor);
 
     var markers = yield observeStyling(5);
     is(markers.length, 0,
        'CSS transitions running on the compositor should not update style ' +
        'on the main thread');
-    div.remove();
+    yield ensureElementRemoval(div);
   });
 
   add_task_if_omta_enabled(function* no_restyling_when_animation_duration_is_changed() {
     var div = addDiv(null, { style: 'animation: opacity 100s' });
     var animation = div.getAnimations()[0];
 
     yield animation.ready;
     ok(animation.isRunningOnCompositor);
 
     div.animationDuration = '200s';
 
     var markers = yield observeStyling(5);
     is(markers.length, 0,
        'Animations running on the compositor should not update style ' +
        'on the main thread');
-    div.remove();
+    yield ensureElementRemoval(div);
   });
 
   add_task_if_omta_enabled(function* only_one_restyling_after_finish_is_called() {
     var div = addDiv(null, { style: 'animation: opacity 100s' });
     var animation = div.getAnimations()[0];
 
     yield animation.ready;
     ok(animation.isRunningOnCompositor);
 
     animation.finish();
 
     var markers = yield observeStyling(5);
     is(markers.length, 1,
        'Animations running on the compositor should only update style ' +
        'once after finish() is called');
-    div.remove();
+    yield ensureElementRemoval(div);
   });
 
   add_task(function* no_restyling_mouse_movement_on_finished_transition() {
     var div = addDiv(null, { style: 'transition: opacity 1ms; opacity: 0' });
     getComputedStyle(div).opacity;
     div.style.opacity = 1;
 
     var animation = div.getAnimations()[0];
@@ -150,17 +157,17 @@ waitForAllPaints(function() {
       // layout flush.
       synthesizeMouseAtPoint(mouseX++, mouseY++,
                              { type: 'mousemove' }, window);
     });
 
     is(markers.length, 0,
        'Bug 1219236: Finished transitions should never cause restyles ' +
        'when mouse is moved on the animations');
-    div.remove();
+    yield ensureElementRemoval(div);
   });
 
   add_task(function* no_restyling_mouse_movement_on_finished_animation() {
     var div = addDiv(null, { style: 'animation: opacity 1ms' });
     var animation = div.getAnimations()[0];
 
     var initialRect = div.getBoundingClientRect();
 
@@ -173,47 +180,47 @@ waitForAllPaints(function() {
       // layout flush.
       synthesizeMouseAtPoint(mouseX++, mouseY++,
                              { type: 'mousemove' }, window);
     });
 
     is(markers.length, 0,
        'Bug 1219236: Finished animations should never cause restyles ' +
        'when mouse is moved on the animations');
-    div.remove();
+    yield ensureElementRemoval(div);
   });
 
   add_task_if_omta_enabled(function* no_restyling_compositor_animations_out_of_view_element() {
     var div = addDiv(null,
       { style: 'animation: opacity 100s; transform: translateY(-400px);' });
     var animation = div.getAnimations()[0];
 
     yield animation.ready;
     ok(!animation.isRunningOnCompositor);
 
     var markers = yield observeStyling(5);
 
     todo_is(markers.length, 0,
             'Bug 1166500: Animations running on the compositor in out of ' +
             'view element should never cause restyles');
-    div.remove();
+    yield ensureElementRemoval(div);
   });
 
   add_task(function* no_restyling_main_thread_animations_out_of_view_element() {
     var div = addDiv(null,
       { style: 'animation: background-color 100s; transform: translateY(-400px);' });
     var animation = div.getAnimations()[0];
 
     yield animation.ready;
     var markers = yield observeStyling(5);
 
     todo_is(markers.length, 0,
             'Bug 1166500: Animations running on the main-thread in out of ' +
             'view element should never cause restyles');
-    div.remove();
+    yield ensureElementRemoval(div);
   });
 
   /*
    Disabled for now since, on Android, the opacity animation runs on the
    compositor even if it is scrolled out of view.
    We will fix this in bug 1166500 or a follow-up bug
   add_task_if_omta_enabled(function* no_restyling_compositor_animations_in_scrolled_out_element() {
     var parentElement = addDiv(null,
@@ -226,17 +233,17 @@ waitForAllPaints(function() {
     yield animation.ready;
     ok(!animation.isRunningOnCompositor);
 
     var markers = yield observeStyling(5);
 
     todo_is(markers.length, 0,
             'Bug 1166500: Animations running on the compositor in elements ' +
             'which are scrolled out should never cause restyles');
-    parentElement.remove(div);
+    yield ensureElementRemoval(parentElement);
   });
   */
 
   add_task(function* no_restyling_main_thread_animations_in_scrolled_out_element() {
     var parentElement = addDiv(null,
       { style: 'overflow-y: scroll; height: 20px;' });
     var div = addDiv(null,
       { style: 'animation: background-color 100s; position: relative; top: 100px;' });
@@ -244,17 +251,17 @@ waitForAllPaints(function() {
     var animation = div.getAnimations()[0];
 
     yield animation.ready;
     var markers = yield observeStyling(5);
 
     todo_is(markers.length, 0,
             'Bug 1166500: Animations running on the main-thread in elements ' +
             'which are scrolled out should never cause restyles');
-    parentElement.remove();
+    yield ensureElementRemoval(parentElement);
   });
 
   /*
    Disabled for now since, on Android and B2G, the opacity animation runs on the
    compositor even if the associated element has visibility:hidden.
    We will fix this in bug 1237454 or a follow-up bug.
   add_task_if_omta_enabled(function* no_restyling_compositor_animations_in_visiblily_hidden_element() {
     var div = addDiv(null,
@@ -264,32 +271,32 @@ waitForAllPaints(function() {
     yield animation.ready;
     ok(!animation.isRunningOnCompositor);
 
     var markers = yield observeStyling(5);
 
     todo_is(markers.length, 0,
             'Bug 1237454: Animations running on the compositor in ' +
             'visibility hidden element should never cause restyles');
-    div.remove();
+    yield ensureElementRemoval(div);
   });
   */
 
   add_task(function* no_restyling_main_thread_animations_in_visiblily_hidden_element() {
     var div = addDiv(null,
      { style: 'animation: background-color 100s; visibility: hidden' });
     var animation = div.getAnimations()[0];
 
     yield animation.ready;
     var markers = yield observeStyling(5);
 
     todo_is(markers.length, 0,
             'Bug 1237454: Animations running on the main-thread in ' +
             'visibility hidden element should never cause restyles');
-    div.remove();
+    yield ensureElementRemoval(div);
   });
 
   add_task_if_omta_enabled(function* no_restyling_compositor_animations_after_pause_is_called() {
     var div = addDiv(null, { style: 'animation: opacity 100s' });
     var animation = div.getAnimations()[0];
 
     yield animation.ready;
     ok(animation.isRunningOnCompositor);
@@ -297,47 +304,47 @@ waitForAllPaints(function() {
     animation.pause();
 
     yield animation.ready;
 
     var markers = yield observeStyling(5);
     is(markers.length, 0,
        'Bug 1232563: Paused animations running on the compositor should ' +
        'never cause restyles once after pause() is called');
-    div.remove();
+    yield ensureElementRemoval(div);
   });
 
   add_task(function* no_restyling_main_thread_animations_after_pause_is_called() {
     var div = addDiv(null, { style: 'animation: background-color 100s' });
     var animation = div.getAnimations()[0];
 
     yield animation.ready;
 
     animation.pause();
 
     yield animation.ready;
 
     var markers = yield observeStyling(5);
     is(markers.length, 0,
        'Bug 1232563: Paused animations running on the main-thread should ' +
        'never cause restyles after pause() is called');
-    div.remove();
+    yield ensureElementRemoval(div);
   });
 
   add_task_if_omta_enabled(function* only_one_restyling_when_current_time_is_set_to_middle_of_duration() {
     var div = addDiv(null, { style: 'animation: opacity 100s' });
     var animation = div.getAnimations()[0];
 
     yield animation.ready;
 
     animation.currentTime = 50000; // 50s
 
     var markers = yield observeStyling(5);
     is(markers.length, 1,
        'Bug 1235478: Animations running on the compositor should only once ' +
        'update style when currentTime is set to middle of duration time');
-    div.remove();
+    yield ensureElementRemoval(div);
   });
 
 });
 
 </script>
 </body>