3 <title>Canvas Hit Regions: accessibility test</title>
4 <script src="../../resources/js-test.js"></script>
8 <button id="button1"></button>
10 <button id="button2"></button>
11 <button id="button3"></button>
15 <button id="button4"></button>
16 <button id="button5"></button>
18 <button id="button6"></button>
23 var canvas = document.getElementById("canvas");
24 var context = canvas.getContext("2d");
26 function drawRectAndAddHitRegion(control, x, y, width, height) {
27 if (window.accessibilityController)
28 window["ax" + control] = accessibilityController.accessibleElementById(control);
31 context.rect(x, y, width, height);
33 context.addHitRegion({
35 control : document.getElementById(control)
39 function testAccessibilityRect(control, x, y, width, height) {
41 if (window.accessibilityController && !window["ax" + control])
42 window["ax" + control] = accessibilityController.accessibleElementById(control);
44 shouldBe("ax" + control + ".x", x.toString());
45 shouldBe("ax" + control + ".y", y.toString());
46 shouldBe("ax" + control + ".width", width.toString());
47 shouldBe("ax" + control + ".height", height.toString());
50 drawRectAndAddHitRegion("button1", 0, 0, 200, 200);
51 drawRectAndAddHitRegion("button2", 0, 0, 100, 50);
52 drawRectAndAddHitRegion("button3", 40, 20, 50, 70);
53 drawRectAndAddHitRegion("button4", 0, 0, 100, 50);
54 drawRectAndAddHitRegion("button5", 40, 20, 50, 70);
55 drawRectAndAddHitRegion("button6", 20, 10, 140, 30);
56 drawRectAndAddHitRegion("button7", 0, 0, 200, 200);
58 debug("Just one button tests.");
59 testAccessibilityRect("button1", 8, 8, 200, 200);
62 debug("The container1 has two buttons.");
63 testAccessibilityRect("button2", 8, 8, 100, 50);
64 testAccessibilityRect("button3", 48, 28, 50, 70);
65 testAccessibilityRect("container1", 8, 8, 100, 90);
68 debug("Remove the button2 from the container1.");
69 document.getElementById("container1").removeChild(document.getElementById("button2"));
70 testAccessibilityRect("container1", 48, 28, 50, 70);
73 debug("Depth-two container tests.");
74 testAccessibilityRect("button4", 8, 8, 100, 50);
75 testAccessibilityRect("button5", 48, 28, 50, 70);
76 testAccessibilityRect("button6", 28, 18, 140, 30);
77 testAccessibilityRect("container2", 8, 8, 160, 90);
78 testAccessibilityRect("container3", 8, 8, 100, 90);