visited-link.tentative.html (2217B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>Soft navigation visited link paint tests.</title> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <script src="/resources/testdriver.js"></script> 9 <script src="/resources/testdriver-vendor.js"></script> 10 <script src="resources/soft-navigation-helper.js"></script> 11 </head> 12 <body> 13 <main id=main> 14 <a id=link>Click me!</a> 15 <a id=visited>link that is really long so it is the LCP</a> 16 </main> 17 <script> 18 const visited = document.getElementById("visited"); 19 const fake_url = "./fake_" + Math.random(); 20 visited.href = fake_url; 21 const visitFakeURLAndAddInvisibleText = () => { 22 requestAnimationFrame(() => requestAnimationFrame(() => { 23 history.replaceState({}, "", fake_url); 24 })); 25 const main = document.getElementById("main"); 26 const div = document.createElement("div"); 27 const text = document.createTextNode( 28 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, ' + 29 'sed do eiusmod tempor incididunt ut labore et dolore magna ' + 30 'aliqua. Ut enim ad minim veniam, quis nostrud exercitation ' + 31 'ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis ' + 32 'aute irure dolor in reprehenderit in voluptate velit esse ' + 33 'cillum dolore eu fugiat nulla pariatur. Excepteur sint ' + 34 'occaecat cupidatat non proident, sunt in culpa qui officia ' + 35 'deserunt mollit anim id est laborum.'); 36 div.appendChild(text); 37 main.appendChild(div); 38 } 39 testSoftNavigation({ 40 testName: "Test that a visited link doesn't trigger LCP after a soft " + 41 "navigation is detected", 42 addContent: async () => { 43 await visitFakeURLAndAddInvisibleText(); 44 }, 45 extraValidations: async (t) => { 46 await new Promise(r => step_timeout(r, 100)); 47 const icps = await getBufferedEntries('interaction-contentful-paint'); 48 assert_not_equals(icps[icps.length - 1].id, 49 "visited", 50 "Soft Nav ICP ID should not be visited"); 51 }, 52 }); 53 </script> 54 </body> 55 </html>