summaryrefslogtreecommitdiffstats
path: root/browser/extensions/formautofill/test/browser/heuristics/browser_parse_name_fields.js
diff options
context:
space:
mode:
Diffstat (limited to 'browser/extensions/formautofill/test/browser/heuristics/browser_parse_name_fields.js')
-rw-r--r--browser/extensions/formautofill/test/browser/heuristics/browser_parse_name_fields.js86
1 files changed, 86 insertions, 0 deletions
diff --git a/browser/extensions/formautofill/test/browser/heuristics/browser_parse_name_fields.js b/browser/extensions/formautofill/test/browser/heuristics/browser_parse_name_fields.js
new file mode 100644
index 0000000000..6433a4a9ea
--- /dev/null
+++ b/browser/extensions/formautofill/test/browser/heuristics/browser_parse_name_fields.js
@@ -0,0 +1,86 @@
+/* Any copyright is dedicated to the Public Domain.
+http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/* global add_heuristic_tests */
+
+"use strict";
+
+add_heuristic_tests([
+ {
+ description:
+ "Update name to cc-name when the previous section is a credit card section",
+ fixtureData: `
+ <html><body><form>
+ <input id="cc-number" autocomplete="cc-number">
+ <input id="given" placeholder="given-name">
+ <input id="family" placeholder="family-name">
+ </form></body></html>`,
+ expectedResult: [
+ {
+ fields: [
+ { fieldName: "cc-number", reason: "autocomplete" },
+ { fieldName: "cc-given-name", reason: "update-heuristic" },
+ { fieldName: "cc-family-name", reason: "update-heuristic" },
+ ],
+ },
+ ],
+ },
+ {
+ description:
+ "Do not update name to cc-name when the previous credit card section already contains cc-name",
+ fixtureData: `
+ <html><body><form>
+ <input id="cc-name" autocomplete="cc-name">
+ <input id="cc-number" autocomplete="cc-number">
+ <input id="given" placeholder="given-name">
+ <input id="family" placeholder="family-name">
+ <input id="address" autocomplete="street-address">
+ <input id="country" autocomplete="country">
+ </form></body></html>`,
+ expectedResult: [
+ {
+ fields: [
+ { fieldName: "cc-name", reason: "autocomplete" },
+ { fieldName: "cc-number", reason: "autocomplete" },
+ ],
+ },
+ {
+ fields: [
+ { fieldName: "given-name", reason: "regex-heuristic" },
+ { fieldName: "family-name", reason: "regex-heuristic" },
+ { fieldName: "street-address", reason: "autocomplete" },
+ { fieldName: "country", reason: "autocomplete" },
+ ],
+ },
+ ],
+ },
+ {
+ description:
+ "Do not update name to cc-name when the previous credit card section contains cc-csc",
+ fixtureData: `
+ <html><body><form>
+ <input id="cc-number" autocomplete="cc-number">
+ <input id="cc-csc" autocomplete="cc-csc">
+ <input id="given" placeholder="given-name">
+ <input id="family" placeholder="family-name">
+ <input id="address" autocomplete="street-address">
+ <input id="country" autocomplete="country">
+ </form></body></html>`,
+ expectedResult: [
+ {
+ fields: [
+ { fieldName: "cc-number", reason: "autocomplete" },
+ //{ fieldName: "cc-csc", reason: "autocomplete" },
+ ],
+ },
+ {
+ fields: [
+ { fieldName: "given-name", reason: "regex-heuristic" },
+ { fieldName: "family-name", reason: "regex-heuristic" },
+ { fieldName: "street-address", reason: "autocomplete" },
+ { fieldName: "country", reason: "autocomplete" },
+ ],
+ },
+ ],
+ },
+]);