a-user-click.html (1312B)
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 const a = document.createElement("a"); 18 a.href = "/common/blank.html?thereplacement"; 19 a.id = "the-anchor"; 20 a.textContent = "needs to have content to be clickable"; 21 document.currentScript.before(a); 22 parent.test_driver.click(a); 23 `; 24 25 const startURL = "resources/slow-code-injector.html?pipe=sub(none)&code=" + encodeURIComponent(code); 26 const afterReplacementURL = "/common/blank.html?thereplacement"; 27 const iframe = insertIframe(t, startURL); 28 29 assert_equals(history.length, startingHistoryLength, "Inserting the under-test iframe must not change history.length"); 30 31 await waitForLoad(t, iframe, afterReplacementURL); 32 assert_equals(history.length, startingHistoryLength + 1, "history.length must change after waiting for the load"); 33 }, "User click on <a> before the load event must NOT replace"); 34 </script>