Reviewed by Adele.
authorap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Mar 2007 05:39:34 +0000 (05:39 +0000)
committerap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Mar 2007 05:39:34 +0000 (05:39 +0000)
        http://bugs.webkit.org/show_bug.cgi?id=12560
        W3C XPath test Text_Nodes.svg fails

WebCore:
        * xml/XPathStep.cpp:
        (WebCore::XPath::Step::nodeTestMatches): Revert the fix, as the behavior doesn't appear
        all that desirable as it did at first glance.

LayoutTests:
        * dom/svg/level3/xpath/Text_Nodes-expected.txt: This fails again.

        * fast/xpath/4XPath/Borrowed/kd_20010423-expected.txt:
        * fast/xpath/4XPath/Borrowed/kd_20010423.html:
        Brought the test back to its original form (in which Firefox passes).

        * fast/xpath/text-nodes-expected.txt: Added.
        * fast/xpath/text-nodes.html: Added.
        A new test for text nodes, verifying some more arcane cases.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@20110 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/dom/svg/level3/xpath/Text_Nodes-expected.txt
LayoutTests/fast/xpath/4XPath/Borrowed/kd_20010423-expected.txt
LayoutTests/fast/xpath/4XPath/Borrowed/kd_20010423.html
LayoutTests/fast/xpath/text-nodes-expected.txt [new file with mode: 0644]
LayoutTests/fast/xpath/text-nodes.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/xml/XPathStep.cpp

index db612da9a534db92ce4345f3b620d8f0963ba78f..1036aa2cf34eb5f5031d0ac2dac6dead45daad39 100644 (file)
@@ -7,6 +7,23 @@
         * fast/events/content-changed-during-drop-expected.txt: Added.
         * fast/events/content-changed-during-drop.html: Added.
 
+2007-03-11  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Adele.
+
+        http://bugs.webkit.org/show_bug.cgi?id=12560
+        W3C XPath test Text_Nodes.svg fails
+
+        * dom/svg/level3/xpath/Text_Nodes-expected.txt: This fails again.
+
+        * fast/xpath/4XPath/Borrowed/kd_20010423-expected.txt:
+        * fast/xpath/4XPath/Borrowed/kd_20010423.html:
+        Brought the test back to its original form (in which Firefox passes).
+
+        * fast/xpath/text-nodes-expected.txt: Added.
+        * fast/xpath/text-nodes.html: Added.
+        A new test for text nodes, verifying some more arcane cases.
+
 2007-03-11  Alexey Proskuryakov  <ap@webkit.org>
 
         Reviewed by Darin.
index 62f9fece9535be3b3c33bc83f5171b4b00d8e071..f0a4a6709cd2ab7c99b4111c295dff465971d564 100644 (file)
@@ -1 +1,2 @@
-Text_Nodes: Success
+Text_Nodes
+S1.2.4-Text-Nodes-Adjacent-Next: assertTrue failed
index 528ae102aeecc944179d8b18819d91722ef88ab1..b4bf046253432fa7edba7c758ef0c00da078895f 100644 (file)
@@ -1,4 +1,4 @@
-PASS actual is "abcabca"
+PASS actual is "abcabcabc"
 PASS successfullyParsed is true
 
 TEST COMPLETE
index c5c68b2f99cd6107ed10a458492a847d187364b8..6a80e2bfe5d49c5bf9fa8223c423cf3b5496949c 100644 (file)
@@ -24,8 +24,9 @@ SRC_1 = '<?xml version="1.0" encoding="utf-8"?>\
     while (currNode = nodeset.iterateNext())
         actual += currNode.nodeValue;
     
-    // In the original 4Suite test, the expectation was "abcabcabc". I believe it was wrong.
-    shouldBe('actual', '"abcabca"')
+    // According to DOM XPath working group note, this should be "abcabca", but we'll rather match Firefox.
+    // See <http://www.w3.org/TR/DOM-Level-3-XPath/xpath.html#TextNodes>.
+    shouldBe('actual', '"abcabcabc"')
 
     var successfullyParsed = true;
 
