prefetch-status.https.html (1467B)
1 <!DOCTYPE html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <script src="/common/dispatcher/dispatcher.js"></script> 5 <script src="/common/utils.js"></script> 6 <script src="../resources/utils.js"></script> 7 <script src="resources/utils.sub.js"></script> 8 9 <meta name="variant" content="?status=200&should_prefetch=true"> 10 <meta name="variant" content="?status=250&should_prefetch=true"> 11 <meta name="variant" content="?status=299&should_prefetch=true"> 12 <meta name="variant" content="?status=400&should_prefetch=false"> 13 <meta name="variant" content="?status=500&should_prefetch=false"> 14 15 <script> 16 setup(() => assertSpeculationRulesIsSupported()); 17 18 // This is split across four test variants due to the test timeouts. 19 let { status, should_prefetch } = Object.fromEntries(new URLSearchParams(location.search)); 20 promise_test(async t => { 21 let agent = await spawnWindow(t); 22 let nextUrl = agent.getExecutorURL({ page: 2, pipe: `status(${status})` }); 23 await agent.forceSinglePrefetch(nextUrl); 24 await agent.navigate(nextUrl); 25 26 if (should_prefetch == 'true') 27 assert_prefetched(await agent.getRequestHeaders(), `Prefetch should work for request status:${status}.`); 28 else 29 assert_not_prefetched(await agent.getRequestHeaders(), `Prefetch should not work for request statue:${status}.`); 30 }, "Check that only prefetched requests with status in 200-299 range are used."); 31 </script>