diff --git a/content/base/src/nsTreeWalker.cpp b/content/base/src/nsTreeWalker.cpp index 973c3f61d302..4b2132cef6de 100644 --- a/content/base/src/nsTreeWalker.cpp +++ b/content/base/src/nsTreeWalker.cpp @@ -180,6 +180,8 @@ NS_IMETHODIMP nsTreeWalker::SetCurrentNode(nsIDOMNode * aCurrentNode) NS_ENSURE_SUCCESS(rv, rv); mCurrentNode = do_QueryInterface(aCurrentNode); + mPossibleIndexes.Clear(); + mPossibleIndexesPos = -1; return NS_OK; } diff --git a/content/base/src/nsTreeWalker.h b/content/base/src/nsTreeWalker.h index 707cc9a0e5cc..b88f4b2a246f 100644 --- a/content/base/src/nsTreeWalker.h +++ b/content/base/src/nsTreeWalker.h @@ -181,8 +181,9 @@ private: */ void SetChildIndex(PRInt32 aIndexPos, PRInt32 aChildIndex) { - mPossibleIndexes.ReplaceElementAt(NS_INT32_TO_PTR(aChildIndex), - aIndexPos); + if (aIndexPos != -1) + mPossibleIndexes.ReplaceElementAt(NS_INT32_TO_PTR(aChildIndex), + aIndexPos); } }; diff --git a/content/base/test/Makefile.in b/content/base/test/Makefile.in index e6f4f340fa5e..f5cf998d396d 100644 --- a/content/base/test/Makefile.in +++ b/content/base/test/Makefile.in @@ -88,6 +88,7 @@ _TEST_FILES = test_bug5141.html \ test_bug372086.html \ test_bug373181.xhtml \ test_bug375314.html \ + test_bug378969.html \ test_bug382113.html \ test_bug390219.html \ test_bug390735.html \ diff --git a/content/base/test/test_bug378969.html b/content/base/test/test_bug378969.html new file mode 100644 index 000000000000..201564177605 --- /dev/null +++ b/content/base/test/test_bug378969.html @@ -0,0 +1,48 @@ + + + +
++ ++ + + diff --git a/content/test/unit/test_treewalker.js b/content/test/unit/test_treewalker.js new file mode 100644 index 000000000000..e5958dfcf13a --- /dev/null +++ b/content/test/unit/test_treewalker.js @@ -0,0 +1,59 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** 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 DOM Tree Walker test code. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Alexander Surkov