4 <title>Canvas Hit Regions: fillRule test
</title>
5 <script src=
"../../resources/js-test.js"></script>
8 <canvas id=
"canvas" width=
"400" height=
"400">
10 <script src=
"./resources/canvas-hit-region-event.js"></script>
13 var canvas
= document
.getElementById("canvas");
14 var context
= canvas
.getContext("2d");
16 context
.rect(20, 20, 60, 60);
17 context
.rect(0, 0, 100, 100);
18 context
.addHitRegion({
23 debug("default fillRule(nonzero):");
24 shouldBe("clickCanvas(1, 1)", "'nonzero'");
25 shouldBe("clickCanvas(99, 98)", "'nonzero'");
26 shouldBe("clickCanvas(21, 21)", "'nonzero'");
27 shouldBe("clickCanvas(50, 50)", "'nonzero'");
30 context
.removeHitRegion("nonzero");
32 context
.addHitRegion({
37 debug("fillRule = evenodd:");
38 shouldBe("clickCanvas(1, 1)", "'evenodd'");
39 shouldBe("clickCanvas(99, 98)", "'evenodd'");
40 shouldBe("clickCanvas(21, 21)", "null");
41 shouldBe("clickCanvas(50, 50)", "null");
44 context
.removeHitRegion("evenodd");
46 context
.addHitRegion({
51 debug("fillRule = nonzero:");
52 shouldBe("clickCanvas(1, 1)", "'nonzero'");
53 shouldBe("clickCanvas(99, 98)", "'nonzero'");
54 shouldBe("clickCanvas(21, 21)", "'nonzero'");
55 shouldBe("clickCanvas(50, 50)", "'nonzero'");
58 context
.removeHitRegion("nonzero");
60 shouldThrow('context.addHitRegion({id : "nonzero", fillRule : null });');
62 context
.addHitRegion({
67 debug("fillRule = undefined, falls back to default (nonzero):");
68 shouldBe("clickCanvas(1, 1)", "'nonzero'");
69 shouldBe("clickCanvas(99, 98)", "'nonzero'");
70 shouldBe("clickCanvas(21, 21)", "'nonzero'");
71 shouldBe("clickCanvas(50, 50)", "'nonzero'");