foreignObject-img.html (756B)
1 <!DOCTYPE html> 2 <html class="reftest-wait"> 3 <style> 4 img { position: absolute; top: 0; left: 0; } 5 </style> 6 <img src="foreignObject-img-helper.svg"> 7 <script> 8 9 // The load of the data: URL inside foreignObject-img-helper.svg does not block 10 // the load event of the <img> in this document, so we loop, painting the image 11 // to a canvas, to tell when it's ready. (So if this test fails, it will fail 12 // by timing out.) 13 14 var img = document.querySelector("img"); 15 var canvas = document.createElement("canvas"); 16 var ctx = canvas.getContext("2d"); 17 18 function paint() { 19 ctx.drawImage(img, 0, 0); 20 if (ctx.getImageData(0, 0, 1, 1).data[1] == 255) { 21 document.documentElement.className = ""; 22 } else { 23 requestAnimationFrame(paint); 24 } 25 } 26 27 paint(); 28 29 </script>