Source code
Revision control
Copy as Markdown
Other Tools
<!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>