Bug 1241692 - Part 1: Ensure that element which is added in each test is removed before subsequent test is processed. r=dholbert
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Sat, 06 Feb 2016 20:38:12 +0900
changeset 283394 df927d7001cdb96045f0fb4cc2f7a4415895e002
parent 283393 33f24d250f97b5150f798f90b60856cef8719514
child 283395 69f7ba132363aa783954f185a5c88b16582da924
push id29980
push userphilringnalda@gmail.com
push dateSun, 07 Feb 2016 23:30:48 +0000
treeherdermozilla-central@1cfe34ea394c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1241692
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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>