location-setter-user-mouseup.html (3726B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>No replace before load, triggered by location setters called as part of user-initiated mouseups</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="resources/helpers.js"></script> 7 <script src="/resources/testdriver.js"></script> 8 <script src="/resources/testdriver-vendor.js"></script> 9 10 <!-- 11 We test this separate from click because the spec as of 12 https://html.spec.whatwg.org/commit-snapshots/4ba46b025ec806ded7b4911bf8f9dd7bf9ff365e/#location-object-setter-navigate 13 referenced click handlers specifically, instead of using the general user activation concept which 14 includes other events like mouseup. 15 --> 16 17 <body> 18 <script> 19 "use strict"; 20 21 promise_test(async t => { 22 const sentinelIframe = await setupSentinelIframe(t); 23 const startingHistoryLength = history.length; 24 25 const code = ` 26 const button = document.createElement("button"); 27 button.id = "the-button"; 28 button.textContent = "needs to have content to be clickable"; 29 button.onmouseup = () => { location.href = "/common/blank.html?thereplacement"; }; 30 document.currentScript.before(button); 31 parent.test_driver.click(button); 32 `; 33 34 const startURL = "resources/slow-code-injector.html?pipe=sub(none)&code=" + encodeURIComponent(code); 35 const afterReplacementURL = "/common/blank.html?thereplacement"; 36 const iframe = insertIframe(t, startURL); 37 38 assert_equals(history.length, startingHistoryLength, "Inserting the under-test iframe must not change history.length"); 39 40 await waitForLoad(t, iframe, afterReplacementURL); 41 assert_equals(history.length, startingHistoryLength + 1, "history.length must change after waiting for the load"); 42 }, "href"); 43 44 promise_test(async t => { 45 const sentinelIframe = await setupSentinelIframe(t); 46 const startingHistoryLength = history.length; 47 48 const code = ` 49 const button = document.createElement("button"); 50 button.id = "the-button"; 51 button.textContent = "needs to have content to be clickable"; 52 button.onmouseup = () => { location.search = "thereplacement"; }; 53 document.currentScript.before(button); 54 parent.test_driver.click(button); 55 `; 56 57 const startURL = "resources/slow-code-injector.html?pipe=sub(none)&code=" + encodeURIComponent(code); 58 const afterReplacementURL = "resources/slow-code-injector.html?thereplacement"; 59 const iframe = insertIframe(t, startURL); 60 61 assert_equals(history.length, startingHistoryLength, "Inserting the under-test iframe must not change history.length"); 62 63 await waitForLoad(t, iframe, afterReplacementURL); 64 assert_equals(history.length, startingHistoryLength + 1, "history.length must change after waiting for the load"); 65 }, "search"); 66 67 promise_test(async t => { 68 const sentinelIframe = await setupSentinelIframe(t); 69 const startingHistoryLength = history.length; 70 71 const code = ` 72 const button = document.createElement("button"); 73 button.id = "the-button"; 74 button.textContent = "needs to have content to be clickable"; 75 button.onmouseup = () => { location.hash = "thereplacement"; }; 76 document.currentScript.before(button); 77 parent.test_driver.click(button); 78 `; 79 80 const startURL = "resources/slow-code-injector.html?pipe=sub(none)&code=" + encodeURIComponent(code); 81 const afterReplacementURL = startURL + "#thereplacement"; 82 const iframe = insertIframe(t, startURL); 83 84 assert_equals(history.length, startingHistoryLength, "Inserting the under-test iframe must not change history.length"); 85 86 await waitForLoad(t, iframe, afterReplacementURL); 87 assert_equals(history.length, startingHistoryLength + 1, "history.length must change after waiting for the load"); 88 }, "hash"); 89 </script>