chromium/chrome/test/data/workers/shared_fetcher_treat_as_public.js

self.addEventListener("connect", (evt) => {
  const port = evt.ports[0];

  port.addEventListener("message", (event) => {
    fetch(event.data)
      .then((response) => port.postMessage({ ok: response.ok }))
      .catch((error) => port.postMessage({ error: error.name }));
  });
  port.start();

  port.postMessage("ready");
});