Commit e8acc1d1 authored by Michael Kaply's avatar Michael Kaply Committed by rvandermeulen@mozilla.com
Browse files

Bug 1877695 - Update tracking protection policy to allow setting strict/standard. a=RyanVM

parent 14266fc3
Loading
Loading
Loading
Loading
+28 −3
Changes for browser/components/enterprisepolicies/Policies.sys.mjs: 28 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -1185,7 +1185,35 @@ export var Policies = {
  },

  EnableTrackingProtection: {
    onAllWindowsRestored(manager, param) {
      if (param.Category) {
        // browser.contentblocking.category only works as a default pref if
        // it is locked.
        PoliciesUtils.setDefaultPref(
          "browser.contentblocking.category",
          param.Category,
          true
        );
        let { ContentBlockingPrefs } = ChromeUtils.importESModule(
          "moz-src:///browser/components/protections/ContentBlockingPrefs.sys.mjs"
        );
        // These are always locked because they would reset at
        // startup anyway.
        ContentBlockingPrefs.setPrefsToCategory(
          param.Category,
          true // locked
        );
        ContentBlockingPrefs.matchCBCategory();
      }
    },
    onBeforeUIStartup(manager, param) {
      if ("Exceptions" in param) {
        addAllowDenyPermissions("trackingprotection", param.Exceptions);
      }
      if (param.Category) {
        // If a category is set, we ignore everything except exceptions.
        return;
      }
      if (param.Value) {
        PoliciesUtils.setDefaultPref(
          "privacy.trackingprotection.enabled",
@@ -1227,9 +1255,6 @@ export var Policies = {
          param.Locked
        );
      }
      if ("Exceptions" in param) {
        addAllowDenyPermissions("trackingprotection", param.Exceptions);
      }
    },
  },

+4 −0
Changes for browser/components/enterprisepolicies/schemas/policies-schema.json: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -638,6 +638,10 @@
          "items": {
            "type": "origin"
          }
        },
        "Category": {
          "type": "string",
          "enum": ["standard", "strict"]
        }
      }
    },
+5 −0
Changes for browser/components/enterprisepolicies/tests/browser/trackingprotection/browser.toml: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
[DEFAULT]
prefs = ["browser.policies.alternatePath='<test-root>/browser/components/enterprisepolicies/tests/browser/trackingprotection/trackingprotection.json'"]
support-files = ["trackingprotection.json"]

["browser_policy_trackingprotection.js"]
+15 −0
Changes for browser/components/enterprisepolicies/tests/browser/trackingprotection/browser_policy_trackingprotection.js: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

add_task(async function test_enabletrackingprotection_strict() {
  await BrowserTestUtils.withNewTab(
    "about:preferences#privacy",
    async browser => {
      let strictRadio = browser.contentDocument.getElementById("strictRadio");
      is(strictRadio.selected, true, "Strict checkbox should be selected");
      is(strictRadio.disabled, true, "Strict checkbox should be disabled");
    }
  );
});
+7 −0
Changes for browser/components/enterprisepolicies/tests/browser/trackingprotection/trackingprotection.json: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
{
  "policies": {
    "EnableTrackingProtection": {
      "Category": "strict"
    }
  }
}
Loading