blob: 7a71f124489a35a7be554d347b7184b5516c6833 [file] [log] [blame]
<html>
<head>
<script>
function debug(str) {
li = document.createElement('li');
li.appendChild(document.createTextNode(str));
document.getElementById('console').appendChild(li);
}
function parseDocument() {
str = '<test><child1>First child</child1>';
str += '<child2 attr="an attribute">Second child</child2>';
str += '<!-- A comment --></test>';
parser = new DOMParser();
doc = parser.parseFromString(str, 'text/xml');
return doc;
}
function runTests() {
if (window.layoutTestController) {
layoutTestController.dumpAsText();
}
doc = parseDocument();
child1 = doc.documentElement.firstChild;
child2 = child1.nextSibling
comment = child2.nextSibling;
fragment = doc.createDocumentFragment();
fragment.appendChild(doc.documentElement.cloneNode(true))
serializer = new XMLSerializer();
debug(serializer.serializeToString(child1));
debug(serializer.serializeToString(child2));
debug(serializer.serializeToString(comment));
debug(serializer.serializeToString(doc));
debug(serializer.serializeToString(fragment));
}
</script>
</head>
<body onload="runTests()">
This tests XMLSerializer on different node types. If the test is successful, there should be five lines of output. The first line should be the child1 tag. The second should be the child2 tag. The third one should be a comment, the fourth one should be the complete document and the fifth one should be the complete document but serialized from a document fragment node.
<ul id="console">
</ul>
</body>
</html>