summaryrefslogtreecommitdiffstats
path: root/dom/serviceworkers/test/fetch/imagecache/imagecache_test.js
blob: cd8f52272840296038343d89d23d5252038ab354 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function synthesizeImage() {
  return clients.matchAll().then(clients => {
    var url = "image-40px.png";
    clients.forEach(client => {
      client.postMessage(url);
    });
    return fetch(url);
  });
}

self.addEventListener("fetch", function (event) {
  if (event.request.url.includes("image-20px.png")) {
    event.respondWith(synthesizeImage());
  }
});