navigation-id-reset.tentative.html (2140B)
1 <!DOCTYPE HTML> 2 <meta name="timeout" content="long"> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="/common/utils.js"></script> 6 <script src="/common/dispatcher/dispatcher.js"></script> 7 <script src="/html/browsers/browsing-the-web/back-forward-cache/resources/helper.sub.js"></script> 8 <script> 9 const reload = () => { 10 window.location.reload(); 11 }; 12 13 const getNavigationId = () => { 14 window.performance.mark('initial_load'); 15 let entries = window.performance.getEntriesByType('mark'); 16 return entries[entries.length - 1].navigationId; 17 } 18 19 promise_test(async t => { 20 const pageA = new RemoteContext(token()); 21 const pageB = new RemoteContext(token()); 22 23 const urlA = executorPath + pageA.context_id; 24 const urlB = originCrossSite + executorPath + pageB.context_id; 25 // Open url A. 26 window.open(urlA, '_blank', 'noopener') 27 await pageA.execute_script(waitForPageShow); 28 29 let navigationIdInitial = await pageA.execute_script(getNavigationId); 30 31 // Navigate away to url B and back. 32 await navigateAndThenBack(pageA, pageB, urlB); 33 34 // Assert navigation id is re-generated and thus different when the 35 // document is load from bfcache. 36 navigationIdAfterBFCacheNav = await pageA.execute_script(getNavigationId); 37 assert_not_equals(navigationIdInitial, navigationIdAfterBFCacheNav, 'Navigation Id should be \ 38 re-generated and different from the previous one after back-forward-cache navigation.'); 39 40 // Reload page. 41 await pageA.execute_script(reload); 42 await pageA.execute_script(waitForPageShow); 43 44 navigationIdAfterReset = await pageA.execute_script(getNavigationId); 45 46 assert_not_equals(navigationIdAfterReset, navigationIdAfterBFCacheNav, 'Navigation Id should\ 47 be re-generated after reload which is different from the previous one.'); 48 49 assert_not_equals(navigationIdAfterReset, navigationIdInitial, 'Navigation Id should\ 50 be re-generated after reload which is different from the one of the initial load.'); 51 52 }, 'Navigation Id should be re-generated after reload.'); 53 </script>