tor-browser

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

2d.line.join.bevel.worker.js (1853B)


      1 // DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
      2 // OffscreenCanvas test in a worker:2d.line.join.bevel
      3 // Description:lineJoin 'bevel' is rendered correctly
      4 // Note:
      5 
      6 importScripts("/resources/testharness.js");
      7 importScripts("/html/canvas/resources/canvas-tests.js");
      8 
      9 var t = async_test("lineJoin 'bevel' is rendered correctly");
     10 var t_pass = t.done.bind(t);
     11 var t_fail = t.step_func(function(reason) {
     12    throw reason;
     13 });
     14 t.step(function() {
     15 
     16  var canvas = new OffscreenCanvas(100, 50);
     17  var ctx = canvas.getContext('2d');
     18 
     19  ctx.fillStyle = '#0f0';
     20  ctx.fillRect(0, 0, 100, 50);
     21 
     22  var tol = 1; // tolerance to avoid antialiasing artifacts
     23 
     24  ctx.lineJoin = 'bevel';
     25  ctx.lineWidth = 20;
     26 
     27  ctx.fillStyle = '#f00';
     28  ctx.strokeStyle = '#0f0';
     29 
     30  ctx.fillRect(10, 10, 20, 20);
     31  ctx.fillRect(20, 20, 20, 20);
     32  ctx.beginPath();
     33  ctx.moveTo(30, 20);
     34  ctx.lineTo(40-tol, 20);
     35  ctx.lineTo(30, 10+tol);
     36  ctx.fill();
     37 
     38  ctx.beginPath();
     39  ctx.moveTo(10, 20);
     40  ctx.lineTo(30, 20);
     41  ctx.lineTo(30, 40);
     42  ctx.stroke();
     43 
     44 
     45  ctx.fillStyle = '#0f0';
     46  ctx.strokeStyle = '#f00';
     47 
     48  ctx.beginPath();
     49  ctx.moveTo(60, 20);
     50  ctx.lineTo(80, 20);
     51  ctx.lineTo(80, 40);
     52  ctx.stroke();
     53 
     54  ctx.fillRect(60, 10, 20, 20);
     55  ctx.fillRect(70, 20, 20, 20);
     56  ctx.beginPath();
     57  ctx.moveTo(80, 20);
     58  ctx.lineTo(90+tol, 20);
     59  ctx.lineTo(80, 10-tol);
     60  ctx.fill();
     61 
     62  _assertPixel(canvas, 34,16, 0,255,0,255);
     63  _assertPixel(canvas, 34,15, 0,255,0,255);
     64  _assertPixel(canvas, 35,15, 0,255,0,255);
     65  _assertPixel(canvas, 36,15, 0,255,0,255);
     66  _assertPixel(canvas, 36,14, 0,255,0,255);
     67 
     68  _assertPixel(canvas, 84,16, 0,255,0,255);
     69  _assertPixel(canvas, 84,15, 0,255,0,255);
     70  _assertPixel(canvas, 85,15, 0,255,0,255);
     71  _assertPixel(canvas, 86,15, 0,255,0,255);
     72  _assertPixel(canvas, 86,14, 0,255,0,255);
     73  t.done();
     74 });
     75 done();