|
1 <!DOCTYPE html> |
|
2 <html> |
|
3 <head> |
|
4 <title>Accessible boundaries for hit regions</title> |
|
5 <link rel="stylesheet" type="text/css" |
|
6 href="chrome://mochikit/content/tests/SimpleTest/test.css" /> |
|
7 |
|
8 <script type="application/javascript" |
|
9 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
10 <script type="application/javascript" |
|
11 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
|
12 |
|
13 <script type="application/javascript" |
|
14 src="../common.js"></script> |
|
15 <script type="application/javascript" |
|
16 src="../role.js"></script> |
|
17 <script type="application/javascript" |
|
18 src="../layout.js"></script> |
|
19 |
|
20 <script type="application/javascript"> |
|
21 SpecialPowers.setBoolPref("canvas.hitregions.enabled", true); |
|
22 |
|
23 function doTest() |
|
24 { |
|
25 var canv = document.getElementById("c"); |
|
26 var context = canv.getContext('2d'); |
|
27 var element = document.getElementById("showA"); |
|
28 context.beginPath(); |
|
29 context.rect(10, 10, 150, 100); |
|
30 context.addHitRegion({control: element}); |
|
31 var input = getAccessible("showA"); |
|
32 var input = getAccessible("showA"); |
|
33 var [cnvX, cnvY, cnvWidth, cnvHeight] = getBoundsForDOMElm(canv); |
|
34 var [accX, accY, accWidth, accHeight] = getBounds(input); |
|
35 is(accX, cnvX + 10, "accX should be 10 and not " + accX); |
|
36 is(accY, cnvY + 10, "accY should be 10 and not " + accY); |
|
37 is(accWidth, 150, "accWidth should be 150 and not " + accWidth); |
|
38 is(accHeight, 100, "accHeight should be 100 and not " + accHeight); |
|
39 |
|
40 SpecialPowers.setBoolPref("canvas.hitregions.enabled", false); |
|
41 SimpleTest.finish(); |
|
42 } |
|
43 |
|
44 SimpleTest.waitForExplicitFinish(); |
|
45 addA11yLoadEvent(doTest); |
|
46 </script> |
|
47 </head> |
|
48 <body> |
|
49 |
|
50 <canvas id="c"> |
|
51 <input id="showA" type="checkbox"><label for="showA"> Show As </label> |
|
52 </canvas> |
|
53 |
|
54 </body> |
|
55 </html> |