Bug 1311196 - Part 1: Add isOMTAEnabled() in testcommon.js. r?boris draft
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Wed, 26 Oct 2016 17:19:37 +0900
changeset 429624 e35e5d600ff8ca310a91154d5a067dcd281bf2ed
parent 429594 f9f3cc95d7282f1fd83f66dd74acbcdbfe821915
child 429625 5188e3e99c8539a796eaf5d96ec9b6285ab01ad0
push id33619
push userbmo:hiikezoe@mozilla-japan.org
push dateWed, 26 Oct 2016 08:19:58 +0000
reviewersboris
bugs1311196
milestone52.0a1
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);
+}