tor-browser

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

2d.imageData.get.rounding.html (1419B)


      1 <!DOCTYPE html>
      2 <!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
      3 <meta charset="UTF-8">
      4 <title>OffscreenCanvas test: 2d.imageData.get.rounding</title>
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <script src="/html/canvas/resources/canvas-tests.js"></script>
      8 
      9 <h1>2d.imageData.get.rounding</h1>
     10 <p class="desc">Test the handling of non-integer source coordinates in getImageData().</p>
     11 
     12 
     13 <script>
     14 var t = async_test("Test the handling of non-integer source coordinates in getImageData().");
     15 var t_pass = t.done.bind(t);
     16 var t_fail = t.step_func(function(reason) {
     17    throw reason;
     18 });
     19 t.step(function() {
     20 
     21  var canvas = new OffscreenCanvas(100, 50);
     22  var ctx = canvas.getContext('2d');
     23 
     24  function testDimensions(sx, sy, sw, sh, width, height)
     25  {
     26      imageData = ctx.getImageData(sx, sy, sw, sh);
     27      _assert(imageData.width == width, "imageData.width == width");
     28      _assert(imageData.height == height, "imageData.height == height");
     29  }
     30 
     31  testDimensions(0, 0, 20, 10, 20, 10);
     32 
     33  testDimensions(.1, .2, 20, 10, 20, 10);
     34  testDimensions(.9, .8, 20, 10, 20, 10);
     35 
     36  testDimensions(0, 0, 20.9, 10.9, 20, 10);
     37  testDimensions(0, 0, 20.1, 10.1, 20, 10);
     38 
     39  testDimensions(-1, -1, 20, 10, 20, 10);
     40 
     41  testDimensions(-1.1, 0, 20, 10, 20, 10);
     42  testDimensions(-1.9,  0, 20, 10, 20, 10);
     43  t.done();
     44 
     45 });
     46 </script>