commit ebfba9ae402e48be88128ad9132d21129210113e
parent ef5b800cf0a9c3990d1c6f350790da3d2c53f90e
Author: Pier Angelo Vendrame <pierov@torproject.org>
Date: Thu, 6 Nov 2025 14:18:32 +0000
Bug 1998435 - Do not reset the default zoom when clearing the FFP state. r=manuel
Differential Revision: https://phabricator.services.mozilla.com/D271446
Diffstat:
2 files changed, 43 insertions(+), 47 deletions(-)
diff --git a/browser/components/resistfingerprinting/test/browser/browser_bug1975753_site_specific_zoom_level.js b/browser/components/resistfingerprinting/test/browser/browser_bug1975753_site_specific_zoom_level.js
@@ -3,10 +3,14 @@
const PATH_NET = TEST_PATH + "file_dummy.html";
const PATH_ORG = PATH_NET.replace("example.net", "example.org");
-add_task(async function () {
+async function runTest(defaultZoom) {
let tab1, tab1Zoom;
tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, PATH_NET);
+
+ tab1Zoom = ZoomManager.getZoomForBrowser(tab1.linkedBrowser);
+ is(tab1Zoom, defaultZoom, "We are starting with the default zoom.");
+
await FullZoom.setZoom(1.25, tab1.linkedBrowser);
tab1Zoom = ZoomManager.getZoomForBrowser(tab1.linkedBrowser);
@@ -46,7 +50,7 @@ add_task(async function () {
is(
tab1Zoom,
- 1.0,
+ defaultZoom,
"privacy.resistFingerprinting is true, site-specific zoom should be reset when clearing FPP state for tab1"
);
@@ -55,4 +59,20 @@ add_task(async function () {
BrowserTestUtils.removeTab(tab1);
await SpecialPowers.popPrefEnv();
+}
+
+add_task(async function () {
+ await runTest(1.0);
+
+ let defaultZoom = 1.5;
+ let context = Cu.createLoadContext();
+ let cps2 = Cc["@mozilla.org/content-pref/service;1"].getService(
+ Ci.nsIContentPrefService2
+ );
+ cps2.setGlobal(FullZoom.name, defaultZoom, context);
+ try {
+ await runTest(defaultZoom);
+ } finally {
+ cps2.removeGlobal(FullZoom.name, context);
+ }
});
diff --git a/toolkit/components/cleardata/ClearDataService.sys.mjs b/toolkit/components/cleardata/ClearDataService.sys.mjs
@@ -438,11 +438,7 @@ const CookieBannerExecutedRecordCleaner = {
// A cleaner for cleaning fingerprinting protection states.
const FingerprintingProtectionStateCleaner = {
- async _maybeClearSiteSpecificZoom(
- deleteAll,
- aSchemelessSite,
- aOriginAttributes = {}
- ) {
+ async _maybeClearSiteSpecificZoom(aSchemelessSite, aOriginAttributes = {}) {
if (
!ChromeUtils.shouldResistFingerprinting("SiteSpecificZoom", null, true)
) {
@@ -455,8 +451,24 @@ const FingerprintingProtectionStateCleaner = {
const ZOOM_PREF_NAME = "browser.content.full-zoom";
await new Promise((aResolve, aReject) => {
- if (deleteAll) {
- cps2.removeByName(ZOOM_PREF_NAME, null, {
+ aOriginAttributes =
+ ChromeUtils.fillNonDefaultOriginAttributes(aOriginAttributes);
+
+ let loadContext;
+ if (
+ aOriginAttributes.privateBrowsingId ==
+ Services.scriptSecurityManager.DEFAULT_PRIVATE_BROWSING_ID
+ ) {
+ loadContext = Cu.createLoadContext();
+ } else {
+ loadContext = Cu.createPrivateLoadContext();
+ }
+
+ cps2.removeBySubdomainAndName(
+ aSchemelessSite,
+ ZOOM_PREF_NAME,
+ loadContext,
+ {
handleCompletion: aReason => {
if (aReason === cps2.COMPLETE_ERROR) {
aReject();
@@ -464,50 +476,19 @@ const FingerprintingProtectionStateCleaner = {
aResolve();
}
},
- });
- } else {
- aOriginAttributes =
- ChromeUtils.fillNonDefaultOriginAttributes(aOriginAttributes);
-
- let loadContext;
- if (
- aOriginAttributes.privateBrowsingId ==
- Services.scriptSecurityManager.DEFAULT_PRIVATE_BROWSING_ID
- ) {
- loadContext = Cu.createLoadContext();
- } else {
- loadContext = Cu.createPrivateLoadContext();
}
-
- cps2.removeBySubdomainAndName(
- aSchemelessSite,
- ZOOM_PREF_NAME,
- loadContext,
- {
- handleCompletion: aReason => {
- if (aReason === cps2.COMPLETE_ERROR) {
- aReject();
- } else {
- aResolve();
- }
- },
- }
- );
- }
+ );
});
},
async deleteAll() {
Services.rfp.cleanAllRandomKeys();
-
- await this._maybeClearSiteSpecificZoom(true);
},
async deleteByPrincipal(aPrincipal) {
Services.rfp.cleanRandomKeyByPrincipal(aPrincipal);
await this._maybeClearSiteSpecificZoom(
- false,
aPrincipal.host,
aPrincipal.originAttributes
);
@@ -520,7 +501,6 @@ const FingerprintingProtectionStateCleaner = {
);
await this._maybeClearSiteSpecificZoom(
- false,
aSchemelessSite,
aOriginAttributesPattern
);
@@ -532,11 +512,7 @@ const FingerprintingProtectionStateCleaner = {
JSON.stringify(aOriginAttributesPattern)
);
- await this._maybeClearSiteSpecificZoom(
- false,
- aHost,
- aOriginAttributesPattern
- );
+ await this._maybeClearSiteSpecificZoom(aHost, aOriginAttributesPattern);
},
async deleteByOriginAttributes(aOriginAttributesString) {