workers-in-cross-origin-iframe.https.html (1850B)
1 <!DOCTYPE html> 2 <title>Construction of Web Workers in cross-origin iframe is deferred</title> 3 <meta name="timeout" content="long"> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="/common/get-host-info.sub.js"></script> 7 <script src="/common/utils.js"></script> 8 <script src="/common/dispatcher/dispatcher.js"></script> 9 <script src="../resources/utils.js"></script> 10 <script src="resources/utils.js"></script> 11 12 <!-- This is a regression test for https://crbug.com/1424250 --> 13 <body> 14 <script> 15 setup(() => assertSpeculationRulesIsSupported()); 16 17 promise_test(async t => { 18 const uid = token(); 19 const bc = new PrerenderChannel('test-channel', uid); 20 const gotMessage = new Promise(resolve => { 21 bc.addEventListener('message', e => { 22 resolve(e.data); 23 }, {once: true}); 24 }); 25 26 // This cross-origin iframe starts a dedicated worker and sends a message to 27 // this document once loading the worker is completed. 28 const crossOriginUrl = 29 new URL(`resources/workers-in-cross-origin-iframe.html?uid=${uid}`, 30 get_host_info()['HTTPS_REMOTE_ORIGIN'] + 31 window.location.pathname); 32 33 // Start prerendering. Loading the cross-origin iframe in a prerendered page 34 // will be deferred until prerender activation. 35 const {exec, activate} = await create_prerendered_page(t); 36 await exec(crossOriginUrl => { 37 const iframe = document.createElement('iframe'); 38 iframe.src = crossOriginUrl; 39 document.body.appendChild(iframe); 40 }, [crossOriginUrl.href]); 41 42 // Activate. This resumes loading the cross-origin iframe. 43 await activate(); 44 45 // Wait for the completion of the worker creation. 46 assert_equals(await gotMessage, 'Success'); 47 }, "Dedicated workers in cross-origin iframe should be loaded after " + 48 "activation"); 49 </script>