mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
96 lines
3.4 KiB
HTML
96 lines
3.4 KiB
HTML
|
<!DOCTYPE HTML>
|
||
|
<html>
|
||
|
<!--
|
||
|
-->
|
||
|
<head>
|
||
|
<title>Test HTML serializer with entities</title>
|
||
|
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||
|
<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=424359">Mozilla Bug </a>
|
||
|
<p id="display"></p>
|
||
|
<div id="content" style="display: none">
|
||
|
<iframe id="testframe" src="file_htmlserializer_2.html">
|
||
|
</iframe>
|
||
|
</div>
|
||
|
<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 = Components.classes['@mozilla.org/network/standard-url;1']
|
||
|
.createInstance(Components.interfaces.nsIURI);
|
||
|
baseUri.spec = window.location.href;
|
||
|
|
||
|
var ios = Components.classes['@mozilla.org/network/io-service;1']
|
||
|
.getService(Components.interfaces.nsIIOService);
|
||
|
var chann = ios.newChannel(aFile, aCharset, baseUri);
|
||
|
|
||
|
var cis = Components.interfaces.nsIConverterInputStream;
|
||
|
|
||
|
var inputStream = Components.classes["@mozilla.org/intl/converter-input-stream;1"]
|
||
|
.createInstance(cis);
|
||
|
inputStream.init(chann.open(), aCharset, 1024, cis.DEFAULT_REPLACEMENT_CHARACTER);
|
||
|
var str = {}, content = '';
|
||
|
while (inputStream.readString(4096, str) != 0) {
|
||
|
content += str.value;
|
||
|
}
|
||
|
return content;
|
||
|
}
|
||
|
|
||
|
|
||
|
function testHtmlSerializer_1 () {
|
||
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||
|
const de = Components.interfaces.nsIDocumentEncoder
|
||
|
var encoder = Components.classes["@mozilla.org/layout/documentEncoder;1?type=text/html"]
|
||
|
.createInstance(Components.interfaces.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
|
||
|
|
||
|
//------------ OutputEncodeW3CEntities
|
||
|
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputEncodeW3CEntities);
|
||
|
out = encoder.encodeToString();
|
||
|
expected = loadFileContent("file_htmlserializer_2_entw3c.html");
|
||
|
is(out, expected, "test OutputEncodeW3CEntities");
|
||
|
|
||
|
//------------ OutputEncodeBasicEntities
|
||
|
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputEncodeBasicEntities);
|
||
|
out = encoder.encodeToString();
|
||
|
expected = loadFileContent("file_htmlserializer_2_basic.html");
|
||
|
is(out, expected, "test OutputEncodeBasicEntities");
|
||
|
|
||
|
//------------ OutputEncodeLatin1Entities
|
||
|
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputEncodeLatin1Entities);
|
||
|
out = encoder.encodeToString();
|
||
|
expected = loadFileContent("file_htmlserializer_2_latin1.html");
|
||
|
is(out, expected, "test OutputEncodeLatin1Entities");
|
||
|
|
||
|
//------------ OutputEncodeHTMLEntities
|
||
|
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputEncodeHTMLEntities);
|
||
|
out = encoder.encodeToString();
|
||
|
expected = loadFileContent("file_htmlserializer_2_enthtml.html");
|
||
|
is(out, expected, "test OutputEncodeHTMLEntities");
|
||
|
|
||
|
SimpleTest.finish();
|
||
|
}
|
||
|
|
||
|
|
||
|
SimpleTest.waitForExplicitFinish();
|
||
|
|
||
|
addLoadEvent(testHtmlSerializer_1);
|
||
|
|
||
|
</script>
|
||
|
</pre>
|
||
|
</body>
|
||
|
</html>
|