Regression test for bug 92473

git-svn-id: svn://10.0.0.236/trunk@236987 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
smontagu%smontagu.org 2007-10-01 14:14:58 +00:00
parent fe7e7cc622
commit 418b960267
3 changed files with 74 additions and 0 deletions

View File

@ -44,6 +44,8 @@ include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_BROWSER_TEST_FILES = \
browser_bug92473.js \
test-form_sjis.html \
browser_bug349769.js \
browser_bug388121-1.js \
browser_bug388121-2.js \

View File

@ -0,0 +1,50 @@
const Ci = Components.interfaces;
const Cc = Components.classes;
/* The test text decoded correctly as Shift_JIS */
const rightText="\u30E6\u30CB\u30B3\u30FC\u30C9\u306F\u3001\u3059\u3079\u3066\u306E\u6587\u5B57\u306B\u56FA\u6709\u306E\u756A\u53F7\u3092\u4ED8\u4E0E\u3057\u307E\u3059";
/* The test text decoded incorrectly as Windows-1251. This is the "right" wrong
text; anything else is unexpected. */
const wrongText="\u0453\u2020\u0453\u006A\u0453\u0052\u0403\u005B\u0453\u0068\u201A\u041D\u0403\u0041\u201A\u00B7\u201A\u0427\u201A\u0414\u201A\u041C\u2022\u00B6\u040B\u0459\u201A\u0419\u040A\u0415\u2014\u004C\u201A\u041C\u201D\u0424\u040C\u2020\u201A\u0440\u2022\u0074\u2014\u005E\u201A\u00B5\u201A\u042C\u201A\u00B7";
var testPage;
function url(spec) {
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
return ios.newURI(spec, null, null);
}
function testContent(text) {
is(testPage.document.getElementById("testpar").innerHTML, text,
"<p> contains expected text");
is(testPage.document.getElementById("testtextarea").innerHTML, text,
"<textarea> contains expected text");
is(testPage.document.getElementById("testinput").value, text,
"<input> contains expected text");
}
function afterOpen() {
/* Test that the content on load is the expected wrong decoding */
testContent(wrongText);
/* Force the page encoding to Shift_JIS */
SetForcedCharset("Shift_JIS");
setTimeout(afterChangeCharset, 3000);
}
function afterChangeCharset() {
/* test that the content is decoded correctly */
testContent(rightText);
testPage.close();
finish();
}
function test() {
var activeWin = Application.activeWindow;
testPage = activeWin.open(url("chrome://mochikit/content/browser/docshell/test/browser/test-form_sjis.html"));
testPage.focus();
waitForExplicitFinish();
setTimeout(afterOpen, 1000);
}

View File

@ -0,0 +1,22 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/REC-html401-19991224/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1251">
<title>Shift_JIS in body and text area</title>
</head>
<body>
<h1>Incorrect meta charset</h1>
<h2>This page is encoded in Shift_JIS, but has an incorrect meta charset
claiming that it is windows-1251</h2>
<p id="testpar">ユニコードは、すべての文字に固有の番号を付与します</p>
<p>
<textarea id="testtextarea" rows=6 cols=60>ユニコードは、すべての文字に固有の番号を付与します</textarea>
<input id="testinput" type="text" size=60 value="ユニコードは、すべての文字に固有の番号を付与します">
</p>
<h2>Expected text on load:</h2>
<p>&#x453;&#x2020;&#x453;&#x6A;&#x453;&#x52;&#x403;&#x5B;&#x453;&#x68;&#x201A;&#x41D;&#x403;&#x41;&#x201A;&#xB7;&#x201A;&#x427;&#x201A;&#x414;&#x201A;&#x41C;&#x2022;&#xB6;&#x40B;&#x459;&#x201A;&#x419;&#x40A;&#x415;&#x2014;&#x4C;&#x201A;&#x41C;&#x201D;&#x424;&#x40C;&#x2020;&#x201A;&#x440;&#x2022;&#x74;&#x2014;&#x5E;&#x201A;&#xB5;&#x201A;&#x42C;&#x201A;&#xB7;</p>
<h2>Expected text on resetting the encoding to Shift_JIS:</h2>
<p>&#x30E6;&#x30CB;&#x30B3;&#x30FC;&#x30C9;&#x306F;&#x3001;&#x3059;&#x3079;&#x3066;&#x306E;&#x6587;&#x5B57;&#x306B;&#x56FA;&#x6709;&#x306E;&#x756A;&#x53F7;&#x3092;&#x4ED8;&#x4E0E;&#x3057;&#x307E;&#x3059;</p>
</body>
</html>