tor-browser

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

iframe-loading-lazy-base-url.html (1735B)


      1 <!DOCTYPE html>
      2 <head>
      3  <title>Deferred iframes with loading='lazy' use the original
      4         base URL specified at parse-time</title>
      5  <link rel="author" title="Rob Buis" href="mailto:rbuis@igalia.com">
      6  <script src="/resources/testharness.js"></script>
      7  <script src="/resources/testharnessreport.js"></script>
      8  <script src="../resources/common.js"></script>
      9  <base href='/html/semantics/embedded-content/the-iframe-element/resources/'>
     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 base URL and scroll down to load the deferred iframe.
     19    window.addEventListener("load", t.step_func(() => {
     20      const base = document.querySelector('base');
     21      base.href = '/invalid-url-where-no-subresources-exist/';
     22      has_window_loaded = true;
     23      below_viewport_iframe.element().scrollIntoView();
     24    }));
     25 
     26    below_viewport_iframe.promise.then(
     27      t.step_func_done(() => {
     28        assert_true(has_window_loaded,
     29                    "Below-viewport loading=lazy iframes do not block the " +
     30                    "window load event");
     31        assert_true(below_viewport_iframe.element().contentDocument.body.
     32                    innerHTML.includes("<p>Subframe</p>"),
     33                    "The loading=lazy iframe's content is accessible upon loading");
     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  <iframe id="below-viewport" src="subframe.html" loading="lazy"
     43          width="200px" height="100px" onload="below_viewport_iframe.resolve()">
     44  </iframe>
     45 </body>