traverseTo-cross-document.html (1991B)
1 <!doctype html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <iframe id="i" src="/common/blank.html"></iframe> 5 <script> 6 async_test(t => { 7 // Wait for after the load event so that the navigation doesn't get converted 8 // into a replace navigation. 9 window.onload = () => t.step_timeout(() => { 10 assert_equals(i.contentWindow.navigation.entries().length, 1); 11 let next_step = "goto"; 12 let key = i.contentWindow.navigation.currentEntry.key; 13 i.contentWindow.navigation.navigate("?1"); 14 i.onload = t.step_func(() => { 15 if (next_step == "goto") { 16 assert_equals(i.contentWindow.navigation.entries().length, 2); 17 assert_equals(i.contentWindow.navigation.currentEntry, i.contentWindow.navigation.entries()[1]); 18 i.contentWindow.navigation.traverseTo(key); 19 next_step = "forward"; 20 } else if (next_step == "forward") { 21 assert_equals(i.contentWindow.navigation.entries().length, 2); 22 assert_equals(key, i.contentWindow.navigation.currentEntry.key); 23 assert_equals(i.contentWindow.navigation.currentEntry, i.contentWindow.navigation.entries()[0]); 24 assert_true(i.contentWindow.navigation.canGoForward); 25 i.contentWindow.navigation.forward(); 26 next_step = "back"; 27 } else if (next_step == "back") { 28 assert_equals(i.contentWindow.navigation.entries().length, 2); 29 assert_equals(i.contentWindow.navigation.currentEntry, i.contentWindow.navigation.entries()[1]); 30 assert_true(i.contentWindow.navigation.canGoBack); 31 i.contentWindow.navigation.back(); 32 next_step = "finish"; 33 } else if (next_step == "finish") { 34 assert_equals(i.contentWindow.navigation.entries().length, 2); 35 assert_equals(i.contentWindow.navigation.currentEntry, i.contentWindow.navigation.entries()[0]); 36 t.done(); 37 } 38 }); 39 }, 0); 40 }, "cross-document traverseTo(), back(), and forward()"); 41 </script>