gecko-dev/intl/uconv/tests/test_long_doc.html

71 строка
4.7 KiB
HTML

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=718573
-->
<head>
<title>Test for Bug 718573</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=718573">Mozilla Bug 718573</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Bug 718573 **/
/* Text longer than 2K bytes to ensure that it crosses a block boundary
while decoding */
const inString = "Many years ago, I contracted an intimacy with a Mr. William Legrand. He was of an ancient Huguenot family, and had once been wealthy; but a series of misfortunes had reduced him to want. To avoid the mortification consequent upon his disasters, he left New Orleans, the city of his forefathers, and took up his residence at Sullivan's Island, near Charleston, South Carolina. This island is a very singular one. It consists of little else than the sea sand, and is about three miles long. Its breadth at no point exceeds a quarter of a mile. It is separated from the mainland by a scarcely perceptible creek, oozing its way through a wilderness of reeds and slime, a favorite resort of the marsh-hen. The vegetation, as might be supposed, is scant, or at least dwarfish. No trees of any magnitude are to be seen. Near the western extremity, where Fort Moultrie stands, and where are some miserable frame buildings, tenanted, during summer, by the fugitives from Charleston dust and fever, may be found, indeed, the bristly palmetto; but the whole island, with the exception of this western point, and a line of hard, white beach on the sea-coast, is covered with a dense undergrowth of the sweet myrtle so much prized by the horticulturists of England. The shrub here often attains the height of fifteen or twenty feet, and forms an almost impenetrable coppice, burthening the air with its fragrance. In the inmost recesses of this coppice, not far from the eastern or more remote end of the island, Legrand had built himself a small hut, which he occupied when I first, by mere accident, made his acquaintance. This soon ripened into friendship -- for there was much in the recluse to excite interest and esteem. I found him well educated, with unusual powers of mind, but infected with misanthropy, and subject to perverse moods of alternate enthusiasm and melancholy. He had with him many books, but rarely employed them. His chief amusements were gunning and fishing, or sauntering along the beach and through the myrtles, in quest of shells or entomological specimens -- his collection of the latter might have been envied by a Swammerdamm. In these excursions he was usually accompanied by an old negro, called Jupiter, who had been manumitted before the reverses of the family, but who could be induced, neither by threats nor by promises, to abandon what he considered his right of attendance upon the footsteps of his young 'Massa Will.' It is not improbable that the relatives of Legrand, conceiving him to be somewhat unsettled in intellect, had contrived to instil this obstinacy into Jupiter, with a view to the supervision and guardianship of the wanderer. ";
const testContent = "<pre id='testPara'>" + inString;
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
const Ci = Components.interfaces;
const Cc = Components.classes;
var ccManager = Cc["@mozilla.org/charset-converter-manager;1"].getService(Ci.nsICharsetConverterManager);
var decoderList = ccManager.getDecoderList();
SimpleTest.waitForExplicitFinish();
while (decoderList.hasMore()) {
var decoder = decoderList.getNext();
// Skip UTF-16 variants. (Other non-ASCII compatible encodings will be
// ignored anyway because of bug 601429
if (decoder.substring(0, 6) == "UTF-16")
continue;
data = encodeURI(testContent);
var dataURI = "data:text/html;charset=" + decoder + "," + data;
var testFrame = document.createElement("iframe");
frameID = decoder;
testFrame.setAttribute("id", frameID);
var testFrameObj = document.body.appendChild(testFrame);
if (decoderList.hasMore())
testFrameObj.setAttribute("onload", "testDecoding('" + decoder + "')");
else
testFrameObj.setAttribute("onload", "lastTest('" + decoder + "')");
testFrameObj.contentDocument.location.assign(dataURI);
}
function lastTest(frame)
{
testDecoding(frame);
SimpleTest.finish();
}
function testDecoding(frame)
{
var iframeDoc = $(frame).contentDocument;
var outString = iframeDoc.getElementById("testPara").innerHTML;
is(outString, inString, "content decoded as " + frame);
}
</script>
</pre>
</body>
</html>