diff --git a/content-security-policy/sandbox/meta-element.sub.html b/content-security-policy/sandbox/meta-element.sub.html new file mode 100644 index 00000000000000..a681fa4c2a6904 --- /dev/null +++ b/content-security-policy/sandbox/meta-element.sub.html @@ -0,0 +1,23 @@ + + + + + + + + diff --git a/content-security-policy/sandbox/service-worker-sandbox.https.html b/content-security-policy/sandbox/service-worker-sandbox.https.html new file mode 100644 index 00000000000000..00d750f83e65d5 --- /dev/null +++ b/content-security-policy/sandbox/service-worker-sandbox.https.html @@ -0,0 +1,75 @@ + + + + + + + diff --git a/content-security-policy/sandbox/shared-worker-sandbox.html b/content-security-policy/sandbox/shared-worker-sandbox.html new file mode 100644 index 00000000000000..5432300ec63215 --- /dev/null +++ b/content-security-policy/sandbox/shared-worker-sandbox.html @@ -0,0 +1,15 @@ + + + + + + + diff --git a/content-security-policy/sandbox/support/empty.html b/content-security-policy/sandbox/support/empty.html new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/content-security-policy/sandbox/support/post-origin-on-load-worker.js b/content-security-policy/sandbox/support/post-origin-on-load-worker.js new file mode 100644 index 00000000000000..9771cfc2b90f68 --- /dev/null +++ b/content-security-policy/sandbox/support/post-origin-on-load-worker.js @@ -0,0 +1,10 @@ +if ('DedicatedWorkerGlobalScope' in self && + self instanceof DedicatedWorkerGlobalScope) { + postMessage(self.origin); +} else if ( + 'SharedWorkerGlobalScope' in self && + self instanceof SharedWorkerGlobalScope) { + self.onconnect = e => { + e.ports[0].postMessage(self.origin); + }; +} diff --git a/content-security-policy/sandbox/support/post-origin-on-load-worker.js.headers b/content-security-policy/sandbox/support/post-origin-on-load-worker.js.headers new file mode 100644 index 00000000000000..1efcf8c226fac0 --- /dev/null +++ b/content-security-policy/sandbox/support/post-origin-on-load-worker.js.headers @@ -0,0 +1 @@ +Content-Security-Policy: sandbox allow-scripts diff --git a/content-security-policy/sandbox/support/sandboxed-service-worker.js b/content-security-policy/sandbox/support/sandboxed-service-worker.js new file mode 100644 index 00000000000000..33531ca413866b --- /dev/null +++ b/content-security-policy/sandbox/support/sandboxed-service-worker.js @@ -0,0 +1,14 @@ +self.addEventListener('fetch', function(event) { + var url = event.request.url; + if (url.indexOf('get-origin') != -1) { + event.respondWith(new Promise(function(resolve) { + resolve(new Response(JSON.stringify({ + origin: self.origin + }))); + })); + } + else if (url.indexOf('fetch') != -1) { + const url = new URL(event.request.url); + event.respondWith(fetch(url.searchParams.get('url'), {mode: event.request.mode})); + } + }); diff --git a/content-security-policy/sandbox/support/sandboxed-service-worker.js.headers b/content-security-policy/sandbox/support/sandboxed-service-worker.js.headers new file mode 100644 index 00000000000000..1efcf8c226fac0 --- /dev/null +++ b/content-security-policy/sandbox/support/sandboxed-service-worker.js.headers @@ -0,0 +1 @@ +Content-Security-Policy: sandbox allow-scripts