tor-browser

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

commit a5c1f98f8b483592e6e1f8b4e86202adba0da1b2
parent b656ac6c1251ce1d28760cb9eca3b8ebc11b8f0e
Author: Mark Banner <standard8@mozilla.com>
Date:   Fri, 31 Oct 2025 14:52:06 +0000

Bug 1996615 - Fix TypeScript issues for UrlbarSearchOneOffs.sys.mjs. r=urlbar-reviewers,search-reviewers,scunnane,jteow

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

Diffstat:
Mbrowser/components/search/SearchOneOffs.sys.mjs | 7+++++++
Mbrowser/components/urlbar/UrlbarSearchOneOffs.sys.mjs | 14+++++++-------
Mbrowser/components/urlbar/UrlbarUtils.sys.mjs | 7++++---
Mbrowser/components/urlbar/tsconfig.json | 1-
4 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/browser/components/search/SearchOneOffs.sys.mjs b/browser/components/search/SearchOneOffs.sys.mjs @@ -12,9 +12,16 @@ ChromeUtils.defineESModuleGetters(lazy, { }); /** + * @import {UrlbarUtils} from "moz-src:///browser/components/urlbar/UrlbarUtils.sys.mjs" + */ + +/** * @typedef {object} LegacySearchButton * @property {boolean} open * Whether the button is in an open state. + * @property {Values<typeof UrlbarUtils.RESULT_SOURCE>} [source] + * The result source of the button. Only appropriate for one-off buttons + * on the urlbar. * @property {nsISearchEngine} engine * The search engine associated with the button. */ diff --git a/browser/components/urlbar/UrlbarSearchOneOffs.sys.mjs b/browser/components/urlbar/UrlbarSearchOneOffs.sys.mjs @@ -3,16 +3,16 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import { SearchOneOffs } from "moz-src:///browser/components/search/SearchOneOffs.sys.mjs"; +import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs"; -const lazy = {}; - -ChromeUtils.defineESModuleGetters(lazy, { +const lazy = XPCOMUtils.declareLazy({ UrlbarPrefs: "moz-src:///browser/components/urlbar/UrlbarPrefs.sys.mjs", UrlbarUtils: "moz-src:///browser/components/urlbar/UrlbarUtils.sys.mjs", }); /** * @import {LegacySearchOneOffButton} from "moz-src:///browser/components/search/SearchOneOffs.sys.mjs" + * @import {UrlbarView} from "moz-src:///browser/components/urlbar/UrlbarView.sys.mjs" */ /** @@ -169,7 +169,7 @@ export class UrlbarSearchOneOffs extends SearchOneOffs { /** * Called when a one-off is clicked. * - * @param {event} event + * @param {MouseEvent|KeyboardEvent} event * The event that triggered the pick. * @param {object} searchMode * Used by UrlbarInput.setSearchMode to enter search mode. See setSearchMode @@ -286,7 +286,7 @@ export class UrlbarSearchOneOffs extends SearchOneOffs { * Overrides the willHide method in the superclass to account for the local * search mode buttons. * - * @returns {boolean} + * @returns {Promise<boolean>} * True if we will hide the one-offs when they are requested. */ async willHide() { @@ -361,7 +361,7 @@ export class UrlbarSearchOneOffs extends SearchOneOffs { * Overrides the superclass's click listener to handle clicks on local * one-offs in addition to engine one-offs. * - * @param {event} event + * @param {MouseEvent} event * The click event. */ _on_click(event) { @@ -370,7 +370,7 @@ export class UrlbarSearchOneOffs extends SearchOneOffs { return; } - let button = event.originalTarget; + let button = /** @type {LegacySearchOneOffButton} */ (event.originalTarget); if (!button.engine && !button.source) { return; diff --git a/browser/components/urlbar/UrlbarUtils.sys.mjs b/browser/components/urlbar/UrlbarUtils.sys.mjs @@ -1115,9 +1115,10 @@ export var UrlbarUtils = { * Returns the name of a result source. The name is the lowercase name of the * corresponding property in the RESULT_SOURCE object. * - * @param {keyof typeof this.RESULT_SOURCE} source A UrlbarUtils.RESULT_SOURCE value. - * @returns {string} The token's name, a lowercased name in the RESULT_SOURCE - * object. + * @param {Values<typeof this.RESULT_SOURCE>} source + * A UrlbarUtils.RESULT_SOURCE value. + * @returns {string} + * The token's name, a lowercased name in the RESULT_SOURCE object. */ getResultSourceName(source) { if (!this._resultSourceNamesBySource) { diff --git a/browser/components/urlbar/tsconfig.json b/browser/components/urlbar/tsconfig.json @@ -5,7 +5,6 @@ "UrlbarProviderGlobalActions.sys.mjs", "UrlbarProviderPlaces.sys.mjs", "UrlbarProvidersManager.sys.mjs", - "UrlbarSearchOneOffs.sys.mjs", "UrlbarView.sys.mjs", "private/MLSuggest.sys.mjs", "private/SuggestBackendRust.sys.mjs",