CSP: worker-src
CSP: worker-src
The HTTP Content-Security-Policy
(CSP) worker-src
directive specifies valid sources for Worker
, SharedWorker
, or ServiceWorker
scripts.
CSP version
3
Directive type
Fetch directive
Fallback
If this directive is absent, the user agent will first look for the child-src
directive, then the script-src
directive, then finally for the default-src
directive, when governing worker execution.
Syntax
One or more sources can be allowed for the worker-src
policy:
Violation cases
Given this CSP header:
Worker
, SharedWorker
, ServiceWorker
are blocked and won't load:
< script>
let blockedWorker = new Worker ( "data:application/javascript,…" ) ;
blockedWorker = new SharedWorker ( "https://not-example.com/" ) ;
navigator. serviceWorker. register ( "https://not-example.com/sw.js" ) ;
</ script>
Specifications
Browser compatibility
Desktop
Mobile
Chrome
Edge
Firefox
Internet Explorer
Opera
Safari
WebView Android
Chrome Android
Firefox for Android
Opera Android
Safari on IOS
Samsung Internet
worker-src
59
Chrome 59 and higher skips the deprecated child-src
directive.
79
58
No
46
Opera 46 and higher skips the deprecated child-src
directive.
15.5
59
Chrome 59 and higher skips the deprecated child-src
directive.
59
Chrome 59 and higher skips the deprecated child-src
directive.
58
43
Opera 43 and higher skips the deprecated child-src
directive.
15.5
7.0