Bug 1379515 - Run test_restyls.html in content. r?birtles draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Sat, 28 Oct 2017 18:37:39 +0900
changeset 688160 11703c7f997b9ee043901bb51c57b9083137b960
parent 688159 719f3bbb2a6afabcdf96c5b7fef4b596bef9266d
child 688161 602c2719ff3e6c91a395729ee95627d208241a99
push id86669
push userhikezoe@mozilla.com
push dateSat, 28 Oct 2017 10:13:18 +0000
reviewersbirtles
bugs1379515
milestone58.0a1
Bug 1379515 - Run test_restyls.html in content. r?birtles MozReview-Commit-ID: 7PPYQYBIo5Y
dom/animation/test/chrome.ini
dom/animation/test/chrome/test_restyles.html
dom/animation/test/mochitest.ini
dom/animation/test/mozilla/file_restyles.html
dom/animation/test/mozilla/test_restyles.html
--- a/dom/animation/test/chrome.ini
+++ b/dom/animation/test/chrome.ini
@@ -9,13 +9,11 @@ support-files =
 # file_animate_xrays.html needs to go in mochitest.ini since it is served
 # over HTTP
 [chrome/test_animation_observers_async.html]
 [chrome/test_animation_observers_sync.html]
 [chrome/test_animation_performance_warning.html]
 [chrome/test_animation_properties.html]
 [chrome/test_cssanimation_missing_keyframes.html]
 [chrome/test_generated_content_getAnimations.html]
-[chrome/test_restyles.html]
-skip-if = os == 'android' # bug 1335986
 [chrome/test_running_on_compositor.html]
 [chrome/test_simulate_compute_values_failure.html]
 skip-if = !debug
--- a/dom/animation/test/mochitest.ini
+++ b/dom/animation/test/mochitest.ini
@@ -43,16 +43,17 @@ support-files =
   mozilla/xhr_doc.html
   mozilla/file_cubic_bezier_limits.html
   mozilla/file_deferred_start.html
   mozilla/file_disabled_properties.html
   mozilla/file_disable_animations_api_core.html
   mozilla/file_discrete-animations.html
   mozilla/file_document-timeline-origin-time-range.html
   mozilla/file_hide_and_show.html
+  mozilla/file_restyles.html
   mozilla/file_restyling_xhr_doc.html
   mozilla/file_set-easing.html
   mozilla/file_transform_limits.html
   mozilla/file_transition_finish_on_compositor.html
   mozilla/file_underlying-discrete-value.html
   style/file_animation-seeking-with-current-time.html
   style/file_animation-seeking-with-start-time.html
   style/file_animation-setting-effect.html
@@ -107,16 +108,18 @@ support-files =
 [mozilla/test_disabled_properties.html]
 [mozilla/test_discrete-animations.html]
 [mozilla/test_distance_of_basic_shape.html]
 [mozilla/test_distance_of_filter.html]
 [mozilla/test_distance_of_transform.html]
 [mozilla/test_document-timeline-origin-time-range.html]
 [mozilla/test_hide_and_show.html]
 [mozilla/test_moz-prefixed-properties.html]
+[mozilla/test_restyles.html]
+skip-if = os == 'android' # bug 1335986
 [mozilla/test_restyling_xhr_doc.html]
 [mozilla/test_set-easing.html]
 [mozilla/test_transform_limits.html]
 [mozilla/test_transition_finish_on_compositor.html]
 skip-if = toolkit == 'android'
 [mozilla/test_underlying-discrete-value.html]
 [style/test_animation-seeking-with-current-time.html]
 [style/test_animation-seeking-with-start-time.html]
rename from dom/animation/test/chrome/test_restyles.html
rename to dom/animation/test/mozilla/file_restyles.html
--- a/dom/animation/test/chrome/test_restyles.html
+++ b/dom/animation/test/mozilla/file_restyles.html
@@ -1,18 +1,30 @@
 <!doctype html>
 <head>
 <meta charset=utf-8>
 <title>Tests restyles caused by animations</title>
-<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
-<script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
-<script src="chrome://mochikit/content/tests/SimpleTest/paint_listener.js"></script>
+<script>
+var ok = opener.ok.bind(opener);
+var is = opener.is.bind(opener);
+var todo = opener.todo.bind(opener);
+var todo_is = opener.todo_is.bind(opener);
+var info = opener.info.bind(opener);
+var original_finish = opener.SimpleTest.finish;
+var SimpleTest = opener.SimpleTest;
+SimpleTest.finish = function finish() {
+  self.close();
+  original_finish();
+}
+</script>
+<script src="/tests/SimpleTest/EventUtils.js"></script>
+<script src="/tests/SimpleTest/SpawnTask.js"></script>
+<script src="/tests/SimpleTest/paint_listener.js"></script>
 <script src="../testcommon.js"></script>
