tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

2d.text.draw.fontface.repeat.worker.js (1187B)


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