tor-browser

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

2d.imageData.get.rounding.worker.js (1261B)


      1 // DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
      2 // OffscreenCanvas test in a worker:2d.imageData.get.rounding
      3 // Description:Test the handling of non-integer source coordinates in getImageData().
      4 // Note:
      5 
      6 importScripts("/resources/testharness.js");
      7 importScripts("/html/canvas/resources/canvas-tests.js");
      8 
      9 var t = async_test("Test the handling of non-integer source coordinates in getImageData().");
     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  function testDimensions(sx, sy, sw, sh, width, height)
     20  {
     21      imageData = ctx.getImageData(sx, sy, sw, sh);
     22      _assert(imageData.width == width, "imageData.width == width");
     23      _assert(imageData.height == height, "imageData.height == height");
     24  }
     25 
     26  testDimensions(0, 0, 20, 10, 20, 10);
     27 
     28  testDimensions(.1, .2, 20, 10, 20, 10);
     29  testDimensions(.9, .8, 20, 10, 20, 10);
     30 
     31  testDimensions(0, 0, 20.9, 10.9, 20, 10);
     32  testDimensions(0, 0, 20.1, 10.1, 20, 10);
     33 
     34  testDimensions(-1, -1, 20, 10, 20, 10);
     35 
     36  testDimensions(-1.1, 0, 20, 10, 20, 10);
     37  testDimensions(-1.9,  0, 20, 10, 20, 10);
     38  t.done();
     39 });
     40 done();