Commit Graph

89 Commits

Author SHA1 Message Date
Barret Rennie
871e74ca58 Bug 1829412 - Simplify NimbusTestUtils.enrollmentHelper r=chumphreys,settings-reviewers,pip-reviewers,credential-management-reviewers,search-reviewers,anti-tracking-reviewers,omc-reviewers,home-newtab-reviewers,thecount,issammani,aminomancer,mconley
The enrollmentHelper was much more complicated than it needed to be. The
internal asynchrony that required awaiting an additional promise was fixed in
bug 1773583.

The returned cleanup function is no longer async, so unnecessary awaits have
been removed. This also applies to enrollWithFeatureConfig, as it is a wrapper
around enrollmentHelper.

Differential Revision: https://phabricator.services.mozilla.com/D212318
2024-06-06 14:42:00 +00:00
Daisuke Akatsuka
c6bfe80f01 Bug 1889820: Add isManageable attribute to show 'Manage' result menu item in a suggestion r=adw
Differential Revision: https://phabricator.services.mozilla.com/D206862
2024-04-09 07:41:52 +00:00
Drew Willcoxon
303ec3a34c Bug 1881073 - Update Yelp suggestions "Show less frequently" behavior. r=daisuke
The problem is that `show_less_frequently` is misspelled. That doesn't cause the
first "Show less frequently" click to fail, but it does cause later clicks to
fail as long as the urlbar session remains ongoing (i.e., the view remains
open). That's because `TelemetryEvent` has [a hardcoded check](https://searchfox.org/mozilla-central/rev/d405168c4d3c0fb900a7354ae17bb34e939af996/browser/components/urlbar/UrlbarController.sys.mjs#962) for
`show_less_frequently` when it determines whether the session is still ongoing.
This check fails due to the misspelling, so `TelemetryEvent` thinks the session
has ended, which messes up later events and commands.

This makes a few related improvements:

* Support the `showLessFrequentlyCap` in the remote settings config for Yelp
* Add a "Show less frequently" task to the Yelp test. This uses the existing
  `doShowLessFrequentlyTests()` helper, which requires the related getters
  and methods to be public.

Differential Revision: https://phabricator.services.mozilla.com/D202356
2024-02-22 05:44:32 +00:00
Drew Willcoxon
ed36ae547a Bug 1880144 - Enable Rust Suggest by default. r=daisuke
This turned out to be a huge pain.

Many tests didn't work with the Rust backend. Generally I tried to keep tests
and tasks that truly need the JS backend, and I skip them when Rust is enabled.
I also added checks for `quickSuggestRustEnabled` so that tests don't assume the
Rust backend is enabled. I don't want to remove anything related to the JS
backend until the Rust backend is shipped in Release and we're confident we
don't need the JS backend anymore.

Also, browser tests didn't work properly because by the time
`QuickSuggestTestUtils.ensureQuickSuggestInit()` runs, the Rust backend has
already initialized, and `_test_remoteSettingsConfig` is not defined. To fix
that, I added a new `_test_setRemoteSettingsConfig()` function that recreates
the store with the new RS test config.

I also added some new helpers for generating remote settings data and for making
expected results in xpcshell tests.

Differential Revision: https://phabricator.services.mozilla.com/D201800
2024-02-14 20:36:08 +00:00
Mark Hammond
0ec2fd36f8 Bug 1875848 - UniFFI generated record constructors now take a POJO. r=lina,bdk,adw
Differential Revision: https://phabricator.services.mozilla.com/D200075
2024-02-08 17:34:58 +00:00
Natalia Csoregi
882dcd96ab Backed out changeset ef78defe4be2 (bug 1875848) for causing quicksuggest failures. CLOSED TREE 2024-02-08 03:45:03 +02:00
Mark Hammond
a45645fcbf Bug 1875848 - UniFFI generated record constructors now take a POJO. r=lina,bdk,adw
Differential Revision: https://phabricator.services.mozilla.com/D200075
2024-02-07 23:16:26 +00:00
Drew Willcoxon
a4f3e9fe53 Bug 1878987 - Part 3: Update RemoteSettingsConfig argument order. r=lina
This bitrots D200075 but since we want to ship Rust Suggest in desktop in 124,
I'd like to vendor ASAP so we can start landing desktop patches, and we need to
fix this argument order to do that.

Depends on D200892

