Bug 1614777 - Part 4: Test cases; r=Standard8

Differential Revision: https://phabricator.services.mozilla.com/D64379

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Liang-Heng Chen 2020-02-27 21:40:04 +00:00
Родитель c9c0ef5deb
Коммит 68e6266159
2 изменённых файлов: 48 добавлений и 0 удалений

Просмотреть файл

@ -144,6 +144,34 @@ add_task(async function test_simple_search_page_visit() {
);
});
add_task(async function test_simple_search_page_visit_telemetry() {
searchCounts.clear();
Services.telemetry.clearScalars();
await BrowserTestUtils.withNewTab(
{
gBrowser,
/* URL must not be in the cache */
url: getSERPUrl(getPageUrl(false, true)),
},
async () => {
let scalars = {};
const key = "browser.search.data_transferred";
await TestUtils.waitForCondition(() => {
scalars =
Services.telemetry.getSnapshotForKeyedScalars("main", false).parent ||
{};
return key in scalars;
}, "should have the expected keyed scalars");
const scalar = scalars[key];
Assert.ok("example" in scalar, "correct telemetry category");
Assert.notEqual(scalars[key].example, 0, "bandwidth logged");
}
);
});
add_task(async function test_follow_on_visit() {
await BrowserTestUtils.withNewTab(
{

Просмотреть файл

@ -147,6 +147,26 @@ add_task(async function simple_remote_no_local_result() {
Assert.equal(result.remote[2], "mom");
});
add_task(async function simple_remote_no_local_result_telemetry() {
Services.telemetry.clearScalars();
let controller = new SearchSuggestionController();
await controller.fetch("mo", false, getEngine);
let scalars = {};
const key = "browser.search.data_transferred";
await TestUtils.waitForCondition(() => {
scalars =
Services.telemetry.getSnapshotForKeyedScalars("main", false).parent || {};
return key in scalars;
}, "should have the expected keyed scalars");
const scalar = scalars[key];
Assert.ok("sggt-other" in scalar, "correct telemetry category");
Assert.notEqual(scalar["sggt-other"], 0, "bandwidth logged");
});
add_task(async function simple_remote_no_local_result_alternative_type() {
let controller = new SearchSuggestionController();
let result = await controller.fetch("mo", false, alternateJSONEngine);