diff options
Diffstat (limited to 'browser/extensions/formautofill/test/browser/heuristics')
29 files changed, 2328 insertions, 0 deletions
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: ` + <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" /> + <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 invisible because of css style", + 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" hidden /> + <input type="text" id="postal-code" autocomplete="postal-code" style="display:none" /> + <input type="text" id="address-line1" autocomplete="address-line1" style="opacity:0" /> + <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" }, + ], + }, + ], + }, + { + // 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: ` + <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" hidden /> + <input type="text" id="postal-code" autocomplete="postal-code" style="display:none" /> + <input type="text" id="address-line1" autocomplete="address-line1" style="opacity:0" /> + <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: "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: ` + <html> + <body> + <form> + <p><label>country: <input type="text" id="country" name="country" /></label></p> + <p><label>tel: <input type="text" id="tel" name="tel" /></label></p> + <p><label><input type="text" id="housenumber" /></label></p> + </form> + </body> + </html>`, + 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: ` + <html> + <body> + <form> + <p><label>country: <input type="text" id="country" name="country" /></label></p> + <p><label>tel: <input type="text" id="tel" name="tel" /></label></p> + <p><label><input type="text" id="housenumber" /></label></p> + <p><label><input type="text" id="addrcomplement" /></label></p> + </form> + </body> + </html>`, + 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: ` + <html> + <body> + <form> + <input type="text" id="street-address" autocomplete="street-address"/> + <input type="text" id="address-line2" autocomplete="address-line2"/> + <input type="text" id="email" autocomplete="email"/> + </form> + </body> + </html>`, + 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: ` + <html> + <body> + <form> + <input type="text" id="street-address" autocomplete="street-address"/> + <input type="text" id="address-line3" autocomplete="address-line3"/> + <input type="text" id="email" autocomplete="email"/> + </form> + </body> + </html>`, + 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: ` + <html> + <body> + <form> + <input type="text" id="street-address" autocomplete="street-address"/> + <input type="text" id="address-line1" autocomplete="address-line1"/> + <input type="text" id="email" autocomplete="email"/> + </form> + </body> + </html>`, + 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: ` + <html><body> + <input id="street-address" autocomplete="street-address"> + <input id="postal-code" autocomplete="postal-code"> + <input id="email" autocomplete="email"> + </body></html> + `, + 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: ` + <html><body> + <input id="postal-code" autocomplete="postal-code"> + <input id="email" autocomplete="email"> + + <input id="postal-code" autocomplete="postal-code"> + </body></html> + `, + 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: ` + <html><body> + <input id="postal-code" autocomplete="postal-code"> + <input id="email" autocomplete="email"> + <input id="email" autocomplete="email"> + </body></html> + `, + 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: ` + <html><body> + <input id="street-address" autocomplete="billing street-address"> + <input id="postal-code" autocomplete="billing postal-code"> + <input id="country" autocomplete="billing country"> + </body></html> + `, + expectedResult: [ + { + default: { + reason: "autocomplete", + addressType: "billing", + }, + fields: [ + { fieldName: "street-address" }, + { fieldName: "postal-code" }, + { fieldName: "country" }, + ], + }, + ], + }, + { + description: `One billing section and one shipping section`, + fixtureData: ` + <html><body> + <input id="street-address" autocomplete="billing street-address"> + <input id="postal-code" autocomplete="billing postal-code"> + <input id="country" autocomplete="billing country"> + <input id="street-address" autocomplete="shipping street-address"> + <input id="postal-code" autocomplete="shipping postal-code"> + <input id="country" autocomplete="shipping country"> + </body></html> + `, + 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: ` + <html><body> + <input id="street-address" autocomplete="billing street-address"> + <input id="postal-code" autocomplete="billing postal-code"> + <input id="street-address" autocomplete="shipping street-address"> + <input id="postal-code" autocomplete="shipping postal-code"> + <input id="country" autocomplete="shipping country"> + <input id="country" autocomplete="billing country"> + </body></html> + `, + 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: ` + <html><body> + <input id="street-address" autocomplete="street-address"> + <input id="postal-code" autocomplete="postal-code"> + <input id="country" autocomplete="country"> + <input id="street-address" autocomplete="billing street-address"> + <input id="postal-code" autocomplete="billing postal-code"> + <input id="country" autocomplete="billing country"> + </body></html> + `, + 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: ` + <html><body> + <input id="street-address" autocomplete="billing street-address"> + <input id="postal-code" autocomplete="billing postal-code"> + <input id="country" autocomplete="billing country"> + <input id="street-address" autocomplete="street-address"> + <input id="postal-code" autocomplete="postal-code"> + <input id="country" autocomplete="country"> + </body></html> + `, + 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: ` + <html><body> + <input id="name" autocomplete="name"> + <input id="street-address" autocomplete="billing street-address"> + <input id="postal-code" autocomplete="billing postal-code"> + <input id="country" autocomplete="billing country"> + <input id="street-address" autocomplete="shipping street-address"> + <input id="postal-code" autocomplete="shipping postal-code"> + <input id="country" autocomplete="shipping country"> + <input id="name" autocomplete="name"> + </body></html> + `, + 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: ` + <html><body> + <input id="name" autocomplete="name"> + <input id="street-address" autocomplete="billing street-address"> + <input id="postal-code" autocomplete="billing postal-code"> + <input id="country" autocomplete="billing country"> + <input id="name" autocomplete="name"> + </body></html> + `, + 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: ` + <html><body> + <input id="street-address" autocomplete="billing street-address"> + <input id="postal-code" autocomplete="billing postal-code"> + <input id="country" autocomplete="billing country"> + <input id="email" autocomplete="email"> + <input id="email" autocomplete="email"> + </body></html> + `, + 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: ` + <html><body> + <input id="street-address" autocomplete="street-address"> + <input id="postal-code" autocomplete="postal-code"> + <input id="country" autocomplete="country"> + <input id="street-address" autocomplete="street-address"> + <input id="postal-code" autocomplete="postal-code"> + <input id="country" autocomplete="country"> + </body></html> + `, + 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 <input> elements, and the following two <select> + // elements are the correct ones. BTW, they are both applied + // autocomplete attr. + { fieldName: "cc-exp-month" }, + { fieldName: "cc-exp-year" }, + { fieldName: "cc-number", reason: "fathom" }, + ], + }, + { + invalid: true, + fields: [ + { fieldName: "cc-exp-month", reason: "regex-heuristic"}, + { fieldName: "cc-exp-year", reason: "regex-heuristic"}, + // {fieldName: "cc-csc"}, + ], + }, + ], + }, + { + fixturePath: "SignIn.html", + expectedResult: [ + { + invalid: true, + fields: [ + { fieldName: "email",reason: "regex-heuristic" }, + ], + }, + { + invalid: true, + fields: [ + { fieldName: "email",reason: "regex-heuristic" }, + ], + }, + ], + }, + ], + "fixtures/third_party/HomeDepot/" +); diff --git a/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Lufthansa.js b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Lufthansa.js new file mode 100644 index 0000000000..801dbf66be --- /dev/null +++ b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Lufthansa.js @@ -0,0 +1,28 @@ +/* global add_heuristic_tests */ + +"use strict"; + +add_heuristic_tests( + [ + { + fixturePath: "Checkout_Payment.html", + expectedResult: [ + { + default: { + reason: "fathom", + }, + fields: [ + { fieldName: "cc-type", reason: "regex-heuristic" }, + { fieldName: "cc-number" }, + { fieldName: "cc-number" }, + { fieldName: "cc-number" }, + { fieldName: "cc-number" }, + { fieldName: "cc-exp-month", reason: "regex-heuristic" }, + { fieldName: "cc-exp-year", reason: "regex-heuristic" }, + ], + }, + ], + }, + ], + "fixtures/third_party/Lufthansa/" +); diff --git a/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Lush.js b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Lush.js new file mode 100644 index 0000000000..a59fc966e5 --- /dev/null +++ b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Lush.js @@ -0,0 +1,31 @@ +/* global add_heuristic_tests */ + +"use strict"; + +add_heuristic_tests( + [ + { + fixturePath: "index.html", + expectedResult: [ + { + default: { + reason: "fathom", + }, + fields: [ + { fieldName: "cc-name" }, + { fieldName: "cc-number" }, + ], + }, + { + fields: [ + { fieldName: "cc-number", reason: "autocomplete" }, + { fieldName: "cc-name", reason: "fathom" }, + { fieldName: "cc-exp-month", reason: "regex-heuristic" }, + { fieldName: "cc-exp-year", reason: "regex-heuristic" }, + ], + }, + ], + }, + ], + "fixtures/third_party/Lush/" +); diff --git a/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Macys.js b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Macys.js new file mode 100644 index 0000000000..e02996b565 --- /dev/null +++ b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Macys.js @@ -0,0 +1,88 @@ +/* global add_heuristic_tests */ + +"use strict"; + +add_heuristic_tests( + [ + { + fixturePath: "Checkout_ShippingAddress.html", + expectedResult: [ + { + default: { + reason: "autocomplete", + }, + fields: [ + { fieldName: "given-name" }, + { fieldName: "family-name" }, + { fieldName: "address-line1" }, + { fieldName: "address-line2" }, + { fieldName: "address-level2" }, // city + { fieldName: "address-level1" }, // state + { fieldName: "postal-code" }, + { fieldName: "tel" }, + ], + }, + ], + }, + { + fixturePath: "Checkout_Payment.html", + expectedResult: [ + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "cc-type" }, // ac-off + { fieldName: "cc-number", reason: "fathom" }, // ac-off + { fieldName: "cc-exp-month" }, // ac-off + { fieldName: "cc-exp-year" }, // ac-off + // {fieldName: "cc-csc"}, // ac-off + ], + }, + { + default: { + reason: "autocomplete", + }, + fields: [ + { fieldName: "given-name" }, + { fieldName: "family-name" }, + { fieldName: "address-line1" }, + { fieldName: "address-line2" }, + { fieldName: "address-level2" }, // city + { fieldName: "address-level1" }, // state + { fieldName: "postal-code" }, + { fieldName: "tel" }, + { fieldName: "email" }, + ], + }, + ], + }, + { + fixturePath: "SignIn.html", + expectedResult: [ + { + invalid: true, + fields: [ + // Sign in + { fieldName: "email", reason: "regex-heuristic"}, + // {fieldName: "password"}, + ], + }, + { + invalid: true, + fields: [ + // Forgot password + { fieldName: "email", reason: "regex-heuristic"}, + ], + }, + { + invalid: true, + fields: [ + { fieldName: "email", reason: "regex-heuristic"}, + ], + }, + ], + }, + ], + "fixtures/third_party/Macys/" +); diff --git a/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_NewEgg.js b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_NewEgg.js new file mode 100644 index 0000000000..d914f02890 --- /dev/null +++ b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_NewEgg.js @@ -0,0 +1,109 @@ +/* global add_heuristic_tests */ + +"use strict"; + +add_heuristic_tests( + [ + { + fixturePath: "ShippingInfo.html", + expectedResult: [ + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "given-name" }, + { fieldName: "family-name" }, + { fieldName: "country" }, + { fieldName: "address-line1" }, + { fieldName: "address-line2" }, + { fieldName: "address-level2" }, + { fieldName: "address-level1" }, // state + { fieldName: "postal-code" }, + { fieldName: "tel" }, + { fieldName: "email" }, + ], + }, + ], + }, + { + fixturePath: "BillingInfo.html", + expectedResult: [ + { + default: { + reason: "fathom", + }, + fields: [ + { fieldName: "cc-name" }, + { fieldName: "cc-number" }, // ac-off + ], + }, + { + default: { + reason: "fathom", + }, + fields: [ + { fieldName: "cc-name" }, + { fieldName: "cc-number" }, // ac-off + { fieldName: "cc-exp-month", reason: "regex-heuristic" }, + { fieldName: "cc-exp-year", reason: "regex-heuristic" }, + // { fieldName: "cc-csc"}, + ], + }, + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "country" }, + { fieldName: "address-line1" }, + { fieldName: "address-line2" }, + { fieldName: "address-level2" }, + { fieldName: "address-level1" }, // state + { fieldName: "postal-code" }, + { fieldName: "tel" }, + ], + }, + { + default: { + reason: "fathom", + }, + fields: [ + { fieldName: "cc-name" }, + { fieldName: "cc-number" }, // ac-off + { fieldName: "cc-exp-month", reason: "regex-heuristic" }, + { fieldName: "cc-exp-year", reason: "regex-heuristic" }, + ], + }, + { + default: { + reason: "fathom", + }, + fields: [ + { fieldName: "cc-name" }, + { fieldName: "cc-number" }, // ac-off + ], + }, + ], + }, + { + fixturePath: "Login.html", + expectedResult: [ + { + invalid: true, + fields: [ + { fieldName: "email", reason: "regex-heuristic" }, + ], + }, + { + invalid: true, + fields: [ + { fieldName: "email", reason: "regex-heuristic" }, // Email Address + { fieldName: "email", reason: "regex-heuristic" }, // Confirm Email Address + ], + }, + ], + }, + ], + "fixtures/third_party/NewEgg/" +); diff --git a/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_OfficeDepot.js b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_OfficeDepot.js new file mode 100644 index 0000000000..8c44104cb6 --- /dev/null +++ b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_OfficeDepot.js @@ -0,0 +1,83 @@ +/* global add_heuristic_tests */ + +"use strict"; + +add_heuristic_tests( + [ + { + fixturePath: "ShippingAddress.html", + expectedResult: [ + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "given-name" }, + { fieldName: "family-name" }, + { fieldName: "organization" }, + { fieldName: "address-line1" }, + { fieldName: "address-line2" }, + { fieldName: "postal-code" }, + { fieldName: "address-level2" }, // City & State + { fieldName: "address-level2" }, // City + { fieldName: "address-level1" }, // State + { fieldName: "tel-area-code" }, + { fieldName: "tel-local-prefix" }, + { fieldName: "tel-local-suffix" }, + { fieldName: "tel-extension" }, + { fieldName: "email" }, + ], + }, + ], + }, + { + fixturePath: "Payment.html", + expectedResult: [ + { + invalid: true, // because non of them is identified by fathom + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "cc-exp-month" }, + { fieldName: "cc-exp-year" }, + { fieldName: "cc-number" }, + ], + }, + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "given-name" }, + { fieldName: "family-name" }, + { fieldName: "organization" }, + { fieldName: "address-line1" }, + { fieldName: "address-line2" }, + { fieldName: "postal-code" }, + { fieldName: "address-level2" }, // City & State + { fieldName: "address-level2" }, // City + { fieldName: "address-level1" }, // state + { fieldName: "tel-area-code" }, + { fieldName: "tel-local-prefix" }, + { fieldName: "tel-local-suffix" }, + { fieldName: "tel-extension" }, + { fieldName: "email" }, + ], + }, + ], + }, + { + fixturePath: "SignIn.html", + expectedResult: [ + { + invalid: true, + fields: [ + { fieldName: "email", reason: "regex-heuristic" }, + ], + }, + ], + }, + ], + "fixtures/third_party/OfficeDepot/" +); diff --git a/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_QVC.js b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_QVC.js new file mode 100644 index 0000000000..bc0504e726 --- /dev/null +++ b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_QVC.js @@ -0,0 +1,96 @@ +/* global add_heuristic_tests */ + +"use strict"; + +add_heuristic_tests( + [ + { + fixturePath: "YourInformation.html", + expectedResult: [ + { + invalid: true, + fields: [ + { fieldName: "tel", reason: "regex-heuristic" }, + { fieldName: "email", reason: "regex-heuristic" }, + // { fieldName: "bday-month"}, // select + // { fieldName: "bday-day"}, // select + // { fieldName: "bday-year"}, + ], + }, + { + fields: [ + { fieldName: "cc-type", reason: "regex-heuristic" }, + { fieldName: "cc-number", reason: "fathom" }, + { fieldName: "cc-exp", reason: "regex-heuristic" }, + // { fieldName: "cc-csc"}, + ], + }, + { + invalid: true, + fields: [ + { fieldName: "cc-number", reason: "regex-heuristic" }, // txtQvcGiftCardNumber + ], + }, + { + invalid: true, + fields: [ + { fieldName: "email", reason: "regex-heuristic" }, + { fieldName: "email", reason: "regex-heuristic" }, + ], + }, + ], + }, + { + fixturePath: "PaymentMethod.html", + expectedResult: [ + { + invalid: true, + fields: [ + { fieldName: "tel", reason: "regex-heuristic" }, + { fieldName: "email", reason: "regex-heuristic" }, + // { fieldName: "bday-month"}, // select + // { fieldName: "bday-day"}, // select + // { fieldName: "bday-year"}, // select + ], + }, + { + default: { + reason: "fathom", + }, + fields: [ + { fieldName: "cc-type", reason: "regex-heuristic" }, // ac-off + { fieldName: "cc-number" }, // ac-off + { fieldName: "cc-exp", reason: "regex-heuristic" }, + // { fieldName: "cc-csc"}, + ], + }, + { + invalid: true, + fields: [ + { fieldName: "cc-number", reason: "regex-heuristic" }, // txtQvcGiftCardNumbe, ac-off + ], + }, + { + invalid: true, + fields: [ + { fieldName: "email", reason: "regex-heuristic" }, + { fieldName: "email", reason: "regex-heuristic" }, + ], + }, + ], + }, + { + fixturePath: "SignIn.html", + expectedResult: [ + { + // Sign in + invalid: true, + fields: [ + { fieldName: "email", reason: "regex-heuristic" }, + ], + }, + ], + }, + ], + "fixtures/third_party/QVC/" +); diff --git a/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Sears.js b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Sears.js new file mode 100644 index 0000000000..4c668ddad1 --- /dev/null +++ b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Sears.js @@ -0,0 +1,81 @@ +/* global add_heuristic_tests */ + +"use strict"; + +add_heuristic_tests( + [ + { + fixturePath: "ShippingAddress.html", + expectedResult: [ + { + invalid: true, + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "email" }, + ] + }, + { + default: { + reason: "regex-heuristic", + }, + fields: [ + // check-out, ac-off + { fieldName: "given-name" }, + { fieldName: "family-name" }, + { fieldName: "address-line1" }, + { fieldName: "address-line2" }, + { fieldName: "address-level2" }, + { fieldName: "address-level1" }, + { fieldName: "postal-code" }, + { fieldName: "tel" }, + { fieldName: "tel-extension" }, + { fieldName: "email" }, + { fieldName: "email" }, + ], + }, + { + default: { + reason: "regex-heuristic", + }, + fields: [ + // ac-off + // { fieldName: "email"}, + { fieldName: "given-name" }, + { fieldName: "family-name" }, + { fieldName: "address-line1" }, + { fieldName: "address-line2" }, + { fieldName: "address-level2" }, + { fieldName: "address-level1" }, + { fieldName: "postal-code" }, + { fieldName: "tel" }, + { fieldName: "tel-extension" }, + // { fieldName: "new-password"}, + ], + }, + { + invalid: true, + default: { + reason: "regex-heuristic", + }, + fields: [ + // ac-off + { fieldName: "email" }, + ] + }, + { + invalid: true, + default: { + reason: "regex-heuristic", + }, + fields: [ + // ac-off + { fieldName: "email" }, + ] + }, + ], + }, + ], + "fixtures/third_party/Sears/" +); diff --git a/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Staples.js b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Staples.js new file mode 100644 index 0000000000..4b03fe2338 --- /dev/null +++ b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Staples.js @@ -0,0 +1,78 @@ +/* global add_heuristic_tests */ + +"use strict"; + +add_heuristic_tests( + [ + { + fixturePath: "Basic.html", + expectedResult: [ + { + // ac-off + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "given-name" }, + { fieldName: "family-name" }, + { fieldName: "address-line1" }, + { fieldName: "email" }, + { fieldName: "tel" }, + { fieldName: "tel" }, // Extension + { fieldName: "organization" }, + ] + }, + ], + }, + { + fixturePath: "Basic_ac_on.html", + expectedResult: [ + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "given-name" }, + { fieldName: "family-name" }, + { fieldName: "address-line1" }, + { fieldName: "email" }, + { fieldName: "tel" }, + { fieldName: "tel" }, // Extension + { fieldName: "organization" }, + ], + }, + ], + }, + { + fixturePath: "PaymentBilling.html", + expectedResult: [ + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "cc-number", reason: "fathom" }, + { fieldName: "cc-exp" }, + // {fieldName: "cc-csc"}, + ], + }, + ], + }, + { + fixturePath: "PaymentBilling_ac_on.html", + expectedResult: [ + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "cc-number", reason: "fathom" }, + { fieldName: "cc-exp" }, + // { fieldName: "cc-csc"}, + ], + }, + ], + }, + ], + "fixtures/third_party/Staples/" +); diff --git a/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Walmart.js b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Walmart.js new file mode 100644 index 0000000000..f2896bd9ac --- /dev/null +++ b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_Walmart.js @@ -0,0 +1,93 @@ +/* global add_heuristic_tests */ + +"use strict"; + +add_heuristic_tests( + [ + { + fixturePath: "Checkout.html", + expectedResult: [ + { + invalid: true, + fields: [ + { fieldName: "postal-code", reason: "regex-heuristic" }, + ], + }, + { + invalid: true, + fields: [ + { fieldName: "email", reason: "regex-heuristic" }, + // { fieldName: "password"}, // ac-off + ], + }, + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "given-name" }, + { fieldName: "family-name" }, + { fieldName: "email" }, // ac-off + // { fieldName: "password"}, + // { fieldName: "password"}, // ac-off + ], + }, + ], + }, + { + fixturePath: "Payment.html", + expectedResult: [ + { + default: { + reason: "autocomplete", + section: "section-payment", + }, + fields: [ + { fieldName: "given-name" }, + { fieldName: "family-name" }, + { fieldName: "tel" }, + ], + }, + { + default: { + reason: "autocomplete", + section: "section-payment", + }, + fields: [ + { fieldName: "cc-number" }, + { fieldName: "cc-exp-month" }, + { fieldName: "cc-exp-year" }, + // { fieldName: "cc-csc"}, + ], + }, + ], + }, + { + fixturePath: "Shipping.html", + expectedResult: [ + { + invalid: true, + fields: [ + { fieldName: "postal-code", reason: "regex-heuristic" }, + ], + }, + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "given-name" }, + { fieldName: "family-name" }, + { fieldName: "tel" }, + { fieldName: "address-line1" }, + { fieldName: "address-line2" }, + { fieldName: "address-level2" }, // city + { fieldName: "address-level1" }, // state + { fieldName: "postal-code" }, + ], + }, + ], + }, + ], + "fixtures/third_party/Walmart/" +); |