You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: DocumentPolicy/DocumentPolicyInWorkers.md
+8-6Lines changed: 8 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ Extending the Document Policy into workers resolves these gaps, ensures consiste
33
33
34
34
- Define how Document Policy applies to all worker types (Dedicated, Shared, and Service Workers)
35
35
- Enable policy-gated features (like js-self-profiling) to work in workers when appropriately configured
36
-
-Align Worker Policy Inheritance with existing standards
36
+
-Clone Document Policy using the same rules as policy container cloning defined in the HTML spec
37
37
38
38
## Non-Goals
39
39
@@ -46,21 +46,23 @@ Extending the Document Policy into workers resolves these gaps, ensures consiste
46
46
47
47
## Proposed solution: Use Document Policy response headers as authoritative, inherit only for local schemes
48
48
49
-
We propose Workers derive their Document Policy from the worker script's HTTP response headers. When no response exists (local blob:/data:), they inherit from the creator document.
49
+
We propose workers derive their Document Policy from the worker script’s HTTP response. For local URLs (blob:, data:), the worker inherits the policy from the creating environment.
50
+
51
+
**For network-loaded workers**: The worker's effective Document-Policy is taken only from the worker script's HTTP response, any creator policy is ignored (no merge/intersection). If the response lacks a Document-Policy header, the feature falls back to its spec-defined default (for js-profiling, typically off).
50
52
51
53
### Semantics by Worker Type
52
54
53
55
**Dedicated Workers:**
54
56
- For network scripts: Parse `Document-Policy` from the worker script's HTTP response headers
55
57
- If no `Document-Policy` header is present: Each feature uses its spec-defined default value (same as document contexts)
56
-
- For local schemes (blob:, data:): Worker inherits the creator's Document Policy, since no response exists to consult
58
+
- For local schemes (blob:, data:): Worker clones the creator's Document Policy, since no HTTP response exists to consult (blob: URLs clone from the environment that created the blob, data: URLs clone from the document that created the worker)
57
59
58
60
**Shared Workers:**
59
61
- For network scripts: Document Policy is established from the worker script's HTTP response headers when the worker is first created
60
62
- When multiple documents attach to the same worker:
61
63
- The shared worker's policy remains fixed based on the script response, regardless of which document initiated the creation
62
64
- Documents can connect to the worker regardless of their own Document Policy settings
63
-
- For local schemes: Behavior mirrors dedicated workers, inherit from the creator's policy
65
+
- For local schemes: Behavior mirrors dedicated workers, clone from the creator's policy
64
66
65
67
**Service Workers:**
66
68
- The SW registration script response is the authoritative source of Document Policy
@@ -96,7 +98,7 @@ The response-driven model avoids this ambiguity. Each origin controls its own fe
96
98
97
99
Inheritance is therefore limited to local schemes (blob:, data:), which have no HTTP response to carry headers. This approach:
98
100
- Aligns with Document Policy's header-based model
99
-
-Matches how COEP and CSP already inherit for blob/data workers in the HTML specification
101
+
-Consistent with other policies that [policy container](https://html.spec.whatwg.org/#initialize-worker-policy-container) model defines in the HTML spec.
- Document Policy inheritance is limited to same-origin and local scheme workers to prevent cross-origin policy leakage.
156
+
- Document Policy inheritance is limited to local URLs (blob:, data:), consistent with the HTML policy container model, this prevents cross-origin policy leakage.
155
157
- Inherited policies cannot expand privileges beyond what the creator or script origin allows.
156
158
- Worker script responses define the effective policy, ensuring each origin controls its own features.
157
159
- Service Workers always use their registration script’s policy, keeping background execution isolated.
0 commit comments