img-empty-alt-replaced.html (759B)
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>