Bug 1311196 - Part 1: Add isOMTAEnabled() in testcommon.js. r?boris
MozReview-Commit-ID: FtJTXlsTACn
--- 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);
+}