mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 14:55:47 +00:00
Bug 1120379 - Add tests for the deletion ping. r=gfritzsche
This commit is contained in:
parent
8b8d56a308
commit
d05706c0a0
@ -72,6 +72,11 @@ function validateTelemetryPingList(list) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Telemetry may generate other pings (e.g. "deletion" pings), so filter those
|
||||
// out.
|
||||
const TEST_TYPES_REGEX = /^test-telemetryArchive/;
|
||||
list = list.filter(p => TEST_TYPES_REGEX.test(p.type));
|
||||
|
||||
if (list.length != TEST_PINGS.length) {
|
||||
console.log("Telemetry ping length is not correct.");
|
||||
return false;
|
||||
|
@ -21,6 +21,7 @@ Cu.import("resource://gre/modules/Promise.jsm", this);
|
||||
Cu.import("resource://gre/modules/Preferences.jsm");
|
||||
|
||||
const PING_FORMAT_VERSION = 4;
|
||||
const DELETION_PING_TYPE = "deletion";
|
||||
const TEST_PING_TYPE = "test-ping-type";
|
||||
|
||||
const PLATFORM_VERSION = "1.9.2";
|
||||
@ -174,6 +175,25 @@ add_task(function* test_simplePing() {
|
||||
checkPingFormat(ping, TEST_PING_TYPE, false, false);
|
||||
});
|
||||
|
||||
add_task(function* test_deletionPing() {
|
||||
const isUnified = Preferences.get(PREF_UNIFIED, false);
|
||||
if (!isUnified) {
|
||||
// Skipping the test if unified telemetry is off, as no deletion ping will
|
||||
// be generated.
|
||||
return;
|
||||
}
|
||||
|
||||
// Disable FHR upload: this should trigger a deletion ping.
|
||||
Preferences.set(PREF_FHR_UPLOAD_ENABLED, false);
|
||||
|
||||
let request = yield gRequestIterator.next();
|
||||
let ping = decodeRequestPayload(request);
|
||||
checkPingFormat(ping, DELETION_PING_TYPE, true, false);
|
||||
|
||||
// Restore FHR Upload.
|
||||
Preferences.set(PREF_FHR_UPLOAD_ENABLED, true);
|
||||
});
|
||||
|
||||
add_task(function* test_pingHasClientId() {
|
||||
// Send a ping with a clientId.
|
||||
yield sendPing(true, false);
|
||||
@ -231,6 +251,14 @@ add_task(function* test_archivePings() {
|
||||
const uploadPref = isUnified ? PREF_FHR_UPLOAD_ENABLED : PREF_ENABLED;
|
||||
Preferences.set(uploadPref, false);
|
||||
|
||||
// If we're using unified telemetry, disabling ping upload will generate a "deletion"
|
||||
// ping. Catch it.
|
||||
if (isUnified) {
|
||||
let request = yield gRequestIterator.next();
|
||||
let ping = decodeRequestPayload(request);
|
||||
checkPingFormat(ping, DELETION_PING_TYPE, true, false);
|
||||
}
|
||||
|
||||
// Register a new Ping Handler that asserts if a ping is received, then send a ping.
|
||||
registerPingHandler(() => Assert.ok(false, "Telemetry must not send pings if not allowed to."));
|
||||
let pingId = yield sendPing(true, true);
|
||||
|
Loading…
Reference in New Issue
Block a user