Bug 941562 - Make the encoding of documents that declare HZ unoverridable. r=emk.

--HG--
rename : docshell/test/browser/browser_bug234628-6.js => docshell/test/browser/browser_bug941562.js
rename : docshell/test/browser/file_bug234628-7-child.html => docshell/test/browser/file_bug941562-child.html
rename : docshell/test/browser/file_bug234628-6.html => docshell/test/browser/file_bug941562.html
This commit is contained in:
Henri Sivonen 2013-11-25 10:06:56 +02:00
parent d0c0e04f69
commit cb7155f1bd
5 changed files with 73 additions and 0 deletions

View File

@ -30,6 +30,8 @@ support-files =
file_bug503832.html
file_bug655270.html
file_bug670318.html
file_bug941562-child.html
file_bug941562.html
print_postdata.sjs
test-form_sjis.html
@ -58,6 +60,7 @@ support-files =
[browser_bug670318.js]
[browser_bug673467.js]
[browser_bug92473.js]
[browser_bug941562.js]
[browser_loadDisallowInherit.js]
[browser_loadURI.js]
[browser_search_notification.js]

View File

@ -0,0 +1,39 @@
function test() {
waitForExplicitFinish();
var rootDir = "http://mochi.test:8888/browser/docshell/test/browser/";
gBrowser.selectedTab = gBrowser.addTab(rootDir + "file_bug941562.html");
gBrowser.selectedBrowser.addEventListener("load", afterOpen, true);
}
function afterOpen(event) {
if (event.target != gBrowser.contentDocument) {
return;
}
gBrowser.selectedBrowser.removeEventListener("load", afterOpen, true);
gBrowser.selectedBrowser.addEventListener("load", afterChangeCharset, true);
is(gBrowser.contentDocument.documentElement.textContent.indexOf('\u20AC'), 140, "Parent doc should be windows-1252 initially");
is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.documentElement.textContent.indexOf('\u4E2D'), 77, "Child doc should be HZ-GB-2312 initially");
BrowserSetForcedCharacterSet("windows-1251");
}
function afterChangeCharset(event) {
if (event.target != gBrowser.contentDocument) {
return;
}
gBrowser.selectedBrowser.removeEventListener("load", afterChangeCharset, true);
is(gBrowser.contentDocument.documentElement.textContent.indexOf('\u0402'), 140, "Parent doc should decode as windows-1251 subsequently");
is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.documentElement.textContent.indexOf('\u4E2D'), 77, "Child doc should decode as HZ-GB-2312 subsequently");
is(gBrowser.contentDocument.characterSet, "windows-1251", "Parent doc should report windows-1251 subsequently");
is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.characterSet, "HZ-GB-2312", "Child doc should report HZ-GB-2312 subsequently");
gBrowser.removeCurrentTab();
finish();
}

View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="hz-gb-2312">
<meta content="width=device-width, initial-scale=1" name="viewport">
<title>meta declaration in parent and meta HZ in child</title>
</head>
<body>
<p>China if decoded as HZ: ~{VP~}</p>
</body>
</html>

View File

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="windows-1252">
<meta content="width=device-width, initial-scale=1" name="viewport">
<title>meta declaration in parent and meta HZ in child</title>
</head>
<body>
<h1>meta declaration in parent and meta HZ in child</h1>
<p>Euro sign if decoded as Windows-1252: €</p>
<p>a with diaeresis if decoded as Windows-1252: ä</p>
<iframe src="file_bug941562-child.html"></iframe>
</body>
</html>

View File

@ -39,6 +39,7 @@ EncodingUtils::IsAsciiCompatible(const nsACString& aPreferredName)
aPreferredName.LowerCaseEqualsLiteral("utf-16be") ||
aPreferredName.LowerCaseEqualsLiteral("utf-16le") ||
aPreferredName.LowerCaseEqualsLiteral("replacement") ||
aPreferredName.LowerCaseEqualsLiteral("hz-gb-2312") ||
aPreferredName.LowerCaseEqualsLiteral("utf-7") ||
aPreferredName.LowerCaseEqualsLiteral("x-imap4-modified-utf7"));
}