Files
ladybird/Tests/LibWeb/Text/input/HTML/HTMLVideoElement-resize-event-during-playback.html
Zaggy1024 04cc5bced9 LibWeb: Update video elements' natural dimensions during playback
This tightens the implementation of video element sizing to the spec by
implementing two spec concepts:
- The media resource's natural width and height, and
- The video element's natural width and height.
The element's natural dimensions change based on the representation,
which has many inputs, so update checks are triggered from many
locations.

The resize event is fired when the media resource's natural dimensions
change, and the layout is invalidated if the element's natural
dimensions change.

Tests for a few important resize triggers have been added.
2026-04-21 19:11:24 -05:00

35 lines
1.1 KiB
HTML

<!DOCTYPE html>
<script src="../include.js"></script>
<video id="video"></video>
<script>
const video = document.getElementById("video");
function logEvent(name) {
println(`${name}: videoWidth=${video.videoWidth} videoHeight=${video.videoHeight}`);
}
for (const name of ["loadedmetadata", "resize", "ended", "seeked"]) {
video.addEventListener(name, () => logEvent(name));
}
asyncTest(async done => {
video.src = "../../../Assets/resize-320x240-640x480.webm";
await new Promise(resolve => video.addEventListener("loadedmetadata", resolve, { once: true }));
println("--- play ---");
await video.play();
await new Promise(resolve => video.addEventListener("ended", resolve, { once: true }));
println("--- seek to 0 ---");
video.currentTime = 0;
await new Promise(resolve => video.addEventListener("seeked", resolve, { once: true }));
println("--- seek to end ---");
video.currentTime = video.duration;
await new Promise(resolve => video.addEventListener("seeked", resolve, { once: true }));
done();
});
</script>