Bug 801402 - Use FindEncodingForLabel from FileReaderSync. r=khuey, r=hsivonen
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Fri, 09 Nov 2012 16:00:25 -0500
changeset 112872 1889ff1d55da9596e6ae946d627c16587e620ab8
parent 112871 81cb145bd52b50940b4051ecf9165c7f30cf0fe1
child 112873 3e88fade2d0cf33adf055163e07a6dce00d81007
push id23839
push userryanvm@gmail.com
push dateSat, 10 Nov 2012 01:34:49 +0000
treeherderautoland@a47525b93528 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey, hsivonen
bugs801402
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 801402 - Use FindEncodingForLabel from FileReaderSync. r=khuey, r=hsivonen
dom/workers/FileReaderSync.cpp
dom/workers/test/test_fileReaderSync.xul
--- a/dom/workers/FileReaderSync.cpp
+++ b/dom/workers/FileReaderSync.cpp
@@ -7,31 +7,31 @@
 #include "FileReaderSync.h"
 
 #include "nsCExternalHandlerService.h"
 #include "nsComponentManagerUtils.h"
 #include "nsCOMPtr.h"
 #include "nsDOMClassInfoID.h"
 #include "nsError.h"
 #include "nsIDOMFile.h"
-#include "nsCharsetAlias.h"
 #include "nsICharsetDetector.h"
 #include "nsIConverterInputStream.h"
 #include "nsIInputStream.h"
 #include "nsIPlatformCharset.h"
 #include "nsISeekableStream.h"
 #include "nsISupportsImpl.h"
 #include "nsISupportsImpl.h"
 #include "nsNetUtil.h"
 #include "nsServiceManagerUtils.h"
 #include "File.h"
 #include "RuntimeService.h"
 #include "DOMBindingInlines.h"
 
 #include "mozilla/Base64.h"
+#include "mozilla/dom/EncodingUtils.h"
 
 USING_WORKERS_NAMESPACE
 using mozilla::ErrorResult;
 using mozilla::dom::Optional;
 
 NS_IMPL_ADDREF_INHERITED(FileReaderSync, DOMBindingBase)
 NS_IMPL_RELEASE_INHERITED(FileReaderSync, DOMBindingBase)
 NS_INTERFACE_MAP_BEGIN(FileReaderSync)
@@ -190,19 +190,18 @@ FileReaderSync::ReadAsText(JSObject* aBl
       aRv.Throw(rv);
       return;
     }
   } else {
     CopyUTF16toUTF8(aEncoding.Value(), charsetGuess);
   }
 
   nsCString charset;
-  rv = nsCharsetAlias::GetPreferred(charsetGuess, charset);
-  if (NS_FAILED(rv)) {
-    aRv.Throw(rv);
+  if (!EncodingUtils::FindEncodingForLabel(charsetGuess, charset)) {
+    aRv.Throw(NS_ERROR_DOM_ENCODING_NOT_SUPPORTED_ERR);
     return;
   }
 
   rv = ConvertStream(stream, charset.get(), aResult);
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return;
   }
--- a/dom/workers/test/test_fileReaderSync.xul
+++ b/dom/workers/test/test_fileReaderSync.xul
@@ -51,17 +51,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
     return fileList.files[0];
   }
 
   function convertToUTF16(s) {
     res = "";
     for (var i = 0; i < s.length; ++i) {
       c = s.charCodeAt(i);
-      res += String.fromCharCode(c >>> 8, c & 255);
+      res += String.fromCharCode(c & 255, c >>> 8);
     }
     return res;
   }
 
   /**
    * Converts the given string to a data URL of the specified mime type.
    */
   function convertToDataURL(mime, s) {