Backed out changeset 9bf6a5eb2ed5 (bug 1770498) for causing mochitest failures on browser_navigator.js . CLOSED TREE

This commit is contained in:
criss 2022-06-02 19:53:39 +03:00
Родитель 6362d2b06a
Коммит cf82fc590a
3 изменённых файлов: 28 добавлений и 22 удалений

Просмотреть файл

@ -2129,8 +2129,6 @@ bool nsContentUtils::IsCallerChromeOrErrorPage(JSContext* aCx,
return doc && IsErrorPage(doc->GetDocumentURI());
}
// Older Should RFP Functions ----------------------------------
/* static */
bool nsContentUtils::ShouldResistFingerprinting() {
return StaticPrefs::privacy_resistFingerprinting();
@ -2145,19 +2143,8 @@ bool nsContentUtils::ShouldResistFingerprinting(
return aGlobalObject->ShouldResistFingerprinting();
}
// Newer Should RFP Functions ----------------------------------
/* static */
bool nsContentUtils::ShouldResistFingerprinting(const char* aJustification) {
// See comment in header file for information about usage
return ShouldResistFingerprinting();
}
bool nsContentUtils::ShouldResistFingerprinting(nsIDocShell* aDocShell) {
if (!aDocShell) {
MOZ_LOG(nsContentUtils::ResistFingerprintingLog(), LogLevel::Info,
("Called nsContentUtils::ShouldResistFingerprinting(const "
"nsIDocShell* aDocShell) with NULL docshell"));
return ShouldResistFingerprinting();
}
return ShouldResistFingerprinting(aDocShell->GetDocument());
@ -2178,6 +2165,21 @@ bool nsContentUtils::ShouldResistFingerprinting(const Document* aDoc) {
return ShouldResistFingerprinting(aDoc->GetChannel());
}
/* static */
bool nsContentUtils::ShouldResistFingerprinting(nsIPrincipal* aPrincipal) {
if (!aPrincipal) {
return ShouldResistFingerprinting();
}
bool isChrome = aPrincipal->IsSystemPrincipal();
return !isChrome && ShouldResistFingerprinting();
}
/* static */
bool nsContentUtils::ShouldResistFingerprinting(const char* aJustification) {
// See comment in header file for information about usage
return ShouldResistFingerprinting();
}
inline void LogDomainAndPrefList(const char* exemptedDomainsPrefName,
nsAutoCString& url, bool isExemptDomain) {
nsAutoCString list;
@ -2268,22 +2270,22 @@ bool nsContentUtils::ShouldResistFingerprinting(nsIChannel* aChannel) {
}
// Case 2: Subresource Load
MOZ_ASSERT(BasePrincipal::Cast(loadInfo->GetLoadingPrincipal())->OriginAttributesRef() == loadInfo->GetOriginAttributes());
return ShouldResistFingerprinting(loadInfo->GetLoadingPrincipal());
return ShouldResistFingerprinting(loadInfo->GetLoadingPrincipal(),
loadInfo->GetOriginAttributes());
}
/* static */
bool nsContentUtils::ShouldResistFingerprinting(nsIPrincipal* aPrincipal) {
bool nsContentUtils::ShouldResistFingerprinting(
nsIPrincipal* aPrincipal,
const mozilla::OriginAttributes& aOriginAttributes) {
if (!ShouldResistFingerprinting("Legacy quick-check")) {
return false;
}
auto originAttributes = BasePrincipal::Cast(aPrincipal)->OriginAttributesRef();
if (StaticPrefs::privacy_resistFingerprinting_testGranularityMask() &
sNonPBMExemptMask) {
// if non-PBM exempt mask is true, exempt non-PBM channels.
if (originAttributes.mPrivateBrowsingId == 0) {
if (aOriginAttributes.mPrivateBrowsingId == 0) {
return false;
}
}
@ -6989,7 +6991,8 @@ void nsContentUtils::FireMutationEventsForDirectParsing(
}
/* static */
const Document* nsContentUtils::GetInProcessSubtreeRootDocument(const Document* aDoc) {
const Document* nsContentUtils::GetInProcessSubtreeRootDocument(
const Document* aDoc) {
if (!aDoc) {
return nullptr;
}

Просмотреть файл

@ -351,10 +351,13 @@ class nsContentUtils {
static bool ShouldResistFingerprinting();
static bool ShouldResistFingerprinting(nsIGlobalObject* aGlobalObject);
static bool ShouldResistFingerprinting(nsIDocShell* aDocShell);
static bool ShouldResistFingerprinting(nsIPrincipal* aPrincipal);
// These functions are the new, nuanced functions
static bool ShouldResistFingerprinting(const Document* aDoc);
static bool ShouldResistFingerprinting(nsIChannel* aChannel);
static bool ShouldResistFingerprinting(nsIPrincipal* aPrincipal);
static bool ShouldResistFingerprinting(
nsIPrincipal* aPrincipal,
const mozilla::OriginAttributes& aOriginAttributes);
/**
* Implement a RFP function that only checks the pref, and does not take

Просмотреть файл

@ -371,7 +371,7 @@ nsresult RemoteWorkerChild::ExecWorkerOnMainThread(RemoteWorkerData&& aData) {
info.mOriginAttributes =
BasePrincipal::Cast(principal)->OriginAttributesRef();
info.mShouldResistFingerprinting = nsContentUtils::ShouldResistFingerprinting(
principal);
info.mPrincipal, info.mOriginAttributes);
net::CookieJarSettings::Deserialize(aData.cookieJarSettings(),
getter_AddRefs(info.mCookieJarSettings));