diff options
Diffstat (limited to 'testing/web-platform/tests/service-workers/service-worker/resources/secure-context-service-worker.js')
-rw-r--r-- | testing/web-platform/tests/service-workers/service-worker/resources/secure-context-service-worker.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/secure-context-service-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/secure-context-service-worker.js new file mode 100644 index 0000000000..5ba99f0753 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/secure-context-service-worker.js @@ -0,0 +1,21 @@ +self.addEventListener('fetch', event => { + let url = new URL(event.request.url); + if (url.pathname.indexOf('sender.html') != -1) { + event.respondWith(new Response( + "<script>window.parent.postMessage('interception', '*');</script>", + { headers: { 'Content-Type': 'text/html'} } + )); + } else if (url.pathname.indexOf('report') != -1) { + self.clients.matchAll().then(clients => { + for (client of clients) { + client.postMessage(url.searchParams.get('result')); + } + }); + event.respondWith( + new Response( + '<script>window.close()</script>', + { headers: { 'Content-Type': 'text/html'} } + ) + ); + } +}); |