Bug 1747893 - Fix credit cards not syncing correctly once disabled on subsequent startup. r=sgalich

Depends on D135076

Differential Revision: https://phabricator.services.mozilla.com/D137673
This commit is contained in:
Tim Giles 2022-02-08 19:32:00 +00:00
Родитель a887c814a4
Коммит 631334fa35
2 изменённых файлов: 4 добавлений и 41 удалений

Просмотреть файл

@ -862,29 +862,3 @@ add_task(async function test_creditCardFillDisabled() {
true
);
});
add_task(async function test_creditCardFillUnavailable() {
Services.prefs.setCharPref(
"extensions.formautofill.creditCards.supported",
"off"
);
let path = getTempFile(TEST_STORE_FILE_NAME).path;
let profileStorage = new FormAutofillStorage(path);
await profileStorage.initialize();
try {
profileStorage.creditCards; // eslint-disable-line no-unused-expressions
throw new Error("Access credit card didn't throw.");
} catch (err) {
Assert.equal(
err.message,
"CreditCards is not initialized. " +
"Please restart if you flip the pref manually."
);
}
Services.prefs.clearUserPref(
"extensions.formautofill.creditCards.availability"
);
});

Просмотреть файл

@ -1997,21 +1997,10 @@ class FormAutofillStorageBase {
if (!this._initializePromise) {
this._store = this._initializeStore();
this._initializePromise = this._store.load().then(() => {
let initializeAutofillRecords = [this.addresses.initialize()];
if (FormAutofill.isAutofillCreditCardsAvailable) {
initializeAutofillRecords.push(this.creditCards.initialize());
} else {
// Make creditCards records unavailable to other modules
// because we never initialize it.
Object.defineProperty(this, "creditCards", {
get() {
throw new Error(
"CreditCards is not initialized. " +
"Please restart if you flip the pref manually."
);
},
});
}
let initializeAutofillRecords = [
this.addresses.initialize(),
this.creditCards.initialize(),
];
return Promise.all(initializeAutofillRecords);
});
}