Use the document encoding when parsing a <video> elements poster URL (#37556)

Testing: Observing the parsed poster URL is not possible by javascript
and would require the server to somehow tell the client which URL was
requested. I don't know how to do that in WPT and I don't think the
effort is worth it.

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
Simon Wülker 2025-06-19 14:41:30 +02:00 committed by GitHub
parent b394727ff6
commit 824755d868
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -174,16 +174,16 @@ impl HTMLVideoElement {
// Step 2. If the poster attribute's value is the empty string or
// if the attribute is absent, then there is no poster frame; return.
if poster_url.is_none_or(|url| url.is_empty()) {
let Some(poster_url) = poster_url.filter(|poster_url| !poster_url.is_empty()) else {
self.htmlmediaelement.set_poster_frame(None);
return;
}
};
// Step 3. Let url be the result of encoding-parsing a URL given
// the poster attribute's value, relative to the element's node
// document.
// Step 4. If url is failure, then return. There is no poster frame.
let poster_url = match self.owner_document().url().join(poster_url.unwrap()) {
let poster_url = match self.owner_document().encoding_parse_a_url(poster_url) {
Ok(url) => url,
Err(_) => {
self.htmlmediaelement.set_poster_frame(None);