navigate-iframe-location.html (1272B)
1 <!doctype html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <iframe id="iframe" src="/common/blank.html"></iframe> 5 <script> 6 async_test(t => { 7 window.onload = t.step_func(() => { 8 navigation.onnavigate = t.step_func_done(() => { 9 assert_unreached("onnavigate should not have fired in source window"); 10 }); 11 iframe.contentWindow.navigation.onnavigate = t.step_func_done(e => { 12 assert_equals(e.navigationType, "push"); 13 assert_true(e.cancelable); 14 assert_true(e.canIntercept); 15 assert_false(e.userInitiated); 16 assert_true(e.hashChange); 17 assert_equals(e.downloadRequest, null); 18 assert_equals(new URL(e.destination.url).hash, "#1"); 19 assert_true(e.destination.sameDocument); 20 assert_equals(e.destination.key, ""); 21 assert_equals(e.destination.id, ""); 22 assert_equals(e.destination.index, -1); 23 assert_equals(e.formData, null); 24 assert_equals(e.sourceElement, null); 25 e.preventDefault(); 26 t.step_timeout(t.step_func_done(() => assert_equals(location.hash, "")), 0); 27 }); 28 iframe.contentWindow.location.hash = "#1"; 29 }); 30 }, "location API on another window fires navigate event in the target window only"); 31 </script>