diff --git a/LayoutTests/fast/xpath/text-nodes-expected.txt b/LayoutTests/fast/xpath/text-nodes-expected.txt
new file mode 100644 (file)
index 0000000..49880e8
--- /dev/null
@@ -0,0 +1,26 @@
+<doc><elem>a<![CDATA[b]]>c</elem></doc>
+child::*, [object Element]: ""
+child::node(), [object Element]: "a b c"
+descendant::*, [object Element]: ""
+descendant::node(), [object Element]: "a b c"
+descendant::node()[2], [object Element]: "b"
+ancestor-or-self::node(), b: "b null null null"
+ancestor-or-self::*, b: "null null"
+ancestor-or-self::node(), a: "a null null null"
+ancestor-or-self::*, a: "null null"
+following::node(), [object Element]: ""
+following::node(), a: "b c"
+following::text(), a: "b c"
+following::node(), b: "c"
+following-sibling::node(), [object Element]: ""
+following-sibling::node(), a: "b c"
+following-sibling::text(), a: "b c"
+following-sibling::node(), b: "c"
+preceding::node(), b: "a"
+preceding-sibling::node(), b: "a"
+preceding::node(), c: "b a"
+preceding::text(), c: "b a"
+preceding-sibling::node(), c: "b a"
+preceding-sibling::text(), c: "b a"
+self::node(), b: "b"
+
diff --git a/LayoutTests/fast/xpath/text-nodes.html b/LayoutTests/fast/xpath/text-nodes.html
new file mode 100644 (file)
index 0000000..10ce9f3
--- /dev/null
@@ -0,0 +1,56 @@
+<body>
+<script>
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+
+    src = '<doc><elem>a<![CDATA[b]]>c</elem></doc>';
+    doc = (new DOMParser).parseFromString(src, "application/xml");
+
+    elem = doc.documentElement.firstChild;
+    aText = elem.firstChild;
+    bText = elem.firstChild.nextSibling;
+    cText = elem.lastChild;
+
+    function test(expr, context) {
+        nodeset = doc.evaluate(expr, context, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
+        str = "";
+        while (currNode = nodeset.iterateNext()) {
+            if (str)
+                str += " ";
+            str += currNode.nodeValue;
+        }
+        
+        document.write(expr + ", " + (context.nodeValue ? context.nodeValue : context) + ": \"" + str + "\"<br>");
+    }
+
+    document.write("<xmp>" + src + "</xmp>");
+
+    test("child::*", elem);
+    test("child::node()", elem);
+    test("descendant::*", elem);
+    test("descendant::node()", elem);
+    test("descendant::node()[2]", elem);
+    test("ancestor-or-self::node()", bText); // the order of result nodes is incorrect in this test
+    test("ancestor-or-self::*", bText);
+    test("ancestor-or-self::node()", aText); // the order of result nodes is incorrect in this test
+    test("ancestor-or-self::*", aText);
+    test("following::node()", elem);
+    test("following::node()", aText);
+    test("following::text()", aText);
+    test("following::node()", bText);
+    test("following-sibling::node()", elem);
+    test("following-sibling::node()", aText);
+    test("following-sibling::text()", aText);
+    test("following-sibling::node()", bText);
+    test("preceding::node()", bText);
+    test("preceding-sibling::node()", bText);
+    test("preceding::node()", cText); // the order of result nodes is incorrect in this test
+    test("preceding::text()", cText); // the order of result nodes is incorrect in this test
+    test("preceding-sibling::node()", cText); // the order of result nodes is incorrect in this test
+    test("preceding-sibling::text()", cText); // the order of result nodes is incorrect in this test
+    test("self::node()", bText);
+
+    var successfullyParsed = true;
+
+</script>
+</body>
index 82d43639a1e46a088302d4778dade705818c213c..e9365cd979fcb430f8664cf802dded70c8850ae5 100644 (file)
@@ -1,3 +1,14 @@
+2007-03-11  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Adele.
+
+        http://bugs.webkit.org/show_bug.cgi?id=12560
+        W3C XPath test Text_Nodes.svg fails
+
+        * xml/XPathStep.cpp:
+        (WebCore::XPath::Step::nodeTestMatches): Revert the fix, as the behavior doesn't appear 
+        all that desirable as it did at first glance.
+
 2007-03-11  Oliver Hunt  <oliver@apple.com>
 
         Reviewed by hyatt.
index b33972a00bbb98ade75fdd54aeb4a004fb647fbb..d03cac69ba9d39e049c0c8f4247ffb48bca56fd3 100644 (file)
@@ -183,18 +183,13 @@ NodeVector Step::nodeTestMatches(const NodeVector& nodes) const
     NodeVector matches;
 
     switch (m_nodeTest.kind()) {
-        case NodeTest::TextNodeTest: {
-            HashSet<Node*> nodeSet;
+        case NodeTest::TextNodeTest:
             for (unsigned i = 0; i < nodes.size(); i++) {
                 Node* node = nodes[i].get();
-                if ((node->nodeType() == Node::TEXT_NODE || node->nodeType() == Node::CDATA_SECTION_NODE)) {
-                    nodeSet.add(node);
-                    if (!nodeSet.contains(node->previousSibling())) // See <http://www.w3.org/TR/DOM-Level-3-XPath/xpath.html#TextNodes>
-                        matches.append(node);
-                }
+                if ((node->nodeType() == Node::TEXT_NODE || node->nodeType() == Node::CDATA_SECTION_NODE))
+                    matches.append(node);
             }
             return matches;
-        }
         case NodeTest::CommentNodeTest:
             for (unsigned i = 0; i < nodes.size(); i++) {
                 Node* node = nodes[i].get();