-
Notifications
You must be signed in to change notification settings - Fork 54
/
original-base-url-applied-tentative.html
52 lines (46 loc) · 2.19 KB
/
original-base-url-applied-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
<!DOCTYPE html>
<head>
<title>Deferred iframes and images with loading='lazy' use the original base URL specified at the parse time</title>
<link rel="author" title="Raj T" href="mailto:rajendrant@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="common.js"></script>
</head>
<!--
Marked as tentative until https://github.com/whatwg/html/pull/3752 is landed.
-->
<script>
const below_viewport_iframe = new ElementLoadPromise("below_viewport_iframe");
const below_viewport_img = new ElementLoadPromise("below_viewport_img");
// Change the base URL and scroll down to load the deferred elements.
window.addEventListener("load", () => {
window.history.pushState(1, document.title, '/invalid-url-where-no-subresources-exist/')
below_viewport_iframe.element().scrollIntoView();
});
async_test(function(t) {
below_viewport_iframe.promise.then(
t.step_func_done(function() {
assert_true(below_viewport_iframe.element().contentDocument.body.innerHTML.includes("<p>Subframe</p>"));
}));
}, "Test that when deferred iframe is loaded, it uses the base URL computed at parse time.");
async_test(function(t) {
below_viewport_img.promise.then(
t.step_func_done(function() {
assert_true(below_viewport_img.element().complete);
assert_greater_than(below_viewport_img.element().naturalWidth, 0);
})
).catch(t.unreached_func("The image load should not fail, trying to load with invalid base URL."));
}, "Test that when deferred img is loaded, it uses the base URL computed at parse time.");
</script>
<body>
<div style="height:10000px;"></div>
<script>
// Change the base URL so that the iframe makes use of that in its relative
// URL to absolute URL computation at parse time.
window.history.pushState(1, document.title, 'resources/')
</script>
<iframe id="below_viewport_iframe" src="subframe.html" loading="lazy" width="200px" height="100px" onload="below_viewport_iframe.resolve();">
</iframe>
<img id="below_viewport_img" src="image.png" loading="lazy" onload="below_viewport_img.resolve();"
onerror="below_viewport_img.reject();">
</body>