mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 1586761 - P7 - Revert a few incorrect changes on P2; r=tjr
P2 removed IsTimerPrecisionReductionEnabled and thus removed the check for RFP pref. While most ReduceTimePrecision* functions are fine with that because GetTimerPrecisionType checks that, the two ReduceTimePrecision*RFP functions miss the check. This patch mainly cover the check for that two functions and rename them to *RFPOnly since they only use RFP when the pref is on. Depends on D64324 Differential Revision: https://phabricator.services.mozilla.com/D66734 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
9ddae1a89d
commit
b34fac17ed
@ -40,7 +40,7 @@ class AnimationUtils {
|
||||
// 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::ReduceTimePrecisionAsMSecsRFP(
|
||||
result.SetValue(nsRFPService::ReduceTimePrecisionAsMSecsRFPOnly(
|
||||
aTime.Value().ToMilliseconds(), 0));
|
||||
}
|
||||
|
||||
|
@ -1754,7 +1754,7 @@ void nsRefreshDriver::RunFrameRequestCallbacks(TimeStamp aNowTime) {
|
||||
// lower time precision, so we accept the security leak here for now
|
||||
if (!perf->IsSystemPrincipal()) {
|
||||
timeStamp =
|
||||
nsRFPService::ReduceTimePrecisionAsMSecsRFP(timeStamp, 0);
|
||||
nsRFPService::ReduceTimePrecisionAsMSecsRFPOnly(timeStamp, 0);
|
||||
}
|
||||
}
|
||||
// else window is partially torn down already
|
||||
|
@ -252,7 +252,8 @@ void CSSAnimation::QueueEvents(const StickyTimeDuration& aActiveTime) {
|
||||
// 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::ReduceTimePrecisionAsSecsRFP(elapsedTime, 0);
|
||||
elapsedTime =
|
||||
nsRFPService::ReduceTimePrecisionAsSecsRFPOnly(elapsedTime, 0);
|
||||
}
|
||||
events.AppendElement(
|
||||
AnimationEventInfo(mAnimationName, mOwningElement.Target(), aMessage,
|
||||
|
@ -148,7 +148,8 @@ void CSSTransition::QueueEvents(const StickyTimeDuration& aActiveTime) {
|
||||
// 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::ReduceTimePrecisionAsSecsRFP(elapsedTime, 0);
|
||||
elapsedTime =
|
||||
nsRFPService::ReduceTimePrecisionAsSecsRFPOnly(elapsedTime, 0);
|
||||
}
|
||||
events.AppendElement(AnimationEventInfo(
|
||||
TransitionProperty(), mOwningElement.Target(), aMessage, elapsedTime,
|
||||
|
@ -422,16 +422,17 @@ nsresult nsRFPService::RandomMidpoint(long long aClampedTimeUSec,
|
||||
* nearest multiple of that precision.
|
||||
*
|
||||
* It will check if it is appropriate to clamp the input time according to the
|
||||
* values of the privacy.resistFingerprinting and privacy.reduceTimerPrecision
|
||||
* preferences. Note that while it will check these prefs, it will use
|
||||
* whatever precision is given to it, so if one desires a minimum precision for
|
||||
* Resist Fingerprinting, it is the caller's responsibility to provide the
|
||||
* correct value. This means you should pass TimerResolution(), which enforces
|
||||
* a minimum vale on the precision based on preferences.
|
||||
* values of the given TimerPrecisionType. Note that if one desires a minimum
|
||||
* precision for Resist Fingerprinting, it is the caller's responsibility to
|
||||
* provide the correct value. This means you should pass TimerResolution(),
|
||||
* which enforces a minimum value on the precision based on preferences.
|
||||
*
|
||||
* It ensures the given precision value is greater than zero, if it is not it
|
||||
* returns the input time.
|
||||
*
|
||||
* While the correct thing to pass is TimerResolution() we expose it as an
|
||||
* argument for testing purposes only.
|
||||
*
|
||||
* @param aTime [in] The input time to be clamped.
|
||||
* @param aTimeScale [in] The units the input time is in (Seconds,
|
||||
* Milliseconds, or Microseconds).
|
||||
@ -455,17 +456,13 @@ double nsRFPService::ReduceTimePrecisionImpl(double aTime, TimeScale aTimeScale,
|
||||
// still want to apply 20us clamping to al timestamps to avoid leaking
|
||||
// nano-second precision.
|
||||
bool unconditionalClamping = false;
|
||||
if (aType == UnconditionalAKAHighRes || TimerResolution() <= 0) {
|
||||
if (aType == UnconditionalAKAHighRes || aResolutionUSec <= 0) {
|
||||
unconditionalClamping = true;
|
||||
aResolutionUSec = RFP_TIMER_UNCONDITIONAL_VALUE; // 20 microseconds
|
||||
aContextMixin = 0; // Just clarifies our logging statement at the end,
|
||||
// otherwise unused
|
||||
}
|
||||
|
||||
if (aResolutionUSec <= 0) {
|
||||
return aTime;
|
||||
}
|
||||
|
||||
// Increase the time as needed until it is in microseconds.
|
||||
// Note that a double can hold up to 2**53 with integer precision. This gives
|
||||
// us only until June 5, 2255 in time-since-the-epoch with integer precision.
|
||||
@ -569,11 +566,11 @@ double nsRFPService::ReduceTimePrecisionAsMSecs(double aTime,
|
||||
}
|
||||
|
||||
/* static */
|
||||
double nsRFPService::ReduceTimePrecisionAsMSecsRFP(double aTime,
|
||||
int64_t aContextMixin) {
|
||||
double nsRFPService::ReduceTimePrecisionAsMSecsRFPOnly(double aTime,
|
||||
int64_t aContextMixin) {
|
||||
return nsRFPService::ReduceTimePrecisionImpl(aTime, MilliSeconds,
|
||||
TimerResolution(), aContextMixin,
|
||||
TimerPrecisionType::RFP);
|
||||
GetTimerPrecisionTypeRFPOnly());
|
||||
}
|
||||
|
||||
/* static */
|
||||
@ -588,11 +585,11 @@ double nsRFPService::ReduceTimePrecisionAsSecs(double aTime,
|
||||
}
|
||||
|
||||
/* static */
|
||||
double nsRFPService::ReduceTimePrecisionAsSecsRFP(double aTime,
|
||||
int64_t aContextMixin) {
|
||||
double nsRFPService::ReduceTimePrecisionAsSecsRFPOnly(double aTime,
|
||||
int64_t aContextMixin) {
|
||||
return nsRFPService::ReduceTimePrecisionImpl(aTime, Seconds,
|
||||
TimerResolution(), aContextMixin,
|
||||
TimerPrecisionType::RFP);
|
||||
GetTimerPrecisionTypeRFPOnly());
|
||||
}
|
||||
|
||||
/* static */
|
||||
@ -1108,6 +1105,19 @@ TimerPrecisionType nsRFPService::GetTimerPrecisionType(
|
||||
return DangerouslyNone;
|
||||
}
|
||||
|
||||
/* static */
|
||||
TimerPrecisionType nsRFPService::GetTimerPrecisionTypeRFPOnly() {
|
||||
if (StaticPrefs::privacy_resistFingerprinting()) {
|
||||
return RFP;
|
||||
}
|
||||
|
||||
if (StaticPrefs::privacy_reduceTimerPrecision_unconditional()) {
|
||||
return UnconditionalAKAHighRes;
|
||||
}
|
||||
|
||||
return DangerouslyNone;
|
||||
}
|
||||
|
||||
/* static */
|
||||
void nsRFPService::TypeToText(TimerPrecisionType aType, nsACString& aText) {
|
||||
switch (aType) {
|
||||
|
@ -158,13 +158,13 @@ class nsRFPService final : public nsIObserver {
|
||||
static double ReduceTimePrecisionAsMSecs(double aTime, int64_t aContextMixin,
|
||||
bool aIsSystemPrincipal,
|
||||
bool aCrossOriginIsolated);
|
||||
static double ReduceTimePrecisionAsMSecsRFP(double aTime,
|
||||
int64_t aContextMixin);
|
||||
static double ReduceTimePrecisionAsMSecsRFPOnly(double aTime,
|
||||
int64_t aContextMixin);
|
||||
static double ReduceTimePrecisionAsSecs(double aTime, int64_t aContextMixin,
|
||||
bool aIsSystemPrincipal,
|
||||
bool aCrossOriginIsolated);
|
||||
static double ReduceTimePrecisionAsSecsRFP(double aTime,
|
||||
int64_t aContextMixin);
|
||||
static double ReduceTimePrecisionAsSecsRFPOnly(double aTime,
|
||||
int64_t aContextMixin);
|
||||
|
||||
// Used by the JS Engine, as it doesn't know about the TimerPrecisionType enum
|
||||
static double ReduceTimePrecisionAsUSecsWrapper(double aTime, JSContext* aCx);
|
||||
@ -269,6 +269,8 @@ class nsRFPService final : public nsIObserver {
|
||||
static TimerPrecisionType GetTimerPrecisionType(bool aIsSystemPrincipal,
|
||||
bool aCrossOriginIsolated);
|
||||
|
||||
static TimerPrecisionType GetTimerPrecisionTypeRFPOnly();
|
||||
|
||||
static void TypeToText(TimerPrecisionType aType, nsACString& aText);
|
||||
|
||||
nsCString mInitialTZValue;
|
||||
|
Loading…
Reference in New Issue
Block a user