Bug 718500 - View > Character Encoding > Auto-Detect menupopup is broken. r=smontagu
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Wed, 18 Jan 2012 14:43:31 +0900
changeset 86003 715e4b7e3b51fded840bec05b9294cc9b8506feb
parent 86002 0673da2a834a2f128380f78788d2a4c45a5f518a
child 86004 7538f4d4697c67c34ce17cb567a35133eb4cb1bc
child 86017 9519fed510ee714348ebb4bbdafb22d7d5814240
push idunknown
push userunknown
push dateunknown
reviewerssmontagu
bugs718500
milestone12.0a1
Bug 718500 - View > Character Encoding > Auto-Detect menupopup is broken. r=smontagu
intl/uconv/src/nsCharsetConverterManager.cpp
intl/uconv/tests/unit/test_bug718500.js
intl/uconv/tests/unit/xpcshell.ini
--- a/intl/uconv/src/nsCharsetConverterManager.cpp
+++ b/intl/uconv/src/nsCharsetConverterManager.cpp
@@ -233,17 +233,16 @@ nsCharsetConverterManager::GetList(const
                                    const nsACString& aPrefix,
                                    nsIUTF8StringEnumerator** aResult)
 {
   if (aResult == NULL) 
     return NS_ERROR_NULL_POINTER;
   *aResult = NULL;
 
   nsresult rv;
-  nsCAutoString alias;
 
   nsCOMPtr<nsICategoryManager> catman = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
   if (NS_FAILED(rv))
     return rv;
 
   nsTArray<nsCString>* array = new nsTArray<nsCString>;
   if (!array)
     return NS_ERROR_OUT_OF_MEMORY;
@@ -257,28 +256,23 @@ nsCharsetConverterManager::GetList(const
     nsCOMPtr<nsISupports> supports;
     if (NS_FAILED(enumerator->GetNext(getter_AddRefs(supports))))
       continue;
     
     nsCOMPtr<nsISupportsCString> supStr = do_QueryInterface(supports);
     if (!supStr)
       continue;
 
-    nsCAutoString fullName(aPrefix);
-    
     nsCAutoString name;
     if (NS_FAILED(supStr->GetData(name)))
       continue;
 
-    fullName += name;
-    rv = GetCharsetAlias(fullName.get(), alias);
-    if (NS_FAILED(rv)) 
-      continue;
-
-    rv = array->AppendElement(alias) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
+    nsCAutoString fullName(aPrefix);
+    fullName.Append(name);
+    NS_ENSURE_TRUE(array->AppendElement(fullName), NS_ERROR_OUT_OF_MEMORY);
   }
     
   return NS_NewAdoptingUTF8StringEnumerator(aResult, array);
 }
 
 // we should change the interface so that we can just pass back a enumerator!
 NS_IMETHODIMP
 nsCharsetConverterManager::GetDecoderList(nsIUTF8StringEnumerator ** aResult)
