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"
|
2010-09-10 10:20:38 -07:00
|
|
|
src="../common.js" />
|
2009-02-27 03:23:26 -08:00
|
|
|
<script type="application/javascript"
|
2010-09-10 10:20:38 -07:00
|
|
|
src="../role.js" />
|
2009-02-27 03:23:26 -08:00
|
|
|
<script type="application/javascript"
|
2010-09-10 10:20:38 -07:00
|
|
|
src="../states.js" />
|
2010-12-02 00:47:14 -08:00
|
|
|
<script type="application/javascript"
|
|
|
|
src="../events.js" />
|
|
|
|
|
|
|
|
<script type="application/javascript"
|
|
|
|
src="hyperlink.js" />
|
2009-02-27 03:23:26 -08:00
|
|
|
|
2008-04-14 06:29:44 -07:00
|
|
|
<script type="application/javascript">
|
|
|
|
<![CDATA[
|
|
|
|
function testThis(aID, aAcc, aRole, aAnchorCount, aAnchorName, aURI,
|
2010-12-02 00:47:14 -08:00
|
|
|
aStartIndex, aEndIndex, aValid)
|
2008-04-14 06:29:44 -07:00
|
|
|
{
|
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 + "!");
|
|
|
|
}
|
|
|
|
|
2010-12-02 00:47:14 -08:00
|
|
|
var gQueue = null;
|
2008-04-14 06:29:44 -07:00
|
|
|
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,
|
2010-12-02 00:47:14 -08:00
|
|
|
true);
|
|
|
|
testStates(linkedLabelAcc, 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);
|
2010-12-02 00:47:14 -08:00
|
|
|
testStates(labelWithValueAcc, 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!");
|
2009-03-14 07:57:29 -07:00
|
|
|
testStates(normalLabelAcc, 0, 0, (STATE_FOCUSABLE | STATE_LINKED));
|
2008-04-14 06:29:44 -07:00
|
|
|
|
2010-12-02 00:47:14 -08:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// Test focus
|
|
|
|
|
|
|
|
gQueue = new eventQueue();
|
|
|
|
|
|
|
|
gQueue.push(new focusLink("linkedLabel", true));
|
|
|
|
gQueue.push(new focusLink("linkLabelWithValue", true));
|
|
|
|
|
|
|
|
gQueue.invoke(); // Will call SimpleTest.finish();
|
2008-04-14 06:29:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
2009-09-23 07:21:47 -07:00
|
|
|
addA11yLoadEvent(doTest);
|
2008-04-14 06:29:44 -07:00
|
|
|
]]>
|
|
|
|
</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>
|