tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

iframe-src-during-pageshow.html (1308B)


      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    window.onpageshow = () => {
     16      parent.document.querySelectorAll("iframe")[1].src = "/common/blank.html?thereplacement";
     17    };
     18  `;
     19  const startURL = "resources/code-injector.html?pipe=sub(none)&code=" + encodeURIComponent(code);
     20  const afterReplacementURL = "/common/blank.html?thereplacement";
     21  const iframe = insertIframe(t, startURL);
     22 
     23  assert_equals(history.length, startingHistoryLength, "Inserting the under-test iframe must not change history.length");
     24 
     25  await waitForLoadAllowingIntermediateLoads(t, iframe, afterReplacementURL);
     26  assert_equals(history.length, startingHistoryLength, "history.length must not change after waiting for the replacement");
     27 
     28  await checkSentinelIframe(t, sentinelIframe);
     29  assert_equals(history.length, startingHistoryLength, "history.length must not change after checking the sentinel iframe");
     30 }, "Replace during the pageshow event, triggered by setting iframeElement.src");
     31 </script>