tor-browser

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

2d.path.isPointInPath.basic.html (2382B)


      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.path.isPointInPath.basic</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.path.isPointInPath.basic</h1>
     10 <p class="desc">Verify the winding rule in isPointInPath works for for rect path.</p>
     11 
     12 
     13 <script>
     14 var t = async_test("Verify the winding rule in isPointInPath works for for rect path.");
     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  canvas.width = 200;
     25  canvas.height = 200;
     26 
     27  // Testing default isPointInPath
     28  ctx.beginPath();
     29  ctx.rect(0, 0, 100, 100);
     30  ctx.rect(25, 25, 50, 50);
     31  _assertSame(ctx.isPointInPath(50, 50), true, "ctx.isPointInPath(50, 50)", "true");
     32  _assertSame(ctx.isPointInPath(NaN, 50), false, "ctx.isPointInPath(NaN, 50)", "false");
     33  _assertSame(ctx.isPointInPath(50, NaN), false, "ctx.isPointInPath(50, NaN)", "false");
     34 
     35  // Testing nonzero isPointInPath
     36  ctx.beginPath();
     37  ctx.rect(0, 0, 100, 100);
     38  ctx.rect(25, 25, 50, 50);
     39  _assertSame(ctx.isPointInPath(50, 50, 'nonzero'), true, "ctx.isPointInPath(50, 50, 'nonzero')", "true");
     40 
     41  // Testing evenodd isPointInPath
     42  ctx.beginPath();
     43  ctx.rect(0, 0, 100, 100);
     44  ctx.rect(25, 25, 50, 50);
     45  _assertSame(ctx.isPointInPath(50, 50, 'evenodd'), false, "ctx.isPointInPath(50, 50, 'evenodd')", "false");
     46 
     47  // Testing extremely large scale
     48  ctx.save();
     49  ctx.scale(Number.MAX_VALUE, Number.MAX_VALUE);
     50  ctx.beginPath();
     51  ctx.rect(-10, -10, 20, 20);
     52  _assertSame(ctx.isPointInPath(0, 0, 'nonzero'), true, "ctx.isPointInPath(0, 0, 'nonzero')", "true");
     53  _assertSame(ctx.isPointInPath(0, 0, 'evenodd'), true, "ctx.isPointInPath(0, 0, 'evenodd')", "true");
     54  ctx.restore();
     55 
     56  // Check with non-invertible ctm.
     57  ctx.save();
     58  ctx.scale(0, 0);
     59  ctx.beginPath();
     60  ctx.rect(-10, -10, 20, 20);
     61  _assertSame(ctx.isPointInPath(0, 0, 'nonzero'), false, "ctx.isPointInPath(0, 0, 'nonzero')", "false");
     62  _assertSame(ctx.isPointInPath(0, 0, 'evenodd'), false, "ctx.isPointInPath(0, 0, 'evenodd')", "false");
     63  ctx.restore();
     64  t.done();
     65 
     66 });
     67 </script>