author | Alexander Surkov <surkov.alexander@gmail.com> |
Thu, 20 Jan 2011 16:02:10 +0800 | |
changeset 60922 | de195d1171d6529c988e291d37999db8fa7ee785 |
parent 60921 | d5e9eddf4acd377d3b4475c54c3dd36fd2d96f1a |
child 60923 | 2e8b3179b204581560131a24ae9554424f17e948 |
push id | 18165 |
push user | surkov.alexander@gmail.com |
push date | Thu, 20 Jan 2011 08:02:50 +0000 |
treeherder | mozilla-central@de195d1171d6 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | davidb, blocking2.0Final |
bugs | 625009 |
milestone | 2.0b10pre |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/accessible/src/html/nsHyperTextAccessible.cpp +++ b/accessible/src/html/nsHyperTextAccessible.cpp @@ -2111,18 +2111,22 @@ nsresult nsHyperTextAccessible::Rendered //////////////////////////////////////////////////////////////////////////////// // nsHyperTextAccessible public 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) { if (aInvalidateAfter) mOffsets.RemoveElementsAt(aChildIndex, count); return mOffsets[aChildIndex - 1]; }
--- a/accessible/tests/mochitest/Makefile.in +++ b/accessible/tests/mochitest/Makefile.in @@ -43,16 +43,17 @@ VPATH = @srcdir@ relativesrcdir = accessible DIRS = \ actions \ attributes \ editabletext \ events \ hyperlink \ + hypertext \ name \ relations \ selectable \ states \ table \ text \ tree \ treeupdate \ @@ -96,17 +97,16 @@ include $(topsrcdir)/config/rules.mk $(warning test_elm_media.html temporarily disabled) \ test_elm_nsApplicationAcc.html \ test_elm_plugin.html \ test_keys.html \ $(warning test_nsIAccessible_comboboxes.xul temporarily disabled) \ test_nsIAccessible_selects.html \ test_nsIAccessible_focus.html \ test_nsIAccessibleDocument.html \ - test_nsIAccessibleHyperText.html \ test_nsIAccessibleImage.html \ test_nsIAccessNode_utils.html \ test_nsOuterDocAccessible.html \ test_role_nsHyperTextAcc.html \ test_text_caret.html \ test_textboxes.html \ test_textboxes.xul \ test_value.html \
new file mode 100644 --- /dev/null +++ b/accessible/tests/mochitest/hypertext/Makefile.in @@ -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)
rename from accessible/tests/mochitest/test_nsIAccessibleHyperText.html rename to accessible/tests/mochitest/hypertext/test_general.html --- a/accessible/tests/mochitest/test_nsIAccessibleHyperText.html +++ b/accessible/tests/mochitest/hypertext/test_general.html @@ -8,19 +8,17 @@ https://bugzilla.mozilla.org/show_bug.cg <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> + src="../common.js"></script> <script type="application/javascript"> var gParagraphAcc; function testLinkIndexAtOffset(aID, aOffset, aIndex) { var htAcc = getAccessible(aID, [nsIAccessibleHyperText]); is(htAcc.getLinkIndexAtOffset(aOffset), aIndex, @@ -36,59 +34,16 @@ https://bugzilla.mozilla.org/show_bug.cg var linkIndex = gParagraphAcc.getLinkIndex(linkAcc); is(linkIndex, aExpectedLinkIndex, "Wrong link index for " + aID + "!"); // Just test the link's name to make sure we get the right one. 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 gParagraphAcc = getAccessible("testParagraph", [nsIAccessibleHyperText]); is(gParagraphAcc.linkCount, 7, "Wrong link count for paragraph!"); // normal hyperlink testThis("NormalHyperlink", 14, 0, "Mozilla Foundation"); @@ -133,19 +88,17 @@ https://bugzilla.mozilla.org/show_bug.cg testLinkIndexAtOffset("p4", 1, 1); // 2nd 'mozilla' link testLinkIndexAtOffset("p4", 2, -1); // ' ' of ' te' text node testLinkIndexAtOffset("p4", 3, -1); // 't' of ' te' text node testLinkIndexAtOffset("p4", 5, -1); // 'x' of 'xt ' text node testLinkIndexAtOffset("p4", 7, -1); // ' ' of 'xt ' text node 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(); addA11yLoadEvent(doTest); </script> </head> <body> @@ -189,12 +142,11 @@ https://bugzilla.mozilla.org/show_bug.cg >Empty link:<br ><a id="emptyLink" href=""><img src=""></img></a><br >Link with embedded span<br ><a id="LinkWithSpan" href="http://www.heise.de/"><span lang="de">Heise Online</span></a><br >Named anchor, must not have "linked" state for it to be exposed correctly:<br ><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>
copy from accessible/tests/mochitest/test_nsIAccessibleHyperText.html copy to accessible/tests/mochitest/hypertext/test_update.html --- a/accessible/tests/mochitest/test_nsIAccessibleHyperText.html +++ b/accessible/tests/mochitest/hypertext/test_update.html @@ -1,51 +1,26 @@ <!DOCTYPE html> <html> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=428248 ---> <head> - <title>nsIHyper>TextAccessible chrome tests</title> - <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" /> + <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> + src="../common.js"></script> <script type="application/javascript" - src="events.js"></script> + src="../events.js"></script> <script type="application/javascript"> - var gParagraphAcc; - - function testLinkIndexAtOffset(aID, aOffset, aIndex) - { - var htAcc = getAccessible(aID, [nsIAccessibleHyperText]); - is(htAcc.getLinkIndexAtOffset(aOffset), aIndex, - "Wrong link index at offset " + aOffset + " for ID " + aID + "!"); - } - - function testThis(aID, aCharIndex, aExpectedLinkIndex, aName) - { - testLinkIndexAtOffset(gParagraphAcc, aCharIndex, aExpectedLinkIndex); - - var linkAcc = gParagraphAcc.getLinkAt(aExpectedLinkIndex); - ok(linkAcc, "No accessible for link " + aID + "!"); - - var linkIndex = gParagraphAcc.getLinkIndex(linkAcc); - is(linkIndex, aExpectedLinkIndex, "Wrong link index for " + aID + "!"); - - // Just test the link's name to make sure we get the right one. - 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) ]; @@ -78,123 +53,70 @@ https://bugzilla.mozilla.org/show_bug.cg } 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() { - // Test link count - gParagraphAcc = getAccessible("testParagraph", [nsIAccessibleHyperText]); - is(gParagraphAcc.linkCount, 7, "Wrong link count for paragraph!"); - - // normal hyperlink - testThis("NormalHyperlink", 14, 0, "Mozilla Foundation"); - - // ARIA hyperlink - testThis("AriaHyperlink", 27, 1, "Mozilla Foundation Home"); - - // ARIA hyperlink with status invalid - testThis("InvalidAriaHyperlink", 63, 2, "Invalid link"); - - // image map, but not its link children. They are not part of hypertext. - testThis("imgmap", 76, 3, "b"); - - // empty hyperlink - testThis("emptyLink", 90, 4, null); - - // normal hyperlink with embedded span - testThis("LinkWithSpan", 116, 5, "Heise Online"); - - // Named anchor - testThis("namedAnchor", 193, 6, "This should never be of state_linked"); + gQueue = new eventQueue(); + gQueue.push(new addLinks("p1")); + gQueue.push(new updateText("p2")); - // Paragraph with link - var p2 = getAccessible("p2", [nsIAccessibleHyperText]); - var link = p2.getLinkAt(0); - is(link, p2.getChildAt(0), "Wrong link for p2"); - is(p2.linkCount, 1, "Wrong link count for p2"); - - // getLinkIndexAtOffset, causes the offsets to be cached; - testLinkIndexAtOffset("p4", 0, 0); // 1st 'mozilla' link - testLinkIndexAtOffset("p4", 1, 1); // 2nd 'mozilla' link - testLinkIndexAtOffset("p4", 2, -1); // ' ' of ' te' text node - testLinkIndexAtOffset("p4", 3, -1); // 't' of ' te' text node - testLinkIndexAtOffset("p4", 5, -1); // 'x' of 'xt ' text node - testLinkIndexAtOffset("p4", 7, -1); // ' ' of 'xt ' text node - testLinkIndexAtOffset("p4", 8, 2); // 3d 'mozilla' link - testLinkIndexAtOffset("p4", 9, 2); // the end, latest link - - // the second pass to make sure link indexes are calculated propertly from - // cached offsets. - testLinkIndexAtOffset("p4", 0, 0); // 1st 'mozilla' link - testLinkIndexAtOffset("p4", 1, 1); // 2nd 'mozilla' link - testLinkIndexAtOffset("p4", 2, -1); // ' ' of ' te' text node - testLinkIndexAtOffset("p4", 3, -1); // 't' of ' te' text node - testLinkIndexAtOffset("p4", 5, -1); // 'x' of 'xt ' text node - testLinkIndexAtOffset("p4", 7, -1); // ' ' of 'xt ' text node - 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.waitForExplicitFinish(); addA11yLoadEvent(doTest); </script> </head> <body> <a target="_blank" - title="Create tests for NSIAccessibleHyperlink interface" - href="https://bugzilla.mozilla.org/show_bug.cgi?id=418368"> - Mozilla Bug 418368 + 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> - <a target="_blank" - title="Cache links within hypertext accessible" - href="https://bugzilla.mozilla.org/show_bug.cgi?id=572394"> - Mozilla Bug 572394 - </a> <p id="display"></p> <div id="content" style="display: none"></div> <pre id="test"> </pre> - <p id="testParagraph"><br - >Simple link:<br - ><a id="NormalHyperlink" href="http://www.mozilla.org">Mozilla Foundation</a><br - >ARIA link:<br - ><span id="AriaHyperlink" role="link" - onclick="window.open('http://www.mozilla.org/');" - tabindex="0">Mozilla Foundation Home</span><br - >Invalid, non-focusable hyperlink:<br - ><span id="InvalidAriaHyperlink" role="link" aria-invalid="true" - onclick="window.open('http:/www.mozilla.org/');">Invalid link</span><br - >Image map:<br - ><map name="atoz_map"><area href="http://www.bbc.co.uk/radio4/atoz/index.shtml#b" - coords="17,0,30,14" - alt="b" - shape="rect"></area - ><area href="http://www.bbc.co.uk/radio4/atoz/index.shtml#a" - coords="0,0,13,14" - alt="a" - shape="rect"></area></map - ><img width="447" id="imgmap" - height="15" - usemap="#atoz_map" - src="letters.gif"></img><br - >Empty link:<br - ><a id="emptyLink" href=""><img src=""></img></a><br - >Link with embedded span<br - ><a id="LinkWithSpan" href="http://www.heise.de/"><span lang="de">Heise Online</span></a><br - >Named anchor, must not have "linked" state for it to be exposed correctly:<br - ><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> + + <p id="p1"></p> + <p id="p2"><b>hello</b><a>friend</a></p> </body> </html>