Bug 1800630 - Don't show top pick result if heuristic url matches. r=adw
Differential Revision: https://phabricator.services.mozilla.com/D162100
This commit is contained in:
@@ -639,9 +639,26 @@ class MuxerUnifiedComplete extends UrlbarMuxer {
|
||||
// error or increase the complexity threshold.
|
||||
// eslint-disable-next-line complexity
|
||||
_canAddResult(result, state) {
|
||||
// Never discard quick suggest results. We may want to change this logic at
|
||||
// some point, but for all current use cases, they should always be shown.
|
||||
// QuickSuggest results are shown unless they are best matches
|
||||
// that duplicate heuristic results.
|
||||
if (result.providerName == lazy.UrlbarProviderQuickSuggest.name) {
|
||||
let heuristicUrl = state.context.heuristicResult?.payload.url;
|
||||
if (
|
||||
heuristicUrl &&
|
||||
!lazy.UrlbarPrefs.get("experimental.hideHeuristic") &&
|
||||
result.isBestMatch
|
||||
) {
|
||||
let opts = {
|
||||
stripHttp: true,
|
||||
stripHttps: true,
|
||||
stripWww: true,
|
||||
trimSlash: true,
|
||||
};
|
||||
return (
|
||||
UrlbarUtils.stripPrefixAndTrim(heuristicUrl, opts)[0] !=
|
||||
UrlbarUtils.stripPrefixAndTrim(result.payload.url, opts)[0]
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ ChromeUtils.defineESModuleGetters(this, {
|
||||
RemoteSettingsClient:
|
||||
"resource:///modules/urlbar/private/RemoteSettingsClient.sys.mjs",
|
||||
QuickSuggest: "resource:///modules/QuickSuggest.sys.mjs",
|
||||
UrlbarProviderAutofill: "resource:///modules/UrlbarProviderAutofill.sys.mjs",
|
||||
UrlbarProviderQuickSuggest:
|
||||
"resource:///modules/UrlbarProviderQuickSuggest.sys.mjs",
|
||||
});
|
||||
|
||||
@@ -29,6 +29,7 @@ const SUGGESTIONS = [
|
||||
"fullkeywo",
|
||||
"fullkeywor",
|
||||
"fullkeyword",
|
||||
"example",
|
||||
],
|
||||
click_url: "http://example.com/click",
|
||||
impression_url: "http://example.com/impression",
|
||||
@@ -408,3 +409,33 @@ add_task(async function noConfig() {
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
// Test that bestMatch results are not shown when there is a heuristic
|
||||
// result for the same domain.
|
||||
add_task(async function hueristicDeduplication() {
|
||||
let scenarios = [
|
||||
["http://example.com/", false],
|
||||
["http://www.example.com/", false],
|
||||
["http://exampledomain.com/", true],
|
||||
];
|
||||
|
||||
for (let [url, expectBestMatch] of scenarios) {
|
||||
await PlacesTestUtils.addVisits(url);
|
||||
let context = createContext("example", {
|
||||
providers: [UrlbarProviderQuickSuggest.name, UrlbarProviderAutofill.name],
|
||||
isPrivate: false,
|
||||
});
|
||||
const EXPECTED_AUTOFILL_RESULT = makeVisitResult(context, {
|
||||
uri: url,
|
||||
title: `test visit for ${url}`,
|
||||
heuristic: true,
|
||||
});
|
||||
await check_results({
|
||||
context,
|
||||
matches: expectBestMatch
|
||||
? [EXPECTED_AUTOFILL_RESULT, EXPECTED_BEST_MATCH_RESULT]
|
||||
: [EXPECTED_AUTOFILL_RESULT],
|
||||
});
|
||||
await PlacesUtils.history.clear();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user