commit 4311ef2c3aa412cff96e8658b0c29c0699611904
parent ab84a7e4c545acc19e793568271cb02973e20980
Author: Max Christian Pohle <mpohle@mozilla.com>
Date: Fri, 31 Oct 2025 13:09:20 +0000
Bug 1993537 - Restored profile should have unique legacy client, r=cdupuis
Differential Revision: https://phabricator.services.mozilla.com/D270732
Diffstat:
3 files changed, 14 insertions(+), 67 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
diff --git a/browser/components/backup/tests/xpcshell/test_BackupService.js b/browser/components/backup/tests/xpcshell/test_BackupService.js
@@ -107,14 +107,6 @@ async function testCreateBackupHelper(sandbox, taskFn) {
"createBackupTest"
);
- let testTelemetryStateObject = {
- clientID: "ed209123-04a1-04a1-04a1-c0ffeec0ffee",
- };
- await IOUtils.writeJSON(
- PathUtils.join(PathUtils.profileDir, "datareporting", "state.json"),
- testTelemetryStateObject
- );
-
Assert.ok(!bs.state.lastBackupDate, "No backup date is stored in state.");
let { manifest, archivePath: backupFilePath } = await bs.createBackup({
profilePath: fakeProfilePath,
@@ -327,14 +319,12 @@ async function testCreateBackupHelper(sandbox, taskFn) {
"Should have post-recovery data from fake backup 3"
);
- let newProfileTelemetryStateObject = await IOUtils.readJSON(
- PathUtils.join(recoveredProfilePath, "datareporting", "state.json")
- );
- Assert.deepEqual(
- testTelemetryStateObject,
- newProfileTelemetryStateObject,
- "Recovered profile inherited telemetry state from the profile that " +
- "initiated recovery"
+ await Assert.rejects(
+ IOUtils.readJSON(
+ PathUtils.join(recoveredProfilePath, "datareporting", "state.json")
+ ),
+ /file does not exist/,
+ "The telemetry state was cleared."
);
await taskFn(bs, manifest);