tor-browser

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

2d.line.width.transformed.worker.js (1915B)


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