| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <script src="../resources/run-after-layout-and-paint.js"></script> | |
| 5 <style> | |
| 6 #output { | |
| 7 width: 100px; | |
| 8 height: 100px; | |
| 9 background-color: red; | |
| 10 } | |
| 11 </style> | |
| 12 </head> | |
| 13 <body> | |
| 14 <div id="output"></div> | |
| 15 | |
| 16 <script id="code" type="text/worklet"> | |
| 17 registerPaint('green', class { | |
| 18 paint(ctx, geom) { | |
| 19 ctx.fillStyle = 'green'; | |
| 20 ctx.fillRect(0, 0, geom.width, geom.height); | |
| 21 } | |
| 22 }); | |
| 23 </script> | |
| 24 | |
| 25 <script> | |
| 26 if (window.testRunner) { | |
| 27 testRunner.waitUntilDone(); | |
| 28 } | |
| 29 | |
| 30 var blob = new Blob([document.getElementById('code').textContent], | |
| 31 {type: 'text/javascript'}); | |
| 32 paintWorklet.addModule(URL.createObjectURL(blob)).then(function() { | |
| 33 var el = document.getElementById('output'); | |
| 34 el.style.backgroundImage = 'paint(green)'; | |
| 35 runAfterLayoutAndPaint(function() { | |
| 36 if (window.testRunner) { | |
| 37 testRunner.notifyDone(); | |
| 38 } | |
| 39 }); | |
| 40 }); | |
| 41 </script> | |
| 42 </body> | |
| 43 </html> | |
| OLD | NEW |