Bug 726097 - Use the right doc accessible when hit testing. Add proper mochi-test. r=surkov

--HG--
rename : accessible/tests/mochitest/test_childAtPoint.html => accessible/tests/mochitest/hittest/test_general.html
rename : accessible/tests/mochitest/test_childAtPoint.xul => accessible/tests/mochitest/hittest/test_general.xul
This commit is contained in:
Hub Figuière 2012-02-15 13:51:04 -08:00
Родитель 61d3b82ba7
Коммит 0698516eb4
6 изменённых файлов: 128 добавлений и 9 удалений

Просмотреть файл

@ -851,7 +851,9 @@ nsAccessible::ChildAtPoint(PRInt32 aX, PRInt32 aY,
// Get accessible for the node with the point or the first accessible in
// the DOM parent chain.
nsAccessible* accessible = accDocument->GetAccessibleOrContainer(content);
nsDocAccessible* contentDocAcc = GetAccService()->
GetDocAccessible(content->OwnerDoc());
nsAccessible* accessible = contentDocAcc->GetAccessibleOrContainer(content);
if (!accessible)
return fallbackAnswer;

Просмотреть файл

@ -49,6 +49,7 @@ DIRS = \
elm \
events \
focus \
hittest \
hyperlink \
hypertext \
name \
@ -96,8 +97,6 @@ _TEST_FILES =\
test_aria_roles.xul \
test_aria_token_attrs.html \
test_bug420863.html \
test_childAtPoint.html \
test_childAtPoint.xul \
test_descr.html \
test_nsIAccessibleDocument.html \
test_nsIAccessibleImage.html \

Просмотреть файл

@ -0,0 +1,55 @@
#
# ***** 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 Foundation.
# Portions created by the Initial Developer are Copyright (C) 2012
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Hubert Figuière <hub@mozilla.com>
#
# 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/hittest
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_TEST_FILES = \
test_general.html \
test_general.xul \
test_browser.html \
$(NULL)
libs:: $(_TEST_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/a11y/$(relativesrcdir)

Просмотреть файл

@ -0,0 +1,64 @@
<!DOCTYPE html>
<html>
<head>
<title>nsIAccessible::childAtPoint() from browser tests</title>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="../common.js"></script>
<script type="application/javascript"
src="../layout.js"></script>
<script type="application/javascript">
function doTest()
{
// Hit testing. See bug #726097
var nodeObj = { value: null };
var hititem = getAccessible("hititem", null, nodeObj);
var [deltaX, deltaY] = getScreenCoords(nodeObj.value);
var hittest = getAccessible("hittest");
var hitX = {}, hitY = {}, hitWidth = {}, hitHeight = {};
hititem.getBounds(hitX, hitY, hitWidth, hitHeight);
var tgtX = deltaX + (hitWidth.value / 2);
var tgtY = deltaY + (hitHeight.value / 2);
var rootAcc = getRootAccessible();
var docAcc = getAccessible(document);
var outerDocAcc = docAcc.parent;
var hitAcc = rootAcc.getDeepestChildAtPoint(tgtX, tgtY);
is(hitAcc, hititem, "Hit match at " + tgtX + "," + tgtY +
". Found: " + prettyName(hitAcc));
var hitAcc2 = docAcc.getDeepestChildAtPoint(tgtX, tgtY);
is(hitAcc, hitAcc2, "Hit match at " + tgtX + "," + tgtY +
". Found: " + prettyName(hitAcc2));
hitAcc = outerDocAcc.getChildAtPoint(tgtX, tgtY);
is(hitAcc, docAcc, "Hit match at " + tgtX + "," + tgtY +
". Found: " + prettyName(hitAcc));
hitAcc = docAcc.getChildAtPoint(tgtX, tgtY);
is(hitAcc, hittest, "Hit match at " + tgtX + "," + tgtY +
". Found: " + prettyName(hitAcc));
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=726097"
title="nsIAccessible::childAtPoint() from browser tests">Mozilla Bug 726097</a>
<div id="hittest">
<div id="hititem"><span role="image">img</span>item</div>
</div>
</body>
</html>

Просмотреть файл

@ -8,9 +8,9 @@
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="common.js"></script>
src="../common.js"></script>
<script type="application/javascript"
src="layout.js"></script>
src="../layout.js"></script>
<script type="application/javascript">
function doTest()
@ -85,6 +85,5 @@
<div id="outofflow" style="width: 10px; height: 10px; position: absolute; left: 0px; top: 0px; background-color: yellow;">
</div>
<div id="area" style="width: 100px; height: 100px; background-color: blue;"></div>
</body>
</html>

Просмотреть файл

@ -10,12 +10,12 @@
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
<script type="application/javascript"
src="treeview.js" />
src="../treeview.js" />
<script type="application/javascript"
src="common.js" />
src="../common.js" />
<script type="application/javascript"
src="layout.js" />
src="../layout.js" />
<script type="application/javascript">
<![CDATA[