parse-input-arguments-005.https.html (1139B)
1 <!DOCTYPE html> 2 <html class="reftest-wait"> 3 <link rel="help" href="https://drafts.css-houdini.org/css-paint-api/"> 4 <link rel="match" href="parse-input-arguments-ref.html"> 5 <style> 6 .container { 7 width: 100px; 8 height: 100px; 9 } 10 11 #canvas-geometry { 12 background-image: paint(geometry); 13 } 14 </style> 15 <script src="/common/reftest-wait.js"></script> 16 <script src="/common/worklet-reftest.js"></script> 17 <body> 18 <div id="canvas-geometry" class="container"></div> 19 20 <script id="code" type="text/worklet"> 21 var testsPassed = false; 22 try { 23 registerPaint('foo', class { paint() { } }); 24 registerPaint('foo', class { paint() { } }); 25 } catch(ex) { 26 // 'foo' gets registered twice. 27 if (ex.name == 'InvalidModificationError') 28 testsPassed = true; 29 } 30 31 registerPaint('geometry', class { 32 paint(ctx, geom) { 33 if (testsPassed) 34 ctx.fillStyle = 'green'; 35 else 36 ctx.fillStyle = 'red'; 37 ctx.fillRect(0, 0, geom.width, geom.height); 38 } 39 }); 40 </script> 41 42 <script> 43 importWorkletAndTerminateTestAfterAsyncPaint(CSS.paintWorklet, document.getElementById('code').textContent); 44 </script> 45 </body> 46 </html>