gecko/accessible/tests/mochitest/hittest/test_general.html

87 lines
3.0 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/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 doTest()
{
// Not specific case, child and deepchild testing.
var list = getAccessible("list");
var listitem = getAccessible("listitem");
var image = getAccessible("image");
if (!MAC) {
testChildAtPoint(list, 1, 1, listitem, image.firstChild);
} else {
todo(false, "Bug 746974 - children must match on all platforms, disable failing test on Mac");
}
// ::MustPrune case (in this case childAtPoint doesn't look inside a
// textbox), point is inside of textbox.
var txt = getAccessible("txt");
testChildAtPoint(txt, 1, 1, txt, txt);
// ::MustPrune case, point is outside of textbox accessible but is in
// document.
testChildAtPoint(txt, -1, 1, null, null);
// ::MustPrune case, point is outside of root accessible.
testChildAtPoint(txt, -10000, 10000, null, null);
// Not specific case, point is inside of btn accessible.
var btn = getAccessible("btn");
var btnText = btn.firstChild;
testChildAtPoint(btn, 1, 1, btnText, btnText);
// Not specific case, point is outside of btn accessible.
testChildAtPoint(btn, -1, 1, null, 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, "area", "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="button">button1</span><span role="button" id="btn">button2</span>
<span role="textbox">textbox1</span><span role="textbox" id="txt">textbox2</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>