chromium/content/test/data/service_worker/request_navigate.html

<!DOCTYPE html>
<meta charset="utf-8">
<title>Request navigate</title>
<script>
// Asks the service worker to call WindowClient.navigate() on us. It will
// message back the result if it failed, or else we navigate away.
async function requestToNavigate() {
  const sawMessage = new Promise((resolve) => {
    navigator.serviceWorker.onmessage = (event) => {
      resolve(event.data);
    };
  });
  const registration = await navigator.serviceWorker.ready;
  registration.active.postMessage({command: 'navigate', url: 'empty.html'});
  return await sawMessage;
}
</script>