diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/base/test/test_bug422403-1.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-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_bug422403-1.html')
-rw-r--r-- | dom/base/test/test_bug422403-1.html | 204 |
1 files changed, 204 insertions, 0 deletions
diff --git a/dom/base/test/test_bug422403-1.html b/dom/base/test/test_bug422403-1.html new file mode 100644 index 000000000..fa6cbbd84 --- /dev/null +++ b/dom/base/test/test_bug422403-1.html @@ -0,0 +1,204 @@ +<!DOCTYPE HTML> +<html> +<!-- +--> +<head> + <title>Test for XHTML 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=422043">Mozilla Bug </a> +<p id="display"></p> +<div id="content" style="display: none"> +</div> +<!-- IMPORTANT: This iframe needs to actually be displayed, so the serializer + sees the relevant styles for <pre> elements. --> +<iframe id="testframe" src="file_xhtmlserializer_1.xhtml"></iframe> +<pre id="test"> +<script class="testbody" type="text/javascript"> + + +function loadFileContent(aFile, aCharset) { + //if(aAsIso == undefined) aAsIso = false; + 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 testHtmlSerializer_1 () { + const de = SpecialPowers.Ci.nsIDocumentEncoder + var encoder = SpecialPowers.Cc["@mozilla.org/layout/documentEncoder;1?type=application/xhtml+xml"] + .createInstance(SpecialPowers.Ci.nsIDocumentEncoder); + + var doc = SpecialPowers.wrap($("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, "application/xhtml+xml", de.OutputLFLineBreak); + encoder.setCharset("UTF-8"); + out = encoder.encodeToString(); + expected = loadFileContent("file_xhtmlserializer_1_noflag.xhtml"); + is(out, expected, "test no flags"); + + //------------- unsupported flags + // since the following flags are not supported, we should + // have a result like the one without flag + encoder.init(doc, "application/xhtml+xml", de.OutputLFLineBreak | de.OutputPreformatted); + out = encoder.encodeToString(); + is(out, expected, "test OutputPreformatted"); + + encoder.init(doc, "application/xhtml+xml", de.OutputLFLineBreak | de.OutputFormatFlowed); + out = encoder.encodeToString(); + is(out, expected, "test OutputFormatFlowed"); + + encoder.init(doc, "application/xhtml+xml", de.OutputLFLineBreak | de.OutputNoScriptContent); + out = encoder.encodeToString(); + is(out, expected, "test OutputNoScriptContent"); + + encoder.init(doc, "application/xhtml+xml", de.OutputLFLineBreak | de.OutputNoFramesContent); + out = encoder.encodeToString(); + is(out, expected, "test OutputNoFramesContent"); + + + //------------ OutputWrap + encoder.init(doc, "application/xhtml+xml", de.OutputLFLineBreak | de.OutputWrap); + out = encoder.encodeToString(); + expected = loadFileContent("file_xhtmlserializer_1_wrap.xhtml"); + is(out, expected, "test OutputWrap"); + + //------------ OutputFormatted + encoder.init(doc, "application/xhtml+xml", de.OutputLFLineBreak | de.OutputFormatted); + out = encoder.encodeToString(); + expected = loadFileContent("file_xhtmlserializer_1_format.xhtml"); + is(out, expected, "test OutputFormatted"); + + //------------ OutputRaw + encoder.init(doc, "application/xhtml+xml", de.OutputLFLineBreak | de.OutputRaw); + out = encoder.encodeToString(); + expected = loadFileContent("file_xhtmlserializer_1_raw.xhtml"); + is(out, expected, "test OutputRaw"); + + //------------ OutputBodyOnly + encoder.init(doc, "application/xhtml+xml", de.OutputLFLineBreak | de.OutputBodyOnly); + out = encoder.encodeToString(); + expected = loadFileContent("file_xhtmlserializer_1_bodyonly.xhtml"); + is(out, expected, "test OutputBodyOnly"); + + + //------------ OutputAbsoluteLinks + encoder.init(doc, "application/xhtml+xml", de.OutputLFLineBreak | de.OutputAbsoluteLinks); + out = encoder.encodeToString(); + expected = loadFileContent("file_xhtmlserializer_1_links.xhtml").trim('\n'); + is(out, expected, "test OutputAbsoluteLinks"); + + //------------ OutputLFLineBreak + encoder.init(doc, "application/xhtml+xml",de.OutputLFLineBreak); + out = encoder.encodeToString(); + expected = loadFileContent("file_xhtmlserializer_1_linebreak.xhtml"); + is(out, expected, "test OutputLFLineBreak"); + + //------------ OutputCRLineBreak + encoder.init(doc, "application/xhtml+xml",de.OutputCRLineBreak); + out = encoder.encodeToString(); + expected = expected.replace(/\n/mg, "\r"); + is(out, expected, "test OutputCRLineBreak"); + + //------------ OutputLFLineBreak + OutputCRLineBreak + encoder.init(doc, "application/xhtml+xml", de.OutputLFLineBreak | de.OutputCRLineBreak); + out = encoder.encodeToString(); + expected = expected.replace(/\r/mg, "\r\n"); + is(out, expected, "test OutputLFLineBreak + OutputCRLineBreak"); + + //------------ OutputNoFormattingInPre + encoder.init(doc, "application/xhtml+xml", de.OutputLFLineBreak | de.OutputNoFormattingInPre); + out = encoder.encodeToString(); + expected = loadFileContent("file_xhtmlserializer_1_noformatpre.xhtml"); + is(out, expected, "test OutputNoFormattingInPre"); + + // ------------- nested body elements + var body2 = doc.createElement('body'); + var p = doc.createElement('p'); + p.appendChild(doc.createTextNode("this is an other body element")); + body2.appendChild(p); + var body = doc.getElementsByTagName('body')[0]; + body.appendChild(body2); + + is(doc.getElementsByTagName('body').length, 2); // to be sure we have two body elements + + encoder.init(doc, "application/xhtml+xml", de.OutputLFLineBreak); + encoder.setCharset("UTF-8"); + out = encoder.encodeToString(); + expected = loadFileContent("file_xhtmlserializer_1_nested_body.xhtml"); + is(out, expected, "test with two nested body elements"); + + // ------------- two body elements + body.parentNode.insertBefore(body2, body); + + is(doc.getElementsByTagName('body').length, 2); // to be sure we have two body elements + encoder.init(doc, "application/xhtml+xml", de.OutputLFLineBreak); + encoder.setCharset("UTF-8"); + out = encoder.encodeToString(); + expected = loadFileContent("file_xhtmlserializer_1_sibling_body.xhtml"); + is(out, expected, "test with two body elements"); + + encoder.init(doc, "application/xhtml+xml", de.OutputLFLineBreak | de.OutputBodyOnly); + encoder.setCharset("UTF-8"); + out = encoder.encodeToString(); + expected = loadFileContent("file_xhtmlserializer_1_sibling_body_only_body.xhtml"); + is(out, expected, "test with two body elements, and output body only"); + + // --------------- no body element + doc.documentElement.removeChild(body); + doc.documentElement.removeChild(body2); + + encoder.init(doc, "application/xhtml+xml", de.OutputLFLineBreak); + encoder.setCharset("UTF-8"); + out = encoder.encodeToString(); + expected = loadFileContent("file_xhtmlserializer_1_no_body.xhtml"); + is(out, expected, "test with no body element"); + + SimpleTest.finish(); +} + + +SimpleTest.waitForExplicitFinish(); + +addLoadEvent(testHtmlSerializer_1); + +</script> +</pre> +</body> +</html> + + |