location-setter.html (2772B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>Replace before load, 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 startURL = "resources/code-injector.html?pipe=sub(none)&code=" + encodeURIComponent("location.href = `/common/blank.html?thereplacement`;"); 17 const afterReplacementURL = "/common/blank.html?thereplacement"; 18 const iframe = insertIframe(t, startURL); 19 assert_equals(history.length, startingHistoryLength, "Inserting the under-test iframe must not change history.length"); 20 21 await waitForLoad(t, iframe, afterReplacementURL); 22 assert_equals(history.length, startingHistoryLength, "history.length must not change after waiting for the replacement"); 23 24 await checkSentinelIframe(t, sentinelIframe); 25 assert_equals(history.length, startingHistoryLength, "history.length must not change after checking the sentinel iframe"); 26 }, "href"); 27 28 promise_test(async t => { 29 const sentinelIframe = await setupSentinelIframe(t); 30 const startingHistoryLength = history.length; 31 32 const startURL = "resources/code-injector.html?pipe=sub(none)&code=" + encodeURIComponent("location.search = `thereplacement`;"); 33 const afterReplacementURL = "resources/code-injector.html?thereplacement"; 34 const iframe = insertIframe(t, startURL); 35 assert_equals(history.length, startingHistoryLength, "Inserting the under-test iframe must not change history.length"); 36 37 await waitForLoad(t, iframe, afterReplacementURL); 38 assert_equals(history.length, startingHistoryLength, "history.length must not change after waiting for the replacement"); 39 40 await checkSentinelIframe(t, sentinelIframe); 41 }, "search"); 42 43 promise_test(async t => { 44 const sentinelIframe = await setupSentinelIframe(t); 45 const startingHistoryLength = history.length; 46 47 const startURL = "resources/code-injector.html?pipe=sub(none)&code=" + encodeURIComponent("location.hash = `thereplacement`;"); 48 const afterReplacementURL = startURL + "#thereplacement"; 49 const iframe = insertIframe(t, startURL); 50 assert_equals(history.length, startingHistoryLength, "Inserting the under-test iframe must not change history.length"); 51 52 await waitForLoad(t, iframe, afterReplacementURL); 53 assert_equals(history.length, startingHistoryLength, "history.length must not change after waiting for the replacement"); 54 55 await checkSentinelIframe(t, sentinelIframe); 56 assert_equals(history.length, startingHistoryLength, "history.length must not change after checking the sentinel iframe"); 57 }, "hash"); 58 </script>