-<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
+<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
 <style>
 @keyframes opacity {
   from { opacity: 1; }
   to { opacity: 0; }
 }
 @keyframes background-color {
   from { background-color: red; }
   to { background-color: blue; }
@@ -29,19 +41,21 @@ div {
 }
 </style>
 </head>
 <body>
 <script>
 'use strict';
 
 function observeStyling(frameCount, onFrame) {
-  var docShell = window.QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
-                       .getInterface(SpecialPowers.Ci.nsIWebNavigation)
-                       .QueryInterface(SpecialPowers.Ci.nsIDocShell);
+  var docShell =
+    SpecialPowers.wrap(window)
+                 .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
+                 .getInterface(SpecialPowers.Ci.nsIWebNavigation)
+                 .QueryInterface(SpecialPowers.Ci.nsIDocShell);
 
   docShell.recordProfileTimelineMarkers = true;
   docShell.popProfileTimelineMarkers();
 
   return new Promise(function(resolve) {
     return waitForAnimationFrames(frameCount, onFrame).then(function() {
       var markers = docShell.popProfileTimelineMarkers();
       docShell.recordProfileTimelineMarkers = false;
@@ -64,19 +78,16 @@ function waitForWheelEvent(aTarget, cent
   return new Promise(function(resolve, reject) {
     sendWheelAndPaintNoFlush(aTarget, centerX, centerY,
                              { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
                                deltaY: 100 },
                              resolve);
   });
 }
 
-SimpleTest.expectAssertions(0, 1); // bug 1332970
-SimpleTest.waitForExplicitFinish();
-
 var omtaEnabled = isOMTAEnabled();
 
 var isAndroid = !!navigator.userAgent.includes("Android");
 var isServo = isStyledByServo();
 var offscreenThrottlingEnabled =
   SpecialPowers.getBoolPref('dom.animations.offscreen-throttling');
 
 function add_task_if_omta_enabled(test) {
@@ -90,78 +101,78 @@ function add_task_if_omta_enabled(test) 
 // We need to wait for all paints before running tests to avoid contaminations
 // from styling of this document itself.
 waitForAllPaints(function() {
   add_task(async function restyling_for_main_thread_animations() {
     var div = addDiv(null, { style: 'animation: background-color 100s' });
     var animation = div.getAnimations()[0];
 
     await animation.ready;
-    ok(!animation.isRunningOnCompositor);
+    ok(!SpecialPowers.wrap(animation).isRunningOnCompositor);
 
     var markers = await observeStyling(5);
     is(markers.length, 5,
        'CSS animations running on the main-thread should update style ' +
        'on the main thread');
     await ensureElementRemoval(div);
   });
 
   add_task_if_omta_enabled(async function no_restyling_for_compositor_animations() {
     var div = addDiv(null, { style: 'animation: opacity 100s' });
     var animation = div.getAnimations()[0];
 
     await animation.ready;
-    ok(animation.isRunningOnCompositor);
+    ok(SpecialPowers.wrap(animation).isRunningOnCompositor);
 
     var markers = await observeStyling(5);
     is(markers.length, 0,
        'CSS animations running on the compositor should not update style ' +
        'on the main thread');
     await ensureElementRemoval(div);
   });
 
   add_task_if_omta_enabled(async 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];
 
     await animation.ready;
-    ok(animation.isRunningOnCompositor);
+    ok(SpecialPowers.wrap(animation).isRunningOnCompositor);
 
     var markers = await observeStyling(5);
     is(markers.length, 0,
        'CSS transitions running on the compositor should not update style ' +
        'on the main thread');
     await ensureElementRemoval(div);
   });
 
   add_task_if_omta_enabled(async function no_restyling_when_animation_duration_is_changed() {
     var div = addDiv(null, { style: 'animation: opacity 100s' });
     var animation = div.getAnimations()[0];
 
     await animation.ready;
-    ok(animation.isRunningOnCompositor);
+    ok(SpecialPowers.wrap(animation).isRunningOnCompositor);
 
     div.animationDuration = '200s';
 
     var markers = await observeStyling(5);
     is(markers.length, 0,
        'Animations running on the compositor should not update style ' +
        'on the main thread');
     await ensureElementRemoval(div);
   });
 
   add_task_if_omta_enabled(async function only_one_restyling_after_finish_is_called() {
     var div = addDiv(null, { style: 'animation: opacity 100s' });
     var animation = div.getAnimations()[0];
 
     await animation.ready;
-    ok(animation.isRunningOnCompositor);
+    ok(SpecialPowers.wrap(animation).isRunningOnCompositor);
 
     animation.finish();
 
     var markers = await observeStyling(5);
     is(markers.length, 1,
        'Animations running on the compositor should only update style ' +
        'once after finish() is called');
     await ensureElementRemoval(div);
@@ -220,17 +231,17 @@ waitForAllPaints(function() {
       return;
     }
 
     var div = addDiv(null,
       { style: 'animation: opacity 100s; transform: translateY(-400px);' });
     var animation = div.getAnimations()[0];
 
     await animation.ready;
-    ok(!animation.isRunningOnCompositor);
+    ok(!SpecialPowers.wrap(animation).isRunningOnCompositor);
 
     var markers = await observeStyling(5);
 
     is(markers.length, 0,
        'Animations running on the compositor in an out-of-view element ' +
        'should never cause restyles');
     await ensureElementRemoval(div);
   });
@@ -374,17 +385,17 @@ waitForAllPaints(function() {
   });
 
   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];
 
     await animation.ready;
-    ok(!animation.isRunningOnCompositor);
+    ok(!SpecialPowers.wrap(animation).isRunningOnCompositor);
 
     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);
   });
@@ -470,17 +481,17 @@ waitForAllPaints(function() {
     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(animation.isRunningOnCompositor);
+    ok(SpecialPowers.wrap(animation).isRunningOnCompositor);
 
     animation.pause();
 
     await animation.ready;
 
     var markers = await observeStyling(5);
     is(markers.length, 0,
        'Bug 1232563: Paused animations running on the compositor should ' +
@@ -520,23 +531,23 @@ waitForAllPaints(function() {
     await ensureElementRemoval(div);
   });
 
   add_task_if_omta_enabled(async function change_duration_and_currenttime() {
     var div = addDiv(null);
     var animation = div.animate({ opacity: [ 0, 1 ] }, 100 * MS_PER_SEC);
 
     await animation.ready;
-    ok(animation.isRunningOnCompositor);
+    ok(SpecialPowers.wrap(animation).isRunningOnCompositor);
 
     // Set currentTime to a time longer than duration.
     animation.currentTime = 500 * MS_PER_SEC;
 
     // Now the animation immediately get back from compositor.
-    ok(!animation.isRunningOnCompositor);
+    ok(!SpecialPowers.wrap(animation).isRunningOnCompositor);
 
     // Extend the duration.
     animation.effect.timing.duration = 800 * MS_PER_SEC;
     var markers = await observeStyling(5);
     is(markers.length, 1,
        'Animations running on the compositor should update style ' +
        'when timing.duration is made longer than the current time');
 
@@ -554,17 +565,17 @@ waitForAllPaints(function() {
 
     // We need to wait a frame to apply display:none style.
     await waitForFrame();
 
     is(animation.playState, 'running',
        'Script animations keep running even when the target element has ' +
        '"display: none" style');
 
-    ok(!animation.isRunningOnCompositor,
+    ok(!SpecialPowers.wrap(animation).isRunningOnCompositor,
        'Script animations on "display:none" element should not run on the ' +
        'compositor');
 
     var markers = await observeStyling(5);
     is(markers.length, 0,
        'Script animations on "display: none" element should not update styles');
 
     div.style.display = '';
@@ -590,31 +601,31 @@ waitForAllPaints(function() {
 
     // We need to wait a frame to apply display:none style.
     await waitForFrame();
 
     is(animation.playState, 'running',
        'Opacity script animations keep running even when the target element ' +
        'has "display: none" style');
 
-    ok(!animation.isRunningOnCompositor,
+    ok(!SpecialPowers.wrap(animation).isRunningOnCompositor,
        'Opacity script animations on "display:none" element should not ' +
        'run on the compositor');
 
     var markers = await observeStyling(5);
     is(markers.length, 0,
        'Opacity script animations on "display: none" element should not ' +
        'update styles');
 
     div.style.display = '';
 
     // We need to wait a frame to unapply display:none style.
     await waitForFrame();
 
-    ok(animation.isRunningOnCompositor,
+    ok(SpecialPowers.wrap(animation).isRunningOnCompositor,
        'Opacity script animations restored from "display: none" should be ' +
        'run on the compositor');
 
     await ensureElementRemoval(div);
   });
 
   add_task(async function restyling_for_empty_keyframes() {
     var div = addDiv(null);
@@ -642,17 +653,17 @@ waitForAllPaints(function() {
 
     await ensureElementRemoval(div);
   });
 
   add_task_if_omta_enabled(async function no_restyling_when_animation_style_when_re_setting_same_animation_property() {
     var div = addDiv(null, { style: 'animation: opacity 100s' });
     var animation = div.getAnimations()[0];
     await animation.ready;
-    ok(animation.isRunningOnCompositor);
+    ok(SpecialPowers.wrap(animation).isRunningOnCompositor);
     // Apply the same animation style
     div.style.animation = 'opacity 100s';
     var markers = await observeStyling(5);
     is(markers.length, 0,
        'Applying same animation style '  +
        'should never cause restyles');
     await ensureElementRemoval(div);
   });
@@ -674,17 +685,17 @@ waitForAllPaints(function() {
 
   add_task_if_omta_enabled(
     async function changing_cascading_result_for_main_thread_animation() {
       var div = addDiv(null, { style: 'background-color: blue' });
       var animation = div.animate({ opacity: [0, 1],
                                     backgroundColor: ['green', 'red'] },
                                   100 * MS_PER_SEC);
       await animation.ready;
-      ok(animation.isRunningOnCompositor,
+      ok(SpecialPowers.wrap(animation).isRunningOnCompositor,
          'The opacity animation is running on the compositor');
       // Make the background-color style as !important to cause an update
       // to the cascade.
       // Bug 1300982: The background-color animation should be no longer
       // running on the main thread.
       div.style.setProperty('background-color', '1', 'important');
       var markers = await observeStyling(5);
       todo_is(markers.length, 0,
@@ -744,17 +755,17 @@ waitForAllPaints(function() {
     // Tests that if we remove an element from the document whose animation
     // cascade needs recalculating, that it is correctly updated when it is
     // re-attached to the document.
     async function restyling_for_opacity_animation_on_re_attached_element() {
       var div = addDiv(null, { style: 'opacity: 1 ! important' });
       var animation = div.animate({ opacity: [0, 1] }, 100 * MS_PER_SEC);
 
       await animation.ready;
-      ok(!animation.isRunningOnCompositor,
+      ok(!SpecialPowers.wrap(animation).isRunningOnCompositor,
          'The opacity animation overridden by an !important rule is NOT ' +
          'running on the compositor');
 
       // Drop the !important rule to update the cascade.
       div.style.setProperty('opacity', '1', '');
 
       div.remove();
 
@@ -763,17 +774,17 @@ waitForAllPaints(function() {
          'Opacity animation on orphaned element should not cause restyles');
 
       document.body.appendChild(div);
 
       // Need a frame to give the animation a chance to be sent to the
       // compositor.
       await waitForFrame();
 
-      ok(animation.isRunningOnCompositor,
+      ok(SpecialPowers.wrap(animation).isRunningOnCompositor,
          'The opacity animation which is no longer overridden by the ' +
          '!important rule begins running on the compositor even if the ' +
          '!important rule had been dropped before the target element was ' +
          'removed');
 
       await ensureElementRemoval(div);
     }
   );
@@ -958,17 +969,17 @@ waitForAllPaints(function() {
   });
 
   add_task_if_omta_enabled(
     async function no_restyling_for_compositor_animation_on_unrelated_style_change() {
       var div = addDiv(null);
       var animation = div.animate({ opacity: [0, 1] }, 100 * MS_PER_SEC);
 
       await animation.ready;
-      ok(animation.isRunningOnCompositor,
+      ok(SpecialPowers.wrap(animation).isRunningOnCompositor,
          'The opacity animation is running on the compositor');
 
       div.style.setProperty('color', 'blue', '');
       var markers = await observeStyling(5);
       if (isServo) {
         is(markers.length, 0,
            'The opacity animation keeps running on the compositor when ' +
            'color style is changed');
new file mode 100644
--- /dev/null
+++ b/dom/animation/test/mozilla/test_restyles.html
@@ -0,0 +1,16 @@
+<!doctype html>
+<meta charset=utf-8>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+<div id='log'></div>
+<script>
+'use strict';
+SimpleTest.waitForExplicitFinish();
+SimpleTest.expectAssertions(0, 1); // bug 1332970
+SpecialPowers.pushPrefEnv(
+  { 'set': [['dom.animations-api.core.enabled', true]] },
+  function() {
+    window.open('file_restyles.html');
+  });
+</script>
+</html>