tor-browser

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

commit d8c8dd249dc40a457dd62d87a342ace52f23bd80
parent 50445a0ee5bbeaeba68911b649963669e4c483e2
Author: Max Christian Pohle <mpohle@mozilla.com>
Date:   Thu, 30 Oct 2025 21:51:52 +0000

Bug 1993537 - Restored profile should have unique legacy client, r=cdupuis

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

Diffstat:
Mbrowser/components/backup/BackupService.sys.mjs | 43-------------------------------------------
Mbrowser/components/backup/tests/marionette/test_backup.py | 16++++++++--------
2 files changed, 8 insertions(+), 51 deletions(-)

diff --git a/browser/components/backup/BackupService.sys.mjs b/browser/components/backup/BackupService.sys.mjs @@ -3089,41 +3089,6 @@ export class BackupService extends EventTarget { } /** - * Make sure the legacy telemetry client ID exists and write telemetry files - * to the profile we are recovering into. - * - * @param {string} profilePath The path of the newly recovered profile - */ - async #writeTelemetryFiles(profilePath) { - // Make sure that a legacy telemetry client ID exists and is written to - // disk. - let clientID = await lazy.ClientID.getClientID(); - lazy.logConsole.debug("Current client ID: ", clientID); - // Next, copy over the legacy telemetry client ID state from the currently - // running profile. The newly created profile that we're recovering into - // should inherit this client ID. - const TELEMETRY_STATE_FILENAME = "state.json"; - const TELEMETRY_STATE_FOLDER = "datareporting"; - await IOUtils.makeDirectory( - PathUtils.join(profilePath, TELEMETRY_STATE_FOLDER) - ); - await IOUtils.copy( - /* source */ - PathUtils.join( - PathUtils.profileDir, - TELEMETRY_STATE_FOLDER, - TELEMETRY_STATE_FILENAME - ), - /* destination */ - PathUtils.join( - profilePath, - TELEMETRY_STATE_FOLDER, - TELEMETRY_STATE_FILENAME - ) - ); - } - - /** * If the encState exists, write the encrypted state object to the * ARCHIVE_ENCRYPTION_STATE_FILE. * @@ -3237,8 +3202,6 @@ export class BackupService extends EventTarget { profile.rootDir.path ); - await this.#writeTelemetryFiles(profile.rootDir.path); - await this.#maybeWriteEncryptedStateObject( encState, profile.rootDir.path @@ -3343,12 +3306,6 @@ export class BackupService extends EventTarget { profile.path ); - // We don't want to copy the client ID if this is a copied profile - // because this profile will be a new profile in the profile group. - if (!copiedProfile) { - await this.#writeTelemetryFiles(profile.path); - } - await this.#maybeWriteEncryptedStateObject(encState, profile.path); await this.#writePostRecoveryData(postRecovery, profile.path); diff --git a/browser/components/backup/tests/marionette/test_backup.py b/browser/components/backup/tests/marionette/test_backup.py @@ -163,11 +163,11 @@ class BackupTest(MarionetteTestCase): # Recover the created backup into a new profile directory. Also get out # the client ID of this profile, because we're going to want to make - # sure that this client ID is inherited by the recovered profile. + # sure that this client ID is not inherited from the intermediate profile. [ newProfileName, newProfilePath, - expectedClientID, + intermediateClientID, osKeyStoreLabel, ] = self.marionette.execute_async_script( """ @@ -201,9 +201,9 @@ class BackupTest(MarionetteTestCase): throw new Error("Could not create recovery profile."); } - let expectedClientID = await ClientID.getClientID(); + let intermediateClientID = await ClientID.getClientID(); - return [newProfile.name, newProfile.rootDir.path, expectedClientID, OSKeyStore.STORE_LABEL]; + return [newProfile.name, newProfile.rootDir.path, intermediateClientID, OSKeyStore.STORE_LABEL]; })().then(outerResolve); """, script_args=[archivePath, recoveryCode, recoveryPath], @@ -211,7 +211,7 @@ class BackupTest(MarionetteTestCase): print(f"Recovery name: {newProfileName}") print(f"Recovery path: {newProfilePath}") - print(f"Expected clientID: {expectedClientID}") + print(f"Intermediate clientID: {intermediateClientID}") print(f"Persisting fake OSKeyStore label: {osKeyStoreLabel}") self.marionette.quit() @@ -270,8 +270,8 @@ class BackupTest(MarionetteTestCase): script_args=[osKeyStoreLabel], ) - # Now also ensure that the recovered profile inherited the client ID - # from the profile that initiated recovery. + # Now also ensure that the recovered profile new client ID and not that + # one from the intermediate profile that initiated recovery. recoveredClientID = self.marionette.execute_async_script( """ const { ClientID } = ChromeUtils.importESModule("resource://gre/modules/ClientID.sys.mjs"); @@ -281,7 +281,7 @@ class BackupTest(MarionetteTestCase): })().then(outerResolve); """ ) - self.assertEqual(recoveredClientID, expectedClientID) + self.assertNotEqual(recoveredClientID, intermediateClientID) self.marionette.quit() self.marionette.instance.profile = originalProfile