summaryrefslogtreecommitdiffstats
path: root/dom/serviceworkers/test/simple_fetch_worker.js
blob: d5b1d8d9a7cd7c1d607b6d7ab11aa94b67060dcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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);
};