Bug 1382545 - Part 1: Rounding the time of Animation API to 100ms when 'privacy.resistFingerprinting'is true. r?birtles,arthuredelstein
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
--- 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)
{