tor-browser

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

iframe-src.html (1541B)


      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.onload = () => { window.onloadFired = true; };
     16  `;
     17  const startURL = "resources/slow-code-injector.html?pipe=sub(none)&code=" + encodeURIComponent(code);
     18  const afterReplacementURL = "/common/blank.html?thereplacement";
     19  const iframe = insertIframe(t, startURL);
     20 
     21  assert_equals(history.length, startingHistoryLength, "Inserting the under-test iframe must not change history.length");
     22 
     23  const absoluteStartURL = (new URL(startURL, location.href)).href;
     24  while (true) {
     25    if (iframe.contentWindow.location.href === absoluteStartURL) {
     26      break;
     27    }
     28    await new Promise(r => setTimeout(r, 0));
     29  }
     30 
     31  assert_equals(iframe.contentWindow.location.href, (new URL(startURL, location.href)).href, "Iframe must be navigated away from the initial about:blank document");
     32  assert_equals(iframe.contentWindow.onloadFired, undefined, "onload must not yet have fired");
     33 
     34  iframe.src = afterReplacementURL;
     35 
     36  await checkSentinelIframe(t, sentinelIframe);
     37  assert_equals(history.length, startingHistoryLength, "history.length must not change after checking the sentinel iframe");
     38 }, "Replace before load, triggered by setting iframeElement.src");
     39 </script>