gecko/accessible/tests/mochitest/test_childAtPoint.html

93 lines
3.4 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>nsIAccessible::childAtPoint() tests</title>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/layout.js"></script>
<script type="application/javascript">
function doTest()
{
// Not specific case, child and deepchild testing.
var list = getAccessible("list");
var listitem = getAccessible("listitem");
var image = getAccessible("image");
testChildAtPoint(list, 1, 1, false, listitem);
testChildAtPoint(list, 1, 1, true, image.firstChild);
// ::MustPrune case (in this case childAtPoint doesn't look inside a
// button), point is inside of button.
var btn = getAccessible("btn");
testChildAtPoint(btn, 1, 1, false, btn);
testChildAtPoint(btn, 1, 1, true, btn);
// ::MustPrune case, point is outside of button accessible but is in
// document.
testChildAtPoint(btn, -1, 1, false, null);
testChildAtPoint(btn, -1, 1, true, null);
// ::MustPrune case, point is outside of root accessible.
testChildAtPoint(btn, -10000, 10000, false, null);
testChildAtPoint(btn, -10000, 10000, true, null);
// Not specific case, point is inside of label accessible.
var label = getAccessible("label");
var labelText = label.firstChild;
testChildAtPoint(label, 1, 1, false, labelText);
testChildAtPoint(label, 1, 1, true, labelText);
// Not specific case, point is outside of label accessible.
testChildAtPoint(label, -1, 1, false, null);
testChildAtPoint(label, -1, 1, true, null);
// Out of flow accessible testing, do not return out of flow accessible
// because it's not a child of the accessible even visually it is.
var rectArea = getNode("area").getBoundingClientRect();
var outOfFlow = getNode("outofflow");
outOfFlow.style.left = rectArea.left + "px";
outOfFlow.style.top = rectArea.top + "px";
testChildAtPoint("area", 1, 1, false, "area");
testChildAtPoint("area", 1, 1, true, "area");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=491657"
title="nsIAccessible::childAtPoint() tests">Mozilla Bug 491657</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<div role="list" id="list">
<div role="listitem" id="listitem"><span role="image" id="image">img</span>item</div>
</div>
<span role="label">label1</span><span role="label" id="label">label2</span>
<span role="button">btn1</span><span role="button" id="btn">btn2</span>
<div id="outofflow" style="width: 10px; height: 10px; position: absolute; left: 0px; top: 0px; background-color: yellow;">
</div>
<div id="area" style="width: 100px; height: 100px; background-color: blue;"></div>
</body>
</html>