summaryrefslogtreecommitdiffstats
path: root/dom/base/test/test_bug541937.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/base/test/test_bug541937.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/base/test/test_bug541937.html')
-rw-r--r--dom/base/test/test_bug541937.html119
1 files changed, 119 insertions, 0 deletions
diff --git a/dom/base/test/test_bug541937.html b/dom/base/test/test_bug541937.html
new file mode 100644
index 000000000..c311b1615
--- /dev/null
+++ b/dom/base/test/test_bug541937.html
@@ -0,0 +1,119 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+-->
+<head>
+ <title>Test for XHTML serializer, bug 541937</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=541937">Mozilla Bug </a>
+<p id="display"></p>
+<div id="content" style="display: none">
+ <iframe id="testframe" src="file_bug541937.html">
+ </iframe>
+ <iframe id="testframe2" src="file_bug541937.xhtml">
+ </iframe>
+</div>
+
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+function testSerializer () {
+ const de = SpecialPowers.Ci.nsIDocumentEncoder;
+ var encoder = SpecialPowers.Cc["@mozilla.org/layout/documentEncoder;1?type=text/html"]
+ .createInstance(SpecialPowers.Ci.nsIDocumentEncoder);
+
+ var parser = new DOMParser();
+ var serializer = new XMLSerializer();
+
+ // with content
+ var str = '<?xml version="1.0"?><doc>\n<link xmlns="http://www.w3.org/1999/xhtml"><!-- child nodes --> \n<content xmlns=""/></link>\n</doc>';
+ var expected = '<?xml version="1.0" encoding="UTF-8"?>\n<doc>\n<link xmlns="http://www.w3.org/1999/xhtml"><!-- child nodes --> \n<content xmlns=""/></link>\n</doc>';
+
+ var doc = parser.parseFromString(str,"application/xml");
+ var result = serializer.serializeToString(doc);
+ result = result.replace(/\r\n/mg, "\n");
+ is(result, expected, "serialization of a link element inside an xml document with children");
+
+ // with only whitespaces
+ str = '<?xml version="1.0"?><doc>\n<link xmlns="http://www.w3.org/1999/xhtml"> \n </link>\n</doc>';
+ expected = '<?xml version="1.0" encoding="UTF-8"?>\n<doc>\n<link xmlns="http://www.w3.org/1999/xhtml"> \n </link>\n</doc>';
+
+ doc = parser.parseFromString(str,"application/xml");
+ result = serializer.serializeToString(doc);
+ result = result.replace(/\r\n/mg, "\n");
+ is(result, expected, "serialization of a link element with only whitespaces as content, inside an xml document");
+
+ // with only one space as content
+ str = '<?xml version="1.0"?><doc>\n<link xmlns="http://www.w3.org/1999/xhtml"> </link>\n</doc>';
+ expected = '<?xml version="1.0" encoding="UTF-8"?>\n<doc>\n<link xmlns="http://www.w3.org/1999/xhtml"> </link>\n</doc>';
+
+ doc = parser.parseFromString(str,"application/xml");
+ result = serializer.serializeToString(doc);
+ result = result.replace(/\r\n/mg, "\n");
+ is(result, expected, "serialization of a link element with only one space as content, inside an xml document");
+
+ // let's remove the content
+ str = '<?xml version="1.0"?><doc>\n<link xmlns="http://www.w3.org/1999/xhtml"> <!-- child nodes --> \ndeleted content<content xmlns=""/> </link>\n</doc>';
+ expected = '<?xml version="1.0" encoding="UTF-8"?>\n<doc>\n<link xmlns="http://www.w3.org/1999/xhtml" />\n</doc>';
+
+ doc = parser.parseFromString(str,"application/xml");
+ doc.documentElement.firstElementChild.textContent = '';
+ result = serializer.serializeToString(doc);
+ result = result.replace(/\r\n/mg, "\n");
+ is(result, expected, "serialization of a link element on which we removed dynamically the content, inside an xml document");
+
+ // with no content but an ended tag
+ str = '<?xml version="1.0"?><doc>\n<link xmlns="http://www.w3.org/1999/xhtml"></link>\n</doc>';
+ expected = '<?xml version="1.0" encoding="UTF-8"?>\n<doc>\n<link xmlns="http://www.w3.org/1999/xhtml" />\n</doc>';
+
+ doc = parser.parseFromString(str,"application/xml");
+ result = serializer.serializeToString(doc);
+ result = result.replace(/\r\n/mg, "\n");
+ is(result, expected, "serialization of a link element with no content but with an ended tag, inside an xml document");
+
+ // with no content
+ str = '<?xml version="1.0"?><doc>\n<link xmlns="http://www.w3.org/1999/xhtml"/>\n</doc>';
+ expected = '<?xml version="1.0" encoding="UTF-8"?>\n<doc>\n<link xmlns="http://www.w3.org/1999/xhtml" />\n</doc>';
+
+ doc = parser.parseFromString(str,"application/xml");
+ result = serializer.serializeToString(doc);
+ result = result.replace(/\r\n/mg, "\n");
+ is(result, expected, "serialization of a link element with no content, inside an xml document");
+
+
+ doc = $("testframe").contentDocument;
+ encoder.init(doc, "text/html", de.OutputLFLineBreak);
+ encoder.setCharset("UTF-8");
+ result = encoder.encodeToString();
+ expected = '<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">\n <title>Test</title>\n';
+ expected += ' <link rel=\"Top\" href=\"\"> ';
+ expected += ' </head><body>foo \n\n\n <p>Hello world</p>\n</body></html>';
+ is(result, expected, "serialization of a link element with content, inside an html document");
+
+ doc = $("testframe2").contentDocument;
+ encoder.init(doc, "application/xhtml+xml", de.OutputLFLineBreak);
+ encoder.setCharset("UTF-8");
+ result = encoder.encodeToString();
+ expected = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n';
+ expected += '<html xmlns="http://www.w3.org/1999/xhtml">\n<head>\n <meta http-equiv="content-type" content="text/html; charset=UTF-8" />\n <title>Test</title>\n';
+ expected += ' <link rel="Top" href=""> foo </link>\n';
+ expected += '\n</head>\n<body>\n <p>Hello world</p>\n</body>\n</html>';
+ is(result, expected, "serialization of a link element with content, inside an xhtml document");
+
+ SimpleTest.finish();
+}
+
+
+SimpleTest.waitForExplicitFinish();
+
+addLoadEvent(testSerializer);
+
+</script>
+</pre>
+</body>
+</html>
+
+