summaryrefslogtreecommitdiffstats
path: root/dom/serviceworkers/test/simple_fetch_worker.js
diff options
context:
space:
mode:
Diffstat (limited to 'dom/serviceworkers/test/simple_fetch_worker.js')
-rw-r--r--dom/serviceworkers/test/simple_fetch_worker.js18
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..09c82011e5
--- /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);
+};