location-setter-during-load.html (3058B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>Replace during the load event, triggered by location setters</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="resources/helpers.js"></script> 7 8 <body> 9 <script> 10 "use strict"; 11 12 promise_test(async t => { 13 const sentinelIframe = await setupSentinelIframe(t); 14 const startingHistoryLength = history.length; 15 16 const code = ` 17 window.onload = () => { 18 location.href = "/common/blank.html?thereplacement"; 19 }; 20 `; 21 22 const startURL = "resources/code-injector.html?pipe=sub(none)&code=" + encodeURIComponent(code); 23 const afterReplacementURL = "/common/blank.html?thereplacement"; 24 const iframe = insertIframe(t, startURL); 25 assert_equals(history.length, startingHistoryLength, "Inserting the under-test iframe must not change history.length"); 26 27 await waitForLoadAllowingIntermediateLoads(t, iframe, afterReplacementURL); 28 assert_equals(history.length, startingHistoryLength, "history.length must not change after waiting for the replacement"); 29 30 await checkSentinelIframe(t, sentinelIframe); 31 assert_equals(history.length, startingHistoryLength, "history.length must not change after checking the sentinel iframe"); 32 }, "href"); 33 34 promise_test(async t => { 35 const sentinelIframe = await setupSentinelIframe(t); 36 const startingHistoryLength = history.length; 37 38 const code = ` 39 window.onload = () => { 40 location.search = "thereplacement"; 41 }; 42 `; 43 44 const startURL = "resources/code-injector.html?pipe=sub(none)&code=" + encodeURIComponent(code); 45 const afterReplacementURL = "resources/code-injector.html?thereplacement"; 46 const iframe = insertIframe(t, startURL); 47 assert_equals(history.length, startingHistoryLength, "Inserting the under-test iframe must not change history.length"); 48 49 await waitForLoadAllowingIntermediateLoads(t, iframe, afterReplacementURL); 50 assert_equals(history.length, startingHistoryLength, "history.length must not change after waiting for the replacement"); 51 52 await checkSentinelIframe(t, sentinelIframe); 53 }, "search"); 54 55 promise_test(async t => { 56 const sentinelIframe = await setupSentinelIframe(t); 57 const startingHistoryLength = history.length; 58 59 const code = ` 60 window.onload = () => { 61 location.hash = "thereplacement"; 62 }; 63 `; 64 65 const startURL = "resources/code-injector.html?pipe=sub(none)&code=" + encodeURIComponent(code); 66 const afterReplacementURL = startURL + "#thereplacement"; 67 const iframe = insertIframe(t, startURL); 68 assert_equals(history.length, startingHistoryLength, "Inserting the under-test iframe must not change history.length"); 69 70 await waitForLoadAllowingIntermediateLoads(t, iframe, afterReplacementURL); 71 assert_equals(history.length, startingHistoryLength, "history.length must not change after waiting for the replacement"); 72 73 await checkSentinelIframe(t, sentinelIframe); 74 assert_equals(history.length, startingHistoryLength, "history.length must not change after checking the sentinel iframe"); 75 }, "hash"); 76 </script>