/
original-base-url-applied-2-tentative.html
55 lines (48 loc) · 2.11 KB
/
original-base-url-applied-2-tentative.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!DOCTYPE html>
<head>
<title>Deferred images with loading='lazy' use the original
base URL specified at the parse time</title>
<link rel="author" title="Rob Buis" href="mailto:rbuis@igalia.com">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="common.js"></script>
<base href='/loading/lazyload/resources/'>
</head>
<!--
Marked as tentative until https://github.com/whatwg/html/pull/3752 is landed.
-->
<script>
const below_viewport_img_promise = new ElementLoadPromise("below_viewport_img");
let has_window_loaded = false;
async_test(function(t) {
// Change the base URL and scroll down to load the deferred elements.
window.addEventListener("load", t.step_func(function() {
const base = document.getElementsByTagName('base')[0];
base.href = '/invalid-url-where-no-subresources-exist/';
has_window_loaded = true;
below_viewport_img_promise.element().scrollIntoView();
}));
below_viewport_img_promise.promise.then(
t.step_func_done(function() {
assert_true(has_window_loaded,
"Below-viewport loading=lazy images do not block the " +
"window load event");
assert_true(below_viewport_img_promise.element().complete,
"The loading=lazy image should be considered complete " +
"upon load.");
assert_greater_than(below_viewport_img_promise.element().naturalWidth,
0,
"The loading=lazy should have non-zero width " +
"upon loading");
})
).catch(t.unreached_func("The image request should not load relative to " +
"the current (incorrect) base URL."));
}, "Deferred images with loading='lazy' use the original base URL " +
"specified at the parse time");
</script>
<body>
<div style="height:1000vh"></div>
<img id="below_viewport_img" src="image.png" loading="lazy"
onload="below_viewport_img_promise.resolve();"
onerror="below_viewport_img_promise.reject();">
</body>