Bug 1878441 - Update the weather suggestions implementation to account for Rust. r=daisuke

This patch requires https://github.com/mozilla/application-services/pull/6089,
which hasn't been vendored yet, so it will be hard to test unless you locally
vendor. I've done that and verified that weather tests still pass.

Weather suggestions in Rust work like this: Rust stores the weather keywords in
the `keywords` table, and when the query matches a keyword, it returns a dummy
`Weather` suggestion that only contains a score. That means weather suggestions
are handled nearly like every other type of suggestion, except when Firefox
receives a weather suggestion from Rust, it must replace it with the actual
suggestion from Merino.

We also need to continue to support weather keywords defined in Nimbus. For
that, this patch continues to use `UrlbarProviderWeather` because I don't want
to add a special case to `UrlbarProviderQuickSuggest` just for this one type of
suggestion. When we stop experimenting with weather, we can remove that
provider.

I moved all the common code from `UrlbarProviderWeather` to `Weather` so both
providers can use it.

Some of the tests check `minKeywordLength` and can't use Rust yet. I'll handle
that in bug 1878444.

Depends on D200105

Differential Revision: https://phabricator.services.mozilla.com/D200755
This commit is contained in:
Drew Willcoxon
2024-02-08 01:47:05 +00:00
parent 01644bf683
commit a2cb610df6
9 changed files with 602 additions and 441 deletions

View File

@@ -1562,6 +1562,11 @@ export var UrlbarUtils = {
},
_getQuickSuggestTelemetryType(result) {
if (result.payload.telemetryType == "weather") {
// Return "weather" without the usual source prefix for consistency with
// the weather result returned by UrlbarProviderWeather.
return "weather";
}
let source = result.payload.source;
if (source == "remote-settings") {
source = "rs";