Reviewed by Darin.
http://bugs.webkit.org/show_bug.cgi?id=12359
XPathEvaluator may return some nodes more than once in a result set
Test: fast/xpath/nodeset-duplicates.html
* xml/XPathPath.cpp:
(WebCore::XPath::LocationPath::doEvaluate): Ensure uniqueness of elements
in the node-set.
* xml/XPathPredicate.cpp:
(WebCore::XPath::Union::doEvaluate): Fixed a uniqueness algorithm that was
already present here. Added a FIXME about incorrect result ordering.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@19227 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/fast/xpath/nodeset-duplicates.html b/LayoutTests/fast/xpath/nodeset-duplicates.html
new file mode 100644
index 0000000..cb99c8c
--- /dev/null
+++ b/LayoutTests/fast/xpath/nodeset-duplicates.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+ <body>
+ <p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=12359">bug 12359</a>:
+ XPathEvaluator may return some nodes more than once in a result set.</p>
+
+ <div>
+ <div>
+ <div></div>
+ </div>
+ </div>
+
+ <script type="text/javascript">
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ try {
+ var result = document.evaluate("//div//div | //div/div", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+
+ if (result.snapshotLength == 2)
+ document.write("SUCCESS");
+ else
+ document.write(result.snapshotLength + " matches (should be 2)");
+
+ } catch (ex) {
+ document.write("Exception: " + ex);
+ }
+ </script>
+ </body>
+</html>