Commit Graph

97 Commits

Author SHA1 Message Date
Gregory Pappas
e9950eccfd Bug 1845311 - Use ChromeUtils.defineLazyGetter in more places r=arai,webdriver-reviewers,geckoview-reviewers,extension-reviewers,application-update-reviewers,credential-management-reviewers,devtools-reviewers,fxview-reviewers,anti-tracking-reviewers,sessionstore-reviewers,pbz,joschmidt,robwu,issammani,bytesized,owlish,dao
Differential Revision: https://phabricator.services.mozilla.com/D184481
2023-07-26 16:28:11 +00:00
Marco Bonardo
b99e0f7f7e Bug 1827770 - Remove isPrivate argument from onEngagement() since it can be inferred. r=daleharvey
We can't use context.isPrivate because sometimes context is undefined.
I filed https://bugzilla.mozilla.org/show_bug.cgi?id=1841762 about that.

Differential Revision: https://phabricator.services.mozilla.com/D182772
2023-07-07 10:01:50 +00:00
Marco Bonardo
ff3c4323fc Bug 1827770 - Remove QueryContext.view and pass the controller to onEngagement() instead. r=daleharvey
Differential Revision: https://phabricator.services.mozilla.com/D182771
2023-07-07 10:01:50 +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
Chris H-C
eca601ffd9 Bug 1836283 - Reinstrument contextual services PingCentre pings in parallel with Glean r=perry.mcmanis,nanj,wstuckey
Covers topsites and quicksuggest impressions, clicks, and blocks.

Removes unused and not-to-be-used topsites-in-urlbar pingcentre instrumentation
rather than reinstrumenting it.

Differential Revision: https://phabricator.services.mozilla.com/D179856
2023-06-26 19:02:46 +00:00
Drew Willcoxon
bd2145522d Bug 1839558 - Allow suggestion scores to be specified in Nimbus. r=daisuke
This adds a `quickSuggestScoreMap` Nimbus variable that lets experiments
override suggestion scores. It maps from telemetry types to score values. For
example:

```
"quickSuggestScoreMap": {
  "amo": 0.25,
  "adm_sponsored": 0.3
}
```

In this example, addon suggestions will always have a score of 0.25, and
sponsored suggestions will always have a score of 0.3. Of course, different
branches within an experiment and different experiments can set different
scores.

While working on this, I saw we have a bug when we try to look up the
`BaseFeature` for a result. To do the lookup, we look up the result's
`telemetryType` in `FEATURE_NAMES_BY_TELEMETRY_TYPE`. That's a problem for `adm`
suggestions because the `telemetryType` will be either `adm_sponsored` or
`adm_nonsponsored`, but neither of those is present in
`FEATURE_NAMES_BY_TELEMETRY_TYPE` -- only `adm` is.

To fix it, I added back the `provider` property to result payloads that I
previously removed, and I added `BaseFeature.merinoProvider` so each feature can
specify its Merino provider. Then, `QuickSuggest` can build a map from Merino
provider names to features, allowing us to look up features without needing to
hardcode something like `FEATURE_NAMES_BY_TELEMETRY_TYPE` or
`FEATURE_NAMES_BY_MERINO_PROVIDER`.

Since I added back the `provider` property, I had to update a lot of tests. (As
a follow up, it would be nice to centralize the creation of expected result
objects in the test helper.)

I also added `BaseFeature.getSuggestionTelemetryType()` to help implement the
score map and to better formalize the idea that telemetry types are an important
property that all quick suggest results should include.

Differential Revision: https://phabricator.services.mozilla.com/D181709
2023-06-22 03:55:40 +00:00
Drew Willcoxon
3fd234d2a0 Bug 1836903 - Implement Pocket suggestions. r=daisuke,desktop-theme-reviewers,dao
This implements most parts of Pocket suggestions. They don't need any special UI
or a dynamic result type because they're only shown as the usual best match rows
or non-best match rows.

Still to do:

* Implement the "Show less frequently" behavior once we decide what the keywords
  will be and how that will work.
* Implement the bottom "Mozilla Pocket" text inside the suggestion row once it's
  finalized. We can use the same technique we use to show the "Sponsored" bottom
  text for adM suggestions.

Other changes this makes:

