2008-04-14 06:29:44 -07:00
|
|
|
<?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" />
|
2009-02-27 03:23:26 -08:00
|
|
|
|
|
|
|
<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" />
|
|
|
|
|
2008-04-14 06:29:44 -07:00
|
|
|
<script type="application/javascript">
|
|
|
|
<![CDATA[
|
|
|
|
function testThis(aID, aAcc, aRole, aAnchorCount, aAnchorName, aURI,
|
|
|
|
aStartIndex, aEndIndex, aValid, aSelectedBefore,
|
|
|
|
aSelectedAfter)
|
|
|
|
{
|
2009-02-27 03:23:26 -08:00
|
|
|
testRole(aID, aRole);
|
2008-04-14 06:29:44 -07:00
|
|
|
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()
|
|
|
|
{
|
2009-02-27 03:23:26 -08:00
|
|
|
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));
|
2008-04-14 06:29:44 -07:00
|
|
|
|
2009-02-27 03:23:26 -08:00
|
|
|
var labelWithValueAcc = getAccessible("linkLabelWithValue",
|
|
|
|
[nsIAccessibleHyperLink]);
|
|
|
|
testThis("linkLabelWithValue", labelWithValueAcc, ROLE_LINK, 1,
|
2008-04-14 06:29:44 -07:00
|
|
|
"Mozilla Foundation", "http://www.mozilla.org/", 2, 3, true,
|
|
|
|
false, true);
|
2009-02-27 03:23:26 -08:00
|
|
|
testStates(labelWithValueAcc,
|
|
|
|
(STATE_FOCUSABLE | STATE_LINKED),
|
|
|
|
(EXT_STATE_HORIZONTAL));
|
2008-04-14 06:29:44 -07:00
|
|
|
|
2009-02-27 03:23:26 -08:00
|
|
|
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);
|
2008-04-14 06:29:44 -07:00
|
|
|
|
|
|
|
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>
|