Backed out 7 changesets (bug 1954188) for causing bc failures at browser_preferences_usage.js

Backed out changeset dae6e2ec0b2d (bug 1954188)
Backed out changeset 47f683e9f0d6 (bug 1954188)
Backed out changeset 14ed1c70e1ec (bug 1954188)
Backed out changeset 291590143ed9 (bug 1954188)
Backed out changeset fbb4e968f0f1 (bug 1954188)
Backed out changeset 4c21e081561e (bug 1954188)
Backed out changeset 33e6088d8317 (bug 1954188)
This commit is contained in:
Cristina Horotan
2025-04-03 03:21:46 +03:00
parent e5fcb5d24a
commit b163893208
25 changed files with 155 additions and 656 deletions

View File

@@ -16936,7 +16936,7 @@ void Document::MaybeRecomputePartitionKey() {
->SetPartitionKey(originURI, false);
}
bool Document::RecomputeResistFingerprinting(bool aForceRefreshRTPCallerType) {
bool Document::RecomputeResistFingerprinting() {
mOverriddenFingerprintingSettings.reset();
const bool previous = mShouldResistFingerprinting;
@@ -17009,7 +17009,7 @@ bool Document::RecomputeResistFingerprinting(bool aForceRefreshRTPCallerType) {
mShouldResistFingerprinting));
bool changed = previous != mShouldResistFingerprinting;
if (changed || aForceRefreshRTPCallerType) {
if (changed) {
if (auto win = nsGlobalWindowInner::Cast(GetInnerWindow())) {
win->RefreshReduceTimerPrecisionCallerType();
}

View File

@@ -4240,7 +4240,7 @@ class Document : public nsINode,
// Recompute the current resist fingerprinting state. Returns true when
// the state was changed.
bool RecomputeResistFingerprinting(bool aForceRefreshRTPCallerType = false);
bool RecomputeResistFingerprinting();
// Recompute the partitionKey for this document if needed. This is for
// handling the case where the principal of the document is changed during the

View File

@@ -942,20 +942,18 @@ static constexpr nsLiteralCString kRfpPrefs[] = {
"privacy.fingerprintingProtection"_ns,
"privacy.fingerprintingProtection.pbmode"_ns,
"privacy.fingerprintingProtection.overrides"_ns,
"privacy.baselineFingerprintingProtection"_ns,
"privacy.baselineFingerprintingProtection.overrides"_ns,
};
static void RecomputeResistFingerprintingAllDocs(const char*, void*) {
AutoTArray<RefPtr<Document>, 64> allDocuments;
Document::GetAllInProcessDocuments(allDocuments);
for (auto& doc : allDocuments) {
doc->RecomputeResistFingerprinting(
/* aForceRefreshRTPCallerType= */ true);
if (auto* pc = doc->GetPresContext()) {
pc->MediaFeatureValuesChanged(
{MediaFeatureChangeReason::PreferenceChange},
MediaFeatureChangePropagation::JustThisDocument);
if (doc->RecomputeResistFingerprinting()) {
if (auto* pc = doc->GetPresContext()) {
pc->MediaFeatureValuesChanged(
{MediaFeatureChangeReason::PreferenceChange},
MediaFeatureChangePropagation::JustThisDocument);
}
}
}
}
@@ -2439,8 +2437,23 @@ bool nsContentUtils::ETPSaysShouldNotResistFingerprinting(
// A positive return from this function should always be obeyed.
// A negative return means we should keep checking things.
// We do not want this check to apply to RFP, only to FPP.
if (nsRFPService::IsRFPPrefEnabled(aIsPBM)) {
// We do not want this check to apply to RFP, only to FPP
// There is one problematic combination of prefs; however:
// If RFP is enabled in PBMode only and FPP is enabled globally
// (so, in non-PBM mode) - we need to know if we're in PBMode or not.
// But that's kind of expensive and we'd like to avoid it if we
// don't have to, so special-case that scenario
if (StaticPrefs::privacy_fingerprintingProtection_DoNotUseDirectly() &&
!StaticPrefs::privacy_resistFingerprinting_DoNotUseDirectly() &&
StaticPrefs::privacy_resistFingerprinting_pbmode_DoNotUseDirectly()) {
if (aIsPBM) {
// In PBM (where RFP is enabled) do not exempt based on the ETP toggle
return false;
}
} else if (StaticPrefs::privacy_resistFingerprinting_DoNotUseDirectly() ||
(aIsPBM &&
StaticPrefs::
privacy_resistFingerprinting_pbmode_DoNotUseDirectly())) {
// In RFP, never use the ETP toggle to exempt.
// We can safely return false here even if we are not in PBM mode
// and RFP_pbmode is enabled because we will later see that and
@@ -2710,6 +2723,19 @@ bool nsContentUtils::ShouldResistFingerprinting_dangerous(
" OriginAttributes) and the URI is %s",
aURI->GetSpecOrDefault().get()));
if (!StaticPrefs::privacy_resistFingerprinting_DoNotUseDirectly() &&
!StaticPrefs::privacy_fingerprintingProtection_DoNotUseDirectly()) {
// If neither of the 'regular' RFP prefs are set, then one (or both)
// of the PBM-Only prefs are set (or we would have failed the
// Positive return check.) Therefore, if we are not in PBM, return false
if (!aOriginAttributes.IsPrivateBrowsing()) {
MOZ_LOG(nsContentUtils::ResistFingerprintingLog(), LogLevel::Debug,
("Inside ShouldResistFingerprinting_dangerous(nsIURI*,"
" OriginAttributes) OA PBM Check said false"));
return false;
}
}
// Exclude internal schemes and web extensions
if (SchemeSaysShouldNotResistFingerprinting(aURI)) {
MOZ_LOG(nsContentUtils::ResistFingerprintingLog(), LogLevel::Debug,
@@ -6607,8 +6633,8 @@ void nsContentUtils::AddScriptRunner(already_AddRefed<nsIRunnable> aRunnable) {
}
if (sScriptBlockerCount) {
PROFILER_MARKER("nsContentUtils::AddScriptRunner", OTHER, {},
FlowMarker, Flow::FromPointer(runnable.get()));
PROFILER_MARKER("nsContentUtils::AddScriptRunner", OTHER, {}, FlowMarker,
Flow::FromPointer(runnable.get()));
sBlockedScriptRunners->AppendElement(runnable.forget());
return;
}

View File

@@ -570,10 +570,6 @@ nsresult ServiceWorkerPrivate::Initialize() {
nsCOMPtr<nsIURI> firstPartyURI;
bool foreignByAncestorContext = false;
bool isOn3PCBExceptionList = false;
// Firefox doesn't support service workers in PBM,
// but we add this just so that when we do,
// we can handle it correctly.
bool isPBM = principal->GetIsInPrivateBrowsing();
if (!principal->OriginAttributesRef().mPartitionKey.IsEmpty()) {
net::CookieJarSettings::Cast(cookieJarSettings)
->SetPartitionKey(principal->OriginAttributesRef().mPartitionKey);
@@ -596,7 +592,7 @@ nsresult ServiceWorkerPrivate::Initialize() {
if (NS_SUCCEEDED(rv)) {
overriddenFingerprintingSettings =
nsRFPService::GetOverriddenFingerprintingSettingsForURI(
firstPartyURI, uri, isPBM);
firstPartyURI, uri);
if (overriddenFingerprintingSettings.isSome()) {
overriddenFingerprintingSettingsArg.emplace(
overriddenFingerprintingSettings.ref());
@@ -629,9 +625,9 @@ nsresult ServiceWorkerPrivate::Initialize() {
overriddenFingerprintingSettings =
isThirdParty
? nsRFPService::GetOverriddenFingerprintingSettingsForURI(
firstPartyURI, uri, isPBM)
firstPartyURI, uri)
: nsRFPService::GetOverriddenFingerprintingSettingsForURI(
uri, nullptr, isPBM);
uri, nullptr);
RefPtr<net::CookieService> csSingleton =
net::CookieService::GetSingleton();
@@ -654,8 +650,7 @@ nsresult ServiceWorkerPrivate::Initialize() {
// the service worker as the first-party domain to get the fingerprinting
// protection overrides.
overriddenFingerprintingSettings =
nsRFPService::GetOverriddenFingerprintingSettingsForURI(uri, nullptr,
isPBM);
nsRFPService::GetOverriddenFingerprintingSettingsForURI(uri, nullptr);
if (overriddenFingerprintingSettings.isSome()) {
overriddenFingerprintingSettingsArg.emplace(
@@ -663,6 +658,7 @@ nsresult ServiceWorkerPrivate::Initialize() {
}
}
bool isPBM = principal->GetIsInPrivateBrowsing();
if (ContentBlockingAllowList::Check(principal, isPBM)) {
net::CookieJarSettings::Cast(cookieJarSettings)
->SetIsOnContentBlockingAllowList(true);

View File

@@ -15706,18 +15706,6 @@
value: true
mirror: always
# Enable/Disable fingerprinting protections that are enabled in
# Enhanced Tracking Protection Standard mode.
# bFPP cannot be enabled in only PBM, it is either enabled
# browser-wide or disabled browser-wide. If FPP is enabled
# in the same context as bFPP, FPP takes precedence. If
# RFP is enabled in the same context as FPP, then RFP takes precedence
- name: privacy.baselineFingerprintingProtection
type: RelaxedAtomicBool
value: true
mirror: always
do_not_use_directly: true
# This pref can be used to disable mozAddonManager entirely for fingerprinting
# reasons. Someone like Tor browser will use this pref.
# NOTE: We'd like this to be a "hidden" pref once StaticPrefs supports it.

View File

@@ -843,14 +843,6 @@ pref("privacy.fingerprintingProtection.overrides", "");
// or remove features on a domain granular level.
pref("privacy.fingerprintingProtection.granularOverrides", "");
// If privacy.baselineFingerprintingProtection is enabled, this pref can be used to add
// or remove features from its effects
pref("privacy.baselineFingerprintingProtection.overrides", "");
// If privacy.baselineFingerprintingProtection is enabled, this pref can be used to add
// or remove features on a domain granular level.
pref("privacy.baselineFingerprintingProtection.granularOverrides", "");
// Fix cookie blocking breakage by providing ephemeral Paritioned LocalStorage
// for a list of hosts when detected as trackers.
// (See nsICookieService::BEHAVIOR_REJECT_TRACKER cookie behavior)

View File

@@ -3212,20 +3212,6 @@ fingerprintingProtection:
pref: privacy.resistFingerprinting.randomization.canvas.use_siphash
description: >-
Uses the SipHash function for canvas randomization.
enabledBaseline:
type: boolean
setPref:
branch: default
pref: privacy.baselineFingerprintingProtection
description: Enables / disables baseline fingerprinting protection.
overridesBaseline:
type: string
setPref:
branch: default
pref: privacy.baselineFingerprintingProtection.overrides
description: >-
The protection overrides to add or remove fingerprinting protection
targets. Please check RFPTargets.inc for all supported targets.
userCharacteristics:
description: Control user characteristic data collection

View File

@@ -49,8 +49,6 @@ const SCHEMA = `{
const COLLECTION_NAME = "fingerprinting-protection-overrides";
const PREF_GRANULAR_OVERRIDES =
"privacy.fingerprintingProtection.granularOverrides";
const PREF_GRANULAR_OVERRIDES_BASELINE =
"privacy.baselineFingerprintingProtection.granularOverrides";
const PREF_REMOTE_OVERRIDES_ENABLED =
"privacy.fingerprintingProtection.remoteOverrides.enabled";
@@ -60,12 +58,6 @@ XPCOMUtils.defineLazyPreferenceGetter(
PREF_GRANULAR_OVERRIDES
);
XPCOMUtils.defineLazyPreferenceGetter(
lazy,
"baselineGranularOverridesPref",
PREF_GRANULAR_OVERRIDES_BASELINE
);
XPCOMUtils.defineLazyPreferenceGetter(
lazy,
"remoteOverridesEnabled",
@@ -79,11 +71,10 @@ export class FingerprintingOverride {
classID = Components.ID("{07f45442-1806-44be-9230-12eb79de9bac}");
QueryInterface = ChromeUtils.generateQI(["nsIFingerprintingOverride"]);
constructor(firstPartyDomain, thirdPartyDomain, overrides, isBaseline) {
constructor(firstPartyDomain, thirdPartyDomain, overrides) {
this.firstPartyDomain = firstPartyDomain;
this.thirdPartyDomain = thirdPartyDomain;
this.overrides = overrides;
this.isBaseline = isBaseline;
}
}
@@ -134,7 +125,6 @@ export class FingerprintingWebCompatService {
// Register listener to import overrides when the overrides pref changes.
Services.prefs.addObserver(PREF_GRANULAR_OVERRIDES, this);
Services.prefs.addObserver(PREF_GRANULAR_OVERRIDES_BASELINE, this);
// Register the sync event for the remote settings updates.
this.#rs.on("sync", event => {
@@ -165,42 +155,37 @@ export class FingerprintingWebCompatService {
// Clear overrides before we update.
this.#granularOverrides.clear();
for (const [pref, isBaseline] of [
[lazy.baselineGranularOverridesPref, true],
[lazy.granularOverridesPref, false],
]) {
let overrides;
try {
overrides = JSON.parse(pref || "[]");
} catch (error) {
lazy.logConsole.error(
`Failed to parse granular override JSON string: Not a valid JSON.`,
error
);
return;
let overrides;
try {
overrides = JSON.parse(lazy.granularOverridesPref || "[]");
} catch (error) {
lazy.logConsole.error(
`Failed to parse granular override JSON string: Not a valid JSON.`,
error
);
return;
}
// Ensure we have an array we can iterate over and not an object.
if (!Array.isArray(overrides)) {
lazy.logConsole.error(
"Failed to parse granular overrides JSON String: Not an array."
);
return;
}
for (let override of overrides) {
// Validate the override.
let { valid, errors } = this.#validator.validate(override);
if (!valid) {
lazy.logConsole.debug("Override validation error", override, errors);
continue;
}
// Ensure we have an array we can iterate over and not an object.
if (!Array.isArray(overrides)) {
lazy.logConsole.error(
"Failed to parse granular overrides JSON String: Not an array."
);
return;
}
for (let override of overrides) {
// Validate the override.
let { valid, errors } = this.#validator.validate(override);
if (!valid) {
lazy.logConsole.debug("Override validation error", override, errors);
continue;
}
this.#granularOverrides.add(
this.#createFingerprintingOverrideFrom(override, isBaseline)
);
}
this.#granularOverrides.add(
this.#createFingerprintingOverrideFrom(override)
);
}
}
@@ -232,18 +217,11 @@ export class FingerprintingWebCompatService {
}
}
#createFingerprintingOverrideFrom(entry, isBaselineOverride = null) {
// If the isBaselineOverride is not provided, we will use the value from the
// entry. If the entry doesn't have the isBaseline field, we will default to
// false.
// We default to false because we didn't have the baseline mode in the past,
// and the existing entries don't have the isBaseline field.
const isBaseline = isBaselineOverride ?? entry.isBaseline ?? false;
#createFingerprintingOverrideFrom(entry) {
return new FingerprintingOverride(
entry.firstPartyDomain,
entry.thirdPartyDomain,
entry.overrides,
isBaseline
entry.overrides
);
}
@@ -262,10 +240,7 @@ export class FingerprintingWebCompatService {
}
observe(subject, topic, prefName) {
if (
prefName != PREF_GRANULAR_OVERRIDES &&
prefName != PREF_GRANULAR_OVERRIDES_BASELINE
) {
if (prefName != PREF_GRANULAR_OVERRIDES) {
return;
}
@@ -277,6 +252,5 @@ export class FingerprintingWebCompatService {
lazy.logConsole.debug("shutdown");
Services.prefs.removeObserver(PREF_GRANULAR_OVERRIDES, this);
Services.prefs.removeObserver(PREF_GRANULAR_OVERRIDES_BASELINE, this);
}
}

View File

@@ -4,7 +4,7 @@
* You can obtain one at https://mozilla.org/MPL/2.0/. */
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
import * as RFPTargetConstants from "resource://gre/modules/RFPTargetConstants.sys.mjs";
import * as constants from "resource://gre/modules/RFPTargetConstants.sys.mjs";
const kPrefResistFingerprinting = "privacy.resistFingerprinting";
const kPrefSpoofEnglish = "privacy.spoof_english";
@@ -704,19 +704,13 @@ class _RFPHelper {
}
getTargets() {
return RFPTargetConstants.Targets;
}
getTargetDefaultsBaseline() {
const key =
Services.appinfo.OS === "Android" ? "ANDROID_DEFAULT" : "DESKTOP_DEFAULT";
return RFPTargetConstants.DefaultTargetsBaseline[key];
return constants.Targets;
}
getTargetDefaults() {
const key =
Services.appinfo.OS === "Android" ? "ANDROID_DEFAULT" : "DESKTOP_DEFAULT";
return RFPTargetConstants.DefaultTargets[key];
return constants.DefaultTargets[key];
}
}

View File

@@ -1,6 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// So far, just a placeholder file.

View File

@@ -18,21 +18,11 @@ def parse_defaults(path):
return defaults
def write_defaults(output, defaults_base, defaults_fpp):
output.write("export const DefaultTargetsBaseline = {\n")
for platform in defaults_base:
def write_defaults(output, defaults):
output.write("export const DefaultTargets = {\n")
for platform in defaults:
output.write(f'\t"{platform}": [')
for target in defaults_base[platform]:
output.write(f'"{target}",')
output.write("],\n")
output.write("}\n")
output.write("\n")
output.write("export const DefaultTargetsFPP = {\n")
for platform in defaults_fpp:
output.write(f'\t"{platform}": [')
for target in defaults_fpp[platform]:
for target in defaults[platform]:
output.write(f'"{target}",')
output.write("],\n")
output.write("}\n")
@@ -62,14 +52,12 @@ def write_targets(output, targets):
output.write("}\n")
def main(output, targets_path, defaults_base_path, defaults_fpp_path):
def main(output, targets_path, defaults_path):
output.write("// This is a generated file. Please do not edit.\n")
output.write(
f"// See extract_rfp_targets.py, {targets_path}, {defaults_base_path}, {defaults_fpp_path} files instead.\n"
"// See extract_rfp_targets.py, RFPTargets.inc, and RFPTargetsDefault.inc files instead.\n"
)
write_targets(output, parse_targets(targets_path))
output.write("\n")
write_defaults(
output, parse_defaults(defaults_base_path), parse_defaults(defaults_fpp_path)
)
write_defaults(output, parse_defaults(defaults_path))

View File

@@ -68,5 +68,5 @@ include("/ipc/chromium/chromium-config.mozbuild")
GeneratedFile(
"RFPTargetConstants.sys.mjs",
script="extract_rfp_targets.py",
inputs=["RFPTargets.inc", "RFPTargetsDefaultBaseline.inc", "RFPTargetsDefault.inc"],
inputs=["RFPTargets.inc", "RFPTargetsDefault.inc"],
)

View File

@@ -21,11 +21,6 @@ interface nsIFingerprintingOverride : nsISupports
* fingerprinting override pref "privacy.fingerprintingProtection.overrides".
*/
readonly attribute ACString overrides;
/**
* Whether the override is baseline or FPP.
*/
readonly attribute boolean isBaseline;
};
/**

View File

@@ -41,12 +41,7 @@ interface nsIRFPService : nsISupports
void cleanAllOverrides();
/**
* Enabled baseline FPP targets.
*/
readonly attribute nsIRFPTargetSetIDL enabledFingerprintingProtectionsBaseline;
/**
* Enabled FPP targets.
* The bitfield of the default enabled RFP Targets.
*/
readonly attribute nsIRFPTargetSetIDL enabledFingerprintingProtections;

View File

@@ -107,8 +107,6 @@ static mozilla::LazyLogModule gFingerprinterDetection("FingerprinterDetection");
static mozilla::LazyLogModule gTimestamps("Timestamps");
#define RESIST_FINGERPRINTINGPROTECTION_OVERRIDE_BASE_PREF \
"privacy.baselineFingerprintingProtection.overrides"
#define RESIST_FINGERPRINTINGPROTECTION_OVERRIDE_PREF \
"privacy.fingerprintingProtection.overrides"
#define GLEAN_DATA_SUBMISSION_PREF "datareporting.healthreport.uploadEnabled"
@@ -142,10 +140,6 @@ static constexpr uint32_t kVideoDroppedRatio = 1;
# define DESKTOP_DEFAULT(name) RFPTarget::name,
#endif
MOZ_CONSTINIT const RFPTargetSet kDefaultFingerprintingProtectionsBase = {
#include "RFPTargetsDefaultBaseline.inc"
};
MOZ_RUNINIT const RFPTargetSet kDefaultFingerprintingProtections = {
#include "RFPTargetsDefault.inc"
};
@@ -168,8 +162,6 @@ static bool sInitialized = false;
// Actually enabled fingerprinting protections.
static StaticMutex sEnabledFingerprintingProtectionsMutex;
MOZ_CONSTINIT static RFPTargetSet sEnabledFingerprintingProtectionsBase
MOZ_GUARDED_BY(sEnabledFingerprintingProtectionsMutex);
MOZ_CONSTINIT static RFPTargetSet sEnabledFingerprintingProtections
MOZ_GUARDED_BY(sEnabledFingerprintingProtectionsMutex);
@@ -192,7 +184,6 @@ already_AddRefed<nsRFPService> nsRFPService::GetOrCreate() {
}
static const char* gCallbackPrefs[] = {
RESIST_FINGERPRINTINGPROTECTION_OVERRIDE_BASE_PREF,
RESIST_FINGERPRINTINGPROTECTION_OVERRIDE_PREF,
GLEAN_DATA_SUBMISSION_PREF,
nullptr,
@@ -242,71 +233,14 @@ nsresult nsRFPService::Init() {
return rv;
}
// Very simple helper functions to improve readability.
/* static */
bool nsRFPService::IsRFPPrefEnabled(bool aIsPrivateMode) {
return StaticPrefs::privacy_resistFingerprinting_DoNotUseDirectly() ||
(aIsPrivateMode &&
StaticPrefs::privacy_resistFingerprinting_pbmode_DoNotUseDirectly());
}
enum FingerprintingProtectionType {
RFP,
FPP,
Baseline,
None,
};
/* static */
bool IsBaselineFPPEnabled() {
return StaticPrefs::
privacy_baselineFingerprintingProtection_DoNotUseDirectly();
}
/* static */
bool IsFPPEnabled(bool aIsPrivateMode) {
return StaticPrefs::privacy_fingerprintingProtection_DoNotUseDirectly() ||
(aIsPrivateMode &&
StaticPrefs::
privacy_fingerprintingProtection_pbmode_DoNotUseDirectly());
}
FingerprintingProtectionType GetEnabledFingeperprintingProtectionMode(
bool aIsPrivateMode) {
if (nsRFPService::IsRFPPrefEnabled(aIsPrivateMode)) {
return FingerprintingProtectionType::RFP;
if (StaticPrefs::privacy_resistFingerprinting_DoNotUseDirectly() ||
(aIsPrivateMode &&
StaticPrefs::privacy_resistFingerprinting_pbmode_DoNotUseDirectly())) {
return true;
}
if (IsFPPEnabled(aIsPrivateMode)) {
return FingerprintingProtectionType::FPP;
}
if (IsBaselineFPPEnabled()) {
return FingerprintingProtectionType::Baseline;
}
return FingerprintingProtectionType::None;
}
Maybe<bool> HandleExeptionalRFPTargets(RFPTarget aTarget, bool aIsPrivateMode) {
MOZ_ASSERT(GetEnabledFingeperprintingProtectionMode(aIsPrivateMode) !=
FingerprintingProtectionType::None);
// IsAlwaysEnabledForPrecompute is used to enable fingerprinting protections.
// It isn't included in the RFPTargetSet.
if (aTarget == RFPTarget::IsAlwaysEnabledForPrecompute) {
return Some(true);
}
// We don't spoof the pointerId on multi-touch devices.
#if SPOOFED_MAX_TOUCH_POINTS > 0
if (aTarget == RFPTarget::PointerId) {
return Some(false);
}
#endif
return Nothing();
return false;
}
/* static */
@@ -315,61 +249,55 @@ bool nsRFPService::IsRFPEnabledFor(
const Maybe<RFPTargetSet>& aOverriddenFingerprintingSettings) {
MOZ_ASSERT(aTarget != RFPTarget::AllTargets);
FingerprintingProtectionType mode =
GetEnabledFingeperprintingProtectionMode(aIsPrivateMode);
if (mode == FingerprintingProtectionType::None) {
#if SPOOFED_MAX_TOUCH_POINTS > 0
if (aTarget == RFPTarget::PointerId) {
return false;
}
#endif
if (Maybe<bool> result =
HandleExeptionalRFPTargets(aTarget, aIsPrivateMode)) {
return *result;
}
if (mode == FingerprintingProtectionType::RFP) {
if (StaticPrefs::privacy_resistFingerprinting_DoNotUseDirectly() ||
(aIsPrivateMode &&
StaticPrefs::privacy_resistFingerprinting_pbmode_DoNotUseDirectly())) {
if (aTarget == RFPTarget::JSLocale) {
return StaticPrefs::privacy_spoof_english() == 2;
}
return true;
}
if (aOverriddenFingerprintingSettings) {
return aOverriddenFingerprintingSettings.ref().contains(aTarget);
if (StaticPrefs::privacy_fingerprintingProtection_DoNotUseDirectly() ||
(aIsPrivateMode &&
StaticPrefs::
privacy_fingerprintingProtection_pbmode_DoNotUseDirectly())) {
if (aTarget == RFPTarget::IsAlwaysEnabledForPrecompute) {
return true;
}
if (aOverriddenFingerprintingSettings) {
return aOverriddenFingerprintingSettings.ref().contains(aTarget);
}
StaticMutexAutoLock lock(sEnabledFingerprintingProtectionsMutex);
return sEnabledFingerprintingProtections.contains(aTarget);
}
StaticMutexAutoLock lock(sEnabledFingerprintingProtectionsMutex);
switch (mode) {
case FingerprintingProtectionType::FPP:
return sEnabledFingerprintingProtections.contains(aTarget);
case FingerprintingProtectionType::Baseline:
return sEnabledFingerprintingProtectionsBase.contains(aTarget);
default:
MOZ_CRASH("Unexpected FingerprintingProtectionType");
return false;
}
return false;
}
void nsRFPService::UpdateFPPOverrideList() {
StaticMutexAutoLock lock(sEnabledFingerprintingProtectionsMutex);
std::tuple<const char*, RFPTargetSet&, const RFPTargetSet&> prefs[] = {
{RESIST_FINGERPRINTINGPROTECTION_OVERRIDE_PREF,
sEnabledFingerprintingProtections, kDefaultFingerprintingProtections},
{RESIST_FINGERPRINTINGPROTECTION_OVERRIDE_BASE_PREF,
sEnabledFingerprintingProtectionsBase,
kDefaultFingerprintingProtectionsBase},
};
for (const auto& [pref, targetSet, defaultSet] : prefs) {
nsAutoString targetOverrides;
nsresult rv = Preferences::GetString(pref, targetOverrides);
if (NS_FAILED(rv)) {
MOZ_LOG(gResistFingerprintingLog, LogLevel::Warning,
("Could not get fingerprinting override pref (%s) value", pref));
continue;
}
targetSet = CreateOverridesFromText(targetOverrides, defaultSet);
nsAutoString targetOverrides;
nsresult rv = Preferences::GetString(
RESIST_FINGERPRINTINGPROTECTION_OVERRIDE_PREF, targetOverrides);
if (NS_WARN_IF(NS_FAILED(rv))) {
MOZ_LOG(gResistFingerprintingLog, LogLevel::Warning,
("Could not get fingerprinting override pref value"));
return;
}
RFPTargetSet enabled = CreateOverridesFromText(
targetOverrides, kDefaultFingerprintingProtections);
StaticMutexAutoLock lock(sEnabledFingerprintingProtectionsMutex);
sEnabledFingerprintingProtections = enabled;
}
/* static */
@@ -420,8 +348,7 @@ void nsRFPService::PrefChanged(const char* aPref) {
("Pref Changed: %s", aPref));
nsDependentCString pref(aPref);
if (pref.EqualsLiteral(RESIST_FINGERPRINTINGPROTECTION_OVERRIDE_PREF) ||
pref.EqualsLiteral(RESIST_FINGERPRINTINGPROTECTION_OVERRIDE_BASE_PREF)) {
if (pref.EqualsLiteral(RESIST_FINGERPRINTINGPROTECTION_OVERRIDE_PREF)) {
UpdateFPPOverrideList();
} else if (pref.EqualsLiteral(GLEAN_DATA_SUBMISSION_PREF)) {
if (XRE_IsParentProcess() &&
@@ -2072,10 +1999,6 @@ nsresult nsRFPService::CreateOverrideDomainKey(
nsresult rv = aOverride->GetFirstPartyDomain(firstPartyDomain);
NS_ENSURE_SUCCESS(rv, rv);
bool isBaseline = false;
rv = aOverride->GetIsBaseline(&isBaseline);
NS_ENSURE_SUCCESS(rv, rv);
// The first party domain shouldn't be empty. And it shouldn't contain a comma
// because we use a comma as a delimiter.
if (firstPartyDomain.IsEmpty() ||
@@ -2106,9 +2029,6 @@ nsresult nsRFPService::CreateOverrideDomainKey(
aDomainKey.Append(thirdPartyDomain);
}
aDomainKey.Append(FP_OVERRIDES_DOMAIN_KEY_DELIMITER);
aDomainKey.Append(isBaseline ? "1" : "0");
return NS_OK;
}
@@ -2169,9 +2089,8 @@ nsRFPService::SetFingerprintingOverrides(
const nsTArray<RefPtr<nsIFingerprintingOverride>>& aOverrides) {
MOZ_ASSERT(XRE_IsParentProcess());
// Clear all overrides before importing.
CleanAllOverrides();
mFingerprintingOverrides.Clear();
StaticMutexAutoLock lock(sEnabledFingerprintingProtectionsMutex);
for (const auto& fpOverride : aOverrides) {
nsAutoCString domainKey;
@@ -2185,18 +2104,12 @@ nsRFPService::SetFingerprintingOverrides(
rv = fpOverride->GetOverrides(overridesText);
NS_ENSURE_SUCCESS(rv, rv);
bool isBaseline = false;
rv = fpOverride->GetIsBaseline(&isBaseline);
NS_ENSURE_SUCCESS(rv, rv);
RFPTargetSet baseOverrides = isBaseline
? sEnabledFingerprintingProtectionsBase
: sEnabledFingerprintingProtections;
StaticMutexAutoLock lock(sEnabledFingerprintingProtectionsMutex);
RFPTargetSet targets = nsRFPService::CreateOverridesFromText(
NS_ConvertUTF8toUTF16(overridesText),
mFingerprintingOverrides.Contains(domainKey)
? mFingerprintingOverrides.Get(domainKey)
: baseOverrides);
: sEnabledFingerprintingProtections);
// The newly added one will replace the existing one for the given domain
// key.
@@ -2214,18 +2127,6 @@ nsRFPService::SetFingerprintingOverrides(
return NS_OK;
}
NS_IMETHODIMP
nsRFPService::GetEnabledFingerprintingProtectionsBaseline(
nsIRFPTargetSetIDL** aProtections) {
StaticMutexAutoLock lock(sEnabledFingerprintingProtectionsMutex);
RFPTargetSet enabled = sEnabledFingerprintingProtectionsBase;
nsCOMPtr<nsIRFPTargetSetIDL> protections = new nsRFPTargetSetIDL(enabled);
protections.forget(aProtections);
return NS_OK;
}
NS_IMETHODIMP
nsRFPService::GetEnabledFingerprintingProtections(
nsIRFPTargetSetIDL** aProtections) {
@@ -2285,11 +2186,9 @@ Maybe<RFPTargetSet> nsRFPService::GetOverriddenFingerprintingSettingsForChannel(
return Nothing();
}
bool isPrivate = loadInfo->GetOriginAttributes().IsPrivateBrowsing();
// The channel is for the first-party load.
if (!AntiTrackingUtils::IsThirdPartyChannel(aChannel)) {
return GetOverriddenFingerprintingSettingsForURI(uri, nullptr, isPrivate);
return GetOverriddenFingerprintingSettingsForURI(uri, nullptr);
}
// The channel is for the third-party load. We get the first-party URI from
@@ -2342,7 +2241,7 @@ Maybe<RFPTargetSet> nsRFPService::GetOverriddenFingerprintingSettingsForChannel(
rv = NS_NewURI(getter_AddRefs(topURI), scheme + u"://"_ns + domain);
MOZ_ASSERT(NS_SUCCEEDED(rv));
return GetOverriddenFingerprintingSettingsForURI(topURI, uri, isPrivate);
return GetOverriddenFingerprintingSettingsForURI(topURI, uri);
}
nsCOMPtr<nsIPrincipal> topPrincipal = topWGP->DocumentPrincipal();
@@ -2394,12 +2293,12 @@ Maybe<RFPTargetSet> nsRFPService::GetOverriddenFingerprintingSettingsForChannel(
attrsForeignByAncestor.mPartitionKey.Equals(partitionKey));
#endif
return GetOverriddenFingerprintingSettingsForURI(topURI, uri, isPrivate);
return GetOverriddenFingerprintingSettingsForURI(topURI, uri);
}
/* static */
Maybe<RFPTargetSet> nsRFPService::GetOverriddenFingerprintingSettingsForURI(
nsIURI* aFirstPartyURI, nsIURI* aThirdPartyURI, bool aIsPrivate) {
nsIURI* aFirstPartyURI, nsIURI* aThirdPartyURI) {
MOZ_ASSERT(aFirstPartyURI);
MOZ_ASSERT(XRE_IsParentProcess());
@@ -2413,17 +2312,9 @@ Maybe<RFPTargetSet> nsRFPService::GetOverriddenFingerprintingSettingsForURI(
// will take over {first-party domain, *} because the latter one has a smaller
// scope.
bool isBaseline = !IsFPPEnabled(aIsPrivate);
auto addIsBaseline = [](nsAutoCString& aKey, bool aIsBaseline) {
aKey.Append(FP_OVERRIDES_DOMAIN_KEY_DELIMITER);
aKey.Append(aIsBaseline ? "1" : "0");
};
// First, we get the overrides that applies to every context.
nsAutoCString key;
key.Assign("*"_ns);
addIsBaseline(key, isBaseline);
Maybe<RFPTargetSet> result = service->mFingerprintingOverrides.MaybeGet(key);
Maybe<RFPTargetSet> result =
service->mFingerprintingOverrides.MaybeGet("*"_ns);
nsCOMPtr<nsIEffectiveTLDService> eTLDService =
mozilla::components::EffectiveTLD::Service();
@@ -2446,10 +2337,11 @@ Maybe<RFPTargetSet> nsRFPService::GetOverriddenFingerprintingSettingsForURI(
// first-party domain.
if (!aThirdPartyURI) {
// Test the {first-party domain, *} scope.
nsAutoCString key;
key.Assign(firstPartyDomain);
key.Append(FP_OVERRIDES_DOMAIN_KEY_DELIMITER);
key.Append("*"_ns);
addIsBaseline(key, isBaseline);
key.Append("*");
Maybe<RFPTargetSet> fpOverrides =
service->mFingerprintingOverrides.MaybeGet(key);
if (fpOverrides) {
@@ -2457,9 +2349,7 @@ Maybe<RFPTargetSet> nsRFPService::GetOverriddenFingerprintingSettingsForURI(
}
// Test the {first-party domain} scope.
key.Assign(firstPartyDomain);
addIsBaseline(key, isBaseline);
fpOverrides = service->mFingerprintingOverrides.MaybeGet(key);
fpOverrides = service->mFingerprintingOverrides.MaybeGet(firstPartyDomain);
if (fpOverrides) {
result = fpOverrides;
}
@@ -2483,10 +2373,10 @@ Maybe<RFPTargetSet> nsRFPService::GetOverriddenFingerprintingSettingsForURI(
}
// Test {first-party domain, *} scope.
nsAutoCString key;
key.Assign(firstPartyDomain);
key.Append(FP_OVERRIDES_DOMAIN_KEY_DELIMITER);
key.Append("*"_ns);
addIsBaseline(key, isBaseline);
key.Append("*");
Maybe<RFPTargetSet> fpOverrides =
service->mFingerprintingOverrides.MaybeGet(key);
if (fpOverrides) {
@@ -2497,7 +2387,6 @@ Maybe<RFPTargetSet> nsRFPService::GetOverriddenFingerprintingSettingsForURI(
key.Assign("*");
key.Append(FP_OVERRIDES_DOMAIN_KEY_DELIMITER);
key.Append(thirdPartyDomain);
addIsBaseline(key, isBaseline);
fpOverrides = service->mFingerprintingOverrides.MaybeGet(key);
if (fpOverrides) {
result = fpOverrides;
@@ -2507,7 +2396,6 @@ Maybe<RFPTargetSet> nsRFPService::GetOverriddenFingerprintingSettingsForURI(
key.Assign(firstPartyDomain);
key.Append(FP_OVERRIDES_DOMAIN_KEY_DELIMITER);
key.Append(thirdPartyDomain);
addIsBaseline(key, isBaseline);
fpOverrides = service->mFingerprintingOverrides.MaybeGet(key);
if (fpOverrides) {
result = fpOverrides;

View File

@@ -355,7 +355,7 @@ class nsRFPService final : public nsIObserver, public nsIRFPService {
// and third-party URI. Otherwise, it will return Nothing() to indicate using
// the default RFPTargets.
static Maybe<RFPTargetSet> GetOverriddenFingerprintingSettingsForURI(
nsIURI* aFirstPartyURI, nsIURI* aThirdPartyURI, bool aIsPrivate);
nsIURI* aFirstPartyURI, nsIURI* aThirdPartyURI);
// --------------------------------------------------------------------------

View File

@@ -814,8 +814,6 @@ const auto* const kCanvasRandomizationPrincipalCheckPref =
"privacy.resistFingerprinting.randomization.canvas.disable_for_chrome";
const auto* const kFingerprintingProtectionOverridesPref =
"privacy.fingerprintingProtection.overrides";
const auto* const kBaselineFPPOverridesPref =
"privacy.baselineFingerprintingProtection.overrides";
namespace {
@@ -905,22 +903,15 @@ bool nsUserCharacteristics::ShouldSubmit() {
return false;
}
nsAutoString overrides;
nsresult rv =
Preferences::GetString(kFingerprintingProtectionOverridesPref, overrides);
if (NS_FAILED(rv) || !overrides.IsEmpty()) {
nsAutoString fppOverrides;
nsresult rv = Preferences::GetString(kFingerprintingProtectionOverridesPref,
fppOverrides);
if (NS_FAILED(rv) || !fppOverrides.IsEmpty()) {
// If there are any overrides, we don't want to send the ping
// as it will mess up data.
return false;
}
rv = Preferences::GetString(kBaselineFPPOverridesPref, overrides);
if (NS_FAILED(rv) || !overrides.IsEmpty()) {
// If there are any baseline overrides, we don't want to send the ping
// as it will mess up data.
return false;
}
// User asked to send a ping regardless of the version
if (sendOnce) {
return true;

View File

@@ -3,7 +3,6 @@ support-files = [
"canvas-fingerprinter.html",
"empty.html",
"font-fingerprinter.html",
"head-fpp-matrix.js",
"head.js",
"scriptExecPage.html",
"serviceWorker.js",
@@ -35,14 +34,6 @@ support-files = [
["browser_fpiServiceWorkers_fingerprinting.js"]
["browser_fpp_protections_matrix_1.js"]
["browser_fpp_protections_matrix_2.js"]
["browser_fpp_protections_matrix_3.js"]
["browser_fpp_protections_matrix_4.js"]
["browser_rfp_canvasplaceholder_pdfjs.js"]
support-files = ["file_pdf.pdf"]

View File

@@ -309,7 +309,7 @@ add_task(async function test_remote_settings() {
// Get the addition and subtraction flags for the domain.
try {
let overrides = extractLow32Bits(
Services.rfp.getFingerprintingOverrides(expect.domain + ",0").low
Services.rfp.getFingerprintingOverrides(expect.domain).low
);
// Verify if the flags are matching to expected values.
@@ -354,7 +354,7 @@ add_task(async function test_remote_settings_pref() {
for (let expect of test.expects) {
try {
// Check for the existance of RFP overrides
Services.rfp.getFingerprintingOverrides(expect.domain + ",0").low;
Services.rfp.getFingerprintingOverrides(expect.domain).low;
ok(
false,
"This line should never run as the override should not exist and the previous line would throw an exception"
@@ -392,7 +392,7 @@ add_task(async function test_pref() {
try {
// Get the addition and subtraction flags for the domain.
let overrides = extractLow32Bits(
Services.rfp.getFingerprintingOverrides(expect.domain + ",0").low
Services.rfp.getFingerprintingOverrides(expect.domain).low
);
// Verify if the flags are matching to expected values.
@@ -447,7 +447,7 @@ add_task(async function test_pref_override_remote_settings() {
// Get the addition and subtraction flags for the domain.
let overrides = extractLow32Bits(
Services.rfp.getFingerprintingOverrides("example.org,0").low
Services.rfp.getFingerprintingOverrides("example.org").low
);
// Verify if the flags are matching to the pref settings.

View File

@@ -1,16 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
/* import-globals-from head-fpp-matrix.js */
Services.scriptloader.loadSubScript(
"chrome://mochitests/content/browser/toolkit/components/resistfingerprinting/tests/browser/head-fpp-matrix.js",
this
);
requestLongerTimeout(4);
add_task(async function verifyOverridesNonGranular() {
await runTestCases(generateTestCases(false, false));
});

View File

@@ -1,16 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
/* import-globals-from head-fpp-matrix.js */
Services.scriptloader.loadSubScript(
"chrome://mochitests/content/browser/toolkit/components/resistfingerprinting/tests/browser/head-fpp-matrix.js",
this
);
requestLongerTimeout(4);
add_task(async function verifyOverridesGranular() {
await runTestCases(generateTestCases(true, true));
});

View File

@@ -1,16 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
/* import-globals-from head-fpp-matrix.js */
Services.scriptloader.loadSubScript(
"chrome://mochitests/content/browser/toolkit/components/resistfingerprinting/tests/browser/head-fpp-matrix.js",
this
);
requestLongerTimeout(4);
add_task(async function verifyOverridesBFppGranular() {
await runTestCases(generateTestCases(true, false));
});

View File

@@ -1,16 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
/* import-globals-from head-fpp-matrix.js */
Services.scriptloader.loadSubScript(
"chrome://mochitests/content/browser/toolkit/components/resistfingerprinting/tests/browser/head-fpp-matrix.js",
this
);
requestLongerTimeout(4);
add_task(async function verifyOverridesFppGranular() {
await runTestCases(generateTestCases(false, true));
});

View File

@@ -1,226 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
const DOMAIN = "example.com";
const EMPTY_PAGE =
getRootDirectory(gTestPath).replace(
"chrome://mochitests/content",
"https://" + DOMAIN
) + "empty.html";
const FPP_PREF = "privacy.fingerprintingProtection";
const ENABLE_FPP = [FPP_PREF, true];
const DISABLE_FPP = [FPP_PREF, false];
const FPP_PBM_PREF = "privacy.fingerprintingProtection.pbmode";
const ENABLE_FPP_PBM = [FPP_PBM_PREF, true];
const DISABLE_FPP_PBM = [FPP_PBM_PREF, false];
const RFP_TARGET = "NavigatorConnection";
const OVERRIDES_ENABLED = `-AllTargets,+${RFP_TARGET}`;
const OVERRIDES_DISABLED = "-AllTargets";
const GRANULAR_OVERRIDES_ENABLED = JSON.stringify([
{
firstPartyDomain: DOMAIN,
overrides: OVERRIDES_ENABLED,
},
]);
const GRANULAR_OVERRIDES_DISABLED = JSON.stringify([
{
firstPartyDomain: DOMAIN,
overrides: OVERRIDES_DISABLED,
},
]);
const FPP_OVERRIDES_ENABLED = [
"privacy.fingerprintingProtection.overrides",
OVERRIDES_ENABLED,
];
const FPP_OVERRIDES_DISABLED = [
"privacy.fingerprintingProtection.overrides",
OVERRIDES_DISABLED,
];
const FPP_GRANULAR_OVERRIDES_ENABLED = [
"privacy.fingerprintingProtection.granularOverrides",
GRANULAR_OVERRIDES_ENABLED,
];
const FPP_GRANULAR_OVERRIDES_DISABLED = [
"privacy.fingerprintingProtection.granularOverrides",
GRANULAR_OVERRIDES_DISABLED,
];
const BFPP_PREF = "privacy.baselineFingerprintingProtection";
const ENABLE_BFPP = [BFPP_PREF, true];
const DISABLE_BFPP = [BFPP_PREF, false];
const BFPP_OVERRIDES_ENABLED = [
"privacy.baselineFingerprintingProtection.overrides",
OVERRIDES_ENABLED,
];
const BFPP_OVERRIDES_DISABLED = [
"privacy.baselineFingerprintingProtection.overrides",
OVERRIDES_DISABLED,
];
const BFPP_GRANULAR_OVERRIDES_ENABLED = [
"privacy.baselineFingerprintingProtection.granularOverrides",
GRANULAR_OVERRIDES_ENABLED,
];
const BFPP_GRANULAR_OVERRIDES_DISABLED = [
"privacy.baselineFingerprintingProtection.granularOverrides",
GRANULAR_OVERRIDES_DISABLED,
];
function generateTestCases(bfppIsGranular, fppIsGranular) {
const result = [];
const len = 5;
const vals = [true, false];
const combinations = Array.from(
{ length: Math.pow(vals.length, len) },
(_, index) => {
return Array.from(
{ length: len },
(_, i) =>
vals[
Math.floor(index / Math.pow(vals.length, len - 1 - i)) % vals.length
]
);
}
);
const [
BFPP_ENABLED_I,
FPP_ENABLED_I,
FPP_PBM_ENABLED_I,
BFPP_OVERRIDES_ENABLED_I,
FPP_OVERRIDES_ENABLED_I,
] = [...Array(len).keys()];
const truthfulnessToPref = [
[ENABLE_BFPP, DISABLE_BFPP],
[ENABLE_FPP, DISABLE_FPP],
[ENABLE_FPP_PBM, DISABLE_FPP_PBM],
bfppIsGranular
? [BFPP_GRANULAR_OVERRIDES_ENABLED, BFPP_GRANULAR_OVERRIDES_DISABLED]
: [BFPP_OVERRIDES_ENABLED, BFPP_OVERRIDES_DISABLED],
fppIsGranular
? [FPP_GRANULAR_OVERRIDES_ENABLED, FPP_GRANULAR_OVERRIDES_DISABLED]
: [FPP_OVERRIDES_ENABLED, FPP_OVERRIDES_DISABLED],
];
const computeExpectedResults = combination => {
let expectedNormalBrowsing = false;
let expectedPrivateBrowsing = false;
// If FPP is enabled, it overrides everything.
if (combination[FPP_ENABLED_I]) {
expectedNormalBrowsing = combination[FPP_OVERRIDES_ENABLED_I];
expectedPrivateBrowsing = combination[FPP_OVERRIDES_ENABLED_I];
return { expectedNormalBrowsing, expectedPrivateBrowsing };
}
// If FPP_PBM is enabled, it overrides bFPP in private browsing.
if (combination[FPP_PBM_ENABLED_I]) {
expectedPrivateBrowsing = combination[FPP_OVERRIDES_ENABLED_I];
if (combination[BFPP_ENABLED_I]) {
expectedNormalBrowsing = combination[BFPP_OVERRIDES_ENABLED_I];
} else {
expectedNormalBrowsing = false;
}
return { expectedNormalBrowsing, expectedPrivateBrowsing };
}
// Both FPP and FPP_PBM are disabled.
if (combination[BFPP_ENABLED_I]) {
expectedNormalBrowsing = combination[BFPP_OVERRIDES_ENABLED_I];
expectedPrivateBrowsing = combination[BFPP_OVERRIDES_ENABLED_I];
return { expectedNormalBrowsing, expectedPrivateBrowsing };
}
return { expectedNormalBrowsing, expectedPrivateBrowsing };
};
for (const combination of combinations) {
const prefs = combination.map(
(val, i) => truthfulnessToPref[i][val ? 0 : 1]
);
const expectedVals = computeExpectedResults(combination);
result.push({
description: `BFPP: ${combination[BFPP_ENABLED_I]}, FPP: ${combination[FPP_ENABLED_I]}, FPP_PBM: ${combination[FPP_PBM_ENABLED_I]}, BFPP_OVERRIDES: ${combination[BFPP_OVERRIDES_ENABLED_I]}, FPP_OVERRIDES: ${combination[FPP_OVERRIDES_ENABLED_I]}, bfppIsGranular: ${bfppIsGranular}, fppIsGranular: ${fppIsGranular}`,
expectedNormalBrowsing: expectedVals.expectedNormalBrowsing,
expectedPrivateBrowsing: expectedVals.expectedPrivateBrowsing,
prefs,
});
}
return result;
}
async function runTestCase(
index,
testCase,
normalBrowsingWindow,
privateBrowsingWindow
) {
await SpecialPowers.pushPrefEnv({
set: testCase.prefs,
});
for (const isPBM of [false, true]) {
const win = isPBM ? privateBrowsingWindow : normalBrowsingWindow;
const expectedValue = isPBM
? testCase.expectedPrivateBrowsing
: testCase.expectedNormalBrowsing;
const description = `${index}: In ${isPBM ? "private browsing" : "normal browsing"}. ${testCase.description}`;
const tab = await BrowserTestUtils.openNewForegroundTab(
win.gBrowser,
EMPTY_PAGE
);
await SpecialPowers.spawn(
tab.linkedBrowser,
[expectedValue, description],
async function (expectedValue, description) {
ok(
"connection" in content.navigator,
"navigator.connection should exist"
);
const result = content.navigator.connection.type === "unknown";
is(result, expectedValue, description);
}
);
BrowserTestUtils.removeTab(tab);
}
await SpecialPowers.popPrefEnv();
}
let normalBrowsingWindow;
let privateBrowsingWindow;
add_setup(async function () {
await SpecialPowers.pushPrefEnv({
set: [["dom.netinfo.enabled", true]],
});
normalBrowsingWindow = await BrowserTestUtils.openNewBrowserWindow();
privateBrowsingWindow = await BrowserTestUtils.openNewBrowserWindow({
private: true,
});
registerCleanupFunction(async () => {
await BrowserTestUtils.closeWindow(normalBrowsingWindow);
await BrowserTestUtils.closeWindow(privateBrowsingWindow);
await SpecialPowers.popPrefEnv();
});
});
async function runTestCases(testCases) {
for (let i = 0; i < testCases.length; i++) {
await runTestCase(
i,
testCases[i],
normalBrowsingWindow,
privateBrowsingWindow
);
}
}

View File

@@ -158,8 +158,6 @@ const auto* const kResistFingerprintingPrefPBMode =
"privacy.resistFingerprinting.pbmode";
const auto* const kFingerprintingProtectionOverrides =
"privacy.fingerprintingProtection.overrides";
const auto* const kBaselineFPPOverridesPref =
"privacy.baselineFingerprintingProtection.overrides";
TEST(ResistFingerprinting, UserCharacteristics_ShouldSubmit)
{
@@ -208,11 +206,4 @@ TEST(ResistFingerprinting, UserCharacteristics_ShouldSubmit)
Preferences::SetCString(kFingerprintingProtectionOverrides, "test");
ASSERT_FALSE(nsUserCharacteristics::ShouldSubmit());
Preferences::ClearUser(kFingerprintingProtectionOverrides);
ASSERT_TRUE(nsUserCharacteristics::ShouldSubmit());
// Verify non-empty baselineFPP overrides prevent submission
Preferences::SetCString(kBaselineFPPOverridesPref, "test");
ASSERT_FALSE(nsUserCharacteristics::ShouldSubmit());
Preferences::ClearUser(kBaselineFPPOverridesPref);
ASSERT_TRUE(nsUserCharacteristics::ShouldSubmit());
}