commit 6675fb88080efd5ef006bea154f5060c921246bc parent 9cbe62581b7f907b2e597173e12dd75b10fce17c Author: Dimi <dlee@mozilla.com> Date: Thu, 23 Oct 2025 12:32:10 +0000 Bug 1935980 - if a field is not identified but has type='tel', assume it is a tel field r=NeilDeakin,credential-management-reviewers Differential Revision: https://phabricator.services.mozilla.com/D266807 Diffstat:
3 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/browser/extensions/formautofill/test/browser/heuristics/browser_parse_tel_fields.js b/browser/extensions/formautofill/test/browser/heuristics/browser_parse_tel_fields.js @@ -34,4 +34,30 @@ add_heuristic_tests([ }, ], }, + { + description: + "Address form where type='tel' must be checked to identify telephone field", + fixtureData: ` + <form> + <input type="text" id="name" autocomplete="name"/> + <input type="text" id="country" autocomplete="country"/> + <input type="text" id="street-address" autocomplete="street-address"/> + <input type="text" id="address-line1" autocomplete="address-line1"/> + <input type="tel"/> + </form>`, + expectedResult: [ + { + default: { + reason: "autocomplete", + }, + fields: [ + { fieldName: "name" }, + { fieldName: "country" }, + { fieldName: "street-address" }, + { fieldName: "address-line1" }, + { fieldName: "tel", reason: "regex-heuristic" }, + ], + }, + ], + }, ]); 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 @@ -28,6 +28,10 @@ add_heuristic_tests( reason: "autocomplete", addressType: "billing", }, + { + fieldName: "tel", + reason: "regex-heuristic", + }, ], }, { diff --git a/toolkit/components/formautofill/shared/FormAutofillHeuristics.sys.mjs b/toolkit/components/formautofill/shared/FormAutofillHeuristics.sys.mjs @@ -1111,6 +1111,12 @@ export const FormAutofillHeuristics = { fathomFoundType ); + // If regular expression based heuristics doesn't find any matched field name, + // and the input type is "tel", just use "tel" as the field name. + if (!matchedFieldNames.length && element.type == "tel") { + return ["tel", inferredInfo]; + } + return [matchedFieldNames, inferredInfo]; },