accessible/tests/mochitest/elm/test_canvas.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial