summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/html/xhtml-serialize.html
blob: bfde40df199125aa899de7179385fc1ee4abb975 (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
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<body>
<p>This test checks whether serialized invalid XHTML is valid XML (for bug 9901).</p>
<p>If the test passes, you'll see a series of 'PASS' messages below.</p>
<pre id="console"></pre>

<script>
if (window.testRunner)
    testRunner.dumpAsText();
    
function log(s)
{
    document.getElementById('console').appendChild(document.createTextNode(s));
}

function shouldBe(a, b)
{
    var evalA;
    try {
        evalA = eval(a);
    } catch(e) {
        evalA = e;
    }
    
    if (evalA == b)
        log('PASS: ' + a + ' should be ' + b + ' and is.\n');
    else
        log('FAIL: ' + a + ' should be ' + b + ' but instead is ' + evalA + '.\n');
}

var doc = (new DOMParser()).parseFromString('<input xmlns="http://www.w3.org/1999/xhtml">123</input>', 'text/xml');
var str = (new XMLSerializer()).serializeToString(doc);

shouldBe('doc.firstChild.firstChild.nodeValue', '123');
shouldBe('str', '<input xmlns=\"http://www.w3.org/1999/xhtml\">123</input>');
</script>
</body>
</html>