Files
sousa-gecko/testing/web-platform/tests/speculation-rules/activation-header/prefetch-activation-beacon.tentative.https.html
T
Jiacheng Guo ea8250042e Bug 2047918 [wpt PR 60654] - Add WPT tests for Prefetch Activation Beacon API, a=testonly
Automatic update from web-platform-tests
Add WPT tests for Prefetch Activation Beacon API

This CL adds WPT tests to verify that the prefetch activation beacon
is sent correctly upon activation of a prefetched or prerendered page.
The tests are placed under the new speculation-rules/activation-header
directory to group activation-header-specific tests.

This change also enables the PrefetchActivationBeacon and
PrerenderActivationBeacon features in fieldtrial_testing_config.json to
ensure tests pass in automated testing environments.

Bug: 524410023
Change-Id: I038496fc2450fcba10c832cbbdca0d524cbd8c7b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7844912
Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org>
Commit-Queue: Jiacheng Guo <gjc@google.com>
Cr-Commit-Position: refs/heads/main@{#1647425}

--

wpt-commits: 403f98b943a9e2bbf05d856e10d2e471de32c091
wpt-pr: 60654
2026-06-18 14:40:15 +00:00

41 lines
1.5 KiB
HTML

<!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>