Bug 1236580 - Fix the tests and update the documentation. r=gfritzsche
--- a/browser/base/content/test/general/browser_aboutHealthReport.js
+++ b/browser/base/content/test/general/browser_aboutHealthReport.js
@@ -9,29 +9,27 @@ XPCOMUtils.defineLazyModuleGetter(this,
const CHROME_BASE = "chrome://mochitests/content/browser/browser/base/content/test/general/";
const HTTPS_BASE = "https://example.com/browser/browser/base/content/test/general/";
const TELEMETRY_LOG_PREF = "toolkit.telemetry.log.level";
const telemetryOriginalLogPref = Preferences.get(TELEMETRY_LOG_PREF, null);
const originalReportUrl = Services.prefs.getCharPref("datareporting.healthreport.about.reportUrl");
-const originalReportUrlUnified = Services.prefs.getCharPref("datareporting.healthreport.about.reportUrlUnified");
registerCleanupFunction(function() {
// Ensure we don't pollute prefs for next tests.
if (telemetryOriginalLogPref) {
Preferences.set(TELEMETRY_LOG_PREF, telemetryOriginalLogPref);
} else {
Preferences.reset(TELEMETRY_LOG_PREF);
}
try {
Services.prefs.setCharPref("datareporting.healthreport.about.reportUrl", originalReportUrl);
- Services.prefs.setCharPref("datareporting.healthreport.about.reportUrlUnified", originalReportUrlUnified);
Services.prefs.setBoolPref("datareporting.healthreport.uploadEnabled", true);
} catch (ex) {}
});
function fakeTelemetryNow(...args) {
let date = new Date(...args);
let scope = {};
const modules = [
@@ -64,18 +62,16 @@ var gTests = [
{
desc: "Test the remote commands",
setup: Task.async(function*()
{
Preferences.set(TELEMETRY_LOG_PREF, "Trace");
yield setupPingArchive();
Preferences.set("datareporting.healthreport.about.reportUrl",
HTTPS_BASE + "healthreport_testRemoteCommands.html");
- Preferences.set("datareporting.healthreport.about.reportUrlUnified",
- HTTPS_BASE + "healthreport_testRemoteCommands.html");
}),
run: function (iframe)
{
let deferred = Promise.defer();
let results = 0;
try {
iframe.contentWindow.addEventListener("FirefoxHealthReportTestResponse", function evtHandler(event) {
let data = event.detail.data;
--- a/toolkit/components/telemetry/docs/environment.rst
+++ b/toolkit/components/telemetry/docs/environment.rst
@@ -39,17 +39,16 @@ Structure::
defaultSearchEngineData: {, // data about the current default engine
name: <string>, // engine name, e.g. "Yahoo"; or "NONE" if no default
loadPath: <string>, // where the engine line is located; missing if no default
submissionURL: <string> // missing if no default or for user-installed engines
},
searchCohort: <string>, // optional, contains an identifier for any active search A/B experiments
e10sEnabled: <bool>, // whether e10s is on, i.e. browser tabs open by default in a different process
telemetryEnabled: <bool>, // false on failure
- isInOptoutSample: <bool>, // whether this client is part of the opt-out sample
locale: <string>, // e.g. "it", null on failure
update: {
channel: <string>, // e.g. "release", null on failure
enabled: <bool>, // true on failure
autoDownload: <bool>, // true on failure
},
userPrefs: {
// Only prefs which are changed from the default value are listed
--- a/toolkit/components/telemetry/docs/preferences.rst
+++ b/toolkit/components/telemetry/docs/preferences.rst
@@ -14,26 +14,16 @@ Preferences
``toolkit.telemetry.unified``
This controls whether unified behavior is enabled. If true:
* Telemetry is always enabled and recording *base* data.
* Telemetry will send additional ``main`` pings.
-``toolkit.telemetry.unifiedIsOptIn``
-
- When true, we enable the Telemetry system only for people that opted into Telemetry, even if unified Telemetry is enabled.
- Defaults to false & requires a restart.
-
-``toolkit.telemetry.optoutSample``
-
- When true, we enable Telemetry opt-out for a sample of users when ``.unified`` and ``unifiedIsOptIn`` are on.
- Defaults to false.
-
``toolkit.telemetry.enabled``
If ``unified`` is off, this controls whether the Telemetry module is enabled.
If ``unified`` is on, this controls whether to record *extended* data.
This preference is controlled through the `Preferences` dialog.
Note that the default value here of this pref depends on the define ``RELEASE_BUILD`` and the channel.
If ``RELEASE_BUILD`` is set, ``MOZ_TELEMETRY_ON_BY_DEFAULT`` gets set, which means this pref will default to ``true``.
@@ -66,20 +56,16 @@ Data-choices notification
``toolkit.telemetry.reportingpolicy.firstRun``
This preference is not present until the first run. After, its value is set to false. This is used to show the infobar with a more aggressive timeout if it wasn't shown yet.
``datareporting.policy.dataSubmissionEnabled``
This is the data submission master kill switch. If disabled, no policy is shown or upload takes place, ever.
-``datareporting.policy.dataSubmissionEnabled.v2``
-
- If disabled, FHR v2 data will not be sent to Mozilla servers. Telemetry v4 data submission will not be affected. This is like ``datareporting.policy.dataSubmissionEnabled``, but only affects FHR - Telemetry upload will not be disabled.
-
``datareporting.policy.dataSubmissionPolicyNotifiedTime``
Records the date user was shown the policy. This preference is also used on Android.
``datareporting.policy.dataSubmissionPolicyAcceptedVersion``
Records the version of the policy notified to the user. This preference is also used on Android.
--- a/toolkit/components/telemetry/tests/unit/head.js
+++ b/toolkit/components/telemetry/tests/unit/head.js
@@ -279,21 +279,16 @@ function fakeGeneratePingId(func) {
module.Policy.generatePingId = func;
}
function fakeCachedClientId(uuid) {
let module = Cu.import("resource://gre/modules/TelemetryController.jsm");
module.Policy.getCachedClientID = () => uuid;
}
-function fakeIsUnifiedOptin(isOptin) {
- let module = Cu.import("resource://gre/modules/TelemetryController.jsm");
- module.Policy.isUnifiedOptin = () => isOptin;
-}
-
// Return a date that is |offset| ms in the future from |date|.
function futureDate(date, offset) {
return new Date(date.getTime() + offset);
}
function truncateToDays(aMsec) {
return Math.floor(aMsec / MILLISECONDS_PER_DAY);
}
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryController.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryController.js
@@ -27,17 +27,16 @@ const PLATFORM_VERSION = "1.9.2";
const APP_VERSION = "1";
const APP_NAME = "XPCShell";
const PREF_BRANCH = "toolkit.telemetry.";
const PREF_ENABLED = PREF_BRANCH + "enabled";
const PREF_ARCHIVE_ENABLED = PREF_BRANCH + "archive.enabled";
const PREF_FHR_UPLOAD_ENABLED = "datareporting.healthreport.uploadEnabled";
const PREF_UNIFIED = PREF_BRANCH + "unified";
-const PREF_OPTOUT_SAMPLE = PREF_BRANCH + "optoutSample";
var gClientID = null;
function sendPing(aSendClientId, aSendEnvironment) {
if (PingServer.started) {
TelemetrySend.setServer("http://localhost:" + PingServer.port);
} else {
TelemetrySend.setServer("http://doesnotexist");
@@ -368,74 +367,16 @@ add_task(function* test_changePingAfterS
const pingId = yield pingPromise;
// Make sure our changes didn't affect the submitted payload.
let archivedCopy = yield TelemetryArchive.promiseArchivedPingById(pingId);
Assert.equal(archivedCopy.payload.canary, "test",
"The payload must not be changed after being submitted.");
});
-add_task(function* test_optoutSampling() {
- if (!Preferences.get(PREF_UNIFIED, false)) {
- dump("Unified Telemetry is disabled, skipping.\n");
- return;
- }
-
- const DATA = [
- {uuid: null, sampled: false}, // not to be sampled
- {uuid: "3d38d821-14a4-3d45-ab0b-02a9fb5a7505", sampled: false}, // samples to 0
- {uuid: "1331255e-7eb5-aa4f-b04e-494a0c6da282", sampled: false}, // samples to 41
- {uuid: "35393e78-a363-ea4e-9fc9-9f9abbee2077", sampled: true }, // samples to 42
- {uuid: "4dc81df6-db03-a34e-ba79-3e877afd22c4", sampled: true }, // samples to 43
- {uuid: "79e15be6-4884-8d4f-98e5-f94790251e5f", sampled: true }, // samples to 44
- {uuid: "c3841566-e39e-384d-826f-508ab6387b21", sampled: true }, // samples to 45
- {uuid: "cc7498a4-2cde-da47-89b3-f3ce5dd7c6fc", sampled: true }, // samples to 46
- {uuid: "0750d8ed-5969-3a4f-90ba-2e85f9074309", sampled: false}, // samples to 47
- {uuid: "0dfcbce7-d82b-b144-8d77-eb15935c9a8e", sampled: false}, // samples to 99
- ];
-
- // Test that the opt-out pref enables us sampling on 5% of release.
- Preferences.set(PREF_ENABLED, false);
- Preferences.set(PREF_OPTOUT_SAMPLE, true);
- fakeIsUnifiedOptin(true);
-
- for (let d of DATA) {
- dump("Testing sampling for uuid: " + d.uuid + "\n");
- fakeCachedClientId(d.uuid);
- yield TelemetryController.reset();
- Assert.equal(TelemetryController.isInOptoutSample, d.sampled,
- "Opt-out sampling should behave as expected");
- Assert.equal(Telemetry.canRecordBase, d.sampled,
- "Base recording setting should be correct");
- }
-
- // If we disable opt-out sampling Telemetry, have the opt-in setting on and extended Telemetry off,
- // we should not enable anything.
- Preferences.set(PREF_OPTOUT_SAMPLE, false);
- fakeIsUnifiedOptin(true);
- for (let d of DATA) {
- dump("Testing sampling for uuid: " + d.uuid + "\n");
- fakeCachedClientId(d.uuid);
- yield TelemetryController.reset();
- Assert.equal(Telemetry.canRecordBase, false,
- "Sampling should not override the default opt-out behavior");
- }
-
- // If we fully enable opt-out Telemetry on release, the sampling should not override that.
- Preferences.set(PREF_OPTOUT_SAMPLE, true);
- fakeIsUnifiedOptin(false);
- for (let d of DATA) {
- dump("Testing sampling for uuid: " + d.uuid + "\n");
- fakeCachedClientId(d.uuid);
- yield TelemetryController.reset();
- Assert.equal(Telemetry.canRecordBase, true,
- "Sampling should not override the default opt-out behavior");
- }
-});
-
add_task(function* test_telemetryEnabledUnexpectedValue(){
// Remove the default value for toolkit.telemetry.enabled from the default prefs.
// Otherwise, we wouldn't be able to set the pref to a string.
let defaultPrefBranch = Services.prefs.getDefaultBranch(null);
defaultPrefBranch.deleteBranch(PREF_ENABLED);
// Set the preferences controlling the Telemetry status to a string.
Preferences.set(PREF_ENABLED, "false");
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js
@@ -333,17 +333,16 @@ function checkBuildSection(data) {
}
}
function checkSettingsSection(data) {
const EXPECTED_FIELDS_TYPES = {
blocklistEnabled: "boolean",
e10sEnabled: "boolean",
telemetryEnabled: "boolean",
- isInOptoutSample: "boolean",
locale: "string",
update: "object",
userPrefs: "object",
};
Assert.ok("settings" in data, "There must be a settings section in Environment.");
for (let f in EXPECTED_FIELDS_TYPES) {