From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../test/browser/heuristics/browser.ini | 17 ++ .../heuristics/browser_autocomplete_off_on_form.js | 74 +++++ .../browser_autocomplete_off_on_inputs.js | 102 +++++++ .../test/browser/heuristics/browser_basic.js | 69 +++++ .../test/browser/heuristics/browser_cc_exp.js | 56 ++++ .../test/browser/heuristics/browser_de_fields.js | 32 +++ .../test/browser/heuristics/browser_fr_fields.js | 27 ++ .../heuristics/browser_ignore_invisible_fields.js | 115 ++++++++ .../browser/heuristics/browser_multiple_section.js | 118 ++++++++ .../heuristics/browser_parseAddressFields.js | 138 +++++++++ .../browser_section_validation_address.js | 79 +++++ .../browser/heuristics/browser_sections_by_name.js | 318 +++++++++++++++++++++ .../browser/heuristics/third_party/browser.ini | 22 ++ .../heuristics/third_party/browser_BestBuy.js | 82 ++++++ .../browser/heuristics/third_party/browser_CDW.js | 71 +++++ .../heuristics/third_party/browser_CostCo.js | 170 +++++++++++ .../heuristics/third_party/browser_DirectAsda.js | 25 ++ .../browser/heuristics/third_party/browser_Ebay.js | 25 ++ .../third_party/browser_GlobalDirectAsda.js | 24 ++ .../heuristics/third_party/browser_HomeDepot.js | 77 +++++ .../heuristics/third_party/browser_Lufthansa.js | 28 ++ .../browser/heuristics/third_party/browser_Lush.js | 31 ++ .../heuristics/third_party/browser_Macys.js | 88 ++++++ .../heuristics/third_party/browser_NewEgg.js | 109 +++++++ .../heuristics/third_party/browser_OfficeDepot.js | 83 ++++++ .../browser/heuristics/third_party/browser_QVC.js | 96 +++++++ .../heuristics/third_party/browser_Sears.js | 81 ++++++ .../heuristics/third_party/browser_Staples.js | 78 +++++ .../heuristics/third_party/browser_Walmart.js | 93 ++++++ 29 files changed, 2328 insertions(+) create mode 100644 browser/extensions/formautofill/test/browser/heuristics/browser.ini create mode 100644 browser/extensions/formautofill/test/browser/heuristics/browser_autocomplete_off_on_form.js create mode 100644 browser/extensions/formautofill/test/browser/heuristics/browser_autocomplete_off_on_inputs.js create mode 100644 browser/extensions/formautofill/test/browser/heuristics/browser_basic.js create mode 100644 browser/extensions/formautofill/test/browser/heuristics/browser_cc_exp.js create mode 100644 browser/extensions/formautofill/test/browser/heuristics/browser_de_fields.js create mode 100644 browser/extensions/formautofill/test/browser/heuristics/browser_fr_fields.js create mode 100644 browser/extensions/formautofill/test/browser/heuristics/browser_ignore_invisible_fields.js create mode 100644 browser/extensions/formautofill/test/browser/heuristics/browser_multiple_section.js create mode 100644 browser/extensions/formautofill/test/browser/heuristics/browser_parseAddressFields.js create mode 100644 browser/extensions/formautofill/test/browser/heuristics/browser_section_validation_address.js create mode 100644 browser/extensions/formautofill/test/browser/heuristics/browser_sections_by_name.js create mode 100644 browser/extensions/formautofill/test/browser/heuristics/third_party/browser.ini create mode 100644 browser/extensions/formautofill/test/browser/heuristics/third_party/browser_BestBuy.js create mode 100644 browser/extensions/formautofill/test/browser/heuristics/third_party/browser_CDW.js create mode 100644 browser/extensions/formautofill/test/browser/heuristics/third_party/browser_CostCo.js create mode 100644 browser/extensions/formautofill/test/browser/heuristics/third_party/browser_DirectAsda.js create mode 100644 browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Ebay.js create mode 100644 browser/extensions/formautofill/test/browser/heuristics/third_party/browser_GlobalDirectAsda.js create mode 100644 browser/extensions/formautofill/test/browser/heuristics/third_party/browser_HomeDepot.js create mode 100644 browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Lufthansa.js create mode 100644 browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Lush.js create mode 100644 browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Macys.js create mode 100644 browser/extensions/formautofill/test/browser/heuristics/third_party/browser_NewEgg.js create mode 100644 browser/extensions/formautofill/test/browser/heuristics/third_party/browser_OfficeDepot.js create mode 100644 browser/extensions/formautofill/test/browser/heuristics/third_party/browser_QVC.js create mode 100644 browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Sears.js create mode 100644 browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Staples.js create mode 100644 browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Walmart.js (limited to 'browser/extensions/formautofill/test/browser/heuristics') diff --git a/browser/extensions/formautofill/test/browser/heuristics/browser.ini b/browser/extensions/formautofill/test/browser/heuristics/browser.ini new file mode 100644 index 0000000000..cc93d6beea --- /dev/null +++ b/browser/extensions/formautofill/test/browser/heuristics/browser.ini @@ -0,0 +1,17 @@ +[DEFAULT] +skip-if = toolkit == 'android' # bug 1730213 +support-files = + ../head.js + ../../fixtures/** + +[browser_autocomplete_off_on_form.js] +[browser_autocomplete_off_on_inputs.js] +[browser_basic.js] +[browser_cc_exp.js] +[browser_de_fields.js] +[browser_fr_fields.js] +[browser_ignore_invisible_fields.js] +[browser_multiple_section.js] +[browser_parseAddressFields.js] +[browser_section_validation_address.js] +[browser_sections_by_name.js] diff --git a/browser/extensions/formautofill/test/browser/heuristics/browser_autocomplete_off_on_form.js b/browser/extensions/formautofill/test/browser/heuristics/browser_autocomplete_off_on_form.js new file mode 100644 index 0000000000..f93752bd1e --- /dev/null +++ b/browser/extensions/formautofill/test/browser/heuristics/browser_autocomplete_off_on_form.js @@ -0,0 +1,74 @@ +/* Any copyright is dedicated to the Public Domain. +http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +/* global add_heuristic_tests */ + +// Ensures that fields are identified correctly even when the containing form +// has its autocomplete attribute set to off. +add_heuristic_tests( + [ + { + fixturePath: "autocomplete_off_on_form.html", + expectedResult: [ + { + default: { + reason: "autocomplete", + }, + fields: [ + { fieldName: "organization" }, + { fieldName: "street-address" }, + { fieldName: "address-level2" }, + { fieldName: "address-level1" }, + { fieldName: "postal-code" }, + { fieldName: "country" }, + { fieldName: "tel" }, + { fieldName: "email" }, + ], + }, + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "organization" }, + { fieldName: "address-line1" }, + { fieldName: "address-line2" }, + { fieldName: "address-line3" }, + { fieldName: "address-level2" }, + { fieldName: "address-level1" }, + { fieldName: "postal-code" }, + { fieldName: "country" }, + { fieldName: "tel" }, + { fieldName: "email" }, + ], + }, + { + default: { + reason: "autocomplete", + }, + fields: [ + { fieldName: "cc-number" }, + { fieldName: "cc-name" }, + { fieldName: "cc-exp-month" }, + { fieldName: "cc-exp-year" }, + ], + }, + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "address-line1" }, + { fieldName: "address-level2" }, + { fieldName: "address-line2" }, + { fieldName: "organization" }, + { fieldName: "address-line3" }, + ], + }, + ], + }, + ], + "fixtures/" +); diff --git a/browser/extensions/formautofill/test/browser/heuristics/browser_autocomplete_off_on_inputs.js b/browser/extensions/formautofill/test/browser/heuristics/browser_autocomplete_off_on_inputs.js new file mode 100644 index 0000000000..13c8d82dbb --- /dev/null +++ b/browser/extensions/formautofill/test/browser/heuristics/browser_autocomplete_off_on_inputs.js @@ -0,0 +1,102 @@ +/* Any copyright is dedicated to the Public Domain. +http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +/* global add_heuristic_tests */ + +// Ensures that fields are identified correctly even when the inputs +// have their autocomplete attribute set to off. +add_heuristic_tests( + [ + { + fixturePath: "autocomplete_off_on_inputs.html", + expectedResult: [ + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "organization" }, + { fieldName: "street-address" }, + { fieldName: "address-level2" }, + { fieldName: "address-level1" }, + { fieldName: "postal-code" }, + { fieldName: "country" }, + { fieldName: "tel" }, + { fieldName: "email" }, + ], + }, + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "organization" }, + { fieldName: "address-line1" }, + { fieldName: "address-line2" }, + { fieldName: "address-line3" }, + { fieldName: "address-level2" }, + { fieldName: "address-level1" }, + { fieldName: "postal-code" }, + { fieldName: "country" }, + { fieldName: "tel" }, + { fieldName: "email" }, + ], + }, + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "cc-number", reason: "fathom" }, + { fieldName: "cc-name", reason: "fathom" }, + { fieldName: "cc-exp-month" }, + { fieldName: "cc-exp-year" }, + ], + }, + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "address-line1" }, + { fieldName: "address-level2" }, + { fieldName: "address-line2" }, + { fieldName: "organization" }, + { fieldName: "address-line3" }, + ], + }, + { + default: { + reason: "autocomplete", + }, + fields: [ + { fieldName: "organization" }, + { fieldName: "address-line1", reason: "regex-heuristic" }, + { fieldName: "address-line2", reason: "regex-heuristic" }, + { fieldName: "address-line3", reason: "regex-heuristic" }, + { fieldName: "address-level2", reason: "regex-heuristic" }, + { fieldName: "address-level1" }, + { fieldName: "postal-code", reason: "regex-heuristic" }, + { fieldName: "country", reason: "regex-heuristic" }, + { fieldName: "tel" }, + { fieldName: "email", reason: "regex-heuristic" }, + ], + }, + { + default: { + reason: "autocomplete", + }, + fields: [ + { fieldName: "cc-number", reason: "fathom" }, + { fieldName: "cc-name" }, + { fieldName: "cc-exp-month", reason: "regex-heuristic" }, + { fieldName: "cc-exp-year", reason: "regex-heuristic" }, + ], + }, + ], + }, + ], + "fixtures/" +); diff --git a/browser/extensions/formautofill/test/browser/heuristics/browser_basic.js b/browser/extensions/formautofill/test/browser/heuristics/browser_basic.js new file mode 100644 index 0000000000..fda375a146 --- /dev/null +++ b/browser/extensions/formautofill/test/browser/heuristics/browser_basic.js @@ -0,0 +1,69 @@ +/* global add_heuristic_tests */ + +"use strict"; + +add_heuristic_tests( + [ + { + fixturePath: "autocomplete_basic.html", + expectedResult: [ + { + default: { + reason: "autocomplete", + }, + fields: [ + { fieldName: "organization" }, + { fieldName: "street-address" }, + { fieldName: "address-level2" }, + { fieldName: "address-level1" }, + { fieldName: "postal-code" }, + { fieldName: "country" }, + { fieldName: "tel" }, + { fieldName: "email" }, + ], + }, + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "organization" }, + { fieldName: "address-line1" }, + { fieldName: "address-line2" }, + { fieldName: "address-line3" }, + { fieldName: "address-level2" }, + { fieldName: "address-level1" }, + { fieldName: "postal-code" }, + { fieldName: "country" }, + { fieldName: "tel" }, + { fieldName: "email" }, + ], + }, + { + default: { + reason: "autocomplete", + }, + fields: [ + { fieldName: "cc-number" }, + { fieldName: "cc-name" }, + { fieldName: "cc-exp-month" }, + { fieldName: "cc-exp-year" }, + ], + }, + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "address-line1" }, + { fieldName: "address-level2" }, + { fieldName: "address-line2" }, + { fieldName: "organization" }, + { fieldName: "address-line3" }, + ], + }, + ], + }, + ], + "fixtures/" +); diff --git a/browser/extensions/formautofill/test/browser/heuristics/browser_cc_exp.js b/browser/extensions/formautofill/test/browser/heuristics/browser_cc_exp.js new file mode 100644 index 0000000000..8eb774b65c --- /dev/null +++ b/browser/extensions/formautofill/test/browser/heuristics/browser_cc_exp.js @@ -0,0 +1,56 @@ +/* global add_heuristic_tests */ + +"use strict"; + +add_heuristic_tests( + [ + { + fixturePath: "heuristics_cc_exp.html", + expectedResult: [ + { + description: "form1", + default: { + reason: "autocomplete", + }, + fields: [ + { fieldName: "cc-name" }, + { fieldName: "cc-number" }, + { fieldName: "cc-exp-month" }, + { fieldName: "cc-exp-year" }, + ], + }, + { + description: "form2", + default: { + reason: "autocomplete", + }, + fields: [{ fieldName: "cc-number" }, { fieldName: "cc-exp" }], + }, + { + description: "form3", + fields: [ + { fieldName: "cc-number", reason: "autocomplete" }, + { fieldName: "cc-exp", reason: "regex-heuristic" }, + ], + }, + { + description: "form4", + fields: [ + { fieldName: "cc-number", reason: "autocomplete" }, + { fieldName: "cc-exp-month", reason: "regex-heuristic" }, + { fieldName: "cc-exp-year", reason: "regex-heuristic" }, + ], + }, + { + description: "form5", + invalid: true, + fields: [ + { fieldName: "cc-exp-month", reason: "regex-heuristic" }, + { fieldName: "cc-exp-year", reason: "regex-heuristic" }, + ], + }, + ], + }, + ], + "fixtures/" +); diff --git a/browser/extensions/formautofill/test/browser/heuristics/browser_de_fields.js b/browser/extensions/formautofill/test/browser/heuristics/browser_de_fields.js new file mode 100644 index 0000000000..0d47cb6935 --- /dev/null +++ b/browser/extensions/formautofill/test/browser/heuristics/browser_de_fields.js @@ -0,0 +1,32 @@ +/* global add_heuristic_tests */ + +"use strict"; + +add_heuristic_tests( + [ + { + fixturePath: "heuristics_de_fields.html", + expectedResult: [ + { + fields: [ + { fieldName: "cc-name", reason: "fathom" }, + { fieldName: "cc-type", reason: "regex-heuristic" }, + { fieldName: "cc-number", reason: "fathom" }, + { fieldName: "cc-exp-month", reason: "regex-heuristic" }, + { fieldName: "cc-exp-year", reason: "regex-heuristic" }, + ], + }, + { + fields: [ + { fieldName: "cc-name", reason: "fathom" }, + { fieldName: "cc-type", reason: "regex-heuristic" }, + { fieldName: "cc-number", reason: "fathom" }, + { fieldName: "cc-exp-month", reason: "regex-heuristic" }, + { fieldName: "cc-exp-year", reason: "regex-heuristic" }, + ], + }, + ], + }, + ], + "fixtures/" +); diff --git a/browser/extensions/formautofill/test/browser/heuristics/browser_fr_fields.js b/browser/extensions/formautofill/test/browser/heuristics/browser_fr_fields.js new file mode 100644 index 0000000000..a2c8add393 --- /dev/null +++ b/browser/extensions/formautofill/test/browser/heuristics/browser_fr_fields.js @@ -0,0 +1,27 @@ +/* Any copyright is dedicated to the Public Domain. +http://creativecommons.org/publicdomain/zero/1.0/ */ + +/* global add_heuristic_tests */ + +"use strict"; + +add_heuristic_tests( + [ + { + fixturePath: "heuristics_fr_fields.html", + expectedResult: [ + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "cc-number", reason: "fathom" }, + { fieldName: "cc-exp" }, + { fieldName: "cc-name" }, + ], + }, + ], + }, + ], + "fixtures/" +); diff --git a/browser/extensions/formautofill/test/browser/heuristics/browser_ignore_invisible_fields.js b/browser/extensions/formautofill/test/browser/heuristics/browser_ignore_invisible_fields.js new file mode 100644 index 0000000000..d22b1d5031 --- /dev/null +++ b/browser/extensions/formautofill/test/browser/heuristics/browser_ignore_invisible_fields.js @@ -0,0 +1,115 @@ +/* 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 fields are visible", + fixtureData: ` + + +
+ + + + + + +
+ +
+
+ + + + `, + 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 invisible because of css style", + fixtureData: ` + + +
+ + + + + + +
+ +
+
+ + + `, + expectedResult: [ + { + default: { + reason: "autocomplete", + }, + fields: [ + { fieldName: "name" }, + { fieldName: "tel" }, + { fieldName: "email" }, + ], + }, + ], + }, + { + // hidden and style="display:none" are always considered regardless what visibility check we use + description: + "invisible fields are identified because number of elemenent in the form exceed the threshold", + prefs: [["extensions.formautofill.heuristics.visibilityCheckThreshold", 1]], + fixtureData: ` + + +
+ + + + + + +
+ +
+
+ + + `, + 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_multiple_section.js b/browser/extensions/formautofill/test/browser/heuristics/browser_multiple_section.js new file mode 100644 index 0000000000..078f2240db --- /dev/null +++ b/browser/extensions/formautofill/test/browser/heuristics/browser_multiple_section.js @@ -0,0 +1,118 @@ +/* global add_heuristic_tests */ + +"use strict"; + +add_heuristic_tests( + [ + { + fixturePath: "multiple_section.html", + expectedResult: [ + { + default: { + reason: "autocomplete", + addressType: "shipping", + }, + fields: [ + { fieldName: "name", addressType: "" }, + { fieldName: "organization", addressType: "" }, + { fieldName: "street-address" }, + { fieldName: "address-level2" }, + { fieldName: "address-level1" }, + { fieldName: "postal-code" }, + { fieldName: "country" }, + ], + }, + { + default: { + reason: "autocomplete", + addressType: "billing", + }, + fields: [ + { fieldName: "street-address" }, + { fieldName: "address-level2" }, + { fieldName: "address-level1" }, + { fieldName: "postal-code" }, + { fieldName: "country" }, + ], + }, + { + default: { + reason: "autocomplete", + section: "section-my", + }, + fields: [ + { fieldName: "street-address" }, + { fieldName: "address-level2" }, + { fieldName: "address-level1" }, + { fieldName: "postal-code" }, + { fieldName: "country" }, + { fieldName: "tel", section: "", contactType: "work" }, + { fieldName: "email", section: "", contactType: "work" }, + ], + }, + { + invalid: true, + default: { + reason: "autocomplete", + }, + fields: [ + // Even the `contactType` of these two fields are different with the + // above two, we still consider they are identical until supporting + // multiple phone number and email in one profile. + { fieldName: "tel", contactType: "home" }, + { fieldName: "email", contactType: "home" }, + ], + }, + { + default: { + reason: "autocomplete", + }, + fields: [ + { fieldName: "name" }, + { fieldName: "organization" }, + { fieldName: "street-address" }, + { fieldName: "address-level2" }, + { fieldName: "address-level1" }, + { fieldName: "postal-code" }, + { fieldName: "country" }, + ], + }, + { + default: { + reason: "autocomplete", + }, + fields: [ + { fieldName: "street-address" }, + { fieldName: "address-level2" }, + { fieldName: "address-level1" }, + { fieldName: "postal-code" }, + { fieldName: "country" }, + ], + }, + { + default: { + reason: "autocomplete", + }, + fields: [ + { fieldName: "street-address" }, + { fieldName: "address-level2" }, + { fieldName: "address-level1" }, + { fieldName: "postal-code" }, + { fieldName: "country" }, + { fieldName: "tel", contactType: "work" }, + { fieldName: "email", contactType: "work" }, + ], + }, + { + invalid: true, + default: { + reason: "autocomplete", + contactType: "home", + }, + fields: [{ fieldName: "tel" }, { fieldName: "email" }], + }, + ], + }, + ], + "fixtures/" +); diff --git a/browser/extensions/formautofill/test/browser/heuristics/browser_parseAddressFields.js b/browser/extensions/formautofill/test/browser/heuristics/browser_parseAddressFields.js new file mode 100644 index 0000000000..ffe739d417 --- /dev/null +++ b/browser/extensions/formautofill/test/browser/heuristics/browser_parseAddressFields.js @@ -0,0 +1,138 @@ +/* Any copyright is dedicated to the Public Domain. +http://creativecommons.org/publicdomain/zero/1.0/ */ + +/* global add_heuristic_tests */ + +"use strict"; + +add_heuristic_tests([ + { + // This bug happens only when the last element is address-lineX and + // the field is identified by regular expressions in `HeuristicsRegExp` but is not + // identified by regular expressions defined in `_parseAddressFields` + fixtureData: ` + + +
+

