Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 3 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /html/semantics/embedded-content/the-video-element/video-loading-lazy-below-viewport-load-event.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>Below-viewport loading=lazy videos do not delay the window load event</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<div style="height: 1000vh"></div>
<!-- The attribute order matters: the parser appends attributes one at a time,
and appending src starts the resource selection algorithm. -->
<video id="loading-before-src" loading="lazy" src="/media/A4.webm?loading-before-src"></video>
<video id="src-before-loading" src="/media/A4.webm?src-before-loading" loading="lazy"></video>
<script>
const scripted = document.createElement("video");
scripted.id = "src-before-loading-scripted";
scripted.src = "/media/A4.webm?src-before-loading-scripted";
scripted.loading = "lazy";
document.body.append(scripted);
const readyStatesAtLoad = new Promise(resolve => {
window.addEventListener("load", () => {
resolve(new Map([...document.querySelectorAll("video")]
.map(video => [video.id, video.readyState])));
});
});
for (const id of ["loading-before-src", "src-before-loading", "src-before-loading-scripted"]) {
promise_test(async () => {
const readyStates = await readyStatesAtLoad;
assert_equals(readyStates.get(id), HTMLMediaElement.HAVE_NOTHING);
}, `${id} has not fetched anything when the load event fires`);
}
</script>