summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/speculation-rules/prerender/resources/service-worker-update.html
blob: d9a9273526efb925e22b74e6c1622e69de46bb8a (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
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.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-update.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.update()
      .then(registration => {
        prerenderEventCollector.addEvent('service worker updated');
      });
  prerenderEventCollector.start(
      promise, 'ServiceWorkerRegistration.update');
}

</script>
</body>