Bug 1294651 - Don't apply iterationComposite value if the preference for Web Animations API is not enabled. r?boris draft
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Wed, 21 Sep 2016 19:17:18 +0900
changeset 416021 41c64bb87ca8574451eb3e586b63ad287831533c
parent 416020 560b2c805bf7bebeb3ceebc495a81b2aa4c0c755
child 531742 d868a8df7467cd8211fd185510f968cf28725e7e
push id30017
push userhiikezoe@mozilla-japan.org
push dateWed, 21 Sep 2016 10:17:44 +0000
reviewersboris
bugs1294651
milestone52.0a1
Bug 1294651 - Don't apply iterationComposite value if the preference for Web Animations API is not enabled. r?boris MozReview-Commit-ID: 5ckKyDSBv3S
dom/animation/KeyframeEffect.cpp
dom/animation/KeyframeEffectReadOnly.cpp
dom/animation/test/mochitest.ini
dom/animation/test/mozilla/file_disable_animations_api_core.html
dom/animation/test/mozilla/test_disable_animations_api_core.html
--- a/dom/animation/KeyframeEffect.cpp
+++ b/dom/animation/KeyframeEffect.cpp
@@ -125,16 +125,22 @@ KeyframeEffect::SetTarget(const Nullable
     KeyframeUtils::ApplyDistributeSpacing(mKeyframes);
   }
 }
 
 void
 KeyframeEffect::SetIterationComposite(
   const IterationCompositeOperation& aIterationComposite)
 {
+  // Ignore iterationComposite if the Web Animations API is not enabled,
+  // then the default value 'Replace' will be used.
+  if (!AnimationUtils::IsCoreAPIEnabled()) {
+    return;
+  }
+
   if (mEffectOptions.mIterationComposite == aIterationComposite) {
     return;
   }
 
   if (mAnimation && mAnimation->IsRelevant()) {
     nsNodeUtils::AnimationChanged(mAnimation);
   }
 
--- a/dom/animation/KeyframeEffectReadOnly.cpp
+++ b/dom/animation/KeyframeEffectReadOnly.cpp
@@ -505,17 +505,21 @@ KeyframeEffectParamsFromUnion(const Opti
   if (!aOptions.IsUnrestrictedDouble()) {
     const KeyframeEffectOptions& options =
       KeyframeEffectOptionsFromUnion(aOptions);
     KeyframeEffectParams::ParseSpacing(options.mSpacing,
                                        result.mSpacingMode,
                                        result.mPacedProperty,
                                        aInvalidPacedProperty,
                                        aRv);
-    result.mIterationComposite = options.mIterationComposite;
+    // Ignore iterationComposite if the Web Animations API is not enabled,
+    // then the default value 'Replace' will be used.
+    if (AnimationUtils::IsCoreAPIEnabled()) {
+      result.mIterationComposite = options.mIterationComposite;
+    }
   }
   return result;
 }
 
 /* static */ Maybe<OwningAnimationTarget>
 KeyframeEffectReadOnly::ConvertTarget(
   const Nullable<ElementOrCSSPseudoElement>& aTarget)
 {
--- a/dom/animation/test/mochitest.ini
+++ b/dom/animation/test/mochitest.ini
@@ -34,16 +34,17 @@ support-files =
   css-transitions/file_element-get-animations.html
   css-transitions/file_keyframeeffect-getkeyframes.html
   css-transitions/file_pseudoElement-get-animations.html
   css-transitions/file_setting-effect.html
   document-timeline/file_document-timeline.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_document-timeline-origin-time-range.html
   mozilla/file_hide_and_show.html
   mozilla/file_partial_keyframes.html
   mozilla/file_spacing_property_order.html
   mozilla/file_transform_limits.html
   mozilla/file_underlying-discrete-value.html
   mozilla/file_set-easing.html
   style/file_animation-seeking-with-current-time.html
@@ -87,16 +88,17 @@ skip-if = buildapp == 'mulet'
 [css-transitions/test_pseudoElement-get-animations.html]
 [css-transitions/test_setting-effect.html]
 [document-timeline/test_document-timeline.html]
 [document-timeline/test_request_animation_frame.html]
 skip-if = buildapp == 'mulet'
 [mozilla/test_cubic_bezier_limits.html]
 [mozilla/test_deferred_start.html]
 skip-if = (toolkit == 'gonk' && debug)
+[mozilla/test_disable_animations_api_core.html]
 [mozilla/test_disabled_properties.html]
 [mozilla/test_document-timeline-origin-time-range.html]
 [mozilla/test_hide_and_show.html]
 [mozilla/test_partial_keyframes.html]
 [mozilla/test_set-easing.html]
 [mozilla/test_spacing_property_order.html]
 [mozilla/test_transform_limits.html]
 [mozilla/test_underlying-discrete-value.html]
new file mode 100644
--- /dev/null
+++ b/dom/animation/test/mozilla/file_disable_animations_api_core.html
@@ -0,0 +1,30 @@
+<!doctype html>
+<meta charset=utf-8>
+<script src="../testcommon.js"></script>
+<body>
+<script>
+'use strict';
+
+test(function(t) {
+  var div = addDiv(t);
+  var anim =
+    div.animate({ marginLeft: ['0px', '10px'] },
+                { duration: 100 * MS_PER_SEC,
+                  easing: 'linear',
+                  iterations: 10,
+                  iterationComposite: 'accumulate' });
+  anim.pause();
+
+  // NOTE: We can't check iterationComposite value itself though API since
+  // Animation.effect is also behind the the Web Animations API.  So we just
+  // check that style value is not affected by iterationComposite.
+  anim.currentTime = 200 * MS_PER_SEC;
+  assert_equals(getComputedStyle(div).marginLeft, '0px',
+    'Animated style should not be accumulated when the Web Animations API is ' +
+    'not enabled even if accumulate is specified in the constructor');
+}, 'iterationComposite should not affect at all if the Web Animations API ' +
+   'is not enabled');
+
+done();
+</script>
+</body>
new file mode 100644
--- /dev/null
+++ b/dom/animation/test/mozilla/test_disable_animations_api_core.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<meta charset=utf-8>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+'use strict';
+setup({explicit_done: true});
+SpecialPowers.pushPrefEnv(
+  { "set": [["dom.animations-api.core.enabled", false]]},
+  function() {
+    window.open("file_disable_animations_api_core.html");
+  });
+</script>