mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-12 23:12:21 +00:00
Bug 966591 - Part 7: Bounds + error handling tests. r=surkov
This commit is contained in:
parent
94416e729d
commit
18f681a602
@ -5,3 +5,4 @@
|
||||
[test_listbox.xul]
|
||||
[test_nsApplicationAcc.html]
|
||||
[test_plugin.html]
|
||||
[test_canvas.html]
|
||||
|
55
accessible/tests/mochitest/elm/test_canvas.html
Normal file
55
accessible/tests/mochitest/elm/test_canvas.html
Normal file
@ -0,0 +1,55 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Accessible boundaries for hit regions</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="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
||||
|
||||
<script type="application/javascript"
|
||||
src="../common.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="../role.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="../layout.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
SpecialPowers.setBoolPref("canvas.hitregions.enabled", true);
|
||||
|
||||
function doTest()
|
||||
{
|
||||
var canv = document.getElementById("c");
|
||||
var context = canv.getContext('2d');
|
||||
var element = document.getElementById("showA");
|
||||
context.beginPath();
|
||||
context.rect(10, 10, 150, 100);
|
||||
context.addHitRegion({control: element});
|
||||
var input = getAccessible("showA");
|
||||
var input = getAccessible("showA");
|
||||
var [cnvX, cnvY, cnvWidth, cnvHeight] = getBoundsForDOMElm(canv);
|
||||
var [accX, accY, accWidth, accHeight] = getBounds(input);
|
||||
is(accX, cnvX + 10, "accX should be 10 and not " + accX);
|
||||
is(accY, cnvY + 10, "accY should be 10 and not " + accY);
|
||||
is(accWidth, 150, "accWidth should be 150 and not " + accWidth);
|
||||
is(accHeight, 100, "accHeight should be 100 and not " + accHeight);
|
||||
|
||||
SpecialPowers.setBoolPref("canvas.hitregions.enabled", false);
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addA11yLoadEvent(doTest);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<canvas id="c">
|
||||
<input id="showA" type="checkbox"><label for="showA"> Show As </label>
|
||||
</canvas>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -8,6 +8,7 @@
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
const Cc = SpecialPowers.Cc;
|
||||
const Cr = SpecialPowers.Cr;
|
||||
SpecialPowers.setBoolPref("canvas.hitregions.enabled", true);
|
||||
|
||||
function IsD2DEnabled() {
|
||||
var enabled = false;
|
||||
@ -21577,6 +21578,46 @@ function test_linedash() {
|
||||
}
|
||||
</script>
|
||||
|
||||
<p>Canvas test: hit regions</p>
|
||||
<canvas id="c688" width="150" height="50">
|
||||
<a id="c688_a"></a>
|
||||
</canvas>
|
||||
<a id="c688_b"></a>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function test_hitregions() {
|
||||
var c = document.getElementById("c688");
|
||||
var d = document.getElementById("c688_a");
|
||||
var e = document.getElementById("c688_b");
|
||||
|
||||
var ctx = c.getContext("2d");
|
||||
var _thrown_outer = false;
|
||||
try {
|
||||
ctx.rect(10,10,100,100);
|
||||
ctx.addHitRegion({control: d});
|
||||
ctx.addHitRegion({control: e});
|
||||
ctx.addHitRegion({id: "a", control: d});
|
||||
ctx.addHitRegion({id: "a", control: d});
|
||||
|
||||
ctx.removeHitRegion("a");
|
||||
ctx.removeHitRegion("a");
|
||||
ctx.removeHitRegion("b");
|
||||
} catch (e) {
|
||||
_thrown_outer = true;
|
||||
}
|
||||
ok(!_thrown_outer, ctx.canvas.id + ' should not throw exception');
|
||||
|
||||
var _thrown = undefined; try {
|
||||
ctx.beginPath();
|
||||
ctx.addHitRegion({control: d});
|
||||
} catch (ex) { _thrown = ex };
|
||||
|
||||
ok(_thrown && _thrown.name == "NotSupportedError", "should throw NotSupportedError");
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
function asyncTestsDone() {
|
||||
@ -24873,6 +24914,12 @@ function runTests() {
|
||||
throw e;
|
||||
ok(false, "unexpected exception thrown in: test_linedash");
|
||||
}
|
||||
try {
|
||||
test_hitregions();
|
||||
} catch(e) {
|
||||
throw e;
|
||||
ok(false, "unexpected exception thrown in: test_linedash");
|
||||
}
|
||||
try {
|
||||
// run this test last since it replaces the getContext method
|
||||
test_type_replace();
|
||||
@ -24893,6 +24940,7 @@ function runTests() {
|
||||
}
|
||||
|
||||
setTimeout(asyncTestsDone, 500);
|
||||
SpecialPowers.setBoolPref("canvas.hitregions.enabled", false);
|
||||
}
|
||||
|
||||
addLoadEvent(runTests);
|
||||
|
Loading…
x
Reference in New Issue
Block a user