summaryrefslogtreecommitdiffstats
path: root/browser/extensions/formautofill/test/browser/heuristics
diff options
context:
space:
mode:
Diffstat (limited to 'browser/extensions/formautofill/test/browser/heuristics')
-rw-r--r--browser/extensions/formautofill/test/browser/heuristics/browser.toml4
-rw-r--r--browser/extensions/formautofill/test/browser/heuristics/browser_ignore_unfocusable_fields.js159
-rw-r--r--browser/extensions/formautofill/test/browser/heuristics/browser_sections_with_invisible_fields.js131
-rw-r--r--browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Euronics.js2
-rw-r--r--browser/extensions/formautofill/test/browser/heuristics/third_party/browser_HomeDepot.js11
5 files changed, 144 insertions, 163 deletions
diff --git a/browser/extensions/formautofill/test/browser/heuristics/browser.toml b/browser/extensions/formautofill/test/browser/heuristics/browser.toml
index e7bbfa0283..2d0916e917 100644
--- a/browser/extensions/formautofill/test/browser/heuristics/browser.toml
+++ b/browser/extensions/formautofill/test/browser/heuristics/browser.toml
@@ -20,8 +20,6 @@ skip-if = ["apple_silicon && !debug"]
["browser_fr_fields.js"]
-["browser_ignore_unfocusable_fields.js"]
-
["browser_label_rules.js"]
["browser_multiple_section.js"]
@@ -37,3 +35,5 @@ skip-if = ["apple_silicon && !debug"]
["browser_section_validation_address.js"]
["browser_sections_by_name.js"]
+
+["browser_sections_with_invisible_fields.js"]
diff --git a/browser/extensions/formautofill/test/browser/heuristics/browser_ignore_unfocusable_fields.js b/browser/extensions/formautofill/test/browser/heuristics/browser_ignore_unfocusable_fields.js
deleted file mode 100644
index 56f53a1e76..0000000000
--- a/browser/extensions/formautofill/test/browser/heuristics/browser_ignore_unfocusable_fields.js
+++ /dev/null
@@ -1,159 +0,0 @@
-/* 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: "All visual fields are considered focusable.",
-
- fixtureData: `
- <html>
- <body>
- <form>
- <input type="text" id="name" autocomplete="name" />
- <input type="text" id="tel" autocomplete="tel" />
- <input type="text" id="email" autocomplete="email"/>
- <select id="country" autocomplete="country">
- <option value="United States">United States</option>
- </select>
- <input type="text" id="postal-code" autocomplete="postal-code"/>
- <input type="text" id="address-line1" autocomplete="address-line1" />
- <div>
- <input type="text" id="address-line2" autocomplete="address-line2" />
- </div>
- </form>
- </form>
- </body>
- </html>
- `,
- expectedResult: [
- {
- default: {
- reason: "autocomplete",
- },
- fields: [
- { fieldName: "name" },
- { fieldName: "tel" },
- { fieldName: "email" },
- { fieldName: "country" },
- { fieldName: "postal-code" },
- { fieldName: "address-line1" },
- { fieldName: "address-line2" },
- ],
- },
- ],
- },
- {
- // ignore opacity (see Bug 1835852),
- description:
- "Invisible fields with style.opacity=0 set are considered focusable.",
-
- fixtureData: `
- <html>
- <body>
- <form>
- <input type="text" id="name" autocomplete="name" style="opacity:0" />
- <input type="text" id="tel" autocomplete="tel" />
- <input type="text" id="email" autocomplete="email" style="opacity:0"/>
- <select id="country" autocomplete="country">
- <option value="United States">United States</option>
- </select>
- <input type="text" id="postal-code" autocomplete="postal-code" />
- <input type="text" id="address-line1" autocomplete="address-line1" />
- <div>
- <input type="text" id="address-line2" autocomplete="address-line2" />
- </div>
- </form>
- </form>
- </body>
- </html>
- `,
- expectedResult: [
- {
- default: {
- reason: "autocomplete",
- },
- fields: [
- { fieldName: "name" },
- { fieldName: "tel" },
- { fieldName: "email" },
- { fieldName: "country" },
- { fieldName: "postal-code" },
- { fieldName: "address-line1" },
- { fieldName: "address-line2" },
- ],
- },
- ],
- },
- {
- description:
- "Some fields are considered unfocusable due to their invisibility.",
-
- fixtureData: `
- <html>
- <body>
- <form>
- <input type="text" id="name" autocomplete="name" />
- <input type="text" id="tel" autocomplete="tel" />
- <input type="text" id="email" autocomplete="email" />
- <input type="text" id="country" autocomplete="country" />
- <input type="text" id="postal-code" autocomplete="postal-code" hidden />
- <input type="text" id="address-line1" autocomplete="address-line1" style="display:none" />
- <div style="visibility: hidden">
- <input type="text" id="address-line2" autocomplete="address-line2" />
- </div>
- </form>
- </body>
- </html>
- `,
- expectedResult: [
- {
- default: {
- reason: "autocomplete",
- },
- fields: [
- { fieldName: "name" },
- { fieldName: "tel" },
- { fieldName: "email" },
- { fieldName: "country" },
- ],
- },
- ],
- },
- {
- description: `Disabled field and field with tabindex="-1" is considered unfocusable`,
-
- fixtureData: `
- <html>
- <body>
- <form>
- <input type="text" id="name" autocomplete="name" />
- <input type="text" id="tel" autocomplete="tel" />
- <input type="text" id="email" autocomplete="email" />
- <input type="text" id="country" autocomplete="country" disabled/>
- <input type="text" id="postal-code" autocomplete="postal-code" tabindex="-1"/>
- <input type="text" id="address-line1" autocomplete="address-line1" />
- <input type="text" id="address-line2" autocomplete="address-line2" />
- </form>
- </body>
- </html>
- `,
- expectedResult: [
- {
- default: {
- reason: "autocomplete",
- },
- fields: [
- { fieldName: "name" },
- { fieldName: "tel" },
- { fieldName: "email" },
- { fieldName: "address-line1" },
- { fieldName: "address-line2" },
- ],
- },
- ],
- },
-]);
diff --git a/browser/extensions/formautofill/test/browser/heuristics/browser_sections_with_invisible_fields.js b/browser/extensions/formautofill/test/browser/heuristics/browser_sections_with_invisible_fields.js
new file mode 100644
index 0000000000..f775d7e5fb
--- /dev/null
+++ b/browser/extensions/formautofill/test/browser/heuristics/browser_sections_with_invisible_fields.js
@@ -0,0 +1,131 @@
+/* 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: `Create a new section when the section already has a field with the same field name`,
+ fixtureData: `
+ <html><body>
+ <input type="text" autocomplete="cc-number"/>
+ <input type="text" autocomplete="cc-name"/>
+ <input type="text" autocomplete="cc-exp"/>
+ <input type="text" autocomplete="cc-exp"/>
+ </body></html>
+ `,
+ expectedResult: [
+ {
+ default: {
+ reason: "autocomplete",
+ },
+ fields: [
+ { fieldName: "cc-number" },
+ { fieldName: "cc-name" },
+ { fieldName: "cc-exp" },
+ ],
+ },
+ {
+ fields: [{ fieldName: "cc-exp", reason: "autocomplete" }],
+ },
+ ],
+ },
+ {
+ description: `Do not create a new section for an invisible field`,
+ fixtureData: `
+ <html><body>
+ <input type="text" autocomplete="cc-number"/>
+ <input type="text" autocomplete="cc-name"/>
+ <input type="text" autocomplete="cc-exp"/>
+ <input type="text" autocomplete="cc-exp" style="display:none"/>
+ </body></html>
+ `,
+ expectedResult: [
+ {
+ default: {
+ reason: "autocomplete",
+ },
+ fields: [
+ { fieldName: "cc-number" },
+ { fieldName: "cc-name" },
+ { fieldName: "cc-exp" },
+ { fieldName: "cc-exp" },
+ ],
+ },
+ ],
+ },
+ {
+ description: `Do not create a new section when the field with the same field name is an invisible field`,
+ fixtureData: `
+ <html><body>
+ <input type="text" autocomplete="cc-number""/>
+ <input type="text" autocomplete="cc-name"/>
+ <input type="text" autocomplete="cc-exp" style="display:none"/>
+ <input type="text" autocomplete="cc-exp"/>
+ </body></html>
+ `,
+ expectedResult: [
+ {
+ default: {
+ reason: "autocomplete",
+ },
+ fields: [
+ { fieldName: "cc-number" },
+ { fieldName: "cc-name" },
+ { fieldName: "cc-exp" },
+ { fieldName: "cc-exp" },
+ ],
+ },
+ ],
+ },
+ {
+ description: `Do not create a new section for an invisible field (match field is not adjacent)`,
+ fixtureData: `
+ <html><body>
+ <input type="text" autocomplete="cc-number"/>
+ <input type="text" autocomplete="cc-name"/>
+ <input type="text" autocomplete="cc-exp"/>
+ <input type="text" autocomplete="cc-number" style="display:none"/>
+ </body></html>
+ `,
+ expectedResult: [
+ {
+ default: {
+ reason: "autocomplete",
+ },
+ fields: [
+ { fieldName: "cc-number" },
+ { fieldName: "cc-name" },
+ { fieldName: "cc-exp" },
+ { fieldName: "cc-number" },
+ ],
+ },
+ ],
+ },
+ {
+ description: `Do not create a new section when the field with the same field name is an invisible field (match field is not adjacent)`,
+ fixtureData: `
+ <html><body>
+ <input type="text" autocomplete="cc-number" style="display:none"/>
+ <input type="text" autocomplete="cc-name"/>
+ <input type="text" autocomplete="cc-exp"/>
+ <input type="text" autocomplete="cc-number"/>
+ </body></html>
+ `,
+ expectedResult: [
+ {
+ default: {
+ reason: "autocomplete",
+ },
+ fields: [
+ { fieldName: "cc-number" },
+ { fieldName: "cc-name" },
+ { fieldName: "cc-exp" },
+ { fieldName: "cc-number" },
+ ],
+ },
+ ],
+ },
+]);
diff --git a/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Euronics.js b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Euronics.js
index cd9757bd35..947757ed17 100644
--- a/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Euronics.js
+++ b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Euronics.js
@@ -16,6 +16,8 @@ add_heuristic_tests(
//{ fieldName: "cc-cvc" },
{ fieldName: "cc-exp-month" },
{ fieldName: "cc-exp-year" },
+ { fieldName: "cc-number", reason: "regex-heuristic" }, // invisible
+ { fieldName: "cc-number", reason: "regex-heuristic" }, // invisible
],
},
{
diff --git a/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_HomeDepot.js b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_HomeDepot.js
index 46e5ecef3c..34a1953157 100644
--- a/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_HomeDepot.js
+++ b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_HomeDepot.js
@@ -35,9 +35,16 @@ add_heuristic_tests(
reason: "autocomplete",
},
fields: [
+ { fieldName: "cc-exp-month" },
+ { fieldName: "cc-exp-year" },
{ fieldName: "cc-number", reason: "fathom" },
- { fieldName: "cc-exp-month", reason: "regex-heuristic" },
- { fieldName: "cc-exp-year", reason: "regex-heuristic" },
+ ],
+ },
+ {
+ invalid: true,
+ fields: [
+ { fieldName: "cc-exp-month", reason: "regex-heuristic" }, // invisible
+ { fieldName: "cc-exp-year", reason: "regex-heuristic" }, // invisible
],
},
],