Bug 1440195 Address CSS Animations r=birtles a=jcristau
authorTom Ritter <tom@mozilla.com>
Mon, 05 Mar 2018 15:58:46 -0600
changeset 462742 0b094ed5c2f8d8de1f445f371cb07da3c1ce449b
parent 462741 cf00a5369f69f6c5b478e4a5018cabe09a8b9a81
child 462743 683adcd07af8f28f22efaf69a03647b7532f9507
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles, jcristau
bugs1440195
milestone60.0
Bug 1440195 Address CSS Animations r=birtles a=jcristau For now, we are going to make _all_ CSS Animations related timer fuzzing only applicable in Resist Fingerprinting Mode (addressing the last couple that had not already been configured that way.) We hardcode their content mix-ins as zero, but leave comments indicating how they should behave. MozReview-Commit-ID: KhmV7wO8Pt5
dom/animation/AnimationUtils.h
layout/style/nsAnimationManager.cpp
layout/style/nsTransitionManager.cpp
--- a/dom/animation/AnimationUtils.h
+++ b/dom/animation/AnimationUtils.h
@@ -27,18 +27,22 @@ class AnimationUtils
 {
 public:
   static dom::Nullable<double>
   TimeDurationToDouble(const dom::Nullable<TimeDuration>& aTime)
   {
     dom::Nullable<double> result;
 
     if (!aTime.IsNull()) {
+      // 0 is an inappropriate mixin for this this area; however CSS Animations needs to
+      // have it's Time Reduction Logic refactored, so it's currently only clamping for
+      // RFP mode. RFP mode gives a much lower time precision, so we accept the security
+      // leak here for now
       result.SetValue(
-        nsRFPService::ReduceTimePrecisionAsMSecs(aTime.Value().ToMilliseconds(), TimerPrecisionType::RFPOnly)
+        nsRFPService::ReduceTimePrecisionAsMSecs(aTime.Value().ToMilliseconds(), 0, TimerPrecisionType::RFPOnly)
       );
     }
 
     return result;
   }
 
   static dom::Nullable<TimeDuration>
   DoubleToTimeDuration(const dom::Nullable<double>& aTime)
old mode 100644
new mode 100755
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -241,17 +241,22 @@ CSSAnimation::QueueEvents(const StickyTi
 
   AutoTArray<AnimationEventInfo, 2> events;
 
   auto appendAnimationEvent = [&](EventMessage aMessage,
                                   const StickyTimeDuration& aElapsedTime,
                                   const TimeStamp& aTimeStamp) {
     double elapsedTime = aElapsedTime.ToSeconds();
     if (aMessage == eAnimationCancel) {
-      elapsedTime = nsRFPService::ReduceTimePrecisionAsSecs(elapsedTime);
+      // 0 is an inappropriate value for this callsite. What we need to do is
+      // use a single random value for all increasing times reportable.
+      // That is to say, whenever elapsedTime goes negative (because an
+      // animation restarts, something rewinds the animation, or otherwise)
+      // a new random value for the mix-in must be generated.
+      elapsedTime = nsRFPService::ReduceTimePrecisionAsSecs(elapsedTime, 0, TimerPrecisionType::RFPOnly);
     }
     events.AppendElement(AnimationEventInfo(mAnimationName,
                                             mOwningElement.Target(),
                                             aMessage,
                                             elapsedTime,
                                             aTimeStamp,
                                             this));
   };
old mode 100644
new mode 100755
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -262,17 +262,22 @@ CSSTransition::QueueEvents(const StickyT
 
   AutoTArray<AnimationEventInfo, 3> events;
 
   auto appendTransitionEvent = [&](EventMessage aMessage,
                                    const StickyTimeDuration& aElapsedTime,
                                    const TimeStamp& aTimeStamp) {
     double elapsedTime = aElapsedTime.ToSeconds();
     if (aMessage == eTransitionCancel) {
-      elapsedTime = nsRFPService::ReduceTimePrecisionAsSecs(elapsedTime);
+      // 0 is an inappropriate value for this callsite. What we need to do is
+      // use a single random value for all increasing times reportable.
+      // That is to say, whenever elapsedTime goes negative (because an
+      // animation restarts, something rewinds the animation, or otherwise)
+      // a new random value for the mix-in must be generated.
+      elapsedTime = nsRFPService::ReduceTimePrecisionAsSecs(elapsedTime, 0, TimerPrecisionType::RFPOnly);
     }
     events.AppendElement(AnimationEventInfo(TransitionProperty(),
                                             mOwningElement.Target(),
                                             aMessage,
                                             elapsedTime,
                                             aTimeStamp,
                                             this));
   };