tor-browser

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

commit 861d8beceecacf34502faf002337fd712e259fc5
parent 5da87acff0149c9bbede73455b9eece0366e2f3e
Author: Daisuke Akatsuka <daisuke@birchill.co.jp>
Date:   Thu, 11 Dec 2025 01:12:06 +0000

Bug 1995227: Remove "url" special handling r=adw

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

Diffstat:
Mbrowser/components/urlbar/UrlbarProviderPlaces.sys.mjs | 8++++++++
Mbrowser/components/urlbar/UrlbarResult.sys.mjs | 28++++------------------------
Mbrowser/components/urlbar/private/DynamicSuggestions.sys.mjs | 8++++++++
Mbrowser/components/urlbar/private/YelpSuggestions.sys.mjs | 2++
Mbrowser/components/urlbar/tests/browser/browser_results_format_displayValue.js | 6+++++-
Mbrowser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_yelp.js | 2++
Mbrowser/components/urlbar/tests/unit/test_autofill_origins.js | 2+-
Mbrowser/components/urlbar/tests/unit/test_autofill_prefix_fallback.js | 6++----
8 files changed, 32 insertions(+), 30 deletions(-)

diff --git a/browser/components/urlbar/UrlbarProviderPlaces.sys.mjs b/browser/components/urlbar/UrlbarProviderPlaces.sys.mjs @@ -408,6 +408,14 @@ function makeUrlbarResult(queryContext, info) { }); } + if (!title && info.url) { + try { + // If there's no title, show the domain as the title. Not all valid URLs + // have a domain. + title = new URL(info.url).URI.displayHostPort; + } catch (e) {} + } + return new lazy.UrlbarResult({ type: UrlbarUtils.RESULT_TYPE.URL, source, diff --git a/browser/components/urlbar/UrlbarResult.sys.mjs b/browser/components/urlbar/UrlbarResult.sys.mjs @@ -332,17 +332,6 @@ export class UrlbarResult { value = lazy.UrlbarUtils.prepareUrlForDisplay(value); } - let highlightable = value; - let highlightType; - if (isTitle && payloadName == "url") { - // If there's no title, show the domain as the title. Not all valid URLs - // have a domain. - try { - value = highlightable = new URL(this.payload.url).URI.displayHostPort; - highlightType = lazy.UrlbarUtils.HIGHLIGHT.TYPED; - } catch (e) {} - } - if (typeof value == "string") { value = value.substring(0, lazy.UrlbarUtils.MAX_TEXT_LENGTH); } @@ -351,7 +340,7 @@ export class UrlbarResult { return { value, highlights: this.#highlights[payloadName] }; } - highlightType ??= this.#highlights?.[payloadName]; + let highlightType = this.#highlights?.[payloadName]; if (!options.tokens?.length || !highlightType) { let cached = { value, options }; @@ -359,7 +348,7 @@ export class UrlbarResult { return cached; } - let highlights = Array.isArray(highlightable) + let highlights = Array.isArray(value) ? value.map(subval => lazy.UrlbarUtils.getTokenMatches( options.tokens, @@ -367,13 +356,7 @@ export class UrlbarResult { highlightType ) ) - : lazy.UrlbarUtils.getTokenMatches( - options.tokens, - highlightable - ? highlightable.substring(0, lazy.UrlbarUtils.MAX_TEXT_LENGTH) - : "", - highlightType - ); + : lazy.UrlbarUtils.getTokenMatches(options.tokens, value, highlightType); let cached = { value, highlights, options }; this.#displayValuesCache.set(payloadName, cached); @@ -390,10 +373,7 @@ export class UrlbarResult { if (this.payload.fallbackTitle) { return "fallbackTitle"; } - if (this.payload.title) { - return "title"; - } - return "url"; + return "title"; case lazy.UrlbarUtils.RESULT_TYPE.SEARCH: if (this.payload.title) { return "title"; diff --git a/browser/components/urlbar/private/DynamicSuggestions.sys.mjs b/browser/components/urlbar/private/DynamicSuggestions.sys.mjs @@ -106,6 +106,14 @@ export class DynamicSuggestions extends SuggestProvider { payload.isManageable = true; payload.helpUrl = lazy.QuickSuggest.HELP_URL; + if (!payload.title && payload.url) { + try { + // If there's no title, show the domain as the title. Not all valid URLs + // have a domain. + payload.title = new URL(payload.url).URI.displayHostPort; + } catch (e) {} + } + let resultProperties = { ...result }; delete resultProperties.payload; return new lazy.UrlbarResult({ diff --git a/browser/components/urlbar/private/YelpSuggestions.sys.mjs b/browser/components/urlbar/private/YelpSuggestions.sys.mjs @@ -222,6 +222,8 @@ export class YelpSuggestions extends SuggestProvider { service: titleHighlights, }, }; + // Used for the tooltip. + payload.title = title; } else { payload.title = title; highlights = { diff --git a/browser/components/urlbar/tests/browser/browser_results_format_displayValue.js b/browser/components/urlbar/tests/browser/browser_results_format_displayValue.js @@ -13,9 +13,13 @@ add_task(async function test_receive_punycode_result() { type: UrlbarUtils.RESULT_TYPE.URL, source: UrlbarUtils.RESULT_SOURCE.HISTORY, suggestedIndex: 0, - payload: { url }, + payload: { + url, + title: "www.اختبار.اختبار.org:5000", + }, highlights: { url: UrlbarUtils.HIGHLIGHT.TYPED, + title: UrlbarUtils.HIGHLIGHT.TYPED, }, }); addCallback(this, result); diff --git a/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_yelp.js b/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_yelp.js @@ -109,6 +109,7 @@ add_task(async function basic() { ], }, }, + title: "best a service delivery in Tokyo, Tokyo-to", }, }, { @@ -1121,6 +1122,7 @@ add_task(async function yelpServiceResultDistinction() { ], }, }, + title: "a service in Yokohama, Kanagawa", }), ], }); diff --git a/browser/components/urlbar/tests/unit/test_autofill_origins.js b/browser/components/urlbar/tests/unit/test_autofill_origins.js @@ -967,7 +967,7 @@ add_task(async function domainTitle() { }), makeVisitResult(context, { uri: "https://www.example.com/", - title: "", + title: "www.example.com", }), ], }, diff --git a/browser/components/urlbar/tests/unit/test_autofill_prefix_fallback.js b/browser/components/urlbar/tests/unit/test_autofill_prefix_fallback.js @@ -40,8 +40,7 @@ add_task(async function () { }), makeBookmarkResult(context, { uri: `https://${host}/`, - // This empty title is set in UrlbarProviderPlaces - title: "", + title: host, }), ], }); @@ -70,8 +69,7 @@ add_task(async function () { }), makeBookmarkResult(context, { uri: `https://www.${host}/`, - // This empty title is set in UrlbarProviderPlaces - title: "", + title: `www.${host}`, }), ], });