Differential Revision: https://phabricator.services.mozilla.com/D200893
2024-02-07 20:07:25 +00:00
Marco Bonardo
5009f208ea Bug 1877976 - Merge the Nimbus frecency feature in the urlbar one. r=adw
Differential Revision: https://phabricator.services.mozilla.com/D200319
2024-02-06 09:21:14 +00:00
Chris H-C
460ebb882a Bug 1868580 - Remove PingCentre from Contextual Services r=nanj,perry.mcmanis
As of 11amPT December 7, Contextual Services is now looking exclusively at
Glean-sent data for Firefox versions 116+. (See DSRE-1489)

Differential Revision: https://phabricator.services.mozilla.com/D195910
2023-12-11 19:21:37 +00:00
Drew Willcoxon
ab05a8bad7 Bug 1861540 - Part 2: Update tests to use the local remote settings server. r=daisuke
This modifies tests to use the server. There are a few important points to call
out:

This means tests are now using the real Rust component, and we need to make sure
the test RS data is valid and matches what Rust expects. For example, I had to
add `icon` properties to suggestions and set the `advertiser` to "Wikipedia" for
non-sponsored suggestions. Otherwise Rust hits an error on ingest. I also
removed some test cases because they tested behaviors that are impossible with
Rust, for example Pocket keywords that are duplicated in the high- and
low-confidence arrays.

We need to be careful to wait until Suggest is done syncing from remote settings
regardless of whether it's using the JS or Rust backend. I added a way to force
the backends to sync. That way, tests can force a sync, wait for it to finish,
and be sure that all sync activity is done.

A common pattern in tests is to call `ensureQuickSuggestInit()` and then set
Suggest-related prefs (or vice versa). This is a little problematic because both
`ensureQuickSuggestInit()` and setting prefs can cause Suggest to start a sync.
It's more problematic now that we're not mocking remote settings or Rust. So I
combined the two by adding a `prefs` param to `ensureQuickSuggestInit()`. That
way, tests can be sure that all syncing is done once that function returns.

Depends on D192037, D192124

Differential Revision: https://phabricator.services.mozilla.com/D192038
2023-10-30 23:33:12 +00:00
Drew Willcoxon
f8ae0421dd Bug 1859389 - Modify desktop Suggest integration so it properly handles timestamp templates. r=daisuke
This makes sure `result.payload.originalUrl` is set correctly depending on Rust
vs. JS, and AMP vs. Wikipedia. The logic is getting a little messy due to all
the various combinations, but there's no way around it until we drop the JS
backend.

I tried setting `raw_url` (or `rawUrl`) on JS suggestions to match Rust
suggestions, and while that made the `AdmWikipedia` logic slightly nicer, it
either made the `UrlbarProviderQuickSuggest._canAddSuggestion()` logic a little
uglier because we need to also check `raw_url` for JS suggestions (snake_case),
or instead we could set `rawUrl` (camelCase) on JS suggestions just like Rust
suggestions, but every other property on JS suggestions uses snake_case.

This is *not* based on bug 1861540 because we need to uplift this, but I don't
want to uplift bug 1861540.

Differential Revision: https://phabricator.services.mozilla.com/D192124
2023-10-30 22:04:56 +00:00
Cristian Tuns
9f3bb56869 Backed out 2 changesets (bug 1861540) for causing xpc shell failures in test_quicksuggest_addons.js CLOSED TREE
Backed out changeset 2a0da4c5f326 (bug 1861540)
Backed out changeset b67e855993cb (bug 1861540)
2023-10-27 19:35:54 -04:00
Drew Willcoxon
629eb836c5 Bug 1861540 - Part 2: Update tests to use the local remote settings server. r=daisuke
This modifies tests to use the server. There are a few important points to call
out:

This means tests are now using the real Rust component, and we need to make sure
the test RS data is valid and matches what Rust expects. For example, I had to
add `icon` properties to suggestions and set the `advertiser` to "Wikipedia" for
non-sponsored suggestions. Otherwise Rust hits an error on ingest. I also
removed some test cases because they tested behaviors that are impossible with
Rust, for example Pocket keywords that are duplicated in the high- and
low-confidence arrays.

We need to be careful to wait until Suggest is done syncing from remote settings
regardless of whether it's using the JS or Rust backend. I added a way to force
the backends to sync. That way, tests can force a sync, wait for it to finish,
and be sure that all sync activity is done.