* Replace the `type=bestmatch` attribute with an `bestmatch` attribute. That
  lets best-match rows have a `type` too, in this case `"pocket"` (actually
  either `"rs_pocket"` or `"merino_pocket"`, since I'm using the telemetry
  result type).
* Improve how UrlbarProviderQuickSuggest delegates to individual features when
  getting result commands, view updates, handling commands, etc., so that we
  don't need to add new `case` statements for each new type of suggestion.

Differential Revision: https://phabricator.services.mozilla.com/D180059
2023-06-07 20:19:44 +00:00
Daisuke Akatsuka
13d726e71a Bug 1833760: Integrate remote settings suggestions with AddonSuggestions r=adw
Differential Revision: https://phabricator.services.mozilla.com/D178424
2023-05-22 01:20:56 +00:00
Daisuke Akatsuka
db3c5fdf57 Bug 1833515: Hide suggestions for addons the user has installed r=adw
Differential Revision: https://phabricator.services.mozilla.com/D178263
2023-05-17 06:21:39 +00:00
Drew Willcoxon
21b13c63b8 Bug 1832927 - Move sponsored/nonsponsored checks back to UrlbarProviderQuickSuggest. r=daisuke
Please see bug 1832927 for background. This fixes the problem on 115 by moving
the sponsored/nonsponsored logic back to the provider.

I added a task to test_quicksuggest_topPicks.js, and I created xpcshell tests
for addons and dynamic Wikipedia with similar tasks. It would be nice to unify
this check for all quick suggest types somehow -- maybe a task in
test_quicksuggest.js, but that's not quite as simple as it seems because each
suggestion type has its own suggestion object and expected result payload. We
might also want to add more tasks to these new files. We can think about that
later because there are other opportunities for test consolidation too.

Differential Revision: https://phabricator.services.mozilla.com/D177952
2023-05-16 01:17:06 +00:00
Daisuke Akatsuka
ecbdc5d8f5 Bug 1832474: Implement addon suggestions result menu r=adw,fluent-reviewers,flod
Differential Revision: https://phabricator.services.mozilla.com/D177852
2023-05-15 12:25:06 +00:00
Drew Willcoxon
e6de21f076 Bug 1832300 - Show is_top_pick suggestions as top picks only when the best match prefs are enabled. r=daisuke
This keeps the current behavior where Firefox shows a suggestion as a top pick
when `is_top_pick` is true, but in addition the two best-match prefs must also
be true.

I cp'ed test_quicksuggest_bestMatch.js to test_quicksuggest_topPicks.js so that
we have a test specifically for top picks, and I added tasks for all preference
combinations. The terms "best match" and "top picks" are overloaded and I tried
to explain what they mean in the code comments I added.

Depends on  D176114

Differential Revision: https://phabricator.services.mozilla.com/D177712
2023-05-11 04:14:40 +00:00
Daisuke Akatsuka
45268fa4c7 Bug 1828610: Implement addon suggestions r=desktop-theme-reviewers,adw,fluent-reviewers,flod,dao
Differential Revision: https://phabricator.services.mozilla.com/D176114
2023-05-10 20:04:38 +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
Drew Willcoxon
7bcb27e930 Bug 1829081 - Make improvements to UrlbarProviderQuickSuggest in preparation for handling many types of suggestions. r=daisuke
This makes some changes to UrlbarProviderQuickSuggest that are much more modest
than my previously proposed refactorings in D176111 and D175998. After thinking
about it more and discussing it with @wstuckey and @daisuke, I'm not sure it's a
good idea to split UrlbarProviderQuickSuggest into multiple providers. In the
future, we will replace a lot of our desktop JS with a single cross-platform
Rust component that serves remote settings suggestions and possibly Merino
suggestions too. We should work with that in mind, and I don't think it makes a
lot of sense to have multiple urlbar providers all fetching from this one
component, even though it would make some things nicer, like being able to
isolate suggestion-specific UI code to each provider.

The main goal of this revision is to better prepare UrlbarProviderQuickSuggest
for many new types of suggestions:

* Add `#makeResult()`, which returns a new `UrlbarResult` appropriate for a
  given suggestion
* Add `#makeDefaultResult()`, which returns a result for suggestions that either
  don't need special handling or are unrecognized
* Remove the `RESULT_SUBTYPE` consts. The idea is that the client doesn't need
  to care too much about the types of results Merino returns, except when
  special handling is required (special UI, special telemetry, etc.)
