summaryrefslogtreecommitdiffstats
path: root/LayoutTests/fast/xpath/id-simple.html
blob: 743c6832d50d19274dc8dbbb54a7bae0bcdc834e (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
<html>
<head>
<script>
    if (window.layoutTestController)
      layoutTestController.dumpAsText();

    var results = "";
    var result;
    var testNum = 1;
    function init() {
        var tests = [
            "id('nested1')",
            "id('nested1')/div[1]",
            "id('nested1')//div[1]",
            "id('nested1')/div[1]/input[2]",
            "id('nested1')/div[1]//input[2]",
            "id('nested1')//div[1]/input[2]",
            "id('nested1')//div[1]//input[2]"
        ];
        for (var i = 0; i < tests.length; i++) {
            runXPath(tests[i]);
        }
        document.getElementById('results').innerHTML = results;
    }
    
    function runXPath(xpath) {
        var result = document.evaluate(xpath, document, null, XPathResult.ANY_TYPE, null).iterateNext();
        results += xpath + " " + (result ? "PASSED" : "FAILED") + ": " + result + "<br />";
    }
</script>
</head>
<body onload="init()">
<p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=15380">bug 15380</a>:
XPath: id('foo') doesn't resolve correctly.</p>
<div id="nested1">
        <div id="nested2">
            <input id="nested3a" type="button" value="nested3a">
            <input id="nested3b" type="button" value="nested3b">
        </div>
    </div>
    <div id="results"></div>
</body>
</html>