a-user-click-during-pageshow.html (1383B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="resources/helpers.js"></script> 6 <script src="/resources/testdriver.js"></script> 7 <script src="/resources/testdriver-vendor.js"></script> 8 9 <body> 10 <script> 11 "use strict"; 12 promise_test(async t => { 13 const sentinelIframe = await setupSentinelIframe(t); 14 const startingHistoryLength = history.length; 15 16 const code = ` 17 window.onpageshow = () => { 18 const a = document.createElement("a"); 19 a.href = "/common/blank.html?thereplacement"; 20 a.id = "the-anchor"; 21 a.textContent = "needs to have content to be clickable"; 22 document.body.append(a); 23 parent.test_driver.click(a); 24 }; 25 `; 26 27 const startURL = "resources/slow-code-injector.html?pipe=sub(none)&code=" + encodeURIComponent(code); 28 const afterReplacementURL = "/common/blank.html?thereplacement"; 29 const iframe = insertIframe(t, startURL); 30 31 assert_equals(history.length, startingHistoryLength, "Inserting the under-test iframe must not change history.length"); 32 33 await waitForLoadAllowingIntermediateLoads(t, iframe, afterReplacementURL); 34 assert_equals(history.length, startingHistoryLength + 1, "history.length must change after waiting for the load"); 35 }, "User click on <a> during the pageshow event must NOT replace"); 36 </script>