Commit bc395414 authored by Marco Bonardo's avatar Marco Bonardo
Browse files

Bug 1672509 - Simple keyword searches are treated as potential domain visits. r=harry a=pascal

Differential Revision: https://phabricator.services.mozilla.com/D96604
parent 51a155f6
...@@ -791,6 +791,7 @@ class UrlbarInput { ...@@ -791,6 +791,7 @@ class UrlbarInput {
} }
if ( if (
!this.searchMode &&
result.heuristic && result.heuristic &&
// If we asked the DNS earlier, avoid the post-facto check. // If we asked the DNS earlier, avoid the post-facto check.
!UrlbarPrefs.get("browser.fixup.dns_first_for_single_words") && !UrlbarPrefs.get("browser.fixup.dns_first_for_single_words") &&
......
...@@ -42,6 +42,7 @@ function promiseNotification(aBrowser, value, expected, input) { ...@@ -42,6 +42,7 @@ function promiseNotification(aBrowser, value, expected, input) {
async function runURLBarSearchTest({ async function runURLBarSearchTest({
valueToOpen, valueToOpen,
enterSearchMode,
expectSearch, expectSearch,
expectNotification, expectNotification,
expectDNSResolve, expectDNSResolve,
...@@ -53,6 +54,10 @@ async function runURLBarSearchTest({ ...@@ -53,6 +54,10 @@ async function runURLBarSearchTest({
const setValueFns = [ const setValueFns = [
value => { value => {
aWindow.gURLBar.value = value; aWindow.gURLBar.value = value;
if (enterSearchMode) {
// Ensure to open the panel.
UrlbarTestUtils.fireInputEvent(aWindow);
}
}, },
value => { value => {
return UrlbarTestUtils.promiseAutocompleteResultPopup({ return UrlbarTestUtils.promiseAutocompleteResultPopup({
...@@ -64,6 +69,13 @@ async function runURLBarSearchTest({ ...@@ -64,6 +69,13 @@ async function runURLBarSearchTest({
for (let i = 0; i < setValueFns.length; ++i) { for (let i = 0; i < setValueFns.length; ++i) {
await setValueFns[i](valueToOpen); await setValueFns[i](valueToOpen);
if (enterSearchMode) {
if (!expectSearch) {
throw new Error("Must execute a search in search mode");
}
await UrlbarTestUtils.enterSearchMode(aWindow);
}
let expectedURI; let expectedURI;
if (!expectSearch) { if (!expectSearch) {
expectedURI = "http://" + valueToOpen + "/"; expectedURI = "http://" + valueToOpen + "/";
...@@ -81,15 +93,15 @@ async function runURLBarSearchTest({ ...@@ -81,15 +93,15 @@ async function runURLBarSearchTest({
); );
EventUtils.synthesizeKey("VK_RETURN", {}, aWindow); EventUtils.synthesizeKey("VK_RETURN", {}, aWindow);
await Promise.all([ if (!enterSearchMode) {
docLoadPromise, await promiseNotification(
promiseNotification(
aWindow.gBrowser, aWindow.gBrowser,
"keyword-uri-fixup", "keyword-uri-fixup",
expectNotification, expectNotification,
valueToOpen valueToOpen
), );
]); }
await docLoadPromise;
if (expectNotification) { if (expectNotification) {
let notificationBox = aWindow.gBrowser.getNotificationBox( let notificationBox = aWindow.gBrowser.getNotificationBox(
...@@ -322,3 +334,23 @@ add_task(async function test_navigate_invalid_url() { ...@@ -322,3 +334,23 @@ add_task(async function test_navigate_invalid_url() {
}); });
gBrowser.removeTab(tab); gBrowser.removeTab(tab);
}); });
add_task(async function test_search_mode() {
info("When in search mode we should never query the DNS");
await SpecialPowers.pushPrefEnv({
set: [["browser.search.suggest.enabled", false]],
});
let tab = (gBrowser.selectedTab = BrowserTestUtils.addTab(
gBrowser,
"about:blank"
));
await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
await runURLBarSearchTest({
enterSearchMode: true,
valueToOpen: "mozilla",
expectSearch: true,
expectNotification: false,
expectDNSResolve: false,
});
gBrowser.removeTab(tab);
});
Supports Markdown
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