Commit Graph

77 Commits

Author SHA1 Message Date
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
Dale Harvey
05f278cf30 Bug 1800993 - Add telemetry for dynamic wikipedia results. r=adw
Differential Revision: https://phabricator.services.mozilla.com/D162253
2022-12-07 22:40:53 +00:00
Mark Banner
0cd6f3836f Bug 1804037 - Convert PartnerLinkAttribution.jsm to an ES module. r=adw,search-reviewers,daleharvey
Differential Revision: https://phabricator.services.mozilla.com/D163814
2022-12-06 11:34:18 +00:00
Ryan VanderMeulen
3b189f8efc Backed out changeset af2c13b9fdb7 (bug 1801244) per developer request. 2022-12-05 16:38:55 -05:00
Drew Willcoxon
73c6ffb1df Bug 1801244 - Make Merino opt out on Beta. r=daisuke,nanj,RyanVM,chutten
This makes Merino opt out on Beta. There are two different parts:

1. Decide what "Beta" means. After discussing this with RyanVM, I'm using the
   same definition [used by telemetry](https://searchfox.org/mozilla-central/rev/2f47e3dacf0d773e9c7f363cecf10cfbea490679/toolkit/components/telemetry/app/TelemetryControllerBase.jsm#103,112-114): (a) if `MOZ_UPDATE_CHANNEL` is "beta"
   or (b) if it's "release" and `app.update.channel` is "beta". The latter case
   is true for RC builds delivered to the Beta channel. I moved the relevant
   telemetry logic to `AppConstants` so I can easily use it too. Bug 1435753 has
   context on this logic w/r/t telemetry.
2. Change the Merino default so it's enabled on Beta in the offline scenario. I
   kept the online scenario's disabled default since the only point of
   delivering the online scenario to the user now is to prompt them to opt in to
   Merino. This change is in UrlbarPrefs.sys.mjs.

The rest of the patch updates tests.

The effect of this patch will be to use a new default value of true for the
`quicksuggest.dataCollection.enabled` pref on Beta in the offline scenario. If
the user didn't touch the pref at all, then its previous default value was
false, and the new default will now be true.

If the user enabled the pref, it will remain enabled. If the user enabled and
then disabled it, it will remain disabled. That's because the pref is sticky, so
once it has a value on the user branch, it will keep that value. This patch only
changes the value of the pref on the default branch, so it won't override the
user's previous choice since that is set on the user branch.

Differential Revision: https://phabricator.services.mozilla.com/D162353
2022-11-22 06:19:24 +00:00
Mark Banner
5d1820b074 Bug 1799314 - Convert consumers of testing modules to import ES modules direct (browser/). r=Gijs,settings-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D161914
2022-11-17 12:00:30 +00:00
Drew Willcoxon
26a76fee34 Bug 1799363 - Add weather suggestions to quick suggest. r=daisuke
This adds a weather feature to quick suggest. It periodically fetches a weather
suggestion from Merino. UrlbarProviderQuickSuggest shows the suggestion when the
search string is empty ("zero prefix").

The implementation of the UrlbarResult returned by UrlbarProviderQuickSuggest is
only temporary. Mandy is working on the final UI in
[SNT-323](https://mozilla-hub.atlassian.net/browse/SNT-323). Landing a temporary
implementation allows Mandy to base her patch on it and trigger real weather
suggestions from Merino to test her implementation against. It also lets people
on the team test weather suggestions without having to wait for the final UI to
land.

I added the following prefs and Nimbus variable to control the feature. It will
initially be rolled out in an experiment, so we need a Nimbus variable. In the
initial experiment, users will be able to dismiss the suggestion but not toggle
a checkbox in about:preferences.

* `weatherFeatureGate` - Nimbus variable that controls the whole feature
* `browser.urlbar.weather.featureGate` - Fallback pref for the Nimbus variable
* `browser.urlbar.suggest.weather` - When the feature gate pref is true, this
  determines whether the suggestion should be shown. In a future patch, we'll
  flip this to false when users dismiss the suggestion.

I set the fetch interval to 30 minutes. That seems reasonable considering that
the suggestion contains the current temperature and weather. Merino will set
caching headers appropriately so that Firefox won't actually make a new network
request if the previously fetched suggestion is new enough.

Depends on D161368

Differential Revision: https://phabricator.services.mozilla.com/D161410
2022-11-17 05:04:07 +00:00
Cristian Tuns
0fdc1821ce Backed out changeset 053963c15ffe (bug 1799363) for causing xpcshell failures on test_weather.js CLOSED TREE 2022-11-16 14:00:59 -05:00
Drew Willcoxon
48330effac Bug 1799363 - Add weather suggestions to quick suggest. r=daisuke
This adds a weather feature to quick suggest. It periodically fetches a weather
suggestion from Merino. UrlbarProviderQuickSuggest shows the suggestion when the
search string is empty ("zero prefix").

The implementation of the UrlbarResult returned by UrlbarProviderQuickSuggest is
only temporary. Mandy is working on the final UI in
[SNT-323](https://mozilla-hub.atlassian.net/browse/SNT-323). Landing a temporary
implementation allows Mandy to base her patch on it and trigger real weather
suggestions from Merino to test her implementation against. It also lets people
on the team test weather suggestions without having to wait for the final UI to
land.

I added the following prefs and Nimbus variable to control the feature. It will
initially be rolled out in an experiment, so we need a Nimbus variable. In the
initial experiment, users will be able to dismiss the suggestion but not toggle
a checkbox in about:preferences.

* `weatherFeatureGate` - Nimbus variable that controls the whole feature
* `browser.urlbar.weather.featureGate` - Fallback pref for the Nimbus variable
* `browser.urlbar.suggest.weather` - When the feature gate pref is true, this
  determines whether the suggestion should be shown. In a future patch, we'll
  flip this to false when users dismiss the suggestion.

I set the fetch interval to 30 minutes. That seems reasonable considering that
the suggestion contains the current temperature and weather. Merino will set
caching headers appropriately so that Firefox won't actually make a new network
request if the previously fetched suggestion is new enough.

Depends on D161368

Differential Revision: https://phabricator.services.mozilla.com/D161410
2022-11-16 17:59:23 +00:00
Drew Willcoxon
3a896d5ba4 Bug 1799264 - Refactor QuickSuggest features [Part 3]: Port the remote settings client to BaseFeature. r=daisuke
This ports the remote settings client to `BaseFeature`.

The remote settings client is different from the other two features I ported in
this patch stack because it depends on preferences, not Nimbus variables:
`suggest.quicksuggest.sponsored` and `suggest.quicksuggest.nonsponsored`. To
support that, I modified `BaseFeature` so it can list the prefs it depends
on. When QuickSuggest observes a pref change, it checks whether it's a pref for
a feature, and if so, it updates it.

Please see bug 1799264 for details.

Depends on D161367

Differential Revision: https://phabricator.services.mozilla.com/D161368
2022-11-08 05:42:10 +00:00
Drew Willcoxon
be65e71e30 Bug 1798595 - Refactor quick suggest [Part 6]: Minor improvements. r=daisuke
This does the following:

* Get rid of `QUICK_SUGGEST_SOURCE` since it's only used in a couple of
  places. Its simpler to use the string literals directly.
* Set `source: "merino"` on Merino suggesions in the Merino client instead of
  doing it in UrlbarProviderQuickSuggest, similar to how the remote settings
  client sets `source: "remote-settings"`
* Export `ONBOARDING_CHOICE` and `ONBOARDING_URI` on the QuickSuggest object for
  consistency with other consts
* Remove unnecessary consts from QuickSuggestTestUtils that are already defined
  on QuickSuggest

Please see bug 1798595 for details.

Depends on D160986

Differential Revision: https://phabricator.services.mozilla.com/D160987
2022-11-02 06:50:15 +00:00
Drew Willcoxon
16aaeab517 Bug 1798595 - Refactor quick suggest [Part 5]: Move remote settings code into QuickSuggestRemoteSettingsClient and initialization into QuickSuggest. r=daisuke
This does the following:

* Moves quick suggest initialization from UrlbarQuickSuggest to QuickSuggest
* Renames UrlbarQuickSuggest.sys.mjs to QuickSuggestRemoteSettingsClient.sys.mjs, so now this file is focused only on remote settings
* Makes QuickSuggest create an instance of QuickSuggestRemoteSettingsClient and keep it as `QuickSuggest.remoteSettings`
* Moves latency telemetry from UrlbarProviderQuickSuggest into QuickSuggestRemoteSettingsClient
* Changes the ad hoc logger used in QuickSuggestRemoteSettingsClient to a proper urlbar-style logger
* Updates consumers to use `QuickSuggest.remoteSettings` instead of UrlbarQuickSuggest

Please see bug 1798595 for details.

Depends on D160985

Differential Revision: https://phabricator.services.mozilla.com/D160986
2022-11-02 06:50:15 +00:00
Drew Willcoxon
209873a1d6 Bug 1798595 - Refactor quick suggest [Part 4]: Move help URL from UrlbarProviderQuickSuggest to QuickSuggest and change how the test utils are initialized. r=daisuke
This moves the help URL const out of UrlbarProviderQuickSuggest in order to make
UrlbarProviderQuickSuggest focused on being a urlbar provider.

It also changes how QuickSuggestTestUtils is initialized to be more similar to
MerinoTestUtils. There's no need for a separate `init()` method when the
constructor will do. I'd like to make this change in a different revision but I
did it here because I want to include all changes to about:preferences in one
revision for easier review.

Please see bug 1798595 for details.

Depends on D160984

Differential Revision: https://phabricator.services.mozilla.com/D160985
2022-11-02 06:50:14 +00:00