mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 438782 – Links should not unconditionally receive an accessible action of jump, r=MarcoZ
This commit is contained in:
parent
360b3ef7a6
commit
f88da4bbe8
@ -143,6 +143,9 @@ nsHTMLLinkAccessible::GetNumActions(PRUint8 *aNumActions)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNumActions);
|
||||
|
||||
if (!IsLinked())
|
||||
return nsHyperTextAccessible::GetNumActions(aNumActions);
|
||||
|
||||
*aNumActions = 1;
|
||||
return NS_OK;
|
||||
}
|
||||
@ -150,8 +153,12 @@ nsHTMLLinkAccessible::GetNumActions(PRUint8 *aNumActions)
|
||||
NS_IMETHODIMP
|
||||
nsHTMLLinkAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
|
||||
{
|
||||
// Action 0 (default action): Jump to link
|
||||
aName.Truncate();
|
||||
|
||||
if (!IsLinked())
|
||||
return nsHyperTextAccessible::GetActionName(aIndex, aName);
|
||||
|
||||
// Action 0 (default action): Jump to link
|
||||
if (aIndex != eAction_Jump)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
@ -162,6 +169,9 @@ nsHTMLLinkAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
|
||||
NS_IMETHODIMP
|
||||
nsHTMLLinkAccessible::DoAction(PRUint8 aIndex)
|
||||
{
|
||||
if (!IsLinked())
|
||||
return nsHyperTextAccessible::DoAction(aIndex);
|
||||
|
||||
// Action 0 (default action): Jump to link
|
||||
if (aIndex != eAction_Jump)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
@ -190,3 +200,20 @@ nsHTMLLinkAccessible::GetURI(PRInt32 aIndex, nsIURI **aURI)
|
||||
|
||||
return link->GetHrefURI(aURI);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Protected members
|
||||
|
||||
PRBool
|
||||
nsHTMLLinkAccessible::IsLinked()
|
||||
{
|
||||
nsCOMPtr<nsILink> link(do_QueryInterface(mDOMNode));
|
||||
if (!link)
|
||||
return PR_FALSE;
|
||||
|
||||
nsLinkState linkState;
|
||||
nsresult rv = link->GetLinkState(linkState);
|
||||
|
||||
return NS_SUCCEEDED(rv) && linkState != eLinkState_NotLink &&
|
||||
linkState != eLinkState_Unknown;
|
||||
}
|
||||
|
@ -64,6 +64,11 @@ public:
|
||||
|
||||
protected:
|
||||
enum { eAction_Jump = 0 };
|
||||
|
||||
/**
|
||||
* Returns true if the link has href attribute.
|
||||
*/
|
||||
PRBool IsLinked();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -62,6 +62,22 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=418368
|
||||
+ aID + "!");
|
||||
}
|
||||
|
||||
function testAction(aId, aAcc, aActionName)
|
||||
{
|
||||
var numActions = aActionName ? 1 : 0;
|
||||
is(aAcc.numActions, numActions,
|
||||
"Wrong actions number for ID " + aId);
|
||||
try {
|
||||
is(aAcc.getActionName(0), aActionName,
|
||||
"Wrong action name for ID " + aId);
|
||||
} catch (e) {
|
||||
if (numActions)
|
||||
ok(false, "Exception on action name getting for ID " + aId);
|
||||
else
|
||||
ok(true, "Correct action name for ID " + aId);
|
||||
}
|
||||
}
|
||||
|
||||
function doTest()
|
||||
{
|
||||
// Mapping needed state flags for easier handling.
|
||||
@ -131,6 +147,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=418368
|
||||
testStates("AriaHyperlink", ariaHyperlinkAcc,
|
||||
(state_focusable | state_focused | state_linked),
|
||||
(ext_state_horizontal), (0));
|
||||
testAction("AriaHyperlink", ariaHyperlinkAcc, "click");
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// ARIA hyperlink with status invalid
|
||||
@ -227,6 +244,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=418368
|
||||
testStates("emptyLink", EmptyHLAcc,
|
||||
(state_focusable | state_linked),
|
||||
(ext_state_horizontal), (0));
|
||||
testAction("emptyLink", EmptyHLAcc, "jump");
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// normal hyperlink with embedded span
|
||||
@ -251,6 +269,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=418368
|
||||
testStates("LinkWithSpan", hyperlinkWithSpanAcc,
|
||||
(state_focusable | state_focused | state_linked),
|
||||
(ext_state_horizontal), (0));
|
||||
testAction("LinkWithSpan", hyperlinkWithSpanAcc, "jump");
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Named anchor, should never have state_linked
|
||||
@ -268,6 +287,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=418368
|
||||
testStates("namedAnchor", namedAnchorAcc,
|
||||
(state_selectable),
|
||||
(ext_state_horizontal), (state_focusable | state_linked));
|
||||
testAction("namedAnchor", namedAnchorAcc, "");
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// No link (hasn't any attribute), should never have state_linked
|
||||
@ -285,6 +305,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=418368
|
||||
testStates("noLink", noLinkAcc,
|
||||
0,
|
||||
(ext_state_horizontal), (state_focusable | state_linked));
|
||||
testAction("noLink", noLinkAcc, "");
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Link with registered 'click' event, should have state_linked
|
||||
@ -302,6 +323,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=418368
|
||||
testStates("linkWithClick", linkWithClickAcc,
|
||||
(state_linked),
|
||||
(ext_state_horizontal), 0);
|
||||
testAction("linkWithClick", linkWithClickAcc, "click");
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Maps to group links (bug 431615).
|
||||
|
Loading…
Reference in New Issue
Block a user