canvas.2d.offscreen.worker.direction.inherit.html (1755B)
1 <!doctype HTML> 2 <html class="reftest-wait"> 3 <meta charset="utf-8"> 4 <title>HTML5 Canvas Test: The direction attribute is inherited in offscreen worker canvas</title> 5 <link rel="match" href="canvas.2d.offscreen.worker.direction-ref.html" /> 6 <link rel="author" href="mailto:schenney@chromium.org"/> 7 <link rel="help" href="https://html.spec.whatwg.org/multipage/canvas.html#text-styles"/> 8 <meta name="assert" content="An offscreen canvas in a worker inherits the direction text attribute." /> 9 <script src="/common/reftest-wait.js"></script> 10 <script type="text/javascript"> 11 function runTest() { 12 const placeholder_canvas = document.createElement('canvas'); 13 placeholder_canvas.setAttribute('width', '300'); 14 placeholder_canvas.setAttribute('height', '150'); 15 placeholder_canvas.setAttribute('dir', 'rtl'); 16 const offscreen = placeholder_canvas.transferControlToOffscreen(); 17 18 const worker = new Worker('text-direction-worker-inherit.js'); 19 worker.postMessage({canvas: offscreen}, [offscreen]); 20 21 const canvas = document.getElementById('canvas1'); 22 const ctx = canvas.getContext('2d', {willReadFrequently: true}); 23 function checkResult() { 24 // Wait until frame propagates. 25 ctx.drawImage(placeholder_canvas, 0, 0); 26 const pixel = ctx.getImageData(0, 0, 1, 1).data; 27 28 if (pixel[3] == 0) { 29 // Result not available, wait longer. 30 requestAnimationFrame(checkResult); 31 } else { 32 takeScreenshot(); 33 } 34 } 35 requestAnimationFrame(checkResult); 36 } 37 </script> 38 <body onload="runTest()"> 39 <canvas id="canvas1" width="300" height="150"> 40 Browser does not support HTML5 Canvas. 41 </canvas> 42 </body> 43 </html>