gecko/accessible/tests/mochitest/test_nsIAccessibleHyperLink.xul

97 lines
3.9 KiB
Plaintext
Raw Normal View History

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="test for nsIAccessibleHyperLink interface on XUL:label elements">
<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 type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/role.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/nsIAccessible_states.js" />
<script type="application/javascript">
<![CDATA[
function testThis(aID, aAcc, aRole, aAnchorCount, aAnchorName, aURI,
aStartIndex, aEndIndex, aValid, aSelectedBefore,
aSelectedAfter)
{
testRole(aID, aRole);
is(aAcc.anchorCount, aAnchorCount, "Wrong number of anchors for ID "
+ aID + "!");
is(aAcc.getAnchor(0).name, aAnchorName, "Wrong name for ID " + aID + "!");
is(aAcc.getURI(0).spec, aURI, "URI wrong for ID " + aID + "!");
is(aAcc.startIndex, aStartIndex, "Wrong startIndex value for ID " + aID
+ "!");
is(aAcc.endIndex, aEndIndex, "Wrong endIndex value for ID " + aID + "!");
is(aAcc.valid, aValid, "Wrong valid state for ID " + aID + "!");
is(aAcc.selected, aSelectedBefore, "Wrong focused state before focus for "
+ aID + "!");
document.getElementById(aID).focus();
is(aAcc.selected, aSelectedAfter, "Wrong selected state after focus for "
+ aID + "!");
}
function doTest()
{
var linkedLabelAcc = getAccessible("linkedLabel",
[nsIAccessibleHyperLink]);
testThis("linkedLabel", linkedLabelAcc, ROLE_LINK, 1,
"Mozilla Foundation home", "http://www.mozilla.org/", 1, 2,
true, false, true);
testStates(linkedLabelAcc,
(STATE_FOCUSABLE | STATE_LINKED),
(EXT_STATE_HORIZONTAL));
var labelWithValueAcc = getAccessible("linkLabelWithValue",
[nsIAccessibleHyperLink]);
testThis("linkLabelWithValue", labelWithValueAcc, ROLE_LINK, 1,
"Mozilla Foundation", "http://www.mozilla.org/", 2, 3, true,
false, true);
testStates(labelWithValueAcc,
(STATE_FOCUSABLE | STATE_LINKED),
(EXT_STATE_HORIZONTAL));
var normalLabelAcc = getAccessible("normalLabel");
testRole(normalLabelAcc, ROLE_LABEL);
is(normalLabelAcc.name, "This label should not be a link",
"Wrong name for normal label!");
testStates(normalLabelAcc, 0, 0, (STATE_FOCUSABLE | STATE_LINKED);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(doTest);
]]>
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=421066"
title="Implement Mochitests for the nsIAccessibleHyperLink interface on XUL:label elements">
Mozilla Bug 421066
</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
<label id="linkedLabel" class="text-link" href="http://www.mozilla.org/">
Mozilla Foundation home</label>
<label id="linkLabelWithValue" value="Mozilla Foundation" class="text-link"
href="http://www.mozilla.org/" />
<label id="normalLabel" value="This label should not be a link" />
</window>