Bug 1588037 - Don't show 'Search in a private window' if an alias was typed. r=Standard8

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Marco Bonardo 2019-10-16 22:07:43 +00:00
Родитель e24c974e7d
Коммит 3db57b200e
2 изменённых файлов: 32 добавлений и 2 удалений

Просмотреть файл

@ -53,7 +53,8 @@ class MuxerUnifiedComplete extends UrlbarMuxer {
*/
sort(context) {
// A Search in a Private Window result should only be shown when there are
// other results, and all of them are searches.
// other results, and all of them are searches. It should also not be shown
// if the user typed an alias, because it's an explicit search engine choice.
let searchInPrivateWindowIndex = context.results.findIndex(
r => r.type == UrlbarUtils.RESULT_TYPE.SEARCH && r.payload.inPrivateWindow
);
@ -62,7 +63,9 @@ class MuxerUnifiedComplete extends UrlbarMuxer {
(context.results.length == 1 ||
context.results.some(
r =>
r.type != UrlbarUtils.RESULT_TYPE.SEARCH || r.payload.keywordOffer
r.type != UrlbarUtils.RESULT_TYPE.SEARCH ||
r.payload.keywordOffer ||
(r.heuristic && r.payload.keyword)
))
) {
// Remove the result.

Просмотреть файл

@ -45,9 +45,17 @@ add_task(async function setup() {
);
await Services.search.moveEngine(engine2, 0);
// Add an engine with an alias.
let aliasEngine = await Services.search.addEngineWithDetails("MozSearch", {
alias: "alias",
method: "GET",
template: "http://example.com/?q={searchTerms}",
});
registerCleanupFunction(async () => {
await Services.search.setDefault(oldDefaultEngine);
await Services.search.setDefaultPrivate(oldDefaultPrivateEngine);
await Services.search.removeEngine(aliasEngine);
await PlacesUtils.history.clear();
});
});
@ -347,3 +355,22 @@ add_task(async function test_oneoff_selected_with_private_engine_keyboard() {
await BrowserTestUtils.closeWindow(win);
});
});
add_task(async function test_alias() {
info(
"Test that 'Search in a Private Window' doesn's appear if an alias is typed"
);
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
waitForFocus,
value: "alias",
});
await AssertNoPrivateResult(window);
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
waitForFocus,
value: "alias something",
});
await AssertNoPrivateResult(window);
});