tor-browser

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

src-then-lazy-load.html (1011B)


      1 <!doctype html>
      2 <title>Image shouldn't load synchronously out of the document.</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <body>
      6 <script>
      7 async function run_test(prop, image, repetitions, t) {
      8  for (let i = 0; i < repetitions; ++i) {
      9    let img = document.createElement("img")
     10    img[prop] = `${image}?src-then-lazy-load-` + Math.random();
     11    img.loading = "lazy";
     12    img.style.display = "none";
     13    img.addEventListener("error", t.unreached_func("error: should never try to load"));
     14    img.addEventListener("load", t.unreached_func("load: should never try to load"));
     15    document.body.appendChild(img);
     16    await new Promise(r => t.step_timeout(r, 500));
     17  }
     18 }
     19 
     20 for (let prop of ["src", "srcset"]) {
     21  for (let path of ["/images/green.png", "/images/not-found"]) {
     22    for (let repetitions of [1, 2]) {
     23      promise_test(t => run_test(prop, path, repetitions, t), `${prop} = ${path} ${repetitions} time(s)`);
     24    }
     25  }
     26 }
     27 </script>