2d.text.draw.fontface.repeat.html (1357B)
1 <!DOCTYPE html> 2 <!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> 3 <meta charset="UTF-8"> 4 <title>OffscreenCanvas test: 2d.text.draw.fontface.repeat</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="/html/canvas/resources/canvas-tests.js"></script> 8 9 <h1>2d.text.draw.fontface.repeat</h1> 10 <p class="desc">Draw with the font immediately, then wait a bit until and draw again. (This crashes some version of WebKit.)</p> 11 12 13 <script> 14 promise_test(async t => { 15 16 var canvas = new OffscreenCanvas(100, 50); 17 var ctx = canvas.getContext('2d'); 18 19 var f = new FontFace("CanvasTest", "url('/fonts/CanvasTest.ttf')"); 20 f.load(); 21 document.fonts.add(f); 22 await document.fonts.ready; 23 ctx.fillStyle = '#f00'; 24 ctx.fillRect(0, 0, 100, 50); 25 ctx.font = '67px CanvasTest'; 26 ctx.fillStyle = '#0f0'; 27 ctx.fillText('AA', 0, 50); 28 29 await new Promise(resolve => t.step_timeout(resolve, 500)); 30 ctx.fillText('AA', 0, 50); 31 _assertPixelApprox(canvas, 5,5, 0,255,0,255, 2); 32 _assertPixelApprox(canvas, 95,5, 0,255,0,255, 2); 33 _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2); 34 _assertPixelApprox(canvas, 75,25, 0,255,0,255, 2); 35 36 }, "Draw with the font immediately, then wait a bit until and draw again. (This crashes some version of WebKit.)"); 37 </script>