entries-after-bfcache-in-iframe.html (1782B)
1 <!doctype html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <script src="/common/utils.js"></script> 5 <script src="/common/dispatcher/dispatcher.js"></script> 6 <script src="/html/browsers/browsing-the-web/back-forward-cache/resources/helper.sub.js"></script> 7 <script src="resources/is_uuid.js"></script> 8 9 <script> 10 // This test ensures that navigation.entries() in an iframe is properly updated 11 // when a page is restored from bfcache. 12 // First, create an iframe and do a fragment navigation in it, so that its 13 // navigation.entries().length == 2. Then go back, so that entries()[0] is 14 // current. Finally, navigate the main window (which should clobber the 15 // the iframe's entries()[1]), and come back via bfcache. If the iframe's 16 // entries() were updated, then its entries().length should have been reduced 17 // to 1. 18 runBfcacheTest({ 19 targetOrigin: originSameOrigin, 20 funcBeforeNavigation: async () => { 21 window.events = []; 22 let i = document.createElement("iframe"); 23 i.src = "/common/blank.html"; 24 document.body.appendChild(i); 25 await new Promise(resolve => i.onload = () => setTimeout(resolve, 0)); 26 await i.contentWindow.navigation.navigate("#foo"); 27 await i.contentWindow.navigation.back(); 28 window.frames[0].navigation.entries()[1].ondispose = () => events.push("dispose"); 29 window.frames[0].onpageshow = () => events.push("pageshow"); 30 }, 31 async funcAfterAssertion(pageA, pageB) { 32 assert_equals(await pageA.execute_script(() => window.frames[0].navigation.entries().length), 1); 33 assert_array_equals(await pageA.execute_script(() => window.events), ["pageshow", "dispose"]); 34 } 35 }, "entries() in an iframe must be updated after navigating back to a bfcached page"); 36 </script>