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

--HG--
extra : rebase_source : e2d52f04c1d63accb786f6cf9b1a102607eed517
This commit is contained in:
Tim Huang 2017-08-17 22:37:29 +08:00
parent be674ca786
commit 5d6e73cb8d

View File

@ -10,6 +10,7 @@
#include "mozilla/TimeStamp.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/Nullable.h"
#include "nsRFPService.h"
#include "nsStringFwd.h"
class nsIContent;
@ -31,7 +32,9 @@ public:
dom::Nullable<double> result;
if (!aTime.IsNull()) {
result.SetValue(aTime.Value().ToMilliseconds());
result.SetValue(
nsRFPService::ReduceTimePrecisionAsMSecs(aTime.Value().ToMilliseconds())
);
}
return result;