commit 3d2a502ca24e0f38d99cbd6a769310d13c71d7e7
parent 91e36bc96dab6fce7d981d8bb9b885430c96e078
Author: Atila Butkovits <abutkovits@mozilla.com>
Date: Mon, 3 Nov 2025 23:27:54 +0200
Revert "Bug 1990522 - Restrict tokens should not be available in the search bar re-implementation. r=mbeier" for causing multiple mochitest failures.
This reverts commit 8168b31afd40ea603285421d51fa4383f43c8422.
Diffstat:
3 files changed, 22 insertions(+), 25 deletions(-)
diff --git a/browser/components/urlbar/UrlbarInput.sys.mjs b/browser/components/urlbar/UrlbarInput.sys.mjs
@@ -1990,9 +1990,9 @@ export class UrlbarInput {
};
}
- let mode =
- this.isAddressbar &&
- lazy.UrlbarUtils.LOCAL_SEARCH_MODES.find(m => m.restrict == token);
+ let mode = lazy.UrlbarUtils.LOCAL_SEARCH_MODES.find(
+ m => m.restrict == token
+ );
if (mode) {
// Return a copy so callers don't modify the object in LOCAL_SEARCH_MODES.
return { ...mode };
diff --git a/browser/components/urlbar/UrlbarProviderHeuristicFallback.sys.mjs b/browser/components/urlbar/UrlbarProviderHeuristicFallback.sys.mjs
@@ -231,10 +231,7 @@ export class UrlbarProviderHeuristicFallback extends UrlbarProvider {
}
async _searchModeKeywordResult(queryContext) {
- if (
- !queryContext.tokens.length ||
- !this.queryInstance.controller.input.isAddressbar
- ) {
+ if (!queryContext.tokens.length) {
return null;
}
diff --git a/browser/components/urlbar/UrlbarProvidersManager.sys.mjs b/browser/components/urlbar/UrlbarProvidersManager.sys.mjs
@@ -437,7 +437,7 @@ export class ProvidersManager {
// can be used for searching. Otherwise sources are extracted from prefs and
// restriction tokens, then restriction tokens must be filtered out of the
// search string.
- let restrictToken = updateSourcesIfEmpty(queryContext, controller);
+ let restrictToken = updateSourcesIfEmpty(queryContext);
if (restrictToken) {
queryContext.restrictToken = restrictToken;
// If the restriction token has an equivalent source, then set it as
@@ -983,31 +983,27 @@ export class Query {
* Updates in place the sources for a given UrlbarQueryContext.
*
* @param {UrlbarQueryContext} context The query context to examine
- * @param {?UrlbarController} [controller] A UrlbarController instance
* @returns {UrlbarSearchStringTokenData|undefined} The restriction token that
* was used to set sources, or undefined if there's no restriction token.
*/
-function updateSourcesIfEmpty(context, controller) {
+function updateSourcesIfEmpty(context) {
if (context.sources && context.sources.length) {
return undefined;
}
let acceptedSources = [];
// There can be only one restrict token per query.
- let restrictToken =
- controller && !controller.input.isAddressbar
- ? undefined
- : context.tokens.find(t =>
- [
- lazy.UrlbarTokenizer.TYPE.RESTRICT_HISTORY,
- lazy.UrlbarTokenizer.TYPE.RESTRICT_BOOKMARK,
- lazy.UrlbarTokenizer.TYPE.RESTRICT_TAG,
- lazy.UrlbarTokenizer.TYPE.RESTRICT_OPENPAGE,
- lazy.UrlbarTokenizer.TYPE.RESTRICT_SEARCH,
- lazy.UrlbarTokenizer.TYPE.RESTRICT_TITLE,
- lazy.UrlbarTokenizer.TYPE.RESTRICT_URL,
- lazy.UrlbarTokenizer.TYPE.RESTRICT_ACTION,
- ].includes(t.type)
- );
+ let restrictToken = context.tokens.find(t =>
+ [
+ lazy.UrlbarTokenizer.TYPE.RESTRICT_HISTORY,
+ lazy.UrlbarTokenizer.TYPE.RESTRICT_BOOKMARK,
+ lazy.UrlbarTokenizer.TYPE.RESTRICT_TAG,
+ lazy.UrlbarTokenizer.TYPE.RESTRICT_OPENPAGE,
+ lazy.UrlbarTokenizer.TYPE.RESTRICT_SEARCH,
+ lazy.UrlbarTokenizer.TYPE.RESTRICT_TITLE,
+ lazy.UrlbarTokenizer.TYPE.RESTRICT_URL,
+ lazy.UrlbarTokenizer.TYPE.RESTRICT_ACTION,
+ ].includes(t.type)
+ );
// RESTRICT_TITLE and RESTRICT_URL do not affect query sources.
let restrictTokenType =
@@ -1018,6 +1014,10 @@ function updateSourcesIfEmpty(context, controller) {
: undefined;
for (let source of Object.values(lazy.UrlbarUtils.RESULT_SOURCE)) {
+ // Skip sources that the context doesn't care about.
+ if (context.sources && !context.sources.includes(source)) {
+ continue;
+ }
// Check prefs and restriction tokens.
switch (source) {
case lazy.UrlbarUtils.RESULT_SOURCE.BOOKMARKS: