Bug 1799435 - Make RFP checks faster. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D161447
This commit is contained in:
Emilio Cobos Álvarez
2022-11-08 02:36:25 +00:00
parent 21a047b345
commit 12e596995e
22 changed files with 185 additions and 134 deletions

View File

@@ -1625,7 +1625,7 @@ bool nsGlobalWindowInner::IsBlackForCC(bool aTracingNeeded) {
bool nsGlobalWindowInner::ShouldResistFingerprinting() const {
if (mDoc) {
return nsContentUtils::ShouldResistFingerprinting(mDoc);
return mDoc->ShouldResistFingerprinting();
}
return nsIScriptGlobalObject::ShouldResistFingerprinting();
}
@@ -4982,10 +4982,8 @@ Storage* nsGlobalWindowInner::GetLocalStorage(ErrorResult& aError) {
if (mDoc) {
cookieJarSettings = mDoc->CookieJarSettings();
} else {
bool shouldResistFingerprinting =
nsContentUtils::ShouldResistFingerprinting(this->GetExtantDoc());
cookieJarSettings =
net::CookieJarSettings::GetBlockingAll(shouldResistFingerprinting);
net::CookieJarSettings::GetBlockingAll(ShouldResistFingerprinting());
}
// Note that this behavior is observable: if we grant storage permission to a
@@ -6584,7 +6582,7 @@ void nsGlobalWindowInner::DisableDeviceSensor(uint32_t aType) {
#if defined(MOZ_WIDGET_ANDROID)
void nsGlobalWindowInner::EnableOrientationChangeListener() {
if (!nsContentUtils::ShouldResistFingerprinting(GetDocShell())) {
if (!ShouldResistFingerprinting()) {
mHasOrientationChangeListeners = true;
mOrientationAngle = Orientation(CallerType::System);
}
@@ -6911,7 +6909,7 @@ void nsGlobalWindowInner::GetGamepads(nsTArray<RefPtr<Gamepad>>& aGamepads) {
// navigator.getGamepads() always returns an empty array when
// privacy.resistFingerprinting is true.
if (nsContentUtils::ShouldResistFingerprinting(GetDocShell())) {
if (ShouldResistFingerprinting()) {
return;
}
@@ -7559,7 +7557,7 @@ void nsGlobalWindowInner::SetReplaceableWindowCoord(
return;
}
if (nsContentUtils::ShouldResistFingerprinting(GetDocShell())) {
if (ShouldResistFingerprinting()) {
bool innerWidthSpecified = false;
bool innerHeightSpecified = false;
bool outerWidthSpecified = false;