cross-document-nav-same-document-traversal.html (1354B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>Same-document traversal during cross-document navigation</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 7 <!-- 8 According to the spec, "apply the history step" will set the ongoing 9 navigation to "traversal", canceling any navigation that is still processing 10 in parallel and hasn't yet reached "apply the history step". 11 --> 12 13 <body> 14 <script type="module"> 15 import { createIframe, delay } from "./resources/helpers.mjs"; 16 17 promise_test(async t => { 18 const iframe = await createIframe(t); 19 20 // Setup 21 iframe.contentWindow.location.hash = "#1"; 22 await delay(t, 0); 23 iframe.contentWindow.location.hash = "#2"; 24 await delay(t, 0); 25 26 iframe.contentWindow.location.search = "?1"; 27 iframe.contentWindow.onload = t.unreached_func("load event fired"); 28 29 iframe.contentWindow.history.back(); 30 31 assert_equals(iframe.contentWindow.location.search, "", "must not go back synchronously (search)"); 32 assert_equals(iframe.contentWindow.location.hash, "#2", "must not go back synchronously (hash)"); 33 34 // Does go back eventually, and only one step 35 await t.step_wait(() => iframe.contentWindow.location.hash === "#1" && iframe.contentWindow.location.search === ""); 36 }, "cross-document navigations are stopped by same-document back()"); 37 </script>