Bug 543931 - expose onmouseup/down via accessible 'click' action, r=marcoz, davidb

--HG--
rename : accessible/tests/mochitest/test_actions_anchors.html => accessible/tests/mochitest/actions/test_anchors.html
rename : accessible/tests/mochitest/test_actions_aria.html => accessible/tests/mochitest/actions/test_aria.html
rename : accessible/tests/mochitest/test_actions.html => accessible/tests/mochitest/actions/test_general.html
rename : accessible/tests/mochitest/test_actions.xul => accessible/tests/mochitest/actions/test_general.xul
rename : accessible/tests/mochitest/test_actions_inputs.html => accessible/tests/mochitest/actions/test_inputs.html
rename : accessible/tests/mochitest/test_actions_tree.xul => accessible/tests/mochitest/actions/test_tree.xul
rename : accessible/tests/mochitest/test_actions_treegrid.xul => accessible/tests/mochitest/actions/test_treegrid.xul
rename : accessible/tests/mochitest/test_states.html => accessible/tests/mochitest/states/test_aria.html
rename : accessible/tests/mochitest/test_states_doc.html => accessible/tests/mochitest/states/test_doc.html
rename : accessible/tests/mochitest/test_states_docarticle.html => accessible/tests/mochitest/states/test_docarticle.html
rename : accessible/tests/mochitest/test_states_editablebody.html => accessible/tests/mochitest/states/test_editablebody.html
rename : accessible/tests/mochitest/test_states_frames.html => accessible/tests/mochitest/states/test_frames.html
rename : accessible/tests/mochitest/test_states_popup.xul => accessible/tests/mochitest/states/test_popup.xul
rename : accessible/tests/mochitest/test_states_tree.xul => accessible/tests/mochitest/states/test_tree.xul
rename : accessible/tests/mochitest/z_states_frame.html => accessible/tests/mochitest/states/z_frames.html
rename : accessible/tests/mochitest/z_states_framearticle.html => accessible/tests/mochitest/states/z_frames_article.html
rename : accessible/tests/mochitest/z_states_framecheckbox.html => accessible/tests/mochitest/states/z_frames_checkbox.html
rename : accessible/tests/mochitest/z_states_frametextbox.html => accessible/tests/mochitest/states/z_frames_textbox.html
This commit is contained in:
Alexander Surkov 2010-02-03 23:00:25 +08:00
parent 47430997d6
commit 7f162b9ae0
31 changed files with 337 additions and 119 deletions

View File

