Reviewed by Darin.
authorap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Mar 2007 18:32:11 +0000 (18:32 +0000)
committerap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Mar 2007 18:32:11 +0000 (18:32 +0000)
        http://bugs.webkit.org/show_bug.cgi?id=12953
        Import/convert 4XPath test suite

        Import the rest of the converted suite. The only remaining failures are due to
        incorrect node order, bug 12497.

        * fast/xpath/4XPath/Core/test_literal_expr.html: Added.
        * fast/xpath/4XPath/Core/test_location_path.html: Added.
        * fast/xpath/4XPath/Core/test_node_test.html: Added.
        * fast/xpath/4XPath/Core/test_nodeset_expr.html: Added.
        * fast/xpath/4XPath/Core/test_parser-expected.txt: Added.
        * fast/xpath/4XPath/Core/test_parser.html: Added.
        * fast/xpath/4XPath/Core/test_predicate_list.html: Added.
        * fast/xpath/4XPath/Core/test_step-expected.txt: Added.
        * fast/xpath/4XPath/Core/test_step.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/xpath/4XPath/Core/test_literal_expr.html [new file with mode: 0644]
LayoutTests/fast/xpath/4XPath/Core/test_location_path.html [new file with mode: 0644]
LayoutTests/fast/xpath/4XPath/Core/test_node_test.html [new file with mode: 0644]
LayoutTests/fast/xpath/4XPath/Core/test_nodeset_expr.html [new file with mode: 0644]
LayoutTests/fast/xpath/4XPath/Core/test_parser-expected.txt [new file with mode: 0644]
LayoutTests/fast/xpath/4XPath/Core/test_parser.html [new file with mode: 0644]
LayoutTests/fast/xpath/4XPath/Core/test_predicate_list.html [new file with mode: 0644]
LayoutTests/fast/xpath/4XPath/Core/test_step-expected.txt [new file with mode: 0644]
LayoutTests/fast/xpath/4XPath/Core/test_step.html [new file with mode: 0644]

index 93197ae..ae16318 100644 (file)
@@ -1,3 +1,23 @@
+2007-03-07  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Darin.
+
+        http://bugs.webkit.org/show_bug.cgi?id=12953
+        Import/convert 4XPath test suite
+
+        Import the rest of the converted suite. The only remaining failures are due to
+        incorrect node order, bug 12497.
+
+        * fast/xpath/4XPath/Core/test_literal_expr.html: Added.
+        * fast/xpath/4XPath/Core/test_location_path.html: Added.
+        * fast/xpath/4XPath/Core/test_node_test.html: Added.
+        * fast/xpath/4XPath/Core/test_nodeset_expr.html: Added.
+        * fast/xpath/4XPath/Core/test_parser-expected.txt: Added.
+        * fast/xpath/4XPath/Core/test_parser.html: Added.
+        * fast/xpath/4XPath/Core/test_predicate_list.html: Added.
+        * fast/xpath/4XPath/Core/test_step-expected.txt: Added.
+        * fast/xpath/4XPath/Core/test_step.html: Added.
+
 2007-03-07  David Kilzer  <ddkilzer@webkit.org>
 
         Reviewed by Darin.