* Add `telemetryType` to result payloads so that the result types recorded in
  Glean are clear and well defined. `telemetryType` is also used to tell the
  type of a result in general. For results that are served by Merino,
  `telemetryType` is the Merino provider name
* Streamline legacy telemetry handling a little, although hopefully we won't be
  doing too much legacy telemetry in the future

There are still open questions that this revision does not resolve, especially
the ability isolate suggestion-specific UI code in a nice way (dynamic result
types). I don't think this revision paints us into any corners.

Other changes:

* Properly document the `${source}_${type}` result types in metrics.yaml (added
  in D174209)
* For Glean result types, replace "suggest_sponsor" with "merino_adm_sponsored"
  and "rs_adm_sponsored", and replace "suggest_non_sponsor" with
  "merino_adm_nonsponsored" and "rs_adm_nonsponsored". This is more consistent
  with the `${source}_${providerName}` convention I'd like to establish.
* Remove code related to Nimbus exposures and a test
  (browser_quicksuggest_bestMatch.js). We aren't using Nimbus exposures anymore.
  We can always add it back if necessary.
* Don't record the custom contextual services pings for dynamic Wikipedia
  results. These pings are only necessary for adM suggestions.

Differential Revision: https://phabricator.services.mozilla.com/D177191
2023-05-08 01:27:28 +00:00
Dão Gottwald
53481047f1 Bug 1827904 - Enable the result menu by default on all channels. r=adw
Differential Revision: https://phabricator.services.mozilla.com/D175362
2023-04-13 17:37:19 +00:00
Drew Willcoxon
c26ec9b3d6 Bug 1827762 - Replace UrlbarProvider.pickResult() and blockResult() with onEngagement() r=mak
This removes `UrlbarProvider.pickResult()` and `blockResult()` in favor of
handling picks and dismissals through `onEngagement()`. A number of providers
use those two methods, so this revision touches a lot of files.

