Skip to content

Commit 0e5831f

Browse files
Add unload to the Permission Policy constants.
1 parent 03c2549 commit 0e5831f

2 files changed

Lines changed: 75 additions & 0 deletions

File tree

‎src/Stott.Security.Optimizely.Test/Features/PermissionPolicy/PermissionPolicyConstantsTests.cs‎

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,78 @@ public sealed class PermissionPolicyConstantsTests
2020
PermissionPolicyConstants.DocumentDomain
2121
];
2222

23+
/// <summary>
24+
/// The directives documented at
25+
/// https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Permissions-Policy
26+
/// as of 29/09/2026, plus those which that page has since dropped but which this module
27+
/// retains so that existing configuration remains editable.
28+
/// </summary>
29+
/// <remarks>
30+
/// Listed literally rather than derived from PermissionPolicyConstants so that a directive
31+
/// cannot be added or removed without a deliberate revalidation against the specification.
32+
/// </remarks>
33+
private static readonly string[] SpecificationDirectives =
34+
[
35+
"accelerometer",
36+
"ambient-light-sensor",
37+
"aria-notify",
38+
"attribution-reporting",
39+
"autoplay",
40+
"bluetooth",
41+
"browsing-topics",
42+
"camera",
43+
"captured-surface-control",
44+
"ch-ua-high-entropy-values",
45+
"compute-pressure",
46+
"cross-origin-isolated",
47+
"deferred-fetch",
48+
"deferred-fetch-minimal",
49+
"display-capture",
50+
"document-domain",
51+
"encrypted-media",
52+
"fullscreen",
53+
"gamepad",
54+
"geolocation",
55+
"gyroscope",
56+
"hid",
57+
"identity-credentials-get",
58+
"idle-detection",
59+
"language-detector",
60+
"language-model",
61+
"local-fonts",
62+
"local-network",
63+
"local-network-access",
64+
"loopback-network",
65+
"magnetometer",
66+
"microphone",
67+
"midi",
68+
"on-device-speech-recognition",
69+
"otp-credentials",
70+
"payment",
71+
"picture-in-picture",
72+
"private-state-token-issuance",
73+
"private-state-token-redemption",
74+
"publickey-credentials-create",
75+
"publickey-credentials-get",
76+
"screen-wake-lock",
77+
"serial",
78+
"speaker-selection",
79+
"storage-access",
80+
"summarizer",
81+
"translator",
82+
"unload",
83+
"usb",
84+
"web-share",
85+
"window-management",
86+
"xr-spatial-tracking"
87+
];
88+
89+
[Test]
90+
public void AllDirectives_MatchesTheDirectivesDefinedByTheSpecification()
91+
{
92+
Assert.That(PermissionPolicyConstants.AllDirectives, Is.EqualTo(SpecificationDirectives));
93+
}
94+
2395
[Test]
2496
[TestCaseSource(nameof(DeprecatedDirectives))]
2597
public void AllDirectives_ContainsDeprecatedDirectivesSoThatExistingConfigurationRemainsEditable(string name)

‎src/Stott.Security.Optimizely/Features/PermissionPolicy/PermissionPolicyConstants.cs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ public static class PermissionPolicyConstants
102102

103103
public const string Translator = "translator";
104104

105+
public const string Unload = "unload";
106+
105107
public const string Usb = "usb";
106108

107109
public const string WebShare = "web-share";
@@ -165,6 +167,7 @@ public static class PermissionPolicyConstants
165167
new(StorageAccess, "Storage Access", "Controls whether third party content (i.e. embedded in an iframe) is allowed to use the Storage Access API to request access to unpartitioned cookies."),
166168
new(Summarizer, "Summarizer", "Controls whether the site is allowed to access the Summarizer API."),
167169
new(Translator, "Translator", "Controls whether the site is allowed to access the translation functionality of the Translator and Language Detector APIs."),
170+
new(Unload, "Unload", "Controls whether the site is allowed to run unload event handlers."),
168171
new(Usb, "USB", "Controls whether the site is allowed to use the WebUSB API."),
169172
new(WebShare, "Web Share", "Controls whether the site is allowed to use Web Share API to share text, links, images, and other content to arbitrary destinations of the user's choice."),
170173
new(WindowManagement, "Window Management", "Controls whether the site is allowed to use the Window Management API to manage windows on multiple displays."),

0 commit comments

Comments
 (0)