tor-browser

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

2d.line.width.basic.worker.js (1779B)


      1 // DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
      2 // OffscreenCanvas test in a worker:2d.line.width.basic
      3 // Description:lineWidth determines the width of line strokes
      4 // Note:
      5 
      6 importScripts("/resources/testharness.js");
      7 importScripts("/html/canvas/resources/canvas-tests.js");
      8 
      9 var t = async_test("lineWidth determines the width of line strokes");
     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  ctx.lineWidth = 20;
     23  // Draw a green line over a red box, to check the line is not too small
     24  ctx.fillStyle = '#f00';
     25  ctx.strokeStyle = '#0f0';
     26  ctx.fillRect(15, 15, 20, 20);
     27  ctx.beginPath();
     28  ctx.moveTo(25, 15);
     29  ctx.lineTo(25, 35);
     30  ctx.stroke();
     31 
     32  // Draw a green box over a red line, to check the line is not too large
     33  ctx.fillStyle = '#0f0';
     34  ctx.strokeStyle = '#f00';
     35  ctx.beginPath();
     36  ctx.moveTo(75, 15);
     37  ctx.lineTo(75, 35);
     38  ctx.stroke();
     39  ctx.fillRect(65, 15, 20, 20);
     40 
     41  _assertPixel(canvas, 14,25, 0,255,0,255);
     42  _assertPixel(canvas, 15,25, 0,255,0,255);
     43  _assertPixel(canvas, 16,25, 0,255,0,255);
     44  _assertPixel(canvas, 25,25, 0,255,0,255);
     45  _assertPixel(canvas, 34,25, 0,255,0,255);
     46  _assertPixel(canvas, 35,25, 0,255,0,255);
     47  _assertPixel(canvas, 36,25, 0,255,0,255);
     48 
     49  _assertPixel(canvas, 64,25, 0,255,0,255);
     50  _assertPixel(canvas, 65,25, 0,255,0,255);
     51  _assertPixel(canvas, 66,25, 0,255,0,255);
     52  _assertPixel(canvas, 75,25, 0,255,0,255);
     53  _assertPixel(canvas, 84,25, 0,255,0,255);
     54  _assertPixel(canvas, 85,25, 0,255,0,255);
     55  _assertPixel(canvas, 86,25, 0,255,0,255);
     56  t.done();
     57 });
     58 done();