Bug 1382545 - Part 1: Rounding the time of Animation API to 100ms when 'privacy.resistFingerprinting'is true. r=arthuredelstein,birtles
authorTim Huang <tihuang@mozilla.com>
Thu, 17 Aug 2017 22:37:29 +0800
changeset 376858 e2213726a3d34e5b211d242ff9663b5c95864fe8
parent 376857 88eb4aebb63c84131f113fc4790de5f49dde5975
child 376859 ad3bc2177e896fcf5d8c919043797cbbf711525e
push id49660
push userryanvm@gmail.com
push dateFri, 25 Aug 2017 12:29:30 +0000
treeherderautoland@ad3bc2177e89 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarthuredelstein, birtles
bugs1382545, 16337
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1382545 - Part 1: Rounding the time of Animation API to 100ms when 'privacy.resistFingerprinting'is true. r=arthuredelstein,birtles Adopt from Tor #16337. This patch makes Animation API to report a rounded time when 'privacy.resistFingerprinting' is true. The Animation API uses AnimationUtils::TimeDurationToDouble() to convert its time duration into a double value and reports it when someone tries to query time through Animation API. So, we use nsRFPService::ReduceTimePrecisionAsMSecs() inside this method to round the time in the scope of the millisecond. MozReview-Commit-ID: 8o01G6AlAu9
dom/animation/AnimationUtils.h
--- a/dom/animation/AnimationUtils.h
+++ b/dom/animation/AnimationUtils.h
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_AnimationUtils_h
 #define mozilla_dom_AnimationUtils_h
 
 #include "mozilla/TimeStamp.h"
 #include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/dom/Nullable.h"
+#include "nsRFPService.h"
 #include "nsStringFwd.h"
 
 class nsIContent;
 class nsIDocument;
 class nsIFrame;
 struct JSContext;
 
 namespace mozilla {
@@ -26,17 +27,19 @@ class AnimationUtils
 {
 public:
   static dom::Nullable<double>
   TimeDurationToDouble(const dom::Nullable<TimeDuration>& aTime)
   {
     dom::Nullable<double> result;
 
     if (!aTime.IsNull()) {
-      result.SetValue(aTime.Value().ToMilliseconds());
+      result.SetValue(
+        nsRFPService::ReduceTimePrecisionAsMSecs(aTime.Value().ToMilliseconds())
+      );
     }
 
     return result;
   }
 
   static dom::Nullable<TimeDuration>
   DoubleToTimeDuration(const dom::Nullable<double>& aTime)
   {