Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /speculation-rules/activation-header/prefetch-activation-beacon.tentative.https.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/dispatcher/dispatcher.js"></script>
<script src="/common/utils.js"></script>
<script src="/speculation-rules/resources/utils.js"></script>
<script src="/speculation-rules/prefetch/resources/utils.sub.js"></script>
<script>
setup(() => assertSpeculationRulesIsSupported());
promise_test(async t => {
const uuid = token();
const agent = await spawnWindow(t, {}, uuid);
const prefetchUrl = new URL(`resources/activation_beacon.py?uuid=${uuid}&action=serve`, location.href);
// Trigger prefetch
await agent.forceSinglePrefetch(prefetchUrl.toString());
// Navigate to the prefetched URL
await agent.navigate(prefetchUrl, { expectedDestinationUrl: null });
const checkUrl = new URL(`resources/activation_beacon.py?uuid=${uuid}&action=check`, location.href);
// Poll for beacon received
let state = {};
let attempts = 0;
while (!state.beacon_received && attempts < 20) {
await new Promise(resolve => t.step_timeout(resolve, 500));
let response = await fetch(checkUrl);
state = await response.json();
attempts++;
}
assert_true(state.fetched, "Resource should have been fetched.");
assert_true(state.beacon_received, "Beacon should have been received.");
}, "Test that prefetch activation beacon is sent upon activation.");
</script>