summaryrefslogtreecommitdiffstats
path: root/dom/base/test/test_bug498433.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_bug498433.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_bug498433.html')
-rw-r--r--dom/base/test/test_bug498433.html104
1 files changed, 104 insertions, 0 deletions
diff --git a/dom/base/test/test_bug498433.html b/dom/base/test/test_bug498433.html
new file mode 100644
index 000000000..5bafcd2ea
--- /dev/null
+++ b/dom/base/test/test_bug498433.html
@@ -0,0 +1,104 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+-->
+<head>
+ <title>Test for HTML serializer</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=498433">Mozilla Bug </a>
+<p id="display"></p>
+<div id="content" style="display: none">
+ <iframe id="testframe" src="file_htmlserializer_ipv6.html">
+ </iframe>
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+
+function loadFileContent(aFile, aCharset) {
+ if (aCharset == undefined)
+ aCharset = 'UTF-8';
+
+ var baseUri = SpecialPowers.Cc['@mozilla.org/network/standard-url;1']
+ .createInstance(SpecialPowers.Ci.nsIURI);
+ baseUri.spec = window.location.href;
+
+ var ios = SpecialPowers.Cc['@mozilla.org/network/io-service;1']
+ .getService(SpecialPowers.Ci.nsIIOService);
+ var chann = ios.newChannel2(aFile,
+ aCharset,
+ baseUri,
+ null, // aLoadingNode
+ SpecialPowers.Services.scriptSecurityManager.getSystemPrincipal(),
+ null, // aTriggeringPrincipal
+ SpecialPowers.Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
+ SpecialPowers.Ci.nsIContentPolicy.TYPE_OTHER);
+
+ var cis = SpecialPowers.Ci.nsIConverterInputStream;
+
+ var inputStream = SpecialPowers.Cc["@mozilla.org/intl/converter-input-stream;1"]
+ .createInstance(cis);
+ inputStream.init(chann.open2(), aCharset, 1024, cis.DEFAULT_REPLACEMENT_CHARACTER);
+ var str = {}, content = '';
+ while (inputStream.readString(4096, str) != 0) {
+ content += str.value;
+ }
+ return content;
+}
+
+function isRoughly(actual, expected, message) {
+ return is(actual.replace("<!DOCTYPE HTML", "<!DOCTYPE html"),
+ expected,
+ message);
+}
+
+function testHtmlSerializer_1 () {
+ const de = SpecialPowers.Ci.nsIDocumentEncoder;
+ var encoder = SpecialPowers.Cc["@mozilla.org/layout/documentEncoder;1?type=text/html"]
+ .createInstance(SpecialPowers.Ci.nsIDocumentEncoder);
+
+ var doc = $("testframe").contentDocument;
+ var out, expected;
+
+ // in the following tests, we must use the OutputLFLineBreak flag, to avoid
+ // to have the default line break of the platform in the result, so the test
+ // can pass on all platform
+
+ //------------ no flags
+ encoder.init(doc, "text/html", de.OutputLFLineBreak);
+ encoder.setCharset("UTF-8");
+ out = encoder.encodeToString();
+ expected = loadFileContent("file_htmlserializer_ipv6_out.html");
+ isRoughly(out, expected, "test no flags");
+ //------------ OutputAbsoluteLinks
+ encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputAbsoluteLinks);
+ encoder.setCharset("UTF-8");
+ out = encoder.encodeToString();
+ expected = loadFileContent("file_htmlserializer_ipv6_out.html");
+ isRoughly(out, expected, "test OutputAbsoluteLinks");
+ //------------ serializing a selection
+ encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputAbsoluteLinks);
+ encoder.setNode(doc.links[0]);
+ out = encoder.encodeToString();
+ expected = "<a href=\"http://[2001:4860:a003::68]/\">Test</a>";
+ isRoughly(out, expected, "test selection");
+
+
+ SimpleTest.finish();
+}
+
+
+SimpleTest.waitForExplicitFinish();
+
+addLoadEvent(testHtmlSerializer_1);
+
+</script>
+</pre>
+
+</body>
+</html>
+
+