unclosed-layers.html (974B)
1 <!DOCTYPE html> 2 <html class="reftest-wait"> 3 <link rel="match" href="unclosed-layers-expected.html"> 4 <title>Canvas test: unclosed-layers</title> 5 <h1>unclosed-layers</h1> 6 <p class="desc">Check that unclosed layers aren't rendered.</p> 7 <canvas id="canvas" width="1" height="1"> 8 <p class="fallback">FAIL (fallback content)</p> 9 </canvas> 10 <script> 11 var placeholder = document.getElementById('canvas'); 12 var offscreen = placeholder.transferControlToOffscreen(); 13 const ctx = offscreen.getContext('2d'); 14 offscreen.width = offscreen.height = 200; 15 16 ctx.fillStyle = 'purple'; 17 ctx.fillRect(60, 60, 75, 50); 18 19 ctx.beginLayer(); 20 ctx.fillRect(40, 40, 75, 50); 21 ctx.fillStyle = 'grey'; 22 ctx.fillRect(50, 50, 75, 50); 23 24 function draw () { 25 // Wait until frame propagates. 26 if(placeholder.width != 200) { 27 requestAnimationFrame(draw); 28 } else { 29 document.documentElement.classList.remove("reftest-wait"); 30 } 31 } 32 requestAnimationFrame(draw); 33 </script>