mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-09 16:57:36 +00:00
Bug 1585410 - Implement and document 'deletion-request' ping r=janerik,Dexter
The 'deletion-request' ping, which supercedes the 'optout' ping, notifies the pipeline when a profile opts out of FHR upload. (IOW, when a user on a specific profile unchecks the box in about:preferences#privacy about sharing technical and interaction data with Mozilla). This ping tries its best to reach the pipeline to let them know that we need to delete data associated with the provided clientId. This means it will remain pending on the client even after opt out and it will try to resend if upload is ever re-enabled. Differential Revision: https://phabricator.services.mozilla.com/D51710 --HG-- rename : toolkit/components/telemetry/docs/data/optout-ping.rst => toolkit/components/telemetry/docs/obsolete/optout-ping.rst rename : toolkit/components/telemetry/tests/marionette/tests/client/test_optout_ping.py => toolkit/components/telemetry/tests/marionette/tests/client/test_deletion_request_ping.py extra : moz-landing-system : lando
This commit is contained in:
parent
533e2b3a3c
commit
afbc898339
@ -45,7 +45,7 @@ const NEWPROFILE_PING_DEFAULT_DELAY = 30 * 60 * 1000;
|
||||
|
||||
// Ping types.
|
||||
const PING_TYPE_MAIN = "main";
|
||||
const PING_TYPE_OPTOUT = "optout";
|
||||
const PING_TYPE_DELETION_REQUEST = "deletion-request";
|
||||
|
||||
// Session ping reasons.
|
||||
const REASON_GATHER_PAYLOAD = "gather-payload";
|
||||
@ -200,6 +200,8 @@ var TelemetryController = Object.freeze({
|
||||
* environment data.
|
||||
* @param {Object} [aOptions.overrideEnvironment=null] set to override the environment data.
|
||||
* @param {Boolean} [aOptions.usePingSender=false] if true, send the ping using the PingSender.
|
||||
* @param {String} [aOptions.overrideClientId=undefined] if set, override the
|
||||
* client id to the provided value. Implies aOptions.addClientId=true.
|
||||
* @returns {Promise} Test-only - a promise that resolves with the ping id once the ping is stored or sent.
|
||||
*/
|
||||
submitExternalPing(aType, aPayload, aOptions = {}) {
|
||||
@ -233,6 +235,8 @@ var TelemetryController = Object.freeze({
|
||||
* @param {Boolean} [aOptions.overwrite=false] true overwrites a ping with the same name,
|
||||
* if found.
|
||||
* @param {Object} [aOptions.overrideEnvironment=null] set to override the environment data.
|
||||
* @param {String} [aOptions.overrideClientId=undefined] if set, override the
|
||||
* client id to the provided value. Implies aOptions.addClientId=true.
|
||||
*
|
||||
* @returns {Promise} A promise that resolves with the ping id when the ping is saved to
|
||||
* disk.
|
||||
@ -379,6 +383,8 @@ var Impl = {
|
||||
* @param {Boolean} aOptions.addEnvironment true if the ping should contain the
|
||||
* environment data.
|
||||
* @param {Object} [aOptions.overrideEnvironment=null] set to override the environment data.
|
||||
* @param {String} [aOptions.overrideClientId=undefined] if set, override the
|
||||
* client id to the provided value. Implies aOptions.addClientId=true.
|
||||
*
|
||||
* @returns {Object} An object that contains the assembled ping data.
|
||||
*/
|
||||
@ -402,8 +408,8 @@ var Impl = {
|
||||
payload,
|
||||
};
|
||||
|
||||
if (aOptions.addClientId) {
|
||||
pingData.clientId = this._clientID;
|
||||
if (aOptions.addClientId || aOptions.overrideClientId) {
|
||||
pingData.clientId = aOptions.overrideClientId || this._clientID;
|
||||
}
|
||||
|
||||
if (aOptions.addEnvironment) {
|
||||
@ -447,13 +453,16 @@ var Impl = {
|
||||
* environment data.
|
||||
* @param {Object} [aOptions.overrideEnvironment=null] set to override the environment data.
|
||||
* @param {Boolean} [aOptions.usePingSender=false] if true, send the ping using the PingSender.
|
||||
* @param {String} [aOptions.overrideClientId=undefined] if set, override the
|
||||
* client id to the provided value. Implies aOptions.addClientId=true.
|
||||
* @returns {Promise} Test-only - a promise that is resolved with the ping id once the ping is stored or sent.
|
||||
*/
|
||||
async _submitPingLogic(aType, aPayload, aOptions) {
|
||||
// Make sure to have a clientId if we need one. This cover the case of submitting
|
||||
// a ping early during startup, before Telemetry is initialized, if no client id was
|
||||
// cached.
|
||||
if (!this._clientID && aOptions.addClientId) {
|
||||
if (!this._clientID && aOptions.addClientId && !aOptions.overrideClientId) {
|
||||
this._log.trace("_submitPingLogic - Waiting on client id");
|
||||
Telemetry.getHistogramById(
|
||||
"TELEMETRY_PING_SUBMISSION_WAITING_CLIENTID"
|
||||
).add();
|
||||
@ -497,6 +506,8 @@ var Impl = {
|
||||
* environment data.
|
||||
* @param {Object} [aOptions.overrideEnvironment=null] set to override the environment data.
|
||||
* @param {Boolean} [aOptions.usePingSender=false] if true, send the ping using the PingSender.
|
||||
* @param {String} [aOptions.overrideClientId=undefined] if set, override the
|
||||
* client id to the provided value. Implies aOptions.addClientId=true.
|
||||
* @returns {Promise} Test-only - a promise that is resolved with the ping id once the ping is stored or sent.
|
||||
*/
|
||||
submitExternalPing: function send(aType, aPayload, aOptions) {
|
||||
@ -559,6 +570,8 @@ var Impl = {
|
||||
* environment data.
|
||||
* @param {Boolean} aOptions.overwrite true overwrites a ping with the same name, if found.
|
||||
* @param {Object} [aOptions.overrideEnvironment=null] set to override the environment data.
|
||||
* @param {String} [aOptions.overrideClientId=undefined] if set, override the
|
||||
* client id to the provided value. Implies aOptions.addClientId=true.
|
||||
*
|
||||
* @returns {Promise} A promise that resolves with the ping id when the ping is saved to
|
||||
* disk.
|
||||
@ -1002,7 +1015,7 @@ var Impl = {
|
||||
|
||||
/**
|
||||
* Called whenever the FHR Upload preference changes (e.g. when user disables FHR from
|
||||
* the preferences panel), this triggers sending the optout ping.
|
||||
* the preferences panel), this triggers sending the "deletion-request" ping.
|
||||
*/
|
||||
_onUploadPrefChange() {
|
||||
const uploadEnabled = Services.prefs.getBoolPref(
|
||||
@ -1050,13 +1063,18 @@ var Impl = {
|
||||
TelemetrySession.resetSubsessionCounter();
|
||||
|
||||
// 5. Set ClientID to a known value
|
||||
let oldClientId = this._clientID;
|
||||
this._clientID = await ClientID.setClientID(
|
||||
TelemetryUtils.knownClientID
|
||||
);
|
||||
|
||||
// 6. Send the optout ping.
|
||||
this._log.trace("_onUploadPrefChange - Sending optout ping.");
|
||||
this.submitExternalPing(PING_TYPE_OPTOUT, {}, { addClientId: false });
|
||||
// 6. Send the deletion-request ping.
|
||||
this._log.trace("_onUploadPrefChange - Sending deletion-request ping.");
|
||||
this.submitExternalPing(
|
||||
PING_TYPE_DELETION_REQUEST,
|
||||
{},
|
||||
{ overrideClientId: oldClientId }
|
||||
);
|
||||
}
|
||||
})();
|
||||
|
||||
@ -1070,7 +1088,7 @@ var Impl = {
|
||||
|
||||
_attachObservers() {
|
||||
if (IS_UNIFIED_TELEMETRY) {
|
||||
// Watch the FHR upload setting to trigger optout pings.
|
||||
// Watch the FHR upload setting to trigger "deletion-request" pings.
|
||||
Services.prefs.addObserver(
|
||||
TelemetryUtils.Preferences.FhrUploadEnabled,
|
||||
this,
|
||||
|
@ -70,7 +70,7 @@ const IS_UNIFIED_TELEMETRY = Services.prefs.getBoolPref(
|
||||
|
||||
const MS_IN_A_MINUTE = 60 * 1000;
|
||||
|
||||
const PING_TYPE_OPTOUT = "optout";
|
||||
const PING_TYPE_DELETION_REQUEST = "deletion-request";
|
||||
|
||||
// We try to spread "midnight" pings out over this interval.
|
||||
const MIDNIGHT_FUZZING_INTERVAL_MS = 60 * MS_IN_A_MINUTE;
|
||||
@ -133,12 +133,12 @@ function isV4PingFormat(aPing) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the provided ping is an optout ping.
|
||||
* Check if the provided ping is a deletion-request ping.
|
||||
* @param {Object} aPing The ping to check.
|
||||
* @return {Boolean} True if the ping is an optout ping, false otherwise.
|
||||
* @return {Boolean} True if the ping is a deletion-request ping, false otherwise.
|
||||
*/
|
||||
function isOptoutPing(aPing) {
|
||||
return isV4PingFormat(aPing) && aPing.type == PING_TYPE_OPTOUT;
|
||||
function isDeletionRequestPing(aPing) {
|
||||
return isV4PingFormat(aPing) && aPing.type == PING_TYPE_DELETION_REQUEST;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -239,7 +239,7 @@ var TelemetrySend = {
|
||||
/**
|
||||
* Check if sending is disabled. If Telemetry is not allowed to upload,
|
||||
* pings are not sent to the server.
|
||||
* If trying to send an optout ping, don't block it.
|
||||
* If trying to send a deletion-request ping, don't block it.
|
||||
*
|
||||
* @param {Object} [ping=null] A ping to be checked.
|
||||
* @return {Boolean} True if pings can be send to the servers, false otherwise.
|
||||
@ -486,7 +486,7 @@ var SendScheduler = {
|
||||
}
|
||||
|
||||
// Get a list of pending pings, sorted by last modified, descending.
|
||||
// Filter out all the pings we can't send now. This addresses scenarios like "optout" pings
|
||||
// Filter out all the pings we can't send now. This addresses scenarios like "deletion-request" pings
|
||||
// which can be sent even when upload is disabled.
|
||||
let pending = TelemetryStorage.getPendingPingList();
|
||||
let current = TelemetrySendImpl.getUnpersistedPings();
|
||||
@ -499,9 +499,9 @@ var SendScheduler = {
|
||||
// Note that the two lists contain different kind of data. |pending| only holds ping
|
||||
// info, while |current| holds actual ping data.
|
||||
if (!TelemetrySendImpl.sendingEnabled()) {
|
||||
// If sending is disabled, only handle an unpersisted optout ping
|
||||
// If sending is disabled, only handle deletion-request pings
|
||||
pending = [];
|
||||
current = current.filter(p => isOptoutPing(p));
|
||||
current = current.filter(p => isDeletionRequestPing(p));
|
||||
}
|
||||
this._log.trace(
|
||||
"_doSendTask - can send - pending: " +
|
||||
@ -1083,19 +1083,11 @@ var TelemetrySendImpl = {
|
||||
try {
|
||||
await this._doPing(ping, ping.id, false);
|
||||
} catch (ex) {
|
||||
if (isOptoutPing(ping)) {
|
||||
// Optout pings should only be tried once and then discarded.
|
||||
this._log.info(
|
||||
"sendPings - optout ping " + ping.id + " not sent, discarding",
|
||||
ex
|
||||
);
|
||||
} else {
|
||||
this._log.info(
|
||||
"sendPings - ping " + ping.id + " not sent, saving to disk",
|
||||
ex
|
||||
);
|
||||
await savePing(ping);
|
||||
}
|
||||
this._log.info(
|
||||
"sendPings - ping " + ping.id + " not sent, saving to disk",
|
||||
ex
|
||||
);
|
||||
await savePing(ping);
|
||||
} finally {
|
||||
this._currentPings.delete(ping.id);
|
||||
}
|
||||
@ -1458,7 +1450,7 @@ var TelemetrySendImpl = {
|
||||
/**
|
||||
* Check if sending is disabled. If Telemetry is not allowed to upload,
|
||||
* pings are not sent to the server.
|
||||
* If trying to send an optout ping, don't block it.
|
||||
* If trying to send a "deletion-request" ping, don't block it.
|
||||
* If unified telemetry is off, don't send pings if Telemetry is disabled.
|
||||
*
|
||||
* @param {Object} [ping=null] A ping to be checked.
|
||||
@ -1477,8 +1469,8 @@ var TelemetrySendImpl = {
|
||||
// With unified Telemetry, the FHR upload setting controls whether we can send pings.
|
||||
// The Telemetry pref enables sending extended data sets instead.
|
||||
if (IS_UNIFIED_TELEMETRY) {
|
||||
// Optout pings are sent once even if the upload is disabled.
|
||||
if (ping && isOptoutPing(ping)) {
|
||||
// "deletion-request" pings are sent once even if the upload is disabled.
|
||||
if (ping && isDeletionRequestPing(ping)) {
|
||||
return true;
|
||||
}
|
||||
return Services.prefs.getBoolPref(
|
||||
@ -1523,11 +1515,8 @@ var TelemetrySendImpl = {
|
||||
async _persistCurrentPings() {
|
||||
for (let [id, ping] of this._currentPings) {
|
||||
try {
|
||||
// Never save an optout ping to disk
|
||||
if (!isOptoutPing(ping)) {
|
||||
await savePing(ping);
|
||||
this._log.trace("_persistCurrentPings - saved ping " + id);
|
||||
}
|
||||
await savePing(ping);
|
||||
this._log.trace("_persistCurrentPings - saved ping " + id);
|
||||
} catch (ex) {
|
||||
this._log.error("_persistCurrentPings - failed to save ping " + id, ex);
|
||||
} finally {
|
||||
|
@ -26,4 +26,4 @@ Important examples are:
|
||||
* :doc:`crash <../data/crash-ping>` - a ping that is captured and sent after a Firefox process crashes.
|
||||
* :doc:`new-profile <../data/new-profile-ping>` - sent on the first run of a new profile.
|
||||
* :doc:`update <../data/update-ping>` - sent right after an update is downloaded.
|
||||
* :doc:`optout <../data/optout-ping>` - sent when FHR upload is disabled
|
||||
* :doc:`deletion-request <../data/deletion-request-ping>` - sent when FHR upload is disabled
|
||||
|
@ -0,0 +1,35 @@
|
||||
"deletion-request" ping
|
||||
=======================
|
||||
|
||||
This ping is submitted when a user opts out of sending technical and interaction data to Mozilla.
|
||||
(In other words, when the
|
||||
``datareporting.healthreport.uploadEnabled``
|
||||
:doc:`preference <../internals/preferences>` is set to ``false``.)
|
||||
|
||||
This ping contains the client id.
|
||||
This ping does not contain any environment data.
|
||||
|
||||
Structure:
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
{
|
||||
version: 4,
|
||||
type: "deletion-request",
|
||||
... common ping data (including clientId)
|
||||
payload: { }
|
||||
}
|
||||
|
||||
Expected behaviours
|
||||
-------------------
|
||||
The following is a list of expected behaviours for the ``deletion-request`` ping:
|
||||
|
||||
- Telemetry will try to send the ping even if upload is disabled.
|
||||
- Telemetry may persist this ping if it can't be immediately sent, and may try to resend it later.
|
||||
|
||||
Version History
|
||||
---------------
|
||||
|
||||
- Firefox 70:
|
||||
|
||||
- "deletion-request" ping replaces the "optout" ping (`bug 1585410 <https://bugzilla.mozilla.org/show_bug.cgi?id=1585410>`_).
|
@ -10,8 +10,6 @@ Data documentation
|
||||
common-ping
|
||||
environment
|
||||
main-ping
|
||||
optout-ping
|
||||
deletion-ping
|
||||
crash-ping
|
||||
backgroundhangmonitor-ping
|
||||
anonymous-ping
|
||||
|
@ -11,3 +11,4 @@ Obsolete Documentation
|
||||
uitelemetry/index
|
||||
fhr/index
|
||||
hybrid-content
|
||||
optout-ping
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
"optout" ping
|
||||
=============
|
||||
"optout" ping (obsolete)
|
||||
========================
|
||||
|
||||
This ping is generated when a user turns off FHR upload from the Preferences panel, changing the related ``datareporting.healthreport.uploadEnabled`` :doc:`preference <../internals/preferences>`.
|
||||
|
@ -10,6 +10,16 @@ class PingFilter(object):
|
||||
return True
|
||||
|
||||
|
||||
class DeletionRequestPingFilter(PingFilter):
|
||||
"""Ping filter that accepts deletion-request pings."""
|
||||
|
||||
def __call__(self, ping):
|
||||
if not super(DeletionRequestPingFilter, self).__call__(ping):
|
||||
return False
|
||||
|
||||
return ping["type"] == "deletion-request"
|
||||
|
||||
|
||||
class EventPingFilter(PingFilter):
|
||||
"""Ping filter that accepts event pings."""
|
||||
|
||||
@ -56,20 +66,10 @@ class MainPingReasonFilter(MainPingFilter):
|
||||
return ping["payload"]["info"]["reason"] == self.reason
|
||||
|
||||
|
||||
class OptoutPingFilter(PingFilter):
|
||||
"""Ping filter that accepts optout pings."""
|
||||
|
||||
def __call__(self, ping):
|
||||
if not super(OptoutPingFilter, self).__call__(ping):
|
||||
return False
|
||||
|
||||
return ping["type"] == "optout"
|
||||
|
||||
|
||||
ANY_PING = PingFilter()
|
||||
DELETION_REQUEST_PING = DeletionRequestPingFilter()
|
||||
EVENT_PING = EventPingFilter()
|
||||
FIRST_SHUTDOWN_PING = FirstShutdownPingFilter()
|
||||
MAIN_PING = MainPingFilter()
|
||||
MAIN_SHUTDOWN_PING = MainPingReasonFilter("shutdown")
|
||||
MAIN_ENVIRONMENT_CHANGE_PING = MainPingReasonFilter("environment-change")
|
||||
OPTOUT_PING = OptoutPingFilter()
|
||||
|
@ -1,8 +1,8 @@
|
||||
[DEFAULT]
|
||||
tags = client
|
||||
|
||||
[test_deletion_request_ping.py]
|
||||
[test_event_ping.py]
|
||||
[test_main_tab_scalars.py]
|
||||
[test_optout_ping.py]
|
||||
[test_search_counts_across_sessions.py]
|
||||
[test_subsession_management.py]
|
||||
|
@ -3,11 +3,11 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
from telemetry_harness.testcase import TelemetryTestCase
|
||||
from telemetry_harness.ping_filters import ANY_PING, OPTOUT_PING, MAIN_SHUTDOWN_PING
|
||||
from telemetry_harness.ping_filters import ANY_PING, DELETION_REQUEST_PING, MAIN_SHUTDOWN_PING
|
||||
|
||||
|
||||
class TestOptoutPing(TelemetryTestCase):
|
||||
"""Tests for "optout" ping."""
|
||||
class TestDeletionRequestPing(TelemetryTestCase):
|
||||
"""Tests for "deletion-request" ping."""
|
||||
|
||||
def disable_telemetry(self):
|
||||
self.marionette.instance.profile.set_persistent_preferences(
|
||||
@ -20,18 +20,18 @@ class TestOptoutPing(TelemetryTestCase):
|
||||
self.marionette.set_pref("datareporting.healthreport.uploadEnabled", True)
|
||||
|
||||
def test_optout_ping_across_sessions(self):
|
||||
"""Test the "optout" ping behaviour across sessions."""
|
||||
"""Test the "deletion-request" ping behaviour across sessions."""
|
||||
|
||||
# Get the client_id.
|
||||
client_id = self.wait_for_ping(self.install_addon, ANY_PING)["clientId"]
|
||||
self.assertIsValidUUID(client_id)
|
||||
|
||||
# Trigger an "optout" ping.
|
||||
optout_ping = self.wait_for_ping(self.disable_telemetry, OPTOUT_PING)
|
||||
# Trigger an "deletion-request" ping.
|
||||
ping = self.wait_for_ping(self.disable_telemetry, DELETION_REQUEST_PING)
|
||||
|
||||
self.assertNotIn("clientId", optout_ping)
|
||||
self.assertIn("payload", optout_ping)
|
||||
self.assertNotIn("environment", optout_ping["payload"])
|
||||
self.assertIn("clientId", ping)
|
||||
self.assertIn("payload", ping)
|
||||
self.assertNotIn("environment", ping["payload"])
|
||||
|
||||
# Close Firefox cleanly.
|
||||
self.marionette.quit(in_app=True)
|
||||
@ -45,7 +45,7 @@ class TestOptoutPing(TelemetryTestCase):
|
||||
self.install_addon()
|
||||
|
||||
# Ensure we've sent no pings since "optout".
|
||||
self.assertEqual(self.ping_server.pings[-1], optout_ping)
|
||||
self.assertEqual(self.ping_server.pings[-1], ping)
|
||||
|
||||
# Turn Telemetry back on.
|
||||
self.enable_telemetry()
|
@ -209,7 +209,7 @@ function decodeRequestPayload(request) {
|
||||
Assert.notEqual(
|
||||
TelemetryUtils.knownClientID,
|
||||
payload.clientId,
|
||||
"Known clientId should never appear in a ping on the server"
|
||||
`Known clientId shouldn't appear in a "${payload.type}" ping on the server.`
|
||||
);
|
||||
|
||||
return payload;
|
||||
|
@ -13,7 +13,7 @@ const { Preferences } = ChromeUtils.import(
|
||||
);
|
||||
|
||||
const PING_FORMAT_VERSION = 4;
|
||||
const OPTOUT_PING_TYPE = "optout";
|
||||
const DELETION_REQUEST_PING_TYPE = "deletion-request";
|
||||
const TEST_PING_TYPE = "test-ping-type";
|
||||
|
||||
function sendPing(addEnvironment = false) {
|
||||
@ -55,7 +55,7 @@ add_task(async function test_setup() {
|
||||
* 6. Detect that upload is enabled and reset client ID
|
||||
*
|
||||
* This scenario e.g. happens when switching between channels
|
||||
* with and without the optout ping reset included.
|
||||
* with and without the deletion-request ping reset included.
|
||||
*/
|
||||
add_task(async function test_clientid_reset_after_reenabling() {
|
||||
await sendPing();
|
||||
@ -70,12 +70,16 @@ add_task(async function test_clientid_reset_after_reenabling() {
|
||||
"Client ID should be valid and random"
|
||||
);
|
||||
|
||||
// Disable FHR upload: this should trigger a optout ping.
|
||||
// Disable FHR upload: this should trigger a deletion-request ping.
|
||||
Preferences.set(TelemetryUtils.Preferences.FhrUploadEnabled, false);
|
||||
|
||||
ping = await PingServer.promiseNextPing();
|
||||
Assert.equal(ping.type, OPTOUT_PING_TYPE, "The ping must be an optout ping");
|
||||
Assert.ok(!("clientId" in ping));
|
||||
Assert.equal(
|
||||
ping.type,
|
||||
DELETION_REQUEST_PING_TYPE,
|
||||
"The ping must be a deletion-request ping"
|
||||
);
|
||||
Assert.equal(ping.clientId, firstClientId);
|
||||
let clientId = await ClientID.getClientID();
|
||||
Assert.equal(TelemetryUtils.knownClientID, clientId);
|
||||
|
||||
@ -115,7 +119,7 @@ add_task(async function test_clientid_reset_after_reenabling() {
|
||||
* 6. Detect that upload is disabled and sets canary client ID
|
||||
*
|
||||
* This scenario e.g. happens when switching between channels
|
||||
* with and without the optout ping reset included.
|
||||
* with and without the deletion-request ping reset included.
|
||||
*/
|
||||
add_task(async function test_clientid_canary_after_disabling() {
|
||||
await sendPing();
|
||||
@ -130,12 +134,16 @@ add_task(async function test_clientid_canary_after_disabling() {
|
||||
"Client ID should be valid and random"
|
||||
);
|
||||
|
||||
// Disable FHR upload: this should trigger a optout ping.
|
||||
// Disable FHR upload: this should trigger a deletion-request ping.
|
||||
Preferences.set(TelemetryUtils.Preferences.FhrUploadEnabled, false);
|
||||
|
||||
ping = await PingServer.promiseNextPing();
|
||||
Assert.equal(ping.type, OPTOUT_PING_TYPE, "The ping must be an optout ping");
|
||||
Assert.ok(!("clientId" in ping));
|
||||
Assert.equal(
|
||||
ping.type,
|
||||
DELETION_REQUEST_PING_TYPE,
|
||||
"The ping must be a deletion-request ping"
|
||||
);
|
||||
Assert.equal(ping.clientId, firstClientId);
|
||||
let clientId = await ClientID.getClientID();
|
||||
Assert.equal(TelemetryUtils.knownClientID, clientId);
|
||||
|
||||
|
@ -25,7 +25,7 @@ const { Preferences } = ChromeUtils.import(
|
||||
ChromeUtils.import("resource://testing-common/ContentTaskUtils.jsm", this);
|
||||
|
||||
const PING_FORMAT_VERSION = 4;
|
||||
const OPTOUT_PING_TYPE = "optout";
|
||||
const DELETION_REQUEST_PING_TYPE = "deletion-request";
|
||||
const TEST_PING_TYPE = "test-ping-type";
|
||||
|
||||
const PLATFORM_VERSION = "1.9.2";
|
||||
@ -159,8 +159,7 @@ add_task(async function test_disableDataUpload() {
|
||||
const OPTIN_PROBE = "telemetry.data_upload_optin";
|
||||
const isUnified = Preferences.get(TelemetryUtils.Preferences.Unified, false);
|
||||
if (!isUnified) {
|
||||
// Skipping the test if unified telemetry is off, as no optout ping will
|
||||
// be generated.
|
||||
// Skipping the test if unified telemetry is off, as no deletion-request ping will be generated.
|
||||
return;
|
||||
}
|
||||
|
||||
@ -184,18 +183,18 @@ add_task(async function test_disableDataUpload() {
|
||||
"Client ID should be valid and random"
|
||||
);
|
||||
|
||||
// Disable FHR upload: this should trigger a optout ping.
|
||||
// Disable FHR upload: this should trigger a deletion-request ping.
|
||||
Preferences.set(TelemetryUtils.Preferences.FhrUploadEnabled, false);
|
||||
|
||||
ping = await PingServer.promiseNextPing();
|
||||
checkPingFormat(ping, OPTOUT_PING_TYPE, false, false);
|
||||
checkPingFormat(ping, DELETION_REQUEST_PING_TYPE, true, false);
|
||||
// Wait on ping activity to settle.
|
||||
await TelemetrySend.testWaitOnOutgoingPings();
|
||||
|
||||
snapshot = Telemetry.getSnapshotForScalars("main", false).parent || {};
|
||||
Assert.ok(
|
||||
!(OPTIN_PROBE in snapshot),
|
||||
"Data optin scalar should not be set after optout"
|
||||
"Data optin scalar should not be set after opt out"
|
||||
);
|
||||
|
||||
// Restore FHR Upload.
|
||||
@ -216,13 +215,21 @@ add_task(async function test_disableDataUpload() {
|
||||
"Enabling data upload should set optin probe"
|
||||
);
|
||||
|
||||
// Simulate a failure in sending the optout ping by disabling the HTTP server.
|
||||
// The clientId should've been reset when we restored FHR Upload.
|
||||
let secondClientId = TelemetryController.getCurrentPingData().clientId;
|
||||
Assert.notEqual(
|
||||
firstClientId,
|
||||
secondClientId,
|
||||
"The client id must have changed"
|
||||
);
|
||||
|
||||
// Simulate a failure in sending the deletion-request ping by disabling the HTTP server.
|
||||
await PingServer.stop();
|
||||
|
||||
// Try to send a ping. It will be saved as pending and get deleted when disabling upload.
|
||||
TelemetryController.submitExternalPing(TEST_PING_TYPE, {});
|
||||
|
||||
// Disable FHR upload to send a optout ping again.
|
||||
// Disable FHR upload to send a deletion-request ping again.
|
||||
Preferences.set(TelemetryUtils.Preferences.FhrUploadEnabled, false);
|
||||
|
||||
// Wait on sending activity to settle, as |TelemetryController.testReset()| doesn't do that.
|
||||
@ -237,9 +244,10 @@ add_task(async function test_disableDataUpload() {
|
||||
let pendingPings = await TelemetryStorage.loadPendingPingList();
|
||||
Assert.equal(
|
||||
pendingPings.length,
|
||||
0,
|
||||
"All the pending pings should have been deleted, including the optout ping"
|
||||
1,
|
||||
"All the pending pings should have been deleted, except the deletion-request ping"
|
||||
);
|
||||
Assert.ok(true, JSON.stringify(PingServer._defers) + "\n\n\n");
|
||||
|
||||
// Enable the ping server again.
|
||||
PingServer.start();
|
||||
@ -261,7 +269,7 @@ add_task(async function test_disableDataUpload() {
|
||||
// Send a test ping
|
||||
await sendPing(true, false);
|
||||
|
||||
// We should have only received the test ping
|
||||
// We should have received the test ping first.
|
||||
ping = await PingServer.promiseNextPing();
|
||||
checkPingFormat(ping, TEST_PING_TYPE, true, false);
|
||||
|
||||
@ -277,6 +285,15 @@ add_task(async function test_disableDataUpload() {
|
||||
"Client ID should be different from the previous value"
|
||||
);
|
||||
|
||||
// The "deletion-request" ping should come next, as it was pending.
|
||||
ping = await PingServer.promiseNextPing();
|
||||
checkPingFormat(ping, DELETION_REQUEST_PING_TYPE, true, false);
|
||||
Assert.equal(
|
||||
secondClientId,
|
||||
ping.clientId,
|
||||
"Deletion must be requested for correct client id"
|
||||
);
|
||||
|
||||
// Wait on ping activity to settle before moving on to the next test. If we were
|
||||
// to shut down telemetry, even though the PingServer caught the expected pings,
|
||||
// TelemetrySend could still be processing them (clearing pings would happen in
|
||||
@ -404,11 +421,10 @@ add_task(async function test_archivePings() {
|
||||
: TelemetryUtils.Preferences.TelemetryEnabled;
|
||||
Preferences.set(uploadPref, false);
|
||||
|
||||
// If we're using unified telemetry, disabling ping upload will generate a "optout"
|
||||
// ping. Catch it.
|
||||
// If we're using unified telemetry, disabling ping upload will generate a "deletion-request" ping. Catch it.
|
||||
if (isUnified) {
|
||||
let ping = await PingServer.promiseNextPing();
|
||||
checkPingFormat(ping, OPTOUT_PING_TYPE, false, false);
|
||||
checkPingFormat(ping, DELETION_REQUEST_PING_TYPE, true, false);
|
||||
}
|
||||
|
||||
// Register a new Ping Handler that asserts if a ping is received, then send a ping.
|
||||
|
Loading…
x
Reference in New Issue
Block a user