sxg-prefetch.tentative.https.html (1318B)
1 <!DOCTYPE html> 2 <title>Prefetched signed exchange and certificate must not be fetched again</title> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="/common/get-host-info.sub.js"></script> 6 <script src="/common/utils.js"></script> 7 <script src="./resources/sxg-util.js"></script> 8 <body> 9 <script> 10 promise_test(async (t) => { 11 const id = token(); 12 const sxgUrl = get_host_info().HTTPS_REMOTE_ORIGIN + '/signed-exchange/resources/prefetch-test-sxg.py?id=' + id; 13 14 await new Promise(resolve => { 15 const link = document.createElement('link'); 16 link.rel = 'prefetch'; 17 link.href = sxgUrl; 18 link.as = 'document'; 19 link.addEventListener('error', t.step_func(() => { 20 assert_unreached('Prefetch should not fail'); 21 })); 22 link.addEventListener('load', t.step_func(() => { 23 resolve(); 24 })); 25 document.body.appendChild(link); 26 }); 27 const message_promise = new Promise((resolve) => { 28 window.addEventListener('message', (event) => { 29 resolve(event.data); 30 }, false); 31 }); 32 const win = window.open(sxgUrl, "_blank"); 33 const message = await message_promise; 34 win.close(); 35 assert_equals(message, 'loaded'); 36 }, 'Prefetched signed exchange and certificate must not be fetched again.'); 37 38 </script> 39 </body>