Reviewed by Darin.
authorap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Feb 2007 06:06:53 +0000 (06:06 +0000)
committerap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Feb 2007 06:06:53 +0000 (06:06 +0000)
        http://bugs.webkit.org/show_bug.cgi?id=12602
        XPath functions string(), normalize-space() and string-length() don't work
        without arguments

        Test: fast/xpath/implicit-node-args.html

        * xml/XPathFunctions.cpp:
        (WebCore::XPath::FunString::doEvaluate):
        (WebCore::XPath::FunStringLength::doEvaluate):
        (WebCore::XPath::FunNormalizeSpace::doEvaluate):
        Don't try to pass RefPtr<Node> to the Value ctor.

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

LayoutTests/ChangeLog
LayoutTests/fast/xpath/implicit-node-args-expected.txt [new file with mode: 0644]
LayoutTests/fast/xpath/implicit-node-args.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/xml/XPathFunctions.cpp

index 74c6663..58f190e 100644 (file)
@@ -2,6 +2,18 @@
 
         Reviewed by Darin.
 
+        http://bugs.webkit.org/show_bug.cgi?id=12602
+        XPath functions string(), normalize-space() and string-length() don't work
+        without arguments
+
+        * fast/xpath/implicit-node-args-expected.txt: Added.
+        * fast/xpath/implicit-node-args.html: Added.
+        Some cases in the test are commented out for now due to bug 12603.
+
+2007-02-04  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Darin.
+
         http://bugs.webkit.org/show_bug.cgi?id=8791
         XPath should support custom node resolvers
 
diff --git a/LayoutTests/fast/xpath/implicit-node-args-expected.txt b/LayoutTests/fast/xpath/implicit-node-args-expected.txt
new file mode 100644 (file)
index 0000000..bf30d1d
--- /dev/null
@@ -0,0 +1,4 @@
+Test for bug 12602:
+
+//div[string() = '123']: SUCCESS
+
diff --git a/LayoutTests/fast/xpath/implicit-node-args.html b/LayoutTests/fast/xpath/implicit-node-args.html
new file mode 100644 (file)
index 0000000..5e4493d
--- /dev/null
@@ -0,0 +1,26 @@
+<html>
+  <body>
+    <div style="display:none">123</div>
+    <p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=12602">bug 12602</a>:
+    </p>
+    <script>
+        if (window.layoutTestController)
+            layoutTestController.dumpAsText();
+
+// The commented out cases cause a crash; see <http://bugs.webkit.org/show_bug.cgi?id=12603>.
+        var tests = [
+              "//div[string() = '123']"
+//            , "//div[normalize-space() = '123']"
+//            , "//div[string-length() = 3]"
+        ];
+
+        while (test = tests.pop()) {
+            var result = document.evaluate(test, document.documentElement, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+            if (result.snapshotLength == 1)
+                document.write("<pre>" + test + ": SUCCESS</pre>");
+            else
+                document.write("<pre>" + test + ": FAILURE. " + result.snapshotLength + " node(s) matched - should be 1</pre>");
+        }
+    </script>
+  </body>
+</html>
index 574f359..cb837ea 100644 (file)
@@ -2,6 +2,22 @@
 
         Reviewed by Darin.
 
+        http://bugs.webkit.org/show_bug.cgi?id=12602
+        XPath functions string(), normalize-space() and string-length() don't work
+        without arguments
+
+        Test: fast/xpath/implicit-node-args.html
+
+        * xml/XPathFunctions.cpp:
+        (WebCore::XPath::FunString::doEvaluate):
+        (WebCore::XPath::FunStringLength::doEvaluate):
+        (WebCore::XPath::FunNormalizeSpace::doEvaluate):
+        Don't try to pass RefPtr<Node> to the Value ctor.
+
+2007-02-04  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Darin.
+
         http://bugs.webkit.org/show_bug.cgi?id=8791
         XPath should support custom node resolvers
 
index 82a5acb..50d32d1 100644 (file)
@@ -440,7 +440,7 @@ bool FunCount::isConstant() const
 Value FunString::doEvaluate() const
 {
     if (argCount() == 0)
-        return Value(Expression::evaluationContext().node).toString();
+        return Value(Expression::evaluationContext().node.get()).toString();
     return arg(0)->evaluate().toString();
 }
 
@@ -532,14 +532,14 @@ Value FunSubstring::doEvaluate() const
 Value FunStringLength::doEvaluate() const
 {
     if (argCount() == 0)
-        return Value(Expression::evaluationContext().node).toString().length();
+        return Value(Expression::evaluationContext().node.get()).toString().length();
     return arg(0)->evaluate().toString().length();
 }
 
 Value FunNormalizeSpace::doEvaluate() const
 {
     if (argCount() == 0) {
-        String s = Value(Expression::evaluationContext().node).toString();
+        String s = Value(Expression::evaluationContext().node.get()).toString();
         return Value(s.simplifyWhiteSpace());
     }