summaryrefslogtreecommitdiffstats
path: root/LayoutTests/fast/xpath/preceding-axis.xhtml
blob: 6a85afb686f38a159e7b8bbd5fe1fe62c516bbde (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
57
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>XPath preceding axis misses nested elements</title>
<style>div#msg { white-space: pre; }</style>
<script>
if (window.layoutTestController)
    layoutTestController.dumpAsText();

window.addEventListener("load", function() {
    var msg = document.getElementById("msg");
    function print(s) { msg.textContent += s; }
    function id(el) { return el.tagName + (el.id ? "#" + el.id : ""); }
    function query(el, xpath, expected) {
        print("Query \"" + xpath + "\" from " + id(el) + "\n");
        var res = document.evaluate(xpath,
                                    el,
                                    function() { return "http://www.w3.org/1999/xhtml"; },
                                    XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
                                    null);

        var resstr = "";
        for (var i = 0; i &lt; res.snapshotLength; i++) {
            var el = res.snapshotItem(i);
            resstr += " " + id(el);
        }
        print("Result:" + resstr + "\n");
        print("Expected: " + expected + "\n");
        if (resstr != (" " + expected)) {
            print("***FAIL***\n");
        } else {
            print("***SUCCESS***\n");
        }
        print("\n");
    }
    
    print("Querying in the following...\n\n");
    print(document.getElementById("test").outerHTML + "\n\n");
    
    query(document.getElementById("D"), "preceding::xhtml:span", "span#A span#B span#C");
}, false);
</script>
</head>
<body>
<div id="test">
    <span id="A"/>
    <div>
      <span id="B">
        <span id="C"/>
      </span>
    </div>
    <span id="D"/>
</div>
<div id="msg"/>
</body>
</html>