navigate-cross-document-event-order.html (1583B)
1 <!doctype html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <iframe id="i" src="resources/notify-top-early.html"></iframe> 5 <script> 6 async_test(t => { 7 let events = []; 8 function finish() { 9 assert_array_equals(events, ["onnavigate", "onunload", "readystateinteractive", "domcontentloaded", "readystatecomplete", "onload", "onpageshow"]); 10 t.done(); 11 }; 12 13 window.onload = t.step_func(() => { 14 window.childStarted = () => { 15 i.contentWindow.navigation.onnavigatesuccess = () => events.push("onnavigatesuccess"); 16 i.contentWindow.navigation.onnavigateerror = () => events.push("onnavigateerror"); 17 i.contentWindow.onpageshow = () => events.push("onpageshow"); 18 i.contentWindow.onhashchange = () => events.push("onhashchange"); 19 i.contentWindow.onpopstate = () => events.push("onpopstate"); 20 i.onload = t.step_func(() => { 21 events.push("onload"); 22 t.step_timeout(finish, 0); 23 }); 24 i.contentDocument.addEventListener("DOMContentLoaded", () => events.push("domcontentloaded")); 25 i.contentDocument.onreadystatechange = () => events.push("readystate" + i.contentDocument.readyState); 26 }; 27 i.contentWindow.onunload = () => events.push("onunload"); 28 i.contentWindow.navigation.onnavigate = () => events.push("onnavigate"); 29 i.contentWindow.navigation.navigate("?1").committed.then( 30 () => events.push("promisefulfilled"), () => events.push("promiserejected")); 31 }); 32 }, "navigate() event ordering for cross-document navigation"); 33 </script>