Bug 1588197 - Add autoplay to our permissions policies. r=mkaply,fluent-reviewers,Gijs,flod, a=RyanVM
authorTaylor <southort@uni.coventry.ac.uk>
Fri, 24 Jan 2020 16:22:01 +0000
changeset 524563 2cf9e0c91d519a73e726739e98c8befa08a72893
parent 524562 62b886edff5f0d4f505ae4d9dc16fada8a9d1561
child 524564 a0b1b53cd303ad65038781bdcc08a1e109ac4df6
push id869
push userryanvm@gmail.com
push dateThu, 13 Feb 2020 20:08:46 +0000
treeherdermozilla-esr68@2cf9e0c91d51 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkaply, fluent-reviewers, Gijs, flod, RyanVM
bugs1588197
milestone68.6.0
Bug 1588197 - Add autoplay to our permissions policies. r=mkaply,fluent-reviewers,Gijs,flod, a=RyanVM Differential Revision: https://phabricator.services.mozilla.com/D55753
browser/components/enterprisepolicies/Policies.jsm
browser/components/enterprisepolicies/content/aboutPolicies.js
browser/components/enterprisepolicies/schemas/policies-schema.json
browser/components/enterprisepolicies/tests/xpcshell/test_permissions.js
browser/locales/en-US/browser/policies/policies-descriptions.ftl
--- a/browser/components/enterprisepolicies/Policies.jsm
+++ b/browser/components/enterprisepolicies/Policies.jsm
@@ -1105,16 +1105,25 @@ var Policies = {
         addAllowDenyPermissions(
           "microphone",
           param.Microphone.Allow,
           param.Microphone.Block
         );
         setDefaultPermission("microphone", param.Microphone);
       }
 
+      if (param.Autoplay) {
+        addAllowDenyPermissions(
+          "autoplay-media",
+          param.Autoplay.Allow,
+          param.Autoplay.Block
+        );
+        setDefaultPermission("autoplay-media", param.Autoplay);
+      }
+
       if (param.Location) {
         addAllowDenyPermissions(
           "geo",
           param.Location.Allow,
           param.Location.Block
         );
         setDefaultPermission("geo", param.Location);
       }
