summaryrefslogtreecommitdiffstats
path: root/LayoutTests/fast/xpath/namespace-vs-predicate.xhtml
blob: 8ef85effc71270f442ae0310a849ff571a9d0a65 (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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
    xmlns:svg="http://www.w3.org/2000/svg"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns:ev="http://www.w3.org/2001/xml-events"
    xml:space="preserve">
<head>
    <title/>
</head>
<body>
    <p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=12733">bug 12733</a>:
    XPath namespace is attached to a wrong step.</p>
    <div id="result">FAILURE: script did't run</div>
    <svg:g id="r_00"/>
    <script>
        if (window.layoutTestController)
            layoutTestController.dumpAsText();

        function nsResolver(prefix) {
            var ns={
                'ev'     : 'http://www.w3.org/2001/xml-events',
                'mathml' : 'http://www.w3.org/1998/Math/MathML',
                'svg'    : 'http://www.w3.org/2000/svg',
                'xhtml'  : 'http://www.w3.org/1999/xhtml',
                'xlink'  : 'http://www.w3.org/1999/xlink'
            };
            return ns[prefix] || null;
        }

        var result = document.evaluate("//svg:g[@id = 'r_00']", document.documentElement, nsResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
        if (result.snapshotLength == 1)
            document.getElementById("result").firstChild.nodeValue = "SUCCESS";
        else
            document.getElementById("result").firstChild.nodeValue = "FAILURE: " + result.snapshotLength + " node(s) matched - should be 1";

        // Remove this node from the document so it doesn't make the DumpRenderTree output
        // different when SVG is enabled and disabled.
        var g = document.getElementsByTagNameNS("http://www.w3.org/2000/svg", "g")[0];
        g.parentNode.removeChild(g);
    </script>

</body>
</html>