tor-browser

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

iframe-loading-lazy-nav-location-replace-cross-origin.html (1263B)


      1 <!DOCTYPE html>
      2 <title>Navigating to a cross-origin for iframe loading='lazy' before it is loaded: location.replace</title>
      3 <script src="/common/get-host-info.sub.js"></script>
      4 <iframe src="support/blank.htm?src" loading="lazy" hidden></iframe>
      5 <script>
      6 const iframe = document.querySelector('iframe');
      7 iframe.setAttribute(
      8  "data-src",
      9  `${get_host_info().HTTP_NOTSAMESITE_ORIGIN}/html/semantics/embedded-content/the-iframe-element/support/blank.htm?nav`
     10 );
     11 
     12 const iframeLoaded = new Promise(resolve => {
     13  iframe.onload = resolve;
     14 });
     15 iframe.contentWindow.location.replace(iframe.dataset.src);
     16 iframe.hidden = false;
     17 </script>
     18 <!-- Loading testharness.js here is intentional to reproduce a bug in WebKit. -->
     19 <script src="/resources/testharness.js"></script>
     20 <script src="/resources/testharnessreport.js"></script>
     21 <script>
     22 setup({single_test: true});
     23 iframeLoaded.then(() => {
     24  // Need a timeout to detect failure when there are two navigations.
     25  step_timeout(() => {
     26    assert_throws_dom(
     27      "SecurityError", // Use the SecurityError to assert this is a cross-origin iframe
     28      () => {
     29        iframe.contentWindow.location.href
     30      },
     31      "The iframe should load the cross-site url via locaiton.replace");
     32    done();
     33  }, 1000);
     34 });
     35 </script>