diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index 82d421475fcd..2e1509b42731 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -180,6 +180,15 @@ bool nsImageFrame::ShouldShowBrokenImageIcon() const { return false; } + // is special, and it shouldn't draw the broken image icon, + // unlike the no-alt attribute or non-empty-alt-attribute case. + if (auto* image = HTMLImageElement::FromNode(mContent)) { + const nsAttrValue* alt = image->GetParsedAttr(nsGkAtoms::alt); + if (alt && alt->IsEmptyString()) { + return false; + } + } + // check for broken images. valid null images (eg. img src="") are // not considered broken because they have no image requests if (nsCOMPtr currentRequest = GetCurrentRequest()) { diff --git a/testing/web-platform/tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-empty-alt-replaced.html b/testing/web-platform/tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-empty-alt-replaced.html new file mode 100644 index 000000000000..3cc06d6c8538 --- /dev/null +++ b/testing/web-platform/tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-empty-alt-replaced.html @@ -0,0 +1,23 @@ + +Images with an empty alt attribute have an intrinsic size of zero + + + + +non-empty + +