tor-browser

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

iframe-loading-lazy-adopt-lazy-iframe-from-script-disabled-document.html (1505B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4  <title>Test lazy loading iframe remains lazy loading originally created
      5         in a script-disabled document, then got adopted to a regular document</title>
      6  <script src="/resources/testharness.js"></script>
      7  <script src="/resources/testharnessreport.js"></script>
      8 </head>
      9 <script>
     10  const t = async_test("Test lazy loading iframe remains lazy loading originally created" +
     11                       "in a script-disabled document, then got adopted to a regular document");
     12 
     13  const lazyIFrameInScriptDisabledDocumentOnLoad =
     14    t.unreached_func("lazy loading iframe shoudn't be loaded because it's not visible");
     15 
     16  window.addEventListener("load", t.step_func(() => {
     17    const parser = new DOMParser();
     18    const remoteDoc = `
     19        <!DOCTYPE html>
     20        <html>
     21          <iframe
     22            id="lazyIFrameInScriptDisabledDocument"
     23            src="resources/subframe.html"
     24            loading="lazy"
     25            width="600"
     26            height="400"
     27            style="display: none"
     28          >
     29          Your browser does not support iframes.
     30          </iframe>
     31        </html>`;
     32 
     33    const htmlDoc = parser.parseFromString(remoteDoc, "text/html");
     34    var newIframe = htmlDoc.getElementById("lazyIFrameInScriptDisabledDocument");
     35    newIframe.onload = lazyIFrameInScriptDisabledDocumentOnLoad;
     36 
     37    document.body.appendChild(newIframe);
     38 
     39    // Give some time to the "load" event to fire.
     40    t.step_timeout(t.step_func_done(), 2000);
     41  }));
     42 </script>
     43 </html>