Bug 1428732 - Add the credit card related rules for recongnizing cc-exp-year, cc-exp-month, and cc-number for German web sites. r=lchang draft
authorSean Lee <selee@mozilla.com>
Wed, 10 Jan 2018 16:15:52 +0800
changeset 718892 99a37544c921239bb56d5c391083bef027b186ab
parent 718845 4db166f0442dddc5b9011c722d7499501fedf283
child 745632 9251e9dd2aa3e2b2874d285b33f2a3bcc488c498
push id95082
push userbmo:selee@mozilla.com
push dateThu, 11 Jan 2018 02:30:55 +0000
reviewerslchang
bugs1428732
milestone59.0a1
Bug 1428732 - Add the credit card related rules for recongnizing cc-exp-year, cc-exp-month, and cc-number for German web sites. r=lchang MozReview-Commit-ID: Cj8YM6XEEZd
browser/extensions/formautofill/content/heuristicsRegexp.js
browser/extensions/formautofill/test/fixtures/heuristics_de_fields.html
browser/extensions/formautofill/test/unit/heuristics/test_de_fields.js
browser/extensions/formautofill/test/unit/xpcshell.ini
--- a/browser/extensions/formautofill/content/heuristicsRegexp.js
+++ b/browser/extensions/formautofill/content/heuristicsRegexp.js
@@ -217,40 +217,43 @@ var HeuristicsRegExp = {
       "|名前" + // ja-JP
       "|Имя.*карты" + // ru
       "|信用卡开户名|开户名|持卡人姓名" + // zh-CN
       "|持卡人姓名", // zh-TW
       "iu"
     ),
     "cc-number": new RegExp(
       "(add)?(?:card|cc|acct).?(?:number|#|no|num|field)" +
+      "|(cc|kk)nr" + // Extra rules by Firefox for de-DE
       "|nummer" + // de-DE
       "|credito|numero|número" + // es
       "|numéro" + // fr-FR
       "|カード番号" + // ja-JP
       "|Номер.*карты" + // ru
       "|信用卡号|信用卡号码" + // zh-CN
       "|信用卡卡號" + // zh-TW
       "|카드", // ko-KR
       "iu"
     ),
     "cc-exp-month": new RegExp(
       "expir|exp.*mo|exp.*date|ccmonth|cardmonth|addmonth" +
+      "|(cc|kk)month" + // Extra rules by Firefox for de-DE
       "|gueltig|gültig|monat" + // de-DE
       "|fecha" + // es
       "|date.*exp" + // fr-FR
       "|scadenza" + // it-IT
       "|有効期限" + // ja-JP
       "|validade" + // pt-BR, pt-PT
       "|Срок действия карты" + // ru
       "|月", // zh-CN,
       "iu"
     ),
     "cc-exp-year": new RegExp(
       "exp|^/|(add)?year" +
+      "|(cc|kk)year" + // Extra rules by Firefox for de-DE
       "|ablaufdatum|gueltig|gültig|jahr" + // de-DE
       "|fecha" + // es
       "|scadenza" + // it-IT
       "|有効期限" + // ja-JP
       "|validade" + // pt-BR, pt-PT
       "|Срок действия карты" + // ru
       "|年|有效期", // zh-CN
       "iu"
new file mode 100644
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/heuristics_de_fields.html
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <meta charset="utf-8">
+  <title>Heuristics de-DE fields test page</title>
+</head>
+<body>
+  <h1>Heuristics de-DE fields test page</h1>
+  <form autocomplete="off">
+    <div>
+      <div>Karteninhaber</div>
+      <input id="creditCardHolder" name="creditCardHolder" maxlength="30" type="text">
+    </div>
+    <div>
+      <div>Kartentyp</div>
+      <select id="CCBrand" name="CCBrand">
+        <option>
+        </option>
+        <option>AMEX</option>
+        <option>VISA</option>
+        <option>MasterCard</option>
+        <option>Maestro</option>
+      </select>
+    </div>
+    <div>
+      <div>Kartennummer</div>
+      <input id="CCNr" name="CCNr" 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>
new file mode 100644
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/test_de_fields.js
@@ -0,0 +1,20 @@
+/* global runHeuristicsTest */
+
+"use strict";
+
+runHeuristicsTest([
+  {
+    fixturePath: "heuristics_de_fields.html",
+    expectedResult: [
+      [
+        [
+          {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-name"},
+          {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-number"},
+          {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp-month"},
+          {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp-year"},
+        ],
+      ],
+    ],
+  },
+], "../../fixtures/");
+
--- a/browser/extensions/formautofill/test/unit/xpcshell.ini
+++ b/browser/extensions/formautofill/test/unit/xpcshell.ini
@@ -1,16 +1,17 @@
 [DEFAULT]
 firefox-appdir = browser
 head = head.js
 support-files =
   ../fixtures/**
 
 [heuristics/test_basic.js]
 [heuristics/test_cc_exp.js]
+[heuristics/test_de_fields.js]
 [heuristics/test_multiple_section.js]
 [heuristics/third_party/test_BestBuy.js]
 [heuristics/third_party/test_CDW.js]
 [heuristics/third_party/test_CostCo.js]
 [heuristics/third_party/test_HomeDepot.js]
 [heuristics/third_party/test_Macys.js]
 [heuristics/third_party/test_NewEgg.js]
 [heuristics/third_party/test_OfficeDepot.js]