Bug 1400147 - Ignore the credit card regexps when extensions.formautofill.creditCards.available is false. r=lchang
authorSean Lee <selee@mozilla.com>
Wed, 20 Sep 2017 08:10:38 +0800
changeset 381853 6918dea06b7b
parent 381852 8918870e7a20
child 381854 d78e78de5d8a
push id51637
push userlchang@mozilla.com
push dateWed, 20 Sep 2017 08:33:57 +0000
treeherderautoland@6918dea06b7b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslchang
bugs1400147
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1400147 - Ignore the credit card regexps when extensions.formautofill.creditCards.available is false. r=lchang MozReview-Commit-ID: 2WPBtJrKGJL
browser/extensions/formautofill/FormAutofillHeuristics.jsm
--- a/browser/extensions/formautofill/FormAutofillHeuristics.jsm
+++ b/browser/extensions/formautofill/FormAutofillHeuristics.jsm
@@ -471,16 +471,33 @@ this.FormAutofillHeuristics = {
       "cc-name",
       "cc-number",
       "cc-exp-month",
       "cc-exp-year",
       "cc-exp",
     ];
     let regexps = isAutoCompleteOff ? FIELDNAMES_IGNORING_AUTOCOMPLETE_OFF : Object.keys(this.RULES);
 
+    if (!FormAutofillUtils.isAutofillCreditCardsAvailable) {
+      if (isAutoCompleteOff) {
+        if (!this._regexpListOf_CcUnavailable_AcOff) {
+          this._regexpListOf_CcUnavailable_AcOff = regexps.filter(name => !FormAutofillUtils.isCreditCardField(name));
+        }
+        regexps = this._regexpListOf_CcUnavailable_AcOff;
+      } else {
+        if (!this._regexpListOf_CcUnavailable_AcOn) {
+          this._regexpListOf_CcUnavailable_AcOn = regexps.filter(name => !FormAutofillUtils.isCreditCardField(name));
+        }
+        regexps = this._regexpListOf_CcUnavailable_AcOn;
+      }
+    }
+    if (regexps.length == 0) {
+      return null;
+    }
+
     let labelStrings;
     let getElementStrings = {};
     getElementStrings[Symbol.iterator] = function* () {
       yield element.id;
       yield element.name;
       if (!labelStrings) {
         labelStrings = [];
         let labels = LabelUtils.findLabelElements(element);