Reject decode when src and srcset are missing

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>
This commit is contained in:
Bentaimia Haddadi 2024-06-09 22:36:11 +02:00
parent aae04c6699
commit c117c01b0e

View file

@ -1173,6 +1173,7 @@ impl HTMLImageElement {
// Step 2 for <https://html.spec.whatwg.org/multipage/#dom-img-decode> // Step 2 for <https://html.spec.whatwg.org/multipage/#dom-img-decode>
fn react_to_decode_image_sync_steps(&self) { fn react_to_decode_image_sync_steps(&self) {
let document = document_from_node(self); let document = document_from_node(self);
let elem = self.upcast::<Element>();
// Step 2.1 of <https://html.spec.whatwg.org/multipage/#dom-img-decode> // Step 2.1 of <https://html.spec.whatwg.org/multipage/#dom-img-decode>
if !document.is_fully_active() || if !document.is_fully_active() ||
matches!(self.current_request.borrow().state, State::Broken) matches!(self.current_request.borrow().state, State::Broken)
@ -1183,6 +1184,10 @@ impl HTMLImageElement {
State::CompletelyAvailable State::CompletelyAvailable
) { ) {
self.resolve_image_decode_promises(); self.resolve_image_decode_promises();
} else if !elem.has_attribute(&local_name!("src")) &&
!elem.has_attribute(&local_name!("srcset"))
{
self.reject_image_decode_promises();
} }
} }