open-samedocument-crossorigin-sameorigindomain.sub.html (1479B)
1 <!doctype html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <body> 5 6 <script> 7 document.domain = "{{host}}"; 8 async_test(t => { 9 const url = new URL("resources/document-domain-setter.sub.html", location.href); 10 url.hostname = "{{domains[www1]}}"; 11 const iframe = document.createElement("iframe"); 12 iframe.name = "windowname"; 13 iframe.src = url; 14 document.body.append(iframe); 15 16 navigation.onnavigate = t.unreached_func("onnavigate must not fire in the source window"); 17 window.onload = t.step_func(() => { 18 iframe.contentWindow.navigation.onnavigate = t.step_func_done(e => { 19 assert_equals(e.navigationType, "push", "navigationType"); 20 assert_true(e.cancelable, "cancelable"); 21 assert_true(e.canIntercept, "canIntercept"); 22 assert_false(e.userInitiated, "userInitiated"); 23 assert_true(e.hashChange, "hashChange"); 24 assert_equals(e.formData, null, "formData"); 25 assert_equals(e.destination.url, url + "#foo", "destination.url"); 26 assert_true(e.destination.sameDocument, "destination.sameDocument"); 27 assert_equals(e.destination.key, "", "destination.key"); 28 assert_equals(e.destination.id, "", "destination.id"); 29 assert_equals(e.destination.index, -1, "destination.index"); 30 }); 31 32 window.open(url + "#foo", iframe.name); 33 }); 34 }, "using window.open() to navigate same-document targeting a same-origin-domain (but cross-origin) window"); 35 </script>