diff options
Diffstat (limited to 'dom/serviceworkers/test/simple_fetch_worker.js')
-rw-r--r-- | dom/serviceworkers/test/simple_fetch_worker.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/dom/serviceworkers/test/simple_fetch_worker.js b/dom/serviceworkers/test/simple_fetch_worker.js new file mode 100644 index 0000000000..d5b1d8d9a7 --- /dev/null +++ b/dom/serviceworkers/test/simple_fetch_worker.js @@ -0,0 +1,18 @@ +// A simple worker script that forward intercepted url to the controlled window. + +function responseMsg(msg) { + self.clients + .matchAll({ + includeUncontrolled: true, + type: "window", + }) + .then(clients => { + if (clients && clients.length) { + clients[0].postMessage(msg); + } + }); +} + +onfetch = function(e) { + responseMsg(e.request.url); +}; |