diff --git a/browser/components/payments/res/containers/address-form.js b/browser/components/payments/res/containers/address-form.js index e660f8d0ad37..1c18f558871f 100644 --- a/browser/components/payments/res/containers/address-form.js +++ b/browser/components/payments/res/containers/address-form.js @@ -95,6 +95,7 @@ export default class AddressForm extends PaymentStateSubscriberMixin(PaymentRequ // validity will be updated before our handlers get the event this.form.addEventListener("input", this); this.form.addEventListener("invalid", this); + this.form.addEventListener("change", this); this.body.appendChild(this.persistCheckbox); this.body.appendChild(this.genericErrorText); @@ -210,6 +211,10 @@ export default class AddressForm extends PaymentStateSubscriberMixin(PaymentRequ handleEvent(event) { switch (event.type) { + case "change": { + this.updateSaveButtonState(); + break; + } case "click": { this.onClick(event); break; diff --git a/browser/components/payments/test/mochitest/test_address_form.html b/browser/components/payments/test/mochitest/test_address_form.html index d1f09ca45320..062625f64e16 100644 --- a/browser/components/payments/test/mochitest/test_address_form.html +++ b/browser/components/payments/test/mochitest/test_address_form.html @@ -141,6 +141,11 @@ add_task(async function test_saveButton() { is(form.querySelectorAll(":-moz-ui-invalid").length, 0, "Check no fields visibly invalid"); ok(!form.saveButton.disabled, "Save button is enabled after re-filling street-address"); + fillField(form.form.querySelector("#country"), "CA"); + ok(form.saveButton.disabled, "Save button is disabled after changing the country to Canada"); + fillField(form.form.querySelector("#country"), "US"); + ok(!form.saveButton.disabled, "Save button is enabled after changing the country to US"); + let messagePromise = promiseContentToChromeMessage("updateAutofillRecord"); is(form.saveButton.textContent, "Add", "Check label"); form.saveButton.scrollIntoView(); diff --git a/browser/components/payments/test/mochitest/test_basic_card_form.html b/browser/components/payments/test/mochitest/test_basic_card_form.html index 29813393ffe3..10a8cc185f38 100644 --- a/browser/components/payments/test/mochitest/test_basic_card_form.html +++ b/browser/components/payments/test/mochitest/test_basic_card_form.html @@ -116,6 +116,17 @@ add_task(async function test_saveButton() { ok(!form.saveButton.disabled, "Save button should be enabled since the required fields are filled"); + fillField(form.form.querySelector("#cc-exp-month"), ""); + fillField(form.form.querySelector("#cc-exp-year"), ""); + form.saveButton.focus(); + ok(form.saveButton.disabled, + "Save button should be disabled since the required fields are empty"); + fillField(form.form.querySelector("#cc-exp-month"), "11"); + fillField(form.form.querySelector("#cc-exp-year"), year); + form.saveButton.focus(); + ok(!form.saveButton.disabled, + "Save button should be enabled since the required fields are filled again"); + info("blanking the cc-number field"); fillField(form.form.querySelector("#cc-number"), ""); ok(form.saveButton.disabled, "Save button is disabled after blanking cc-number"); @@ -381,6 +392,8 @@ add_task(async function test_field_validity_updates() { let ccNumber = form.form.querySelector("#cc-number"); let nameInput = form.form.querySelector("#cc-name"); + let monthInput = form.form.querySelector("#cc-exp-month"); + let yearInput = form.form.querySelector("#cc-exp-year"); info("test with valid cc-number but missing cc-name"); fillField(ccNumber, "4111111111111111"); @@ -388,10 +401,15 @@ add_task(async function test_field_validity_updates() { ok(!nameInput.checkValidity(), "cc-name field is invalid when empty"); ok(form.saveButton.disabled, "Save button should be disabled with incomplete input"); - info("correct by adding cc-name value"); + info("correct by adding cc-name and expiration values"); fillField(nameInput, "First"); + fillField(monthInput, "11"); + let year = (new Date()).getFullYear().toString(); + fillField(yearInput, year); ok(ccNumber.checkValidity(), "cc-number field is valid with good input"); ok(nameInput.checkValidity(), "cc-name field is valid with a value"); + ok(monthInput.checkValidity(), "cc-exp-month field is valid with a value"); + ok(yearInput.checkValidity(), "cc-exp-year field is valid with a value"); ok(!form.saveButton.disabled, "Save button should not be disabled with good input"); info("edit to make the cc-number invalid"); diff --git a/browser/components/preferences/in-content/main.js b/browser/components/preferences/in-content/main.js index 94438268632a..44d701db5409 100644 --- a/browser/components/preferences/in-content/main.js +++ b/browser/components/preferences/in-content/main.js @@ -1553,14 +1553,23 @@ var gMainPane = { if (this._filter.value) visibleTypes = visibleTypes.filter(this._matchesFilter, this); - for (let visibleType of visibleTypes) { - let item = new HandlerListItem(visibleType); - item.connectAndAppendToList(this._list); - - if (visibleType.type === lastSelectedType) { - this._list.selectedItem = item.node; + let items = visibleTypes.map(visibleType => new HandlerListItem(visibleType)); + let itemsFragment = document.createDocumentFragment(); + let lastSelectedItem; + for (let item of items) { + item.createNode(itemsFragment); + if (item.handlerInfoWrapper.type == lastSelectedType) { + lastSelectedItem = item; } } + this._list.appendChild(itemsFragment); + for (let item of items) { + item.setupNode(); + } + + if (lastSelectedItem) { + this._list.selectedItem = lastSelectedItem.node; + } }, _matchesFilter(aType) { @@ -2496,11 +2505,13 @@ class HandlerListItem { } } - connectAndAppendToList(list) { + createNode(list) { list.appendChild(document.importNode(gHandlerListItemFragment, true)); this.node = list.lastChild; gNodeToObjectMap.set(this.node, this); + } + setupNode() { this.node.querySelector(".actionsMenu").addEventListener("command", event => gMainPane.onSelectAction(event.originalTarget)); diff --git a/browser/extensions/formautofill/content/editCreditCard.xhtml b/browser/extensions/formautofill/content/editCreditCard.xhtml index c804114e188e..d6c3df27fd34 100644 --- a/browser/extensions/formautofill/content/editCreditCard.xhtml +++ b/browser/extensions/formautofill/content/editCreditCard.xhtml @@ -28,7 +28,7 @@