Bug 1615198 [wpt PR 21773] - Remove tentative from lazy load tests, a=testonly
[gecko.git] / testing / web-platform / tests / html / semantics / embedded-content / the-img-element / image-loading-lazy-move-document.html
blobff7e83105cc904145e67eb156653b69b6f0b113a
1 <!DOCTYPE html>
2 <head>
3 <title>Moving loading='lazy' image into another top level document</title>
4 <link rel="help" href="https://github.com/scott-little/lazyload">
5 <script src="/resources/testharness.js"></script>
6 <script src="/resources/testharnessreport.js"></script>
7 </head>
9 <div style="height:1000vh;"></div>
10 <img loading="lazy"
11 src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAIAAAAC64paAAAAG0lEQVR42mP8z0A%2BYKJA76jmUc2jmkc1U0EzACKcASfOgGoMAAAAAElFTkSuQmCC">
12 <script>
13 promise_test(async t => {
14 let image_loaded = false;
15 const img = document.querySelector("img");
16 img.addEventListener("load", () => { image_loaded = true; });
18 await new Promise(resolve => window.addEventListener("load", resolve));
20 assert_false(image_loaded,
21 "lazy-load image shouldn't be loaded yet");
23 const anotherWin = window.open("resources/newwindow.html");
25 await new Promise(resolve => anotherWin.addEventListener("load", resolve));
27 anotherWin.document.body.appendChild(img);
29 assert_false(image_loaded,
30 "lazy-load image shouldn't be loaded yet");
32 img.scrollIntoView();
34 await new Promise(resolve => img.addEventListener("load", resolve));
35 assert_true(img.complete,
36 "Now the lazy-load image should be loaded");
37 });
38 </script>