A common pattern in tests is to call `ensureQuickSuggestInit()` and then set
Suggest-related prefs (or vice versa). This is a little problematic because both
`ensureQuickSuggestInit()` and setting prefs can cause Suggest to start a sync.
It's more problematic now that we're not mocking remote settings or Rust. So I
combined the two by adding a `prefs` param to `ensureQuickSuggestInit()`. That
way, tests can be sure that all syncing is done once that function returns.

Depends on D192037

Differential Revision: https://phabricator.services.mozilla.com/D192038
2023-10-27 22:31:55 +00:00
Drew Willcoxon
a316dabe80 Bug 1859341 - Modify desktop Suggest integration so it uses addon and Pocket suggestions from Rust. r=daisuke
This builds on the recent vendor that was done in bug 1859069 and D191004 in
particular.

The parameter to the Rust `SuggestStore.query()` function now takes an object
with a `providers` property, instead of separate boolean sponsored and
nonsponsored properties. `providers` is an array whose items are integers that
identify Rust providers (defined in [the RustSuggest bindings here](https://searchfox.org/mozilla-central/rev/c3c92500ef8ffab4fa53d4b2d5c5e2b49025e89b/toolkit/components/uniffi-bindgen-gecko-js/components/generated/RustSuggest.sys.mjs#953-958)).

`MockRustSuggest` in `QuickSuggestTestUtils.sys.mjs` is becoming kind of a pain
to keep updated. More tasks in `test_quicksuggest_pocket.js` should use Rust
than the ones I've updated here, but they don't because I would need to
(re)implement the prefix-matching behavior in `MockRustSuggest`. In a follow-up
I'd like to explore using a mock remote settings server instead so that the real
Rust component can be tested.

Differential Revision: https://phabricator.services.mozilla.com/D191351
2023-10-20 02:52:56 +00:00
Norisz Fay
578a0551ac Backed out changeset 1b9473fe1ebe (bug 1859341) for causing bc failures on browser_glean_telemetry_engagement_selected_result.js CLOSED TREE 2023-10-20 05:30:32 +03:00
Drew Willcoxon
22d28243e8 Bug 1859341 - Modify desktop Suggest integration so it uses addon and Pocket suggestions from Rust. r=daisuke
This builds on the recent vendor that was done in bug 1859069 and D191004 in
particular.

The parameter to the Rust `SuggestStore.query()` function now takes an object
with a `providers` property, instead of separate boolean sponsored and
nonsponsored properties. `providers` is an array whose items are integers that
identify Rust providers (defined in [the RustSuggest bindings here](https://searchfox.org/mozilla-central/rev/c3c92500ef8ffab4fa53d4b2d5c5e2b49025e89b/toolkit/components/uniffi-bindgen-gecko-js/components/generated/RustSuggest.sys.mjs#953-958)).

`MockRustSuggest` in `QuickSuggestTestUtils.sys.mjs` is becoming kind of a pain
to keep updated. More tasks in `test_quicksuggest_pocket.js` should use Rust
than the ones I've updated here, but they don't because I would need to
(re)implement the prefix-matching behavior in `MockRustSuggest`. In a follow-up
I'd like to explore using a mock remote settings server instead so that the real
Rust component can be tested.

Differential Revision: https://phabricator.services.mozilla.com/D191351
2023-10-20 01:42:21 +00:00
Drew Willcoxon
61acdfca1f Bug 1859069 - Part 3: Fix urlbar consumers for the updated suggest JS bindings. r=lina
As the TODO's say, I'd like to clean this up and add support for AMO and Pocket,
but right now let's just get the status quo working.

Depends on D191003

Differential Revision: https://phabricator.services.mozilla.com/D191004
2023-10-14 00:37:13 +00:00
Drew Willcoxon
baa7ed8772 Bug 1827966 - Part 2: Remove support for dismiss and help buttons from quick suggest tests. r=dao
Depends on D190892

Differential Revision: https://phabricator.services.mozilla.com/D190893
2023-10-13 21:52:06 +00:00
Drew Willcoxon
f9f954cc37 Bug 1858547 - Remove the quickSuggestBlockingEnabled Nimbus variable and fallback pref. r=daisuke
Depends on D190516

Differential Revision: https://phabricator.services.mozilla.com/D190742
2023-10-12 15:50:50 +00:00
Drew Willcoxon
234916db20 Bug 1857391 - Remove Firefox Suggest "best match" as its own separate feature. r=daisuke,settings-reviewers
This removes "best match" as its own separate Firefox Suggest feature. In the
future, whether or not a suggestion is a best match (a.k.a. top pick) will be
determined by relevant product requirements. I've confirmed this with Nive.

Here's a summary of changes:

* Removes prefs and Nimbus variables related to best match
* Removes the "Top pick" checkbox in about:preferences
* Removes support for the `best_match` quick suggest config property. This
  property was removed from the config in remote settings a while ago.
* Removes legacy telemetry scalars related to best match. These scalars were
  added years ago for the original best match experiment and before we started
  using Glean. In the case of non-sponsored suggestions, the scalars have not
  been recorded at all for some time. In the case of sponsored suggestions, they
  can now be recorded again due to the recent addition of sponsored priority
  suggestions, but they are superseded by Glean.

Differential Revision: https://phabricator.services.mozilla.com/D190516
2023-10-11 17:17:06 +00:00
Drew Willcoxon
17f4082056 Bug 1857396 - Use the update timer manager to periodically perform ingestion in the Suggest Rust component. r=daisuke
This uses the update timer manager (`nsIUpdateTimerManager`) to periodically
ingest. This is the same mechanism the desktop remote settings client uses.
Please see the bug for more info on the update timer manager. I left some notes
there.

I chose the same 24-hour interval that the remote settings client uses. So
overall, this should give us pretty much the same update behavior we have with
remote settings in the JS backend.

Differential Revision: https://phabricator.services.mozilla.com/D190384
2023-10-10 02:28:54 +00:00
Drew Willcoxon
0d60a186b7 Bug 1855884 - Handle icons from the Suggest Rust component. r=dao
The new Rust implementation of Suggest stores icons for some suggestion types in
its Sqlite database, and it returns these icons to consumers as byte arrays. To
show these icons in the view quickly and without any overhead, we can create
`Blob` URLs from the arrays. Blob URLs need to be revoked when we're done with
them to avoid leaking the backing data.

This patch implements some simple lifetime management of blob URLs in the view.
The first time the view shows a result, it creates a blob URL for the result's
icon. The view caches the URL while it remains open, so as the user continues to
type and possibly match the same result many times, the view will use the same
blob URL each time. When the view closes, it revokes the URL. This seems like a
reasonable, natural lifetime for these URLs, and the implementation is simple.

Depends on D189452

Differential Revision: https://phabricator.services.mozilla.com/D189615
2023-10-05 04:36:12 +00:00
Daisuke Akatsuka
7205841601 Bug 1856736: Revert group labels and result labels to their previous appearance r=adw
Differential Revision: https://phabricator.services.mozilla.com/D189984
2023-10-03 22:24:04 +00:00
Drew Willcoxon
29454d2d80 Bug 1855615 - Make sure Suggest Glean telemetry is tested with the Rust backend enabled. r=daisuke
This updates the engagement Glean test so it checks Rust results.

It also adds a getter to `SuggestBackendRust` that returns a promise that's
resolved once the backend's initialization is fully complete. Setting
`quicksuggest.rustEnabled` will either trigger the Rust backend to perform
initialization and ingestion, or it will trigger the JS backend to re-sync all
features. Either way, tests need to wait until all of that is done.

Differential Revision: https://phabricator.services.mozilla.com/D189452
2023-09-29 01:02:33 +00:00
Drew Willcoxon
336e2ba93f Bug 1854060 - Initial integration of the Suggest Rust component into desktop urlbar. r=daisuke
This builds on D188681 and adds a new `BaseFeature` called `SuggestBackendRust`.
When `quickSuggestRustEnabled` is true, `UrlbarProviderQuickSuggest` will use
`SuggestBackendRust` to fetch remote settings suggestions; otherwise it will use
`SuggestBackendJs`.

The Rust component is already integrated into desktop Firefox (bug 1851256, bug
1851845), and it's exposed to JS via `RustSuggest.sys.mjs`. Currently it only
supports AMP (sponsored, a.k.a. adM) and Wikipedia (non-sponsored) suggestions.

It's possible to configure the path of the Sqlite file created by the Rust
component. This patch uses `suggest.sqlite` in the user's local profile (cache)
directory.

This is only the initial integration. I can think of a few follow-ups:

* Handle icons. In this patch, results from `SuggestBackendRust` don't have
  icons at all. I have a WIP.
* Handle ingestion better. "Ingest" here means Firefox must tell the Rust
  component to re-fetch suggestions from remote settings and rebuild its Sqlite
  database. Unfortunately the Rust component doesn't keep the data updated by
  itself, so we'll need to periodically tell the component to ingest. This patch
  performs ingestion every time `SuggestBackendRust` is (re)enabled, which is a
  good enough start.
* Maybe handle tests better. For now I modified the main quick suggest unit
  test, test_quicksuggest.js, so it tests both backends. Other tests should
  maybe be updated too, I'm not sure yet.

Depends on D188681

Differential Revision: https://phabricator.services.mozilla.com/D188684
2023-09-26 05:15:30 +00:00
Drew Willcoxon
f5ec50f5ae Bug 1854059 - Convert Suggest remote settings component to a BaseFeature. r=daisuke
This converts `QuickSuggestRemoteSettings` into a `BaseFeature` so that it can
be managed by `QuickSuggest` and easily enabled and disabled depending on
whether the new Rust component is enabled.

Summary of major changes:

* Rename `QuickSuggestRemoteSettings` to `SuggestBackendJs` and make it a
  `BaseFeature`. In D188684 I'll also add a new `SuggestBackendRust` feature.
* Introduce a `quickSuggestRustEnabled` Nimbus variable. The JS backend will be
  disabled if this variable is true. Nothing else uses the variable in this
  patch but D188684 does.
* Move `DEFAULT_SUGGESTION_SCORE` to `UrlbarProviderQuickSuggest` and make the
  provider ensure all suggestions have scores.

Differential Revision: https://phabricator.services.mozilla.com/D188681
2023-09-26 05:15:29 +00:00
Daisuke Akatsuka
fe247c61cb Bug 1852187: Move sponsored suggestions higher r=adw,fluent-reviewers,flod
Differential Revision: https://phabricator.services.mozilla.com/D187873
2023-09-14 05:14:48 +00:00
Drew Willcoxon
bf1430c569 Bug 1841408 - Unify rich suggestions, best match, Firefox Suggest sponsored results, and Pocket Suggestions. r=dao,daleharvey
This does a few things:

* Unify the view implementations of rich suggestions, Firefox Suggest sponsored
  results, and best match. I did this by using the best match implementation
  and extending it to rich suggestions and Suggest sponsored.
* Use the unified implementation for Pocket suggestions too.
* Add a bottom-text concept since Pocket suggestions shown as top picks need to
  show both a description and some text below it. (The actual bottom text per
  result is added in D182632 since I didn't want to make this patch bigger than
  necessary)

I have a couple motivations for these changes:

* I'm implementing Pocket suggestions, which need to show some text below the
  suggestion title as well as the URL. I was going to just use the Firefox
  Suggest sponsored approach, where the action text is wrapped below the title,
  but that doesn't work because it can't show both the wrapped action text and
  the URL.
* IMO we should use rich suggestions as the basis for all rows going forward,
  i.e., unify the different row implementations around rich suggestions.

The reason I chose the best match implementation instead of the rich suggestions
implementation is because the grid-based approach of rich suggestions doesn't
work well when the URL also needs to be shown. The URL should be
baseline-aligned with the row title, which isn't easy to do when the URL is
outside the grid. The rich suggestions implementation also doesn't wrap the URL.

Other details:

* The `rich-suggestion=no-icon` attribute value is only used for styling, so we
  can replace it with `@supports -moz-bool-pref()`. That lets us make the
  `rich-suggestion` attribute a simple boolean.
* I kept the `isBestMatch` property for results since
  `searchEngagementTelemetryGroup()` uses it to return "top_pick", and the view
  also uses it to create the "Top pick" row/group label. It still has semantic
  meaning so I think that's OK. It's no longer used by the view to create
  different DOM or styling.
* Move `isRichSuggestion` from the payload to the result itself, since it's no
  longer used for only one type of result. It's like `isBestMatch`, which is
  also on the result.
* Add `richSuggestionIconSize` to the result too. The best match icon size
  is 52. The Pocket best match icon size is 24 (but will have added padding and
  a background color to make it appear 52px). IMO this is better than adding
  rules for each type of suggestion to the CSS. It's cleaner and also indicates
  what the "standard" icon sizes are.

Depends on D182580

Differential Revision: https://phabricator.services.mozilla.com/D182537
2023-07-05 15:47:24 +00:00
Marco Bonardo
ddbafa4329 Bug 1834989 - Clean up UrlbarTestUtils use. r=adw
Differential Revision: https://phabricator.services.mozilla.com/D179056
2023-05-26 14:56:55 +00:00
Daisuke Akatsuka
009401662c Bug 1833975: Use MockRemoteSettings for QuickSuggestTestUtils.setConfig r=adw
Differential Revision: https://phabricator.services.mozilla.com/D178791
2023-05-25 13:55:55 +00:00
Daisuke Akatsuka
278b9be236 Bug 1833975: Use MockRemoteSettings for QuickSuggestTestUtils.setRemoteSettingsResults() r=adw
Differential Revision: https://phabricator.services.mozilla.com/D178790
2023-05-25 13:55:55 +00:00
Daisuke Akatsuka
08edf23090 Bug 1833975: Introduce MockRemoteSettings to sync RemoteSettings data r=adw
Differential Revision: https://phabricator.services.mozilla.com/D178789
2023-05-25 13:55:55 +00:00
Norisz Fay
8cd234ee24 Backed out 5 changesets (bug 1833975, bug 1834646) for causing xpcshell failures on test_quicksuggest_positionInSuggestions.js CLOSED TREE
Backed out changeset 313ba1d28b0a (bug 1834646)
Backed out changeset e06da1bd5237 (bug 1833975)
Backed out changeset 22a19ef954b3 (bug 1833975)
Backed out changeset f6a474dcdc0e (bug 1833975)
Backed out changeset 43f66a49f875 (bug 1833975)
2023-05-25 14:10:58 +03:00
Daisuke Akatsuka
1a6447d877 Bug 1833975: Use MockRemoteSettings for QuickSuggestTestUtils.setConfig r=adw
Differential Revision: https://phabricator.services.mozilla.com/D178791
2023-05-25 08:14:55 +00:00
Daisuke Akatsuka
ea002d4416 Bug 1833975: Use MockRemoteSettings for QuickSuggestTestUtils.setRemoteSettingsResults() r=adw
Differential Revision: https://phabricator.services.mozilla.com/D178790
2023-05-25 08:14:55 +00:00
Daisuke Akatsuka
f3c0425f24 Bug 1833975: Introduce MockRemoteSettings to sync RemoteSettings data r=adw
Differential Revision: https://phabricator.services.mozilla.com/D178789
2023-05-25 08:14:55 +00:00
Mark Banner
0666077666 Bug 1826062 - Automatic fixes for upgrading Prettier to 2.8.8. r=mossop,perftest-reviewers,webcompat-reviewers,geckoview-reviewers,denschub,devtools-reviewers,sparky,calu
Differential Revision: https://phabricator.services.mozilla.com/D177027
2023-05-20 12:26:53 +00:00
Drew Willcoxon
94f4f34eee Bug 1831656 - Refactor quick suggest remote settings management. r=daisuke
This refactors quick suggest remote settings management so it will be easier to
support new types of remote settings suggestions. It builds on D177191.

Currently, RemoteSettingsClient only handles adM and Wikipedia suggestions. It
would be possible for it to support more suggestions types by adding a series of
`if` statements, one per suggestion type (to check if the suggestion type is
enabled), with each statement fetching a specific suggestion type's data.
However, that doesn't scale elegantly.

It would also be possible for RemoteSettingsClient to be agnostic about the
suggestions in remote settings. IOW it doesn't need to care that different types
of suggestions are stored in RS. It could treat them all as one big map from
keywords to suggestions. However, that would require uniformity and stability in
how suggestions are stored in RS, and since the Suggest project is not mature,
that's not the case right now, and it won't be the case any time soon.

Instead, this revision moves suggestion-specific logic from RemoteSettingsClient
to BaseFeature classes specific to each suggestion type. Each BaseFeature
registers itself with remote settings using the new QuickSuggestRemoteSettings
module, fetches its specific RS data, and builds whatever data structure is
appropriate for serving its suggestions. I expect most features to use a simple
map from keywords to suggestions, like adM/Wikipedia does, so I factored out the
map-related code into a new SuggestionsMap class. The weather feature is an
exception because only its keywords are stored in RS, not the suggestion itself.

UrlbarProviderQuickSuggest accesses remote settings suggestions by going through
QuickSuggestRemoteSettings. It only needs to make one call.

This design should work well when the cross-platform Rust component is ready.
We should only need to modify UrlbarProviderQuickSuggest so it fetches
suggestions from the Rust component instead of QuickSuggestRemoteSettings.

Depends on D177191

Differential Revision: https://phabricator.services.mozilla.com/D176779
2023-05-08 09:08:42 +00:00
Barret Rennie
f7a4fadf48 Bug 1788954 - Convert toolkit/components/nimbus to ES modules r=Standard8,pip-reviewers,credential-management-reviewers,sgalich
Differential Revision: https://phabricator.services.mozilla.com/D172850
2023-03-30 20:51:58 +00:00
CanadaHonk
de0de3489c Bug 1801379 - Migrate Sinon.jsm to an ES module r=extension-reviewers,application-update-reviewers,pip-reviewers,credential-management-reviewers,fxview-reviewers,devtools-reviewers,Standard8,nchevobbe,sclements,dimi,mconley,bytesized,robwu
Migrated `testing/modules/Sinon.sys.mjs` to an ES module.

`testing` should now be 100% ESM 🎉

Differential Revision: https://phabricator.services.mozilla.com/D173643
2023-03-29 07:34:10 +00:00
Drew Willcoxon
f5dc21ef86 Bug 1819797 - Update telemetry for navigational suggestions and dynamic Wikipedia and add subtypes to quick suggest results. r=daleharvey
This adds a bunch of scalars to record navigational suggestions telemetry as
discussed with data science and described in the spec. These scalars are
different from the other Suggest ones because we want to record how nav
suggestions interact with the heuristic result. Unlike the existing scalars, the
keys of these new scalars are the types of heuristics that were shown when a nav
suggestion was or wasn't shown. One of the scalars is updated every time a nav
suggestion is *not* shown, and of course for most users that will be the vast
majority of the time or all the time, so I put all these scalars behind a Nimbus
variable. We'll set the variable to true in the control and treatment branches
of the nav suggestions experiment.

This patch also makes sure nav suggestions are recorded properly in Glean, as
`navigational`. I noticed that dynamic Wikipedia results are currently recorded
as `suggest_non_sponsor`, so I also added a new `dynamic_wikipedia` Glean type
for them. They're also recorded as `urlbar.picked.quicksuggest` in the legacy
telemetry, so I also changed it so they're recorded as
`urlbar.picked.dynamic_wikipedia`.

Currently for dynamic Wikipedia, the non-sponsored scalars are also incremented,
and I discussed with data science whether they and the sponsored scalars should
be incremented for all the new Suggest suggestion types we now have. We agreed
that they should be reserved for the usual partner sponsored and expanded
Wikipedia suggestions, and they should not be used for these new Suggest types,
so this patch also makes that change, and it does not update the non-sponsored
scalars for nav suggestions either.

The other major change this makes is to add a new `subtype` property to quick
suggest result payloads. I think we need a clear, simple way to distinguish
between all these various Suggest suggestion types that doesn't depend on
examining different payload properties depending on the type.

Differential Revision: https://phabricator.services.mozilla.com/D171525
2023-03-08 01:11:02 +00:00
Drew Willcoxon
5f9e3b5752 Bug 1814795 - Support keyword-based weather suggestions in addition to zero-prefix. r=daisuke
This adds a new pref, `browser.urlbar.weather.zeroPrefix`. When true, weather
suggestions are shown on "zero prefix" like they are now, which means they're
shown when the user focuses the urlbar and before they type anything. When the
pref is false, the weather provider will show suggestions only if the search
string matches a keyword in a set of keywords managed by `QuickSuggest.weather`.

My plan is to store the keywords in the quick suggest config object in remote
settings. Nan suggested this too. Currently the config does not contain any
keywords, but this patch can be tested by setting the pref to false, running the
following in the browser console, and then typing "weather" in the urlbar:

```lang=js
ChromeUtils.importESModule("resource:///modules/QuickSuggest.sys.mjs")
  .QuickSuggest.remoteSettings._test_setConfig({
    weather_keywords: ["weather"],
  });
```

Other changes:

* It's possible for a keyword to match both the weather suggestion and a quick
  suggest suggestion. Only the weather suggestion should be shown. This patch
  modifies to the muxer for that.
* This modifies `UrlbarView.#rowLabel()` to show the "Top pick" (a.k.a. best
  match) label for keyword-based weather suggestions, in addition to zero-prefix
  suggestions like we currently do.
* This modifies the remote settings client so it becomes enabled when keyword-
  based weather suggestions are enabled, so that the config can be accessed.

Depends on D168738

Differential Revision: https://phabricator.services.mozilla.com/D168757
2023-02-07 02:26:55 +00:00
Dão Gottwald
b480cfa156 Bug 1810647 - Prepare for enable urlbar result menu in Nightly. r=mak,fluent-reviewers,flod
Differential Revision: https://phabricator.services.mozilla.com/D167004
2023-01-23 15:54:53 +00:00
Drew Willcoxon
51937fb742 Bug 1808697 - Allow Merino and remote settings suggestions to be passed separately to ensureQuickSuggestInit(). r=daleharvey
`QuickSuggestTestUtils.ensureQuickSuggestInit()` was written before Merino, so
it assumes the suggestion objects passed in are remote settings suggestions.
This revision modifies it so Merino and remote settings suggestions can both be
passed in. That makes it a little nicer for tests that need to test Merino
suggestions in particular, like navigational suggestions, dynamic Wikipedia,
etc.

Another motivation for this change is that it makes it clear which type of
suggestion is being passed to `ensureQuickSuggestInit()`. Unfortunately Merino
suggestion objects are slightly different from remote settings result objects
(`block_id` vs. `id` for example), which are both different from UrlbarResult
objects, and it can be confusing when reading tests. Since "result" is the name
of remote settings objects used internally in the remote settings client, I've
used that term here, and I've updated all callers to use it instead of
"suggestion".

This also makes `MerinoTestUtils` and `QuickSuggestTestUtils` singletons.
Otherwise the new `MerinoTestUtils` instance used inside `QuickSuggestTestUtils`
isn't the same as the one used in the test that calls into
`QuickSuggestTestUtils`, which is very confusing. This made me realize it's a
good idea for these test utils objects to be singletons.

Finally I removed `is_top_pick` handling from the remote settings client and
remote settings suggestions, since the related test is now using Merino. I also
removed `_test_is_best_match` since only one test was using it and it's not
necessary.

Depends on D166019

Differential Revision: https://phabricator.services.mozilla.com/D166050
2023-01-09 20:46:00 +00:00
Mark Banner
df47c60747 Bug 1806359 - Convert telemetry imports to direct ES imports. r=necko-reviewers,application-update-reviewers,pip-reviewers,credential-management-reviewers,janerik,mconley,sgalich,bytesized,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D165002
2022-12-23 12:37:07 +00:00
Daisuke Akatsuka
98c1beeb43 Bug 1805321: Move initNimbusFeature() to UrlbarTestUtils r=adw
Differential Revision: https://phabricator.services.mozilla.com/D164529
2022-12-13 23:00:12 +00:00
Drew Willcoxon
80ddf477dd Bug 1804807 - Refactor quick suggest telemetry tests. r=daleharvey
This refactors quick suggest telemetry tests. My goal is to make it really
simple to add tests for new types of suggestions, like dynamic Wikipedia and
weather.

I've split browser_quicksuggest_telemetry.js into different files, one per
suggestion type: sponsored, nonsponsored, and dynamic Wikipedia. I'm working on
a new file for weather in bug 1804536. There are two other files for other
telemetry that isn't primary or core telemetry. (In the patch, I cp'ed
browser_quicksuggest_telemetry.js to these two new files,
browser_telemetry_other.js and browser_telemetry_impressionEdgeCases.js.)

I named the new files browser_telemetry_foo.js. I don't think it's important to
keep the "quicksuggest" in their names because they're already in the
quicksuggest directory and these file names were starting to get long.

I added some automated telemetry helpers to head.js. They can be used to
declaratively define the primary telemetry that's expected for a particular
suggestion. The helpers automatically check all types of primary telemetry for
the suggestion: impression, click, help, and block. When we add a new suggestion
type, we can add a new file that uses these helpers, and hopefully it should be
pretty simple.

I also removed some tasks that in hindsight aren't important and/or are covered
by other tasks/tests.

All the changes from `http` to `https` in this revision are due to lint.

Depends on D162253

Differential Revision: https://phabricator.services.mozilla.com/D164307
2022-12-09 23:49:46 +00:00
Dale Harvey
31c13c0cd4 Bug 1800993 - Add telemetry for dynamic wikipedia results. r=adw
Differential Revision: https://phabricator.services.mozilla.com/D162253
2022-12-09 21:29:38 +00:00
Sandor Molnar
b46f787337 Backed out changeset ba7612a763a0 (bug 1800993) for needing data-review. CLOSED TREE 2022-12-08 00:55:42 +02:00