4 <title>Test click events on canvas hit regions
</title>
5 <script type=
"application/javascript" src=
"/tests/SimpleTest/SimpleTest.js"></script>
6 <script type=
"text/javascript" src=
"/tests/SimpleTest/EventUtils.js"></script>
7 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
14 <div id=
"content" style=
"display: none">
18 <script type=
"application/javascript">
19 SpecialPowers.pushPrefEnv({
"set": [[
"canvas.hitregions.enabled", true]]}, function() {
21 var input = document.getElementById(
"input");
23 input.addEventListener('mousedown', function(evt){
24 regionId = evt.region;
30 var ctx = input.getContext(
"2d");
32 ctx.rect(
20,
20,
100,
75);
34 ctx.addHitRegion({id:
"a"});
36 ctx.fillStyle =
"red";
37 ctx.rect(
60,
40,
100,
75);
39 ctx.addHitRegion({id:
"b"});
41 ctx.fillStyle =
"yellow";
42 ctx.rect(
80,
60,
10,
10);
44 ctx.addHitRegion({id:
"c"});
46 synthesizeMouse(input,
25,
25, {type:
"mousedown"});
47 is(regionId,
"a",
"Hit region a",
". Found: " + regionId);
49 synthesizeMouse(input,
5,
5, {type:
"mousedown", button:
1});
50 is(regionId,
"",
"Hit region null",
". Found: " + regionId);
52 synthesizeMouse(input,
65,
45, {type:
"mousedown"});
53 is(regionId,
"b",
"Hit region b",
". Found: " + regionId);
55 synthesizeMouse(input,
85,
65, {type:
"mousedown"});
56 is(regionId,
"c",
"Hit region c",
". Found: " + regionId);
58 ctx.removeHitRegion(
"c");
59 synthesizeMouse(input,
85,
65, {type:
"mousedown"});
60 is(regionId,
"b",
"Hit region b",
". Found: " + regionId);
62 ok(false,
"unexpected exception thrown: " + e);
71 SimpleTest.waitForExplicitFinish();