chromium/third_party/blink/web_tests/http/tests/inspector-protocol/service-worker/resources/claim-on-activate-service-worker.js

(function () {
  self.addEventListener("activate", onActivate);
  self.addEventListener("fetch", onFetch);

  function onActivate(e) {
    e.waitUntil(
      Promise.resolve().then(
        () => self.clients.claim()
      ));
  };

  async function onFetch(e) {
    if (e.request.mode === "navigate")
      return;
    e.respondWith(fetch(e.request));
  }
})();