Pier Angelo Vendrame pushed to branch mullvad-browser-140.5.0esr-15.0-1 at The Tor Project / Applications / Mullvad Browser Commits: 0ce96cef by Pier Angelo Vendrame at 2025-11-10T10:49:23+01:00 Bug 1998435 - Do not reset the default zoom when clearing the FFP state. r=manuel Differential Revision: https://phabricator.services.mozilla.com/D271446 - - - - - 2 changed files: - browser/components/resistfingerprinting/test/browser/browser_bug1975753_site_specific_zoom_level.js - toolkit/components/cleardata/ClearDataService.sys.mjs Changes: ===================================== 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,29 @@ 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 + ); + let { promise, resolve, reject } = Promise.withResolvers(); + cps2.setGlobal(FullZoom.name, defaultZoom, context, { + handleError(error) { + reject(error); + }, + handleCompletion() { + resolve(); + }, + }); + await promise; + try { + await runTest(defaultZoom); + } finally { + cps2.removeGlobal(FullZoom.name, context); + } }); ===================================== toolkit/components/cleardata/ClearDataService.sys.mjs ===================================== @@ -415,11 +415,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) ) { @@ -432,8 +428,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(); @@ -441,50 +453,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 ); @@ -497,7 +478,6 @@ const FingerprintingProtectionStateCleaner = { ); await this._maybeClearSiteSpecificZoom( - false, aSchemelessSite, aOriginAttributesPattern ); @@ -509,11 +489,7 @@ const FingerprintingProtectionStateCleaner = { JSON.stringify(aOriginAttributesPattern) ); - await this._maybeClearSiteSpecificZoom( - false, - aHost, - aOriginAttributesPattern - ); + await this._maybeClearSiteSpecificZoom(aHost, aOriginAttributesPattern); }, async deleteByOriginAttributes(aOriginAttributesString) { View it on GitLab: https://gitlab.torproject.org/tpo/applications/mullvad-browser/-/commit/0ce9... -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/mullvad-browser/-/commit/0ce9... You're receiving this email because of your account on gitlab.torproject.org.
participants (1)
-
Pier Angelo Vendrame (@pierov)