1<body>
2<script>
3    if (window.layoutTestController)
4        layoutTestController.dumpAsText();
5
6    src = '<doc><elem>a<![CDATA[b]]>c</elem></doc>';
7    doc = (new DOMParser).parseFromString(src, "application/xml");
8
9    elem = doc.documentElement.firstChild;
10    aText = elem.firstChild;
11    bText = elem.firstChild.nextSibling;
12    cText = elem.lastChild;
13
14    function test(expr, context) {
15        nodeset = doc.evaluate(expr, context, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
16        str = "";
17        while (currNode = nodeset.iterateNext()) {
18            if (str)
19                str += " ";
20            str += currNode.nodeValue;
21        }
22        
23        document.write(expr + ", " + (context.nodeValue ? context.nodeValue : context) + ": \"" + str + "\"<br>");
24    }
25
26    document.write("<xmp>" + src + "</xmp>");
27
28    test("child::*", elem);
29    test("child::node()", elem);
30    test("descendant::*", elem);
31    test("descendant::node()", elem);
32    test("descendant::node()[2]", elem);
33    test("ancestor-or-self::node()", bText);
34    test("ancestor-or-self::*", bText);
35    test("ancestor-or-self::node()", aText);
36    test("ancestor-or-self::*", aText);
37    test("following::node()", elem);
38    test("following::node()", aText);
39    test("following::text()", aText);
40    test("following::node()", bText);
41    test("following-sibling::node()", elem);
42    test("following-sibling::node()", aText);
43    test("following-sibling::text()", aText);
44    test("following-sibling::node()", bText);
45    test("preceding::node()", bText);
46    test("preceding-sibling::node()", bText);
47    test("preceding::node()", cText);
48    test("preceding::text()", cText);
49    test("preceding-sibling::node()", cText);
50    test("preceding-sibling::text()", cText);
51    test("self::node()", bText);
52
53    var successfullyParsed = true;
54
55</script>
56</body>
57