transition-to-prerender-manual.html (1466B)
1 <!DOCTYPE html> 2 <html class="reftest-wait"> 3 <title>View transitions: prerender navigation</title> 4 <link rel="help" href="https://drafts.csswg.org/css-view-transitions-2/"> 5 <link rel="author" href="mailto:vmpstr@chromium.org"> 6 <!-- TODO(crbug.com/1418681). This test should work automatically, 7 but doesn't due to the referenced bug. 8 <link rel="match" href="transition-to-prerender-ref.html"> 9 --> 10 <script src="/common/utils.js"></script> 11 <script src="/speculation-rules/prerender/resources/utils.js"></script> 12 <script src="/common/reftest-wait.js"></script> 13 <style> 14 @view-transition { navigation: auto; } 15 html { background: red; } 16 #target { 17 width: 200px; 18 height: 200px; 19 background: black; 20 color: white; 21 position: absolute; 22 top: 40px; 23 view-transition-name: target; 24 } 25 </style> 26 <div id="target"></div> 27 <script> 28 const uid = token(); 29 30 function startTest() { 31 const old_url = "/transition-to-prerender-manual.html"; 32 const new_url = `/resources/transition-to-prerender.html?uid=${uid}`; 33 window.location.href = window.location.href.replace(old_url, new_url); 34 } 35 36 async function waitForPrerender() { 37 const channel = new PrerenderChannel('prerender-channel', uid); 38 39 const gotMessage = new Promise(resolve => { 40 channel.addEventListener('message', resolve) 41 }, { 42 once: true 43 }); 44 45 startPrerendering(`resources/transition-to-prerender.html?uid=${uid}`); 46 await gotMessage; 47 startTest(); 48 } 49 50 onload = waitForPrerender; 51 </script> 52 </html>