tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit d9e9e0179d4ee1e72eeda79e65557d45ea25c6c2
parent ae14d1de4d426ad886ccccfa637780f7393b1936
Author: Dimi <dlee@mozilla.com>
Date:   Mon, 27 Oct 2025 09:46:22 +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:
Mbrowser/extensions/formautofill/test/browser/address/browser_phonenumber.js | 33+++++++++++++++++++++++++++------
Mbrowser/extensions/formautofill/test/browser/heuristics/browser_parse_tel_fields.js | 26++++++++++++++++++++++++++
Mbrowser/extensions/formautofill/test/browser/heuristics/third_party/browser_HomeDepot.js | 4++++
Mbrowser/extensions/formautofill/test/browser/heuristics/third_party/browser_OfficeDepot.js | 1+
Mtoolkit/components/formautofill/shared/FormAutofillHeuristics.sys.mjs | 6++++++
5 files changed, 64 insertions(+), 6 deletions(-)

diff --git a/browser/extensions/formautofill/test/browser/address/browser_phonenumber.js b/browser/extensions/formautofill/test/browser/address/browser_phonenumber.js @@ -589,10 +589,30 @@ let forms = [ results: { // ISSUE 14: // The telephone fields are not detected at all. - ADDRESS_US_LOCAL: { "postal-code": "" }, - ADDRESS_US_REMOTE: { "postal-code": "" }, - ADDRESS_DE_LOCAL: { "postal-code": "" }, - ADDRESS_DE_REMOTE: { "postal-code": "" }, + ADDRESS_US_LOCAL: { + "postal-code": "", + tel1: "6172535702", + tel2: "6172535702", + tel3: "6172535702", + }, + ADDRESS_US_REMOTE: { + "postal-code": "", + tel1: "030983333000", + tel2: "030983333000", + tel3: "030983333000", + }, + ADDRESS_DE_LOCAL: { + "postal-code": "", + tel1: "030983333001", + tel2: "030983333001", + tel3: "030983333001", + }, + ADDRESS_DE_REMOTE: { + "postal-code": "", + tel1: "033345649473", + tel2: "033345649473", + tel3: "033345649473", + }, }, }, { @@ -681,11 +701,12 @@ function processTestItems() { // This is a special case to handle when two fields of the // same type are present, which can be specified as, for example, // 'tel' and 'tel2'. + let fieldName = field; if (field.match(/[0-9]$/)) { - field = field.substring(0, field.length - 1); + fieldName = field.substring(0, field.length - 1); } - let fieldData = { fieldName: field }; + let fieldData = { fieldName }; let value = profileInfo[field]; // A value starting with * means use reason="autocomplete". 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/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_OfficeDepot.js b/browser/extensions/formautofill/test/browser/heuristics/third_party/browser_OfficeDepot.js @@ -64,6 +64,7 @@ add_heuristic_tests( { fieldName: "tel-local-suffix", reason: "update-heuristic" }, { fieldName: "tel-extension", reason: "update-heuristic" }, { fieldName: "email" }, + { fieldName: "tel" }, ], }, ], 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]; },