same-document-nav-same-document-traversal.html (1771B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>Same-document traversal after a same-document navigations</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 back() won't 10 cancel them. 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, delay } from "./resources/helpers.mjs"; 19 20 promise_test(async t => { 21 const iframe = await createIframe(t); 22 23 // Setup 24 iframe.contentWindow.location.hash = "#1"; 25 await delay(t, 0); 26 iframe.contentWindow.location.hash = "#2"; 27 await delay(t, 0); 28 29 iframe.contentWindow.location.hash = "#3"; 30 iframe.contentWindow.history.back(); 31 32 assert_equals(iframe.contentWindow.location.hash, "#3", "must not go back synchronously"); 33 34 // Does go back eventually, and only one step 35 await t.step_wait(() => iframe.contentWindow.location.hash === "#2"); 36 }, "fragment navigation then back()"); 37 38 promise_test(async t => { 39 const iframe = await createIframe(t); 40 41 // Setup 42 iframe.contentWindow.history.pushState(null, "", "?1"); 43 await delay(t, 0); 44 iframe.contentWindow.history.pushState(null, "", "?2"); 45 await delay(t, 0); 46 47 iframe.contentWindow.history.pushState(null, "", "?3"); 48 iframe.contentWindow.history.back(); 49 50 assert_equals(iframe.contentWindow.location.search, "?3", "must not go back synchronously"); 51 52 // Does go back eventually, and only one step 53 await t.step_wait(() => iframe.contentWindow.location.search === "?2"); 54 }, "pushState then back()"); 55 </script>