chromium/third_party/blink/web_tests/http/tests/inspector-protocol/fetch/resources/service-worker.js

self.installPromise = new Promise(fulfill => self.installCallback = fulfill);

self.addEventListener('install', event => {
  if (location.search === '?defer-install')
    event.waitUntil(self.installPromise);
});

self.addEventListener('fetch', fetchEvent => {
  if (/fulfill-by-sw/.test(fetchEvent.request.url)) {
    fetchEvent.respondWith(new Response("response from service worker"));
    return;
  }

  fetchEvent.respondWith(fetch(fetchEvent.request));
});