summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/content-security-policy/sandbox/support/sandboxed-service-worker.js
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/content-security-policy/sandbox/support/sandboxed-service-worker.js')
-rw-r--r--testing/web-platform/tests/content-security-policy/sandbox/support/sandboxed-service-worker.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/testing/web-platform/tests/content-security-policy/sandbox/support/sandboxed-service-worker.js b/testing/web-platform/tests/content-security-policy/sandbox/support/sandboxed-service-worker.js
new file mode 100644
index 0000000000..d4971266f5
--- /dev/null
+++ b/testing/web-platform/tests/content-security-policy/sandbox/support/sandboxed-service-worker.js
@@ -0,0 +1,14 @@
+self.addEventListener('fetch', function(event) {
+ const url = new URL(event.request.url);
+ if (url.pathname.indexOf('get-origin') != -1) {
+ event.respondWith(new Promise(function(resolve) {
+ resolve(new Response(JSON.stringify({
+ origin: self.origin
+ })));
+ }));
+ }
+ else if (url.pathname.indexOf('fetch') != -1) {
+ event.respondWith(fetch(url.searchParams.get('url'),
+ {mode: event.request.mode}));
+ }
+ });