commit 30cf57717aec3d6a6a90001432910d2361a8fc01
parent 3aff40439915ff57dfafc492f12e28b085a9ae58
Author: Moritz Beier <mbeier@mozilla.com>
Date: Thu, 4 Dec 2025 09:25:45 +0000
Bug 2002799 - URL navigation is performed from new search bar widget. r=dao,urlbar-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D274926
Diffstat:
2 files changed, 41 insertions(+), 22 deletions(-)
diff --git a/browser/components/urlbar/UrlbarProviderHeuristicFallback.sys.mjs b/browser/components/urlbar/UrlbarProviderHeuristicFallback.sys.mjs
@@ -68,33 +68,35 @@ export class UrlbarProviderHeuristicFallback extends UrlbarProvider {
async startQuery(queryContext, addCallback) {
let instance = this.queryInstance;
- let result = this._matchUnknownUrl(queryContext);
- if (result) {
- addCallback(this, result);
- // Since we can't tell if this is a real URL and whether the user wants
- // to visit or search for it, we provide an alternative searchengine
- // match if the string looks like an alphanumeric origin or an e-mail.
- let str = queryContext.searchString;
- if (!URL.canParse(str)) {
- if (
- lazy.UrlbarPrefs.get("keyword.enabled") &&
- (lazy.UrlUtils.looksLikeOrigin(str, {
- noIp: true,
- noPort: true,
- }) ||
- lazy.UrlUtils.REGEXP_COMMON_EMAIL.test(str))
- ) {
- let searchResult = await this._engineSearchResult({ queryContext });
- if (instance != this.queryInstance) {
- return;
+ if (queryContext.sapName != "searchbar") {
+ let result = this._matchUnknownUrl(queryContext);
+ if (result) {
+ addCallback(this, result);
+ // Since we can't tell if this is a real URL and whether the user wants
+ // to visit or search for it, we provide an alternative searchengine
+ // match if the string looks like an alphanumeric origin or an e-mail.
+ let str = queryContext.searchString;
+ if (!URL.canParse(str)) {
+ if (
+ lazy.UrlbarPrefs.get("keyword.enabled") &&
+ (lazy.UrlUtils.looksLikeOrigin(str, {
+ noIp: true,
+ noPort: true,
+ }) ||
+ lazy.UrlUtils.REGEXP_COMMON_EMAIL.test(str))
+ ) {
+ let searchResult = await this._engineSearchResult({ queryContext });
+ if (instance != this.queryInstance) {
+ return;
+ }
+ addCallback(this, searchResult);
}
- addCallback(this, searchResult);
}
+ return;
}
- return;
}
- result = await this._searchModeKeywordResult(queryContext);
+ let result = await this._searchModeKeywordResult(queryContext);
if (instance != this.queryInstance) {
return;
}
diff --git a/browser/components/urlbar/tests/unit/test_providerHeuristicFallback.js b/browser/components/urlbar/tests/unit/test_providerHeuristicFallback.js
@@ -130,6 +130,23 @@ add_task(async function () {
],
});
+ info("visit url on searchbar (should search)");
+ query = "https://mozilla.org";
+ context = createContext(query, {
+ isPrivate: false,
+ sapName: "searchbar",
+ });
+ await check_results({
+ context,
+ matches: [
+ makeSearchResult(context, {
+ engineName: SUGGESTIONS_ENGINE_NAME,
+ heuristic: true,
+ query,
+ }),
+ ],
+ });
+
info("visit url, about: protocol (no host)");
query = "about:nonexistent";
context = createContext(query, { isPrivate: false });