From 8beac03ab01bd7182b2ff3126052e5af174b9073 Mon Sep 17 00:00:00 2001 From: Daisuke Akatsuka Date: Wed, 7 Feb 2024 08:52:06 +0000 Subject: [PATCH] Bug 1877920: Add a Nimbus variable to show Yelp suggestions as a top pick r=adw Differential Revision: https://phabricator.services.mozilla.com/D200896 --- .../urlbar/private/YelpSuggestions.sys.mjs | 5 +-- .../quicksuggest/unit/test_quicksuggest_yelp.js | 45 +++++++++++++++++++++- toolkit/components/nimbus/FeatureManifest.yaml | 8 ++++ 3 files changed, 53 insertions(+), 5 deletions(-) diff --git a/browser/components/urlbar/private/YelpSuggestions.sys.mjs b/browser/components/urlbar/private/YelpSuggestions.sys.mjs index e9cbdc7612e8..4bb671f4139b 100644 --- a/browser/components/urlbar/private/YelpSuggestions.sys.mjs +++ b/browser/components/urlbar/private/YelpSuggestions.sys.mjs @@ -37,6 +37,8 @@ export class YelpSuggestions extends BaseFeature { } makeResult(queryContext, suggestion, searchString) { + suggestion.is_top_pick = lazy.UrlbarPrefs.get("yelpSuggestPriority"); + return Object.assign( new lazy.UrlbarResult( lazy.UrlbarUtils.RESULT_TYPE.URL, @@ -50,9 +52,6 @@ export class YelpSuggestions extends BaseFeature { }) ), { - isBestMatch: true, - suggestedIndex: 1, - isRichSuggestion: true, richSuggestionIconSize: 24, } ); diff --git a/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_yelp.js b/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_yelp.js index 7fe011a4b4c4..a915c9e0361b 100644 --- a/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_yelp.js +++ b/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_yelp.js @@ -146,7 +146,7 @@ add_task(async function yelpSpecificPrefsDisabled() { // Check wheather the Yelp suggestions will be shown by the setup of Nimbus // variable. -add_task(async function nimbus() { +add_task(async function featureGate() { // Disable the fature gate. UrlbarPrefs.set("yelp.featureGate", false); await check_results({ @@ -198,6 +198,47 @@ add_task(async function nimbus() { await QuickSuggestTestUtils.forceSync(); }); +// Check wheather the Yelp suggestions will be shown as top_pick by the Nimbus +// variable. +add_task(async function yelpSuggestPriority() { + // Enable by Nimbus. + const cleanUpNimbusEnable = await UrlbarTestUtils.initNimbusFeature({ + yelpSuggestPriority: true, + }); + await QuickSuggestTestUtils.forceSync(); + + await check_results({ + context: createContext("ramen", { + providers: [UrlbarProviderQuickSuggest.name], + isPrivate: false, + }), + matches: [ + makeExpectedResult({ + url: "https://www.yelp.com/search?find_desc=ramen", + title: "ramen", + isTopPick: true, + }), + ], + }); + + await cleanUpNimbusEnable(); + await QuickSuggestTestUtils.forceSync(); + + await check_results({ + context: createContext("ramen", { + providers: [UrlbarProviderQuickSuggest.name], + isPrivate: false, + }), + matches: [ + makeExpectedResult({ + url: "https://www.yelp.com/search?find_desc=ramen", + title: "ramen", + isTopPick: false, + }), + ], + }); +}); + // The `Yelp` Rust provider should be passed to the Rust component when // querying depending on whether Yelp suggestions are enabled. add_task(async function rustProviders() { @@ -227,7 +268,7 @@ function makeExpectedResult(expected) { return { type: UrlbarUtils.RESULT_TYPE.URL, source: UrlbarUtils.RESULT_SOURCE.SEARCH, - isBestMatch: true, + isBestMatch: expected.isTopPick ?? false, heuristic: false, payload: { source: "rust", diff --git a/toolkit/components/nimbus/FeatureManifest.yaml b/toolkit/components/nimbus/FeatureManifest.yaml index 096cc32180f2..49152c686d13 100644 --- a/toolkit/components/nimbus/FeatureManifest.yaml +++ b/toolkit/components/nimbus/FeatureManifest.yaml @@ -427,6 +427,14 @@ urlbar: description: >- Feature gate that controls whether all aspects of the Yelp suggestion feature are exposed to the user. + yelpSuggestPriority: + type: boolean + fallbackPref: browser.urlbar.quicksuggest.yelpPriority + description: >- + Whether or not showing yelp suggestion as priority. + If this variable is true, the following things are processed. + * Change the suggested index to 1. + * Handle as top pick. originsAlternativeEnable: description: >- Use an alternative ranking algorithm for autofilling origins, that is -- 2.11.4.GIT