Bug 625009 - text offsets don't get updated when text of first child text accessible is changed, r=davidb, a=blocking2.0Final+

--HG--
rename : accessible/tests/mochitest/test_nsIAccessibleHyperText.html => accessible/tests/mochitest/hypertext/test_general.html
rename : accessible/tests/mochitest/test_nsIAccessibleHyperText.html => accessible/tests/mochitest/hypertext/test_update.html
This commit is contained in:
Alexander Surkov 2011-01-20 16:02:10 +08:00
parent 34436ceb96
commit 8f94a94033
5 changed files with 184 additions and 52 deletions

View File

@ -2116,8 +2116,12 @@ PRInt32
nsHyperTextAccessible::GetChildOffset(PRUint32 aChildIndex,
PRBool aInvalidateAfter)
{
if (aChildIndex == 0)
if (aChildIndex == 0) {
if (aInvalidateAfter)
mOffsets.Clear();
return aChildIndex;
}
PRInt32 count = mOffsets.Length() - aChildIndex;
if (count > 0) {

View File

@ -48,6 +48,7 @@ DIRS = \
editabletext \
events \
hyperlink \
hypertext \
name \
relations \
selectable \
@ -101,7 +102,6 @@ _TEST_FILES =\
test_nsIAccessible_selects.html \
test_nsIAccessible_focus.html \
test_nsIAccessibleDocument.html \
test_nsIAccessibleHyperText.html \
test_nsIAccessibleImage.html \
test_nsIAccessNode_utils.html \
test_nsOuterDocAccessible.html \

View File

@ -0,0 +1,54 @@
#
# ***** 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) 2011
# 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/hypertext
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_TEST_FILES = \
test_general.html \
test_update.html \
$(NULL)
libs:: $(_TEST_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/a11y/$(relativesrcdir)

View File

@ -13,9 +13,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=428248
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="common.js"></script>
<script type="application/javascript"
src="events.js"></script>
src="../common.js"></script>
<script type="application/javascript">
var gParagraphAcc;
@ -41,49 +39,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=428248
is(linkAcc.getAnchor(0).name, aName, "Wrong name for " + aID + "!");
}
const kLinksCount = 128;
function addLinks(aContainerID)
{
this.containerNode = getNode(aContainerID);
this.eventSeq = [
new invokerChecker(EVENT_REORDER, this.containerNode)
];
this.invoke = function addLinks_invoke()
{
for (var jdx = 0; jdx < kLinksCount; jdx++) {
var a = document.createElement("a");
a.setAttribute("href", "mozilla.org");
a.textContent = "mozilla";
this.containerNode.appendChild(a);
var span = document.createElement("span");
span.textContent = " text ";
this.containerNode.appendChild(span);
}
}
this.finalCheck = function addLinks_finalCheck()
{
// getLinkAt and getLinkIndex.
var htAcc = getAccessible(this.containerNode, [nsIAccessibleHyperText]);
for (var jdx = 0; jdx < kLinksCount; jdx++) {
var link = htAcc.getLinkAt(jdx);
ok(link, "No link at index " + jdx + " for '" + aContainerID + "'");
var linkIdx = htAcc.getLinkIndex(link);
is(linkIdx, jdx, "Wrong link index for '" + aContainerID + "'!");
}
}
this.getID = function addLinks_getID()
{
return "Add links for '" + aContainerID + "'";
}
}
var gQueue = null;
function doTest()
{
// Test link count
@ -138,9 +93,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=428248
testLinkIndexAtOffset("p4", 8, 2); // 3d 'mozilla' link
testLinkIndexAtOffset("p4", 9, 2); // the end, latest link
gQueue = new eventQueue();
gQueue.push(new addLinks("p3"));
gQueue.invoke(); // Will call SimpleTest.finish();
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
@ -194,7 +147,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=428248
><a id="namedAnchor" name="named_anchor">This should never be of state_linked</a>
</p>
<p id="p2"><a href="http://mozilla.org">mozilla.org</a></p>
<p id="p3"></p>
<p id="p4"><a href="www">mozilla</a><a href="www">mozilla</a><span> te</span><span>xt </span><a href="www">mozilla</a></p>
</body>
</html>

View File

@ -0,0 +1,122 @@
<!DOCTYPE html>
<html>
<head>
<title>nsIHyper>TextAccessible in dynamic tests</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="../common.js"></script>
<script type="application/javascript"
src="../events.js"></script>
<script type="application/javascript">
const kLinksCount = 128;
function addLinks(aContainerID)
{
this.containerNode = getNode(aContainerID);
this.eventSeq = [
new invokerChecker(EVENT_REORDER, this.containerNode)
];
this.invoke = function addLinks_invoke()
{
for (var jdx = 0; jdx < kLinksCount; jdx++) {
var a = document.createElement("a");
a.setAttribute("href", "mozilla.org");
a.textContent = "mozilla";
this.containerNode.appendChild(a);
var span = document.createElement("span");
span.textContent = " text ";
this.containerNode.appendChild(span);
}
}
this.finalCheck = function addLinks_finalCheck()
{
// getLinkAt and getLinkIndex.
var htAcc = getAccessible(this.containerNode, [nsIAccessibleHyperText]);
for (var jdx = 0; jdx < kLinksCount; jdx++) {
var link = htAcc.getLinkAt(jdx);
ok(link, "No link at index " + jdx + " for '" + aContainerID + "'");
var linkIdx = htAcc.getLinkIndex(link);
is(linkIdx, jdx, "Wrong link index for '" + aContainerID + "'!");
}
}
this.getID = function addLinks_getID()
{
return "Add links for '" + aContainerID + "'";
}
}
function updateText(aContainerID)
{
this.containerNode = getNode(aContainerID);
this.container = getAccessible(this.containerNode, nsIAccessibleHyperText);
this.text = this.container.firstChild.QueryInterface(nsIAccessNode);
this.textNode = this.text.DOMNode;
this.textLen = this.textNode.data.length;
this.eventSeq = [
new invokerChecker(EVENT_TEXT_INSERTED, this.containerNode)
];
this.invoke = function updateText_invoke()
{
is(this.container.getLinkIndexAtOffset(this.textLen), 0,
"Wrong intial text offsets!");
this.text.DOMNode.appendData(" my");
}
this.finalCheck = function updateText_finalCheck()
{
is(this.container.getLinkIndexAtOffset(this.textLen), -1,
"Text offsets weren't updated!");
}
this.getID = function updateText_getID()
{
return "update text for '" + aContainerID + "'";
}
}
var gQueue = null;
function doTest()
{
gQueue = new eventQueue();
gQueue.push(new addLinks("p1"));
gQueue.push(new updateText("p2"));
gQueue.invoke(); // Will call SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
title="Text offsets don't get updated when text of first child text accessible is changed"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=625009">
Mozilla Bug 625009
</a><br>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<p id="p1"></p>
<p id="p2"><b>hello</b><a>friend</a></p>
</body>
</html>