tor-browser

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

iframe-loading-lazy-base-url-2.html (1979B)


      1 <!DOCTYPE html>
      2 <head>
      3  <title>Deferred loading=lazy iframes load relative to the document's base URL
      4         at parse-time</title>
      5  <link rel="author" title="Dom Farolino" href="mailto:dom@chromium.org">
      6  <link rel="author" title="Raj T" href="mailto:rajendrant@chromium.org">
      7  <script src="/resources/testharness.js"></script>
      8  <script src="/resources/testharnessreport.js"></script>
      9  <script src="../resources/common.js"></script>
     10 </head>
     11 
     12 <script>
     13  const below_viewport_iframe = new ElementLoadPromise("below-viewport");
     14 
     15  let has_window_loaded = false;
     16 
     17  async_test(t => {
     18    // Change the document's base URL to a bogus one, and scroll the
     19    // below-viewport iframe into view. When it loads, it should load relative
     20    // to the old base URL computed at parse-time.
     21    window.addEventListener("load", t.step_func(() => {
     22      window.history.pushState(2, document.title,
     23                               '/invalid-url-where-no-subresources-exist/')
     24      has_window_loaded = true;
     25      below_viewport_iframe.element().scrollIntoView();
     26    }));
     27 
     28    below_viewport_iframe.promise.then(t.step_func_done(() => {
     29      assert_true(has_window_loaded,
     30            "Below-viewport loading=lazy iframes do not block the " +
     31            "window load event");
     32      assert_true(below_viewport_iframe.element()
     33                    .contentDocument.body.innerHTML.includes("<p>Subframe</p>"));
     34    }));
     35 
     36  }, "When a loading=lazy iframe is loaded, it loads relative to the " +
     37     "document's base URL computed at parse-time.");
     38 </script>
     39 
     40 <body>
     41  <div style="height:1000vh;"></div>
     42  <script>
     43    // Change the document's base URL so that the iframe request parses relative
     44    // to it when it sets up the request at parse-time.
     45    window.history.pushState(1, document.title, 'resources/')
     46  </script>
     47  <iframe id="below-viewport" src="subframe.html" loading="lazy" width="200px"
     48          height="100px" onload="below_viewport_iframe.resolve()"</iframe>
     49 </body>