tor-browser

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

commit ab1493fa25dfd42d4b6a839533839c12df8c8848
parent fccb4d38061687a6bc0864f5194264a2216187b2
Author: Harsheet <hsohaney@mozilla.com>
Date:   Tue, 14 Oct 2025 17:01:46 +0000

Bug 1991953 - Set restored profile as default if old profile was default; rename to old-[profile name]. r=kpatenio

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

Diffstat:
Mbrowser/components/backup/BackupService.sys.mjs | 13+++++++++++++
Mbrowser/components/backup/tests/xpcshell/test_BackupService.js | 22+++++++++++++++++++++-
2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/browser/components/backup/BackupService.sys.mjs b/browser/components/backup/BackupService.sys.mjs @@ -2989,6 +2989,19 @@ export class BackupService extends EventTarget { ); await IOUtils.writeJSON(postRecoveryPath, postRecovery); + // In a release scenario, this should always be true + // this makes it easier to get around setting up profiles for testing other functionality + if (profileSvc.currentProfile) { + // if our current profile was default, let's make the new one default + if (profileSvc.currentProfile === profileSvc.defaultProfile) { + profileSvc.defaultProfile = profile; + } + + // let's rename the old profile with a prefix old-[profile_name] + profile.name = profileSvc.currentProfile.name; + profileSvc.currentProfile.name = `old-${profileSvc.currentProfile.name}`; + } + await profileSvc.asyncFlush(); if (shouldLaunch) { diff --git a/browser/components/backup/tests/xpcshell/test_BackupService.js b/browser/components/backup/tests/xpcshell/test_BackupService.js @@ -273,6 +273,14 @@ async function testCreateBackupHelper(sandbox, taskFn) { "createBackupTestRecoveredProfile" ); + let originalProfileName = currentProfile.name; + + let profileSvc = Cc["@mozilla.org/toolkit/profile-service;1"].getService( + Ci.nsIToolkitProfileService + ); + // make our current profile default + profileSvc.defaultProfile = currentProfile; + let recoveredProfile = await bs.recoverFromBackupArchive( backupFilePath, null, @@ -282,10 +290,22 @@ async function testCreateBackupHelper(sandbox, taskFn) { ); Assert.ok( - recoveredProfile.name.startsWith(currentProfile.name), + recoveredProfile.name.startsWith(originalProfileName), "Should maintain profile name across backup and restore" ); + Assert.strictEqual( + currentProfile.name, + `old-${originalProfileName}`, + "The old profile should be prefixed with old-" + ); + + Assert.strictEqual( + profileSvc.defaultProfile, + recoveredProfile, + "The new profile should now be the default" + ); + // Check that resources were recovered from highest to lowest backup priority. sinon.assert.callOrder( FakeBackupResource3.prototype.recover,