iframe-content-not-observed.html (2462B)
1 <!doctype html> 2 <!-- 3 The soft navigation version of the identically named test in 4 /largest-contentful-paint/iframe-content-not-observed.html 5 Notes: 6 - This test almost triggers a soft navigation except that the 7 contents inside the iframe don't count, even though it's same-origin. 8 This is actually just like LCP, and we also test that the iframe content 9 doesn't generate a soft LCP entry either. 10 --> 11 <meta charset="utf-8" /> 12 <title> 13 Largest Contentful Paint and soft navigation: do NOT observe elements from same-origin iframes 14 </title> 15 <script src="/resources/testharness.js"></script> 16 <script src="/resources/testharnessreport.js"></script> 17 <script src="/resources/testdriver.js"></script> 18 <script src="/resources/testdriver-vendor.js"></script> 19 <script src="/soft-navigation-heuristics/resources/soft-navigation-test-helper.js"></script> 20 <script> 21 function clickHandler() { 22 document.body.innerHTML = `<iframe src='/largest-contentful-paint/resources/iframe-with-content.html'></iframe>`; 23 history.pushState({}, "", "/test"); 24 } 25 </script> 26 <body> 27 <div id="click-target" onclick="clickHandler()">Click!</div> 28 </body> 29 <script> 30 promise_test(async (t) => { 31 assert_implements(window.LargestContentfulPaint, "LargestContentfulPaint is not implemented"); 32 const helper = new SoftNavigationTestHelper(t); 33 const lcpEntries = 34 await helper.getBufferedPerformanceEntriesWithTimeout("largest-contentful-paint"); 35 assert_equals(lcpEntries.length, 1); 36 assert_equals(lcpEntries[0].id, "click-target", "The first entry should be the button"); 37 38 const softNavigationPromise = 39 SoftNavigationTestHelper.getPerformanceEntries("soft-navigation") 40 .then((entries) => { 41 assert_unreached("Should not have received a soft navigation entry!"); 42 }); 43 const softLcpPromise = 44 SoftNavigationTestHelper.getPerformanceEntries("interaction-contentful-paint") 45 .then((entries) => { 46 assert_unreached("Should not have received an a soft LCP entry!"); 47 }); 48 49 if (test_driver) { 50 test_driver.click(document.getElementById("click-target")); 51 } 52 53 // If neither the soft navigation nor the soft LCP are received within 3 seconds, we're ok. 54 await Promise.race([ 55 softNavigationPromise, 56 softLcpPromise, 57 new Promise((resolve) => t.step_timeout(resolve(), 2000)), 58 ]); 59 }, "Element in child iframe is not observed for lcp or soft navigation, even if same-origin."); 60 </script>