tor-browser

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

commit 9383341578da9ef00e5050262269e3c92fee39be
parent f61c65db67512b5b3034fc29ca4e78f8ea0023fa
Author: Serban Stanca <sstanca@mozilla.com>
Date:   Fri, 31 Oct 2025 02:02:27 +0200

Revert "Bug 1993537 - Restored profile should have unique legacy client, r=cdupuis" for causing xpcshell failures in test_BackupService.js.

This reverts commit d8c8dd249dc40a457dd62d87a342ace52f23bd80.

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

diff --git a/browser/components/backup/BackupService.sys.mjs b/browser/components/backup/BackupService.sys.mjs @@ -3089,6 +3089,41 @@ 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. * @@ -3202,6 +3237,8 @@ export class BackupService extends EventTarget { profile.rootDir.path ); + await this.#writeTelemetryFiles(profile.rootDir.path); + await this.#maybeWriteEncryptedStateObject( encState, profile.rootDir.path @@ -3306,6 +3343,12 @@ 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 not inherited from the intermediate profile. + # sure that this client ID is inherited by the recovered profile. [ newProfileName, newProfilePath, - intermediateClientID, + expectedClientID, osKeyStoreLabel, ] = self.marionette.execute_async_script( """ @@ -201,9 +201,9 @@ class BackupTest(MarionetteTestCase): throw new Error("Could not create recovery profile."); } - let intermediateClientID = await ClientID.getClientID(); + let expectedClientID = await ClientID.getClientID(); - return [newProfile.name, newProfile.rootDir.path, intermediateClientID, OSKeyStore.STORE_LABEL]; + return [newProfile.name, newProfile.rootDir.path, expectedClientID, 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"Intermediate clientID: {intermediateClientID}") + print(f"Expected clientID: {expectedClientID}") 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 new client ID and not that - # one from the intermediate profile that initiated recovery. + # Now also ensure that the recovered profile inherited the client ID + # from the 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.assertNotEqual(recoveredClientID, intermediateClientID) + self.assertEqual(recoveredClientID, expectedClientID) self.marionette.quit() self.marionette.instance.profile = originalProfile