@@ -312,17 +306,16 @@ nsCharsetConverterManager::GetCharsetAli
   NS_ENSURE_ARG_POINTER(aCharset);
 
   // We try to obtain the preferred name for this charset from the charset 
   // aliases.
   nsresult rv;
   nsCOMPtr<nsICharsetAlias> csAlias(do_GetService(NS_CHARSETALIAS_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsAutoString pref;
   rv = csAlias->GetPreferred(nsDependentCString(aCharset), aResult);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
 
 NS_IMETHODIMP
new file mode 100644
--- /dev/null
+++ b/intl/uconv/tests/unit/test_bug718500.js
@@ -0,0 +1,219 @@
+var detectList = [
+  "chardet.universal_charset_detector",
+  "chardet.ja_parallel_state_machine",
+  "chardet.ko_parallel_state_machine",
+  "chardet.zhtw_parallel_state_machine",
+  "chardet.zhcn_parallel_state_machine",
+  "chardet.zh_parallel_state_machine",
+  "chardet.cjk_parallel_state_machine",
+  "chardet.off",
+  "chardet.ruprob",
+  "chardet.ukprob",
+];
+
+var encoderList = [
+  "ISO-8859-1",
+  "windows-1252",
+  "x-mac-roman",
+  "UTF-8",
+  "us-ascii",
+  "ISO-8859-2",
+  "ISO-8859-3",
+  "ISO-8859-4",
+  "ISO-8859-5",
+  "ISO-8859-6",
+  "ISO-8859-6-I",
+  "ISO-8859-6-E",
+  "ISO-8859-7",
+  "ISO-8859-8",
+  "ISO-8859-8-I",
+  "ISO-8859-8-E",
+  "ISO-8859-9",
+  "ISO-8859-10",
+  "ISO-8859-13",
+  "ISO-8859-14",
+  "ISO-8859-15",
+  "ISO-8859-16",
+  "ISO-IR-111",
+  "windows-1250",
+  "windows-1251",
+  "windows-1253",
+  "windows-1254",
+  "windows-1255",
+  "windows-1256",
+  "windows-1257",
+  "windows-1258",
+  "TIS-620",
+  "windows-874",
+  "ISO-8859-11",
+  "KOI8-R",
+  "KOI8-U",
+  "x-mac-ce",
+  "x-mac-greek",
+  "x-mac-turkish",
+  "x-mac-croatian",
+  "x-mac-romanian",
+  "x-mac-cyrillic",
+  "x-mac-icelandic",
+  "armscii-8",
+  "x-viet-tcvn5712",
+  "VISCII",
+  "x-viet-vps",
+  "UTF-7",
+  "x-imap4-modified-utf7",
+  "UTF-16",
+  "UTF-16BE",
+  "UTF-16LE",
+  "T.61-8bit",
+  "x-user-defined",
+  "x-mac-arabic",
+  "x-mac-devanagari",
+  "x-mac-farsi",
+  "x-mac-gurmukhi",
+  "x-mac-gujarati",
+  "x-mac-hebrew",
+
+  "Adobe-Symbol-Encoding",
+  "x-zapf-dingbats",
+  "x-tscii",
+  "x-tamilttf-0",
+
+  "IBM850",
+  "IBM852",
+  "IBM855",
+  "IBM857",
+  "IBM862",
+  "IBM864",
+  "IBM864i",
+  "IBM866",
+  "Shift_JIS",
+  "ISO-2022-JP",
+  "EUC-JP",
+  "jis_0201",
+  "x-euc-tw",
+  "Big5",
+  "Big5-HKSCS",
+  "hkscs-1",
+  "EUC-KR",
+  "x-johab",
+  "x-windows-949",
+  "GB2312",
+  "gbk",
+  "HZ-GB-2312",
+  "gb18030",
+];
+
+var decoderList = [
+  "ISO-8859-1",
+  "windows-1252",
+  "x-mac-roman",
+  "UTF-8",
+  "us-ascii",
+  "ISO-8859-2",
+  "ISO-8859-3",
+  "ISO-8859-4",
+  "ISO-8859-5",
+  "ISO-8859-6",
+  "ISO-8859-6-I",
+  "ISO-8859-6-E",
+  "ISO-8859-7",
+  "ISO-8859-8",
+  "ISO-8859-8-I",
+  "ISO-8859-8-E",
+  "ISO-8859-9",
+  "ISO-8859-10",
+  "ISO-8859-13",
+  "ISO-8859-14",
+  "ISO-8859-15",
+  "ISO-8859-16",
+  "ISO-IR-111",
+  "windows-1250",
+  "windows-1251",
+  "windows-1253",
+  "windows-1254",
+  "windows-1255",
+  "windows-1256",
+  "windows-1257",
+  "windows-1258",
+  "TIS-620",
+  "windows-874",
+  "ISO-8859-11",
+  "KOI8-R",
+  "KOI8-U",
+  "x-mac-ce",
+  "x-mac-greek",
+  "x-mac-turkish",
+  "x-mac-croatian",
+  "x-mac-romanian",
+  "x-mac-cyrillic",
+  "x-mac-icelandic",
+  "armscii-8",
+  "x-viet-tcvn5712",
+  "VISCII",
+  "x-viet-vps",
+  "UTF-7",
+  "x-imap4-modified-utf7",
+  "UTF-16",
+  "UTF-16BE",
+  "UTF-16LE",
+  "T.61-8bit",
+  "x-user-defined",
+  "x-mac-arabic",
+  "x-mac-devanagari",
+  "x-mac-farsi",
+  "x-mac-gurmukhi",
+  "x-mac-gujarati",
+  "x-mac-hebrew",
+  "IBM850",
+  "IBM852",
+  "IBM855",
+  "IBM857",
+  "IBM862",
+  "IBM864",
+  "IBM864i",
+  "IBM866",
+  "Shift_JIS",
+  "ISO-2022-JP",
+  "EUC-JP",
+  "x-euc-tw",
+  "Big5",
+  "Big5-HKSCS",
+  "EUC-KR",
+  "x-johab",
+  "x-windows-949",
+  "GB2312",
+  "gbk",
+  "HZ-GB-2312",
+  "gb18030",
+  "ISO-2022-KR",
+  "ISO-2022-CN",
+];
+
+function verifyList(aEnumerator, aList)
+{
+  var count = 0;
+
+  while (aEnumerator.hasMore()) {
+    var result = aEnumerator.getNext();
+    for (var i = 0; i < aList.length; i++) {
+      if (result == aList[i]) {
+        count++;
+        break;
+      }
+    }
+    if (i == aList.length) {
+      do_throw("Unknown chardet: " + result);
+    }
+  }
+  do_check_eq(count, aList.length);
+}
+
+function run_test()
+{
+  var cm = Components.classes["@mozilla.org/charset-converter-manager;1"]
+           .getService(Components.interfaces.nsICharsetConverterManager);
+
+  verifyList(cm.GetCharsetDetectorList(), detectList);
+  verifyList(cm.getEncoderList(), encoderList);
+  verifyList(cm.getDecoderList(), decoderList);
+}
--- a/intl/uconv/tests/unit/xpcshell.ini
+++ b/intl/uconv/tests/unit/xpcshell.ini
@@ -24,16 +24,17 @@ tail =
 [test_bug457886.js]
 [test_bug522931.js]
 [test_bug563283.js]
 [test_bug563618.js]
 [test_bug601429.js]
 [test_bug699673.js]
 [test_bug90411.js]
 [test_bug713519.js]
+[test_bug718500.js]
 [test_charset_conversion.js]
 [test_decode_8859-1.js]
 [test_decode_8859-10.js]
 [test_decode_8859-11.js]
 [test_decode_8859-13.js]
 [test_decode_8859-14.js]
 [test_decode_8859-15.js]
 [test_decode_8859-2.js]