mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 10:00:54 +00:00
Bug 615913 - fix focus hyperlink tests, r=marcoz, a=test
This commit is contained in:
parent
7235d32caf
commit
229baaec0f
@ -46,6 +46,7 @@ include $(DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
_TEST_FILES =\
|
||||
hyperlink.js \
|
||||
test_general.html \
|
||||
test_general.xul \
|
||||
$(NULL)
|
||||
|
48
accessible/tests/mochitest/hyperlink/hyperlink.js
Normal file
48
accessible/tests/mochitest/hyperlink/hyperlink.js
Normal file
@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Focus hyperlink invoker.
|
||||
*
|
||||
* @param aID [in] hyperlink identifier
|
||||
* @param aSelectedAfter [in] specifies if hyperlink is selected/focused after
|
||||
* the focus
|
||||
*/
|
||||
function focusLink(aID, aSelectedAfter)
|
||||
{
|
||||
this.node = getNode(aID);
|
||||
this.accessible = getAccessible(this.node);
|
||||
|
||||
this.eventSeq = [];
|
||||
this.unexpectedEventSeq = [];
|
||||
|
||||
var checker = new invokerChecker(EVENT_FOCUS, this.accessible);
|
||||
if (aSelectedAfter)
|
||||
this.eventSeq.push(checker);
|
||||
else
|
||||
this.unexpectedEventSeq.push(checker);
|
||||
|
||||
this.invoke = function focusLink_invoke()
|
||||
{
|
||||
is(this.accessible.selected, false,
|
||||
"Wrong selected state before focus for ID " + prettyName(aID) + "!");
|
||||
|
||||
var expectedStates = (aSelectedAfter ? STATE_FOCUSABLE : 0);
|
||||
var unexpectedStates = (!aSelectedAfter ? STATE_FOCUSABLE : 0) | STATE_FOCUSED;
|
||||
testStates(aID, expectedStates, 0, unexpectedStates, 0);
|
||||
|
||||
this.node.focus();
|
||||
}
|
||||
|
||||
this.finalCheck = function focusLink_finalCheck()
|
||||
{
|
||||
is(this.accessible.selected, aSelectedAfter,
|
||||
"Wrong seleccted state after focus for ID " + prettyName(aID) + "!");
|
||||
|
||||
var expectedStates = (aSelectedAfter ? STATE_FOCUSABLE | STATE_FOCUSED : 0);
|
||||
var unexpectedStates = (!aSelectedAfter ? STATE_FOCUSABLE | STATE_FOCUSED : 0);
|
||||
testStates(aID, expectedStates, 0, unexpectedStates, 0);
|
||||
}
|
||||
|
||||
this.getID = function focusLink_getID()
|
||||
{
|
||||
return "focus hyperlink " + prettyName(aID);
|
||||
}
|
||||
}
|
@ -18,6 +18,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=418368
|
||||
src="../role.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="../states.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="../events.js"></script>
|
||||
|
||||
<script type="application/javascript"
|
||||
src="hyperlink.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
function testThis(aID, aAcc, aRole, aAnchors, aName, aValid, aStartIndex,
|
||||
@ -36,15 +41,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=418368
|
||||
+ aID + "!");
|
||||
}
|
||||
|
||||
function testFocus(aID, aAcc, aSelectedBefore, aSelectedAfter)
|
||||
{
|
||||
is(aAcc.selected, aSelectedBefore,
|
||||
"Wrong selected state before focus for ID " + aID + "!");
|
||||
document.getElementById(aID).focus();
|
||||
is(aAcc.selected, aSelectedAfter,
|
||||
"Wrong seleccted state after focus for ID " + aID + "!");
|
||||
}
|
||||
|
||||
function testAction(aId, aAcc, aActionName)
|
||||
{
|
||||
var numActions = aActionName ? 1 : 0;
|
||||
@ -61,6 +57,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=418368
|
||||
}
|
||||
}
|
||||
|
||||
//gA11yEventDumpToConsole = true; // debug stuff
|
||||
|
||||
var gQueue = null;
|
||||
function doTest()
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -71,13 +70,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=418368
|
||||
"Mozilla Foundation", true, 17, 18);
|
||||
is(normalHyperlinkAcc.getURI(0).spec, "http://www.mozilla.org/",
|
||||
"URI wrong for normalHyperlinkElement!");
|
||||
testStates(normalHyperlinkAcc,
|
||||
(STATE_FOCUSABLE | STATE_LINKED),
|
||||
(EXT_STATE_HORIZONTAL));
|
||||
testFocus("NormalHyperlink", normalHyperlinkAcc, false, true);
|
||||
testStates(normalHyperlinkAcc,
|
||||
(STATE_FOCUSABLE | STATE_FOCUSED | STATE_LINKED),
|
||||
(EXT_STATE_HORIZONTAL));
|
||||
testStates(normalHyperlinkAcc, STATE_LINKED, EXT_STATE_HORIZONTAL);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// ARIA hyperlink
|
||||
@ -85,13 +78,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=418368
|
||||
[nsIAccessibleHyperLink]);
|
||||
testThis("AriaHyperlink", ariaHyperlinkAcc, ROLE_LINK, 1,
|
||||
"Mozilla Foundation Home", true, 30, 31);
|
||||
testStates(ariaHyperlinkAcc,
|
||||
(STATE_FOCUSABLE | STATE_LINKED),
|
||||
(EXT_STATE_HORIZONTAL));
|
||||
testFocus("AriaHyperlink", ariaHyperlinkAcc, false, true);
|
||||
testStates(ariaHyperlinkAcc,
|
||||
(STATE_FOCUSABLE | STATE_FOCUSED | STATE_LINKED),
|
||||
(EXT_STATE_HORIZONTAL));
|
||||
testStates(ariaHyperlinkAcc, STATE_LINKED, EXT_STATE_HORIZONTAL);
|
||||
testAction("AriaHyperlink", ariaHyperlinkAcc, "click");
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -99,11 +86,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=418368
|
||||
var invalidAriaHyperlinkAcc = getAccessible("InvalidAriaHyperlink",
|
||||
[nsIAccessibleHyperLink]);
|
||||
is(invalidAriaHyperlinkAcc.valid, false, "Should not be valid!");
|
||||
testStates(invalidAriaHyperlinkAcc,
|
||||
(STATE_LINKED),
|
||||
(EXT_STATE_HORIZONTAL), (STATE_FOCUSABLE));
|
||||
testFocus("InvalidAriaHyperlink", invalidAriaHyperlinkAcc,
|
||||
false, false);
|
||||
testStates(invalidAriaHyperlinkAcc, STATE_LINKED, EXT_STATE_HORIZONTAL);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// image map and its link children
|
||||
@ -151,13 +134,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=418368
|
||||
"Heise Online", true, 119, 120);
|
||||
is(hyperlinkWithSpanAcc.getURI(0).spec, "http://www.heise.de/",
|
||||
"URI wrong for hyperlinkElementWithSpan!");
|
||||
testStates(hyperlinkWithSpanAcc,
|
||||
(STATE_FOCUSABLE | STATE_LINKED),
|
||||
(EXT_STATE_HORIZONTAL));
|
||||
testFocus("LinkWithSpan", hyperlinkWithSpanAcc, false, true);
|
||||
testStates(hyperlinkWithSpanAcc,
|
||||
(STATE_FOCUSABLE | STATE_FOCUSED | STATE_LINKED),
|
||||
(EXT_STATE_HORIZONTAL));
|
||||
testStates(hyperlinkWithSpanAcc, STATE_LINKED, EXT_STATE_HORIZONTAL);
|
||||
testAction("LinkWithSpan", hyperlinkWithSpanAcc, "jump");
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -247,7 +224,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=418368
|
||||
[nsIAccessibleHyperLink]);
|
||||
ok(!res, "Text accessible shouldn't implement nsIAccessibleHyperLink");
|
||||
|
||||
SimpleTest.finish();
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Test focus
|
||||
gQueue = new eventQueue();
|
||||
|
||||
gQueue.push(new focusLink("NormalHyperlink", true));
|
||||
gQueue.push(new focusLink("AriaHyperlink", true));
|
||||
gQueue.push(new focusLink("InvalidAriaHyperlink", false));
|
||||
gQueue.push(new focusLink("LinkWithSpan", true));
|
||||
|
||||
gQueue.invoke(); // Will call SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
@ -17,12 +17,16 @@
|
||||
src="../role.js" />
|
||||
<script type="application/javascript"
|
||||
src="../states.js" />
|
||||
<script type="application/javascript"
|
||||
src="../events.js" />
|
||||
|
||||
<script type="application/javascript"
|
||||
src="hyperlink.js" />
|
||||
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
function testThis(aID, aAcc, aRole, aAnchorCount, aAnchorName, aURI,
|
||||
aStartIndex, aEndIndex, aValid, aSelectedBefore,
|
||||
aSelectedAfter)
|
||||
aStartIndex, aEndIndex, aValid)
|
||||
{
|
||||
testRole(aID, aRole);
|
||||
is(aAcc.anchorCount, aAnchorCount, "Wrong number of anchors for ID "
|
||||
@ -33,33 +37,24 @@
|
||||
+ "!");
|
||||
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 + "!");
|
||||
}
|
||||
|
||||
var gQueue = null;
|
||||
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));
|
||||
true);
|
||||
testStates(linkedLabelAcc, 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));
|
||||
testStates(labelWithValueAcc, STATE_LINKED, EXT_STATE_HORIZONTAL);
|
||||
|
||||
var normalLabelAcc = getAccessible("normalLabel");
|
||||
testRole(normalLabelAcc, ROLE_LABEL);
|
||||
@ -67,7 +62,15 @@
|
||||
"Wrong name for normal label!");
|
||||
testStates(normalLabelAcc, 0, 0, (STATE_FOCUSABLE | STATE_LINKED));
|
||||
|
||||
SimpleTest.finish();
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Test focus
|
||||
|
||||
gQueue = new eventQueue();
|
||||
|
||||
gQueue.push(new focusLink("linkedLabel", true));
|
||||
gQueue.push(new focusLink("linkLabelWithValue", true));
|
||||
|
||||
gQueue.invoke(); // Will call SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
Loading…
Reference in New Issue
Block a user