Reviewed by Darin.
authorap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Nov 2007 06:02:20 +0000 (06:02 +0000)
committerap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Nov 2007 06:02:20 +0000 (06:02 +0000)
        http://bugs.webkit.org/show_bug.cgi?id=15448
        Import XPath test suite from amachang.art-code.org

        Test by Hitoshi Amano <seijro@gmail.com>.

        * fast/xpath/xpath-functional-test-expected.txt: Added.
        * fast/xpath/xpath-functional-test.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/xpath/xpath-functional-test-expected.txt [new file with mode: 0644]
LayoutTests/fast/xpath/xpath-functional-test.html [new file with mode: 0644]

index 5418a1d89cf7b0bab450db5df294ee8755126ea9..a08e9128637052dabc49568fe7eba208d1e9a31f 100644 (file)
@@ -1,3 +1,15 @@
+2007-11-15  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Darin.
+
+        http://bugs.webkit.org/show_bug.cgi?id=15448
+        Import XPath test suite from amachang.art-code.org
+
+        Test by Hitoshi Amano <seijro@gmail.com>.
+
+        * fast/xpath/xpath-functional-test-expected.txt: Added.
+        * fast/xpath/xpath-functional-test.html: Added.
+
 2007-11-15  Khoo Yit Phang  <khooyp@cs.umd.edu>
 
         Reviewed by Darin.
