dynamic-import.https.html (1040B)
1 <!DOCTYPE html> 2 <html class="reftest-wait"> 3 <link rel="help" href="https://html.spec.whatwg.org/#hostimportmoduledynamically(referencingscriptormodule,-specifier,-promisecapability)"> 4 <link rel="match" href="dynamic-import-ref.html"> 5 <style> 6 #output { 7 width: 100px; 8 height: 100px; 9 background-image: paint(rects); 10 background-color: blue; 11 } 12 </style> 13 <script src="/common/reftest-wait.js"></script> 14 <script src="/common/worklet-reftest.js"></script> 15 <body> 16 <div id="output"></div> 17 18 <script id="code" type="text/worklet"> 19 registerPaint('rects', class { 20 async paint(ctx, geom) { 21 ctx.fillStyle = 'red'; 22 try { 23 await import('./resources/imported-module.mjs'); 24 } catch (e) { 25 if (e.constructor === TypeError) { 26 ctx.fillStyle = 'green'; 27 } 28 } 29 ctx.fillRect(0, 0, geom.width, geom.height); 30 } 31 }); 32 </script> 33 34 <script> 35 "use strict"; 36 importWorkletAndTerminateTestAfterAsyncPaint(CSS.paintWorklet, document.getElementById('code').textContent); 37 </script>