empty-src-no-current-request.html (1704B)
1 <!doctype html> 2 <meta charset="utf-8"> 3 <title>src = "" doesn't trigger a sync load if there's no existing current request</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1905646"> 7 <script> 8 promise_test(async function(t) { 9 let img = new Image(); 10 img.src = ""; 11 img.loading = "lazy"; 12 img.onload = t.unreached_func("should not trigger a load event"); 13 img.onerror = t.unreached_func("should not trigger an error event"); 14 // Shouldn't fire any event since it's in the lazy state. 15 await new Promise(r => t.step_timeout(r, 0)); 16 await new Promise(r => t.step_timeout(r, 0)); 17 18 // We're about to append it to the document, which should trigger the (lazy) load (and in this case error event). 19 let error = new Promise(r => { 20 img.onerror = r; 21 }); 22 document.documentElement.appendChild(img); 23 await error; 24 }, "Without srcset"); 25 26 promise_test(async function(t) { 27 let img = new Image(); 28 img.src = ""; 29 img.srcset = "/images/green.png"; 30 img.loading = "lazy"; 31 img.onload = t.unreached_func("should not trigger a load event"); 32 img.onerror = t.unreached_func("should not trigger an error event"); 33 // Shouldn't fire any event since it's in the lazy state. 34 await new Promise(r => t.step_timeout(r, 0)); 35 await new Promise(r => t.step_timeout(r, 0)); 36 37 // We're about to append it to the document, which should trigger the (lazy) load. 38 let load = new Promise(r => { 39 img.onload = r; 40 }); 41 42 document.documentElement.appendChild(img); 43 await load; 44 }, "With srcset"); 45 </script>