зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1505141 - Always preserveOldProperties for payment request but blank mailing address fields by default. r=jaws
Differential Revision: https://phabricator.services.mozilla.com/D12190 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
f036261bf0
Коммит
4d0cbeac7f
|
@ -662,10 +662,12 @@ var paymentDialogWrapper = {
|
|||
formAutofillStorage[collectionName];
|
||||
|
||||
if (guid) {
|
||||
// We only care to preserve old properties for credit cards,
|
||||
// because credit cards don't get their full record sent to the
|
||||
// unprivileged frame (the cc-number is excluded).
|
||||
let preserveOldProperties = collectionName == "creditCards";
|
||||
// We want to preserve old properties since the edit forms are often
|
||||
// shown without all fields visible/enabled and we don't want those
|
||||
// fields to be blanked upon saving. Examples of hidden/disabled fields:
|
||||
// email, cc-number, mailing-address on the payer forms, and payer fields
|
||||
// not requested in the payer form.
|
||||
let preserveOldProperties = true;
|
||||
await collection.update(guid, record, preserveOldProperties);
|
||||
} else {
|
||||
responseMessage.guid = await collection.add(record);
|
||||
|
|
|
@ -174,6 +174,7 @@ add_task(async function test_saveButton() {
|
|||
"additional-name": "",
|
||||
"organization": "Allizom",
|
||||
"street-address": "404 Internet Super Highway",
|
||||
"address-level3": "",
|
||||
"address-level2": "Firefoxity City",
|
||||
"address-level1": "CA",
|
||||
"postal-code": "00001",
|
||||
|
|
|
@ -48,16 +48,29 @@ class EditAutofillForm {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get inputs from the form.
|
||||
* Get a record from the form suitable for a save/update in storage.
|
||||
* @returns {object}
|
||||
*/
|
||||
buildFormObject() {
|
||||
let initialObject = {};
|
||||
if (this.hasMailingAddressFields) {
|
||||
// Start with an empty string for each mailing-address field so that any
|
||||
// fields hidden for the current country are blanked in the return value.
|
||||
initialObject = {
|
||||
"street-address": "",
|
||||
"address-level3": "",
|
||||
"address-level2": "",
|
||||
"address-level1": "",
|
||||
"postal-code": "",
|
||||
};
|
||||
}
|
||||
|
||||
return Array.from(this._elements.form.elements).reduce((obj, input) => {
|
||||
if (!input.disabled) {
|
||||
obj[input.id] = input.value;
|
||||
}
|
||||
return obj;
|
||||
}, {});
|
||||
}, initialObject);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -158,6 +171,11 @@ class EditAddress extends EditAutofillForm {
|
|||
this.formatForm(record.country);
|
||||
}
|
||||
|
||||
get hasMailingAddressFields() {
|
||||
let {addressFields} = this._elements.form.dataset;
|
||||
return !addressFields || addressFields.trim().split(/\s+/).includes("mailing-address");
|
||||
}
|
||||
|
||||
/**
|
||||
* `mailing-address` is a special attribute token to indicate mailing fields + country.
|
||||
*
|
||||
|
@ -239,7 +257,11 @@ class EditAddress extends EditAutofillForm {
|
|||
* @param {Set} requiredFields Set of `fieldId` strings that mark which fields are required
|
||||
*/
|
||||
arrangeFields(fieldsOrder, requiredFields) {
|
||||
/**
|
||||
* @see FormAutofillStorage.VALID_ADDRESS_FIELDS
|
||||
*/
|
||||
let fields = [
|
||||
// `name` is a wrapper for the 3 name fields.
|
||||
"name",
|
||||
"organization",
|
||||
"street-address",
|
||||
|
|
Загрузка…
Ссылка в новой задаче