Commit 51a155f6 authored by Harry Twyford's avatar Harry Twyford
Browse files

Bug 1676398 - browser.urlbar.update2.emptySearchBehavior should only affect...

Bug 1676398 - browser.urlbar.update2.emptySearchBehavior should only affect search engines in search mode. r=mak a=pascal

Differential Revision: https://phabricator.services.mozilla.com/D96616
parent be35407a
......@@ -66,6 +66,7 @@ class ProviderUnifiedComplete extends UrlbarProvider {
if (
!queryContext.trimmedSearchString &&
UrlbarPrefs.get("update2") &&
queryContext.searchMode?.engineName &&
UrlbarPrefs.get("update2.emptySearchBehavior") < 2
) {
return false;
......
......@@ -287,6 +287,29 @@ add_task(async function emptySearch_behavior() {
// the picked engine, history without redirects, and no heuristic.
await checkResults([]);
await UrlbarTestUtils.exitSearchMode(window, { clickClose: true });
// We should still show history for empty searches when not in search mode.
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: " ",
});
await checkResults([
{
heuristic: true,
type: UrlbarUtils.RESULT_TYPE.SEARCH,
source: UrlbarUtils.RESULT_SOURCE.SEARCH,
searchParams: {
query: " ",
engine: defaultEngine.name,
},
},
{
heuristic: false,
type: UrlbarUtils.RESULT_TYPE.URL,
source: UrlbarUtils.RESULT_SOURCE.HISTORY,
url: `http://mochi.test/`,
},
]);
await UrlbarTestUtils.promisePopupClose(window);
await SpecialPowers.popPrefEnv();
});
......@@ -312,6 +335,39 @@ add_task(async function emptySearch_behavior() {
await PlacesUtils.history.clear();
});
add_task(async function emptySearch_local() {
await PlacesTestUtils.addVisits([`http://mochi.test/`]);
await BrowserTestUtils.withNewTab("about:robots", async function(browser) {
await SpecialPowers.pushPrefEnv({
set: [["browser.urlbar.update2.emptySearchBehavior", 0]],
});
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: "",
});
await UrlbarTestUtils.enterSearchMode(window, {
source: UrlbarUtils.RESULT_SOURCE.HISTORY,
});
Assert.equal(gURLBar.value, "", "Urlbar value should be cleared.");
// Even when emptySearchBehavior is 0, we still show the user's most frecent
// history for an empty search.
await checkResults([
{
heuristic: false,
type: UrlbarUtils.RESULT_TYPE.URL,
source: UrlbarUtils.RESULT_SOURCE.HISTORY,
url: `http://mochi.test/`,
},
]);
await UrlbarTestUtils.exitSearchMode(window, { clickClose: true });
await UrlbarTestUtils.promisePopupClose(window);
await SpecialPowers.popPrefEnv();
});
await PlacesUtils.history.clear();
});
add_task(async function nonEmptySearch() {
await BrowserTestUtils.withNewTab("about:robots", async function(browser) {
let query = "hello";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment