summaryrefslogtreecommitdiffstats
path: root/toolkit/components/formautofill/shared/FormAutofillUtils.sys.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/components/formautofill/shared/FormAutofillUtils.sys.mjs')
-rw-r--r--toolkit/components/formautofill/shared/FormAutofillUtils.sys.mjs42
1 files changed, 42 insertions, 0 deletions
diff --git a/toolkit/components/formautofill/shared/FormAutofillUtils.sys.mjs b/toolkit/components/formautofill/shared/FormAutofillUtils.sys.mjs
index e86f14975c..c2b48a53a3 100644
--- a/toolkit/components/formautofill/shared/FormAutofillUtils.sys.mjs
+++ b/toolkit/components/formautofill/shared/FormAutofillUtils.sys.mjs
@@ -176,6 +176,12 @@ FormAutofillUtils = {
return Array.from(categories);
},
+ getCollectionNameFromFieldName(fieldName) {
+ return this.isCreditCardField(fieldName)
+ ? CREDITCARDS_COLLECTION_NAME
+ : ADDRESSES_COLLECTION_NAME;
+ },
+
getAddressSeparator() {
// The separator should be based on the L10N address format, and using a
// white space is a temporary solution.
@@ -799,6 +805,42 @@ FormAutofillUtils = {
return null;
},
+ /**
+ * Find the option element from xul menu popups, as used in address capture
+ * doorhanger.
+ *
+ * This is a proxy to `findAddressSelectOption`, which expects HTML select
+ * DOM nodes and operates on options instead of xul menuitems.
+ *
+ * NOTE: This is a temporary solution until Bug 1886949 is landed. This
+ * method will then be removed `findAddressSelectOption` will be used
+ * directly.
+ *
+ * @param {XULPopupElement} menupopup
+ * @param {object} address
+ * @param {string} fieldName
+ * @returns {XULElement}
+ */
+ findAddressSelectOptionWithMenuPopup(menupopup, address, fieldName) {
+ class MenuitemProxy {
+ constructor(menuitem) {
+ this.menuitem = menuitem;
+ }
+ get text() {
+ return this.menuitem.label;
+ }
+ get value() {
+ return this.menuitem.value;
+ }
+ }
+ const selectEl = {
+ options: Array.from(menupopup.childNodes).map(
+ menuitem => new MenuitemProxy(menuitem)
+ ),
+ };
+ return this.findAddressSelectOption(selectEl, address, fieldName)?.menuitem;
+ },
+
findCreditCardSelectOption(selectEl, creditCard, fieldName) {
let oneDigitMonth = creditCard["cc-exp-month"]
? creditCard["cc-exp-month"].toString()