summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/speculation-rules/prerender/resources/service-worker-unregister.html
blob: a78775a5a2c7a5724f7d97a4c3d8c6638c76f6d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<!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>