--- a/toolkit/components/telemetry/tests/gtest/TelemetryTestHelpers.cpp
+++ b/toolkit/components/telemetry/tests/gtest/TelemetryTestHelpers.cpp
@@ -171,18 +171,18 @@ GetElement(JSContext* cx, uint32_t index
valueOut.set(element);
}
void
GetSnapshots(JSContext* cx, nsCOMPtr<nsITelemetry> mTelemetry,
const char* name, JS::MutableHandleValue valueOut, bool is_keyed)
{
JS::RootedValue snapshots(cx);
- nsresult rv = is_keyed ? mTelemetry->SnapshotKeyedHistograms(nsITelemetry::DATASET_RELEASE_CHANNEL_OPTIN, false, false, cx, &snapshots)
- : mTelemetry->SnapshotHistograms(nsITelemetry::DATASET_RELEASE_CHANNEL_OPTIN, false, false, cx, &snapshots);
+ nsresult rv = is_keyed ? mTelemetry->SnapshotKeyedHistograms(nsITelemetry::DATASET_RELEASE_CHANNEL_OPTIN, false, cx, &snapshots)
+ : mTelemetry->SnapshotHistograms(nsITelemetry::DATASET_RELEASE_CHANNEL_OPTIN, false, cx, &snapshots);
JS::RootedValue snapshot(cx);
GetProperty(cx, "parent", snapshots, &snapshot);
ASSERT_EQ(rv, NS_OK) << "Cannot call histogram snapshots";
valueOut.set(snapshot);
}
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryHistograms.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryHistograms.js
@@ -68,17 +68,16 @@ function check_histogram(histogram_type,
// verify properties
Assert.equal(sum, s.sum);
// there should be exactly one element per bucket
for (let i of s.counts) {
Assert.equal(i, 1);
}
var hgrams = Telemetry.snapshotHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN,
- false,
false).parent;
let gh = hgrams[name];
Assert.equal(gh.histogram_type, histogram_type);
Assert.equal(gh.min, min);
Assert.equal(gh.max, max);
// Check that booleans work with nonboolean histograms
@@ -112,17 +111,16 @@ function test_instantiate() {
let h = Telemetry.getHistogramById(ID);
// Instantiate the subsession histogram through |add| and make sure they match.
// This MUST be the first use of "TELEMETRY_TEST_COUNT" in this file, otherwise
// |add| will not instantiate the histogram.
h.add(1);
let snapshot = h.snapshot();
let subsession = Telemetry.snapshotHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN,
- true /* subsession */,
false /* clear */).parent;
Assert.ok(ID in subsession);
Assert.equal(snapshot.sum, subsession[ID].sum,
"Histogram and subsession histogram sum must match.");
// Clear the histogram, so we don't void the assumptions from the other tests.
h.clear();
});
@@ -172,17 +170,16 @@ add_task(async function test_parameterCo
}
});
add_task(async function test_noSerialization() {
// Instantiate the storage for this histogram and make sure it doesn't
// get reflected into JS, as it has no interesting data in it.
Telemetry.getHistogramById("NEWTAB_PAGE_PINNED_SITES_COUNT");
let histograms = Telemetry.snapshotHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN,
- false /* subsession */,
false /* clear */).parent;
Assert.equal(false, "NEWTAB_PAGE_PINNED_SITES_COUNT" in histograms);
});
add_task(async function test_boolean_histogram() {
var h = Telemetry.getHistogramById("TELEMETRY_TEST_BOOLEAN");
var r = h.snapshot().ranges;
// boolean histograms ignore numeric parameters
@@ -441,26 +438,24 @@ add_task(async function test_histogramRe
add_task(async function test_expired_histogram() {
var test_expired_id = "TELEMETRY_TEST_EXPIRED";
var dummy = Telemetry.getHistogramById(test_expired_id);
dummy.add(1);
for (let process of ["main", "content", "gpu", "extension"]) {
let histograms = Telemetry.snapshotHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN,
- false /* subsession */,
false /* clear */);
if (!(process in histograms)) {
info("Nothing present for process " + process);
continue;
}
Assert.equal(histograms[process].__expired__, undefined);
}
let parentHgrams = Telemetry.snapshotHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN,
- false /* subsession */,
false /* clear */).parent;
Assert.equal(parentHgrams[test_expired_id], undefined);
});
add_task(async function test_keyed_histogram() {
// Check that invalid names get rejected.
let threw = false;
@@ -509,17 +504,16 @@ add_task(async function test_keyed_boole
testKeys.push(key);
testSnapShot[key] = testHistograms[2];
testSnapShot[key].sum = 0;
testSnapShot[key].counts = [1, 0, 0];
Assert.deepEqual(h.keys().sort(), testKeys);
Assert.deepEqual(h.snapshot(), testSnapShot);
let parentHgrams = Telemetry.snapshotKeyedHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN,
- false /* subsession */,
false /* clear */).parent;
Assert.deepEqual(parentHgrams[KEYED_ID], testSnapShot);
h.clear();
Assert.deepEqual(h.keys(), []);
Assert.deepEqual(h.snapshot(), {});
});
@@ -567,17 +561,16 @@ add_task(async function test_keyed_count
testHistograms[4].counts[0] = 1;
testHistograms[4].sum = 1;
testSnapShot[key] = testHistograms[4];
Assert.deepEqual(h.keys().sort(), testKeys);
Assert.deepEqual(h.snapshot(), testSnapShot);
let parentHgrams = Telemetry.snapshotKeyedHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN,
- false /* subsession */,
false /* clear */).parent;
Assert.deepEqual(parentHgrams[KEYED_ID], testSnapShot);
// Test clearing categorical histogram.
h.clear();
Assert.deepEqual(h.keys(), []);
Assert.deepEqual(h.snapshot(), {});
@@ -642,17 +635,16 @@ add_task(async function test_keyed_flag_
"ranges": [0, 1, 2],
"counts": [0, 1, 0]
};
Assert.deepEqual(h.keys().sort(), [KEY]);
Assert.deepEqual(h.snapshot(), testSnapshot);
let parentHgrams = Telemetry.snapshotKeyedHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN,
- false /* subsession */,
false /* clear */).parent;
Assert.deepEqual(parentHgrams[KEYED_ID], testSnapshot);
h.clear();
Assert.deepEqual(h.keys(), []);
Assert.deepEqual(h.snapshot(), {});
});
@@ -794,52 +786,47 @@ add_task(async function test_keyed_histo
});
add_task(async function test_histogramSnapshots() {
let keyed = Telemetry.getKeyedHistogramById("TELEMETRY_TEST_KEYED_COUNT");
keyed.add("a", 1);
// Check that keyed histograms are not returned
let parentHgrams = Telemetry.snapshotHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN,
- false /* subsession */,
false /* clear */).parent;
Assert.ok(!("TELEMETRY_TEST_KEYED_COUNT" in parentHgrams));
});
add_task(async function test_datasets() {
// Check that datasets work as expected.
const RELEASE_CHANNEL_OPTOUT = Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTOUT;
const RELEASE_CHANNEL_OPTIN = Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN;
// Check that registeredHistogram works properly
let registered = Telemetry.snapshotHistograms(RELEASE_CHANNEL_OPTIN,
- false /* subsession */,
false /* clear */);
registered = new Set(Object.keys(registered.parent));
Assert.ok(registered.has("TELEMETRY_TEST_FLAG"));
Assert.ok(registered.has("TELEMETRY_TEST_RELEASE_OPTIN"));
Assert.ok(registered.has("TELEMETRY_TEST_RELEASE_OPTOUT"));
registered = Telemetry.snapshotHistograms(RELEASE_CHANNEL_OPTOUT,
- false /* subsession */,
false /* clear */);
registered = new Set(Object.keys(registered.parent));
Assert.ok(!registered.has("TELEMETRY_TEST_FLAG"));
Assert.ok(!registered.has("TELEMETRY_TEST_RELEASE_OPTIN"));
Assert.ok(registered.has("TELEMETRY_TEST_RELEASE_OPTOUT"));
// Check that registeredKeyedHistograms works properly
registered = Telemetry.snapshotKeyedHistograms(RELEASE_CHANNEL_OPTIN,
- false /* subsession */,
false /* clear */);
registered = new Set(Object.keys(registered.parent));
Assert.ok(registered.has("TELEMETRY_TEST_KEYED_FLAG"));
Assert.ok(registered.has("TELEMETRY_TEST_KEYED_RELEASE_OPTOUT"));
registered = Telemetry.snapshotKeyedHistograms(RELEASE_CHANNEL_OPTOUT,
- false /* subsession */,
false /* clear */);
registered = new Set(Object.keys(registered.parent));
Assert.ok(!registered.has("TELEMETRY_TEST_KEYED_FLAG"));
Assert.ok(registered.has("TELEMETRY_TEST_KEYED_RELEASE_OPTOUT"));
});
add_task({
skip_if: () => gIsAndroid
@@ -1171,17 +1158,16 @@ async function test_platformSpecificHist
mobile_histo.clear();
default_histo.add(42);
desktop_histo.add(42);
multiplatform_histo.add(42);
mobile_histo.add(42);
let histograms = Telemetry.snapshotHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN,
- false /* subsession */,
false /* clear */).parent;
Assert.ok(DEFAULT_PLATFORMS_HISTOGRAM in histograms, "Should have recorded default platforms histogram");
Assert.ok(DESKTOP_ONLY_HISTOGRAM in histograms, "Should have recorded desktop-only histogram");
Assert.ok(MULTIPLATFORM_HISTOGRAM in histograms, "Should have recorded multiplatform histogram");
Assert.ok(!(MOBILE_ONLY_HISTOGRAM in histograms), "Should not have recorded mobile-only histogram");
});
@@ -1205,17 +1191,16 @@ async function test_mobileSpecificHistog
mobile_histo.clear();
default_histo.add(1);
desktop_histo.add(1);
multiplatform_histo.add(1);
mobile_histo.add(1);
let histograms = Telemetry.snapshotHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN,
- false /* subsession */,
false /* clear */).parent;
Assert.ok(DEFAULT_PLATFORMS_HISTOGRAM in histograms, "Should have recorded default platforms histogram");
Assert.ok(MOBILE_ONLY_HISTOGRAM in histograms, "Should have recorded mobile-only histogram");
Assert.ok(MULTIPLATFORM_HISTOGRAM in histograms, "Should have recorded multiplatform histogram");
Assert.ok(!(DESKTOP_ONLY_HISTOGRAM in histograms), "Should not have recorded desktop-only histogram");
});