Bug 1655575 - Add enterprise policy for xr permission. r=emalysz

Differential Revision: https://phabricator.services.mozilla.com/D85200
This commit is contained in:
Michael Kaply 2020-07-28 21:19:06 +00:00
Родитель 3714922d1b
Коммит 44ccffe5c8
5 изменённых файлов: 77 добавлений и 0 удалений

Просмотреть файл

@ -128,6 +128,7 @@ function initRow(aPartId) {
case "desktop-notification":
case "camera":
case "microphone":
case "xr":
checkbox.disabled = Services.prefs.prefIsLocked(
"permissions.default." + aPartId
);

Просмотреть файл

@ -1386,6 +1386,15 @@ var Policies = {
);
setDefaultPermission("desktop-notification", param.Notifications);
}
if ("VirtualReality" in param) {
addAllowDenyPermissions(
"xr",
param.VirtualReality.Allow,
param.VirtualReality.Block
);
setDefaultPermission("xr", param.VirtualReality);
}
},
},

Просмотреть файл

@ -836,6 +836,35 @@
"type": "boolean"
}
}
},
"VirtualReality": {
"type": "object",
"properties": {
"Allow": {
"type": "array",
"strict": false,
"items": {
"type": "origin"
}
},
"Block": {
"type": "array",
"strict": false,
"items": {
"type": "origin"
}
},
"BlockNewRequests": {
"type": "boolean"
},
"Locked": {
"type": "boolean"
}
}
}
}
},

Просмотреть файл

@ -25,6 +25,10 @@ add_task(async function test_pageinfo_permissions() {
BlockNewRequests: true,
Locked: true,
},
VirtualReality: {
BlockNewRequests: true,
Locked: true,
},
Autoplay: {
Default: "block-audio",
Locked: true,
@ -51,6 +55,7 @@ add_task(async function test_pageinfo_permissions() {
"cookie",
"camera",
"microphone",
"xr",
];
await BrowserTestUtils.withNewTab(TEST_ORIGIN, async function(browser) {

Просмотреть файл

@ -44,6 +44,12 @@ add_task(async function test_setup_preexisting_permissions() {
Ci.nsIPermissionManager.ALLOW_ACTION,
Ci.nsIPermissionManager.EXPIRE_SESSION
);
PermissionTestUtils.add(
"https://www.pre-existing-allow.com",
"xr",
Ci.nsIPermissionManager.ALLOW_ACTION,
Ci.nsIPermissionManager.EXPIRE_SESSION
);
// Pre-existing DENY permissions that should be overridden
// with ALLOW.
@ -78,6 +84,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",
"xr",
Ci.nsIPermissionManager.DENY_ACTION,
Ci.nsIPermissionManager.EXPIRE_SESSION
);
});
add_task(async function test_setup_activate_policies() {
@ -104,6 +116,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"],
},
VirtualReality: {
Allow: ["https://www.allow.com", "https://www.pre-existing-deny.com"],
Block: ["https://www.deny.com", "https://www.pre-existing-allow.com"],
},
},
},
});
@ -170,6 +186,10 @@ add_task(async function test_autoplay_policy() {
checkAllPermissionsForType("autoplay-media");
});
add_task(async function test_xr_policy() {
checkAllPermissionsForType("xr");
});
add_task(async function test_change_permission() {
// Checks that changing a permission will still retain the
// value set through the engine.
@ -203,12 +223,19 @@ add_task(async function test_change_permission() {
Ci.nsIPermissionManager.DENY_ACTION,
Ci.nsIPermissionManager.EXPIRE_SESSION
);
PermissionTestUtils.add(
"https://www.allow.com",
"xr",
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");
checkPermission("allow.com", "ALLOW", "xr");
// Also change one un-managed permission to make sure it doesn't
// cause any problems to the policy engine or the permission manager.
@ -242,6 +269,12 @@ add_task(async function test_change_permission() {
Ci.nsIPermissionManager.DENY_ACTION,
Ci.nsIPermissionManager.EXPIRE_SESSION
);
PermissionTestUtils.add(
"https://www.unmanaged.com",
"xr",
Ci.nsIPermissionManager.DENY_ACTION,
Ci.nsIPermissionManager.EXPIRE_SESSION
);
});
add_task(async function test_setup_trackingprotection() {