summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/speculation-rules/prerender/resources/fetch-intercepted-by-service-worker.html
blob: 46aefb4e153d2dbd0eec203f5044009de25b980d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/speculation-rules/prerender/resources/utils.js"></script>
<script>

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

async function startFetch() {
  assert_true(document.prerendering);

  const response = await fetch('cache.txt?should-intercept');
  const body = await response.text();

  const bc = new PrerenderChannel('prerender-channel', uid);
  bc.postMessage(body);
  bc.close();
}

startFetch();
</script>