diff --git a/browser/base/content/pageinfo/permissions.js b/browser/base/content/pageinfo/permissions.js index 6a24ffa00699..1c74278e09b7 100644 --- a/browser/base/content/pageinfo/permissions.js +++ b/browser/base/content/pageinfo/permissions.js @@ -128,6 +128,7 @@ function initRow(aPartId) { case "desktop-notification": case "camera": case "microphone": + case "xr": checkbox.disabled = Services.prefs.prefIsLocked( "permissions.default." + aPartId ); diff --git a/browser/components/enterprisepolicies/Policies.jsm b/browser/components/enterprisepolicies/Policies.jsm index a273db0d22f5..c3d77211010d 100644 --- a/browser/components/enterprisepolicies/Policies.jsm +++ b/browser/components/enterprisepolicies/Policies.jsm @@ -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); + } }, }, diff --git a/browser/components/enterprisepolicies/schemas/policies-schema.json b/browser/components/enterprisepolicies/schemas/policies-schema.json index 80e389e56755..8e48d6b647e6 100644 --- a/browser/components/enterprisepolicies/schemas/policies-schema.json +++ b/browser/components/enterprisepolicies/schemas/policies-schema.json @@ -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" + } + } } } }, diff --git a/browser/components/enterprisepolicies/tests/browser/browser_policy_pageinfo_permissions.js b/browser/components/enterprisepolicies/tests/browser/browser_policy_pageinfo_permissions.js index 203c0149f34c..6ae0e857381e 100644 --- a/browser/components/enterprisepolicies/tests/browser/browser_policy_pageinfo_permissions.js +++ b/browser/components/enterprisepolicies/tests/browser/browser_policy_pageinfo_permissions.js @@ -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) { diff --git a/browser/components/enterprisepolicies/tests/xpcshell/test_permissions.js b/browser/components/enterprisepolicies/tests/xpcshell/test_permissions.js index 1b522d92af83..7f7523363936 100644 --- a/browser/components/enterprisepolicies/tests/xpcshell/test_permissions.js +++ b/browser/components/enterprisepolicies/tests/xpcshell/test_permissions.js @@ -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() {