navigation-id-initial-load.tentative.html (2221B)
1 <!DOCTYPE HTML> 2 <meta name="timeout" content="long"> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <!-- 6 Navigation timing, LCP and paint timing entries are only emitted during initial 7 load, not after a bfcache navigation. Therefore we only verify the existence of 8 navigation id, not the increment. 9 --> 10 11 <body> 12 <p>This text is to trigger a LCP entry emission.</p> 13 <script> 14 async function NavigationIdsFromLCP() { 15 return new Promise(resolve => { 16 new PerformanceObserver((entryList) => { 17 resolve(entryList.getEntries()); 18 }).observe({ type: 'largest-contentful-paint', buffered: true }); 19 }) 20 } 21 22 promise_test(async t => { 23 // Assert navigation id exists in LCP entries and and are all the same. 24 const navigationIdsOfLCP = (await NavigationIdsFromLCP()).map(e => e.navigationId); 25 assert_true(navigationIdsOfLCP.every(e => e == navigationIdsOfLCP[0]), 26 'Navigation Ids of LCP entries should be the same at initial navigation'); 27 28 // Assert navigation id exists in a NavigationTiming entry. 29 const navigationIdOfNavigationTiming = 30 performance.getEntriesByType('navigation')[0].navigationId; 31 assert_true(!!navigationIdOfNavigationTiming, 32 'Navigation Id of a navigation timing entry should exist at initial navigation'); 33 34 // Assert navigation id exists in PaintTiming entries and are all the same. 35 const navigationIdsOfPaintTiming = 36 performance.getEntriesByType('paint').map(e => e.navigationId); 37 assert_true(navigationIdsOfPaintTiming.every(e => 38 e == navigationIdsOfPaintTiming[0]), 39 'Navigation Id of PaintTiming entries should be the same as the initial navigation.'); 40 41 // Assert navigation ids are all the same. 42 const navigationIdsOfAll = 43 navigationIdsOfLCP.concat(navigationIdsOfPaintTiming, navigationIdOfNavigationTiming); 44 assert_true(navigationIdsOfAll.every(e => e == navigationIdsOfAll[0]), 45 'Navigation Id of all entries should be the same as the initial navigation.'); 46 47 }, 'Navigation Ids should exist and are all the same as the initial navigation.'); 48 </script> 49 </body>