a-click.html (1097B)
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 7 <body> 8 <script> 9 "use strict"; 10 promise_test(async t => { 11 const sentinelIframe = await setupSentinelIframe(t); 12 const startingHistoryLength = history.length; 13 14 const code = ` 15 const a = document.createElement("a"); 16 a.href = "/common/blank.html?thereplacement"; 17 document.currentScript.before(a); 18 a.click(); 19 `; 20 21 const startURL = "resources/code-injector.html?pipe=sub(none)&code=" + encodeURIComponent(code); 22 const afterReplacementURL = "/common/blank.html?thereplacement"; 23 const iframe = insertIframe(t, startURL); 24 25 assert_equals(history.length, startingHistoryLength, "Inserting the under-test iframe must not change history.length"); 26 27 await waitForLoad(t, iframe, afterReplacementURL); 28 assert_equals(history.length, startingHistoryLength + 1, "history.length must change after waiting for the load"); 29 }, "aElement.click() before the load event must NOT replace"); 30 </script>