summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/resources/image-loading-lazy-in-viewport.html
blob: bafdacc883a7b1d1e72b208769d5d5af59083aa4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<!DOCTYPE html>

<!-- This frame is used by image-loading-lazy-in-cross-origin-iframe-002.sub.html -->

<img id="img" loading="lazy">

<script>
  const img = document.querySelector('#img');

  // Prevent the list of available images check from loading the image non-lazily.
  img.src = "image.png?image-loading-lazy-in-viewport-" + Math.random() + "-" + Date.now();

  img.addEventListener("load", () => {
    parent.postMessage("image_loaded", "*");
  });

  window.addEventListener("load", () => {
    parent.postMessage("window_loaded", "*");
  });
</script>