diff --git a/dom/file/FileReader.cpp b/dom/file/FileReader.cpp index 62f05578200f..4c623fc9db24 100644 --- a/dom/file/FileReader.cpp +++ b/dom/file/FileReader.cpp @@ -143,31 +143,25 @@ FileReader::GetInterface(const nsIID& aIID, void** aResult) { return QueryInterface(aIID, aResult); } -void FileReader::GetResult(JSContext* aCx, JS::MutableHandle aResult, - ErrorResult& aRv) { +void FileReader::GetResult(JSContext* aCx, + Nullable& aResult) { JS::Rooted result(aCx); if (mDataFormat == FILE_AS_ARRAYBUFFER) { - if (mReadyState == DONE && mResultArrayBuffer) { - result.setObject(*mResultArrayBuffer); - } else { - result.setNull(); + if (mReadyState != DONE || !mResultArrayBuffer || + !aResult.SetValue().SetAsArrayBuffer().Init(mResultArrayBuffer)) { + aResult.SetNull(); } - if (!JS_WrapValue(aCx, &result)) { - aRv.Throw(NS_ERROR_FAILURE); - return; - } - - aResult.set(result); return; } - nsString tmpResult = mResult; - if (!xpc::StringToJsval(aCx, tmpResult, aResult)) { - aRv.Throw(NS_ERROR_FAILURE); + if (mResult.IsVoid()) { + aResult.SetNull(); return; } + + aResult.SetValue().SetAsString() = mResult; } void FileReader::OnLoadEndArrayBuffer() { diff --git a/dom/file/FileReader.h b/dom/file/FileReader.h index d63034d64cb6..4fa85d1abbf3 100644 --- a/dom/file/FileReader.h +++ b/dom/file/FileReader.h @@ -27,6 +27,7 @@ namespace dom { class Blob; class DOMException; +class OwningStringOrArrayBuffer; class StrongWorkerRef; class WeakWorkerRef; @@ -93,8 +94,7 @@ class FileReader final : public DOMEventTargetHelper, DOMException* GetError() const { return mError; } - void GetResult(JSContext* aCx, JS::MutableHandle aResult, - ErrorResult& aRv); + void GetResult(JSContext* aCx, Nullable& aResult); IMPL_EVENT_HANDLER(loadstart) IMPL_EVENT_HANDLER(progress) diff --git a/dom/webidl/FileReader.webidl b/dom/webidl/FileReader.webidl index 6749e7110754..e1f7dc8c6a7f 100644 --- a/dom/webidl/FileReader.webidl +++ b/dom/webidl/FileReader.webidl @@ -34,10 +34,7 @@ interface FileReader : EventTarget { readonly attribute unsigned short readyState; - // File or Blob data - // bug 858217: readonly attribute (DOMString or ArrayBuffer)? result; - [Throws] - readonly attribute any result; + readonly attribute (DOMString or ArrayBuffer)? result; readonly attribute DOMException? error;