Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /speculation-rules/prefetch/redirect-url.https.html?origin=cross-site-initial - WPT Dashboard Interop Dashboard
- /speculation-rules/prefetch/redirect-url.https.html?origin=cross-site-redirect - WPT Dashboard Interop Dashboard
- /speculation-rules/prefetch/redirect-url.https.html?origin=same-origin - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta name="timeout" content="long">
<meta name="variant" content="?origin=same-origin">
<meta name="variant" content="?origin=cross-site-redirect">
<meta name="variant" content="?origin=cross-site-initial">
<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="../resources/utils.js"></script>
<script src="resources/utils.sub.js"></script>
<script src="resources/redirect-helper.sub.js"></script>
<script>
setup(() => assertSpeculationRulesIsSupported());
// Navigate to the initial URL of the prefetch.
for (const prefetchTiming of
['redirect-received-before-navigation-start',
'redirect-received-after-navigation-start']) {
promise_test(async t => {
const {agent,
prefetchInitialUrl,
prefetchFinalUrl,
redirectToPrefetchInitialUrl,
redirectToPrefetchFinalUrl} = await prepare(t, prefetchTiming);
await agent.forceSinglePrefetch(prefetchInitialUrl);
await agent.navigate(prefetchInitialUrl,
{expectedDestinationUrl: prefetchFinalUrl});
assert_prefetched(await agent.getRequestHeaders(),
'Prefetched response should be used by navigation.');
}, prefetchTiming);
}
</script>