summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/dom/cloneNode.html
blob: a94433d48cc1e5963306dd408c40a4f65642a0ad (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
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
    <script>
    function log(s)
    {
        var logDiv = document.getElementById("log");
        logDiv.appendChild(document.createTextNode(s));
        logDiv.appendChild(document.createElement('br'));
    }

    function matches(node, clonedNode, passedMessage)
    {
        if (node.localName === clonedNode.localName && node.prefix === clonedNode.prefix && node.namespaceURI === clonedNode.namespaceURI && node.nodeName === clonedNode.nodeName)
            log("PASSED: " + passedMessage);
        else
            log("FAILED");
    }

    function test()
    {
        if (window.testRunner)
            testRunner.dumpAsText();

        var xmlDoc = document.implementation.createDocument("http://www.example.com", "foo:bar", null);

        var xmlNode = xmlDoc.createElement("foo:bar");
        var clonedXMLNode = xmlNode.cloneNode(false);  // WebKit crashes.
        var htmlNode = document.getElementById('log');
        var clonedHTMLNode = htmlNode.cloneNode(false);

        matches(xmlNode, clonedXMLNode, "Cloned XML node matches the original");
        matches(htmlNode, clonedHTMLNode, "Cloned HTML node matches the original");
    }
    </script>
</head>
<body onload="test()">
<p> Test for bug Bug <a href="https://bugs.webkit.org/show_bug.cgi?id=23956">23956</a>: Safari crashes when cloneNode fails (cloning a XML element with an invalid nodeName)</p>
<p> For this test to pass, it should not crash and you should see PASSED twice.</p>
<div id='log'/>
</body>
</html>