Bug 1311196 - Part 1: Add isOMTAEnabled() in testcommon.js. r=boris
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Wed, 26 Oct 2016 17:19:37 +0900
changeset 319563 8dfb01b23512a84ef0fb46049c02d8bea9b2723c
parent 319562 868407a1bd36a284484d2ce4d6ed0bac584a8536
child 319564 cd9fc546638163263a40f9700e563c97c0ca8666
push id33561
push userhiikezoe@mozilla-japan.org
push dateWed, 26 Oct 2016 21:05:29 +0000
treeherderautoland@c9a8a051dd30 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersboris
bugs1311196
milestone52.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 1311196 - Part 1: Add isOMTAEnabled() in testcommon.js. r=boris MozReview-Commit-ID: FtJTXlsTACn
dom/animation/test/chrome/test_restyles.html
dom/animation/test/chrome/test_running_on_compositor.html
dom/animation/test/mozilla/file_deferred_start.html
dom/animation/test/testcommon.js
--- a/dom/animation/test/chrome/test_restyles.html
+++ b/dom/animation/test/chrome/test_restyles.html
@@ -59,19 +59,17 @@ 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);
+var omtaEnabled = isOMTAEnabled();
 
 var isAndroid = !!navigator.userAgent.includes("Android");
 
 function add_task_if_omta_enabled(test) {
   if (!omtaEnabled) {
     info(test.name + " is skipped because OMTA is disabled");
     return;
   }
--- a/dom/animation/test/chrome/test_running_on_compositor.html
+++ b/dom/animation/test/chrome/test_running_on_compositor.html
@@ -45,19 +45,17 @@ div {
   target="_blank">Mozilla Bug 1045994</a>
 <div id="log"></div>
 <script>
 'use strict';
 
 /** Test for bug 1045994 - Add a chrome-only property to inspect if an
     animation is running on the compositor or not **/
 
-const OMTAPrefKey = 'layers.offmainthreadcomposition.async-animations';
-var omtaEnabled = SpecialPowers.DOMWindowUtils.layerManagerRemote &&
-                  SpecialPowers.getBoolPref(OMTAPrefKey);
+var omtaEnabled = isOMTAEnabled();
 
 function assert_animation_is_running_on_compositor(animation, desc) {
   assert_equals(animation.isRunningOnCompositor, omtaEnabled,
                 desc + ' at ' + animation.currentTime + 'ms');
 }
 
 function assert_animation_is_not_running_on_compositor(animation, desc) {
   assert_equals(animation.isRunningOnCompositor, false,
--- a/dom/animation/test/mozilla/file_deferred_start.html
+++ b/dom/animation/test/mozilla/file_deferred_start.html
@@ -76,20 +76,17 @@ async_test(function(t) {
 
 // Test that compositor animations with delays get synced correctly
 //
 // NOTE: It is important that we DON'T use
 // SpecialPowers.DOMWindowUtils.advanceTimeAndRefresh here since that takes
 // us through a different code path.
 async_test(function(t) {
   // This test only applies to compositor animations
-  const OMTAPrefKey = 'layers.offmainthreadcomposition.async-animations';
-  var omtaEnabled = SpecialPowers.DOMWindowUtils.layerManagerRemote &&
-                    opener.SpecialPowers.getBoolPref(OMTAPrefKey);
-  if (!omtaEnabled) {
+  if (!isOMTAEnabled()) {
     t.done();
     return;
   }
 
   // Setup animation
   var div = addDiv(t);
   div.classList.add('target');
   div.style.animation = 'animTransform 100s -50s forwards';
--- a/dom/animation/test/testcommon.js
+++ b/dom/animation/test/testcommon.js
@@ -201,8 +201,16 @@ function setupSynchronousObserver(t, tar
    });
   t.add_cleanup(() => {
     observer.disconnect();
   });
   observer.observe(target, { animations: true, subtree: subtree });
   return observer;
 }
 
+/**
+ * Returns true if off-main-thread animations.
+ */
+function isOMTAEnabled() {
+  const OMTAPrefKey = 'layers.offmainthreadcomposition.async-animations';
+  return SpecialPowers.DOMWindowUtils.layerManagerRemote &&
+         SpecialPowers.getBoolPref(OMTAPrefKey);
+}