CSP: worker-src

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since August 2016.

HTTP Content-Security-Policy (CSP) worker-src 지시문은 Worker, SharedWorker, 또는 ServiceWorker의 유효한 스크립트 소스를 지정합니다.

CSP 버전 3
지시 형식 Fetch directive
대비책

이 지시문이 없으면 사용자 에이전트는 먼저 child-src 지시문을 찾은 다음 script-src 지시문을 찾고, 마지막으로 default-src 지시문을 찾습니다.

구문

worker-src 정책에 대해 하나 이상의 소스를 허용할 수 있습니다.

http
Content-Security-Policy: worker-src <source>;
Content-Security-Policy: worker-src <source> <source>;

소스

<source>CSP Source Values에 나열된 값 중 하나입니다.

이 값은 모든 fetch 지시문기타 여러 지시문에서 사용할 수 있습니다.

예제

위반 사례

주어진 CSP 해더가 다음과 같다면

http
Content-Security-Policy: worker-src https://example.com/

아래에서 Worker, SharedWorker, ServiceWorker는 차단되어 로드되지 않습니다.

html
<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>

명세서

Specification
Content Security Policy Level 3
# directive-worker-src

브라우저 호환성

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
worker-src

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
See implementation notes.

같이 보기