summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/speculation-rules/prerender/resources/prerender-while-prerender-outer.html
blob: 313c34667f42d21dd39adf31a0490318b70baa97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!DOCTYPE html>
<meta charset="utf-8">
<title>Prerender while prerendering test: outer prerendered page</title>
<script src="utils.js"></script>

<script type="module">
const params = new URLSearchParams(location.search);
const uid = params.get("uid");
const innerURL = `prerender-while-prerender-inner.html?uid=${uid}`;

startPrerendering(innerURL);
// Wait 5 seconds for any potential prerender to start and get to the point
// where it would send a message that would cause a failure.
await new Promise(r => setTimeout(r, 5_000));

document.addEventListener("prerenderingchange", () => {
  location.href = innerURL;
});

const channel = new PrerenderChannel("start-test", uid);
channel.postMessage("ready to start");
channel.close();
</script>