Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/canvas/offscreen/path-objects/2d.path.isPointInPath.nobitmap.transform.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
<meta charset="UTF-8">
<title>OffscreenCanvas test: 2d.path.isPointInPath.nobitmap.transform</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/html/canvas/resources/canvas-tests.js"></script>
<h1>2d.path.isPointInPath.nobitmap.transform</h1>
<p class="desc">The transformation matrix mutators apply on a canvas with no bitmap</p>
<script>
var t = async_test("The transformation matrix mutators apply on a canvas with no bitmap");
var t_pass = t.done.bind(t);
var t_fail = t.step_func(function(reason) {
throw reason;
});
t.step(function() {
var canvas = new OffscreenCanvas(0, 0);
var ctx = canvas.getContext('2d');
ctx.translate(50, 0);
ctx.rect(0, 0, 20, 20);
_assertSame(ctx.isPointInPath(60, 10), true, "ctx.isPointInPath(60, 10)", "true");
_assertSame(ctx.isPointInPath(10, 10), false, "ctx.isPointInPath(10, 10)", "false");
ctx.resetTransform();
_assertSame(ctx.getTransform().e, 0, "ctx.getTransform().e", "0");
ctx.beginPath();
ctx.scale(2, 2);
ctx.rect(0, 0, 20, 20);
_assertSame(ctx.isPointInPath(30, 30), true, "ctx.isPointInPath(30, 30)", "true");
_assertSame(ctx.isPointInPath(50, 50), false, "ctx.isPointInPath(50, 50)", "false");
ctx.setTransform(1, 0, 0, 1, 0, 50);
_assertSame(ctx.getTransform().f, 50, "ctx.getTransform().f", "50");
ctx.beginPath();
ctx.rect(0, 0, 20, 20);
_assertSame(ctx.isPointInPath(10, 60), true, "ctx.isPointInPath(10, 60)", "true");
_assertSame(ctx.isPointInPath(10, 10), false, "ctx.isPointInPath(10, 10)", "false");
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.transform(1, 0, 0, 1, 50, 0);
ctx.beginPath();
ctx.rect(0, 0, 20, 20);
_assertSame(ctx.isPointInPath(60, 10), true, "ctx.isPointInPath(60, 10)", "true");
_assertSame(ctx.isPointInPath(10, 10), false, "ctx.isPointInPath(10, 10)", "false");
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.rotate(Math.PI / 2);
ctx.beginPath();
ctx.rect(10, 10, 20, 20);
_assertSame(ctx.isPointInPath(-20, 20), true, "ctx.isPointInPath(-20, 20)", "true");
_assertSame(ctx.isPointInPath(20, 20), false, "ctx.isPointInPath(20, 20)", "false");
t.done();
});
</script>