Skip to content

Commit 4ee848f

Browse files
emiliomoz-wptsync-bot
authored andcommitted
Don't give images with empty alt an intrinsic ratio.
The spec seems to want us to treat it like an inline, but that's not what other browsers do (I added tests for this in bug 1196668, and they still pass in all engines). This is an oddly specific condition to put in nsImageFrame::ShouldShowBrokenImageIcon(), but oh well, we're past all sanity here I think... Differential Revision: https://phabricator.services.mozilla.com/D63715 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1616537 gecko-commit: 76472c6d442738730a601ecf22d6cd83e570cae2 gecko-integration-branch: autoland gecko-reviewers: bzbarsky
1 parent 0ac5dc3 commit 4ee848f

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!doctype html>
2+
<title>Images with an empty alt attribute have an intrinsic size of zero</title>
3+
<script src="/resources/testharness.js"></script>
4+
<script src="/resources/testharnessreport.js"></script>
5+
<style>
6+
img {
7+
width: 50px;
8+
height: auto;
9+
}
10+
</style>
11+
<img src="broken">
12+
<img src="broken" alt="non-empty">
13+
<img src="broken" alt="">
14+
<script>
15+
const t = async_test("Images with an empty alt attribute have an intrinsic size of zero");
16+
onload = t.step_func_done(function() {
17+
for (const img of document.querySelectorAll("img")) {
18+
const alt = img.getAttribute("alt");
19+
const shouldTakeUpSpace = alt == null || alt.length > 0;
20+
(shouldTakeUpSpace ? assert_not_equals : assert_equals)(img.offsetHeight, 0, img.outerHTML);
21+
}
22+
});
23+
</script>

0 commit comments

Comments
 (0)