Handling dismissals through `onEngagement()` means `UrlbarInput.pickResult()`
can no longer tell whether a result is successfully dismissed, so it can't
remove the result anymore. (Maybe `onEngagement()` could return some value
indicating it dismissed the result, but I don't want to go down that road.)
Instead, I split `UrlbarController.handleDeleteEntry()` into two methods: a
public one that removes the result and notifies listeners, and a private one
that handles dismissing the selected result internally in
UrlbarController. Providers that have dismissable results should now implement
`onEngagement()` and call `controller.removeResult()`.

I made some other improvements to engagement handling. There's still room for
more but this patch is big enough already.

Other notable changes:

Include the engaged result in engagement notifications so providers have easy
access to it and can respond to clicks and dismissals more easily. That also
lets us stop passing `selIndex` and `provider` to `engagementEvent.record()`
since now it can compute those from the passed-in result.

Add the concept of `isSessionOngoing` to engagement notifications so providers
can tell whether an engagement ended the search session. Right now, providers
like quick suggest that record a bunch of provider-specific legacy telemetry
assume that `onEngagement()` ends the session, but that's no longer true.

Unify result buttons and result menu commands by setting
`element.dataset.command` on buttons (hopefully we can remove buttons soon, at
least the ones that aren't tip buttons)

Make sure we always notify providers on engagement even on dismissals or
when skipping legacy telemetry

Move dismissal of restyled search suggestions and history results from
`UrlbarController.handleDeleteEntry()` to the Places provider

Move dismissal of form history results from
`UrlbarController.handleDeleteEntry()` to the search suggestions provider

In the Places provider, remove the unused `_addSearchEngineMatch()` method. Also
remove the code in the "searchengine" case that creates a non-search-history
result. This code is unreached because the only time the provider creates a
"searchengine" match it also sets `isSearchHistory` to true.

In `UrlbarTestUtils.promiseAutocompleteResultPopup()`, change the default value
of the `fireInputEvent` param from false to true. This is necessary because
without a starting input event, the start event info in `engagementEvent` will
be null, so when `engagementEvent.record()` is called at the end of the
engagement, it will bail, and providers will not be notified of the engagement.
IMO true is a better default value anyway because input events will typically be
fired when the user performs a search.

Differential Revision: https://phabricator.services.mozilla.com/D174941
2023-04-13 06:03:33 +00:00
Dão Gottwald
28de24be6c Bug 1823643 - In ProviderQuickSuggest::blockResult, check result.payload.isBlockable instead of re-determining whether blocking is enabled. r=adw
Differential Revision: https://phabricator.services.mozilla.com/D173138
2023-03-21 22:55:39 +00:00
Dão Gottwald
252116cf0a Bug 1823608 - Fix and consolidate logic for whether quickSuggest and bestMatch blocking are enabled. r=mak
Differential Revision: https://phabricator.services.mozilla.com/D173124
2023-03-21 11:07:26 +00:00
Dão Gottwald
e81c928b0a Bug 1822338 - Enable quick suggest and best match blocking when the result menu is enabled. r=adw
Differential Revision: https://phabricator.services.mozilla.com/D172575
2023-03-16 13:14:33 +00:00
Cristina Horotan
0c8e508db4 Backed out changeset 4b929a47cf6a (bug 1822338) for causing bc failures at browser_glean_telemetry_engagement_type.js CLOSED TREE 2023-03-15 14:45:06 +02:00
Dão Gottwald
ac80f9c8f4 Bug 1822338 - Enable quick suggest and best match blocking when the result menu is enabled. r=adw
Differential Revision: https://phabricator.services.mozilla.com/D172575
2023-03-15 11:03:19 +00:00
Butkovits Atila
df65fd5b69 Backed out changeset 8526273dd69a (bug 1822338) for causing failures at browser_quicksuggest_block.js. CLOSED TREE 2023-03-15 11:38:03 +02:00
Dão Gottwald
950fb701f1 Bug 1822338 - Enable quick suggest and best match blocking when the result menu is enabled. r=adw
Differential Revision: https://phabricator.services.mozilla.com/D172575
2023-03-15 08:39: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
Daisuke Akatsuka
2407eb3bf1 Bug 1820081: Correspond to cleared query context when paste-and-go and drop-and-go r=adw
Differential Revision: https://phabricator.services.mozilla.com/D171527
2023-03-05 22:45:29 +00:00
Drew Willcoxon
9f4378e671 Bug 1814732 - Move weather suggestions to their own provider. r=daisuke
This moves weather suggestions from the quick suggest provider to their own
provider. This will make it easier to implement weather suggestions that are
triggered by keyword instead of being shown on zero-prefix.

It does the following:

* Copies UrlbarProviderQuickSuggest.sys.mjs to UrlbarProviderWeather.sys.mjs
* Removes everything weather-related from UrlbarProviderQuickSuggest.sys.mjs
* Removes everything not weather-related from UrlbarProviderWeather.sys.mjs
* Makes some simplifications to the new provider since it doesn't need to
  support quick suggest suggestions
* Removes `result.payload.isWeather` since now we can use `result.providerName`
* This does *not* change any telemetry

Differential Revision: https://phabricator.services.mozilla.com/D168738
2023-02-07 02:26:54 +00:00
Dão Gottwald
a7c5be04f9 Bug 1814689 - Consolidate code handling UrlbarView overflowable elements. r=adw
Differential Revision: https://phabricator.services.mozilla.com/D168699
2023-02-03 10:25:39 +00:00
mcheang
f26d2a59ce Bug 1811556 - Fix text fading in weather suggestion result and hide middot when high and low temperatures are wrapped. r=adw
Differential Revision: https://phabricator.services.mozilla.com/D167416
2023-02-01 13:52:57 +00:00
Drew Willcoxon
b2d3b1dc40 Bug 1813155 - Quick suggest provider should not be active for search strings that contain only spaces. r=mak
I broke this in D167218. We didn't have a test for it.

Differential Revision: https://phabricator.services.mozilla.com/D168139
2023-01-30 16:45:32 +00:00
Dão Gottwald
d7994183f4 Bug 1811507 - Fix highlighting of dynamic type rows. r=adw
Differential Revision: https://phabricator.services.mozilla.com/D167795
2023-01-27 19:21:10 +00:00
Drew Willcoxon
c81b3fa8ae Bug 1811373 - Cache weather suggestion l10n strings and allow L10nCache to cache strings only by ID. r=dao
This caches weather suggestion l10n strings by adding `cacheable: true` to the
view update object returned by the provider. Doing so hooks into UrlbarView's
dynamic result type functionality [here](https://searchfox.org/mozilla-central/rev/738b761bb2847f609f9cacc550680071cdc53637/browser/components/urlbar/UrlbarView.sys.mjs#1737-1739).

w/r/t l10n strings and caching, weather suggestions are a bit of a new case
because most of these strings take arguments that can't be known in advance and
that will change over time. For a string with arguments, L10nCache creates a
cache key by concating the string's ID and the values of its arguments. That
makes sense for strings whose values are things like search engine names, where
the set of possible argument values is small and where we may need to show
different translated strings when for example the search engine changes. For
those strings, we want to cache the translated strings separately using
different keys.

Weather suggestion strings like "20°C" are a different story. The ideal UX for
these strings is: While the UI is waiting for the string to be re-localized with
new argument values, it should show the previous localized string with the old
argument values. If the argument values have changed, there will still be some
flicker as the old values are replaced with the new ones, but it's the best we
can do, and at least there won't be empty space in the UI.

This isn't possible with L10nCache right now due to how it creates cache keys,
as mentioned earlier. So I added a new option that tells it to cache strings by
ID only, excluding argument values. That way only one translated string is
cached regardless of whatever argument values it was cached with.

Differential Revision: https://phabricator.services.mozilla.com/D167318
2023-01-23 17:49:55 +00:00
Drew Willcoxon
215545afbe Bug 1811018 - Don't show a weather suggestion when the search string contains spaces. r=daisuke
The weather suggestion shouldn't be shown when the search string contains only
spaces. We should check `queryContext.searchString` directly instead of the
trimmed search string. I implemented this wrong in D161410.

Differential Revision: https://phabricator.services.mozilla.com/D167218
2023-01-19 16:31:58 +00:00
mcheang
3be5c87967 Bug 1810250 - Add weather icons for weather suggestions in the urlbar.r=adw,desktop-theme-reviewers,dao
This patch receives a weather icon id from our merino server. We then use that
icon id and map it to a specific weather icon svg file within
urlbar-dyanmic-result.css. The icons colors are specified for light, dark, and
high contrast mode.

Differential Revision: https://phabricator.services.mozilla.com/D166848
2023-01-17 15:11:23 +00:00
Sandor Molnar
2a3754ea58 Backed out changeset dfce1bce524c (bug 1810250) for causing xpc failures in browser/components/urlbar/tests/quicksuggest/unit/test_weather.js CLOSED TREE 2023-01-16 23:59:30 +02:00
mcheang
3fccc60ccb Bug 1810250 - Add weather icons for weather suggestions in the urlbar.r=adw,desktop-theme-reviewers,dao DONTBUILD
This patch receives a weather icon id from our merino server. We then use that
icon id and map it to a specific weather icon svg file within
urlbar-dyanmic-result.css. The icons colors are specified for light, dark, and
high contrast mode.

Differential Revision: https://phabricator.services.mozilla.com/D166848
2023-01-16 19:59:19 +00:00
Dão Gottwald
e7a8bffbe0 Bug 1809705 - Implement "Learn more about Firefox Suggest" menu item in the urlbar result menu. r=adw,fluent-reviewers,flod
Differential Revision: https://phabricator.services.mozilla.com/D166578
2023-01-13 16:03:06 +00:00
Cristian Tuns
e148ca6903 Backed out changeset 03202cdedb1e (bug 1809705) for causing bc failures CLOSED TREE 2023-01-13 10:18:41 -05:00
Dão Gottwald
047b8c03dc Bug 1809705 - Implement "Learn more about Firefox Suggest" menu item in the urlbar result menu. r=adw,fluent-reviewers,flod
Differential Revision: https://phabricator.services.mozilla.com/D166578
2023-01-13 10:50:16 +00:00
Drew Willcoxon
21d32b4e51 Bug 1809201 - Use regionalPrefsLocales for the weather suggestions temperature unit. r=nanj
This replaces `Services.locale.appLocaleAsBCP47` with `regionalPrefsLocales[0]`
when determining the temperature unit to use for weather suggestions.

In summary, that means two things:

* When the language of the OS locale is the same as the language of the app's
  locale, weather suggestions will use the OS locale. e.g., if your OS locale is
  en-CA but your Firefox is en-US, weather will prefer en-CA since both locales
  are English, and so temperatures will be shown in C. This is a change from the
  current behavior, where they would be shown in F.
* When the user checked the "Use your operating system settings..." checkbox in
  about:preferences for unit formatting, weather suggestions will always use the
  OS locale, regardless of the app locale.

This is due to how `regionalPrefsLocales` works [1].

This revision also makes a couple of changes to code added in D166216:

* Instead of storing both C and F temperatures in the UrlbarResult payload,
  store only the user's appropriate temperature. This allows the xcpshell test
  (test_weather.js) to test locale behavior instead of having to do it in a
  browser test, and there's no reason not to do it anyway.
* Replace the hardcoded expected suggestion properties in test_weather.js with
  the ones from `WEATHER_SUGGESTION`, as was the case before D166216.

[1] `regionalPrefsLocales` is implemented [here](https://searchfox.org/mozilla-central/rev/d62c4c4d5547064487006a1506287da394b64724/intl/locale/LocaleService.cpp#485). If
`intl.regional_prefs.use_os_locales` is true, `regionalPrefsLocales` returns the
user's OS locales. The checkbox for this pref [is visible](https://searchfox.org/mozilla-central/rev/893a8f062ec6144c84403fbfb0a57234418b89cf/browser/components/preferences/main.js#1485-1491) only when the user's
primary OS locale doesn't match the app's primary locale. The full label for the
checkbox is [here](https://searchfox.org/mozilla-central/rev/d62c4c4d5547064487006a1506287da394b64724/browser/locales/en-US/browser/preferences/preferences.ftl#324). The pref defaults to false.

If `intl.regional_prefs.use_os_locales` is false, `regionalPrefsLocales` returns
the OS locales only if the OS locale's language is the same as the app locale's
language. Otherwise it returns the app's locales.

In either case, if an error is encountered, the app's locales are returned.

Differential Revision: https://phabricator.services.mozilla.com/D166722
2023-01-12 22:04:19 +00:00
mcheang
cd7ed9d357 Bug 1808974 - Client UI for weather suggestions. r=adw,flod
This patch implements the following:

It gets a weather result by calling `_makeWeatherResult` which calls our backend
Merino server. Based on the data returned by Merino, it parses through the
results to display the city, url, provider, weather summary, current, high, and
low temperatues to the user. It checks for a 0-prefix result to display the
weather. Lastly, it includes a top pick label for weather.

Differential Revision: https://phabricator.services.mozilla.com/D166216
2023-01-11 23:07:45 +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
Drew Willcoxon
bab02048db Bug 1806950 - Don't send custom engagement pings for navigational suggestions. r=daleharvey
This stops trying to send custom engagement pings for navigational
suggestions. That fixes the JS error that's due to the fact that these
suggestions don't have an advertiser. The purpose of these pings is to report
aggregate engagements to partners, and that's not applicable to navigational
suggestions, so not sending pings for these is OK.

I added browser_telemetry_navigationalSuggestions.js to ensure we're not sending
pings. This test will probably need to be substantially modified when we
implement all the required telemetry for navigational suggestions. That's
tracked in [this Jira ticket](https://mozilla-hub.atlassian.net/browse/SNT-337) and documented in the spec.

Until we implement that new telemetry, navigational suggestions are treated as
non-sponsored suggestions w/r/t telemetry, so I copied this file from
browser_telemetry_nonsponsored.js.

Depends on D164615

Differential Revision: https://phabricator.services.mozilla.com/D166019
2023-01-09 20:45:59 +00:00
Drew Willcoxon
9cb9133500 Bug 1806765 - Implement zero-prefix telemetry and add weather suggestion exposure telemetry. r=dao
This adds telemetry to UrlbarView that records the following things related to
the zero-prefix view (i.e., the topsites view):

* Exposures: How many times the ZP view was shown
* Engagements: How many times a result was picked in the ZP view
* Abandonments: How many times the user abandoned the ZP view
* Dwell time: How long the user was shown the ZP view

I considered adding telemetry specifically for topsites instead of the ZP view
as a whole, but since we have plans to start showing other types of results in
the ZP view, I don't think it's a good idea to rely on one specific type of
result as a proxy for the view itself. What DS and Product want to know about is
the view itself: how many times it was shown, for how long, etc.

This also adds one related scalar related to weather suggestions that counts the
number of times it's shown. This is the same scalar I added in D164778 using a
different, more complex approach.

Depends on D164615

Differential Revision: https://phabricator.services.mozilla.com/D165253
2023-01-06 23:44:19 +00:00
Drew Willcoxon
4f60a88fed Bug 1804536 - Implement telemetry for weather suggestions. r=daleharvey
This adds the following scalars:

* `impression_weather`
* `click_weather`
* `help_weather`
* `block_weather`

And these histograms:

* `FX_URLBAR_MERINO_LATENCY_WEATHER_MS`
* `FX_URLBAR_MERINO_RESPONSE_WEATHER`

The histograms are updated in addition to the existing general Merino latency
and response histograms. I also modified the existing response histogram by
adding a new `no_suggestion` category so we can tell the difference between a
successful fetch with suggestions and a successful fetch without suggestions.

There's other telemetry in https://mozilla-hub.atlassian.net/browse/SNT-333 that
this doesn't add. I didn't want to do it all here since some of it is very
different. I'll file new bugs as necessary.

Other changes this makes:

* Factor out weather initialization from test_weather.js into MerinoTestUtils so
  it can also be used in the new browser_telemetry_weather.js
* Copy `updateTopSites()` from the main urlbar head.js to quicksuggest's head.js
* Add some more `info()` logging to the telemetry helpers in head.js

Differential Revision: https://phabricator.services.mozilla.com/D164615
2023-01-06 16:41:49 +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
Drew Willcoxon
05d8fae55e Bug 1804525 - Make weather suggestions blockable. r=daisuke
This makes the weather suggestion blockable. It depends on the new `isBlockable`
payload property added in D163766. The suggestion's row in the view will
automatically get a block button by setting that property.

We don't have an existing browser-chrome test for the block button by itself to
make sure picking it removes the row, so I added a task to
browser_remove_match.js.

The change to test_weather.js makes sure calling `blockResult()` on the provider
correctly disables the `suggest.weather` pref.

Depends on D163766

Differential Revision: https://phabricator.services.mozilla.com/D164120
2022-12-08 16:22:32 +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
Drew Willcoxon
212d13a054 Bug 1803873 - Support row buttons in all row types and make changes to tip rows. r=dao
This makes a couple of large changes:

(1) "Generic" buttons (the ones added by `UrlbarView.#addRowButton()`) are now
supported in all row types. The help button that's currently included in some
types of rows when `result.payload.helpUrl` is defined is now supported for all
row types, and two additional button types are now supported too: block buttons
and labeled buttons. A row will get a block button if its
`result.payload.isBlockable` is defined. It will get a labeled button if
`result.payload.buttons` is defined and non-empty. A button can include a `url`
property that is then added as an attribute on the button's element, and
`UrlbarInput.pickResult()` will use this attribute to load the URL when the
button is picked.

(2) The reason I added labeled buttons is because it lets us support tip buttons
without much more effort, which then lets us get rid of the special row type
used for tips. With this patch, tips are now standard rows that use generic
buttons.

This approach should be compatible with the result menu, when we switch over to
it, because we can include the help and block commands in the menu when
`helpUrl` and `isBlockable` are defined, instead of creating buttons for them.
Labeled buttons -- the ones used in tips -- would still be created. The result
menu button itself can continue to be a generic button.

It should also be compatible with including the result menu button inside the
row selection. We'll still add buttons to `.urlbarView-row`, separate from
`.urlbarView-row-inner`, so that the buttons can continue to be on the right
side of the row. We can color the background of the row instead of the
row-inner.

As with D163630, my motivation for this change is to support generic buttons in
dynamic result rows so that help and block buttons can be easily added to
weather suggestions. Here too the larger changes of supporting generic labeled
buttons and removing special rows for tips aren't strictly necessary, but I took
the opportunity to rework things.

Finally, this makes a few other changes:

* It includes some of the more minor improvements to selection that I made in
  D163630.

* It removes the help URL code from quick actions since it was decided not to
  show a help button. Currently, the button is hidden in CSS, but now that a
  generic help button is added for dynamic result rows when
  `result.payload.helpUrl` is defined, `helpUrl` needs to be removed from the
  payload to prevent a button from being added.

* I removed the special tip wrapping behavior, where the tip button and help
  button would wrap below the tip's text. Instead, now the text wraps inside
  row-inner and the buttons always remain on the same horizontal as the text. I
  don't think it's worth the extra complication.

Differential Revision: https://phabricator.services.mozilla.com/D163766
2022-12-06 18:43:49 -05:00