summaryrefslogtreecommitdiffstats
path: root/dom/serviceworkers/test/fetch/imagecache/imagecache_test.js
blob: e1f2af736b9a0c7e51dbfc40fc7c4eaef47d850d (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());
  }
});