--- a/browser/components/enterprisepolicies/content/aboutPolicies.js
+++ b/browser/components/enterprisepolicies/content/aboutPolicies.js
@@ -272,16 +272,17 @@ function generateDocumentation() {
   new_cont.setAttribute("id", "documentationContent");
 
   // map specific policies to a different string ID, to allow updates to
   // existing descriptions
   let string_mapping = {
     DisableSetDesktopBackground: "DisableSetAsDesktopBackground",
     Certificates: "CertificatesDescription",
     SanitizeOnShutdown: "SanitizeOnShutdown2",
+    Permissions: "Permissions2",
   };
 
   for (let policyName in schema.properties) {
     let main_tbody = document.createElement("tbody");
     main_tbody.classList.add("collapsible");
     main_tbody.addEventListener("click", function() {
       let content = this.nextElementSibling;
       content.classList.toggle("content");
--- a/browser/components/enterprisepolicies/schemas/policies-schema.json
+++ b/browser/components/enterprisepolicies/schemas/policies-schema.json
@@ -612,16 +612,37 @@
             },
 
             "Locked": {
               "type": "boolean"
             }
           }
         },
 
+        "Autoplay": {
+          "type": "object",
+          "properties": {
+            "Allow": {
+              "type": "array",
+              "strict": false,
+              "items": {
+                "type": "origin"
+              }
+            },
+
+            "Block": {
+              "type": "array",
+              "strict": false,
+              "items": {
+                "type": "origin"
+              }
+            }
+          }
+        },
+
         "Location": {
           "type": "object",
           "properties": {
             "Allow": {
               "type": "array",
               "strict": false,
               "items": {
                 "type": "origin"
--- a/browser/components/enterprisepolicies/tests/xpcshell/test_permissions.js
+++ b/browser/components/enterprisepolicies/tests/xpcshell/test_permissions.js
@@ -3,17 +3,17 @@
 
 "use strict";
 
 function URI(str) {
   return Services.io.newURI(str);
 }
 
 add_task(async function test_setup_preexisting_permissions() {
-  // Pre-existing ALLOW permissions that should be overriden
+  // Pre-existing ALLOW permissions that should be overridden
   // with DENY.
 
   // No ALLOW -> DENY override for popup and install permissions,
   // because their policies only supports the Allow parameter.
 
   Services.perms.add(
     URI("https://www.pre-existing-allow.com"),
     "camera",
@@ -33,18 +33,24 @@ add_task(async function test_setup_preex
     Ci.nsIPermissionManager.EXPIRE_SESSION
   );
   Services.perms.add(
     URI("https://www.pre-existing-allow.com"),
     "desktop-notification",
     Ci.nsIPermissionManager.ALLOW_ACTION,
     Ci.nsIPermissionManager.EXPIRE_SESSION
   );
+  Services.perms.add(
+    URI("https://www.pre-existing-allow.com"),
+    "autoplay-media",
+    Ci.nsIPermissionManager.ALLOW_ACTION,
+    Ci.nsIPermissionManager.EXPIRE_SESSION
+  );
 
-  // Pre-existing DENY permissions that should be overriden
+  // Pre-existing DENY permissions that should be overridden
   // with ALLOW.
 
   Services.perms.add(
     URI("https://www.pre-existing-deny.com"),
     "camera",
     Ci.nsIPermissionManager.DENY_ACTION,
     Ci.nsIPermissionManager.EXPIRE_SESSION
   );
@@ -61,16 +67,22 @@ add_task(async function test_setup_preex
     Ci.nsIPermissionManager.EXPIRE_SESSION
   );
   Services.perms.add(
     URI("https://www.pre-existing-deny.com"),
     "desktop-notification",
     Ci.nsIPermissionManager.DENY_ACTION,
     Ci.nsIPermissionManager.EXPIRE_SESSION
   );
+  Services.perms.add(
+    URI("https://www.pre-existing-deny.com"),
+    "autoplay-media",
+    Ci.nsIPermissionManager.DENY_ACTION,
+    Ci.nsIPermissionManager.EXPIRE_SESSION
+  );
 });
 
 add_task(async function test_setup_activate_policies() {
   await setupPolicyEngineWithJson({
     policies: {
       Permissions: {
         Camera: {
           Allow: ["https://www.allow.com", "https://www.pre-existing-deny.com"],
@@ -83,16 +95,20 @@ add_task(async function test_setup_activ
         Location: {
           Allow: ["https://www.allow.com", "https://www.pre-existing-deny.com"],
           Block: ["https://www.deny.com", "https://www.pre-existing-allow.com"],
         },
         Notifications: {
           Allow: ["https://www.allow.com", "https://www.pre-existing-deny.com"],
           Block: ["https://www.deny.com", "https://www.pre-existing-allow.com"],
         },
+        Autoplay: {
+          Allow: ["https://www.allow.com", "https://www.pre-existing-deny.com"],
+          Block: ["https://www.deny.com", "https://www.pre-existing-allow.com"],
+        },
       },
     },
   });
   equal(
     Services.policies.status,
     Ci.nsIEnterprisePolicies.ACTIVE,
     "Engine is active"
   );
@@ -145,16 +161,20 @@ add_task(async function test_microphone_
 add_task(async function test_location_policy() {
   checkAllPermissionsForType("geo");
 });
 
 add_task(async function test_notifications_policy() {
   checkAllPermissionsForType("desktop-notification");
 });
 
+add_task(async function test_autoplay_policy() {
+  checkAllPermissionsForType("autoplay-media");
+});
+
 add_task(async function test_change_permission() {
   // Checks that changing a permission will still retain the
   // value set through the engine.
   Services.perms.add(
     URI("https://www.allow.com"),
     "camera",
     Ci.nsIPermissionManager.DENY_ACTION,
     Ci.nsIPermissionManager.EXPIRE_SESSION
@@ -172,21 +192,28 @@ add_task(async function test_change_perm
     Ci.nsIPermissionManager.EXPIRE_SESSION
   );
   Services.perms.add(
     URI("https://www.allow.com"),
     "desktop-notification",
     Ci.nsIPermissionManager.DENY_ACTION,
     Ci.nsIPermissionManager.EXPIRE_SESSION
   );
+  Services.perms.add(
+    URI("https://www.allow.com"),
+    "autoplay-media",
+    Ci.nsIPermissionManager.DENY_ACTION,
+    Ci.nsIPermissionManager.EXPIRE_SESSION
+  );
 
   checkPermission("allow.com", "ALLOW", "camera");
   checkPermission("allow.com", "ALLOW", "microphone");
   checkPermission("allow.com", "ALLOW", "geo");
   checkPermission("allow.com", "ALLOW", "desktop-notification");
+  checkPermission("allow.com", "ALLOW", "autoplay-media");
 
   // Also change one un-managed permission to make sure it doesn't
   // cause any problems to the policy engine or the permission manager.
   Services.perms.add(
     URI("https://www.unmanaged.com"),
     "camera",
     Ci.nsIPermissionManager.DENY_ACTION,
     Ci.nsIPermissionManager.EXPIRE_SESSION
@@ -204,16 +231,22 @@ add_task(async function test_change_perm
     Ci.nsIPermissionManager.EXPIRE_SESSION
   );
   Services.perms.add(
     URI("https://www.unmanaged.com"),
     "desktop-notification",
     Ci.nsIPermissionManager.DENY_ACTION,
     Ci.nsIPermissionManager.EXPIRE_SESSION
   );
+  Services.perms.add(
+    URI("https://www.unmanaged.com"),
+    "autoplay-media",
+    Ci.nsIPermissionManager.DENY_ACTION,
+    Ci.nsIPermissionManager.EXPIRE_SESSION
+  );
 });
 
 add_task(async function test_setup_trackingprotection() {
   await setupPolicyEngineWithJson({
     policies: {
       EnableTrackingProtection: {
         Exceptions: ["https://www.allow.com"],
       },
--- a/browser/locales/en-US/browser/policies/policies-descriptions.ftl
+++ b/browser/locales/en-US/browser/policies/policies-descriptions.ftl
@@ -122,17 +122,17 @@ policy-OfferToSaveLogins = Enforce the s
 policy-OfferToSaveLoginsDefault = Set the default value for allowing { -brand-short-name } to offer to remember saved logins and passwords. Both true and false values are accepted.
 
 policy-OverrideFirstRunPage = Override the first run page. Set this policy to blank if you want to disable the first run page.
 
 policy-OverridePostUpdatePage = Override the post-update “What’s New” page. Set this policy to blank if you want to disable the post-update page.
 
 policy-PasswordManagerEnabled = Enable saving passwords to the password manager.
 
-policy-Permissions = Configure permissions for camera, microphone, location and notifications.
+policy-Permissions2 = Configure permissions for camera, microphone, location, notifications, and autoplay.
 
 policy-PopupBlocking = Allow certain websites to display popups by default.
 
 policy-Preferences = Set and lock the value for a subset of preferences.
 
 policy-PromptForDownloadLocation = Ask where to save files when downloading.
 
 policy-Proxy = Configure proxy settings.