summaryrefslogtreecommitdiffstats
path: root/LayoutTests/fast/xpath/text-nodes.html
blob: 96a9e38f5eef70fa1b4c6f7af816ada544949518 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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);
    test("ancestor-or-self::*", bText);
    test("ancestor-or-self::node()", aText);
    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);
    test("preceding::text()", cText);
    test("preceding-sibling::node()", cText);
    test("preceding-sibling::text()", cText);
    test("self::node()", bText);

    var successfullyParsed = true;

</script>
</body>