summaryrefslogtreecommitdiffstats
path: root/accessible/tests/mochitest/hittest/test_canvas_hitregion.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /accessible/tests/mochitest/hittest/test_canvas_hitregion.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'accessible/tests/mochitest/hittest/test_canvas_hitregion.html')
-rw-r--r--accessible/tests/mochitest/hittest/test_canvas_hitregion.html88
1 files changed, 88 insertions, 0 deletions
diff --git a/accessible/tests/mochitest/hittest/test_canvas_hitregion.html b/accessible/tests/mochitest/hittest/test_canvas_hitregion.html
new file mode 100644
index 000000000..fc1df3d60
--- /dev/null
+++ b/accessible/tests/mochitest/hittest/test_canvas_hitregion.html
@@ -0,0 +1,88 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>nsIAccessible::childAtPoint() for canvas from browser tests</title>
+ <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
+
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <script type="application/javascript"
+ src="../common.js"></script>
+ <script type="application/javascript"
+ src="../layout.js"></script>
+
+ <script type="application/javascript">
+ function redrawCheckbox(context, element, x, y)
+ {
+ context.save();
+ context.font = '10px sans-serif';
+ context.textAlign = 'left';
+ context.textBaseline = 'middle';
+ var metrics = context.measureText(element.parentNode.textContent);
+ context.beginPath();
+ context.strokeStyle = 'black';
+ context.rect(x-5, y-5, 10, 10);
+ context.stroke();
+ if (element.checked) {
+ context.fillStyle = 'black';
+ context.fill();
+ }
+ context.fillText(element.parentNode.textContent, x+5, y);
+
+ context.beginPath();
+ context.rect(x-7, y-7, 12 + metrics.width+2, 14);
+
+ if (document.activeElement == element)
+ context.drawFocusIfNeeded(element);
+ context.addHitRegion({control: element});
+ context.restore();
+ }
+
+ function doTest()
+ {
+ var offsetX = 20, offsetY = 40;
+ getNode("hitcanvas").scrollIntoView(true);
+
+ var context = document.getElementById("hitcanvas").getContext('2d');
+ redrawCheckbox(context, document.getElementById('hitcheck'),
+ offsetX, offsetY);
+
+ var hitcanvas = getAccessible("hitcanvas");
+ var hitcheck = getAccessible("hitcheck");
+
+ var [hitX, hitY, hitWidth, hitHeight] = getBounds(hitcanvas);
+ var [deltaX, deltaY] = CSSToDevicePixels(window, offsetX, offsetY);
+
+ var docAcc = getAccessible(document);
+
+ // test if we hit the region associated with the shadow dom checkbox
+ var tgtX = hitX + deltaX;
+ var tgtY = hitY + deltaY;
+ hitAcc = docAcc.getDeepestChildAtPoint(tgtX, tgtY);
+ isObject(hitAcc, hitcheck, `Hit match at (${tgtX}, ${tgtY}`);
+
+ // test that we don't hit the region associated with the shadow dom checkbox
+ tgtY = hitY + deltaY * 2;
+ hitAcc = docAcc.getDeepestChildAtPoint(tgtX, tgtY);
+ isObject(hitAcc, hitcanvas, `Hit match at (${tgtX}, ${tgtY}`);
+
+ SimpleTest.finish();
+ }
+ SimpleTest.waitForExplicitFinish();
+ addA11yLoadEvent(function() {
+ SpecialPowers.pushPrefEnv({"set": [['canvas.hitregions.enabled', true]]}, doTest);
+ });
+ </script>
+</head>
+<body>
+
+ <a target="_blank"
+ href="https://bugzilla.mozilla.org/show_bug.cgi?id=966591"
+ title="nsIAccessible::childAtPoint() for canvas hit regions from browser tests">Mozilla Bug 966591</a>
+
+ <canvas id="hitcanvas">
+ <input id="hitcheck" type="checkbox"><label for="showA"> Show A </label>
+ </canvas>
+</body>
+</html>