Skip to content

Commit a060ce8

Browse files
authored
Clarify on effective DP, aligns with Policy Container model (#1194)
* align with policy container: * reword on the goals
1 parent 3de2292 commit a060ce8

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

DocumentPolicy/DocumentPolicyInWorkers.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Extending the Document Policy into workers resolves these gaps, ensures consiste
3333

3434
- Define how Document Policy applies to all worker types (Dedicated, Shared, and Service Workers)
3535
- 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
3737

3838
## Non-Goals
3939

@@ -46,21 +46,23 @@ Extending the Document Policy into workers resolves these gaps, ensures consiste
4646

4747
## Proposed solution: Use Document Policy response headers as authoritative, inherit only for local schemes
4848

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).
5052

5153
### Semantics by Worker Type
5254

5355
**Dedicated Workers:**
5456
- For network scripts: Parse `Document-Policy` from the worker script's HTTP response headers
5557
- 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)
5759

5860
**Shared Workers:**
5961
- For network scripts: Document Policy is established from the worker script's HTTP response headers when the worker is first created
6062
- When multiple documents attach to the same worker:
6163
- The shared worker's policy remains fixed based on the script response, regardless of which document initiated the creation
6264
- 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
6466

6567
**Service Workers:**
6668
- 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
9698

9799
Inheritance is therefore limited to local schemes (blob:, data:), which have no HTTP response to carry headers. This approach:
98100
- 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.
100102
- Prevents cross-origin policy leakage
101103
- Ensures consistent, predictable behavior
102104

@@ -151,7 +153,7 @@ partial dictionary WorkerOptions {
151153

152154
## Privacy, and Security Considerations
153155

154-
- 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.
155157
- Inherited policies cannot expand privileges beyond what the creator or script origin allows.
156158
- Worker script responses define the effective policy, ensuring each origin controls its own features.
157159
- Service Workers always use their registration script’s policy, keeping background execution isolated.

0 commit comments

Comments
 (0)