diff --git a/LayoutTests/fast/xpath/xpath-functional-test-expected.txt b/LayoutTests/fast/xpath/xpath-functional-test-expected.txt
new file mode 100644 (file)
index 0000000..f364038
--- /dev/null
@@ -0,0 +1,99 @@
+[ok].//blockquote/*
+[ok].//blockquote/child::*
+[ok].//blockquote/parent::*
+[ok].//blockquote/descendant::*
+[ok].//blockquote/descendant-or-self::*
+[ok].//blockquote/ancestor::*
+[ok].//blockquote/ancestor-or-self::*
+[ok].//blockquote/following-sibling::*
+[ok].//blockquote/preceding-sibling::*
+[ok].//blockquote/following::*
+[ok].//blockquote/preceding::*
+[ok].//blockquote/self::*
+[ok].//blockquote/attribute::id/parent::*
+[ok].//blockquote/@id/parent::*
+[ok].//*[blockquote]
+[ok].//*[child::blockquote]
+[ok].//*[parent::blockquote]
+[ok].//*[descendant::blockquote]
+[ok].//*[descendant-or-self::blockquote]
+[ok].//*[ancestor::blockquote]
+[ok].//*[ancestor-or-self::blockquote]
+[ok].//*[following-sibling::blockquote]
+[ok].//*[preceding-sibling::blockquote]
+[ok].//*[following::blockquote]
+[ok].//*[preceding::blockquote]
+[ok].//*[self::blockquote]
+[ok].//*[@id]
+[ok].//*[attribute::id]
+[ok].//blockquote/text()
+[ok].//blockquote/comment()
+[ng].//blockquote/processing-instruction()
+[ng].//blockquote/processing-instruction("pi")
+[ng].//blockquote/node()
+[ok].//blockquote/p
+[ok].//blockquote/*
+[ok].//*[child::* and preceding::font]
+[ok].//*[not(child::*) and preceding::font]
+[ok].//*[preceding::blockquote or following::blockquote]
+[ok].//blockquote/ancestor::* | .//blockquote/descendant::*
+[ok].//*[.="sub"]
+[ok].//*[@title > 12 and @class < 15]
+[ok].//*[@title != @class]
+[ok].//*[((@class * @class + @title * @title) div (@class + @title)) > ((@class - @title) * (@class - @title))]
+[ok].//*[@title mod 2 = 0]
+[ok].//blockquote/child::*[last()]
+[ok].//blockquote/descendant::*[position() < 4]
+[ok]id(.//font/@face)
+[ok].//*[name(.) = "sub"]
+[ok].//*[name() = "sub"]
+[ok].//blockquote/child::*[2]
+[ok].//blockquote/descendant::*[4]
+[ok].//blockquote/descendant-or-self::*[4]
+[ok].//blockquote/ancestor::*[2]
+[ok].//blockquote/ancestor-or-self::*[2]
+[ok].//blockquote/following-sibling::*[1]
+[ok].//blockquote/preceding-sibling::*[1]
+[ok].//blockquote/following::*[4]
+[ok].//blockquote/preceding::*[4]
+[ok].//*[starts-with(.,"s")]
+[ok].//*[string(@title - 1) = "0"]
+[ok].//*[string() = "sub"]
+[ok].//*[string(.) = "sub"]
+[ok].//*[concat(.,..) = "subsubsup"]
+[ok].//node()[concat(.,..,../..) = "bbbs"]
+[ok].//*[starts-with(.,"s")]
+[ok].//*[substring-before(.,"u") = "s"]
+[ok].//*[substring-after(.,"on") = "t"]
+[ok].//*[substring(.,2,1) = "u"]
+[ok].//*[substring(.,2) = "up"]
+[ok].//*[contains(.,"b")]
+[ok].//*[string-length() = 3]
+[ok].//*[string-length(.) = 3]
+[ok].//*[.=translate(normalize-space(" s u b ")," ","")]
+[ok].//*[normalize-space()="q"]
+[ok].//*[boolean(@title - 1) = false()]
+[ok].//*[not(@title - 1) = true()]
+[ng].//*[lang("it")]
+[ok].//*[number(@title) < number(@class)]
+[ok].//*[sum(ancestor::*/@title) < sum(descendant::*/@title)]
+[ok].//*[floor(@title div @class) = 1]
+[ok].//*[ceiling(@title div @class) = 1]
+[ok].//*[round(@title div @class) = 1]
+[ok].//*[blockquote]
+dt
+dd
+emstrong
+
+bs
+
+blockquoteText1:
+blockquoteText2
+delins
+
+font
+dfna
+
+subsup
+
+abbrq
diff --git a/LayoutTests/fast/xpath/xpath-functional-test.html b/LayoutTests/fast/xpath/xpath-functional-test.html
new file mode 100644 (file)
index 0000000..f0df428
--- /dev/null
@@ -0,0 +1,178 @@
+<html>
+ <head>
+  <title>XPath Test</title>
+  <script>
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+
+    function test(expression, expect) {
+        function error(message) {
+            var e = Error();
+            e.result = result;
+            e.expects = expects;
+            e.expression = expression;
+            e.message = message;
+            return e
+        };
+        var result = document.evaluate(expression, document.body, null, 7, null);
+        var expects = expect.split(/\s+/);
+        for (var i = 0, l = expects.length; i < l; i++) if (expects[i] == '') expects.splice(i, 1);
+        if (result.snapshotLength != expects.length) throw error();
+        for (var i = 0, l = expects.length; i < l; i++) {
+            var expect = expects[i];
+            var r = expect.match(/^(?:([atpc]):)?(.*)$/);
+            var node = result.snapshotItem(i);
+            if (!types[r[1] || ''](node, r[2])) throw error();
+        }
+        return true;
+    };
+    window.onload = function() {
+        var ul = document.createElement('ul');
+        for (var i = 0, l = data.length; i < l; i ++) {
+            var li = document.createElement('li');
+            try {
+                test.apply(null, data[i]);
+                li.appendChild(document.createTextNode('[ok]' + data[i][0]));
+                li.className = 'ok';
+                li.style.color = 'green';
+            }
+            catch (e) {
+                li.appendChild(document.createTextNode('[ng]' + data[i][0]));
+                li.className = 'ng';
+                li.style.color = 'red';
+            }
+            ul.appendChild(li);
+        }
+        document.body.insertBefore(ul, document.body.firstChild);
+    };
+    var types = {
+        a: function(node, expect) {
+            var r = expect.split(':');
+            return r[0] == node.nodeName && r[1] == node.nodeValue;
+        },
+        t: function(node, expect) {
+            return expect == node.nodeValue;
+        },
+        p: function(node, expect) {
+            return expect == node.nodeName;
+        },
+        c: function(node, expect) {
+            return expect == node.nodeValue;
+        },
+        '': function(node, expect) {
+            return expect.toLowerCase() == node.nodeName.toLowerCase();
+        }
+    };
+    var data = [
+        ['.//blockquote/*', 'br p font'],
+        ['.//blockquote/child::*', 'br p font'],
+        ['.//blockquote/parent::*', 'center'],
+        ['.//blockquote/descendant::*', 'br p del ins font'],
+        ['.//blockquote/descendant-or-self::*', 'blockquote br p del ins font'],
+        ['.//blockquote/ancestor::*', 'html body div center'],
+        ['.//blockquote/ancestor-or-self::*', 'html body div center blockquote'],
+        ['.//blockquote/following-sibling::*', 'h3 h4'],
+        ['.//blockquote/preceding-sibling::*', 'h1 h2'],
+        ['.//blockquote/following::*', 'h3 dfn a h4 sub sup span abbr q'],
+        ['.//blockquote/preceding::*', 'head title script dl dt dd h1 em strong h2 b s'],
+        ['.//blockquote/self::*', 'blockquote'],
+        ['.//blockquote/attribute::id/parent::*', 'blockquote'],
+        ['.//blockquote/@id/parent::*', 'blockquote'],
+
+
+        ['.//*[blockquote]', 'center'],
+        ['.//*[child::blockquote]', 'center'],
+        ['.//*[parent::blockquote]', 'br p font'],
+        ['.//*[descendant::blockquote]', 'div center'],
+        ['.//*[descendant-or-self::blockquote]', 'div center blockquote'],
+        ['.//*[ancestor::blockquote]', 'br p del ins font'],
+        ['.//*[ancestor-or-self::blockquote]', 'blockquote br p del ins font'],
+        ['.//*[following-sibling::blockquote]', 'h1 h2'],
+        ['.//*[preceding-sibling::blockquote]', 'h3 h4'],
+        ['.//*[following::blockquote]', 'dl dt dd h1 em strong h2 b s'],
+        ['.//*[preceding::blockquote]', 'h3 dfn a h4 sub sup span abbr q'],
+        ['.//*[self::blockquote]', 'blockquote'],
+        ['.//*[@id]', 'div dl dt dd center h1 em strong h2 b s blockquote br p del ins font h3 dfn a h4 sub sup span abbr q'],
+        ['.//*[attribute::id]', 'div dl dt dd center h1 em strong h2 b s blockquote br p del ins font h3 dfn a h4 sub sup span abbr q'],
+
+
+        ['.//blockquote/text()', 't:blockquoteText1: t:blockquoteText2'],
+        ['.//blockquote/comment()', 'c:blockquoteComment'],
+        ['.//blockquote/processing-instruction()', 'p:pi'],
+        ['.//blockquote/processing-instruction("pi")', 'p:pi'],
+        ['.//blockquote/node()', 'c:blockquoteComment t:blockquoteText1: br t:blockquoteText2 p p:pi font'],
+        ['.//blockquote/p', 'p'],
+        ['.//blockquote/*', 'br p font'],
+
+
+        ['.//*[child::* and preceding::font]', 'h3 h4 span'],
+        ['.//*[not(child::*) and preceding::font]', 'dfn a sub sup abbr q'],
+        ['.//*[preceding::blockquote or following::blockquote]', 
+                            'dl dt dd h1 em strong h2 b s h3 dfn a h4 sub sup span abbr q'],
+        ['.//blockquote/ancestor::* | .//blockquote/descendant::*', 'html body div center br p del ins font'],
+        ['.//*[.="sub"]', 'sub'],
+        ['.//*[@title > 12 and @class < 15]', 'br p del ins font'], 
+        ['.//*[@title != @class]',
+                'div dl dt dd center em strong b s blockquote br p del ins font dfn a sub sup span abbr q'], 
+        ['.//*[((@class * @class + @title * @title) div (@class + @title)) > ((@class - @title) * (@class - @title))]',
+                'dl h1 h2 s blockquote br p font h3 dfn a h4 sub sup span abbr q'],
+        ['.//*[@title mod 2 = 0]', 'dl dd h1 strong b blockquote p ins h3 a sub span q'],
+
+
+        ['.//blockquote/child::*[last()]', 'font'],
+        ['.//blockquote/descendant::*[position() < 4]', 'br p del'],
+        ['id(.//font/@face)', 'strong q'],
+        ['.//*[name(.) = "sub"]', 'sub'],
+        ['.//*[name() = "sub"]', 'sub'],
+
+
+        ['.//blockquote/child::*[2]', 'p'],
+        ['.//blockquote/descendant::*[4]', 'ins'],
+        ['.//blockquote/descendant-or-self::*[4]', 'del'],
+        ['.//blockquote/ancestor::*[2]', 'div'],
+        ['.//blockquote/ancestor-or-self::*[2]', 'center'],
+        ['.//blockquote/following-sibling::*[1]', 'h3'],
+        ['.//blockquote/preceding-sibling::*[1]', 'h2'],
+        ['.//blockquote/following::*[4]', 'h4'],
+        ['.//blockquote/preceding::*[4]', 'strong'],
+
+        
+        ['.//*[starts-with(.,"s")]', 'strong s h4 sub sup'],
+        ['.//*[string(@title - 1) = "0"]', 'div'],
+        ['.//*[string() = "sub"]', 'sub'],
+        ['.//*[string(.) = "sub"]', 'sub'],
+        ['.//*[concat(.,..) = "subsubsup"]', 'sub'],
+        ['.//node()[concat(.,..,../..) = "bbbs"]', 't:b'],
+        ['.//*[starts-with(.,"s")]', 'strong s h4 sub sup'],
+        ['.//*[substring-before(.,"u") = "s"]', 'h4 sub sup'],
+        ['.//*[substring-after(.,"on") = "t"]', 'blockquote font'],
+        ['.//*[substring(.,2,1) = "u"]', 'h4 sub sup'],
+        ['.//*[substring(.,2) = "up"]', 'sup'],
+        ['.//*[contains(.,"b")]', 'div center h2 b blockquote h4 sub span abbr'],
+        ['.//*[string-length() = 3]', 'del ins dfn sub sup'],
+        ['.//*[string-length(.) = 3]', 'del ins dfn sub sup'],
+        ['.//*[.=translate(normalize-space("  s  u  b  ")," ","")]', 'sub'],
+        ['.//*[normalize-space()="q"]', 'q'],
+
+
+        ['.//*[boolean(@title - 1) = false()]', 'div'],
+        ['.//*[not(@title - 1) = true()]', 'div'],
+        ['.//*[lang("it")]', 'q'],
+
+
+        ['.//*[number(@title) < number(@class)]', 'div dl center blockquote span'],
+        ['.//*[sum(ancestor::*/@title) < sum(descendant::*/@title)]',
+                'div dl center h1 h2 blockquote p h3 h4 span'],
+        ['.//*[floor(@title div @class) = 1]',
+                'h1 em strong h2 b s br p del ins font h3 dfn a h4 sub sup abbr q'],
+        ['.//*[ceiling(@title div @class) = 1]', 'div dl center h1 h2 blockquote h3 h4 span'],
+        ['.//*[round(@title div @class) = 1]',
+                'dl h1 h2 b s blockquote br p del ins font h3 dfn a h4 sub sup span abbr q'],
+
+
+        ['.//*[blockquote]', 'center']
+    ];
+  </script>
+ </head>
+ <body><div id="n1" title="1" class="26" xml:lang="en"><dl id="n2" title="2" class="3"><dt id="n3" title="3" class="1">dt</dt><dd id="n4" title="4" class="2">dd</dd></dl><center id="n5" title="5" class="22"><h1 id="n6" title="6" class="6"><em id="n7" title="7" class="4">em</em><strong id="n8" title="8" class="5">strong</strong></h1><h2 id="n9" title="9" class="9"><b id="n10" title="10" class="7">b</b><s id="n11" title="11" class="8">s</s></h2><blockquote id="n12" title="12" class="15"><!--blockquoteComment-->blockquoteText1:<br id="n13" title="13" class="10"/>blockquoteText2<p id="n14" title="14" class="13"><del id="n15" title="15" class="11">del</del><ins id="n16" title="16" class="12">ins</ins></p><?pi name="value"?><font id="n17" title="17" class="14" face="n8 n26">font</font></blockquote><h3 id="n18" title="18" class="18"><dfn id="n19" title="19" class="16">dfn</dfn><a id="n20" title="20" class="17">a</a></h3><h4 id="n21" title="21" class="21"><sub id="n22" title="22" class="19">sub</sub><sup id="n23" title="23" class="20">sup</sup></h4></center><span id="n24" title="24" class="25"><abbr id="n25" title="25" class="23">abbr</abbr><q id="n26" title="26" class="24" cite="n8 n17" xml:lang="it">q</q></span></div></body>
+</html>