Bug 1740442 - Fix missing cc-name for DE heuristics. r=sgalich
authorTim Giles <tgiles@mozilla.com>
Mon, 15 Nov 2021 19:23:31 +0000
changeset 599206 42e02578ba7c4bfa42c63b4faa81318b7129cff4
parent 599205 75c615b53e7b96334ee7e75f0224be36daf04595
child 599207 2236aa837ff63d280df545abb6cca31139c6a4b7
push id38981
push userccozmuta@mozilla.com
push dateTue, 16 Nov 2021 09:34:25 +0000
treeherdermozilla-central@3890e2f0b025 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssgalich
bugs1740442
milestone96.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 1740442 - Fix missing cc-name for DE heuristics. r=sgalich Differential Revision: https://phabricator.services.mozilla.com/D131154
browser/extensions/formautofill/test/fixtures/heuristics_de_fields.html
browser/extensions/formautofill/test/unit/heuristics/test_de_fields.js
toolkit/components/formautofill/content/heuristicsRegexp.js
--- a/browser/extensions/formautofill/test/fixtures/heuristics_de_fields.html
+++ b/browser/extensions/formautofill/test/fixtures/heuristics_de_fields.html
@@ -57,10 +57,67 @@
         <option value="2027">2027</option>
       </select>
     </div>
     <div>
       <div>Prüfnummer</div>
       <input name="cccvc" id="CVV" maxlength="4" size="5" type="password">
     </div>
   </form>
+  <!-- We use 'test-input[x]' here so we can verify label text instead of tipping off the heuristic via id or name -->
+  <form autocomplete="off">
+    <div>
+      <label for="test-input">Name auf der Karte</label>
+      <input id="test-input" maxlength="30" type="text">
+    </div>
+    <div>
+      <label for="test-input2">Kartentyp</label>
+      <select id="CCBrand" name="CCBrand">
+        <option>
+        </option>
+        <option>AMEX</option>
+        <option>VISA</option>
+        <option>MasterCard</option>
+        <option>Maestro</option>
+      </select>
+    </div>
+    <div>
+      <label for="test-input3">Kartennummer</label>
+      <input id="test-input3" maxlength="19" type="text">
+    </div>
+    <div>
+      <div>gültig bis</div>
+      <select id="KKMonth" name="KKMonth">
+        <option value="MM">MM</option>
+        <option value="01">01</option>
+        <option value="02">02</option>
+        <option value="03">03</option>
+        <option value="04">04</option>
+        <option value="05">05</option>
+        <option value="06">06</option>
+        <option value="07">07</option>
+        <option value="08">08</option>
+        <option value="09">09</option>
+        <option value="10">10</option>
+        <option value="11">11</option>
+        <option value="12">12</option>
+      </select>
+      <select id="KKYear" name="KKYear">
+        <option value="YYYY">JJJJ</option>
+        <option value="2018">2018</option>
+        <option value="2019">2019</option>
+        <option value="2020">2020</option>
+        <option value="2021">2021</option>
+        <option value="2022">2022</option>
+        <option value="2023">2023</option>
+        <option value="2024">2024</option>
+        <option value="2025">2025</option>
+        <option value="2026">2026</option>
+        <option value="2027">2027</option>
+      </select>
+    </div>
+    <div>
+      <div>Prüfnummer</div>
+      <input name="cccvc" id="CVV" maxlength="4" size="5" type="password">
+    </div>
+  </form>
 </body>
 </html>
--- a/browser/extensions/formautofill/test/unit/heuristics/test_de_fields.js
+++ b/browser/extensions/formautofill/test/unit/heuristics/test_de_fields.js
@@ -36,13 +36,47 @@ runHeuristicsTest(
             {
               section: "",
               addressType: "",
               contactType: "",
               fieldName: "cc-exp-year",
             },
           ],
         ],
+        [
+          [
+            {
+              section: "",
+              addressType: "",
+              contactType: "",
+              fieldName: "cc-name",
+            },
+            {
+              section: "",
+              addressType: "",
+              contactType: "",
+              fieldName: "cc-type",
+            },
+            {
+              section: "",
+              addressType: "",
+              contactType: "",
+              fieldName: "cc-number",
+            },
+            {
+              section: "",
+              addressType: "",
+              contactType: "",
+              fieldName: "cc-exp-month",
+            },
+            {
+              section: "",
+              addressType: "",
+              contactType: "",
+              fieldName: "cc-exp-year",
+            },
+          ],
+        ],
       ],
     },
   ],
   "../../fixtures/"
 );
--- a/toolkit/components/formautofill/content/heuristicsRegexp.js
+++ b/toolkit/components/formautofill/content/heuristicsRegexp.js
@@ -42,17 +42,20 @@ var HeuristicsRegExp = {
     //=========================================================================
     // Firefox-specific rules
     {
       "address-line1": "addrline1|address_1",
       "address-line2": "addrline2|address_2",
       "address-line3": "addrline3|address_3",
       "address-level1": "land", // de-DE
       "additional-name": "apellido.?materno|lastlastname",
-      "cc-name": "titulaire", // fr-FR
+      "cc-name":
+        // eslint-disable-next-line prettier/prettier
+        "titulaire" + // fr-FR
+        "|(name auf der karte)", // de-DE
       "cc-number": "(cc|kk)nr", // de-DE
       "cc-exp-month": "(cc|kk)month", // de-DE
       "cc-exp-year": "(cc|kk)year", // de-DE
       "cc-type": "type",
     },
 
     //=========================================================================
     // These are the rules used by Bitwarden [0], converted into RegExp form.