same-document-nav-cross-document-nav.html (1441B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>Cross-document navigation after a same-document navigation</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 7 <!-- 8 These tests are kind of silly since it's hard to imagine any other result: 9 same-document navigations are always synchronous so of course the 10 same-document navigation will succeed, followed by the cross-document one. 11 12 Nevertheless they're nice as a basis from which to write corresponding app 13 history tests, where the consequences aren't as obvious. 14 --> 15 16 <body> 17 <script type="module"> 18 import { createIframe, waitForLoad } from "./resources/helpers.mjs"; 19 20 promise_test(async t => { 21 const iframe = await createIframe(t); 22 23 iframe.contentWindow.location.hash = "#1"; 24 assert_equals(iframe.contentWindow.location.hash, "#1"); 25 26 iframe.contentWindow.location.search = "?2"; 27 await waitForLoad(iframe); 28 assert_equals(iframe.contentWindow.location.search, "?2"); 29 }, "fragment navigation then cross-document navigation"); 30 31 promise_test(async t => { 32 const iframe = await createIframe(t); 33 34 iframe.contentWindow.history.pushState(null, "", "?1"); 35 assert_equals(iframe.contentWindow.location.search, "?1"); 36 37 iframe.contentWindow.location.search = "?2"; 38 await waitForLoad(iframe); 39 assert_equals(iframe.contentWindow.location.search, "?2"); 40 }, "pushState() then cross-document navigation"); 41 </script>