Bug 1429153 - Add policy for disabling telemetry. r=Felipe, a=RyanVM
authorMichael Kaply <mozilla@kaply.com>
Thu, 29 Mar 2018 10:44:12 -0500
changeset 462940 60416c55a73b8d65e15e81eadb52078b2550c680
parent 462939 54d48c08e4c952384c7e31b391396f7f8784e247
child 462941 cd55743cae2c4dfb05920ba0602c7735a3c95505
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersFelipe, RyanVM
bugs1429153
milestone60.0
Bug 1429153 - Add policy for disabling telemetry. r=Felipe, a=RyanVM MozReview-Commit-ID: 6fGGuJzZUhU
browser/components/enterprisepolicies/Policies.jsm
browser/components/enterprisepolicies/schemas/policies-schema.json
browser/components/enterprisepolicies/tests/browser/browser.ini
browser/components/enterprisepolicies/tests/browser/browser_policy_disable_telemetry.js
--- a/browser/components/enterprisepolicies/Policies.jsm
+++ b/browser/components/enterprisepolicies/Policies.jsm
@@ -227,16 +227,25 @@ var Policies = {
   "DisableSysAddonUpdate": {
     onBeforeAddons(manager, param) {
       if (param) {
         manager.disallowFeature("SysAddonUpdate");
       }
     }
   },
 
+  "DisableTelemetry": {
+    onBeforeAddons(manager, param) {
+      if (param) {
+        setAndLockPref("datareporting.healthreport.uploadEnabled", false);
+        setAndLockPref("datareporting.policy.dataSubmissionEnabled", false);
+      }
+    }
+  },
+
   "DisplayBookmarksToolbar": {
     onBeforeUIStartup(manager, param) {
       let value = (!param).toString();
       // This policy is meant to change the default behavior, not to force it.
       // If this policy was alreay applied and the user chose to re-hide the
       // bookmarks toolbar, do not show it again.
       runOncePerModification("displayBookmarksToolbar", value, () => {
         gXulStore.setValue(BROWSER_DOCUMENT_URL, "PersonalToolbar", "collapsed", value);
--- a/browser/components/enterprisepolicies/schemas/policies-schema.json
+++ b/browser/components/enterprisepolicies/schemas/policies-schema.json
@@ -180,16 +180,24 @@
     "DisableSysAddonUpdate": {
       "description": "Prevent the browser from installing and updating system addons.",
       "first_available": "60.0",
       "enterprise_only": true,
 
       "type": "boolean"
     },
 
+    "DisableTelemetry": {
+      "description": "Turns off telemetry.",
+      "first_available": "60.0",
+      "enterprise_only": true,
+
+      "type": "boolean"
+    },
+
     "DisplayBookmarksToolbar": {
       "description": "Causes the bookmarks toolbar to be displayed by default.",
       "first_available": "60.0",
 
       "type": "boolean"
     },
 
     "DisplayMenuBar": {
--- a/browser/components/enterprisepolicies/tests/browser/browser.ini
+++ b/browser/components/enterprisepolicies/tests/browser/browser.ini
@@ -28,13 +28,14 @@ support-files =
 [browser_policy_disable_feedback_commands.js]
 [browser_policy_disable_fxaccounts.js]
 [browser_policy_disable_masterpassword.js]
 [browser_policy_disable_pdfjs.js]
 [browser_policy_disable_pocket.js]
 [browser_policy_disable_privatebrowsing.js]
 [browser_policy_disable_safemode.js]
 [browser_policy_disable_shield.js]
+[browser_policy_disable_telemetry.js]
 [browser_policy_display_bookmarks.js]
 [browser_policy_display_menu.js]
 [browser_policy_proxy.js]
 [browser_policy_search_engine.js]
 [browser_policy_set_homepage.js]
new file mode 100644
--- /dev/null
+++ b/browser/components/enterprisepolicies/tests/browser/browser_policy_disable_telemetry.js
@@ -0,0 +1,19 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+add_task(async function test_policy_disable_telemetry() {
+  const { TelemetryReportingPolicy } = ChromeUtils.import("resource://gre/modules/TelemetryReportingPolicy.jsm", {});
+
+  ok(TelemetryReportingPolicy, "TelemetryReportingPolicy exists");
+  is(TelemetryReportingPolicy.canUpload(), true, "Telemetry is enabled");
+
+  await setupPolicyEngineWithJson({
+    "policies": {
+      "DisableTelemetry": true
+    }
+  });
+
+  is(TelemetryReportingPolicy.canUpload(), false, "Telemetry is disabled");
+});