Define langgroups for all charset decoders

This commit is contained in:
smontagu%smontagu.org 2007-11-11 19:52:34 +00:00
Родитель 2ce7118eec
Коммит b23fe01d80
4 изменённых файлов: 158 добавлений и 0 удалений

Просмотреть файл

@ -112,6 +112,7 @@ ibm855.LangGroup = x-cyrillic
ibm857.LangGroup = tr
ibm862.LangGroup = he
ibm864.LangGroup = ar
ibm864i.LangGroup = ar
ibm866.LangGroup = x-cyrillic
ibm869.LangGroup = el
ibm1125.LangGroup = x-cyrillic
@ -121,8 +122,11 @@ iso-2022-cn.LangGroup = zh-CN
iso-2022-jp.LangGroup = ja
iso-2022-kr.LangGroup = ko
iso-8859-1.LangGroup = x-western
iso-8859-10.LangGroup = x-western
iso-8859-14.LangGroup = x-western
iso-8859-15.LangGroup = x-western
iso-8859-2.LangGroup = x-central-euro
iso-8859-16.LangGroup = x-central-euro
iso-8859-3.LangGroup = x-western
iso-8859-4.LangGroup = x-baltic
iso-8859-13.LangGroup = x-baltic
@ -138,6 +142,7 @@ iso-8859-9.LangGroup = tr
jis_0208-1983.LangGroup = ja
koi8-r.LangGroup = x-cyrillic
koi8-u.LangGroup = x-cyrillic
iso-ir-111.LangGroup = x-cyrillic
shift_jis.LangGroup = ja
tis-620.LangGroup = th
tis620-2.LangGroup = th
@ -145,6 +150,7 @@ windows-874.LangGroup = th
iso-8859-11.LangGroup = th
x-thaittf-0.LangGroup = th
us-ascii.LangGroup = x-western
t.61-8bit.LangGroup = x-western
utf-8.LangGroup = x-unicode
utf-16.LangGroup = x-unicode
utf-16be.LangGroup = x-unicode
@ -153,6 +159,10 @@ utf-32.LangGroup = x-unicode
utf-32be.LangGroup = x-unicode
utf-32le.LangGroup = x-unicode
utf-7.LangGroup = x-unicode
x-imap4-modified-utf7.LangGroup = x-unicode
viscii.LangGroup = x-western
x-viet-tcvn5712.LangGroup = x-western
x-viet-vps.LangGroup = x-western
windows-1250.LangGroup = x-central-euro
windows-1251.LangGroup = x-cyrillic
windows-1252.LangGroup = x-western
@ -161,6 +171,7 @@ windows-1254.LangGroup = tr
windows-1255.LangGroup = he
windows-1256.LangGroup = ar
windows-1257.LangGroup = x-baltic
windows-1258.LangGroup = x-western
windows-936.LangGroup = zh-CN
x-cns-11643-1.LangGroup = zh-TW
x-euc-tw.LangGroup = zh-TW
@ -168,12 +179,18 @@ x-gbk.LangGroup = zh-CN
gb_2312-80.LangGroup = zh-CN
x-gbk-noascii.LangGroup = zh-CN
x-mac-ce.LangGroup = x-central-euro
x-mac-croatian.LangGroup = x-central-euro
x-mac-cyrillic.LangGroup = x-cyrillic
x-mac-devanagari.LangGroup = x-devanagari
x-mac-farsi.LangGroup = ar
x-mac-greek.LangGroup = el
x-mac-gujarati.LangGroup = x-gujr
x-mac-gurmukhi.LangGroup = x-guru
x-mac-icelandic.LangGroup = x-western
x-mac-roman.LangGroup = x-western
x-mac-turkish.LangGroup = tr
x-mac-ukrainian.LangGroup = x-cyrillic
x-mac-romanian.LangGroup = x-central-euro
x-user-defined.LangGroup = x-user-def
ks_c_5601-1987.LangGroup = ko
x-x11johab.LangGroup = ko

Просмотреть файл

@ -0,0 +1,21 @@
function run_test()
{
var failures = false;
var ccManager =
Components.classes["@mozilla.org/charset-converter-manager;1"]
.getService(Components.interfaces.nsICharsetConverterManager);
var decoderList = ccManager.getDecoderList();
while (decoderList.hasMore()) {
var decoder = decoderList.getNext();
try {
var langGroup = ccManager.getCharsetLangGroup(decoder);
} catch(e) {
dump("no langGroup for " + decoder + "\n");
failures = true;
}
}
if (failures) {
do_throw("missing langGroups");
}
}

Просмотреть файл

@ -83,6 +83,7 @@ ifdef MOZ_MOCHITEST
_TEST_FILES = \
test_bug66619.html \
test_bug388019.html \
test_bug399284.html \
test_bug399951.html \
$(NULL)

Просмотреть файл

@ -0,0 +1,119 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=399284
-->
<head>
<title>Test for Bug 399284</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=399284">Mozilla Bug 399284</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Bug 399284 **/
const testContent = "<p id='testPara'>The quick brown fox jumps over the lazy dog";
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();
// encode the content for non-ASCII compatible encodings
if (decoder == "UTF-16" || decoder == "UTF-16BE")
data = encodeUTF16BE(testContent);
else if (decoder == "UTF-16LE")
data = encodeUTF16LE(testContent);
else if (decoder == "UTF-32BE")
data = encodeUTF32BE(testContent);
else if (decoder == "UTF-32LE")
data = encodeUTF32LE(testContent);
else
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", "testFontSize('" + decoder + "')");
else
testFrameObj.setAttribute("onload", "lastTest('" + decoder + "')");
testFrameObj.contentDocument.location.assign(dataURI);
}
function encodeUTF16BE(string)
{
var encodedString = "";
for (i = 0; i < string.length; ++i) {
encodedString += "%00";
encodedString += encodeURI(string.charAt(i));
}
return encodedString;
}
function encodeUTF16LE(string)
{
var encodedString = "";
for (i = 0; i < string.length; ++i) {
encodedString += encodeURI(string.charAt(i));
encodedString += "%00";
}
return encodedString;
}
function encodeUTF32BE(string)
{
var encodedString = "";
for (i = 0; i < string.length; ++i) {
encodedString += "%00";
encodedString += "%00";
encodedString += "%00";
encodedString += encodeURI(string.charAt(i));
}
return encodedString;
}
function encodeUTF32LE(string)
{
var encodedString = "";
for (i = 0; i < string.length; ++i) {
encodedString += encodeURI(string.charAt(i));
encodedString += "%00";
encodedString += "%00";
encodedString += "%00";
}
return encodedString;
}
function lastTest(frame)
{
testFontSize(frame);
SimpleTest.finish();
}
function testFontSize(frame)
{
var iframeDoc = $(frame).contentDocument;
var size = parseInt(iframeDoc.defaultView.
getComputedStyle(iframeDoc.getElementById("testPara"),
null).
getPropertyValue("font-size"));
ok(size > 0, "font size assigned for " + frame);
}
</script>
</pre>
</body>
</html>