Bug 1264101 - force dom.animations-api.core.enabled pref to true before animation inspector tests;r=pbro draft
authorJulian Descottes <jdescottes@mozilla.com>
Fri, 15 Apr 2016 12:35:58 +0200
changeset 352016 c20aad209c3bd47b4e76ba05f3ca675fc86ed92a
parent 351976 53c4ca2e1c43607bcce08089eaf60b4dd43b0235
child 518556 178b0e4566c56367daaa19519b766707c98e245b
push id15589
push userjdescottes@mozilla.com
push dateFri, 15 Apr 2016 14:04:44 +0000
reviewerspbro
bugs1264101
milestone48.0a1
Bug 1264101 - force dom.animations-api.core.enabled pref to true before animation inspector tests;r=pbro WebAnimations API is not enabled by default in all release channels yet. It is behing the pref dom.animations-api.core.enabled. Turn the preference on before any test of the animationinspector, and clear it after the test. MozReview-Commit-ID: K8UXEthLhnH
devtools/client/animationinspector/test/browser_animation_playerWidgets_appear_on_panel_init.js
devtools/client/animationinspector/test/browser_animation_timeline_takes_rate_into_account.js
devtools/client/animationinspector/test/head.js
--- a/devtools/client/animationinspector/test/browser_animation_playerWidgets_appear_on_panel_init.js
+++ b/devtools/client/animationinspector/test/browser_animation_playerWidgets_appear_on_panel_init.js
@@ -5,22 +5,16 @@
 "use strict";
 
 // Test that player widgets are displayed right when the animation panel is
 // initialized, if the selected node (<body> by default) is animated.
 
 const { ANIMATION_TYPES } = require("devtools/server/actors/animation");
 
 add_task(function* () {
-  yield new Promise(resolve => {
-    SpecialPowers.pushPrefEnv({"set": [
-      ["dom.animations-api.core.enabled", true]
-    ]}, resolve);
-  });
-
   yield addTab(URL_ROOT + "doc_multiple_animation_types.html");
 
   let {panel} = yield openAnimationInspector();
   is(panel.animationsTimelineComponent.animations.length, 3,
     "Three animations are handled by the timeline after init");
   assertAnimationsDisplayed(panel, 3,
     "Three animations are displayed after init");
   is(
--- a/devtools/client/animationinspector/test/browser_animation_timeline_takes_rate_into_account.js
+++ b/devtools/client/animationinspector/test/browser_animation_timeline_takes_rate_into_account.js
@@ -7,22 +7,16 @@
 // Check that if an animation has had its playbackRate changed via the DOM, then
 // the timeline UI shows the right delay and duration.
 // Indeed, the header in the timeline UI always shows the unaltered time,
 // because there might be multiple animations displayed at the same time, some
 // of which may have a different rate than others. Those that have had their
 // rate changed have a delay = delay/rate and a duration = duration/rate.
 
 add_task(function* () {
-  yield new Promise(resolve => {
-    SpecialPowers.pushPrefEnv({"set": [
-      ["dom.animations-api.core.enabled", true]
-    ]}, resolve);
-  });
-
   yield addTab(URL_ROOT + "doc_modify_playbackRate.html");
 
   let {panel} = yield openAnimationInspector();
 
   let timelineEl = panel.animationsTimelineComponent.rootWrapperEl;
 
   let timeBlocks = timelineEl.querySelectorAll(".time-block");
   is(timeBlocks.length, 2, "2 animations are displayed");
--- a/devtools/client/animationinspector/test/head.js
+++ b/devtools/client/animationinspector/test/head.js
@@ -26,24 +26,34 @@ registerCleanupFunction(function* () {
 });
 
 // Clean-up all prefs that might have been changed during a test run
 // (safer here because if the test fails, then the pref is never reverted)
 registerCleanupFunction(() => {
   Services.prefs.clearUserPref("devtools.debugger.log");
 });
 
+// WebAnimations API is not enabled by default in all release channels yet, see
+// Bug 1264101.
+function enableWebAnimationsAPI() {
+  return new Promise(resolve => {
+    SpecialPowers.pushPrefEnv({"set": [
+      ["dom.animations-api.core.enabled", true]
+    ]}, resolve);
+  });
+}
+
 /**
  * Add a new test tab in the browser and load the given url.
  * @param {String} url The url to be loaded in the new tab
  * @return a promise that resolves to the tab object when the url is loaded
  */
 var _addTab = addTab;
 addTab = function(url) {
-  return _addTab(url).then(tab => {
+  return enableWebAnimationsAPI().then(() => _addTab(url)).then(tab => {
     let browser = tab.linkedBrowser;
     info("Loading the helper frame script " + FRAME_SCRIPT_URL);
     browser.messageManager.loadFrameScript(FRAME_SCRIPT_URL, false);
     info("Loading the helper frame script " + COMMON_FRAME_SCRIPT_URL);
     browser.messageManager.loadFrameScript(COMMON_FRAME_SCRIPT_URL, false);
     return tab;
   });
 };