prefetch-single.https.html (1421B)
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="?from_protocol=http&to_protocol=http"> 10 <meta name="variant" content="?from_protocol=http&to_protocol=https"> 11 <meta name="variant" content="?from_protocol=https&to_protocol=http"> 12 <meta name="variant" content="?from_protocol=https&to_protocol=https"> 13 14 <script> 15 setup(() => assertSpeculationRulesIsSupported()); 16 17 // This is split across four test variants due to the test timeouts. 18 let { from_protocol, to_protocol } = Object.fromEntries(new URLSearchParams(location.search)); 19 promise_test(async t => { 20 let agent = await spawnWindow(t, { protocol: from_protocol }); 21 let nextUrl = agent.getExecutorURL({ protocol: to_protocol, page: 2 }); 22 await agent.forceSinglePrefetch(nextUrl); 23 await agent.navigate(nextUrl); 24 25 if (to_protocol == "https") { 26 assert_prefetched(await agent.getRequestHeaders(), "Prefetch should work for HTTPS urls."); 27 } else { 28 assert_not_prefetched(await agent.getRequestHeaders(), "Prefetch should not work for HTTP urls."); 29 } 30 }, `test single ${to_protocol} url prefetch from a ${from_protocol} url`); 31 </script>