Bug 1061469 - part 8: Encoding for Imports. r=mrbkap
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -3515,16 +3515,20 @@ nsDocument::GetBaseTarget(nsAString &aBa
void
nsDocument::SetDocumentCharacterSet(const nsACString& aCharSetID)
{
// XXX it would be a good idea to assert the sanity of the argument,
// but before we figure out what to do about non-Encoding Standard
// encodings in the charset menu and in mailnews, assertions are futile.
if (!mCharacterSet.Equals(aCharSetID)) {
+ if (mMasterDocument && !aCharSetID.EqualsLiteral("UTF-8")) {
+ // Imports are always UTF-8
+ return;
+ }
mCharacterSet = aCharSetID;
int32_t n = mCharSetObservers.Length();
for (int32_t i = 0; i < n; i++) {
nsIObserver* observer = mCharSetObservers.ElementAt(i);
observer->Observe(static_cast<nsIDocument *>(this), "charset",
new file mode 100644
--- /dev/null
+++ b/content/html/content/test/imports/file_encoding.html
@@ -0,0 +1,5 @@
+<!DOCTYPE html>
+<head>
+<meta charset="EUC-KR">
+</head>
+<body>Ignore my encoding</body>
\ No newline at end of file
--- a/content/html/content/test/imports/mochitest.ini
+++ b/content/html/content/test/imports/mochitest.ini
@@ -30,19 +30,21 @@ support-files =
file_cycle_4_B.html
file_cycle_4_C.html
file_cycle_4_D.html
file_cycle_4_E.html
file_cycle_5_A.html
file_cycle_5_B.html
file_cycle_5_C.html
file_cycle_5_D.html
+ file_encoding.html
[test_cycle_1.html]
skip-if = toolkit == 'gonk' # nested imports fail on b2g emulator
[test_cycle_2.html]
skip-if = toolkit == 'gonk' # nested imports fail on b2g emulator
[test_cycle_3.html]
skip-if = toolkit == 'gonk' # nested imports fail on b2g emulator
[test_cycle_4.html]
skip-if = toolkit == 'gonk' # nested imports fail on b2g emulator
[test_cycle_5.html]
skip-if = toolkit == 'gonk' # nested imports fail on b2g emulator
+[test_encoding.html]
new file mode 100644
--- /dev/null
+++ b/content/html/content/test/imports/test_encoding.html
@@ -0,0 +1,30 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1061469
+-->
+<head>
+ <title>Test for Bug 1061469</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
+</head>
+<body>
+ <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1061469">Mozilla Bug 1061469</a>
+ <script type="text/javascript">
+ SimpleTest.waitForExplicitFinish();
+ var success = false;
+ function loaded() {
+ success = true;
+ }
+ function failed() {
+ ok(false, "Import loading failed");
+ }
+ </script>
+ <link rel="import" href="file_encoding.html" id="import" onload="loaded()" onerror="failed()"></link>
+ <script type="text/javascript">
+ is(document.getElementById("import").import.characterSet, "UTF-8", "characterSet should be UTF-8 for imports");
+ SimpleTest.finish();
+ </script>
+</body>
+</html>
\ No newline at end of file