commit 3cfc7702e97072b45e5cc42123972a050788ecb0
parent 987c3ad1309488780e8831a074b28cbdb8377e7b
Author: Cristina Horotan <chorotan@mozilla.com>
Date: Thu, 16 Oct 2025 14:31:02 +0300
Revert "Bug 1993480, Bug 1993499 - ensure mirror is re-migrated after fixed import-mirroring - r=dimi,firefox-desktop-core-reviewers ,Gijs" for causing bc failures on browser_rust_mirror.js
This reverts commit 19f6a3de7a35c9e339550b6f20c42287dae176f6.
Revert "Bug 1993499 - Fix migration for profile change by restructuring rust store and mirror inits. r=credential-management-reviewers,dimi"
This reverts commit 14a8d0148214ac326452e66c03760f598c1cc66c.
Revert "Bug 1993480 - Rust store not mirrored during import - r=dimi"
This reverts commit 5bd559b895dbc783ec0dda05271191a1d1ed5737.
Diffstat:
6 files changed, 21 insertions(+), 98 deletions(-)
diff --git a/browser/components/BrowserGlue.sys.mjs b/browser/components/BrowserGlue.sys.mjs
@@ -1605,7 +1605,7 @@ BrowserGlue.prototype = {
// Use an increasing number to keep track of the current state of the user's
// profile, so we can move data around as needed as the browser evolves.
// Completely unrelated to the current Firefox release number.
- const APP_DATA_VERSION = 162;
+ const APP_DATA_VERSION = 161;
const PREF = "browser.migration.version";
let profileDataVersion = Services.prefs.getIntPref(PREF, -1);
diff --git a/browser/components/ProfileDataUpgrader.sys.mjs b/browser/components/ProfileDataUpgrader.sys.mjs
@@ -929,8 +929,7 @@ export let ProfileDataUpgrader = {
Services.prefs.setBoolPref("signon.reencryptionNeeded", true);
}
- // Updating from 161 to 162 to trigger the re-migration of the Rusts store.
- if (existingDataVersion < 162) {
+ if (existingDataVersion < 161) {
// Force all logins to be re-migrated to the rust store.
Services.prefs.setBoolPref("signon.rustMirror.migrationNeeded", true);
}
diff --git a/toolkit/components/passwordmgr/LoginHelper.sys.mjs b/toolkit/components/passwordmgr/LoginHelper.sys.mjs
@@ -1413,11 +1413,9 @@ export const LoginHelper = {
* @returns {Object[]} An entry for each processed row containing how the row was processed and the login data.
*/
async maybeImportLogins(loginDatas) {
- // by setting this flag we ensure no events are submitted
this.importing = true;
- const processor = new ImportRowProcessor();
-
try {
+ const processor = new ImportRowProcessor();
for (let rawLoginData of loginDatas) {
// Do some sanitization on a clone of the loginData.
let loginData = ChromeUtils.shallowClone(rawLoginData);
@@ -1712,7 +1710,6 @@ export const LoginHelper = {
* Send a notification when stored data is changed.
*/
notifyStorageChanged(changeType, data) {
- // do not emit individual events during csv import
if (this.importing) {
return;
}
diff --git a/toolkit/components/passwordmgr/LoginManagerRustMirror.sys.mjs b/toolkit/components/passwordmgr/LoginManagerRustMirror.sys.mjs
@@ -249,10 +249,8 @@ export class LoginManagerRustMirror {
}
break;
- // re-migrate on importLogins event
case "importLogins":
- this.#logger.log("re-migrating logins after import...");
- await this.#migrate();
+ // ignoring importLogins event
break;
default:
@@ -262,6 +260,11 @@ export class LoginManagerRustMirror {
}
async #maybeRunMigration() {
+ if (this.#migrationInProgress) {
+ this.#logger.log("Migration already in progress.");
+ return;
+ }
+
if (!this.#isEnabled || lazy.LoginHelper.isPrimaryPasswordSet()) {
this.#logger.log("Mirror is not active. Migration will not run.");
return;
@@ -278,24 +281,16 @@ export class LoginManagerRustMirror {
return;
}
- this.#logger.log("Migration is needed");
-
- await this.#migrate();
- }
-
- async #migrate() {
- if (this.#migrationInProgress) {
- this.#logger.log("Migration already in progress.");
- return;
- }
-
- this.#logger.log("Starting migration...");
+ this.#logger.log("Migration is needed, migrating...");
// We ignore events during migration run. Once we switch the
// stores over, we will run an initial migration again to ensure
// consistancy.
this.#migrationInProgress = true;
+ // wait until loaded
+ await this.#jsonStorage.initializationPromise;
+
const t0 = Date.now();
const runId = Services.uuid.generateUUID();
let numberOfLoginsToMigrate = 0;
diff --git a/toolkit/components/passwordmgr/storage-desktop.sys.mjs b/toolkit/components/passwordmgr/storage-desktop.sys.mjs
@@ -24,12 +24,14 @@ export class LoginManagerStorage extends LoginManagerStorage_json {
this.#jsonStorage = new LoginManagerStorage_json();
this.#rustStorage = new LoginManagerRustStorage();
- this.#initializationPromise = this.#jsonStorage
- .initialize()
- .then(() => this.#rustStorage.initialize())
- .then(() => {
- new LoginManagerRustMirror(this.#jsonStorage, this.#rustStorage);
- });
+ new LoginManagerRustMirror(this.#jsonStorage, this.#rustStorage);
+
+ this.#initializationPromise = new Promise(resolve =>
+ this.#jsonStorage
+ .initialize()
+ .then(() => this.#rustStorage.initialize())
+ .then(resolve)
+ );
}
this.#initializationPromise.then(() => callback?.());
diff --git a/toolkit/components/passwordmgr/test/browser/browser_rust_mirror.js b/toolkit/components/passwordmgr/test/browser/browser_rust_mirror.js
@@ -11,9 +11,6 @@ const { LoginManagerRustStorage } = ChromeUtils.importESModule(
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
-const { LoginCSVImport } = ChromeUtils.importESModule(
- "resource://gre/modules/LoginCSVImport.sys.mjs"
-);
/**
* Tests addLogin gets synced to Rust Storage
@@ -112,73 +109,6 @@ add_task(async function test_mirror_removeLogin() {
});
/**
- * Tests CSV import: addition gets synced to Rust Storage
- */
-add_task(async function test_mirror_csv_import_add() {
- await SpecialPowers.pushPrefEnv({
- set: [["signon.rustMirror.enabled", true]],
- });
-
- let csvFile = await LoginTestUtils.file.setupCsvFileWithLines([
- "url,username,password,httpRealm,formActionOrigin,guid,timeCreated,timeLastUsed,timePasswordChanged",
- `https://example.com,joe@example.com,qwerty,My realm,,{5ec0d12f-e194-4279-ae1b-d7d281bb46f0},1589617814635,1589710449871,1589617846802`,
- ]);
- await LoginCSVImport.importFromCSV(csvFile.path);
-
- // note LoginManagerRustStorage is a singleton and already initialized when
- // Services.logins gets initialized.
- const rustStorage = new LoginManagerRustStorage();
-
- const storedLoginInfos = await Services.logins.getAllLogins();
- const rustStoredLoginInfos = await rustStorage.getAllLogins();
- LoginTestUtils.assertLoginListsEqual(storedLoginInfos, rustStoredLoginInfos);
-
- LoginTestUtils.clearData();
- rustStorage.removeAllLogins();
- await SpecialPowers.flushPrefEnv();
-});
-
-/**
- * Tests CSV import: modification gets synced to Rust Storage
- */
-add_task(async function test_mirror_csv_import_modify() {
- await SpecialPowers.pushPrefEnv({
- set: [["signon.rustMirror.enabled", true]],
- });
-
- // create a login
- const loginInfo = LoginTestUtils.testData.formLogin({
- origin: "https://example.com",
- username: "username",
- password: "password",
- });
- const login = await Services.logins.addLoginAsync(loginInfo);
- // and import it, so we update
- let csvFile = await LoginTestUtils.file.setupCsvFileWithLines([
- "url,username,password,httpRealm,formActionOrigin,guid,timeCreated,timeLastUsed,timePasswordChanged",
- `https://example.com,username,qwerty,My realm,,${login.guid},1589617814635,1589710449871,1589617846802`,
- ]);
- await LoginCSVImport.importFromCSV(csvFile.path);
-
- // note LoginManagerRustStorage is a singleton and already initialized when
- // Services.logins gets initialized.
- const rustStorage = new LoginManagerRustStorage();
-
- const [storedLoginInfo] = await Services.logins.getAllLogins();
- const [rustStoredLoginInfo] = await rustStorage.getAllLogins();
-
- Assert.equal(
- storedLoginInfo.password,
- rustStoredLoginInfo.password,
- "password has been updated via csv import"
- );
-
- LoginTestUtils.clearData();
- rustStorage.removeAllLogins();
- await SpecialPowers.flushPrefEnv();
-});
-
-/**
* Verifies that the migration is triggered by according pref change
*/
add_task(async function test_migration_is_triggered_by_pref_change() {