mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Backed out 2 changesets (bug 1693927, bug 1693126) as requested. CLOSED TREE
Backed out changeset f49147a4544b (bug 1693126) Backed out changeset 8bb5bc9c97b2 (bug 1693927)
This commit is contained in:
parent
9388fa1057
commit
bfcf41eb69
@ -332,10 +332,6 @@ pref("browser.urlbar.suggest.quicksuggest", true);
|
||||
// Whether the QuickSuggest experiment is enabled.
|
||||
pref("browser.urlbar.quicksuggest.enabled", false);
|
||||
|
||||
// The URL for clicks on QuickSuggest help buttons and learn-more links.
|
||||
// TODO (bug 1693671): Replace this URL with the final URL of the blog post.
|
||||
pref("browser.urlbar.quicksuggest.helpURL", "https://www.mozilla.org/");
|
||||
|
||||
// How many times to show the QuickSuggest onboarding help button.
|
||||
pref("browser.urlbar.quicksuggest.onboardingCount", 0);
|
||||
pref("browser.urlbar.quicksuggest.onboardingMaxCount", 5);
|
||||
|
@ -259,9 +259,11 @@ var gSearchPane = {
|
||||
}
|
||||
|
||||
// The experiment is enabled.
|
||||
// TODO (bug 1693671): Replace this URL with the final URL of the blog post.
|
||||
let learnMoreURL = "https://mozilla.org/";
|
||||
document
|
||||
.getElementById("showQuickSuggestLearnMore")
|
||||
.setAttribute("href", UrlbarPrefs.get("quicksuggest.helpURL"));
|
||||
.setAttribute("href", learnMoreURL);
|
||||
container.removeAttribute("hidden");
|
||||
if (desc.dataset.l10nId) {
|
||||
desc.dataset.l10nIdOriginal = desc.dataset.l10nId;
|
||||
|
@ -899,10 +899,11 @@ class TelemetryEvent {
|
||||
let row = element.closest(".urlbarView-row");
|
||||
if (row.result && row.result.providerName != "UrlbarProviderTopSites") {
|
||||
// Element handlers go here.
|
||||
if (element.classList.contains("urlbarView-help")) {
|
||||
return row.result.type == UrlbarUtils.RESULT_TYPE.TIP
|
||||
? "tiphelp"
|
||||
: "help";
|
||||
if (
|
||||
row.result.type == UrlbarUtils.RESULT_TYPE.TIP &&
|
||||
element.classList.contains("urlbarView-help")
|
||||
) {
|
||||
return "tiphelp";
|
||||
}
|
||||
}
|
||||
// Now handle the result.
|
||||
|
@ -168,11 +168,6 @@ const PREF_URLBAR_DEFAULTS = new Map([
|
||||
// Whether the QuickSuggest experiment is enabled.
|
||||
["quicksuggest.enabled", false],
|
||||
|
||||
// The URL for clicks on QuickSuggest help buttons and learn-more links.
|
||||
// TODO (bug 1693671): Replace this URL with the final URL of the blog post,
|
||||
// and don't forget to update firefox.js.
|
||||
["quicksuggest.helpURL", "https://www.mozilla.org/"],
|
||||
|
||||
// The number of times the onboarding help button has been shown in
|
||||
// QuickSuggest results.
|
||||
["quicksuggest.onboardingCount", 0],
|
||||
|
@ -11,7 +11,6 @@ const { XPCOMUtils } = ChromeUtils.import(
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
Services: "resource://gre/modules/Services.jsm",
|
||||
UrlbarPrefs: "resource:///modules/UrlbarPrefs.jsm",
|
||||
UrlbarQuickSuggest: "resource:///modules/UrlbarQuickSuggest.jsm",
|
||||
UrlbarProvider: "resource:///modules/UrlbarUtils.jsm",
|
||||
@ -19,31 +18,20 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
UrlbarUtils: "resource:///modules/UrlbarUtils.jsm",
|
||||
});
|
||||
|
||||
// These prefs are relative to the `browser.urlbar` branch.
|
||||
const EXPERIMENT_PREF = "quicksuggest.enabled";
|
||||
const SUGGEST_PREF = "suggest.quicksuggest";
|
||||
const ONBOARDING_COUNT_PREF = "quicksuggest.onboardingCount";
|
||||
const ONBOARDING_MAX_COUNT_PREF = "quicksuggest.onboardingMaxCount";
|
||||
|
||||
// TODO (bug 1693671): Replace this URL with the final URL of the blog post.
|
||||
const ONBOARDING_URL = "https://mozilla.org/";
|
||||
const ONBOARDING_TEXT = "Learn more about Firefox Suggests";
|
||||
|
||||
const TELEMETRY_SCALAR_IMPRESSION =
|
||||
"contextual.services.quicksuggest.impression";
|
||||
const TELEMETRY_SCALAR_CLICK = "contextual.services.quicksuggest.click";
|
||||
const TELEMETRY_SCALAR_HELP = "contextual.services.quicksuggest.help";
|
||||
|
||||
const TELEMETRY_EVENT_CATEGORY = "contextservices.quicksuggest";
|
||||
|
||||
/**
|
||||
* A provider that returns a suggested url to the user based on what
|
||||
* they have currently typed so they can navigate directly.
|
||||
*/
|
||||
class ProviderQuickSuggest extends UrlbarProvider {
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
this._updateExperimentState();
|
||||
UrlbarPrefs.addObserver(this);
|
||||
}
|
||||
// Whether we added a result during the most recent query.
|
||||
_addedResultInLastQuery = false;
|
||||
|
||||
/**
|
||||
* Returns the name of this provider.
|
||||
@ -82,8 +70,8 @@ class ProviderQuickSuggest extends UrlbarProvider {
|
||||
return (
|
||||
queryContext.trimmedSearchString &&
|
||||
!queryContext.searchMode &&
|
||||
UrlbarPrefs.get(EXPERIMENT_PREF) &&
|
||||
UrlbarPrefs.get(SUGGEST_PREF) &&
|
||||
UrlbarPrefs.get("quicksuggest.enabled") &&
|
||||
UrlbarPrefs.get("suggest.quicksuggest") &&
|
||||
UrlbarPrefs.get("suggest.searches") &&
|
||||
UrlbarPrefs.get("browser.search.suggest.enabled") &&
|
||||
(!queryContext.isPrivate ||
|
||||
@ -115,7 +103,7 @@ class ProviderQuickSuggest extends UrlbarProvider {
|
||||
|
||||
// Show the help button if we haven't reached the max onboarding count yet.
|
||||
if (this._onboardingCount < this._onboardingMaxCount) {
|
||||
payload.helpUrl = UrlbarPrefs.get("quicksuggest.helpURL");
|
||||
payload.helpUrl = ONBOARDING_URL;
|
||||
payload.helpTitle = ONBOARDING_TEXT;
|
||||
}
|
||||
|
||||
@ -151,91 +139,16 @@ class ProviderQuickSuggest extends UrlbarProvider {
|
||||
* it describes the search string and picked result.
|
||||
*/
|
||||
onEngagement(isPrivate, state, queryContext, details) {
|
||||
if (!this._addedResultInLastQuery) {
|
||||
return;
|
||||
}
|
||||
this._addedResultInLastQuery = false;
|
||||
|
||||
// Per spec, we update the onboarding count and telemetry only when the user
|
||||
// picks a result, i.e., when `state` is "engagement".
|
||||
if (state != "engagement") {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the index of the quick suggest result.
|
||||
let resultIndex = queryContext.results.length - 1;
|
||||
let lastResult = queryContext.results[resultIndex];
|
||||
if (!lastResult?.payload.isSponsored) {
|
||||
Cu.reportError(`Last result is not a quick suggest`);
|
||||
return;
|
||||
}
|
||||
|
||||
// Increment the onboarding count.
|
||||
if (this._onboardingCount < this._onboardingMaxCount) {
|
||||
if (
|
||||
state == "engagement" &&
|
||||
this._addedResultInLastQuery &&
|
||||
this._onboardingCount < this._onboardingMaxCount
|
||||
) {
|
||||
this._onboardingCount++;
|
||||
}
|
||||
|
||||
// Record telemetry. We want to record the 1-based index of the result, so
|
||||
// add 1 to the 0-based resultIndex.
|
||||
let telemetryResultIndex = resultIndex + 1;
|
||||
|
||||
// impression scalar
|
||||
Services.telemetry.keyedScalarAdd(
|
||||
TELEMETRY_SCALAR_IMPRESSION,
|
||||
telemetryResultIndex,
|
||||
1
|
||||
);
|
||||
|
||||
if (details.selIndex == resultIndex) {
|
||||
// click or help scalar
|
||||
Services.telemetry.keyedScalarAdd(
|
||||
details.selType == "help"
|
||||
? TELEMETRY_SCALAR_HELP
|
||||
: TELEMETRY_SCALAR_CLICK,
|
||||
telemetryResultIndex,
|
||||
1
|
||||
);
|
||||
}
|
||||
this._addedResultInLastQuery = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a urlbar pref changes. We use this to listen for changes to
|
||||
* `browser.urlbar.suggest.quicksuggest` so we can record a telemetry event.
|
||||
* We also need to listen for `browser.urlbar.quicksuggest.enabled` so we can
|
||||
* enable/disable the event telemetry.
|
||||
*
|
||||
* @param {string} pref
|
||||
* The name of the pref relative to `browser.urlbar`.
|
||||
*/
|
||||
onPrefChanged(pref) {
|
||||
switch (pref) {
|
||||
case EXPERIMENT_PREF:
|
||||
this._updateExperimentState();
|
||||
break;
|
||||
case SUGGEST_PREF:
|
||||
Services.telemetry.recordEvent(
|
||||
TELEMETRY_EVENT_CATEGORY,
|
||||
"enable_toggled",
|
||||
UrlbarPrefs.get(SUGGEST_PREF) ? "enabled" : "disabled"
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates state based on the `browser.urlbar.quicksuggest.enabled` pref.
|
||||
* Right now we only need to enable/disable event telemetry.
|
||||
*/
|
||||
_updateExperimentState() {
|
||||
Services.telemetry.setEventRecordingEnabled(
|
||||
TELEMETRY_EVENT_CATEGORY,
|
||||
UrlbarPrefs.get(EXPERIMENT_PREF)
|
||||
);
|
||||
}
|
||||
|
||||
// Whether we added a result during the most recent query.
|
||||
_addedResultInLastQuery = false;
|
||||
|
||||
get _onboardingCount() {
|
||||
return UrlbarPrefs.get(ONBOARDING_COUNT_PREF);
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ Event Extra
|
||||
``history``, ``keyword``, ``searchengine``, ``searchsuggestion``,
|
||||
``switchtab``, ``remotetab``, ``extension``, ``oneoff``, ``keywordoffer``,
|
||||
``canonized``, ``tip``, ``tiphelp``, ``formhistory``, ``tabtosearch``,
|
||||
``help``, ``unknown``
|
||||
``unknown``
|
||||
In practice, ``tabtosearch`` should not appear in real event telemetry.
|
||||
Opening a tab-to-search result enters search mode and entering search mode
|
||||
does not currently mark the end of an engagement. It is noted here for
|
||||
@ -413,8 +413,8 @@ TopSites Click
|
||||
User's current locale.
|
||||
|
||||
|
||||
Other telemetry relevant to the Address Bar
|
||||
-------------------------------------------
|
||||
Search probes relevant to the Address Bar
|
||||
-----------------------------------------
|
||||
|
||||
SEARCH_COUNTS
|
||||
This histogram tracks search engines and Search Access Points. It is augmented
|
||||
@ -484,47 +484,6 @@ contextual.services.topsites.*
|
||||
impression or click.
|
||||
Note that these scalars are shared with the TopSites on the newtab page.
|
||||
|
||||
contextual.services.quicksuggest.*
|
||||
These keyed scalars record impressions and clicks on Quick Suggest results,
|
||||
also called Firefox Suggests results, in the address bar. The keys for each
|
||||
scalar are the 1-based indexes of the Quick Suggest results, and the values
|
||||
are the number of impressions or clicks for the corresponding indexes. For
|
||||
example, for a Quick Suggest impression at 0-based index 9, the value for key
|
||||
``10`` will be incremented in the
|
||||
``contextual.services.quicksuggest.impression`` scalar.
|
||||
|
||||
The keyed scalars are:
|
||||
|
||||
- ``contextual.services.quicksuggest.impression``
|
||||
Incremented when a Quick Suggest result is shown in an address bar
|
||||
engagement where the user picks any result. The particular picked result
|
||||
doesn't matter, and it doesn't need to be the Quick Suggest result.
|
||||
- ``contextual.services.quicksuggest.click``
|
||||
Incremented when the user picks a Quick Suggest result (not including the
|
||||
help button).
|
||||
- ``contextual.services.quicksuggest.help``
|
||||
Incremented when the user picks the onboarding help button in a Quick
|
||||
Suggest result.
|
||||
|
||||
contextservices.quicksuggest
|
||||
This is event telemetry under the ``contextservices.quicksuggest`` category.
|
||||
It's enabled only when the ``browser.urlbar.quicksuggest.enabled`` pref is
|
||||
true. An event is recorded when the user toggles the
|
||||
``browser.urlbar.suggest.quicksuggest`` pref, which corresponds to the
|
||||
checkbox in about:preferences#search labeled "Show suggested and sponsored
|
||||
results in the address bar". If the user never toggles the pref, then this
|
||||
event is never recorded.
|
||||
|
||||
The full spec for this event is:
|
||||
|
||||
- Category: ``contextservices.quicksuggest``
|
||||
- Method: ``enable_toggled``
|
||||
- Objects: ``enabled``, ``disabled`` -- ``enabled`` is recorded when the
|
||||
pref is flipped from false to true, and ``disabled`` is recorded when the
|
||||
pref is flipped from true to false.
|
||||
- Value: Not used
|
||||
- Extra: Not used
|
||||
|
||||
Obsolete probes
|
||||
---------------
|
||||
|
||||
|
@ -200,7 +200,6 @@ var UrlbarTestUtils = {
|
||||
details.image = element.getElementsByClassName("urlbarView-favicon")[0].src;
|
||||
details.title = result.title;
|
||||
details.tags = "tags" in result.payload ? result.payload.tags : [];
|
||||
details.isSponsored = result.payload.isSponsored;
|
||||
let actions = element.getElementsByClassName("urlbarView-action");
|
||||
let urls = element.getElementsByClassName("urlbarView-url");
|
||||
let typeIcon = element.querySelector(".urlbarView-type-icon");
|
||||
|
@ -263,8 +263,6 @@ support-files =
|
||||
tags = search-telemetry
|
||||
[browser_urlbar_telemetry_places.js]
|
||||
tags = search-telemetry
|
||||
[browser_urlbar_telemetry_quicksuggest.js]
|
||||
tags = search-telemetry
|
||||
[browser_urlbar_telemetry_remotetab.js]
|
||||
tags = search-telemetry
|
||||
[browser_urlbar_telemetry_searchmode.js]
|
||||
|
@ -54,7 +54,11 @@ async function assertIsQuickSuggest(index = -1, win = window) {
|
||||
let result = await UrlbarTestUtils.getDetailsOfResultAt(win, index);
|
||||
Assert.equal(result.type, UrlbarUtils.RESULT_TYPE.URL);
|
||||
Assert.equal(result.url, `${TEST_URL}?q=frabbits`);
|
||||
Assert.ok(result.isSponsored, "Result isSponsored");
|
||||
|
||||
if (result.url != `${TEST_URL}?q=frabbits`) {
|
||||
await new Promise(r => {});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -65,9 +69,7 @@ async function assertNoQuickSuggestResults() {
|
||||
for (let i = 0; i < UrlbarTestUtils.getResultCount(window); i++) {
|
||||
let r = await UrlbarTestUtils.getDetailsOfResultAt(window, i);
|
||||
Assert.ok(
|
||||
r.type != UrlbarUtils.RESULT_TYPE.URL ||
|
||||
!r.url.includes(TEST_URL) ||
|
||||
!r.isSponsored,
|
||||
r.type != UrlbarUtils.RESULT_TYPE.URL || !r.url.includes(TEST_URL),
|
||||
`Result at index ${i} should not be a QuickSuggest result`
|
||||
);
|
||||
}
|
||||
|
@ -52,8 +52,6 @@ class TestProvider extends UrlbarTestUtils.TestProvider {
|
||||
}
|
||||
|
||||
add_task(async function test() {
|
||||
UrlbarTestUtils.init(this);
|
||||
|
||||
// Add a dynamic result type.
|
||||
UrlbarResult.addDynamicResultType(DYNAMIC_TYPE_NAME);
|
||||
UrlbarView.addDynamicViewTemplate(DYNAMIC_TYPE_NAME, {
|
||||
|
@ -119,8 +119,6 @@ add_task(async function setup() {
|
||||
await PlacesUtils.history.clear();
|
||||
await PlacesUtils.bookmarks.eraseEverything();
|
||||
|
||||
UrlbarTestUtils.init(this);
|
||||
|
||||
// Make sure to restore the engine once we're done.
|
||||
registerCleanupFunction(async function() {
|
||||
Services.telemetry.canRecordExtended = oldCanRecord;
|
||||
|
@ -139,8 +139,6 @@ add_task(async function setup() {
|
||||
url: TEST_URL + "?q=%s",
|
||||
});
|
||||
|
||||
UrlbarTestUtils.init(this);
|
||||
|
||||
// Make sure to restore the engine once we're done.
|
||||
registerCleanupFunction(async function() {
|
||||
await PlacesUtils.keywords.remove("get");
|
||||
|
@ -1,322 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* This file tests urlbar telemetry for Quick Suggest results.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
UrlbarQuickSuggest: "resource:///modules/UrlbarQuickSuggest.jsm",
|
||||
});
|
||||
|
||||
const TEST_SJS =
|
||||
"http://mochi.test:8888/browser/browser/components/urlbar/tests/browser/quicksuggest.sjs";
|
||||
const TEST_URL = TEST_SJS + "?q=frabbits";
|
||||
const TEST_SEARCH_STRING = "frab";
|
||||
const TEST_DATA = [
|
||||
{
|
||||
id: 1,
|
||||
url: TEST_URL,
|
||||
title: "frabbits",
|
||||
keywords: [TEST_SEARCH_STRING],
|
||||
},
|
||||
];
|
||||
|
||||
const TEST_HELP_URL = "http://example.com/help";
|
||||
|
||||
const TELEMETRY_SCALARS = {
|
||||
IMPRESSION: "contextual.services.quicksuggest.impression",
|
||||
CLICK: "contextual.services.quicksuggest.click",
|
||||
HELP: "contextual.services.quicksuggest.help",
|
||||
};
|
||||
|
||||
const TELEMETRY_EVENT_CATEGORY = "contextservices.quicksuggest";
|
||||
|
||||
const EXPERIMENT_PREF = "browser.urlbar.quicksuggest.enabled";
|
||||
const SUGGEST_PREF = "suggest.quicksuggest";
|
||||
const ONBOARDING_COUNT_PREF = "quicksuggest.onboardingCount";
|
||||
|
||||
add_task(async function init() {
|
||||
await PlacesUtils.history.clear();
|
||||
await UrlbarTestUtils.formHistory.clear();
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
[EXPERIMENT_PREF, true],
|
||||
["browser.urlbar.quicksuggest.helpURL", TEST_HELP_URL],
|
||||
["browser.urlbar.suggest.searches", true],
|
||||
],
|
||||
});
|
||||
|
||||
// Add a mock engine so we don't hit the network.
|
||||
let engine = await Services.search.addEngineWithDetails("Test", {
|
||||
template: "http://example.com/?search={searchTerms}",
|
||||
});
|
||||
let oldDefaultEngine = await Services.search.getDefault();
|
||||
Services.search.setDefault(engine);
|
||||
|
||||
// Set up Quick Suggest.
|
||||
await UrlbarQuickSuggest.init();
|
||||
await UrlbarQuickSuggest._processSuggestionsJSON(TEST_DATA);
|
||||
|
||||
// Enable local telemetry recording for the duration of the test.
|
||||
let oldCanRecord = Services.telemetry.canRecordExtended;
|
||||
Services.telemetry.canRecordExtended = true;
|
||||
|
||||
Services.telemetry.clearScalars();
|
||||
|
||||
UrlbarTestUtils.init(this);
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
Services.search.setDefault(oldDefaultEngine);
|
||||
await Services.search.removeEngine(engine);
|
||||
Services.telemetry.canRecordExtended = oldCanRecord;
|
||||
});
|
||||
});
|
||||
|
||||
// Tests the impression scalar.
|
||||
add_task(async function impression() {
|
||||
await BrowserTestUtils.withNewTab("about:blank", async () => {
|
||||
await UrlbarTestUtils.promiseAutocompleteResultPopup({
|
||||
window,
|
||||
value: TEST_SEARCH_STRING,
|
||||
fireInputEvent: true,
|
||||
});
|
||||
let index = 1;
|
||||
await assertIsQuickSuggest(index);
|
||||
await UrlbarTestUtils.promisePopupClose(window, () => {
|
||||
EventUtils.synthesizeKey("KEY_Enter");
|
||||
});
|
||||
assertScalars({ [TELEMETRY_SCALARS.IMPRESSION]: index + 1 });
|
||||
});
|
||||
});
|
||||
|
||||
// Makes sure the impression scalar is not incremented when the urlbar
|
||||
// engagement is abandoned.
|
||||
add_task(async function noImpression_abandonment() {
|
||||
await BrowserTestUtils.withNewTab("about:blank", async () => {
|
||||
await UrlbarTestUtils.promiseAutocompleteResultPopup({
|
||||
window,
|
||||
value: TEST_SEARCH_STRING,
|
||||
fireInputEvent: true,
|
||||
});
|
||||
await assertIsQuickSuggest();
|
||||
await UrlbarTestUtils.promisePopupClose(window, () => {
|
||||
gURLBar.blur();
|
||||
});
|
||||
assertScalars({});
|
||||
});
|
||||
});
|
||||
|
||||
// Makes sure the impression scalar is not incremented when a Quick Suggest
|
||||
// result is not present.
|
||||
add_task(async function noImpression_noQuickSuggestResult() {
|
||||
await BrowserTestUtils.withNewTab("about:blank", async () => {
|
||||
await UrlbarTestUtils.promiseAutocompleteResultPopup({
|
||||
window,
|
||||
value: "noImpression_noQuickSuggestResult",
|
||||
fireInputEvent: true,
|
||||
});
|
||||
await assertNoQuickSuggestResults();
|
||||
await UrlbarTestUtils.promisePopupClose(window, () => {
|
||||
EventUtils.synthesizeKey("KEY_Enter");
|
||||
});
|
||||
assertScalars({});
|
||||
});
|
||||
});
|
||||
|
||||
// Tests the click scalar by picking a Quick Suggest result with the keyboard.
|
||||
add_task(async function click_keyboard() {
|
||||
await BrowserTestUtils.withNewTab("about:blank", async () => {
|
||||
await UrlbarTestUtils.promiseAutocompleteResultPopup({
|
||||
window,
|
||||
value: TEST_SEARCH_STRING,
|
||||
fireInputEvent: true,
|
||||
});
|
||||
let index = 1;
|
||||
await assertIsQuickSuggest(index);
|
||||
await UrlbarTestUtils.promisePopupClose(window, () => {
|
||||
EventUtils.synthesizeKey("KEY_ArrowDown");
|
||||
EventUtils.synthesizeKey("KEY_Enter");
|
||||
});
|
||||
assertScalars({
|
||||
[TELEMETRY_SCALARS.IMPRESSION]: index + 1,
|
||||
[TELEMETRY_SCALARS.CLICK]: index + 1,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Tests the click scalar by picking a Quick Suggest result with the mouse.
|
||||
add_task(async function click_mouse() {
|
||||
await BrowserTestUtils.withNewTab("about:blank", async () => {
|
||||
await UrlbarTestUtils.promiseAutocompleteResultPopup({
|
||||
window,
|
||||
value: TEST_SEARCH_STRING,
|
||||
fireInputEvent: true,
|
||||
});
|
||||
let index = 1;
|
||||
let result = await assertIsQuickSuggest(index);
|
||||
await UrlbarTestUtils.promisePopupClose(window, () => {
|
||||
EventUtils.synthesizeMouseAtCenter(result.element.row, {});
|
||||
});
|
||||
assertScalars({
|
||||
[TELEMETRY_SCALARS.IMPRESSION]: index + 1,
|
||||
[TELEMETRY_SCALARS.CLICK]: index + 1,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Tests the help scalar by picking a Quick Suggest result help button with the
|
||||
// keyboard.
|
||||
add_task(async function help_keyboard() {
|
||||
UrlbarPrefs.clear(ONBOARDING_COUNT_PREF);
|
||||
await BrowserTestUtils.withNewTab("about:blank", async () => {
|
||||
await UrlbarTestUtils.promiseAutocompleteResultPopup({
|
||||
window,
|
||||
value: TEST_SEARCH_STRING,
|
||||
fireInputEvent: true,
|
||||
});
|
||||
let index = 1;
|
||||
let result = await assertIsQuickSuggest(index);
|
||||
let helpButton = result.element.row._elements.get("helpButton");
|
||||
Assert.ok(helpButton, "The result has an onboarding help button");
|
||||
let helpLoadPromise = BrowserTestUtils.browserLoaded(
|
||||
gBrowser.selectedBrowser
|
||||
);
|
||||
await UrlbarTestUtils.promisePopupClose(window, () => {
|
||||
EventUtils.synthesizeKey("KEY_ArrowDown", { repeat: 2 });
|
||||
EventUtils.synthesizeKey("KEY_Enter");
|
||||
});
|
||||
await helpLoadPromise;
|
||||
Assert.equal(gBrowser.currentURI.spec, TEST_HELP_URL, "Help URL loaded");
|
||||
assertScalars({
|
||||
[TELEMETRY_SCALARS.IMPRESSION]: index + 1,
|
||||
[TELEMETRY_SCALARS.HELP]: index + 1,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Tests the help scalar by picking a Quick Suggest result help button with the
|
||||
// mouse.
|
||||
add_task(async function help_mouse() {
|
||||
UrlbarPrefs.clear(ONBOARDING_COUNT_PREF);
|
||||
await BrowserTestUtils.withNewTab("about:blank", async () => {
|
||||
await UrlbarTestUtils.promiseAutocompleteResultPopup({
|
||||
window,
|
||||
value: TEST_SEARCH_STRING,
|
||||
fireInputEvent: true,
|
||||
});
|
||||
let index = 1;
|
||||
let result = await assertIsQuickSuggest(index);
|
||||
let helpButton = result.element.row._elements.get("helpButton");
|
||||
Assert.ok(helpButton, "The result has an onboarding help button");
|
||||
let helpLoadPromise = BrowserTestUtils.browserLoaded(
|
||||
gBrowser.selectedBrowser
|
||||
);
|
||||
await UrlbarTestUtils.promisePopupClose(window, () => {
|
||||
EventUtils.synthesizeMouseAtCenter(helpButton, {});
|
||||
});
|
||||
await helpLoadPromise;
|
||||
Assert.equal(gBrowser.currentURI.spec, TEST_HELP_URL, "Help URL loaded");
|
||||
assertScalars({
|
||||
[TELEMETRY_SCALARS.IMPRESSION]: index + 1,
|
||||
[TELEMETRY_SCALARS.HELP]: index + 1,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Tests the contextservices.quicksuggest enable_toggled event telemetry by
|
||||
// toggling the suggest.quicksuggest pref.
|
||||
add_task(async function enableToggled() {
|
||||
Services.telemetry.clearEvents();
|
||||
|
||||
// Toggle the suggest.quicksuggest pref twice. We should get two events.
|
||||
let enabled = UrlbarPrefs.get(SUGGEST_PREF);
|
||||
for (let i = 0; i < 2; i++) {
|
||||
enabled = !enabled;
|
||||
UrlbarPrefs.set(SUGGEST_PREF, enabled);
|
||||
TelemetryTestUtils.assertEvents([
|
||||
{
|
||||
category: TELEMETRY_EVENT_CATEGORY,
|
||||
method: "enable_toggled",
|
||||
object: enabled ? "enabled" : "disabled",
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
// Set the main quicksuggest.enabled pref to false and toggle the
|
||||
// suggest.quicksuggest pref again. We shouldn't get any events.
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [[EXPERIMENT_PREF, false]],
|
||||
});
|
||||
enabled = !enabled;
|
||||
UrlbarPrefs.set(SUGGEST_PREF, enabled);
|
||||
TelemetryTestUtils.assertEvents([], { category: TELEMETRY_EVENT_CATEGORY });
|
||||
await SpecialPowers.popPrefEnv();
|
||||
|
||||
UrlbarPrefs.clear(SUGGEST_PREF);
|
||||
});
|
||||
|
||||
/**
|
||||
* Checks the values of all the Quick Suggest scalars.
|
||||
*
|
||||
* @param {object} expectedIndexesByScalarName
|
||||
* Maps scalar names to the expected 1-based indexes of results. If you
|
||||
* expect a scalar to be incremented, then include it in this object. If you
|
||||
* expect a scalar not to be incremented, don't include it.
|
||||
*/
|
||||
function assertScalars(expectedIndexesByScalarName) {
|
||||
let scalars = TelemetryTestUtils.getProcessScalars("parent", true, true);
|
||||
for (let scalarName of Object.values(TELEMETRY_SCALARS)) {
|
||||
if (scalarName in expectedIndexesByScalarName) {
|
||||
TelemetryTestUtils.assertKeyedScalar(
|
||||
scalars,
|
||||
scalarName,
|
||||
expectedIndexesByScalarName[scalarName],
|
||||
1
|
||||
);
|
||||
} else {
|
||||
Assert.ok(
|
||||
!(scalarName in scalars),
|
||||
"Scalar should not be present: " + scalarName
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that a result is a Quick Suggest result.
|
||||
*
|
||||
* @param {number} [index]
|
||||
* The expected index of the Quick Suggest result. Pass -1 to use the index
|
||||
* of the last result.
|
||||
* @returns {result}
|
||||
* The result at the given index.
|
||||
*/
|
||||
async function assertIsQuickSuggest(index = -1) {
|
||||
if (index < 0) {
|
||||
index = UrlbarTestUtils.getResultCount(window) - 1;
|
||||
Assert.greater(index, -1, "Sanity check: Result count should be > 0");
|
||||
}
|
||||
let result = await UrlbarTestUtils.getDetailsOfResultAt(window, index);
|
||||
Assert.equal(result.type, UrlbarUtils.RESULT_TYPE.URL, "Result type");
|
||||
Assert.equal(result.url, TEST_URL, "Result URL");
|
||||
Assert.ok(result.isSponsored, "Result isSponsored");
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that none of the results are Quick Suggest results.
|
||||
*/
|
||||
async function assertNoQuickSuggestResults() {
|
||||
for (let i = 0; i < UrlbarTestUtils.getResultCount(window); i++) {
|
||||
let r = await UrlbarTestUtils.getDetailsOfResultAt(window, i);
|
||||
Assert.ok(
|
||||
r.type != UrlbarUtils.RESULT_TYPE.URL ||
|
||||
!r.url.includes(TEST_URL) ||
|
||||
!r.isSponsored,
|
||||
`Result at index ${i} should not be a QuickSuggest result`
|
||||
);
|
||||
}
|
||||
}
|
@ -166,8 +166,6 @@ add_task(async function setup() {
|
||||
.stub(SyncedTabs._internal, "getTabClients")
|
||||
.callsFake(() => Promise.resolve(Cu.cloneInto([REMOTE_TAB], {})));
|
||||
|
||||
UrlbarTestUtils.init(this);
|
||||
|
||||
// Make sure to restore the engine once we're done.
|
||||
registerCleanupFunction(async function() {
|
||||
sandbox.restore();
|
||||
|
@ -72,7 +72,6 @@ add_task(async function setup() {
|
||||
});
|
||||
await PlacesUtils.history.clear();
|
||||
await PlacesUtils.bookmarks.eraseEverything();
|
||||
UrlbarTestUtils.init(this);
|
||||
});
|
||||
|
||||
add_task(async function test() {
|
||||
|
@ -102,8 +102,6 @@ add_task(async function setup() {
|
||||
});
|
||||
|
||||
add_task(async function test() {
|
||||
UrlbarTestUtils.init(this);
|
||||
|
||||
await BrowserTestUtils.withNewTab("about:blank", async () => {
|
||||
let sites = AboutNewTab.getTopSites();
|
||||
Assert.equal(
|
||||
|
@ -2720,18 +2720,3 @@ installation:
|
||||
- agashlin@mozilla.com
|
||||
- rtestard@mozilla.com
|
||||
expiry_version: "94"
|
||||
|
||||
contextservices.quicksuggest:
|
||||
enable_toggled:
|
||||
objects: ["enabled", "disabled"]
|
||||
release_channel_collection: opt-out
|
||||
products:
|
||||
- "firefox"
|
||||
record_in_processes: ["main"]
|
||||
description: >
|
||||
This is recorded when the `browser.urlbar.suggest.quicksuggest` boolean
|
||||
pref is toggled.
|
||||
bug_numbers: [1693126]
|
||||
notification_emails:
|
||||
- fx-search@mozilla.com
|
||||
expiry_version: never
|
||||
|
@ -6719,60 +6719,6 @@ contextual.services.topsites:
|
||||
- main
|
||||
|
||||
|
||||
contextual.services.quicksuggest:
|
||||
impression:
|
||||
bug_numbers:
|
||||
- 1693927
|
||||
description: >
|
||||
A keyed uint recording how many times the user has viewed Firefox Suggests
|
||||
(a.k.a. Quick Suggest) results in the urlbar. The key is the 1-based index
|
||||
of each result.
|
||||
expires: never
|
||||
kind: uint
|
||||
keyed: true
|
||||
notification_emails:
|
||||
- najiang@mozilla.com
|
||||
release_channel_collection: opt-out
|
||||
products:
|
||||
- 'firefox'
|
||||
record_in_processes:
|
||||
- main
|
||||
click:
|
||||
bug_numbers:
|
||||
- 1693927
|
||||
description: >
|
||||
A keyed uint recording how many times the user has clicked on Firefox
|
||||
Suggests (a.k.a. Quick Suggest) results in the urlbar (not including the
|
||||
help button). The key is the 1-based index of each result.
|
||||
expires: never
|
||||
kind: uint
|
||||
keyed: true
|
||||
notification_emails:
|
||||
- najiang@mozilla.com
|
||||
release_channel_collection: opt-out
|
||||
products:
|
||||
- 'firefox'
|
||||
record_in_processes:
|
||||
- main
|
||||
help:
|
||||
bug_numbers:
|
||||
- 1693927
|
||||
description: >
|
||||
A keyed uint recording how many times the user has clicked on the help
|
||||
button in Firefox Suggests (a.k.a. Quick Suggest) results in the urlbar.
|
||||
The key is the 1-based index of each result.
|
||||
expires: never
|
||||
kind: uint
|
||||
keyed: true
|
||||
notification_emails:
|
||||
- najiang@mozilla.com
|
||||
release_channel_collection: opt-out
|
||||
products:
|
||||
- 'firefox'
|
||||
record_in_processes:
|
||||
- main
|
||||
|
||||
|
||||
# The following section is for probes testing the Telemetry system. They will not be
|
||||
# submitted in pings and are only used for testing.
|
||||
telemetry.test:
|
||||
|
Loading…
Reference in New Issue
Block a user