Bug 1588197 - Add autoplay to our permissions policies. r=mkaply,fluent-reviewers,Gijs,flod

Differential Revision: https://phabricator.services.mozilla.com/D55753

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Taylor 2020-01-24 16:22:01 +00:00
parent afb4e5ad9d
commit f4e85ffc2f
5 changed files with 67 additions and 3 deletions

View File

@ -1113,6 +1113,15 @@ var Policies = {
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",

View File

@ -277,6 +277,7 @@ function generateDocumentation() {
DisableSetDesktopBackground: "DisableSetAsDesktopBackground",
Certificates: "CertificatesDescription",
SanitizeOnShutdown: "SanitizeOnShutdown2",
Permissions: "Permissions2",
};
for (let policyName in schema.properties) {

View File

@ -605,6 +605,27 @@
}
},
"Autoplay": {
"type": "object",
"properties": {
"Allow": {
"type": "array",
"strict": false,
"items": {
"type": "origin"
}
},
"Block": {
"type": "array",
"strict": false,
"items": {
"type": "origin"
}
}
}
},
"Location": {
"type": "object",
"properties": {

View File

@ -8,7 +8,7 @@ function URI(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,
@ -38,8 +38,14 @@ add_task(async function test_setup_preexisting_permissions() {
Ci.nsIPermissionManager.ALLOW_ACTION,
Ci.nsIPermissionManager.EXPIRE_SESSION
);
PermissionTestUtils.add(
"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.
PermissionTestUtils.add(
@ -66,6 +72,12 @@ add_task(async function test_setup_preexisting_permissions() {
Ci.nsIPermissionManager.DENY_ACTION,
Ci.nsIPermissionManager.EXPIRE_SESSION
);
PermissionTestUtils.add(
"https://www.pre-existing-deny.com",
"autoplay-media",
Ci.nsIPermissionManager.DENY_ACTION,
Ci.nsIPermissionManager.EXPIRE_SESSION
);
});
add_task(async function test_setup_activate_policies() {
@ -88,6 +100,10 @@ add_task(async function test_setup_activate_policies() {
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"],
},
},
},
});
@ -150,6 +166,10 @@ 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.
@ -177,11 +197,18 @@ add_task(async function test_change_permission() {
Ci.nsIPermissionManager.DENY_ACTION,
Ci.nsIPermissionManager.EXPIRE_SESSION
);
PermissionTestUtils.add(
"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.
@ -209,6 +236,12 @@ add_task(async function test_change_permission() {
Ci.nsIPermissionManager.DENY_ACTION,
Ci.nsIPermissionManager.EXPIRE_SESSION
);
PermissionTestUtils.add(
"https://www.unmanaged.com",
"autoplay-media",
Ci.nsIPermissionManager.DENY_ACTION,
Ci.nsIPermissionManager.EXPIRE_SESSION
);
});
add_task(async function test_setup_trackingprotection() {

View File

@ -127,7 +127,7 @@ policy-OverridePostUpdatePage = Override the post-update “Whats New” 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.