Skip to content

Commit dbb8020

Browse files
committed
Test lazy loading intersection observations outside viewport
For: whatwg/html#10019
1 parent 905cb44 commit dbb8020

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!doctype html>
2+
<meta charset=utf-8>
3+
<title>Lazy-loading image outside the viewport does not block image inside the viewport</title>
4+
<link rel="help" href="https://github.com/whatwg/html/issues/10019">
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
8+
<style>
9+
img {
10+
border: 1px solid black;
11+
width: 30px;
12+
height: 30px;
13+
}
14+
15+
#notInViewport {
16+
position: relative;
17+
top: -1000px;
18+
}
19+
</style>
20+
21+
<body>
22+
<script>
23+
const imageSrc = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwADhQGAWjR9awAAAABJRU5ErkJggg==";
24+
25+
async_test(t => {
26+
const notInViewport = document.createElement("img");
27+
notInViewport.id = "notInViewport";
28+
notInViewport.loading = "lazy";
29+
30+
const inViewport = document.createElement("img");
31+
inViewport.id = "inViewport";
32+
inViewport.loading = "lazy";
33+
inViewport.onerror = t.unreached_func("The in-viewport lazy image must load");
34+
inViewport.onload = t.step_func_done(() => {});
35+
36+
document.body.append(notInViewport, inViewport);
37+
notInViewport.src = imageSrc;
38+
inViewport.src = imageSrc;
39+
}, "A lazy image outside the viewport must not block a later lazy image inside the viewport");
40+
</script>

0 commit comments

Comments
 (0)