test_img_src_causing_reflow.html (1158B)
1 <!doctype html> 2 <meta charset="utf-8"> 3 <title>Test for bug 1787072</title> 4 <script src="/tests/SimpleTest/SimpleTest.js"></script> 5 <style> 6 img { 7 width: 100px; 8 height: 100px; 9 background-color: blue; 10 } 11 </style> 12 <img> <!-- Initially broken --> 13 <script> 14 add_task(async function() { 15 const utils = SpecialPowers.DOMWindowUtils; 16 const img = document.querySelector("img"); 17 img.getBoundingClientRect(); 18 19 let origFramesConstructed = utils.framesConstructed; 20 let origFramesReflowed = utils.framesReflowed; 21 22 let error = new Promise(r => img.addEventListener("error", r, { once: true })); 23 24 // Doesn't need to be an actual image. 25 img.src = "/some-valid-url"; 26 27 img.getBoundingClientRect(); 28 is(origFramesReflowed, utils.framesReflowed, "Shouldn't have reflowed when going broken -> loading"); 29 is(origFramesConstructed, utils.framesConstructed, "Shouldn't have reflowed when going broken -> loading"); 30 31 await error; 32 33 is(origFramesReflowed, utils.framesReflowed, "Shouldn't have reflowed when going loading -> broken"); 34 is(origFramesConstructed, utils.framesConstructed, "Shouldn't have reflowed when going loading -> broken"); 35 }); 36 </script>