@ -1613,7 +1613,7 @@ nsAccessibilityService::GetAccessible(nsIDOMNode *aNode,
// correspond to the doc accessible and will be created in any case
if (!newAcc && content->Tag() != nsAccessibilityAtoms::body && content->GetParent() &&
((weakFrame.GetFrame() && weakFrame.GetFrame()->IsFocusable()) ||
(isHTML && nsCoreUtils::HasListener(content, NS_LITERAL_STRING("click"))) ||
(isHTML && nsCoreUtils::HasClickListener(content)) ||
HasUniversalAriaProperty(content, aWeakShell) || roleMapEntry ||
HasRelatedContent(content) || nsCoreUtils::IsXLink(content))) {
// This content is focusable or has an interesting dynamic content accessibility property.

View File

@ -3214,8 +3214,7 @@ nsAccessible::GetActionRule(PRUint32 aStates)
return eClickAction;
// Has registered 'click' event handler.
PRBool isOnclick = nsCoreUtils::HasListener(content,
NS_LITERAL_STRING("click"));
PRBool isOnclick = nsCoreUtils::HasClickListener(content);
if (isOnclick)
return eClickAction;

View File

@ -251,8 +251,7 @@ void
nsLinkableAccessible::CacheActionContent()
{
nsCOMPtr<nsIContent> walkUpContent(do_QueryInterface(mDOMNode));
PRBool isOnclick = nsCoreUtils::HasListener(walkUpContent,
NS_LITERAL_STRING("click"));
PRBool isOnclick = nsCoreUtils::HasClickListener(walkUpContent);
if (isOnclick) {
mActionContent = walkUpContent;
@ -261,8 +260,7 @@ nsLinkableAccessible::CacheActionContent()
}
while ((walkUpContent = walkUpContent->GetParent())) {
isOnclick = nsCoreUtils::HasListener(walkUpContent,
NS_LITERAL_STRING("click"));
isOnclick = nsCoreUtils::HasClickListener(walkUpContent);
nsCOMPtr<nsIDOMNode> walkUpNode(do_QueryInterface(walkUpContent));

View File

@ -75,13 +75,16 @@
static NS_DEFINE_IID(kRangeCID, NS_RANGE_CID);
PRBool
nsCoreUtils::HasListener(nsIContent *aContent, const nsAString& aEventType)
nsCoreUtils::HasClickListener(nsIContent *aContent)
{
NS_ENSURE_TRUE(aContent, PR_FALSE);
nsIEventListenerManager* listenerManager =
aContent->GetListenerManager(PR_FALSE);
return listenerManager && listenerManager->HasListenersFor(aEventType);
return listenerManager &&
(listenerManager->HasListenersFor(NS_LITERAL_STRING("click")) ||
listenerManager->HasListenersFor(NS_LITERAL_STRING("mousedown")) ||
listenerManager->HasListenersFor(NS_LITERAL_STRING("mouseup")));
}
void

View File

@ -57,10 +57,10 @@ class nsCoreUtils
{
public:
/**
* Return true if the given node has registered event listener of the given
* type.
* Return true if the given node has registered click, mousedown or mouseup
* event listeners.
*/
static PRBool HasListener(nsIContent *aContent, const nsAString& aEventType);
static PRBool HasClickListener(nsIContent *aContent);
/**
* Dispatch click event to XUL tree cell.

View File

@ -87,8 +87,7 @@ nsHTMLLinkAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState)
// This is a either named anchor (a link with also a name attribute) or
// it doesn't have any attributes. Check if 'click' event handler is
// registered, otherwise bail out.
PRBool isOnclick = nsCoreUtils::HasListener(content,
NS_LITERAL_STRING("click"));
PRBool isOnclick = nsCoreUtils::HasClickListener(content);
if (!isOnclick)
return NS_OK;
}

View File

@ -42,7 +42,7 @@ srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = accessible
DIRS = attributes events selectable tree
DIRS = actions attributes events selectable states tree
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
@ -71,13 +71,6 @@ _TEST_FILES =\
states.js \
table.js \
value.js \
test_actions.html \
test_actions.xul \
test_actions_anchors.html \
test_actions_aria.html \
test_actions_inputs.html \
test_actions_tree.xul \
test_actions_treegrid.xul \
test_aria_activedescendant.html \
test_aria_role_article.html \
test_aria_role_equation.html \
@ -114,14 +107,6 @@ _TEST_FILES =\
test_relations.xul \
test_relations_tree.xul \
test_role_nsHyperTextAcc.html \
test_role_table_cells.html \
test_states.html \
test_states_doc.html \
test_states_docarticle.html \
test_states_editablebody.html \
test_states_frames.html \
test_states_popup.xul \
test_states_tree.xul \
test_table_1.html \
test_table_4.html \
test_table_headers.html \
@ -149,10 +134,6 @@ _TEST_FILES =\
testTextboxes.js \
treeview.css \
treeview.js \
z_states_frame.html \
z_states_framearticle.html \
z_states_framecheckbox.html \
z_states_frametextbox.html \
$(NULL)
libs:: $(_TEST_FILES)

View File

@ -0,0 +1,59 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Mozilla Corporation.
# Portions created by the Initial Developer are Copyright (C) 2010
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Alexander Surkov <surkov.alexander@gmail.com> (original author)
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = accessible/actions
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_TEST_FILES =\
test_anchors.html \
test_aria.html \
test_general.html \
test_general.xul \
test_inputs.html \
test_tree.xul \
test_treegrid.xul \
$(NULL)
libs:: $(_TEST_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/a11y/$(relativesrcdir)

View File

@ -1,7 +1,8 @@
<html>
<head>
<title>nsIAccessible actions testing for anchors</title>
<title>nsIAccessible actions testing for HTML links that
scroll the page to named anchors</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />

View File

@ -23,7 +23,17 @@
{
var actionsArray = [
{
ID: "li_clickable",
ID: "li_clickable1",
actionName: "click",
events: CLICK_EVENTS
},
{
ID: "li_clickable2",
actionName: "click",
events: CLICK_EVENTS
},
{
ID: "li_clickable3",
actionName: "click",
events: CLICK_EVENTS
}
@ -42,6 +52,11 @@
href="https://bugzilla.mozilla.org/show_bug.cgi?id=523789"
title="nsHTMLLiAccessible shouldn't be inherited from linkable accessible">
Mozilla Bug 523789
</a><br>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=423409"
title="Expose click action if mouseup and mousedown are registered">
Mozilla Bug 423409
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
@ -49,7 +64,9 @@
</pre>
<ul>
<li id="li_clickable" onclick="">Clickable list item</li>
<li id="li_clickable1" onclick="">Clickable list item</li>
<li id="li_clickable2" onmousedown="">Clickable list item</li>
<li id="li_clickable3" onmouseup="">Clickable list item</li>
</ul>
</body>
</html>

View File

@ -0,0 +1,99 @@
<html>
<head>
<title>nsIAccessible actions testing on HTML links (HTML:a)</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<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>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/actions.js"></script>
<script type="application/javascript">
function doTest()
{
var actionsArray = [
{
ID: "link1",
actionName: "jump",
events: CLICK_EVENTS
},
{
ID: "img1",
actionName: "click",
events: CLICK_EVENTS
},
{
ID: "link2",
actionName: "click",
events: CLICK_EVENTS
},
{
ID: "img2",
actionName: "click",
events: CLICK_EVENTS
},
{
ID: "link3",
actionName: "click",
events: CLICK_EVENTS
},
{
ID: "img3",
actionName: "click",
events: CLICK_EVENTS
},
{
ID: "link4",
actionName: "click",
events: CLICK_EVENTS
},
{
ID: "img4",
actionName: "click",
events: CLICK_EVENTS
}
];
testActions(actionsArray);
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=423409"
title="Expose click action if mouseup and mousedown are registered">
Mozilla Bug 423409
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<a href="http://mozilla.org" id="link1">
<img src="chrome://mochikit/content/a11y/accessible/moz.png" id="img1">
</a>
<a id="link2" onmousedown="">
<img src="chrome://mochikit/content/a11y/accessible/moz.png" id="img2">
</a>
<a id="link3" onclick="">
<img src="chrome://mochikit/content/a11y/accessible/moz.png" id="img3">
</a>
<a id="link4" onmouseup="">
<img src="chrome://mochikit/content/a11y/accessible/moz.png" id="img4">
</a>
</body>
</html>

View File

@ -0,0 +1,64 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Mozilla Corporation.
# Portions created by the Initial Developer are Copyright (C) 2010
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Alexander Surkov <surkov.alexander@gmail.com> (original author)
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = accessible/states
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_TEST_FILES =\
test_aria.html \
test_doc.html \
test_docarticle.html \
test_editablebody.html \
test_frames.html \
test_link.html \
test_popup.xul \
test_tree.xul \
z_frames.html \
z_frames_article.html \
z_frames_checkbox.html \
z_frames_textbox.html \
$(NULL)
libs:: $(_TEST_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/a11y/$(relativesrcdir)

View File

@ -1,7 +1,7 @@
<html>
<head>
<title>nsIAccessible states testing</title>
<title>ARIA based nsIAccessible states testing</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />

View File

@ -61,9 +61,9 @@
<pre id="test">
</pre>
<iframe id="frame_doc" src="z_states_frame.html"></iframe>
<iframe id="frame_doc_article" src="z_states_framearticle.html"></iframe>
<iframe id="frame_doc_checkbox" src="z_states_framecheckbox.html"></iframe>
<iframe id="frame_doc_textbox" src="z_states_frametextbox.html"></iframe>
<iframe id="frame_doc" src="z_frames.html"></iframe>
<iframe id="frame_doc_article" src="z_frames_article.html"></iframe>
<iframe id="frame_doc_checkbox" src="z_frames_checkbox.html"></iframe>
<iframe id="frame_doc_textbox" src="z_frames_textbox.html"></iframe>
</body>
</html>

View File

@ -0,0 +1,57 @@
<html>
<head>
<title>HTML link states testing</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<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>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/role.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/states.js"></script>
<script type="application/javascript">
function doTest()
{
// strong roles
testStates("link1", STATE_LINKED);
testStates("link2", STATE_LINKED);
testStates("link3", STATE_LINKED);
testStates("link4", STATE_LINKED);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=423409"
title="Expose click action if mouseup and mousedown are registered">
Mozilla Bug 423409
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<a id="link1" href="http://mozilla.org">link</a>
<a id="link2" onclick="">link</a>
<a id="link3" onmousedown="">link</a>
<a id="link4" onmouseup="">link</a>
</body>
</html>

View File

@ -1,10 +1,7 @@
<!DOCTYPE html>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=472326
-->
<head>
<title>test nsHyperTextAccessible roles</title>
<title>test nsHyperTextAccessible accesible objects creation and their roles</title>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
@ -51,6 +48,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=472326
testRole("definitionterm", ROLE_LISTITEM);
testRole("definitiondescription", ROLE_PARAGRAPH);
// Has click, mousedown or mouseup listeners.
testRole("span1", ROLE_TEXT_CONTAINER);
testRole("span2", ROLE_TEXT_CONTAINER);
testRole("span3", ROLE_TEXT_CONTAINER);
SimpleTest.finish();
}
@ -62,10 +64,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=472326
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=472326"
title="html:input of type "file" no longer rendered to screen readers">
Mozilla Bug 472326</a>
Mozilla Bug 472326
</a><br>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=474261"
title="Test remaining implementations in nsHypertextAccessible::GetRole">
bug 474261</a>
bug 474261
</a><br>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=423409"
title="Expose click action if mouseup and mousedown are registered">
Mozilla Bug 423409
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
@ -89,5 +97,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=472326
<dt id="definitionterm">gecko</dt>
<dd id="definitiondescription">geckos have sticky toes</dd>
</dl>
<span id="span1" onclick="">clickable span</span>
<span id="span2" onmousedown="">clickable span</span>
<span id="span3" onmouseup="">clickable span</span>
</body>
</html>

View File

@ -1,71 +0,0 @@
<!DOCTYPE html>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=474281
-->
<head>
<title>Name calculation for table and grid cells</title>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<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>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/nsIAccessible_name.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/role.js"></script>
<script type="application/javascript">
function doTests()
{
// Test table cell name and role
testRole("tc", ROLE_CELL);
// Test grid cell.
testRole("gc", ROLE_GRID_CELL);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTests);
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=474281"
title="accessible name of html table cells is incorrectly including descendants">
Mozilla bug 474281</a>
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<table>
<tr>
<td id="tc">
<p>This is a paragraph</p>
<a href="#">This is a link</a>
<ul>
<li>This is a list</li>
</ul>
</td>
</tr>
</table>
<table>
<tr>
<td id="gc" role="gridcell">
<p>This is a paragraph</p>
<a href="#">This is a link</a>
<ul>
<li>This is a list</li>
</ul>
</td>
</tr>
</table>
</body>
</html>