mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
Bug 1361855 - Refactor browser/modules/test/browser/head.js:getHistogram() and getKeyedHistogram(); r=Gijs,MattN
MozReview-Commit-ID: 3GyNfmXm5g6 --HG-- extra : rebase_source : 192ab9b904886e1e371c9c60ac06e6618f9f683e
This commit is contained in:
parent
a7b00209a5
commit
4102eb4e5b
@ -45,7 +45,7 @@ add_task(async function test_context_menu() {
|
||||
// Let's reset the Telemetry data.
|
||||
Services.telemetry.clearScalars();
|
||||
Services.telemetry.clearEvents();
|
||||
let search_hist = getSearchCountsHistogram();
|
||||
let search_hist = getAndClearKeyedHistogram("SEARCH_COUNTS");
|
||||
|
||||
// Open a new tab with a page containing some text.
|
||||
let tab =
|
||||
@ -93,7 +93,7 @@ add_task(async function test_about_newtab() {
|
||||
// Let's reset the counts.
|
||||
Services.telemetry.clearScalars();
|
||||
Services.telemetry.clearEvents();
|
||||
let search_hist = getSearchCountsHistogram();
|
||||
let search_hist = getAndClearKeyedHistogram("SEARCH_COUNTS");
|
||||
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:newtab", false);
|
||||
await ContentTask.spawn(tab.linkedBrowser, null, async function() {
|
||||
|
@ -47,7 +47,7 @@ add_task(async function test_abouthome_simpleQuery() {
|
||||
// Let's reset the counts.
|
||||
Services.telemetry.clearScalars();
|
||||
Services.telemetry.clearEvents();
|
||||
let search_hist = getSearchCountsHistogram();
|
||||
let search_hist = getAndClearKeyedHistogram("SEARCH_COUNTS");
|
||||
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
|
||||
|
||||
|
@ -106,9 +106,8 @@ add_task(async function test_plainQuery() {
|
||||
// Let's reset the counts.
|
||||
Services.telemetry.clearScalars();
|
||||
Services.telemetry.clearEvents();
|
||||
let resultMethodHist = Services.telemetry.getHistogramById("FX_SEARCHBAR_SELECTED_RESULT_METHOD");
|
||||
resultMethodHist.clear();
|
||||
let search_hist = getSearchCountsHistogram();
|
||||
let resultMethodHist = getAndClearHistogram("FX_SEARCHBAR_SELECTED_RESULT_METHOD");
|
||||
let search_hist = getAndClearKeyedHistogram("SEARCH_COUNTS");
|
||||
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank");
|
||||
|
||||
@ -147,9 +146,8 @@ add_task(async function test_oneOff_enter() {
|
||||
// Let's reset the counts.
|
||||
Services.telemetry.clearScalars();
|
||||
Services.telemetry.clearEvents();
|
||||
let resultMethodHist = Services.telemetry.getHistogramById("FX_SEARCHBAR_SELECTED_RESULT_METHOD");
|
||||
resultMethodHist.clear();
|
||||
let search_hist = getSearchCountsHistogram();
|
||||
let resultMethodHist = getAndClearHistogram("FX_SEARCHBAR_SELECTED_RESULT_METHOD");
|
||||
let search_hist = getAndClearKeyedHistogram("SEARCH_COUNTS");
|
||||
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank");
|
||||
|
||||
@ -191,8 +189,7 @@ add_task(async function test_oneOff_enter() {
|
||||
add_task(async function test_oneOff_enterSelection() {
|
||||
// Let's reset the counts.
|
||||
Services.telemetry.clearScalars();
|
||||
let resultMethodHist = Services.telemetry.getHistogramById("FX_SEARCHBAR_SELECTED_RESULT_METHOD");
|
||||
resultMethodHist.clear();
|
||||
let resultMethodHist = getAndClearHistogram("FX_SEARCHBAR_SELECTED_RESULT_METHOD");
|
||||
|
||||
// Create an engine to generate search suggestions and add it as default
|
||||
// for this test.
|
||||
@ -235,8 +232,7 @@ add_task(async function test_oneOff_enterSelection() {
|
||||
add_task(async function test_oneOff_click() {
|
||||
// Let's reset the counts.
|
||||
Services.telemetry.clearScalars();
|
||||
let resultMethodHist = Services.telemetry.getHistogramById("FX_SEARCHBAR_SELECTED_RESULT_METHOD");
|
||||
resultMethodHist.clear();
|
||||
let resultMethodHist = getAndClearHistogram("FX_SEARCHBAR_SELECTED_RESULT_METHOD");
|
||||
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank");
|
||||
|
||||
@ -260,9 +256,8 @@ add_task(async function test_suggestion_click() {
|
||||
// Let's reset the counts.
|
||||
Services.telemetry.clearScalars();
|
||||
Services.telemetry.clearEvents();
|
||||
let resultMethodHist = Services.telemetry.getHistogramById("FX_SEARCHBAR_SELECTED_RESULT_METHOD");
|
||||
resultMethodHist.clear();
|
||||
let search_hist = getSearchCountsHistogram();
|
||||
let resultMethodHist = getAndClearHistogram("FX_SEARCHBAR_SELECTED_RESULT_METHOD");
|
||||
let search_hist = getAndClearKeyedHistogram("SEARCH_COUNTS");
|
||||
|
||||
// Create an engine to generate search suggestions and add it as default
|
||||
// for this test.
|
||||
@ -319,8 +314,7 @@ add_task(async function test_suggestion_click() {
|
||||
add_task(async function test_suggestion_enterSelection() {
|
||||
// Let's reset the counts.
|
||||
Services.telemetry.clearScalars();
|
||||
let resultMethodHist = Services.telemetry.getHistogramById("FX_SEARCHBAR_SELECTED_RESULT_METHOD");
|
||||
resultMethodHist.clear();
|
||||
let resultMethodHist = getAndClearHistogram("FX_SEARCHBAR_SELECTED_RESULT_METHOD");
|
||||
|
||||
// Create an engine to generate search suggestions and add it as default
|
||||
// for this test.
|
||||
|
@ -108,16 +108,12 @@ add_task(async function test_simpleQuery() {
|
||||
// Let's reset the counts.
|
||||
Services.telemetry.clearScalars();
|
||||
Services.telemetry.clearEvents();
|
||||
let resultIndexHist = Services.telemetry.getHistogramById("FX_URLBAR_SELECTED_RESULT_INDEX");
|
||||
let resultTypeHist = Services.telemetry.getHistogramById("FX_URLBAR_SELECTED_RESULT_TYPE");
|
||||
let resultMethodHist = Services.telemetry.getHistogramById("FX_URLBAR_SELECTED_RESULT_METHOD");
|
||||
let resultIndexByTypeHist = Services.telemetry.getKeyedHistogramById("FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE");
|
||||
resultIndexByTypeHist.clear();
|
||||
resultIndexHist.clear();
|
||||
resultTypeHist.clear();
|
||||
resultMethodHist.clear();
|
||||
|
||||
let search_hist = getSearchCountsHistogram();
|
||||
let resultIndexHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_INDEX");
|
||||
let resultTypeHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_TYPE");
|
||||
let resultIndexByTypeHist = getAndClearKeyedHistogram("FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE");
|
||||
let resultMethodHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_METHOD");
|
||||
let search_hist = getAndClearKeyedHistogram("SEARCH_COUNTS");
|
||||
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank");
|
||||
|
||||
@ -167,16 +163,12 @@ add_task(async function test_searchAlias() {
|
||||
// Let's reset the counts.
|
||||
Services.telemetry.clearScalars();
|
||||
Services.telemetry.clearEvents();
|
||||
let resultIndexHist = Services.telemetry.getHistogramById("FX_URLBAR_SELECTED_RESULT_INDEX");
|
||||
let resultTypeHist = Services.telemetry.getHistogramById("FX_URLBAR_SELECTED_RESULT_TYPE");
|
||||
let resultIndexByTypeHist = Services.telemetry.getKeyedHistogramById("FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE");
|
||||
let resultMethodHist = Services.telemetry.getHistogramById("FX_URLBAR_SELECTED_RESULT_METHOD");
|
||||
resultIndexByTypeHist.clear();
|
||||
resultIndexHist.clear();
|
||||
resultTypeHist.clear();
|
||||
resultMethodHist.clear();
|
||||
|
||||
let search_hist = getSearchCountsHistogram();
|
||||
let resultIndexHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_INDEX");
|
||||
let resultTypeHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_TYPE");
|
||||
let resultIndexByTypeHist = getAndClearKeyedHistogram("FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE");
|
||||
let resultMethodHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_METHOD");
|
||||
let search_hist = getAndClearKeyedHistogram("SEARCH_COUNTS");
|
||||
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank");
|
||||
|
||||
@ -228,16 +220,12 @@ add_task(async function test_oneOff_enter() {
|
||||
// Let's reset the counts.
|
||||
Services.telemetry.clearScalars();
|
||||
Services.telemetry.clearEvents();
|
||||
let resultIndexHist = Services.telemetry.getHistogramById("FX_URLBAR_SELECTED_RESULT_INDEX");
|
||||
let resultTypeHist = Services.telemetry.getHistogramById("FX_URLBAR_SELECTED_RESULT_TYPE");
|
||||
let resultIndexByTypeHist = Services.telemetry.getKeyedHistogramById("FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE");
|
||||
let resultMethodHist = Services.telemetry.getHistogramById("FX_URLBAR_SELECTED_RESULT_METHOD");
|
||||
resultIndexByTypeHist.clear();
|
||||
resultIndexHist.clear();
|
||||
resultTypeHist.clear();
|
||||
resultMethodHist.clear();
|
||||
|
||||
let search_hist = getSearchCountsHistogram();
|
||||
let resultIndexHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_INDEX");
|
||||
let resultTypeHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_TYPE");
|
||||
let resultIndexByTypeHist = getAndClearKeyedHistogram("FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE");
|
||||
let resultMethodHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_METHOD");
|
||||
let search_hist = getAndClearKeyedHistogram("SEARCH_COUNTS");
|
||||
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank");
|
||||
|
||||
@ -293,8 +281,7 @@ add_task(async function test_oneOff_enterSelection() {
|
||||
// Let's reset the counts.
|
||||
Services.telemetry.clearScalars();
|
||||
|
||||
let resultMethodHist = Services.telemetry.getHistogramById("FX_URLBAR_SELECTED_RESULT_METHOD");
|
||||
resultMethodHist.clear();
|
||||
let resultMethodHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_METHOD");
|
||||
|
||||
// Create an engine to generate search suggestions and add it as default
|
||||
// for this test.
|
||||
@ -338,8 +325,7 @@ add_task(async function test_oneOff_click() {
|
||||
// Let's reset the counts.
|
||||
Services.telemetry.clearScalars();
|
||||
|
||||
let resultMethodHist = Services.telemetry.getHistogramById("FX_URLBAR_SELECTED_RESULT_METHOD");
|
||||
resultMethodHist.clear();
|
||||
let resultMethodHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_METHOD");
|
||||
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank");
|
||||
|
||||
@ -363,16 +349,12 @@ add_task(async function test_suggestion_click() {
|
||||
// Let's reset the counts.
|
||||
Services.telemetry.clearScalars();
|
||||
Services.telemetry.clearEvents();
|
||||
let resultIndexHist = Services.telemetry.getHistogramById("FX_URLBAR_SELECTED_RESULT_INDEX");
|
||||
let resultTypeHist = Services.telemetry.getHistogramById("FX_URLBAR_SELECTED_RESULT_TYPE");
|
||||
let resultIndexByTypeHist = Services.telemetry.getKeyedHistogramById("FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE");
|
||||
let resultMethodHist = Services.telemetry.getHistogramById("FX_URLBAR_SELECTED_RESULT_METHOD");
|
||||
resultIndexByTypeHist.clear();
|
||||
resultIndexHist.clear();
|
||||
resultTypeHist.clear();
|
||||
resultMethodHist.clear();
|
||||
|
||||
let search_hist = getSearchCountsHistogram();
|
||||
let resultIndexHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_INDEX");
|
||||
let resultTypeHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_TYPE");
|
||||
let resultIndexByTypeHist = getAndClearKeyedHistogram("FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE");
|
||||
let resultMethodHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_METHOD");
|
||||
let search_hist = getAndClearKeyedHistogram("SEARCH_COUNTS");
|
||||
|
||||
// Create an engine to generate search suggestions and add it as default
|
||||
// for this test.
|
||||
@ -442,8 +424,7 @@ add_task(async function test_suggestion_enterSelection() {
|
||||
// Let's reset the counts.
|
||||
Services.telemetry.clearScalars();
|
||||
|
||||
let resultMethodHist = Services.telemetry.getHistogramById("FX_URLBAR_SELECTED_RESULT_METHOD");
|
||||
resultMethodHist.clear();
|
||||
let resultMethodHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_METHOD");
|
||||
|
||||
// Create an engine to generate search suggestions and add it as default
|
||||
// for this test.
|
||||
|
@ -76,15 +76,31 @@ let typeInSearchField = async function(browser, text, fieldName) {
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Clear and get the SEARCH_COUNTS histogram.
|
||||
* Clear and get the named histogram
|
||||
* @param {String} name
|
||||
* The name of the histogram
|
||||
*/
|
||||
function getSearchCountsHistogram() {
|
||||
let search_hist = Services.telemetry.getKeyedHistogramById("SEARCH_COUNTS");
|
||||
search_hist.clear();
|
||||
return search_hist;
|
||||
function getAndClearHistogram(name) {
|
||||
let histogram = Services.telemetry.getHistogramById(name);
|
||||
histogram.clear();
|
||||
return histogram;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear and get the named keyed histogram
|
||||
* @param {String} name
|
||||
* The name of the keyed histogram
|
||||
*/
|
||||
function getAndClearKeyedHistogram(name) {
|
||||
let histogram = Services.telemetry.getKeyedHistogramById(name);
|
||||
histogram.clear();
|
||||
return histogram;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check that the keyed histogram contains the right value.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user