Revision eb9f8a917a751b5bd2e4ed86840eac8b5c4445f2 authored by Brian Birtles on 15 March 2018, 06:57:09 UTC, committed by Brian Birtles on 15 March 2018, 06:57:09 UTC
This patch also drops the test that an AnimationEffectTiming object is created in the appropriate realm since it is no longer the case that a separate timing object is created.
1 parent df2153f
XMLSerializer-serializeToString.html
<!DOCTYPE HTML>
<meta charset=utf-8>
<html>
<head>
<title>domparsing Test: XMLSerializer.serializeToString</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>domparsing_XMLSerializer_serializeToString</h1>
<script>
function createXmlDoc(){
var input = '<?xml version="1.0" encoding="UTF-8"?><root><child1>value1</child1></root>';
var parser = new DOMParser();
return parser.parseFromString(input, 'text/xml');
}
test(function() {
var serializer = new XMLSerializer();
var root = createXmlDoc().documentElement;
var xmlString = serializer.serializeToString(root);
assert_equals(xmlString, '<root><child1>value1</child1></root>');
}, 'check XMLSerializer.serializeToString method could parsing xmldoc to string');
test(function() {
var serializer = new XMLSerializer();
var root = createXmlDoc().documentElement;
var element = root.ownerDocument.createElementNS('urn:foo', 'another');
var child1 = root.firstChild;
root.replaceChild(element, child1);
element.appendChild(child1);
var xmlString = serializer.serializeToString(root);
assert_equals(xmlString, '<root><another xmlns="urn:foo"><child1 xmlns="">value1</child1></another></root>');
}, 'Check if the default namespace is correctly reset.');
test(function() {
var input = '<root xmlns="urn:bar"><outer xmlns=""><inner>value1</inner></outer></root>';
var root = (new DOMParser()).parseFromString(input, 'text/xml').documentElement;
var xmlString = (new XMLSerializer()).serializeToString(root);
assert_equals(xmlString, '<root xmlns="urn:bar"><outer xmlns=""><inner>value1</inner></outer></root>');
}, 'Check if there is no redundant empty namespace declaration.');
test(function() {
var serializer = new XMLSerializer();
var parser = new DOMParser();
var root = parser.parseFromString('<root />', 'text/xml').documentElement;
root.setAttribute('attr', '\t');
assert_in_array(serializer.serializeToString(root), [
'<root attr="	"/>', '<root attr="	"/>']);
root.setAttribute('attr', '\n');
assert_in_array(serializer.serializeToString(root), [
'<root attr="
"/>', '<root attr=" "/>']);
root.setAttribute('attr', '\r');
assert_in_array(serializer.serializeToString(root), [
'<root attr="
"/>', '<root attr=" "/>']);
}, 'check XMLSerializer.serializeToString escapes attribute values for roundtripping');
</script>
</body>
</html>
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...