mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 15:25:52 +00:00
Bug 1524227 Replacing getParentProcessScalar with generic getProcessScalar r=chutten
Replacing existing getParentProcessScalars with a generic implementation of getProcessScalars Differential Revision: https://phabricator.services.mozilla.com/D18861 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
d2b017325d
commit
2c911ec44a
@ -20,8 +20,7 @@ Services.obs.notifyObservers(null, TELEMETRY_SUBSESSION_TOPIC);
|
||||
* Get a snapshot of the scalars and check them against the provided values.
|
||||
*/
|
||||
let checkScalars = (countsObject) => {
|
||||
const scalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN);
|
||||
const scalars = TelemetryTestUtils.getProcessScalars("parent");
|
||||
|
||||
// Check the expected values. Scalars that are never set must not be reported.
|
||||
TelemetryTestUtils.assertScalar(scalars, MAX_CONCURRENT_TABS, countsObject.maxTabs,
|
||||
|
@ -75,8 +75,7 @@ add_task(async function test_context_menu() {
|
||||
searchItem.click();
|
||||
|
||||
info("Validate the search metrics.");
|
||||
const scalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true, false);
|
||||
const scalars = TelemetryTestUtils.getProcessScalars("parent", true, false);
|
||||
TelemetryTestUtils.assertKeyedScalar(scalars, SCALAR_CONTEXT_MENU, "search", 1);
|
||||
Assert.equal(Object.keys(scalars[SCALAR_CONTEXT_MENU]).length, 1,
|
||||
"This search must only increment one entry in the scalar.");
|
||||
@ -114,8 +113,7 @@ add_task(async function test_about_newtab() {
|
||||
await p;
|
||||
|
||||
// Check if the scalars contain the expected values.
|
||||
const scalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true, false);
|
||||
const scalars = TelemetryTestUtils.getProcessScalars("parent", true, false);
|
||||
TelemetryTestUtils.assertKeyedScalar(scalars, SCALAR_ABOUT_NEWTAB, "search_enter", 1);
|
||||
Assert.equal(Object.keys(scalars[SCALAR_ABOUT_NEWTAB]).length, 1,
|
||||
"This search must only increment one entry in the scalar.");
|
||||
|
@ -69,8 +69,7 @@ add_task(async function test_abouthome_activitystream_simpleQuery() {
|
||||
await p;
|
||||
|
||||
// Check if the scalars contain the expected values.
|
||||
const scalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true, false);
|
||||
const scalars = TelemetryTestUtils.getProcessScalars("parent", true, false);
|
||||
TelemetryTestUtils.assertKeyedScalar(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.");
|
||||
|
@ -11,7 +11,7 @@ add_task(async function test_aboutRestartRequired() {
|
||||
Services.telemetry.clearScalars();
|
||||
|
||||
let scalars =
|
||||
TelemetryTestUtils.getParentProcessScalars(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTOUT);
|
||||
TelemetryTestUtils.getProcessScalars("parent");
|
||||
|
||||
// Check preconditions
|
||||
is(scalars[SCALAR_BUILDID_MISMATCH], undefined,
|
||||
@ -23,7 +23,7 @@ add_task(async function test_aboutRestartRequired() {
|
||||
gBrowser.selectedTab.linkedBrowser);
|
||||
|
||||
scalars =
|
||||
TelemetryTestUtils.getParentProcessScalars(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTOUT);
|
||||
TelemetryTestUtils.getProcessScalars("parent");
|
||||
|
||||
is(scalars[SCALAR_BUILDID_MISMATCH], 1,
|
||||
"Build ID mismatch count should be 1.");
|
||||
|
@ -50,8 +50,7 @@ add_task(async function test_URIAndDomainCounts() {
|
||||
|
||||
let checkCounts = (countsObject) => {
|
||||
// Get a snapshot of the scalars and then clear them.
|
||||
const scalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN);
|
||||
const scalars = TelemetryTestUtils.getProcessScalars("parent");
|
||||
TelemetryTestUtils.assertScalar(scalars, TOTAL_URI_COUNT, countsObject.totalURIs,
|
||||
"The URI scalar must contain the expected value.");
|
||||
TelemetryTestUtils.assertScalar(scalars, UNIQUE_DOMAINS_COUNT, countsObject.domainCount,
|
||||
|
@ -30,8 +30,7 @@ add_task(async function test_privateMode() {
|
||||
await BrowserTestUtils.browserLoaded(privateWin.gBrowser.selectedBrowser);
|
||||
|
||||
// Check that tab and window count is recorded.
|
||||
const scalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN);
|
||||
const scalars = TelemetryTestUtils.getProcessScalars("parent");
|
||||
|
||||
ok(!(TOTAL_URI_COUNT in scalars), "We should not track URIs in private mode.");
|
||||
ok(!(UNFILTERED_URI_COUNT in scalars), "We should not track URIs in private mode.");
|
||||
@ -80,8 +79,7 @@ add_task(async function test_sessionRestore() {
|
||||
await tabRestored;
|
||||
|
||||
// Check that the URI is not recorded.
|
||||
const scalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN);
|
||||
const scalars = TelemetryTestUtils.getProcessScalars("parent");
|
||||
|
||||
ok(!(TOTAL_URI_COUNT in scalars), "We should not track URIs from restored sessions.");
|
||||
ok(!(UNFILTERED_URI_COUNT in scalars), "We should not track URIs from restored sessions.");
|
||||
|
@ -111,8 +111,7 @@ add_task(async function test_plainQuery() {
|
||||
await p;
|
||||
|
||||
// Check if the scalars contain the expected values.
|
||||
const scalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true, false);
|
||||
const scalars = TelemetryTestUtils.getProcessScalars("parent", true, false);
|
||||
TelemetryTestUtils.assertKeyedScalar(scalars, SCALAR_SEARCHBAR, "search_enter", 1);
|
||||
Assert.equal(Object.keys(scalars[SCALAR_SEARCHBAR]).length, 1,
|
||||
"This search must only increment one entry in the scalar.");
|
||||
@ -159,8 +158,7 @@ add_task(async function test_oneOff_enter() {
|
||||
await p;
|
||||
|
||||
// Check if the scalars contain the expected values.
|
||||
const scalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true, false);
|
||||
const scalars = TelemetryTestUtils.getProcessScalars("parent", true, false);
|
||||
TelemetryTestUtils.assertKeyedScalar(scalars, SCALAR_SEARCHBAR, "search_oneoff", 1);
|
||||
Assert.equal(Object.keys(scalars[SCALAR_SEARCHBAR]).length, 1,
|
||||
"This search must only increment one entry in the scalar.");
|
||||
@ -275,8 +273,7 @@ add_task(async function test_suggestion_click() {
|
||||
await p;
|
||||
|
||||
// Check if the scalars contain the expected values.
|
||||
const scalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true, false);
|
||||
const scalars = TelemetryTestUtils.getProcessScalars("parent", true, false);
|
||||
TelemetryTestUtils.assertKeyedScalar(scalars, SCALAR_SEARCHBAR, "search_suggestion", 1);
|
||||
Assert.equal(Object.keys(scalars[SCALAR_SEARCHBAR]).length, 1,
|
||||
"This search must only increment one entry in the scalar.");
|
||||
|
@ -156,7 +156,7 @@ add_task(async function test_simpleQuery() {
|
||||
await p;
|
||||
|
||||
// Check if the scalars contain the expected values.
|
||||
const scalars = TelemetryTestUtils.getParentProcessScalars(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true, false);
|
||||
const scalars = TelemetryTestUtils.getProcessScalars("parent", true, false);
|
||||
TelemetryTestUtils.assertKeyedScalar(scalars, SCALAR_URLBAR, "search_enter", 1);
|
||||
Assert.equal(Object.keys(scalars[SCALAR_URLBAR]).length, 1,
|
||||
"This search must only increment one entry in the scalar.");
|
||||
@ -204,7 +204,7 @@ add_task(async function test_searchAlias() {
|
||||
await p;
|
||||
|
||||
// Check if the scalars contain the expected values.
|
||||
const scalars = TelemetryTestUtils.getParentProcessScalars(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true, false);
|
||||
const scalars = TelemetryTestUtils.getProcessScalars("parent", true, false);
|
||||
TelemetryTestUtils.assertKeyedScalar(scalars, SCALAR_URLBAR, "search_alias", 1);
|
||||
Assert.equal(Object.keys(scalars[SCALAR_URLBAR]).length, 1,
|
||||
"This search must only increment one entry in the scalar.");
|
||||
@ -283,7 +283,7 @@ add_task(async function test_oneOff_enter() {
|
||||
await p;
|
||||
|
||||
// Check if the scalars contain the expected values.
|
||||
const scalars = TelemetryTestUtils.getParentProcessScalars(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true, false);
|
||||
const scalars = TelemetryTestUtils.getProcessScalars("parent", true, false);
|
||||
TelemetryTestUtils.assertKeyedScalar(scalars, SCALAR_URLBAR, "search_oneoff", 1);
|
||||
Assert.equal(Object.keys(scalars[SCALAR_URLBAR]).length, 1,
|
||||
"This search must only increment one entry in the scalar.");
|
||||
@ -384,7 +384,7 @@ add_task(async function test_suggestion_click() {
|
||||
await p;
|
||||
|
||||
// Check if the scalars contain the expected values.
|
||||
const scalars = TelemetryTestUtils.getParentProcessScalars(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true, false);
|
||||
const scalars = TelemetryTestUtils.getProcessScalars("parent", true, false);
|
||||
TelemetryTestUtils.assertKeyedScalar(scalars, SCALAR_URLBAR, "search_suggestion", 1);
|
||||
Assert.equal(Object.keys(scalars[SCALAR_URLBAR]).length, 1,
|
||||
"This search must only increment one entry in the scalar.");
|
||||
|
@ -10,8 +10,7 @@ ChromeUtils.defineModuleGetter(this, "TelemetryTestUtils",
|
||||
const TEST_URL = "https://example.com/";
|
||||
|
||||
function getTelemetryForScalar(aName) {
|
||||
let scalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true);
|
||||
let scalars = TelemetryTestUtils.getProcessScalars("parent", true);
|
||||
return scalars[aName] || 0;
|
||||
}
|
||||
|
||||
|
@ -30,8 +30,7 @@ add_task(async function test_serializationFormat() {
|
||||
Telemetry.keyedScalarSet(KEYED_UINT_SCALAR, "first_key", 1234);
|
||||
|
||||
// Get a snapshot of the scalars for the main process (internally called "default").
|
||||
const scalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN);
|
||||
const scalars = TelemetryTestUtils.getProcessScalars("parent");
|
||||
|
||||
// Check that they are serialized to the correct format.
|
||||
Assert.equal(typeof(scalars[UINT_SCALAR]), "number",
|
||||
@ -65,8 +64,7 @@ add_task(async function test_keyedSerializationFormat() {
|
||||
Telemetry.keyedScalarSet(KEYED_UINT_SCALAR, expectedOtherKey, expectedOtherValue);
|
||||
|
||||
// Get a snapshot of the scalars.
|
||||
const keyedScalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true);
|
||||
const keyedScalars = TelemetryTestUtils.getProcessScalars("parent", true);
|
||||
|
||||
Assert.ok(!(UINT_SCALAR in keyedScalars),
|
||||
UINT_SCALAR + " must not be serialized with the keyed scalars.");
|
||||
@ -103,13 +101,11 @@ add_task(async function test_nonexistingScalar() {
|
||||
Telemetry.keyedScalarSetMaximum(NON_EXISTING_SCALAR, "some_key", 11715);
|
||||
|
||||
// Get a snapshot of the scalars.
|
||||
const scalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN);
|
||||
const scalars = TelemetryTestUtils.getProcessScalars("parent");
|
||||
|
||||
Assert.ok(!(NON_EXISTING_SCALAR in scalars), "The non existing scalar must not be persisted.");
|
||||
|
||||
const keyedScalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true);
|
||||
const keyedScalars = TelemetryTestUtils.getProcessScalars("parent", true);
|
||||
|
||||
Assert.ok(!(NON_EXISTING_SCALAR in keyedScalars),
|
||||
"The non existing keyed scalar must not be persisted.");
|
||||
@ -136,10 +132,8 @@ add_task(async function test_expiredScalar() {
|
||||
Telemetry.scalarSet(UNEXPIRED_SCALAR, expectedValue);
|
||||
|
||||
// Get a snapshot of the scalars.
|
||||
const scalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN);
|
||||
const keyedScalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN);
|
||||
const scalars = TelemetryTestUtils.getProcessScalars("parent");
|
||||
const keyedScalars = TelemetryTestUtils.getProcessScalars("parent");
|
||||
|
||||
Assert.ok(!(EXPIRED_SCALAR in scalars), "The expired scalar must not be persisted.");
|
||||
Assert.equal(scalars[UNEXPIRED_SCALAR], expectedValue,
|
||||
@ -150,8 +144,7 @@ add_task(async function test_expiredScalar() {
|
||||
|
||||
add_task(async function test_unsignedIntScalar() {
|
||||
let checkScalar = (expectedValue) => {
|
||||
const scalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN);
|
||||
const scalars = TelemetryTestUtils.getProcessScalars("parent");
|
||||
Assert.equal(scalars[UINT_SCALAR], expectedValue,
|
||||
UINT_SCALAR + " must contain the expected value.");
|
||||
};
|
||||
@ -203,8 +196,7 @@ add_task(async function test_unsignedIntScalar() {
|
||||
|
||||
add_task(async function test_stringScalar() {
|
||||
let checkExpectedString = (expectedString) => {
|
||||
const scalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN);
|
||||
const scalars = TelemetryTestUtils.getProcessScalars("parent");
|
||||
Assert.equal(scalars[STRING_SCALAR], expectedString,
|
||||
STRING_SCALAR + " must contain the expected string value.");
|
||||
};
|
||||
@ -234,8 +226,7 @@ add_task(async function test_stringScalar() {
|
||||
|
||||
add_task(async function test_booleanScalar() {
|
||||
let checkExpectedBool = (expectedBoolean) => {
|
||||
const scalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN);
|
||||
const scalars = TelemetryTestUtils.getProcessScalars("parent");
|
||||
Assert.equal(scalars[BOOLEAN_SCALAR], expectedBoolean,
|
||||
BOOLEAN_SCALAR + " must contain the expected boolean value.");
|
||||
};
|
||||
@ -273,15 +264,13 @@ add_task(async function test_scalarRecording() {
|
||||
const OPTOUT_SCALAR = "telemetry.test.release_optout";
|
||||
|
||||
let checkValue = (scalarName, expectedValue) => {
|
||||
const scalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN);
|
||||
const scalars = TelemetryTestUtils.getProcessScalars("parent");
|
||||
Assert.equal(scalars[scalarName], expectedValue,
|
||||
scalarName + " must contain the expected value.");
|
||||
};
|
||||
|
||||
let checkNotSerialized = (scalarName) => {
|
||||
const scalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN);
|
||||
const scalars = TelemetryTestUtils.getProcessScalars("parent");
|
||||
Assert.ok(!(scalarName in scalars), scalarName + " was not recorded.");
|
||||
};
|
||||
|
||||
@ -316,15 +305,13 @@ add_task(async function test_keyedScalarRecording() {
|
||||
const testKey = "policy_key";
|
||||
|
||||
let checkValue = (scalarName, expectedValue) => {
|
||||
const scalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true);
|
||||
const scalars = TelemetryTestUtils.getProcessScalars("parent", true);
|
||||
Assert.equal(scalars[scalarName][testKey], expectedValue,
|
||||
scalarName + " must contain the expected value.");
|
||||
};
|
||||
|
||||
let checkNotSerialized = (scalarName) => {
|
||||
const scalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true);
|
||||
const scalars = TelemetryTestUtils.getProcessScalars("parent", true);
|
||||
Assert.ok(!(scalarName in scalars), scalarName + " was not recorded.");
|
||||
};
|
||||
|
||||
@ -363,10 +350,8 @@ add_task(async function test_subsession() {
|
||||
Telemetry.keyedScalarSet(KEYED_UINT_SCALAR, "some_random_key", 12);
|
||||
|
||||
// Get a snapshot and reset the subsession. The value we set must be there.
|
||||
let scalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, false, true);
|
||||
let keyedScalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true, true);
|
||||
let scalars = TelemetryTestUtils.getProcessScalars("parent", false, true);
|
||||
let keyedScalars = TelemetryTestUtils.getProcessScalars("parent", true, true);
|
||||
|
||||
Assert.equal(scalars[UINT_SCALAR], 3785,
|
||||
UINT_SCALAR + " must contain the expected value.");
|
||||
@ -379,10 +364,8 @@ add_task(async function test_subsession() {
|
||||
|
||||
// Get a new snapshot and reset the subsession again. Since no new value
|
||||
// was set, the scalars should not be reported.
|
||||
scalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, false, true);
|
||||
keyedScalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true, true);
|
||||
scalars = TelemetryTestUtils.getProcessScalars("parent", false, true);
|
||||
keyedScalars = TelemetryTestUtils.getProcessScalars("parent", true, true);
|
||||
|
||||
Assert.ok(!(UINT_SCALAR in scalars), UINT_SCALAR + " must be empty and not reported.");
|
||||
Assert.ok(!(STRING_SCALAR in scalars), STRING_SCALAR + " must be empty and not reported.");
|
||||
@ -411,8 +394,7 @@ add_task(async function test_keyed_uint() {
|
||||
|
||||
// Get a snapshot of the scalars and make sure the keys contain
|
||||
// the correct values.
|
||||
const keyedScalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true);
|
||||
const keyedScalars = TelemetryTestUtils.getProcessScalars("parent", true);
|
||||
|
||||
for (let k = 0; k < 3; k++) {
|
||||
const keyName = KEYS[k];
|
||||
@ -439,8 +421,7 @@ add_task(async function test_keyed_boolean() {
|
||||
|
||||
// Get a snapshot of the scalars and make sure the keys contain
|
||||
// the correct values.
|
||||
let keyedScalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true);
|
||||
let keyedScalars = TelemetryTestUtils.getProcessScalars("parent", true);
|
||||
Assert.equal(keyedScalars[KEYED_BOOLEAN_TYPE][first_key], true,
|
||||
"The key must contain the expected value.");
|
||||
Assert.equal(keyedScalars[KEYED_BOOLEAN_TYPE][second_key], false,
|
||||
@ -450,8 +431,7 @@ add_task(async function test_keyed_boolean() {
|
||||
Telemetry.keyedScalarSet(KEYED_BOOLEAN_TYPE, first_key, false);
|
||||
Telemetry.keyedScalarSet(KEYED_BOOLEAN_TYPE, second_key, true);
|
||||
|
||||
keyedScalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true);
|
||||
keyedScalars = TelemetryTestUtils.getProcessScalars("parent", true);
|
||||
Assert.equal(keyedScalars[KEYED_BOOLEAN_TYPE][first_key], false,
|
||||
"The key must contain the expected value.");
|
||||
Assert.equal(keyedScalars[KEYED_BOOLEAN_TYPE][second_key], true,
|
||||
@ -482,8 +462,7 @@ add_task(async function test_keyed_keys_length() {
|
||||
Telemetry.keyedScalarSet(KEYED_UINT_SCALAR, "", 1);
|
||||
|
||||
// Make sure the key with the right length contains the expected value.
|
||||
let keyedScalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true);
|
||||
let keyedScalars = TelemetryTestUtils.getProcessScalars("parent", true);
|
||||
Assert.equal(Object.keys(keyedScalars[KEYED_UINT_SCALAR]).length, 1,
|
||||
"The keyed scalar must contain exactly 1 key.");
|
||||
Assert.ok(NORMAL_KEY in keyedScalars[KEYED_UINT_SCALAR],
|
||||
@ -520,8 +499,7 @@ add_task(async function test_keyed_max_keys() {
|
||||
|
||||
// Make sure all the keys except the last one are available and have the correct
|
||||
// values.
|
||||
let keyedScalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true);
|
||||
let keyedScalars = TelemetryTestUtils.getProcessScalars("parent", true);
|
||||
|
||||
// Check that the keyed scalar only contain the first 100 keys.
|
||||
const reportedKeysSet = new Set(Object.keys(keyedScalars[KEYED_UINT_SCALAR]));
|
||||
@ -821,10 +799,8 @@ async function test_productSpecificScalar() {
|
||||
Telemetry.keyedScalarSetMaximum(MOBILE_ONLY_KEYED_SCALAR, expectedKey, 11715);
|
||||
|
||||
// Get a snapshot of the scalars.
|
||||
const scalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN);
|
||||
const keyedScalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN);
|
||||
const scalars = TelemetryTestUtils.getProcessScalars("parent");
|
||||
const keyedScalars = TelemetryTestUtils.getProcessScalars("parent");
|
||||
|
||||
Assert.equal(scalars[DEFAULT_PRODUCT_SCALAR], expectedValue, "The default platfomrs scalar must contain the right value");
|
||||
Assert.equal(scalars[DESKTOP_ONLY_SCALAR], expectedValue, "The desktop-only scalar must contain the right value");
|
||||
@ -865,10 +841,8 @@ async function test_mobileSpecificScalar() {
|
||||
Telemetry.keyedScalarSetMaximum(DESKTOP_ONLY_KEYED_SCALAR, expectedKey, 11715);
|
||||
|
||||
// Get a snapshot of the scalars.
|
||||
const scalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN);
|
||||
const keyedScalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true);
|
||||
const scalars = TelemetryTestUtils.getProcessScalars("parent");
|
||||
const keyedScalars = TelemetryTestUtils.getProcessScalars("parent", true);
|
||||
|
||||
Assert.equal(scalars[DEFAULT_PRODUCT_SCALAR], expectedValue, "The default products scalar must contain the right value");
|
||||
Assert.equal(scalars[MOBILE_ONLY_SCALAR], expectedValue, "The mobile-only scalar must contain the right value");
|
||||
@ -909,8 +883,7 @@ async function test_geckoviewSpecificScalar() {
|
||||
Telemetry.scalarSetMaximum(DESKTOP_ONLY_SCALAR, 11715);
|
||||
|
||||
// Get a snapshot of the scalars.
|
||||
const scalars = TelemetryTestUtils.getParentProcessScalars(
|
||||
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN);
|
||||
const scalars = TelemetryTestUtils.getProcessScalars("parent");
|
||||
|
||||
Assert.equal(scalars[GECKOVIEW_ONLY_SCALAR], expectedValue, "The geckoview-only scalar must contain the right value");
|
||||
Assert.equal(scalars[MOBILE_ONLY_SCALAR], expectedValue, "The mobile-only scalar must contain the right value");
|
||||
|
@ -48,22 +48,25 @@ var TelemetryTestUtils = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a snapshot of scalars from the parent-process.
|
||||
* Returns a snapshot of scalars from the specified process.
|
||||
*
|
||||
* @param {Number} aChannel The channel dataset type from nsITelemetry.
|
||||
* @param {String} aProcessName Name of the process. Could be parent or
|
||||
* something else.
|
||||
* @param {boolean} [aKeyed] Set to true if keyed scalars rather than normal
|
||||
* scalars should be snapshotted.
|
||||
* @param {boolean} [aClear] Set to true to clear the scalars once the snapshot
|
||||
* has been obtained.
|
||||
* @param {Number} aChannel The channel dataset type from nsITelemetry.
|
||||
* @returns {Object} The snapshotted scalars from the parent process.
|
||||
*/
|
||||
getParentProcessScalars(aChannel, aKeyed = false, aClear = false) {
|
||||
getProcessScalars(aProcessName, aKeyed = false, aClear = false,
|
||||
aChannel = Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN) {
|
||||
const extended = aChannel == Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN;
|
||||
const currentExtended = Services.telemetry.canRecordExtended;
|
||||
Services.telemetry.canRecordExtended = extended;
|
||||
const scalars = aKeyed ?
|
||||
Services.telemetry.getSnapshotForKeyedScalars("main", aClear).parent :
|
||||
Services.telemetry.getSnapshotForScalars("main", aClear).parent;
|
||||
Services.telemetry.getSnapshotForKeyedScalars("main", aClear)[aProcessName] :
|
||||
Services.telemetry.getSnapshotForScalars("main", aClear)[aProcessName];
|
||||
Services.telemetry.canRecordExtended = currentExtended;
|
||||
return scalars || {};
|
||||
},
|
||||
|
@ -366,7 +366,7 @@ async function readFile(file) {
|
||||
|
||||
function checkStartupReason(expected = undefined) {
|
||||
const tId = "startup.profile_selection_reason";
|
||||
let scalars = TelemetryTestUtils.getParentProcessScalars(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTOUT);
|
||||
let scalars = TelemetryTestUtils.getProcessScalars("parent");
|
||||
|
||||
if (expected === undefined) {
|
||||
Assert.ok(!(tId in scalars), "Startup telemetry should not have been recorded.");
|
||||
|
Loading…
Reference in New Issue
Block a user