+

+

+
+ + `, + expectedResult: [ + { + description: + "Address Line1 in the last element and is not updated in _parsedAddressFields", + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "country" }, + { fieldName: "tel" }, + { fieldName: "address-line1" }, + ], + }, + ], + }, + { + fixtureData: ` + + +
+

+

+

+

+
+ + `, + expectedResult: [ + { + description: + "Address Line2 in the last element and is not updated in _parsedAddressFields", + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "country" }, + { fieldName: "tel" }, + { fieldName: "address-line1" }, + { fieldName: "address-line2" }, + ], + }, + ], + }, + { + // Bug 1833613 + description: + "street-address field is treated as address-line1 when address-line2 is present while adddress-line1 is not", + fixtureData: ` + + +
+ + + +
+ + `, + expectedResult: [ + { + fields: [ + { fieldName: "address-line1", reason: "regexp-heuristic" }, + { fieldName: "address-line2", reason: "autocomplete" }, + { fieldName: "email", reason: "autocomplete" }, + ], + }, + ], + }, + { + // Bug 1833613 + description: + "street-address field should not be treated as address-line1 when address-line2 is not present", + fixtureData: ` + + +
+ + + +
+ + `, + expectedResult: [ + { + fields: [ + { fieldName: "street-address", reason: "autocomplete" }, + { fieldName: "address-line3", reason: "autocomplete" }, + { fieldName: "email", reason: "autocomplete" }, + ], + }, + ], + }, + { + // Bug 1833613 + description: + "street-address field should not be treated as address-line1 when address-line1 is present", + fixtureData: ` + + +
+ + + +
+ + `, + expectedResult: [ + { + fields: [ + { fieldName: "street-address", reason: "autocomplete" }, + { fieldName: "address-line1", reason: "autocomplete" }, + { fieldName: "email", reason: "autocomplete" }, + ], + }, + ], + }, +]); diff --git a/browser/extensions/formautofill/test/browser/heuristics/browser_section_validation_address.js b/browser/extensions/formautofill/test/browser/heuristics/browser_section_validation_address.js new file mode 100644 index 0000000000..2e9cf42ab0 --- /dev/null +++ b/browser/extensions/formautofill/test/browser/heuristics/browser_section_validation_address.js @@ -0,0 +1,79 @@ +/* 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: `An address section is valid when it only contains more than three fields`, + fixtureData: ` + + + + + + `, + expectedResult: [ + { + default: { + reason: "autocomplete", + }, + fields: [ + { fieldName: "street-address" }, + { fieldName: "postal-code" }, + { fieldName: "email" }, + ], + }, + ], + }, + { + description: `An address section is invalid when it contains less than threee fields`, + fixtureData: ` + + + + + + + `, + expectedResult: [ + { + description: "A section with two fields", + invalid: true, + fields: [ + { fieldName: "postal-code", reason: "autocomplete" }, + { fieldName: "email", reason: "autocomplete" }, + ], + }, + { + description: "A section with one field", + invalid: true, + fields: [{ fieldName: "postal-code", reason: "autocomplete" }], + }, + ], + }, + { + description: `Address section validation only counts the number of different address field name in the section`, + fixtureData: ` + + + + + + `, + expectedResult: [ + { + description: + "A section with three fields but has duplicated email fields", + invalid: true, + fields: [ + { fieldName: "postal-code", reason: "autocomplete" }, + { fieldName: "email", reason: "autocomplete" }, + { fieldName: "email", reason: "autocomplete" }, + ], + }, + ], + }, +]); diff --git a/browser/extensions/formautofill/test/browser/heuristics/browser_sections_by_name.js b/browser/extensions/formautofill/test/browser/heuristics/browser_sections_by_name.js new file mode 100644 index 0000000000..c6c8ea5759 --- /dev/null +++ b/browser/extensions/formautofill/test/browser/heuristics/browser_sections_by_name.js @@ -0,0 +1,318 @@ +/* Any copyright is dedicated to the Public Domain. +http://creativecommons.org/publicdomain/zero/1.0/ */ + +/* global add_heuristic_tests */ + +"use strict"; + +// The following are included in this test +// - One named billing section +// - One named billing section and one named shipping section +// - One named billing section and one section without name +// - Fields without section name are merged to a section with section name +// - Two sections without name + +add_heuristic_tests([ + { + description: `One named billing section`, + fixtureData: ` + + + + + + `, + expectedResult: [ + { + default: { + reason: "autocomplete", + addressType: "billing", + }, + fields: [ + { fieldName: "street-address" }, + { fieldName: "postal-code" }, + { fieldName: "country" }, + ], + }, + ], + }, + { + description: `One billing section and one shipping section`, + fixtureData: ` + + + + + + + + + `, + expectedResult: [ + { + default: { + reason: "autocomplete", + addressType: "billing", + }, + fields: [ + { fieldName: "street-address" }, + { fieldName: "postal-code" }, + { fieldName: "country" }, + ], + }, + { + default: { + reason: "autocomplete", + addressType: "shipping", + }, + fields: [ + { fieldName: "street-address" }, + { fieldName: "postal-code" }, + { fieldName: "country" }, + ], + }, + ], + }, + { + description: `One billing section, one shipping section, and then billing section`, + fixtureData: ` + + + + + + + + + `, + expectedResult: [ + { + default: { + reason: "autocomplete", + addressType: "billing", + }, + fields: [ + { fieldName: "street-address" }, + { fieldName: "postal-code" }, + { fieldName: "country" }, + ], + }, + { + default: { + reason: "autocomplete", + addressType: "shipping", + }, + fields: [ + { fieldName: "street-address" }, + { fieldName: "postal-code" }, + { fieldName: "country" }, + ], + }, + ], + }, + { + description: `one section without a name and one billing section`, + fixtureData: ` + + + + + + + + + `, + expectedResult: [ + { + default: { + reason: "autocomplete", + }, + fields: [ + { fieldName: "street-address" }, + { fieldName: "postal-code" }, + { fieldName: "country" }, + ], + }, + { + default: { + reason: "autocomplete", + addressType: "billing", + }, + fields: [ + { fieldName: "street-address" }, + { fieldName: "postal-code" }, + { fieldName: "country" }, + ], + }, + ], + }, + { + description: `One billing section and one section without a name`, + fixtureData: ` + + + + + + + + + `, + expectedResult: [ + { + default: { + reason: "autocomplete", + addressType: "billing", + }, + fields: [ + { fieldName: "street-address" }, + { fieldName: "postal-code" }, + { fieldName: "country" }, + ], + }, + { + default: { + reason: "autocomplete", + }, + fields: [ + { fieldName: "street-address" }, + { fieldName: "postal-code" }, + { fieldName: "country" }, + ], + }, + ], + }, + { + description: `Fields without section name are merged (test both before and after the section with a name)`, + fixtureData: ` + + + + + + + + + + + `, + expectedResult: [ + { + default: { + reason: "autocomplete", + addressType: "billing", + }, + fields: [ + { fieldName: "name", addressType: "" }, + { fieldName: "street-address" }, + { fieldName: "postal-code" }, + { fieldName: "country" }, + ], + }, + { + default: { + reason: "autocomplete", + addressType: "shipping", + }, + fields: [ + { fieldName: "street-address" }, + { fieldName: "postal-code" }, + { fieldName: "country" }, + { fieldName: "name", addressType: "" }, + ], + }, + ], + }, + { + description: `Fields without section name are merged, but do not merge if the field already exists`, + fixtureData: ` + + + + + + + + `, + expectedResult: [ + { + default: { + reason: "autocomplete", + addressType: "billing", + }, + fields: [ + { fieldName: "name", addressType: "" }, + { fieldName: "street-address" }, + { fieldName: "postal-code" }, + { fieldName: "country" }, + ], + }, + { + invalid: true, + fields: [{ fieldName: "name", reason: "autocomplete" }], + }, + ], + }, + { + description: `Fields without section name are merged (multi-fields)`, + fixtureData: ` + + + + + + + + `, + expectedResult: [ + { + default: { + reason: "autocomplete", + addressType: "billing", + }, + fields: [ + { fieldName: "street-address" }, + { fieldName: "postal-code" }, + { fieldName: "country" }, + { fieldName: "email", addressType: "" }, + { fieldName: "email", addressType: "" }, + ], + }, + ], + }, + { + description: `Two sections without name`, + fixtureData: ` + + + + + + + + + `, + expectedResult: [ + { + default: { + reason: "autocomplete", + }, + fields: [ + { fieldName: "street-address" }, + { fieldName: "postal-code" }, + { fieldName: "country" }, + ], + }, + { + default: { + reason: "autocomplete", + }, + fields: [ + { fieldName: "street-address" }, + { fieldName: "postal-code" }, + { fieldName: "country" }, + ], + }, + ], + }, +]); diff --git a/browser/extensions/formautofill/test/browser/heuristics/third_party/browser.ini b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser.ini new file mode 100644 index 0000000000..6519ce9ae8 --- /dev/null +++ b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser.ini @@ -0,0 +1,22 @@ +[DEFAULT] +skip-if = toolkit == 'android' # bug 1730213 +support-files = + ../../head.js + ../../../fixtures/** + +[browser_BestBuy.js] +[browser_CDW.js] +[browser_CostCo.js] +[browser_DirectAsda.js] +[browser_Ebay.js] +[browser_GlobalDirectAsda.js] +[browser_HomeDepot.js] +[browser_Lufthansa.js] +[browser_Lush.js] +[browser_Macys.js] +[browser_NewEgg.js] +[browser_OfficeDepot.js] +[browser_QVC.js] +[browser_Sears.js] +[browser_Staples.js] +[browser_Walmart.js] diff --git a/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_BestBuy.js b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_BestBuy.js new file mode 100644 index 0000000000..e91c19de45 --- /dev/null +++ b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_BestBuy.js @@ -0,0 +1,82 @@ +/* global add_heuristic_tests */ + +"use strict"; + +add_heuristic_tests( + [ + { + fixturePath: "Checkout_ShippingAddress.html", + expectedResult: [ + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "given-name" }, + { fieldName: "family-name" }, + { fieldName: "street-address" }, + { fieldName: "address-level2" }, // city + { fieldName: "address-level1" }, // state + { fieldName: "postal-code" }, + ], + }, + { + invalid: true, + fields: [ + { fieldName: "email", reason: "regex-heuristic" }, // sign-up + ], + }, + { + invalid: true, + fields: [ + { fieldName: "email", reason: "regex-heuristic" }, + { fieldName: "tel", reason: "regex-heuristic" }, + ], + }, + ], + }, + { + fixturePath: "Checkout_Payment.html", + expectedResult: [ + { + invalid: true, + fields: [ + { fieldName: "email", reason: "regex-heuristic" }, + ], + }, + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "given-name" }, + { fieldName: "family-name" }, + { fieldName: "street-address" }, + { fieldName: "address-level2" }, // city + { fieldName: "address-level1" }, // state + { fieldName: "postal-code" }, + ], + }, + { + invalid: true, + fields: [ + { fieldName: "email", reason: "regex-heuristic" }, + { fieldName: "tel", reason: "regex-heuristic" }, + ], + }, + ], + }, + { + fixturePath: "SignIn.html", + expectedResult: [ + { + invalid: true, + fields: [ + { fieldName: "email", reason: "regex-heuristic" }, // sign-in + ], + }, + ], + }, + ], + "fixtures/third_party/BestBuy/" +); diff --git a/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_CDW.js b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_CDW.js new file mode 100644 index 0000000000..feae321cb2 --- /dev/null +++ b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_CDW.js @@ -0,0 +1,71 @@ +/* global add_heuristic_tests */ + +"use strict"; + +add_heuristic_tests( + [ + { + fixturePath: "Checkout_ShippingInfo.html", + expectedResult: [ + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "given-name" }, + { fieldName: "family-name" }, + { fieldName: "organization" }, + { fieldName: "address-line1" }, + { fieldName: "address-line2" }, + { fieldName: "address-level2" }, // city + { fieldName: "address-level1" }, // state + { fieldName: "postal-code" }, + { fieldName: "postal-code" }, // EXt + { fieldName: "email" }, + { fieldName: "tel" }, + { fieldName: "tel-extension" }, + ], + }, + ], + }, + { + fixturePath: "Checkout_BillingPaymentInfo.html", + expectedResult: [ + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "given-name" }, + { fieldName: "family-name" }, + { fieldName: "organization" }, + { fieldName: "address-line1" }, + { fieldName: "address-line2" }, + { fieldName: "address-level2" }, // city + { fieldName: "address-level1" }, // state + { fieldName: "postal-code" }, + { fieldName: "postal-code" }, // Ext + ], + }, + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "cc-type" }, // ac-off + { fieldName: "cc-number", reason: "fathom" }, // ac-off + { fieldName: "cc-exp-month" }, + { fieldName: "cc-exp-year" }, + // {fieldName: "cc-csc"}, + ], + }, + ], + }, + { + fixturePath: "Checkout_Logon.html", + expectedResult: [ + ], + }, + ], + "fixtures/third_party/CDW/" +); diff --git a/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_CostCo.js b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_CostCo.js new file mode 100644 index 0000000000..c83973b3c9 --- /dev/null +++ b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_CostCo.js @@ -0,0 +1,170 @@ +/* global add_heuristic_tests */ + +"use strict"; + +add_heuristic_tests( + [ + { + fixturePath: "ShippingAddress.html", + expectedResult: [ + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "given-name" }, + { fieldName: "additional-name" }, // middle-name initial + { fieldName: "family-name" }, + { fieldName: "organization" }, + { fieldName: "country" }, + { fieldName: "address-line1" }, + { fieldName: "address-line2" }, + { fieldName: "address-level2" }, // city + { fieldName: "address-level1" }, // state + { fieldName: "postal-code" }, + { fieldName: "tel" }, + { fieldName: "email" }, + ], + }, + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "given-name" }, + { fieldName: "additional-name" }, // middle-name initial + { fieldName: "family-name" }, + { fieldName: "organization" }, + { fieldName: "country" }, + { fieldName: "address-line1" }, + { fieldName: "address-line2" }, + { fieldName: "address-level2" }, // city + { fieldName: "address-level1" }, // state + { fieldName: "postal-code" }, + { fieldName: "tel" }, + { fieldName: "email" }, + ], + }, + { + invalid: true, + fields: [ + { fieldName: "email", reason: "regex-heuristic" }, + ], + }, + ], + }, + { + fixturePath: "Payment.html", + expectedResult: [ + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "cc-type" }, // ac-off + { fieldName: "cc-number", reason: "fathom" }, // ac-off + { fieldName: "cc-exp-month" }, + { fieldName: "cc-exp-year" }, + // { fieldName: "cc-csc"}, // ac-off + { fieldName: "cc-name", reason: "fathom" }, // ac-off + ], + }, + { + invalid: true, // confidence is not high enough + fields: [ + { fieldName: "cc-number", reason: "fathom" }, // ac-off + ], + }, + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "given-name" }, + { fieldName: "additional-name" }, // middle-name initial + { fieldName: "family-name" }, + { fieldName: "organization" }, + { fieldName: "country" }, + { fieldName: "address-line1" }, + { fieldName: "address-line2" }, + { fieldName: "address-level2" }, // city + { fieldName: "address-level1" }, // state + { fieldName: "postal-code" }, + { fieldName: "tel" }, + { fieldName: "email" }, + ], + }, + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "given-name" }, + { fieldName: "additional-name" }, // middle-name initial + { fieldName: "family-name" }, + { fieldName: "organization" }, + { fieldName: "country" }, + { fieldName: "address-line1" }, + { fieldName: "address-line2" }, + { fieldName: "address-level2" }, + { fieldName: "address-level1" }, // state + { fieldName: "postal-code" }, + { fieldName: "tel" }, + { fieldName: "email" }, + ], + }, + { + invalid: true, + fields: [ + { fieldName: "email", reason: "regex-heuristic" }, + ], + }, + ], + }, + { + fixturePath: "SignIn.html", + expectedResult: [ + { + invalid: true, + fields: [ + { fieldName: "email", reason: "regex-heuristic" }, + ], + }, + { + invalid: true, + fields: [ + // Forgot password + { fieldName: "email", reason: "regex-heuristic" }, + ], + }, + { + invalid: true, + fields: [ + { fieldName: "email", reason: "regex-heuristic" }, + ], + }, + { + invalid: true, + fields: [ + { fieldName: "email", reason: "regex-heuristic" }, + // {fieldName: "password"}, + ], + }, + { + invalid: true, + fields: [ + // Sign up + { fieldName: "email", reason: "regex-heuristic" }, + ], + }, + { + invalid: true, + fields: [ + { fieldName: "email", reason: "regex-heuristic" }, + ], + } + ], + }, + ], + "fixtures/third_party/CostCo/" +); diff --git a/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_DirectAsda.js b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_DirectAsda.js new file mode 100644 index 0000000000..6cb7979173 --- /dev/null +++ b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_DirectAsda.js @@ -0,0 +1,25 @@ +/* global add_heuristic_tests */ + +"use strict"; + +add_heuristic_tests( + [ + { + fixturePath: "Payment.html", + expectedResult: [ + { + default: { + reason: "fathom", + }, + fields: [ + { fieldName: "cc-number" }, + { fieldName: "cc-name" }, + { fieldName: "cc-exp-month", reason: "regex-heuristic" }, + { fieldName: "cc-exp-year", reason: "regex-heuristic" }, + ], + }, + ], + }, + ], + "fixtures/third_party/DirectAsda/" +) diff --git a/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Ebay.js b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Ebay.js new file mode 100644 index 0000000000..db6047718f --- /dev/null +++ b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Ebay.js @@ -0,0 +1,25 @@ +/* global add_heuristic_tests */ + +"use strict"; + +add_heuristic_tests( + [ + { + fixturePath: "Checkout_Payment_FR.html", + expectedResult: [ + { + default: { + reason: "autocomplete", + }, + fields: [ + { fieldName: "cc-number" }, + { fieldName: "cc-exp" }, + { fieldName: "cc-given-name" }, + { fieldName: "cc-family-name" }, + ], + }, + ], + }, + ], + "fixtures/third_party/Ebay/" +) diff --git a/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_GlobalDirectAsda.js b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_GlobalDirectAsda.js new file mode 100644 index 0000000000..7b82009032 --- /dev/null +++ b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_GlobalDirectAsda.js @@ -0,0 +1,24 @@ +/* global add_heuristic_tests */ + +"use strict"; + +add_heuristic_tests( + [ + { + fixturePath: "Payment.html", + expectedResult: [ + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "cc-number", reason: "fathom" }, + { fieldName: "cc-exp-month" }, + { fieldName: "cc-exp-year" }, + ], + }, + ], + }, + ], + "fixtures/third_party/GlobalDirectAsda/" +) 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 new file mode 100644 index 0000000000..8aac002b2d --- /dev/null +++ b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_HomeDepot.js @@ -0,0 +1,77 @@ +/* global add_heuristic_tests */ + +"use strict"; + +add_heuristic_tests( + [ + { + fixturePath: "Checkout_ShippingPayment.html", + expectedResult: [ + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "given-name" }, + { fieldName: "family-name" }, + { fieldName: "email" }, + { fieldName: "tel" }, + { fieldName: "street-address" }, + { fieldName: "postal-code" }, + ], + }, + { + invalid: true, + fields: [ + { + fieldName: "street-address", + reason: "autocomplete", + addressType: "billing", + }, + ], + }, + // THis should be fixed by visibility check + { + default: { + reason: "autocomplete", + }, + fields: [ + // FIXME: bug 1392944 - the uncommented cc-exp-month and cc-exp-year are + // both invisible elements, and the following two