v147 · developer trial · workers · security

Document Policy in Dedicated Workers

Document Policy — the HTTP-header-based mechanism for opting into platform constraints — now applies to Dedicated Workers. Performance and security controls can be enforced consistently across the document and its workers instead of stopping at the main thread.

concepts

  1. Policy Headers

    A canonical reference card for the Document Policy directives that now apply inside a Dedicated Worker. Click each card to see the exact header value, what it does, and where in the worker lifecycle it's enforced.

  2. Worker violation probe

    A permissive and a strict worker run the same probes — sync XHR, 5000×5000 image decode, indirect eval. The strict worker's no-unsized-media · sync-xhr=() · no-document-write stops the operations exactly where the policy says it should.

  3. Worker Feature Probe

    Spawns a real Blob-URL Dedicated Worker and runs capability checks for js-profiling, sync XHR, SharedArrayBuffer, and Scheduler API — reporting results for both the main thread and worker side by side to confirm policy inheritance.

  4. Policy Inheritance Tester

    Configure a Document Policy header string, spawn a worker with matching policy, then run a battery of policy-gated operations (sync XHR, oversized image decode, eval). A pass/fail matrix compares behaviour in permissive vs. restricted workers and confirms inherited vs. overridden directives.

  5. Compatibility Lab

    Probes Dedicated Worker availability, tests eval and sync XHR access inside a blob-URL worker, and detects Document Policy header presence. Spawns a real worker to compare permissive vs. restricted behaviour, and provides the HTTP header pattern for enforcing policy in workers.

why it shipped

Document Policy gives sites a way to lock themselves out of misbehaving by demanding constraints at load time — "no sync XHR", "no oversized images", "no slow scripts". But until now those constraints stopped at the main thread; a worker spun up by the document could violate them silently. Extending Document Policy to Dedicated Workers makes the constraints consistent across the whole execution graph, and lets developers reason about behaviour without worrying which thread the offending code is on.

references

implementation reference

Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