diff --git a/LayoutTests/fast/xpath/4XPath/Core/test_literal_expr.html b/LayoutTests/fast/xpath/4XPath/Core/test_literal_expr.html
new file mode 100644 (file)
index 0000000..16f0754
--- /dev/null
@@ -0,0 +1,56 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../../js/resources/js-test-style.css">
+<script src="../../../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<div id="console"></div>
+
+<script>
+    shouldBe('document.evaluate(\'""\', document, null, XPathResult.STRING_TYPE, null).stringValue', '""');
+    shouldBe('document.evaluate(\'"Hi"\', document, null, XPathResult.STRING_TYPE, null).stringValue', '"Hi"');
+    shouldBe('document.evaluate(\'"NaN"\', document, null, XPathResult.STRING_TYPE, null).stringValue', '"NaN"');
+    shouldBe('document.evaluate(\'"\u2022 = middle dot"\', document, null, XPathResult.STRING_TYPE, null).stringValue', '"\u2022 = middle dot"');
+    shouldBe('document.evaluate(\'"0"\', document, null, XPathResult.STRING_TYPE, null).stringValue', '"0"');
+    shouldBe('document.evaluate(\'"1"\', document, null, XPathResult.STRING_TYPE, null).stringValue', '"1"');
+    shouldBe('document.evaluate(\'"2"\', document, null, XPathResult.STRING_TYPE, null).stringValue', '"2"');
+    shouldBe('document.evaluate(\'"3"\', document, null, XPathResult.STRING_TYPE, null).stringValue', '"3"');
+    shouldBe('document.evaluate(\'"4"\', document, null, XPathResult.STRING_TYPE, null).stringValue', '"4"');
+    shouldBe('document.evaluate(\'"5"\', document, null, XPathResult.STRING_TYPE, null).stringValue', '"5"');
+    shouldBe('document.evaluate(\'"31"\', document, null, XPathResult.STRING_TYPE, null).stringValue', '"31"');
+    shouldBe('document.evaluate(\'"-1"\', document, null, XPathResult.STRING_TYPE, null).stringValue', '"-1"');
+    shouldBe('document.evaluate(\'"-2"\', document, null, XPathResult.STRING_TYPE, null).stringValue', '"-2"');
+    shouldBe('document.evaluate(\'"-3"\', document, null, XPathResult.STRING_TYPE, null).stringValue', '"-3"');
+    shouldBe('document.evaluate(\'"-4"\', document, null, XPathResult.STRING_TYPE, null).stringValue', '"-4"');
+    shouldBe('document.evaluate(\'"-5"\', document, null, XPathResult.STRING_TYPE, null).stringValue', '"-5"');
+    shouldBe('document.evaluate(\'"3.1415926535"\', document, null, XPathResult.STRING_TYPE, null).stringValue', '"3.1415926535"');
+
+    shouldBe('document.evaluate(\'0\', document, null, XPathResult.NUMBER_TYPE, null).numberValue', '0.0');
+    shouldBe('document.evaluate(\'0.5\', document, null, XPathResult.NUMBER_TYPE, null).numberValue', '0.5');
+    shouldBe('document.evaluate(\'-0.5\', document, null, XPathResult.NUMBER_TYPE, null).numberValue', '-0.5');
+    shouldBe('document.evaluate(\'1\', document, null, XPathResult.NUMBER_TYPE, null).numberValue', '1.0');
+    shouldBe('document.evaluate(\'-1\', document, null, XPathResult.NUMBER_TYPE, null).numberValue', '-1.0');
+    shouldBe('document.evaluate(\'1.5\', document, null, XPathResult.NUMBER_TYPE, null).numberValue', '1.5');
+    shouldBe('document.evaluate(\'-1.5\', document, null, XPathResult.NUMBER_TYPE, null).numberValue', '-1.5');
+    shouldBe('document.evaluate(\'2\', document, null, XPathResult.NUMBER_TYPE, null).numberValue', '2.0');
+    shouldBe('document.evaluate(\'-2\', document, null, XPathResult.NUMBER_TYPE, null).numberValue', '-2.0');
+    shouldBe('document.evaluate(\'2.6\', document, null, XPathResult.NUMBER_TYPE, null).numberValue', '2.6');
+    shouldBe('document.evaluate(\'-2.6\', document, null, XPathResult.NUMBER_TYPE, null).numberValue', '-2.6');
+    shouldBe('document.evaluate(\'3\', document, null, XPathResult.NUMBER_TYPE, null).numberValue', '3.0');
+    shouldBe('document.evaluate(\'-3\', document, null, XPathResult.NUMBER_TYPE, null).numberValue', '-3.0');
+    shouldBe('document.evaluate(\'31\', document, null, XPathResult.NUMBER_TYPE, null).numberValue', '31.0');
+    shouldBe('document.evaluate(\'4\', document, null, XPathResult.NUMBER_TYPE, null).numberValue', '4.0');
+    shouldBe('document.evaluate(\'-4\', document, null, XPathResult.NUMBER_TYPE, null).numberValue', '-4.0');
+    shouldBe('document.evaluate(\'4.5\', document, null, XPathResult.NUMBER_TYPE, null).numberValue', '4.5');
+    shouldBe('document.evaluate(\'-4.5\', document, null, XPathResult.NUMBER_TYPE, null).numberValue', '-4.5');
+    shouldBe('document.evaluate(\'5\', document, null, XPathResult.NUMBER_TYPE, null).numberValue', '5.0');
+    shouldBe('document.evaluate(\'-5\', document, null, XPathResult.NUMBER_TYPE, null).numberValue', '-5.0');
+    shouldBe('document.evaluate(\'-42\', document, null, XPathResult.NUMBER_TYPE, null).numberValue', '-42.0');
+
+    var successfullyParsed = true;
+
+</script>
+<script src="../../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/xpath/4XPath/Core/test_location_path.html b/LayoutTests/fast/xpath/4XPath/Core/test_location_path.html
new file mode 100644 (file)
index 0000000..38634d2
--- /dev/null
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../../js/resources/js-test-style.css">
+<script src="../../../js/resources/js-test-pre.js"></script>
+<script src="test.js"></script>
+</head>
+<body>
+<div id="console"></div>
+
+<script>
+    result = DOM.evaluate("//*", CHILD2, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("//*", result, [ROOT, CHILD1].concat(GCHILDREN1, [CHILD2], GCHILDREN2, [CHILD3, LANG], LCHILDREN));
+
+    result = DOM.evaluate("*/*", ROOT, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("*/*", result, GCHILDREN1.concat(GCHILDREN2, LCHILDREN));
+
+    result = DOM.evaluate("/", CHILD1, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("/", result, [DOM]);
+
+    result = DOM.evaluate("/child::*", CHILD2, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("/child::*", result, [ROOT]);
+
+    result = DOM.evaluate("child::*/child::*", ROOT, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("child::*/child::*", result, GCHILDREN1.concat(GCHILDREN2, LCHILDREN));
+
+    var successfullyParsed = true;
+
+</script>
+<script src="../../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/xpath/4XPath/Core/test_node_test.html b/LayoutTests/fast/xpath/4XPath/Core/test_node_test.html
new file mode 100644 (file)
index 0000000..b20eb95
--- /dev/null
@@ -0,0 +1,63 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../../js/resources/js-test-style.css">
+<script src="../../../js/resources/js-test-pre.js"></script>
+<script src="test.js"></script>
+</head>
+<body>
+<div id="console"></div>
+
+<script>
+    function nsResolver(prefix) {
+        if (prefix == 'bar')
+            return 'http://foo.com';
+        return null;
+    }
+
+    function nodeInResult(node, result) {
+        for (i=0; i < result.snapshotLength; ++i)
+            if (result.snapshotItem(i) == node)
+                return true;
+        return false;
+    }
+
+    result = DOM.evaluate("//*", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    shouldBe("nodeInResult(ROOT, result)", "true");
+
+    result = DOM.evaluate("//bar:CHILD3", ROOT, nsResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    shouldBe("nodeInResult(ROOT, result)", "false");
+    shouldBe("nodeInResult(CHILD1, result)", "false");
+    shouldBe("nodeInResult(CHILD3, result)", "true");
+
+    result = DOM.evaluate("//bar:*", ROOT, nsResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    shouldBe("nodeInResult(ROOT, result)", "false");
+    shouldBe("nodeInResult(CHILD1, result)", "false");
+    shouldBe("nodeInResult(CHILD3, result)", "true");
+
+    result = DOM.evaluate("//node()", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    shouldBe("nodeInResult(ROOT, result)", "true");
+    shouldBe("nodeInResult(TEXT1, result)", "true");
+
+    result = DOM.evaluate("//text()", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    shouldBe("nodeInResult(ROOT, result)", "false");
+    shouldBe("nodeInResult(TEXT1, result)", "true");
+
+    result = DOM.evaluate("//comment()", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    shouldBe("nodeInResult(ROOT, result)", "false");
+    shouldBe("nodeInResult(COMMENT, result)", "true");
+
+    result = DOM.evaluate("//processing-instruction()", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    shouldBe("nodeInResult(ROOT, result)", "false");
+    shouldBe("nodeInResult(PI, result)", "true");
+
+    result = DOM.evaluate("//processing-instruction('xml-stylesheet')", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    shouldBe("nodeInResult(PI, result)", "true");
+    shouldBe("nodeInResult(PI2, result)", "false");
+
+    var successfullyParsed = true;
+
+</script>
+<script src="../../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/xpath/4XPath/Core/test_nodeset_expr.html b/LayoutTests/fast/xpath/4XPath/Core/test_nodeset_expr.html
new file mode 100644 (file)
index 0000000..e94a32f
--- /dev/null
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../../js/resources/js-test-style.css">
+<script src="../../../js/resources/js-test-pre.js"></script>
+<script src="test.js"></script>
+</head>
+<body>
+<div id="console"></div>
+
+<script>
+    result = DOM.evaluate("(/ROOT | /ROOT/CHILD1)[true()]", CHILD1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("(/ROOT | /ROOT/CHILD1)[true()]", result, [ROOT, CHILD1]);
+
+    result = DOM.evaluate("(/ROOT | /ROOT/CHILD1)[.=/ROOT]", CHILD1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("(/ROOT | /ROOT/CHILD1)[.=/ROOT]", result, [ROOT]);
+
+    result = DOM.evaluate("(/ROOT | /ROOT/CHILD1) | (/ROOT)", CHILD1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("(/ROOT | /ROOT/CHILD1) | (/ROOT)", result, [ROOT, CHILD1]);
+
+    var successfullyParsed = true;
+
+</script>
+<script src="../../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/xpath/4XPath/Core/test_parser-expected.txt b/LayoutTests/fast/xpath/4XPath/Core/test_parser-expected.txt
new file mode 100644 (file)
index 0000000..8aa7b8b
--- /dev/null
@@ -0,0 +1,45 @@
+PASS child::*
+PASS /child::*
+PASS /*/*
+PASS /child::*/*/child::GCHILD
+FAIL //* item 2 incorrect (expected GCHILD, actual CHILD2)
+PASS //GCHILD
+PASS //@attr1
+PASS x:GCHILD
+PASS .//GCHILD
+PASS .//GCHILD
+PASS /
+PASS //CHILD1/..
+PASS .//foo:*
+PASS CHILD1 | CHILD2
+PASS descendant::GCHILD[3]
+PASS descendant::GCHILD[parent::CHILD1]
+PASS descendant::GCHILD[position() > 1]
+PASS @attr1[.='val1']
+PASS DOM.evaluate("1", ROOT, null, XPathResult.ANY_TYPE, null).numberValue is 1
+PASS DOM.evaluate("00200", ROOT, null, XPathResult.ANY_TYPE, null).numberValue is 200
+PASS DOM.evaluate("3+4*7", ROOT, null, XPathResult.ANY_TYPE, null).numberValue is 31
+PASS DOM.evaluate("3-4*1", ROOT, null, XPathResult.ANY_TYPE, null).numberValue is -1
+PASS DOM.evaluate("string('1')", ROOT, null, XPathResult.ANY_TYPE, null).stringValue is '1'
+PASS DOM.evaluate("concat('1', '2')", ROOT, null, XPathResult.ANY_TYPE, null).stringValue is '12'
+PASS DOM.evaluate("true()", ROOT, null, XPathResult.ANY_TYPE, null).booleanValue is true
+PASS DOM.evaluate("false()", ROOT, null, XPathResult.ANY_TYPE, null).booleanValue is false
+PASS DOM.evaluate("1=3<4", ROOT, null, XPathResult.ANY_TYPE, null).booleanValue is true
+PASS DOM.evaluate("1 or 2 and 3", ROOT, null, XPathResult.ANY_TYPE, null).booleanValue is true
+PASS DOM.evaluate("1 and 2 = 3", ROOT, null, XPathResult.ANY_TYPE, null).booleanValue is false
+PASS DOM.evaluate("-1 or 2", ROOT, null, XPathResult.ANY_TYPE, null).booleanValue is true
+PASS DOM.evaluate(". or *", ROOT, null, XPathResult.ANY_TYPE, null).booleanValue is true
+PASS text()
+PASS processing-instruction('f')
+PASS (child::*)
+PASS DOM.evaluate(". * 0", ROOT, null, XPathResult.NUMBER_TYPE, null).numberValue is NaN
+PASS DOM.evaluate(".. * 0", ROOT, null, XPathResult.NUMBER_TYPE, null).numberValue is NaN
+PASS DOM.evaluate("/.. * 0", ROOT, null, XPathResult.NUMBER_TYPE, null).numberValue is NaN
+PASS CHILD2/@CODE
+PASS DOM.evaluate("CHILD2/@CODE * 0", ROOT, null, XPathResult.NUMBER_TYPE, null).numberValue is 0
+PASS föø
+PASS DOM.evaluate("\\", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null) threw exception Error: INVALID_EXPRESSION_ERR: DOM XPath Exception 51.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/xpath/4XPath/Core/test_parser.html b/LayoutTests/fast/xpath/4XPath/Core/test_parser.html
new file mode 100644 (file)
index 0000000..3c49923
--- /dev/null
@@ -0,0 +1,114 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../../js/resources/js-test-style.css">
+<script src="../../../js/resources/js-test-pre.js"></script>
+<script src="test.js"></script>
+</head>
+<body>
+<div id="console"></div>
+
+<script>
+    function nsResolver(prefix) {
+        if (prefix == 'x')
+            return 'http://spam.com';
+        return null;
+    }
+
+    result = DOM.evaluate("child::*", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("child::*", result, CHILDREN);
+
+    result = DOM.evaluate("/child::*", CHILD1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("/child::*", result, [ROOT]);
+
+    result = DOM.evaluate("/*/*", CHILD1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("/*/*", result, CHILDREN);
+
+    result = DOM.evaluate("/child::*/*/child::GCHILD", CHILD1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("/child::*/*/child::GCHILD", result, GCHILDREN1.concat(GCHILDREN2));
+
+    result = DOM.evaluate("//*", CHILD1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("//*", result, [ROOT, CHILD1].concat(GCHILDREN1, [CHILD2], GCHILDREN2, [CHILD3, LANG], LCHILDREN));
+
+    result = DOM.evaluate("//GCHILD", CHILD1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("//GCHILD", result, GCHILDREN1.concat(GCHILDREN2));
+
+    result = DOM.evaluate("//@attr1", CHILD1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("//@attr1", result, [ATTR1, ATTR2]);
+
+    result = DOM.evaluate("x:GCHILD", CHILD1, nsResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("x:GCHILD", result, []);
+
+    result = DOM.evaluate(".//GCHILD", CHILD2, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot(".//GCHILD", result, GCHILDREN2);
+
+    result = DOM.evaluate(".//GCHILD", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot(".//GCHILD", result, GCHILDREN1.concat(GCHILDREN2));
+
+    result = DOM.evaluate("/", text, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("/", result, [DOM]);
+
+    result = DOM.evaluate("//CHILD1/..", CHILD1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("//CHILD1/..", result, [ROOT]);
+
+    result = DOM.evaluate(".//foo:*", CHILD3, DOM.createNSResolver(CHILD3), XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot(".//foo:*", result, []);
+
+    result = DOM.evaluate("CHILD1 | CHILD2", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("CHILD1 | CHILD2", result, [CHILD1, CHILD2]);
+
+    result = DOM.evaluate("descendant::GCHILD[3]", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("descendant::GCHILD[3]", result, [GCHILD21]);
+
+    result = DOM.evaluate("descendant::GCHILD[parent::CHILD1]", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("descendant::GCHILD[parent::CHILD1]", result, GCHILDREN1);
+
+    result = DOM.evaluate("descendant::GCHILD[position() > 1]", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("descendant::GCHILD[position() > 1]", result, [GCHILD12].concat(GCHILDREN2));
+
+    result = DOM.evaluate("@attr1[.='val1']", CHILD1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("@attr1[.='val1']", result, [ATTR1]);
+
+    shouldBe('DOM.evaluate("1", ROOT, null, XPathResult.ANY_TYPE, null).numberValue', "1");
+    shouldBe('DOM.evaluate("00200", ROOT, null, XPathResult.ANY_TYPE, null).numberValue', "200");
+    shouldBe('DOM.evaluate("3+4*7", ROOT, null, XPathResult.ANY_TYPE, null).numberValue', "31");
+    shouldBe('DOM.evaluate("3-4*1", ROOT, null, XPathResult.ANY_TYPE, null).numberValue', "-1");
+    shouldBe('DOM.evaluate("string(\'1\')", ROOT, null, XPathResult.ANY_TYPE, null).stringValue', "'1'");
+    shouldBe('DOM.evaluate("concat(\'1\', \'2\')", ROOT, null, XPathResult.ANY_TYPE, null).stringValue', "'12'");
+    shouldBe('DOM.evaluate("true()", ROOT, null, XPathResult.ANY_TYPE, null).booleanValue', "true");
+    shouldBe('DOM.evaluate("false()", ROOT, null, XPathResult.ANY_TYPE, null).booleanValue', "false");
+    shouldBe('DOM.evaluate("1=3<4", ROOT, null, XPathResult.ANY_TYPE, null).booleanValue', "true");
+    shouldBe('DOM.evaluate("1 or 2 and 3", ROOT, null, XPathResult.ANY_TYPE, null).booleanValue', "true");
+    shouldBe('DOM.evaluate("1 and 2 = 3", ROOT, null, XPathResult.ANY_TYPE, null).booleanValue', "false");
+    shouldBe('DOM.evaluate("-1 or 2", ROOT, null, XPathResult.ANY_TYPE, null).booleanValue', "true");
+    shouldBe('DOM.evaluate(". or *", ROOT, null, XPathResult.ANY_TYPE, null).booleanValue', "true");
+
+    result = DOM.evaluate("text()", CHILD3, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("text()", result, []);
+
+    result = DOM.evaluate("processing-instruction('f')", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("processing-instruction('f')", result, []);
+
+    result = DOM.evaluate("(child::*)", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("(child::*)", result, CHILDREN);
+
+    shouldBe('DOM.evaluate(". * 0", ROOT, null, XPathResult.NUMBER_TYPE, null).numberValue', "NaN");
+    shouldBe('DOM.evaluate(".. * 0", ROOT, null, XPathResult.NUMBER_TYPE, null).numberValue', "NaN");
+    shouldBe('DOM.evaluate("/.. * 0", ROOT, null, XPathResult.NUMBER_TYPE, null).numberValue', "NaN");
+
+    result = DOM.evaluate("CHILD2/@CODE", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("CHILD2/@CODE", result, [IDATTR2]);
+
+    shouldBe('DOM.evaluate("CHILD2/@CODE * 0", ROOT, null, XPathResult.NUMBER_TYPE, null).numberValue', "0");
+
+    result = DOM.evaluate("f\xf6\xf8", LANG, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("f\xf6\xf8", result, [NONASCIIQNAME]);
+
+    shouldThrow('DOM.evaluate("\\\\", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)');
+
+    var successfullyParsed = true;
+
+</script>
+<script src="../../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/xpath/4XPath/Core/test_predicate_list.html b/LayoutTests/fast/xpath/4XPath/Core/test_predicate_list.html
new file mode 100644 (file)
index 0000000..a8c1caf
--- /dev/null
@@ -0,0 +1,48 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../../js/resources/js-test-style.css">
+<script src="../../../js/resources/js-test-pre.js"></script>
+<script src="test.js"></script>
+</head>
+<body>
+<div id="console"></div>
+
+<script>
+    result = DOM.evaluate("self::node()[true() and false()][true()]", ROOT, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("self::node()[true() and false()][true()]", result, []);
+
+    result = DOM.evaluate("self::node()[true() or false()][true()]", ROOT, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("self::node()[true() or false()][true()]", result, [ROOT]);
+
+    dom2 = (new DOMParser).parseFromString(
+        "<?xml version='1.0'?>" +
+        "<elementList>" +
+        "    <element>" +
+        "        <x>" +
+        "           <y>a</y>" +
+        "        </x>" +
+        "    </element>" +
+        "    <element>" +
+        "        <x>" +
+        "            <y>z</y>" +
+        "        </x>" +
+        "    </element>" +
+        "</elementList>",
+        "application/xml");
+
+    result = dom2.evaluate("//element[descendant::y[.='z']]", dom2, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("//element[descendant::y[.='z']]", result, [dom2.getElementsByTagName("element")[1]]);
+
+    result = dom2.evaluate("//element[descendant::y[.='z']][1]", dom2, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("//element[descendant::y[.='z']][1]", result, [dom2.getElementsByTagName("element")[1]]);
+
+    result = dom2.evaluate("//element[descendant::y[.='z']][2]", dom2, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("//element[descendant::y[.='z']][2]", result, []);
+
+    var successfullyParsed = true;
+
+</script>
+<script src="../../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/xpath/4XPath/Core/test_step-expected.txt b/LayoutTests/fast/xpath/4XPath/Core/test_step-expected.txt
new file mode 100644 (file)
index 0000000..9c94b2a
--- /dev/null
@@ -0,0 +1,9 @@
+PASS ancestor::*
+FAIL ancestor-or-self::* item 0 incorrect (expected ROOT, actual CHILD1)
+PASS descendant-or-self::*
+PASS child::GCHILD[position()=1]
+PASS child::GCHILD[1]
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/xpath/4XPath/Core/test_step.html b/LayoutTests/fast/xpath/4XPath/Core/test_step.html
new file mode 100644 (file)
index 0000000..62f3c34
--- /dev/null
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../../js/resources/js-test-style.css">
+<script src="../../../js/resources/js-test-pre.js"></script>
+<script src="test.js"></script>
+</head>
+<body>
+<div id="console"></div>
+
+<script>
+    result = DOM.evaluate("ancestor::*", CHILD1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("ancestor::*", result, [ROOT]);
+
+    result = DOM.evaluate("ancestor-or-self::*", CHILD1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("ancestor-or-self::*", result, [ROOT, CHILD1]);
+
+    result = DOM.evaluate("descendant-or-self::GCHILD", CHILD1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("descendant-or-self::*", result, GCHILDREN1);
+
+    result = DOM.evaluate("child::GCHILD[position()=1]", CHILD1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("child::GCHILD[position()=1]", result, [GCHILD11]);
+
+    result = DOM.evaluate("child::GCHILD[1]", CHILD1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("child::GCHILD[1]", result, [GCHILD11]);
+
+    var successfullyParsed = true;
+
+</script>
+<script src="../../../js/resources/js-test-post.js"></script>
+</body>
+</html>