<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script>
<script src="/speculation-rules/prerender/resources/utils.js"></script>
<script src="/speculation-rules/prerender/resources/deferred-promise-utils.js"></script>
<body>
<script type="module">

const params = new URLSearchParams(location.search);
const uid = params.get('uid');

// The main test page (restriction-service-worker-unregister.https.html) loads
// the initiator page, then the initiator page will prerender itself with the
// `prerendering` parameter.
const isPrerendering = params.has('prerendering');

if (!isPrerendering) {
  loadInitiatorPage();
} else {
  const registration =
      await navigator.serviceWorker.getRegistration(location.href);

  const prerenderEventCollector = new PrerenderEventCollector();
  const promise = registration.unregister()
      .then(registration => {
        prerenderEventCollector.addEvent('service worker unregistered');
      });
  prerenderEventCollector.start(
      promise, 'ServiceWorkerRegistration.unregister');
}

</script>
</body>
