tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 5b860ce34a5cc47618f1433d6671c90745f0a4a6
parent ea90b161fe6c4fc6ce870312f1a1c6190b07bb94
Author: Harsheet <hsohaney@mozilla.com>
Date:   Wed, 22 Oct 2025 12:22:29 +0000

Bug 1994874 - Don't backup the user's backup preferences. r=cdupuis,sthompson

Differential Revision: https://phabricator.services.mozilla.com/D269288

Diffstat:
Mbrowser/components/backup/resources/PreferencesBackupResource.sys.mjs | 5++++-
Mbrowser/components/backup/tests/xpcshell/test_PreferencesBackupResource_Nimbus.js | 15+++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/browser/components/backup/resources/PreferencesBackupResource.sys.mjs b/browser/components/backup/resources/PreferencesBackupResource.sys.mjs @@ -36,12 +36,15 @@ export class PreferencesBackupResource extends BackupResource { */ static addPrefsToIgnoreInBackup(prefsOverrideMap) { // List of prefs we never backup. - const kIgnoredPrefs = [ + let kIgnoredPrefs = [ "app.normandy.user_id", "toolkit.telemetry.cachedProfileGroupID", PROFILE_RESTORATION_DATE_PREF, ]; + const backupPrefs = Services.prefs.getChildList("browser.backup."); + kIgnoredPrefs = kIgnoredPrefs.concat(backupPrefs); + // Prefs with this prefix are always overriden. const kNimbusMetadataPrefPrefix = "nimbus."; diff --git a/browser/components/backup/tests/xpcshell/test_PreferencesBackupResource_Nimbus.js b/browser/components/backup/tests/xpcshell/test_PreferencesBackupResource_Nimbus.js @@ -188,6 +188,20 @@ function checkNimbusHasSetPrefs() { Assert.deepEqual(jsonTestValue, parsedJson); } +async function checkIgnoredBackupPrefs(backupPrefsFilePath) { + let contents = (await IOUtils.readUTF8(backupPrefsFilePath)) + .split("\n") + .map(line => line.trim()); + + let checkPrefNotSerialized = pref => { + Assert.ok( + !contents.reduce((acc, line) => acc || line.includes(pref), false) + ); + }; + + checkPrefNotSerialized("browser.backup."); +} + async function checkBackupIgnoredNimbusPrefs(backupPrefsFilePath) { let contents = (await IOUtils.readUTF8(backupPrefsFilePath)) .split("\n") @@ -281,6 +295,7 @@ add_task(async function test_prefs_backup_does_not_backup_nimbus_prefs() { checkNimbusHasSetPrefs(); const { sandbox, stagingPath, sourcePath } = await performBackup(); await checkBackupIgnoredNimbusPrefs(PathUtils.join(stagingPath, "prefs.js")); + await checkIgnoredBackupPrefs(PathUtils.join(stagingPath, "prefs.js")); await maybeRemovePath(stagingPath); await maybeRemovePath(sourcePath); sandbox.restore();