mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 00:35:44 +00:00
Bug 1617631
- Add a topsite type to the FX_URLBAR_SELECTED_RESULT_(TYPE/INDEX_BY_TYPE) histograms. r=adw
Differential Revision: https://phabricator.services.mozilla.com/D64158 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
b115b5f0b9
commit
ba8dcdc6b4
@ -550,6 +550,11 @@ class UrlbarController {
|
||||
Cu.reportError(`Unknown Result Type ${result.type}`);
|
||||
return;
|
||||
}
|
||||
// The "topsite" type overrides the above ones, because it starts from a
|
||||
// unique user interaction, that we want to count apart.
|
||||
if (result.providerName == "UrlbarProviderTopSites") {
|
||||
telemetryType = "topsite";
|
||||
}
|
||||
|
||||
Services.telemetry
|
||||
.getHistogramById("FX_URLBAR_SELECTED_RESULT_INDEX")
|
||||
|
@ -68,6 +68,7 @@ FX_URLBAR_SELECTED_RESULT_TYPE
|
||||
10. extension
|
||||
11. preloaded-top-site
|
||||
12. tip
|
||||
13. topsite
|
||||
|
||||
FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE
|
||||
This probe tracks picked result type, for each one it tracks the index where
|
||||
|
@ -95,6 +95,9 @@ const URLBAR_SELECTED_RESULT_TYPES = {
|
||||
extension: 10,
|
||||
"preloaded-top-site": 11,
|
||||
tip: 12,
|
||||
topsite: 13,
|
||||
// There's no more space in this histogram, next addition must define a new
|
||||
// one.
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -48,6 +48,7 @@ skip-if = verify && debug
|
||||
[browser_UsageTelemetry_urlbar_places.js]
|
||||
[browser_UsageTelemetry_urlbar_remotetab.js]
|
||||
[browser_UsageTelemetry_urlbar_tip.js]
|
||||
[browser_UsageTelemetry_urlbar_topsite.js]
|
||||
[browser_UsageTelemetry_urlbar.js]
|
||||
support-files =
|
||||
usageTelemetrySearchSuggestions.sjs
|
||||
|
@ -0,0 +1,148 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
/**
|
||||
* This file tests urlbar telemetry for topsite results.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
AboutNewTab: "resource:///modules/AboutNewTab.jsm",
|
||||
UrlbarTestUtils: "resource://testing-common/UrlbarTestUtils.jsm",
|
||||
URLBAR_SELECTED_RESULT_TYPES: "resource:///modules/BrowserUsageTelemetry.jsm",
|
||||
URLBAR_SELECTED_RESULT_METHODS:
|
||||
"resource:///modules/BrowserUsageTelemetry.jsm",
|
||||
});
|
||||
|
||||
const EN_US_TOPSITES =
|
||||
"https://www.youtube.com/,https://www.facebook.com/,https://www.amazon.com/,https://www.reddit.com/,https://www.wikipedia.org/,https://twitter.com/";
|
||||
|
||||
function snapshotHistograms() {
|
||||
Services.telemetry.clearScalars();
|
||||
Services.telemetry.clearEvents();
|
||||
return {
|
||||
resultIndexHist: TelemetryTestUtils.getAndClearHistogram(
|
||||
"FX_URLBAR_SELECTED_RESULT_INDEX"
|
||||
),
|
||||
resultTypeHist: TelemetryTestUtils.getAndClearHistogram(
|
||||
"FX_URLBAR_SELECTED_RESULT_TYPE"
|
||||
),
|
||||
resultIndexByTypeHist: TelemetryTestUtils.getAndClearKeyedHistogram(
|
||||
"FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE"
|
||||
),
|
||||
resultMethodHist: TelemetryTestUtils.getAndClearHistogram(
|
||||
"FX_URLBAR_SELECTED_RESULT_METHOD"
|
||||
),
|
||||
search_hist: TelemetryTestUtils.getAndClearKeyedHistogram("SEARCH_COUNTS"),
|
||||
};
|
||||
}
|
||||
|
||||
function assertHistogramResults(histograms, type, index, method) {
|
||||
TelemetryTestUtils.assertHistogram(histograms.resultIndexHist, index, 1);
|
||||
|
||||
TelemetryTestUtils.assertHistogram(
|
||||
histograms.resultTypeHist,
|
||||
URLBAR_SELECTED_RESULT_TYPES[type],
|
||||
1
|
||||
);
|
||||
|
||||
TelemetryTestUtils.assertKeyedHistogramValue(
|
||||
histograms.resultIndexByTypeHist,
|
||||
type,
|
||||
index,
|
||||
1
|
||||
);
|
||||
|
||||
TelemetryTestUtils.assertHistogram(histograms.resultMethodHist, method, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the Top Sites feed.
|
||||
* @param {function} condition
|
||||
* A callback that returns true after Top Sites are successfully updated.
|
||||
* @param {boolean} searchShortcuts
|
||||
* True if Top Sites search shortcuts should be enabled.
|
||||
*/
|
||||
async function updateTopSites(condition, searchShortcuts = false) {
|
||||
// Toggle the pref to clear the feed cache and force an update.
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.newtabpage.activity-stream.feeds.topsites", false],
|
||||
["browser.newtabpage.activity-stream.feeds.topsites", true],
|
||||
[
|
||||
"browser.newtabpage.activity-stream.improvesearch.topSiteSearchShortcuts",
|
||||
searchShortcuts,
|
||||
],
|
||||
],
|
||||
});
|
||||
|
||||
// Wait for the feed to be updated.
|
||||
await TestUtils.waitForCondition(() => {
|
||||
let sites = AboutNewTab.getTopSites();
|
||||
return condition(sites);
|
||||
}, "Waiting for top sites to be updated");
|
||||
}
|
||||
|
||||
add_task(async function setup() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.urlbar.update1", true],
|
||||
["browser.urlbar.openViewOnFocus", true],
|
||||
["browser.newtabpage.activity-stream.default.sites", EN_US_TOPSITES],
|
||||
],
|
||||
});
|
||||
await updateTopSites(
|
||||
sites => sites && sites.length == EN_US_TOPSITES.split(",").length
|
||||
);
|
||||
});
|
||||
|
||||
add_task(async function test() {
|
||||
await BrowserTestUtils.withNewTab("about:blank", async () => {
|
||||
let sites = AboutNewTab.getTopSites();
|
||||
Assert.equal(
|
||||
sites.length,
|
||||
6,
|
||||
"The test suite browser should have 6 Top Sites."
|
||||
);
|
||||
|
||||
const histograms = snapshotHistograms();
|
||||
|
||||
await UrlbarTestUtils.promisePopupOpen(window, () => {
|
||||
EventUtils.synthesizeMouseAtCenter(window.gURLBar.inputField, {});
|
||||
});
|
||||
|
||||
await UrlbarTestUtils.promiseSearchComplete(window);
|
||||
Assert.equal(
|
||||
UrlbarTestUtils.getResultCount(window),
|
||||
sites.length,
|
||||
"The number of results should be the same as the number of Top Sites (6)."
|
||||
);
|
||||
// Select the first resultm and confirm it.
|
||||
let result = await UrlbarTestUtils.getDetailsOfResultAt(window, 0);
|
||||
EventUtils.synthesizeKey("KEY_ArrowDown");
|
||||
Assert.equal(
|
||||
UrlbarTestUtils.getSelectedRowIndex(window),
|
||||
0,
|
||||
"The first result should be selected"
|
||||
);
|
||||
|
||||
let loadPromise = BrowserTestUtils.waitForDocLoadAndStopIt(
|
||||
result.url,
|
||||
gBrowser.selectedBrowser
|
||||
);
|
||||
EventUtils.synthesizeKey("KEY_Enter");
|
||||
await loadPromise;
|
||||
|
||||
assertHistogramResults(
|
||||
histograms,
|
||||
"topsite",
|
||||
0,
|
||||
URLBAR_SELECTED_RESULT_METHODS.arrowEnterSelection
|
||||
);
|
||||
await UrlbarTestUtils.promisePopupClose(window, () => {
|
||||
window.gURLBar.blur();
|
||||
});
|
||||
});
|
||||
});
|
@ -7558,7 +7558,7 @@
|
||||
"kind": "enumerated",
|
||||
"n_values": 14,
|
||||
"releaseChannelCollection": "opt-out",
|
||||
"bug_numbers": [775825],
|
||||
"bug_numbers": [775825, 1617631],
|
||||
"description": "Firefox: The type of the selected result in the URL bar popup. See BrowserUsageTelemetry.jsm:URLBAR_SELECTED_RESULT_TYPES for the result types."
|
||||
},
|
||||
"FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE": {
|
||||
@ -7570,7 +7570,7 @@
|
||||
"n_values": 14,
|
||||
"keyed": true,
|
||||
"releaseChannelCollection": "opt-out",
|
||||
"bug_numbers": [1345834],
|
||||
"bug_numbers": [1345834, 1617631],
|
||||
"description": "Firefox: The index of the selected result in the URL bar popup by the type of the selected result in the URL bar popup. See BrowserUsageTelemetry.jsm:URLBAR_SELECTED_RESULT_TYPES for the result types."
|
||||
},
|
||||
"FX_URLBAR_SELECTED_RESULT_METHOD": {
|
||||
|
Loading…
Reference in New Issue
Block a user