tor-browser

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

commit c06fcd1e656ee3e5ca91a80b035cd944c7a5a3c7
parent 4a06d092ba692a88e92ca9b30d0f3070d77e3618
Author: Neil Deakin <neil@mozilla.com>
Date:   Tue, 16 Dec 2025 14:47:40 +0000

Bug 1999525, modifications to tests to account for improved telephone country and tel-national detection, r=dimi,credential-management-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D275143

Diffstat:
Mbrowser/extensions/formautofill/test/browser/address/browser.toml | 2++
Mbrowser/extensions/formautofill/test/browser/address/browser_phonenumber.js | 147+++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------
Abrowser/extensions/formautofill/test/browser/address/browser_phonenumber_country.js | 72++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mbrowser/extensions/formautofill/test/browser/head.js | 5++++-
4 files changed, 177 insertions(+), 49 deletions(-)

diff --git a/browser/extensions/formautofill/test/browser/address/browser.toml b/browser/extensions/formautofill/test/browser/address/browser.toml @@ -75,3 +75,5 @@ skip-if = [ ["browser_edit_address_doorhanger_save_edited_fields.js"] ["browser_phonenumber.js"] + +["browser_phonenumber_country.js"] diff --git a/browser/extensions/formautofill/test/browser/address/browser_phonenumber.js b/browser/extensions/formautofill/test/browser/address/browser_phonenumber.js @@ -93,15 +93,18 @@ let forms = [ <input id="tel" autocomplete="tel"> </form>`, results: { - ADDRESS_US_LOCAL: { country: "+1", tel: "*+16172535702" }, - ADDRESS_US_REMOTE: { country: "+1", tel: "*+4930983333000" }, - ADDRESS_DE_LOCAL: { country: "+49", tel: "*+4930983333001" }, + ADDRESS_US_LOCAL: { "tel-country-code": "+1", tel: "*+16172535702" }, + ADDRESS_US_REMOTE: { "tel-country-code": "+49", tel: "*+4930983333000" }, + ADDRESS_DE_LOCAL: { "tel-country-code": "+49", tel: "*+4930983333001" }, // ISSUE 3: // This is incorrect, the country code is already part of the phone number, // but it is being applied twice. The result should be: - // ADDRESS_DE_REMOTE: { country: "+33", tel: "*+3334564947391" }, + // ADDRESS_DE_REMOTE: { "tel-country-code": "+33", tel: "*+3334564947391" }, // This same issue affects a number of the remaining tests. - ADDRESS_DE_REMOTE: { country: "+49", tel: "*+493334564947391" }, + ADDRESS_DE_REMOTE: { + "tel-country-code": "+49", + tel: "*+493334564947391", + }, }, }, { @@ -115,6 +118,7 @@ let forms = [ // in inferFieldInfo(), which only looks for the last two options and assumes that these // last two must match a country. Probably, we should not do that check at all if we think // this will be a tel-country-code field. + // This was fixed by bug 1999525. description: "dropdown for country, values of form '+XX', but with an alternate name for the country", fixtureData: `<form> @@ -153,10 +157,10 @@ let forms = [ <input id="tel" autocomplete="tel"> </form>`, results: { - ADDRESS_US_LOCAL: { country: "", tel: "*+16172535702" }, - ADDRESS_US_REMOTE: { country: "", tel: "*+4930983333000" }, - ADDRESS_DE_LOCAL: { country: "", tel: "*+4930983333001" }, - ADDRESS_DE_REMOTE: { country: "", tel: "*+493334564947391" }, + ADDRESS_US_LOCAL: { "tel-country-code": "", tel: "*+16172535702" }, + ADDRESS_US_REMOTE: { "tel-country-code": "", tel: "*+4930983333000" }, + ADDRESS_DE_LOCAL: { "tel-country-code": "", tel: "*+4930983333001" }, + ADDRESS_DE_REMOTE: { "tel-country-code": "", tel: "*+493334564947391" }, }, }, @@ -177,10 +181,10 @@ let forms = [ <input id="tel" autocomplete="tel"> </form>`, results: { - ADDRESS_US_LOCAL: { country: "1", tel: "*+16172535702" }, - ADDRESS_US_REMOTE: { country: "1", tel: "*+4930983333000" }, - ADDRESS_DE_LOCAL: { country: "49", tel: "*+4930983333001" }, - ADDRESS_DE_REMOTE: { country: "49", tel: "*+493334564947391" }, + ADDRESS_US_LOCAL: { "tel-country-code": "1", tel: "*+16172535702" }, + ADDRESS_US_REMOTE: { "tel-country-code": "49", tel: "*+4930983333000" }, + ADDRESS_DE_LOCAL: { "tel-country-code": "49", tel: "*+4930983333001" }, + ADDRESS_DE_REMOTE: { "tel-country-code": "49", tel: "*+493334564947391" }, }, }, @@ -204,14 +208,23 @@ let forms = [ results: { // Interestingly, this is being detected as a 'tel' field but is treated // as 'tel-national' when filled in: - ADDRESS_US_LOCAL: { "tel-country-code": "*+1", tel: "6172535702" }, + ADDRESS_US_LOCAL: { + "tel-country-code": "*+1", + "tel-national": "@6172535702", + }, // ISSUE 5: // The 'tel' field has a '0' prepended. - ADDRESS_US_REMOTE: { "tel-country-code": "*+49", tel: "030983333000" }, - ADDRESS_DE_LOCAL: { "tel-country-code": "*+49", tel: "030983333001" }, + ADDRESS_US_REMOTE: { + "tel-country-code": "*+49", + "tel-national": "@030983333000", + }, + ADDRESS_DE_LOCAL: { + "tel-country-code": "*+49", + "tel-national": "@030983333001", + }, ADDRESS_DE_REMOTE: { "tel-country-code": "*+49", - tel: "03334564947391", + "tel-national": "@03334564947391", }, }, }, @@ -232,14 +245,21 @@ let forms = [ <input id="tel"> </form>`, results: { - ADDRESS_US_LOCAL: { country: "+1", tel: "6172535702" }, - // As with the last test, '0' is prepended, even though the dropdown is detected as - // a country field and not tel-country-code. - ADDRESS_US_REMOTE: { country: "+1", tel: "030983333000" }, - ADDRESS_DE_LOCAL: { country: "+49", tel: "030983333001" }, + ADDRESS_US_LOCAL: { + "tel-country-code": "+1", + "tel-national": "@6172535702", + }, + ADDRESS_US_REMOTE: { + "tel-country-code": "+49", + "tel-national": "@030983333000", + }, + ADDRESS_DE_LOCAL: { + "tel-country-code": "+49", + "tel-national": "@030983333001", + }, ADDRESS_DE_REMOTE: { - country: "+49", - tel: "03334564947391", + "tel-country-code": "+49", + "tel-national": "@03334564947391", }, }, }, @@ -306,12 +326,21 @@ let forms = [ <input id="phone"> </form>`, results: { - ADDRESS_US_LOCAL: { "tel-country-code": "+1", tel: "6172535702" }, - ADDRESS_US_REMOTE: { "tel-country-code": "+49", tel: "030983333000" }, - ADDRESS_DE_LOCAL: { "tel-country-code": "+49", tel: "030983333001" }, + ADDRESS_US_LOCAL: { + "tel-country-code": "+1", + "tel-national": "@6172535702", + }, + ADDRESS_US_REMOTE: { + "tel-country-code": "+49", + "tel-national": "@030983333000", + }, + ADDRESS_DE_LOCAL: { + "tel-country-code": "+49", + "tel-national": "@030983333001", + }, ADDRESS_DE_REMOTE: { "tel-country-code": "+49", - tel: "03334564947391", + "tel-national": "@03334564947391", }, }, }, @@ -330,12 +359,21 @@ let forms = [ <input id="phone"> </form>`, results: { - ADDRESS_US_LOCAL: { "tel-country-code": "+1", tel: "6172535702" }, - ADDRESS_US_REMOTE: { "tel-country-code": "+49", tel: "030983333000" }, - ADDRESS_DE_LOCAL: { "tel-country-code": "+49", tel: "030983333001" }, + ADDRESS_US_LOCAL: { + "tel-country-code": "+1", + "tel-national": "@6172535702", + }, + ADDRESS_US_REMOTE: { + "tel-country-code": "+49", + "tel-national": "@030983333000", + }, + ADDRESS_DE_LOCAL: { + "tel-country-code": "+49", + "tel-national": "@030983333001", + }, ADDRESS_DE_REMOTE: { "tel-country-code": "+49", - tel: "03334564947391", + "tel-national": "@03334564947391", }, }, }, @@ -359,22 +397,22 @@ let forms = [ // instead of the country abbreviations. ADDRESS_US_LOCAL: { "tel-country-code": "+1", - tel: "6172535702", + "tel-national": "@6172535702", country: "US", }, ADDRESS_US_REMOTE: { "tel-country-code": "+49", - tel: "030983333000", + "tel-national": "@030983333000", country: "US", }, ADDRESS_DE_LOCAL: { "tel-country-code": "+49", - tel: "030983333001", + "tel-national": "@030983333001", country: "DE", }, ADDRESS_DE_REMOTE: { "tel-country-code": "+49", - tel: "03334564947391", + "tel-national": "@03334564947391", country: "DE", }, }, @@ -497,37 +535,37 @@ let forms = [ <input id="lastname"> <input id="phone-country-code" maxlength="3"> <input id="phone-area-code" maxlength="3"> - <input id="phone-local-prefix" maxlength="5"> - <input id="phone-local-suffix" maxlength="3"> + <input id="phone-local-prefix" maxlength="3"> + <input id="phone-local-suffix" maxlength="5"> </form>`, results: { // These do not match the grammar in PHONE_FIELD_GRAMMARS so they are all // treated as 'tel' fields, but the values are cropped due to the maxlength // attributes. - // ISSUE 12: why does tel3 have the value "617" and not "61725" as its maxlength is 5? + // ISSUE 12: why does tel2 have the value "617" and not "61725" as its maxlength is 5? ADDRESS_US_LOCAL: { "tel-country-code": "+1", + "tel-national": "@617", tel: "617", tel2: "617", - tel3: "617", }, ADDRESS_US_REMOTE: { "tel-country-code": "+49", + "tel-national": "@030", tel: "030", tel2: "030", - tel3: "030", }, ADDRESS_DE_LOCAL: { "tel-country-code": "+49", + "tel-national": "@030", tel: "030", tel2: "030", - tel3: "030", }, ADDRESS_DE_REMOTE: { "tel-country-code": "+49", + "tel-national": "@033", tel: "033", tel2: "033", - tel3: "033", }, }, }, @@ -588,7 +626,7 @@ let forms = [ </form>`, results: { // ISSUE 14: - // The telephone fields are not detected at all. + // The telephone fields are not detected at all. This was fixed by 1935980. ADDRESS_US_LOCAL: { "postal-code": "", tel1: "6172535702", @@ -632,10 +670,23 @@ let forms = [ </form>`, results: { // ISSUE 16: the telephone fields should be treated as tel-country-code and tel-national. - ADDRESS_US_LOCAL: { "tel-country-code": "+1", tel: "6172535702" }, - ADDRESS_US_REMOTE: { "tel-country-code": "+49", tel: "030983333000" }, - ADDRESS_DE_LOCAL: { "tel-country-code": "+49", tel: "030983333001" }, - ADDRESS_DE_REMOTE: { "tel-country-code": "+49", tel: "03334564947391" }, + // This was fixed by bug 1999525. + ADDRESS_US_LOCAL: { + "tel-country-code": "+1", + "tel-national": "@6172535702", + }, + ADDRESS_US_REMOTE: { + "tel-country-code": "+49", + "tel-national": "@030983333000", + }, + ADDRESS_DE_LOCAL: { + "tel-country-code": "+49", + "tel-national": "@030983333001", + }, + ADDRESS_DE_REMOTE: { + "tel-country-code": "+49", + "tel-national": "@03334564947391", + }, }, }, { diff --git a/browser/extensions/formautofill/test/browser/address/browser_phonenumber_country.js b/browser/extensions/formautofill/test/browser/address/browser_phonenumber_country.js @@ -0,0 +1,72 @@ +/* Any copyright is dedicated to the Public Domain. +http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +add_autofill_heuristic_tests([ + { + description: + "Address form with country code field where the id doesn't match", + fixtureData: ` + <form> + <input id="firstname"> + <input id="lastname"> + <select id="copt"> + <option value="-">Unknown + <option value="1">Canada + <option value="2">France + <option value="3">Germany + <option value="4">Greece + <option value="5">United States + <option value="6">Venezuela + </select> + <input id="tel"> + </form>`, + profile: TEST_ADDRESS_1, + expectedResult: [ + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "given-name", autofill: TEST_ADDRESS_1["given-name"] }, + { fieldName: "family-name", autofill: TEST_ADDRESS_1["family-name"] }, + { fieldName: "country", autofill: "5" }, + { fieldName: "tel", autofill: TEST_ADDRESS_1.tel.substring(2) }, + ], + }, + ], + }, + { + description: + "Address form with country code field where the country does not exist", + fixtureData: ` + <form> + <input id="firstname"> + <input id="lastname"> + <select id="copt"> + <option value="-">Unknown + <option value="1">Canada + <option value="2">France + <option value="3">Germany + <option value="4">Greece + <option value="5">Venezuela + </select> + <input id="tel"> + </form>`, + profile: TEST_ADDRESS_1, + expectedResult: [ + { + default: { + reason: "regex-heuristic", + }, + fields: [ + { fieldName: "given-name", autofill: TEST_ADDRESS_1["given-name"] }, + { fieldName: "family-name", autofill: TEST_ADDRESS_1["family-name"] }, + { fieldName: "country", autofill: "" }, + { fieldName: "tel", autofill: TEST_ADDRESS_1.tel.substring(2) }, + ], + }, + ], + }, +]); diff --git a/browser/extensions/formautofill/test/browser/head.js b/browser/extensions/formautofill/test/browser/head.js @@ -1217,7 +1217,10 @@ async function verifyPreviewResult(browser, section, expectedSection) { if (content.HTMLSelectElement.isInstance(element)) { if (obj.expected) { for (let idx = 0; idx < element.options.length; idx++) { - if (element.options[idx].value == obj.expected) { + if ( + element.options[idx].value == obj.expected && + element.previewValue == element.options[idx].text + ) { obj.expected = element.options[idx].text; break; }