зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1474143 - Use sharedData instead of initialProcessData for autofillSavedFieldNames. r=Felipe
Differential Revision: https://phabricator.services.mozilla.com/D16646 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
d79b44b156
Коммит
9509d5a093
|
@ -345,7 +345,9 @@ var FormAutofillContent = {
|
|||
/**
|
||||
* @type {Set} Set of the fields with usable values in any saved profile.
|
||||
*/
|
||||
savedFieldNames: null,
|
||||
get savedFieldNames() {
|
||||
return Services.cpmm.sharedData.get("FormAutofill:savedFieldNames");
|
||||
},
|
||||
|
||||
/**
|
||||
* @type {Object} The object where to store the active items, e.g. element,
|
||||
|
@ -357,7 +359,6 @@ var FormAutofillContent = {
|
|||
FormAutofill.defineLazyLogGetter(this, "FormAutofillContent");
|
||||
|
||||
Services.cpmm.addMessageListener("FormAutofill:enabledStatus", this);
|
||||
Services.cpmm.addMessageListener("FormAutofill:savedFieldNames", this);
|
||||
Services.obs.addObserver(this, "earlyformsubmit");
|
||||
|
||||
let autofillEnabled = Services.cpmm.initialProcessData.autofillEnabled;
|
||||
|
@ -370,9 +371,6 @@ var FormAutofillContent = {
|
|||
if (autofillEnabled || shouldEnableAutofill) {
|
||||
ProfileAutocomplete.ensureRegistered();
|
||||
}
|
||||
|
||||
this.savedFieldNames =
|
||||
Services.cpmm.initialProcessData.autofillSavedFieldNames;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -440,9 +438,6 @@ var FormAutofillContent = {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case "FormAutofill:savedFieldNames": {
|
||||
this.savedFieldNames = data;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ FormAutofillParent.prototype = {
|
|||
* @returns {boolean} whether form autofill is active (enabled and has data)
|
||||
*/
|
||||
_computeStatus() {
|
||||
const savedFieldNames = Services.ppmm.initialProcessData.autofillSavedFieldNames;
|
||||
const savedFieldNames = Services.ppmm.sharedData.get("FormAutofill:savedFieldNames");
|
||||
|
||||
return (Services.prefs.getBoolPref(ENABLED_AUTOFILL_ADDRESSES_PREF) ||
|
||||
Services.prefs.getBoolPref(ENABLED_AUTOFILL_CREDITCARDS_PREF)) &&
|
||||
|
@ -375,18 +375,19 @@ FormAutofillParent.prototype = {
|
|||
_updateSavedFieldNames() {
|
||||
log.debug("_updateSavedFieldNames");
|
||||
|
||||
let savedFieldNames;
|
||||
// Don't access the credit cards store unless it is enabled.
|
||||
if (FormAutofill.isAutofillCreditCardsAvailable) {
|
||||
Services.ppmm.initialProcessData.autofillSavedFieldNames =
|
||||
new Set([...this.formAutofillStorage.addresses.getSavedFieldNames(),
|
||||
...this.formAutofillStorage.creditCards.getSavedFieldNames()]);
|
||||
savedFieldNames = new Set([
|
||||
...this.formAutofillStorage.addresses.getSavedFieldNames(),
|
||||
...this.formAutofillStorage.creditCards.getSavedFieldNames(),
|
||||
]);
|
||||
} else {
|
||||
Services.ppmm.initialProcessData.autofillSavedFieldNames =
|
||||
this.formAutofillStorage.addresses.getSavedFieldNames();
|
||||
savedFieldNames = this.formAutofillStorage.addresses.getSavedFieldNames();
|
||||
}
|
||||
|
||||
Services.ppmm.broadcastAsyncMessage("FormAutofill:savedFieldNames",
|
||||
Services.ppmm.initialProcessData.autofillSavedFieldNames);
|
||||
Services.ppmm.sharedData.set("FormAutofill:savedFieldNames", savedFieldNames);
|
||||
|
||||
this._updateStatus();
|
||||
},
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Test for keeping the valid fields information in initialProcessData.
|
||||
* Test for keeping the valid fields information in sharedData.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
@ -54,7 +54,7 @@ add_task(async function test_profileSavedFieldNames_update() {
|
|||
|
||||
// The set is empty if there's no profile in the store.
|
||||
formAutofillParent._updateSavedFieldNames();
|
||||
Assert.equal(Services.ppmm.initialProcessData.autofillSavedFieldNames.size, 0);
|
||||
Assert.equal(Services.ppmm.sharedData.get("FormAutofill:savedFieldNames").size, 0);
|
||||
|
||||
// 2 profiles with 4 valid fields.
|
||||
formAutofillParent.formAutofillStorage.addresses._data = [{
|
||||
|
@ -81,7 +81,7 @@ add_task(async function test_profileSavedFieldNames_update() {
|
|||
|
||||
formAutofillParent._updateSavedFieldNames();
|
||||
|
||||
let autofillSavedFieldNames = Services.ppmm.initialProcessData.autofillSavedFieldNames;
|
||||
let autofillSavedFieldNames = Services.ppmm.sharedData.get("FormAutofill:savedFieldNames");
|
||||
Assert.equal(autofillSavedFieldNames.size, 4);
|
||||
Assert.equal(autofillSavedFieldNames.has("organization"), true);
|
||||
Assert.equal(autofillSavedFieldNames.has("street-address"), true);
|
||||
|
|
Загрузка…
Ссылка в новой задаче