summaryrefslogtreecommitdiffstats
path: root/browser/modules/test/browser_UsageTelemetry_content_aboutHome.js
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2018-02-03 06:00:38 -0500
committerMatt A. Tobin <email@mattatobin.com>2018-02-03 06:00:38 -0500
commit8148615da179fdd60f19018e13b4e94b95609cc6 (patch)
tree771fccdd99fa3adf35fdd2c81d8197b415a89b91 /browser/modules/test/browser_UsageTelemetry_content_aboutHome.js
parent494802c1be7888025b95260d23db187467d2b9dd (diff)
downloadUXP-8148615da179fdd60f19018e13b4e94b95609cc6.tar
UXP-8148615da179fdd60f19018e13b4e94b95609cc6.tar.gz
UXP-8148615da179fdd60f19018e13b4e94b95609cc6.tar.lz
UXP-8148615da179fdd60f19018e13b4e94b95609cc6.tar.xz
UXP-8148615da179fdd60f19018e13b4e94b95609cc6.zip
Remove browser tests - Part 1: The Tests (except for experiments)
Diffstat (limited to 'browser/modules/test/browser_UsageTelemetry_content_aboutHome.js')
-rw-r--r--browser/modules/test/browser_UsageTelemetry_content_aboutHome.js84
1 files changed, 0 insertions, 84 deletions
diff --git a/browser/modules/test/browser_UsageTelemetry_content_aboutHome.js b/browser/modules/test/browser_UsageTelemetry_content_aboutHome.js
deleted file mode 100644
index 1818ae5fd..000000000
--- a/browser/modules/test/browser_UsageTelemetry_content_aboutHome.js
+++ /dev/null
@@ -1,84 +0,0 @@
-"use strict";
-
-const SCALAR_ABOUT_HOME = "browser.engagement.navigation.about_home";
-
-add_task(function* setup() {
- // about:home uses IndexedDB. However, the test finishes too quickly and doesn't
- // allow it enougth time to save. So it throws. This disables all the uncaught
- // exception in this file and that's the reason why we split about:home tests
- // out of the other UsageTelemetry files.
- ignoreAllUncaughtExceptions();
-
- // Create two new search engines. Mark one as the default engine, so
- // the test don't crash. We need to engines for this test as the searchbar
- // in content doesn't display the default search engine among the one-off engines.
- Services.search.addEngineWithDetails("MozSearch", "", "mozalias", "", "GET",
- "http://example.com/?q={searchTerms}");
-
- Services.search.addEngineWithDetails("MozSearch2", "", "mozalias2", "", "GET",
- "http://example.com/?q={searchTerms}");
-
- // Make the first engine the default search engine.
- let engineDefault = Services.search.getEngineByName("MozSearch");
- let originalEngine = Services.search.currentEngine;
- Services.search.currentEngine = engineDefault;
-
- // Move the second engine at the beginning of the one-off list.
- let engineOneOff = Services.search.getEngineByName("MozSearch2");
- Services.search.moveEngine(engineOneOff, 0);
-
- // Enable Extended Telemetry.
- yield SpecialPowers.pushPrefEnv({"set": [["toolkit.telemetry.enabled", true]]});
-
- // Make sure to restore the engine once we're done.
- registerCleanupFunction(function* () {
- Services.search.currentEngine = originalEngine;
- Services.search.removeEngine(engineDefault);
- Services.search.removeEngine(engineOneOff);
- });
-});
-
-add_task(function* test_abouthome_simpleQuery() {
- // Let's reset the counts.
- Services.telemetry.clearScalars();
- Services.telemetry.clearEvents();
- let search_hist = getSearchCountsHistogram();
-
- let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser);
-
- info("Setup waiting for AboutHomeLoadSnippetsCompleted.");
- let promiseAboutHomeLoaded = new Promise(resolve => {
- tab.linkedBrowser.addEventListener("AboutHomeLoadSnippetsCompleted", function loadListener(event) {
- tab.linkedBrowser.removeEventListener("AboutHomeLoadSnippetsCompleted", loadListener, true);
- resolve();
- }, true, true);
- });
-
- info("Load about:home.");
- tab.linkedBrowser.loadURI("about:home");
- info("Wait for AboutHomeLoadSnippetsCompleted.");
- yield promiseAboutHomeLoaded;
-
- info("Trigger a simple serch, just test + enter.");
- let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
- yield typeInSearchField(tab.linkedBrowser, "test query", "searchText");
- yield BrowserTestUtils.synthesizeKey("VK_RETURN", {}, tab.linkedBrowser);
- yield p;
-
- // Check if the scalars contain the expected values.
- const scalars =
- Services.telemetry.snapshotKeyedScalars(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, false);
- checkKeyedScalar(scalars, SCALAR_ABOUT_HOME, "search_enter", 1);
- Assert.equal(Object.keys(scalars[SCALAR_ABOUT_HOME]).length, 1,
- "This search must only increment one entry in the scalar.");
-
- // Make sure SEARCH_COUNTS contains identical values.
- checkKeyedHistogram(search_hist, 'other-MozSearch.abouthome', 1);
-
- // Also check events.
- let events = Services.telemetry.snapshotBuiltinEvents(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, false);
- events = events.filter(e => e[1] == "navigation" && e[2] == "search");
- checkEvents(events, [["navigation", "search", "about_home", "enter", {engine: "other-MozSearch"}]]);
-
- yield BrowserTestUtils.removeTab(tab);
-});