Merge inbound to m-c
authorRyan VanderMeulen <ryanvm@gmail.com>
Sun, 06 May 2012 20:31:24 -0400
changeset 93316 448f554f6acbfe632da02e23526344f3defebe69
parent 93302 835d5fab89dc3113bcffd5d34bb00f39d5464eed (current diff)
parent 93315 2ee4a5436340f0be19890938997bf032eb8f9467 (diff)
child 93317 c24b721ca5c9cc90056847761f4213c44198b23e
child 93390 fba62ff1fc5b740da04b5d65b89527c4308552c9
child 93474 bc9a3a32b4358b9ed27266bc70515ab1b6f522c0
push id22625
push userryanvm@gmail.com
push dateMon, 07 May 2012 00:31:41 +0000
treeherdermozilla-central@448f554f6acb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone15.0a1
first release with
nightly linux32
448f554f6acb / 15.0a1 / 20120507030511 / files
nightly linux64
448f554f6acb / 15.0a1 / 20120507030511 / files
nightly mac
448f554f6acb / 15.0a1 / 20120507030511 / files
nightly win32
448f554f6acb / 15.0a1 / 20120507030511 / files
nightly win64
448f554f6acb / 15.0a1 / 20120507030511 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge inbound to m-c
--- a/content/base/src/nsXMLHttpRequest.cpp
+++ b/content/base/src/nsXMLHttpRequest.cpp
@@ -783,34 +783,36 @@ static void LogMessage(const char* aWarn
                                   nsContentUtils::eDOM_PROPERTIES,
                                   aWarning);
 }
 
 /* readonly attribute nsIDOMDocument responseXML; */
 NS_IMETHODIMP
 nsXMLHttpRequest::GetResponseXML(nsIDOMDocument **aResponseXML)
 {
-  nsresult rv = NS_OK;
+  ErrorResult rv;
   nsIDocument* responseXML = GetResponseXML(rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+  if (rv.Failed()) {
+    return rv.ErrorCode();
+  }
 
   if (!responseXML) {
     *aResponseXML = nsnull;
     return NS_OK;
   }
 
   return CallQueryInterface(responseXML, aResponseXML);
 }
 
 nsIDocument*
-nsXMLHttpRequest::GetResponseXML(nsresult& aRv)
+nsXMLHttpRequest::GetResponseXML(ErrorResult& aRv)
 {
   if (mResponseType != XML_HTTP_RESPONSE_TYPE_DEFAULT &&
       mResponseType != XML_HTTP_RESPONSE_TYPE_DOCUMENT) {
-    aRv = NS_ERROR_DOM_INVALID_STATE_ERR;
+    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return nsnull;
   }
   if (mWarnAboutMultipartHtml) {
     mWarnAboutMultipartHtml = false;
     LogMessage("HTMLMultipartXHRWarning", GetOwner());
   }
   if (mWarnAboutSyncHtml) {
     mWarnAboutSyncHtml = false;
@@ -924,32 +926,32 @@ nsXMLHttpRequest::AppendToResponseText(c
 
   return NS_OK;
 }
 
 /* readonly attribute AString responseText; */
 NS_IMETHODIMP
 nsXMLHttpRequest::GetResponseText(nsAString& aResponseText)
 {
-  nsresult rv = NS_OK;
+  ErrorResult rv;
   nsString responseText;
   GetResponseText(responseText, rv);
   aResponseText = responseText;
-  return rv;
+  return rv.ErrorCode();
 }
 
 void
-nsXMLHttpRequest::GetResponseText(nsString& aResponseText, nsresult& aRv)
+nsXMLHttpRequest::GetResponseText(nsString& aResponseText, ErrorResult& aRv)
 {
   aResponseText.Truncate();
 
   if (mResponseType != XML_HTTP_RESPONSE_TYPE_DEFAULT &&
       mResponseType != XML_HTTP_RESPONSE_TYPE_TEXT &&
       mResponseType != XML_HTTP_RESPONSE_TYPE_CHUNKED_TEXT) {
-    aRv = NS_ERROR_DOM_INVALID_STATE_ERR;
+    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
 
   if (mResponseType == XML_HTTP_RESPONSE_TYPE_CHUNKED_TEXT &&
       !mInLoadProgressEvent) {
     aResponseText.SetIsVoid(true);
     return;
   }
@@ -967,34 +969,36 @@ nsXMLHttpRequest::GetResponseText(nsStri
     return;
   }
 
   if (mResponseCharset != mResponseXML->GetDocumentCharacterSet()) {
     mResponseCharset = mResponseXML->GetDocumentCharacterSet();
     mResponseText.Truncate();
     mResponseBodyDecodedPos = 0;
 
+    nsresult rv;
     nsCOMPtr<nsICharsetConverterManager> ccm =
-      do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &aRv);
-    if (NS_FAILED(aRv)) {
+      do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
+    if (NS_FAILED(rv)) {
+      aRv.Throw(rv);
       return;
     }
 
     aRv = ccm->GetUnicodeDecoderRaw(mResponseCharset.get(),
                                     getter_AddRefs(mDecoder));
-    if (NS_FAILED(aRv)) {
+    if (aRv.Failed()) {
       return;
     }
   }
 
   NS_ASSERTION(mResponseBodyDecodedPos < mResponseBody.Length(),
                "Unexpected mResponseBodyDecodedPos");
   aRv = AppendToResponseText(mResponseBody.get() + mResponseBodyDecodedPos,
                              mResponseBody.Length() - mResponseBodyDecodedPos);
-  if (NS_FAILED(aRv)) {
+  if (aRv.Failed()) {
     return;
   }
 
   mResponseBodyDecodedPos = mResponseBody.Length();
   
   if (mState & XML_HTTP_REQUEST_DONE) {
     // Free memory buffer which we no longer need
     mResponseBody.Truncate();
@@ -1129,52 +1133,52 @@ NS_IMETHODIMP nsXMLHttpRequest::SetRespo
   } else if (aResponseType.EqualsLiteral("moz-chunked-arraybuffer")) {
     responseType = XML_HTTP_RESPONSE_TYPE_CHUNKED_ARRAYBUFFER;
   } else if (aResponseType.EqualsLiteral("moz-blob")) {
     responseType = XML_HTTP_RESPONSE_TYPE_MOZ_BLOB;
   } else {
     return NS_OK;
   }
 
-  nsresult rv = NS_OK;
+  ErrorResult rv;
   SetResponseType(responseType, rv);
-  return rv;
+  return rv.ErrorCode();
 }
 
 void
 nsXMLHttpRequest::SetResponseType(XMLHttpRequestResponseType aType,
-                                  nsresult& aRv)
+                                  ErrorResult& aRv)
 {
   SetResponseType(ResponseType(aType), aRv);
 }
 
 void
 nsXMLHttpRequest::SetResponseType(nsXMLHttpRequest::ResponseType aResponseType,
-                                  nsresult& aRv)
+                                  ErrorResult& aRv)
 {
   // If the state is not OPENED or HEADERS_RECEIVED raise an
   // INVALID_STATE_ERR exception and terminate these steps.
   if (!(mState & (XML_HTTP_REQUEST_OPENED | XML_HTTP_REQUEST_SENT |
                   XML_HTTP_REQUEST_HEADERS_RECEIVED))) {
-    aRv = NS_ERROR_DOM_INVALID_STATE_ERR;
+    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
 
   // sync request is not allowed setting responseType in window context
   if (HasOrHasHadOwner() &&
       !(mState & (XML_HTTP_REQUEST_UNSENT | XML_HTTP_REQUEST_ASYNC))) {
     LogMessage("ResponseTypeSyncXHRWarning", GetOwner());
-    aRv = NS_ERROR_DOM_INVALID_ACCESS_ERR;
+    aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
     return;
   }
 
   if (!(mState & XML_HTTP_REQUEST_ASYNC) &&
       (aResponseType == XML_HTTP_RESPONSE_TYPE_CHUNKED_TEXT ||
        aResponseType == XML_HTTP_RESPONSE_TYPE_CHUNKED_ARRAYBUFFER)) {
-    aRv = NS_ERROR_DOM_INVALID_STATE_ERR;
+    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
 
   // Set the responseType attribute's value to the given value.
   mResponseType = aResponseType;
 
   // If the state is OPENED, SetCacheAsFile would have no effect here
   // because the channel hasn't initialized the cache entry yet.
@@ -1183,44 +1187,43 @@ nsXMLHttpRequest::SetResponseType(nsXMLH
   // it immediately because OnStartRequest is already dispatched.
   if (mState & XML_HTTP_REQUEST_HEADERS_RECEIVED) {
     nsCOMPtr<nsICachingChannel> cc(do_QueryInterface(mChannel));
     if (cc) {
       cc->SetCacheAsFile(mResponseType == XML_HTTP_RESPONSE_TYPE_BLOB ||
                          mResponseType == XML_HTTP_RESPONSE_TYPE_MOZ_BLOB);
     }
   }
-  aRv = NS_OK;
 }
 
 /* readonly attribute jsval response; */
 NS_IMETHODIMP
 nsXMLHttpRequest::GetResponse(JSContext *aCx, jsval *aResult)
 {
-  nsresult rv = NS_OK;
+  ErrorResult rv;
   *aResult = GetResponse(aCx, rv);
-  return rv;
+  return rv.ErrorCode();
 }
 
 JS::Value
-nsXMLHttpRequest::GetResponse(JSContext* aCx, nsresult& aRv)
+nsXMLHttpRequest::GetResponse(JSContext* aCx, ErrorResult& aRv)
 {
   switch (mResponseType) {
   case XML_HTTP_RESPONSE_TYPE_DEFAULT:
   case XML_HTTP_RESPONSE_TYPE_TEXT:
   case XML_HTTP_RESPONSE_TYPE_CHUNKED_TEXT:
   {
     nsString str;
     aRv = GetResponseText(str);
-    if (NS_FAILED(aRv)) {
+    if (aRv.Failed()) {
       return JSVAL_NULL;
     }
     JS::Value result;
     if (!xpc::StringToJsval(aCx, str, &result)) {
-      aRv = NS_ERROR_OUT_OF_MEMORY;
+      aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
       return JSVAL_NULL;
     }
     return result;
   }
 
   case XML_HTTP_RESPONSE_TYPE_ARRAYBUFFER:
   case XML_HTTP_RESPONSE_TYPE_CHUNKED_ARRAYBUFFER:
   {
@@ -1230,33 +1233,33 @@ nsXMLHttpRequest::GetResponse(JSContext*
           mInLoadProgressEvent)) {
       return JSVAL_NULL;
     }
 
     if (!mResultArrayBuffer) {
       RootResultArrayBuffer();
       aRv = nsContentUtils::CreateArrayBuffer(aCx, mResponseBody,
                                               &mResultArrayBuffer);
-      if (NS_FAILED(aRv)) {
+      if (aRv.Failed()) {
         return JSVAL_NULL;
       }
     }
     return OBJECT_TO_JSVAL(mResultArrayBuffer);
   }
   case XML_HTTP_RESPONSE_TYPE_BLOB:
   case XML_HTTP_RESPONSE_TYPE_MOZ_BLOB:
   {
     if (!(mState & XML_HTTP_REQUEST_DONE)) {
       if (mResponseType != XML_HTTP_RESPONSE_TYPE_MOZ_BLOB) {
         return JSVAL_NULL;
       }
 
       if (!mResponseBlob) {
         aRv = CreatePartialBlob();
-        if (NS_FAILED(aRv)) {
+        if (aRv.Failed()) {
           return JSVAL_NULL;
         }
       }
     }
 
     if (!mResponseBlob) {
       return JSVAL_NULL;
     }
@@ -1283,17 +1286,17 @@ nsXMLHttpRequest::GetResponse(JSContext*
   {
     if (!(mState & XML_HTTP_REQUEST_DONE)) {
       return JSVAL_NULL;
     }
 
     if (mResultJSON == JSVAL_VOID) {
       aRv = CreateResponseParsedJSON(aCx);
       mResponseText.Truncate();
-      if (NS_FAILED(aRv)) {
+      if (aRv.Failed()) {
         // Per spec, errors aren't propagated. null is returned instead.
         aRv = NS_OK;
         // It would be nice to log the error to the console. That's hard to
         // do without calling window.onerror as a side effect, though.
         JS_ClearPendingException(aCx);
         mResultJSON = JSVAL_NULL;
       }
     }
@@ -1494,24 +1497,24 @@ nsXMLHttpRequest::GetAllResponseHeaders(
     aResponseHeaders.Append('\n');
   }
 }
 
 NS_IMETHODIMP
 nsXMLHttpRequest::GetResponseHeader(const nsACString& aHeader,
                                     nsACString& aResult)
 {
-  nsresult rv = NS_OK;
+  ErrorResult rv;
   GetResponseHeader(aHeader, aResult, rv);
-  return rv;
+  return rv.ErrorCode();
 }
 
 void
 nsXMLHttpRequest::GetResponseHeader(const nsACString& header,
-                                    nsACString& _retval, nsresult& aRv)
+                                    nsACString& _retval, ErrorResult& aRv)
 {
   _retval.SetIsVoid(true);
 
   nsCOMPtr<nsIHttpChannel> httpChannel = GetCurrentHttpChannel();
 
   if (!httpChannel) {
     // If the state is UNSENT or OPENED,
     // return null and terminate these steps.
@@ -1605,17 +1608,17 @@ nsXMLHttpRequest::GetResponseHeader(cons
     }
 
     if (!safeHeader) {
       return;
     }
   }
 
   aRv = httpChannel->GetResponseHeader(header, _retval);
-  if (aRv == NS_ERROR_NOT_AVAILABLE) {
+  if (aRv.ErrorCode() == NS_ERROR_NOT_AVAILABLE) {
     // Means no header
     _retval.SetIsVoid(true);
     aRv = NS_OK;
   }
 }
 
 already_AddRefed<nsILoadGroup>
 nsXMLHttpRequest::GetLoadGroup() const
@@ -2513,56 +2516,57 @@ nsXMLHttpRequest::ChangeStateToDone()
     // We're a multipart request, so we're not done. Reset to opened.
     ChangeState(XML_HTTP_REQUEST_OPENED);
   }
 }
 
 NS_IMETHODIMP
 nsXMLHttpRequest::SendAsBinary(const nsAString &aBody, JSContext *aCx)
 {
-  nsresult rv = NS_OK;
+  ErrorResult rv;
   SendAsBinary(aCx, aBody, rv);
-  return rv;
+  return rv.ErrorCode();
 }
 
 void
-nsXMLHttpRequest::SendAsBinary(JSContext *aCx, const nsAString &aBody, nsresult& aRv)
+nsXMLHttpRequest::SendAsBinary(JSContext *aCx, const nsAString &aBody,
+                               ErrorResult& aRv)
 {
   char *data = static_cast<char*>(NS_Alloc(aBody.Length() + 1));
   if (!data) {
-    aRv = NS_ERROR_OUT_OF_MEMORY;
+    aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
     return;
   }
 
   nsAString::const_iterator iter, end;
   aBody.BeginReading(iter);
   aBody.EndReading(end);
   char *p = data;
   while (iter != end) {
     if (*iter & 0xFF00) {
       NS_Free(data);
-      aRv = NS_ERROR_DOM_INVALID_CHARACTER_ERR;
+      aRv.Throw(NS_ERROR_DOM_INVALID_CHARACTER_ERR);
       return;
     }
     *p++ = static_cast<char>(*iter++);
   }
   *p = '\0';
 
   nsCOMPtr<nsIInputStream> stream;
   aRv = NS_NewByteInputStream(getter_AddRefs(stream), data, aBody.Length(),
                               NS_ASSIGNMENT_ADOPT);
-  if (NS_FAILED(aRv)){
+  if (aRv.Failed()) {
     NS_Free(data);
     return;
   }
 
   nsCOMPtr<nsIWritableVariant> variant = new nsVariant();
 
   aRv = variant->SetAsISupports(stream);
-  if (NS_FAILED(aRv)) {
+  if (aRv.Failed()) {
     return;
   }
 
   aRv = Send(variant, aCx);
 }
 
 static nsresult
 GetRequestBody(nsIDOMDocument* aDoc, nsIInputStream** aResult,
@@ -3293,30 +3297,30 @@ nsXMLHttpRequest::GetTimeout(PRUint32 *a
 {
   *aTimeout = GetTimeout();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsXMLHttpRequest::SetTimeout(PRUint32 aTimeout)
 {
-  nsresult rv = NS_OK;
+  ErrorResult rv;
   SetTimeout(aTimeout, rv);
-  return rv;
+  return rv.ErrorCode();
 }
 
 void
-nsXMLHttpRequest::SetTimeout(uint32_t aTimeout, nsresult& aRv)
+nsXMLHttpRequest::SetTimeout(uint32_t aTimeout, ErrorResult& aRv)
 {
   if (!(mState & (XML_HTTP_REQUEST_ASYNC | XML_HTTP_REQUEST_UNSENT)) &&
       HasOrHasHadOwner()) {
     /* Timeout is not supported for synchronous requests with an owning window,
        per XHR2 spec. */
     LogMessage("TimeoutSyncXHRWarning", GetOwner());
-    aRv = NS_ERROR_DOM_INVALID_ACCESS_ERR;
+    aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
     return;
   }
 
   mTimeoutMilliseconds = aTimeout;
   if (mRequestSentTime) {
     StartTimeoutTimer();
   }
 }
@@ -3866,27 +3870,27 @@ nsXMLHttpRequest::GetInterface(const nsI
                              reinterpret_cast<void**>(aResult));
 
   }
 
   return QueryInterface(aIID, aResult);
 }
 
 JS::Value
-nsXMLHttpRequest::GetInterface(JSContext* aCx, nsIJSIID* aIID, nsresult& aRv)
+nsXMLHttpRequest::GetInterface(JSContext* aCx, nsIJSIID* aIID, ErrorResult& aRv)
 {
   const nsID* iid = aIID->GetID();
   nsCOMPtr<nsISupports> result;
   JS::Value v = JSVAL_NULL;
   aRv = GetInterface(*iid, getter_AddRefs(result));
-  NS_ENSURE_SUCCESS(aRv, JSVAL_NULL);
+  NS_ENSURE_FALSE(aRv.Failed(), JSVAL_NULL);
 
   JSObject* global = JS_GetGlobalForObject(aCx, GetWrapper());
   aRv = nsContentUtils::WrapNative(aCx, global, result, iid, &v);
-  return NS_SUCCEEDED(aRv) ? v : JSVAL_NULL;
+  return aRv.Failed() ? JSVAL_NULL : v;
 }
 
 nsXMLHttpRequestUpload*
 nsXMLHttpRequest::GetUpload()
 {
   if (!mUpload) {
     mUpload = new nsXMLHttpRequestUpload(this);
   }
--- a/content/base/src/nsXMLHttpRequest.h
+++ b/content/base/src/nsXMLHttpRequest.h
@@ -79,17 +79,17 @@ class AsyncVerifyRedirectCallbackForward
 class nsIUnicodeDecoder;
 class nsIDOMFormData;
 
 #define IMPL_EVENT_HANDLER(_lowercase, _capitalized)                    \
   JSObject* GetOn##_lowercase()                                         \
   {                                                                     \
     return GetListenerAsJSObject(mOn##_capitalized##Listener);          \
   }                                                                     \
-  void SetOn##_lowercase(JSContext* aCx, JSObject* aCallback, nsresult& aRv) \
+  void SetOn##_lowercase(JSContext* aCx, JSObject* aCallback, ErrorResult& aRv) \
   {                                                                     \
     aRv = SetJSObjectListener(aCx, NS_LITERAL_STRING(#_lowercase),      \
                               mOn##_capitalized##Listener,              \
                               aCallback);                               \
   }
 
 class nsXHREventTarget : public nsDOMEventTargetHelper,
                          public nsIXMLHttpRequestEventTarget
@@ -206,22 +206,22 @@ public:
   }
   nsISupports* GetParentObject()
   {
     return GetOwner();
   }
 
   // The WebIDL parser converts constructors into methods called _Constructor.
   static already_AddRefed<nsXMLHttpRequest>
-  _Constructor(nsISupports* aGlobal, nsresult& aRv)
+  _Constructor(nsISupports* aGlobal, ErrorResult& aRv)
   {
     nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal);
     nsCOMPtr<nsIScriptObjectPrincipal> principal = do_QueryInterface(aGlobal);
     if (!window || ! principal) {
-      aRv = NS_ERROR_FAILURE;
+      aRv.Throw(NS_ERROR_FAILURE);
       return NULL;
     }
 
     nsRefPtr<nsXMLHttpRequest> req = new nsXMLHttpRequest();
     req->Construct(principal->GetPrincipal(), window);
     return req.forget();
   }
 
@@ -278,32 +278,32 @@ public:
   // event handler
   IMPL_EVENT_HANDLER(readystatechange, Readystatechange)
 
   // states
   uint16_t GetReadyState();
 
   // request
   void Open(const nsAString& aMethod, const nsAString& aUrl, bool aAsync,
-            const nsAString& aUser, const nsAString& aPassword, nsresult& aRv)
+            const nsAString& aUser, const nsAString& aPassword, ErrorResult& aRv)
   {
     aRv = Open(NS_ConvertUTF16toUTF8(aMethod), NS_ConvertUTF16toUTF8(aUrl),
                aAsync, aUser, aPassword);
   }
   void SetRequestHeader(const nsAString& aHeader, const nsAString& aValue,
-                        nsresult& aRv)
+                        ErrorResult& aRv)
   {
     aRv = SetRequestHeader(NS_ConvertUTF16toUTF8(aHeader),
                            NS_ConvertUTF16toUTF8(aValue));
   }
   uint32_t GetTimeout()
   {
     return mTimeoutMilliseconds;
   }
-  void SetTimeout(uint32_t aTimeout, nsresult& aRv);
+  void SetTimeout(uint32_t aTimeout, ErrorResult& aRv);
   bool GetWithCredentials();
   void SetWithCredentials(bool aWithCredentials, nsresult& aRv);
   nsXMLHttpRequestUpload* GetUpload();
 
 private:
   class RequestBody
   {
   public:
@@ -382,65 +382,65 @@ private:
     return Send(aCx, nsnull, aBody);
   }
   nsresult Send(JSContext *aCx, const RequestBody& aBody)
   {
     return Send(aCx, Nullable<RequestBody>(aBody));
   }
 
 public:
-  void Send(JSContext *aCx, nsresult& aRv)
+  void Send(JSContext *aCx, ErrorResult& aRv)
   {
     aRv = Send(aCx, Nullable<RequestBody>());
   }
-  void Send(JSContext *aCx, JSObject* aArrayBuffer, nsresult& aRv)
+  void Send(JSContext *aCx, JSObject* aArrayBuffer, ErrorResult& aRv)
   {
     NS_ASSERTION(aArrayBuffer, "Null should go to string version");
     aRv = Send(aCx, RequestBody(aArrayBuffer));
   }
-  void Send(JSContext *aCx, nsIDOMBlob* aBlob, nsresult& aRv)
+  void Send(JSContext *aCx, nsIDOMBlob* aBlob, ErrorResult& aRv)
   {
     NS_ASSERTION(aBlob, "Null should go to string version");
     aRv = Send(aCx, RequestBody(aBlob));
   }
-  void Send(JSContext *aCx, nsIDocument* aDoc, nsresult& aRv)
+  void Send(JSContext *aCx, nsIDocument* aDoc, ErrorResult& aRv)
   {
     NS_ASSERTION(aDoc, "Null should go to string version");
     aRv = Send(aCx, RequestBody(aDoc));
   }
-  void Send(JSContext *aCx, const nsAString& aString, nsresult& aRv)
+  void Send(JSContext *aCx, const nsAString& aString, ErrorResult& aRv)
   {
     if (DOMStringIsNull(aString)) {
       Send(aCx, aRv);
     }
     else {
       aRv = Send(aCx, RequestBody(aString));
     }
   }
-  void Send(JSContext *aCx, nsIDOMFormData* aFormData, nsresult& aRv)
+  void Send(JSContext *aCx, nsIDOMFormData* aFormData, ErrorResult& aRv)
   {
     NS_ASSERTION(aFormData, "Null should go to string version");
     aRv = Send(aCx, RequestBody(aFormData));
   }
-  void Send(JSContext *aCx, nsIInputStream* aStream, nsresult& aRv)
+  void Send(JSContext *aCx, nsIInputStream* aStream, ErrorResult& aRv)
   {
     NS_ASSERTION(aStream, "Null should go to string version");
     aRv = Send(aCx, RequestBody(aStream));
   }
-  void SendAsBinary(JSContext *aCx, const nsAString& aBody, nsresult& aRv);
+  void SendAsBinary(JSContext *aCx, const nsAString& aBody, ErrorResult& aRv);
 
   void Abort();
 
   // response
   uint32_t GetStatus();
   void GetStatusText(nsString& aStatusText);
   void GetResponseHeader(const nsACString& aHeader, nsACString& aResult,
-                         nsresult& aRv);
+                         ErrorResult& aRv);
   void GetResponseHeader(const nsAString& aHeader, nsString& aResult,
-                         nsresult& aRv)
+                         ErrorResult& aRv)
   {
     nsCString result;
     GetResponseHeader(NS_ConvertUTF16toUTF8(aHeader), result, aRv);
     if (result.IsVoid()) {
       aResult.SetIsVoid(true);
     }
     else {
       // We use UTF8ToNewUnicode here because it truncates after invalid UTF-8
@@ -455,33 +455,33 @@ public:
   {
     // XXX Should we do some validation here?
     mOverrideMimeType = aMimeType;
   }
   XMLHttpRequestResponseType GetResponseType()
   {
     return XMLHttpRequestResponseType(mResponseType);
   }
-  void SetResponseType(XMLHttpRequestResponseType aType, nsresult& aRv);
-  JS::Value GetResponse(JSContext* aCx, nsresult& aRv);
-  void GetResponseText(nsString& aResponseText, nsresult& aRv);
-  nsIDocument* GetResponseXML(nsresult& aRv);
+  void SetResponseType(XMLHttpRequestResponseType aType, ErrorResult& aRv);
+  JS::Value GetResponse(JSContext* aCx, ErrorResult& aRv);
+  void GetResponseText(nsString& aResponseText, ErrorResult& aRv);
+  nsIDocument* GetResponseXML(ErrorResult& aRv);
 
   bool GetMozBackgroundRequest();
   void SetMozBackgroundRequest(bool aMozBackgroundRequest, nsresult& aRv);
   bool GetMultipart();
   void SetMultipart(bool aMultipart, nsresult& aRv);
 
   nsIChannel* GetChannel()
   {
     return mChannel;
   }
 
   // We need a GetInterface callable from JS for chrome JS
-  JS::Value GetInterface(JSContext* aCx, nsIJSIID* aIID, nsresult& aRv);
+  JS::Value GetInterface(JSContext* aCx, nsIJSIID* aIID, ErrorResult& aRv);
 
   // This creates a trusted readystatechange event, which is not cancelable and
   // doesn't bubble.
   static nsresult CreateReadystatechangeEvent(nsIDOMEvent** aDOMEvent);
   // For backwards compatibility aPosition should contain the headers for upload
   // and aTotalSize is LL_MAXUINT when unknown. Both those values are
   // used by nsXMLHttpProgressEvent. Normal progress event should not use
   // headers in aLoaded and aTotal is 0 when unknown.
@@ -628,17 +628,17 @@ protected:
     XML_HTTP_RESPONSE_TYPE_DOCUMENT,
     XML_HTTP_RESPONSE_TYPE_JSON,
     XML_HTTP_RESPONSE_TYPE_TEXT,
     XML_HTTP_RESPONSE_TYPE_CHUNKED_TEXT,
     XML_HTTP_RESPONSE_TYPE_CHUNKED_ARRAYBUFFER,
     XML_HTTP_RESPONSE_TYPE_MOZ_BLOB
   };
 
-  void SetResponseType(nsXMLHttpRequest::ResponseType aType, nsresult& aRv);
+  void SetResponseType(nsXMLHttpRequest::ResponseType aType, ErrorResult& aRv);
 
   ResponseType mResponseType;
 
   // It is either a cached blob-response from the last call to GetResponse,
   // but is also explicitly set in OnStopRequest.
   nsCOMPtr<nsIDOMBlob> mResponseBlob;
   // Non-null only when we are able to get a os-file representation of the
   // response, i.e. when loading from a file, or when the http-stream
--- a/content/canvas/src/WebGLContext.cpp
+++ b/content/canvas/src/WebGLContext.cpp
@@ -780,41 +780,42 @@ WebGLContext::GetCanvasLayer(nsDisplayLi
     mResetLayer = false;
 
     return canvasLayer.forget().get();
 }
 
 NS_IMETHODIMP
 WebGLContext::GetContextAttributes(jsval *aResult)
 {
-    nsresult rv = NS_OK;
+    ErrorResult rv;
     JSObject* obj = GetContextAttributes(rv);
-    NS_ENSURE_SUCCESS(rv, rv);
+    if (rv.Failed())
+        return rv.ErrorCode();
 
     *aResult = JS::ObjectOrNullValue(obj);
     return NS_OK;
 }
 
 JSObject*
-WebGLContext::GetContextAttributes(nsresult &rv)
+WebGLContext::GetContextAttributes(ErrorResult &rv)
 {
     if (!IsContextStable())
     {
         return NULL;
     }
 
     JSContext *cx = nsContentUtils::GetCurrentJSContext();
     if (!cx) {
-        rv = NS_ERROR_FAILURE;
+        rv.Throw(NS_ERROR_FAILURE);
         return NULL;
     }
 
     JSObject *obj = JS_NewObject(cx, NULL, NULL, NULL);
     if (!obj) {
-        rv = NS_ERROR_FAILURE;
+        rv.Throw(NS_ERROR_FAILURE);
         return NULL;
     }
 
     gl::ContextFormat cf = gl->ActualFormat();
 
     if (!JS_DefineProperty(cx, obj, "alpha", cf.alpha > 0 ? JSVAL_TRUE : JSVAL_FALSE,
                            NULL, NULL, JSPROP_ENUMERATE) ||
         !JS_DefineProperty(cx, obj, "depth", cf.depth > 0 ? JSVAL_TRUE : JSVAL_FALSE,
@@ -825,17 +826,17 @@ WebGLContext::GetContextAttributes(nsres
                            NULL, NULL, JSPROP_ENUMERATE) ||
         !JS_DefineProperty(cx, obj, "premultipliedAlpha",
                            mOptions.premultipliedAlpha ? JSVAL_TRUE : JSVAL_FALSE,
                            NULL, NULL, JSPROP_ENUMERATE) ||
         !JS_DefineProperty(cx, obj, "preserveDrawingBuffer",
                            mOptions.preserveDrawingBuffer ? JSVAL_TRUE : JSVAL_FALSE,
                            NULL, NULL, JSPROP_ENUMERATE))
     {
-        rv = NS_ERROR_FAILURE;
+        rv.Throw(NS_ERROR_FAILURE);
         return NULL;
     }
 
     return obj;
 }
 
 /* [noscript] DOMString mozGetUnderlyingParamString(in WebGLenum pname); */
 NS_IMETHODIMP
--- a/content/canvas/src/WebGLContext.h
+++ b/content/canvas/src/WebGLContext.h
@@ -72,16 +72,17 @@
 #ifdef XP_MACOSX
 #include "ForceDiscreteGPUHelperCGL.h"
 #endif
 
 #include "angle/ShaderLang.h"
 
 #include "mozilla/dom/TypedArray.h"
 #include "mozilla/dom/Nullable.h"
+#include "mozilla/ErrorResult.h"
 
 /* 
  * Minimum value constants defined in 6.2 State Tables of OpenGL ES - 2.0.25
  *   https://bugzilla.mozilla.org/show_bug.cgi?id=686732
  * 
  * Exceptions: some of the following values are set to higher values than in the spec because
  * the values in the spec are ridiculously low. They are explicitly marked below
 */
@@ -689,17 +690,17 @@ public:
         return mWidth;
     }
     WebGLsizei GetDrawingBufferHeight() const {
         if (!IsContextStable())
             return 0;
         return mHeight;
     }
         
-    JSObject *GetContextAttributes(nsresult &rv);
+    JSObject *GetContextAttributes(ErrorResult &rv);
     bool IsContextLost() const { return !IsContextStable(); }
     void GetSupportedExtensions(dom::Nullable< nsTArray<nsString> > &retval);
     nsIWebGLExtension* GetExtension(const nsAString& aName);
     void ActiveTexture(WebGLenum texture);
     void AttachShader(WebGLProgram* program, WebGLShader* shader);
     void BindAttribLocation(WebGLProgram* program, WebGLuint location,
                             const nsAString& name);
     void BindBuffer(WebGLenum target, WebGLBuffer* buf);
@@ -792,64 +793,64 @@ public:
     already_AddRefed<WebGLActiveInfo> GetActiveAttrib(WebGLProgram *prog,
                                                       WebGLuint index);
     already_AddRefed<WebGLActiveInfo> GetActiveUniform(WebGLProgram *prog,
                                                        WebGLuint index);
     void GetAttachedShaders(WebGLProgram* prog,
                             dom::Nullable< nsTArray<WebGLShader*> > &retval);
     WebGLint GetAttribLocation(WebGLProgram* prog, const nsAString& name);
     JS::Value GetBufferParameter(WebGLenum target, WebGLenum pname);
-    JS::Value GetParameter(JSContext* cx, WebGLenum pname, nsresult& rv);
+    JS::Value GetParameter(JSContext* cx, WebGLenum pname, ErrorResult& rv);
     WebGLenum GetError();
     JS::Value GetFramebufferAttachmentParameter(JSContext* cx,
                                                 WebGLenum target,
                                                 WebGLenum attachment,
                                                 WebGLenum pname,
-                                                nsresult& rv);
+                                                ErrorResult& rv);
     JS::Value GetProgramParameter(WebGLProgram *prog, WebGLenum pname);
-    void GetProgramInfoLog(WebGLProgram *prog, nsAString& retval, nsresult& rv);
+    void GetProgramInfoLog(WebGLProgram *prog, nsAString& retval, ErrorResult& rv);
     JS::Value GetRenderbufferParameter(WebGLenum target, WebGLenum pname);
     JS::Value GetShaderParameter(WebGLShader *shader, WebGLenum pname);
     already_AddRefed<WebGLShaderPrecisionFormat>
       GetShaderPrecisionFormat(WebGLenum shadertype, WebGLenum precisiontype);
-    void GetShaderInfoLog(WebGLShader *shader, nsAString& retval, nsresult& rv);
+    void GetShaderInfoLog(WebGLShader *shader, nsAString& retval, ErrorResult& rv);
     void GetShaderSource(WebGLShader *shader, nsAString& retval);
     JS::Value GetTexParameter(WebGLenum target, WebGLenum pname);
     JS::Value GetUniform(JSContext* cx, WebGLProgram *prog,
-                         WebGLUniformLocation *location, nsresult& rv);
+                         WebGLUniformLocation *location, ErrorResult& rv);
     already_AddRefed<WebGLUniformLocation>
       GetUniformLocation(WebGLProgram *prog, const nsAString& name);
     JS::Value GetVertexAttrib(JSContext* cx, WebGLuint index, WebGLenum pname,
-                              nsresult& rv);
+                              ErrorResult& rv);
     WebGLsizeiptr GetVertexAttribOffset(WebGLuint index, WebGLenum pname);
     void Hint(WebGLenum target, WebGLenum mode);
     bool IsBuffer(WebGLBuffer *buffer);
     bool IsEnabled(WebGLenum cap);
     bool IsFramebuffer(WebGLFramebuffer *fb);
     bool IsProgram(WebGLProgram *prog);
     bool IsRenderbuffer(WebGLRenderbuffer *rb);
     bool IsShader(WebGLShader *shader);
     bool IsTexture(WebGLTexture *tex);
     void LineWidth(WebGLfloat width) {
         if (!IsContextStable())
             return;
         MakeContextCurrent();
         gl->fLineWidth(width);
     }
-    void LinkProgram(WebGLProgram *program, nsresult& rv);
+    void LinkProgram(WebGLProgram *program, ErrorResult& rv);
     void PixelStorei(WebGLenum pname, WebGLint param);
     void PolygonOffset(WebGLfloat factor, WebGLfloat units) {
         if (!IsContextStable())
             return;
         MakeContextCurrent();
         gl->fPolygonOffset(factor, units);
     }
     void ReadPixels(WebGLint x, WebGLint y, WebGLsizei width, WebGLsizei height,
                     WebGLenum format, WebGLenum type,
-                    dom::ArrayBufferView* pixels, nsresult& rv);
+                    dom::ArrayBufferView* pixels, ErrorResult& rv);
     void RenderbufferStorage(WebGLenum target, WebGLenum internalformat,
                              WebGLsizei width, WebGLsizei height);
     void SampleCoverage(WebGLclampf value, WebGLboolean invert) {
         if (!IsContextStable())
             return;
         MakeContextCurrent();
         gl->fSampleCoverage(value, invert);
     }
@@ -861,41 +862,42 @@ public:
     void StencilMask(WebGLuint mask);
     void StencilMaskSeparate(WebGLenum face, WebGLuint mask);
     void StencilOp(WebGLenum sfail, WebGLenum dpfail, WebGLenum dppass);
     void StencilOpSeparate(WebGLenum face, WebGLenum sfail, WebGLenum dpfail,
                            WebGLenum dppass);
     void TexImage2D(JSContext* cx, WebGLenum target, WebGLint level,
                     WebGLenum internalformat, WebGLsizei width,
                     WebGLsizei height, WebGLint border, WebGLenum format,
-                    WebGLenum type, dom::ArrayBufferView *pixels, nsresult& rv);
+                    WebGLenum type, dom::ArrayBufferView *pixels,
+                    ErrorResult& rv);
     void TexImage2D(JSContext* cx, WebGLenum target, WebGLint level,
                     WebGLenum internalformat, WebGLenum format, WebGLenum type,
-                    dom::ImageData* pixels, nsresult& rv);
+                    dom::ImageData* pixels, ErrorResult& rv);
     void TexImage2D(JSContext* /* unused */, WebGLenum target, WebGLint level,
                     WebGLenum internalformat, WebGLenum format, WebGLenum type,
-                    dom::Element* elt, nsresult& rv);
+                    dom::Element* elt, ErrorResult& rv);
     void TexParameterf(WebGLenum target, WebGLenum pname, WebGLfloat param) {
         TexParameter_base(target, pname, nsnull, &param);
     }
     void TexParameteri(WebGLenum target, WebGLenum pname, WebGLint param) {
         TexParameter_base(target, pname, &param, nsnull);
     }
     
     void TexSubImage2D(JSContext* cx, WebGLenum target, WebGLint level,
                        WebGLint xoffset, WebGLint yoffset,
                        WebGLsizei width, WebGLsizei height, WebGLenum format,
                        WebGLenum type, dom::ArrayBufferView* pixels,
-                       nsresult& rv);
+                       ErrorResult& rv);
     void TexSubImage2D(JSContext* cx, WebGLenum target, WebGLint level,
                        WebGLint xoffset, WebGLint yoffset, WebGLenum format,
-                       WebGLenum type, dom::ImageData* pixels, nsresult& rv);
+                       WebGLenum type, dom::ImageData* pixels, ErrorResult& rv);
     void TexSubImage2D(JSContext* /* unused */, WebGLenum target, WebGLint level,
                        WebGLint xoffset, WebGLint yoffset, WebGLenum format,
-                       WebGLenum type, dom::Element* elt, nsresult& rv);
+                       WebGLenum type, dom::Element* elt, ErrorResult& rv);
 
     void Uniform1i(WebGLUniformLocation* location, WebGLint x);
     void Uniform2i(WebGLUniformLocation* location, WebGLint x, WebGLint y);
     void Uniform3i(WebGLUniformLocation* location, WebGLint x, WebGLint y,
                    WebGLint z);
     void Uniform4i(WebGLUniformLocation* location, WebGLint x, WebGLint y,
                    WebGLint z, WebGLint w);
 
--- a/content/canvas/src/WebGLContextGL.cpp
+++ b/content/canvas/src/WebGLContextGL.cpp
@@ -2316,37 +2316,38 @@ WebGLContext::GetAttribLocation(WebGLPro
 
     MakeContextCurrent();
     return gl->fGetAttribLocation(progname, mappedName.get());
 }
 
 NS_IMETHODIMP
 WebGLContext::GetParameter(PRUint32 pname, JSContext* cx, JS::Value *retval)
 {
-    nsresult rv = NS_OK;
+    ErrorResult rv;
     JS::Value v = GetParameter(cx, pname, rv);
-    NS_ENSURE_SUCCESS(rv, rv);
+    if (rv.Failed())
+        return rv.ErrorCode();
     *retval = v;
     return NS_OK;
 }
 
 static JS::Value
-StringValue(JSContext* cx, const char* chars, nsresult& rv)
+StringValue(JSContext* cx, const char* chars, ErrorResult& rv)
 {
     JSString* str = JS_NewStringCopyZ(cx, chars);
     if (!str) {
-        rv = NS_ERROR_OUT_OF_MEMORY;
+        rv.Throw(NS_ERROR_OUT_OF_MEMORY);
         return JS::NullValue();
     }
 
     return JS::StringValue(str);
 }
 
 JS::Value
-WebGLContext::GetParameter(JSContext* cx, WebGLenum pname, nsresult& rv)
+WebGLContext::GetParameter(JSContext* cx, WebGLenum pname, ErrorResult& rv)
 {
     if (!IsContextStable())
         return JS::NullValue();
 
     MakeContextCurrent();
     
     if (MinCapabilityMode()) {
         switch(pname) {
@@ -2742,30 +2743,31 @@ WebGLContext::GetBufferParameter(WebGLen
     }
 
     return JS::NullValue();
 }
 
 NS_IMETHODIMP
 WebGLContext::GetFramebufferAttachmentParameter(WebGLenum target, WebGLenum attachment, WebGLenum pname, JSContext* cx, JS::Value *retval)
 {
-    nsresult rv = NS_OK;
+    ErrorResult rv;
     JS::Value v =
         GetFramebufferAttachmentParameter(cx, target, attachment, pname, rv);
-    NS_ENSURE_SUCCESS(rv, rv);
+    if (rv.Failed())
+        return rv.ErrorCode();
     *retval = v;
     return NS_OK;
 }
 
 JS::Value
 WebGLContext::GetFramebufferAttachmentParameter(JSContext* cx,
                                                 WebGLenum target,
                                                 WebGLenum attachment,
                                                 WebGLenum pname,
-                                                nsresult& rv)
+                                                ErrorResult& rv)
 {
     if (!IsContextStable())
         return JS::NullValue();
 
     if (target != LOCAL_GL_FRAMEBUFFER) {
         ErrorInvalidEnumInfo("getFramebufferAttachmentParameter: target", target);
         return JS::NullValue();
     }
@@ -2796,17 +2798,17 @@ WebGLContext::GetFramebufferAttachmentPa
                 return JS::DoubleValue(uint32_t(LOCAL_GL_RENDERBUFFER));
 
             case LOCAL_GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
             {
                 JS::Value v;
                 if (!dom::WrapObject(cx, GetWrapper(),
                                      const_cast<WebGLRenderbuffer*>(fba.Renderbuffer()),
                                      &v)) {
-                    rv = NS_ERROR_FAILURE;
+                    rv.Throw(NS_ERROR_FAILURE);
                     return JS::NullValue();
                 }
                 return v;
             }
 
             default:
                 ErrorInvalidEnumInfo("GetFramebufferAttachmentParameter: pname", pname);
                 return JS::NullValue();
@@ -3017,24 +3019,24 @@ WebGLContext::GetProgramParameter(WebGLP
     }
 
     return JS::NullValue();
 }
 
 NS_IMETHODIMP
 WebGLContext::GetProgramInfoLog(nsIWebGLProgram *pobj, nsAString& retval)
 {
-    nsresult rv = NS_OK;
+    ErrorResult rv;
     GetProgramInfoLog(static_cast<WebGLProgram*>(pobj), retval, rv);
-    return rv;
+    return rv.ErrorCode();
 }
 
 void
 WebGLContext::GetProgramInfoLog(WebGLProgram *prog, nsAString& retval,
-                                nsresult& rv)
+                                ErrorResult& rv)
 {
     if (!IsContextStable())
     {
         retval.SetIsVoid(true);
         return;
     }
 
     if (!ValidateObject("getProgramInfoLog: program", prog)) {
@@ -3244,27 +3246,28 @@ WebGLContext::GetTexParameter(WebGLenum 
     return JS::NullValue();
 }
 
 /* any getUniform(in WebGLProgram program, in WebGLUniformLocation location) raises(DOMException); */
 NS_IMETHODIMP
 WebGLContext::GetUniform(nsIWebGLProgram *pobj, nsIWebGLUniformLocation *ploc,
                          JSContext *cx, JS::Value *retval)
 {
-    nsresult rv = NS_OK;
+    ErrorResult rv;
     JS::Value v = GetUniform(cx, static_cast<WebGLProgram*>(pobj),
                              static_cast<WebGLUniformLocation*>(ploc), rv);
-    NS_ENSURE_SUCCESS(rv, rv);
+    if (rv.Failed())
+        return rv.ErrorCode();
     *retval = v;
     return NS_OK;
 }
 
 JS::Value
 WebGLContext::GetUniform(JSContext* cx, WebGLProgram *prog,
-                         WebGLUniformLocation *location, nsresult& rv)
+                         WebGLUniformLocation *location, ErrorResult& rv)
 {
     if (!IsContextStable())
         return JS::NullValue();
 
     if (!ValidateObject("getUniform: program", prog))
         return JS::NullValue();
 
     if (!ValidateObject("getUniform: location", location))
@@ -3323,69 +3326,69 @@ WebGLContext::GetUniform(JSContext* cx, 
                     break;
                 }
             }
             if (found_it) break;
         }
     }
 
     if (index == uniforms) {
-        rv = NS_ERROR_FAILURE; // XXX GL error? shouldn't happen.
+        rv.Throw(NS_ERROR_FAILURE); // XXX GL error? shouldn't happen.
         return JS::NullValue();
     }
 
     GLenum baseType;
     GLint unitSize;
     if (!BaseTypeAndSizeFromUniformType(uniformType, &baseType, &unitSize)) {
-        rv = NS_ERROR_FAILURE;
+        rv.Throw(NS_ERROR_FAILURE);
         return JS::NullValue();
     }
 
     // this should never happen
     if (unitSize > 16) {
-        rv = NS_ERROR_FAILURE;
+        rv.Throw(NS_ERROR_FAILURE);
         return JS::NullValue();
     }
 
     if (baseType == LOCAL_GL_FLOAT) {
         GLfloat fv[16] = { GLfloat(0) };
         gl->fGetUniformfv(progname, location->Location(), fv);
         if (unitSize == 1) {
             return JS::DoubleValue(fv[0]);
         } else {
             JSObject* obj = Float32Array::Create(cx, unitSize, fv);
             if (!obj) {
-                rv = NS_ERROR_OUT_OF_MEMORY;
+                rv.Throw(NS_ERROR_OUT_OF_MEMORY);
             }
             return JS::ObjectOrNullValue(obj);
         }
     } else if (baseType == LOCAL_GL_INT) {
         GLint iv[16] = { 0 };
         gl->fGetUniformiv(progname, location->Location(), iv);
         if (unitSize == 1) {
             return JS::Int32Value(iv[0]);
         } else {
             JSObject* obj = Int32Array::Create(cx, unitSize, iv);
             if (!obj) {
-                rv = NS_ERROR_OUT_OF_MEMORY;
+                rv.Throw(NS_ERROR_OUT_OF_MEMORY);
             }
             return JS::ObjectOrNullValue(obj);
         }
     } else if (baseType == LOCAL_GL_BOOL) {
         GLint iv[16] = { 0 };
         gl->fGetUniformiv(progname, location->Location(), iv);
         if (unitSize == 1) {
             return JS::BooleanValue(iv[0] ? true : false);
         } else {
             JS::Value uv[16];
             for (int k = 0; k < unitSize; k++)
                 uv[k] = JS::BooleanValue(iv[k] ? true : false);
             JSObject* obj = JS_NewArrayObject(cx, unitSize, uv);
             if (!obj) {
-                rv = NS_ERROR_OUT_OF_MEMORY;
+                rv.Throw(NS_ERROR_OUT_OF_MEMORY);
             }
             return JS::ObjectOrNullValue(obj);
         }
     }
 
     // Else preserving behavior, but I'm not sure this is correct per spec
     return JS::UndefinedValue();
 }
@@ -3428,42 +3431,43 @@ WebGLContext::GetUniformLocation(WebGLPr
     }
     return loc;
 }
 
 NS_IMETHODIMP
 WebGLContext::GetVertexAttrib(WebGLuint index, WebGLenum pname, JSContext* cx,
                               JS::Value *retval)
 {
-    nsresult rv = NS_OK;
+    ErrorResult rv;
     JS::Value v = GetVertexAttrib(cx, index, pname, rv);
-    NS_ENSURE_SUCCESS(rv, rv);
+    if (rv.Failed())
+        return rv.ErrorCode();
     *retval = v;
     return NS_OK;
 }
 
 JS::Value
 WebGLContext::GetVertexAttrib(JSContext* cx, WebGLuint index, WebGLenum pname,
-                              nsresult& rv)
+                              ErrorResult& rv)
 {
     if (!IsContextStable())
         return JS::NullValue();
 
     if (!ValidateAttribIndex(index, "getVertexAttrib"))
         return JS::NullValue();
 
     MakeContextCurrent();
 
     switch (pname) {
         case LOCAL_GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
         {
             JS::Value v;
             if (!dom::WrapObject(cx, GetWrapper(),
                                  mAttribBuffers[index].buf.get(), &v)) {
-                rv = NS_ERROR_FAILURE;
+                rv.Throw(NS_ERROR_FAILURE);
                 return JS::NullValue();
             }
             return v;
         }
 
         case LOCAL_GL_VERTEX_ATTRIB_ARRAY_STRIDE:
             return JS::Int32Value(mAttribBuffers[index].stride);
 
@@ -3487,17 +3491,17 @@ WebGLContext::GetVertexAttrib(JSContext*
             } else {
                 vec[0] = mVertexAttrib0Vector[0];
                 vec[1] = mVertexAttrib0Vector[1];
                 vec[2] = mVertexAttrib0Vector[2];
                 vec[3] = mVertexAttrib0Vector[3];
             }
             JSObject* obj = Float32Array::Create(cx, 4, vec);
             if (!obj) {
-                rv = NS_ERROR_OUT_OF_MEMORY;
+                rv.Throw(NS_ERROR_OUT_OF_MEMORY);
             }
             return JS::ObjectOrNullValue(obj);
         }
 
         case LOCAL_GL_VERTEX_ATTRIB_ARRAY_ENABLED:
         case LOCAL_GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
         {
             GLint i = 0;
@@ -3696,35 +3700,34 @@ WebGLContext::IsEnabled(WebGLenum cap)
     return gl->fIsEnabled(cap);
 }
 
 GL_SAME_METHOD_1(LineWidth, LineWidth, WebGLfloat)
 
 NS_IMETHODIMP
 WebGLContext::LinkProgram(nsIWebGLProgram *pobj)
 {
-    nsresult rv = NS_OK;
+    ErrorResult rv;
     LinkProgram(static_cast<WebGLProgram*>(pobj), rv);
-    return rv;
+    return rv.ErrorCode();
 }
 
 void
-WebGLContext::LinkProgram(WebGLProgram *program, nsresult& rv)
+WebGLContext::LinkProgram(WebGLProgram *program, ErrorResult& rv)
 {
     if (!IsContextStable())
         return;
 
     if (!ValidateObject("linkProgram", program))
         return;
     
     GLuint progname = program->GLName();
 
     if (!program->NextGeneration()) {
-        rv = NS_ERROR_FAILURE;
-        return;
+        return rv.Throw(NS_ERROR_FAILURE);
     }
 
     if (!program->HasBothShaderTypesAttached()) {
         program->SetLinkStatus(false);
         return;
     }
 
     MakeContextCurrent();
@@ -3795,35 +3798,34 @@ WebGLContext::ReadPixels(WebGLint x, Web
         return NS_ERROR_FAILURE;
     }
 
     if (!JS_IsTypedArrayObject(&pixelsVal.toObject(), cx)) {
         return NS_ERROR_FAILURE;
     }
 
     ArrayBufferView pixels(cx, &pixelsVal.toObject());
-    nsresult rv = NS_OK;
+    ErrorResult rv;
     ReadPixels(x, y, width, height, format, type, &pixels, rv);
-    return rv;
+    return rv.ErrorCode();
 }
 
 void
 WebGLContext::ReadPixels(WebGLint x, WebGLint y, WebGLsizei width,
                          WebGLsizei height, WebGLenum format,
                          WebGLenum type, ArrayBufferView* pixels,
-                         nsresult& rv)
+                         ErrorResult& rv)
 {
     if (!IsContextStable()) {
         return;
     }
 
     if (HTMLCanvasElement()->IsWriteOnly() && !nsContentUtils::IsCallerTrustedForRead()) {
         LogMessageIfVerbose("ReadPixels: Not allowed");
-        rv = NS_ERROR_DOM_SECURITY_ERR;
-        return;
+        return rv.Throw(NS_ERROR_DOM_SECURITY_ERR);
     }
 
     if (width < 0 || height < 0)
         return ErrorInvalidValue("ReadPixels: negative size passed");
 
     const WebGLRectangleObject *framebufferRect = FramebufferRectangleObject();
     WebGLsizei framebufferWidth = framebufferRect ? framebufferRect->Width() : 0;
     WebGLsizei framebufferHeight = framebufferRect ? framebufferRect->Height() : 0;
@@ -4016,18 +4018,17 @@ WebGLContext::ReadPixels(WebGLint x, Web
                         *rowp = 0xff;
                         rowp += 4;
                     }
 
                     row += checked_alignedRowSize.value();
                 }
             } else {
                 NS_WARNING("Unhandled case, how'd we get here?");
-                rv = NS_ERROR_FAILURE;
-                return;
+                return rv.Throw(NS_ERROR_FAILURE);
             }
         }            
     }
 }
 
 NS_IMETHODIMP
 WebGLContext::MozRenderbufferStorage(WebGLenum target, WebGLenum internalformat, WebGLsizei width, WebGLsizei height)
 {
@@ -5355,23 +5356,24 @@ WebGLContext::GetShaderParameter(WebGLSh
     }
 
     return JS::NullValue();
 }
 
 NS_IMETHODIMP
 WebGLContext::GetShaderInfoLog(nsIWebGLShader *sobj, nsAString& retval)
 {
-    nsresult rv = NS_OK;
+    ErrorResult rv;
     GetShaderInfoLog(static_cast<WebGLShader*>(sobj), retval, rv);
-    return rv;
+    return rv.ErrorCode();
 }
 
 void
-WebGLContext::GetShaderInfoLog(WebGLShader *shader, nsAString& retval, nsresult& rv)
+WebGLContext::GetShaderInfoLog(WebGLShader *shader, nsAString& retval,
+                               ErrorResult& rv)
 {
     if (!IsContextStable())
     {
         retval.SetIsVoid(true);
         return;
     }
 
     if (!ValidateObject("getShaderInfoLog: shader", shader))
@@ -5384,18 +5386,17 @@ WebGLContext::GetShaderInfoLog(WebGLShad
     }
 
     MakeContextCurrent();
 
     WebGLuint shadername = shader->GLName();
     GLint k = -1;
     gl->fGetShaderiv(shadername, LOCAL_GL_INFO_LOG_LENGTH, &k);
     if (k == -1) {
-        rv = NS_ERROR_FAILURE; // XXX GL Error? should never happen.
-        return;
+        return rv.Throw(NS_ERROR_FAILURE); // XXX GL Error? should never happen.
     }
 
     if (k == 0) {
         retval.Truncate();
         return;
     }
 
     nsCAutoString log;
@@ -5785,33 +5786,33 @@ WebGLContext::TexImage2D_base(WebGLenum 
 }
 
 NS_IMETHODIMP
 WebGLContext::TexImage2D_array(WebGLenum target, WebGLint level, WebGLenum internalformat,
                                WebGLsizei width, WebGLsizei height, WebGLint border,
                                WebGLenum format, WebGLenum type,
                                JSObject *pixels, JSContext *cx)
 {
-    nsresult rv = NS_OK;
+    ErrorResult rv;
     if (!pixels) {
         TexImage2D(cx, target, level, internalformat, width, height, border,
                    format, type, nsnull, rv);
     } else {
         ArrayBufferView view(cx, pixels);
         TexImage2D(cx, target, level, internalformat, width, height, border,
                    format, type, &view, rv);
     }
-    return rv;
+    return rv.ErrorCode();
 }
 
 void
 WebGLContext::TexImage2D(JSContext* cx, WebGLenum target, WebGLint level,
                          WebGLenum internalformat, WebGLsizei width,
                          WebGLsizei height, WebGLint border, WebGLenum format,
-                         WebGLenum type, ArrayBufferView *pixels, nsresult& rv)
+                         WebGLenum type, ArrayBufferView *pixels, ErrorResult& rv)
 {
     if (!IsContextStable())
         return;
 
     return TexImage2D_base(target, level, internalformat, width, height, 0, border, format, type,
                            pixels ? pixels->mData : 0,
                            pixels ? pixels->mLength : 0,
                            pixels ? (int)JS_GetTypedArrayType(pixels->mObj, cx) : -1,
@@ -5835,17 +5836,17 @@ WebGLContext::TexImage2D_imageData(WebGL
                     -1,
                     WebGLTexelFormat::RGBA8, false);
     return NS_OK;
 }
 
 void
 WebGLContext::TexImage2D(JSContext* cx, WebGLenum target, WebGLint level,
                          WebGLenum internalformat, WebGLenum format,
-                         WebGLenum type, ImageData* pixels, nsresult& rv)
+                         WebGLenum type, ImageData* pixels, ErrorResult& rv)
 {
     if (!IsContextStable())
         return;
 
     if (!pixels) {
         // Spec says to generate an INVALID_VALUE error
         return ErrorInvalidValue("texImage2D: null ImageData");
     }
@@ -5857,35 +5858,35 @@ WebGLContext::TexImage2D(JSContext* cx, 
                            WebGLTexelFormat::RGBA8, false);
 }
 
 
 NS_IMETHODIMP
 WebGLContext::TexImage2D_dom(WebGLenum target, WebGLint level, WebGLenum internalformat,
                              WebGLenum format, GLenum type, Element* elt)
 {
-    nsresult rv = NS_OK;
+    ErrorResult rv;
     TexImage2D(NULL, target, level, internalformat, format, type, elt, rv);
-    return rv;
+    return rv.ErrorCode();
 }
 
 void
 WebGLContext::TexImage2D(JSContext* /* unused */, WebGLenum target,
                          WebGLint level, WebGLenum internalformat,
                          WebGLenum format, WebGLenum type, Element* elt,
-                         nsresult& rv)
+                         ErrorResult& rv)
 {
     if (!IsContextStable())
         return;
 
     nsRefPtr<gfxImageSurface> isurf;
 
     int srcFormat;
     rv = DOMElementToImageSurface(elt, getter_AddRefs(isurf), &srcFormat);
-    if (NS_FAILED(rv))
+    if (rv.Failed())
         return;
 
     PRUint32 byteLength = isurf->Stride() * isurf->Height();
 
     return TexImage2D_base(target, level, internalformat,
                            isurf->Width(), isurf->Height(), isurf->Stride(), 0,
                            format, type,
                            isurf->Data(), byteLength,
@@ -6017,35 +6018,35 @@ WebGLContext::TexSubImage2D_base(WebGLen
 
 NS_IMETHODIMP
 WebGLContext::TexSubImage2D_array(WebGLenum target, WebGLint level,
                                   WebGLint xoffset, WebGLint yoffset,
                                   WebGLsizei width, WebGLsizei height,
                                   WebGLenum format, WebGLenum type,
                                   JSObject *pixels, JSContext *cx)
 {
-    nsresult rv = NS_OK;
+    ErrorResult rv;
     if (!pixels) {
         TexSubImage2D(cx, target, level, xoffset, yoffset, width, height,
                       format, type, nsnull, rv);
     } else {
         ArrayBufferView view(cx, pixels);
         TexSubImage2D(cx, target, level, xoffset, yoffset, width, height,
                       format, type, &view, rv);
     }
-    return rv;
+    return rv.ErrorCode();
 }
 
 void
 WebGLContext::TexSubImage2D(JSContext* cx, WebGLenum target, WebGLint level,
                             WebGLint xoffset, WebGLint yoffset,
                             WebGLsizei width, WebGLsizei height,
                             WebGLenum format, WebGLenum type,
                             ArrayBufferView* pixels,
-                            nsresult& rv)
+                            ErrorResult& rv)
 {
     if (!IsContextStable())
         return;
 
     if (!pixels)
         return ErrorInvalidValue("TexSubImage2D: pixels must not be null!");
 
     return TexSubImage2D_base(target, level, xoffset, yoffset,
@@ -6079,17 +6080,17 @@ WebGLContext::TexSubImage2D_imageData(We
                        WebGLTexelFormat::RGBA8, false);
     return NS_OK;
 }
 
 void
 WebGLContext::TexSubImage2D(JSContext* cx, WebGLenum target, WebGLint level,
                             WebGLint xoffset, WebGLint yoffset,
                             WebGLenum format, WebGLenum type, ImageData* pixels,
-                            nsresult& rv)
+                            ErrorResult& rv)
 {
     if (!IsContextStable())
         return;
 
     if (!pixels)
         return ErrorInvalidValue("TexSubImage2D: pixels must not be null!");
 
     Uint8ClampedArray arr(cx, pixels->GetDataObject());
@@ -6102,35 +6103,35 @@ WebGLContext::TexSubImage2D(JSContext* c
 }
 
 NS_IMETHODIMP
 WebGLContext::TexSubImage2D_dom(WebGLenum target, WebGLint level,
                                 WebGLint xoffset, WebGLint yoffset,
                                 WebGLenum format, WebGLenum type,
                                 Element *elt)
 {
-    nsresult rv = NS_OK;
+    ErrorResult rv;
     TexSubImage2D(NULL, target, level, xoffset, yoffset, format, type, elt, rv);
-    return rv;
+    return rv.ErrorCode();
 }
 
 void
 WebGLContext::TexSubImage2D(JSContext* /* unused */, WebGLenum target,
                             WebGLint level, WebGLint xoffset, WebGLint yoffset,
                             WebGLenum format, WebGLenum type,
-                            dom::Element* elt, nsresult& rv)
+                            dom::Element* elt, ErrorResult& rv)
 {
     if (!IsContextStable())
         return;
 
     nsRefPtr<gfxImageSurface> isurf;
 
     int srcFormat;
     rv = DOMElementToImageSurface(elt, getter_AddRefs(isurf), &srcFormat);
-    if (NS_FAILED(rv))
+    if (rv.Failed())
         return;
 
     PRUint32 byteLength = isurf->Stride() * isurf->Height();
 
     return TexSubImage2D_base(target, level,
                               xoffset, yoffset,
                               isurf->Width(), isurf->Height(), isurf->Stride(),
                               format, type,
--- a/content/events/src/nsDOMEventTargetHelper.h
+++ b/content/events/src/nsDOMEventTargetHelper.h
@@ -44,16 +44,17 @@
 #include "nsIDOMEventTarget.h"
 #include "nsIDOMEventListener.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsPIDOMWindow.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsEventListenerManager.h"
 #include "nsIScriptContext.h"
 #include "nsWrapperCache.h"
+#include "mozilla/ErrorResult.h"
 
 class nsDOMEventListenerWrapper : public nsIDOMEventListener
 {
 public:
   nsDOMEventListenerWrapper(nsIDOMEventListener* aListener)
   : mListener(aListener) {}
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
@@ -75,29 +76,29 @@ public:
   virtual ~nsDOMEventTargetHelper();
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMEventTargetHelper)
 
   NS_DECL_NSIDOMEVENTTARGET
   void AddEventListener(const nsAString& aType,
                         nsIDOMEventListener* aCallback, // XXX nullable
                         bool aCapture, Nullable<bool>& aWantsUntrusted,
-                        nsresult& aRv)
+                        mozilla::ErrorResult& aRv)
   {
     aRv = AddEventListener(aType, aCallback, aCapture,
                            !aWantsUntrusted.IsNull() && aWantsUntrusted.Value(),
                            aWantsUntrusted.IsNull() ? 1 : 2);
   }
   void RemoveEventListener(const nsAString& aType,
                            nsIDOMEventListener* aCallback,
-                           bool aCapture, nsresult& aRv)
+                           bool aCapture, mozilla::ErrorResult& aRv)
   {
     aRv = RemoveEventListener(aType, aCallback, aCapture);
   }
-  bool DispatchEvent(nsIDOMEvent* aEvent, nsresult& aRv)
+  bool DispatchEvent(nsIDOMEvent* aEvent, mozilla::ErrorResult& aRv)
   {
     bool result = false;
     aRv = DispatchEvent(aEvent, &result);
     return result;
   }
 
   void GetParentObject(nsIScriptGlobalObject **aParentObject)
   {
--- a/content/media/ogg/nsOggCodecState.cpp
+++ b/content/media/ogg/nsOggCodecState.cpp
@@ -874,17 +874,17 @@ bool nsOpusState::DecodeHeader(ogg_packe
   }
 
   return true;
 }
 
 /* Return the timestamp (in microseconds) equivalent to a granulepos. */
 PRInt64 nsOpusState::Time(PRInt64 granulepos)
 {
-  if (granulepos < 0)
+  if (!mActive || granulepos < 0)
     return -1;
 
   // Ogg Opus always runs at a granule rate of 48 kHz.
   CheckedInt64 t = CheckedInt64(granulepos - mPreSkip) * USECS_PER_S;
   return t.valid() ? t.value() / mRate : -1;
 }
 
 bool nsOpusState::IsHeader(ogg_packet* aPacket)
--- a/dom/bindings/BindingUtils.h
+++ b/dom/bindings/BindingUtils.h
@@ -4,16 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_BindingUtils_h__
 #define mozilla_dom_BindingUtils_h__
 
 #include "mozilla/dom/DOMJSClass.h"
 #include "mozilla/dom/workers/Workers.h"
+#include "mozilla/ErrorResult.h"
 
 #include "jsapi.h"
 #include "jsfriendapi.h"
 
 #include "XPCQuickStubs.h"
 #include "XPCWrapper.h"
 #include "nsTraceRefcnt.h"
 #include "nsWrapperCacheInlines.h"
@@ -39,21 +40,21 @@ Throw(JSContext* cx, nsresult rv)
       ThrowDOMExceptionForNSResult(cx, rv);
     }
   }
   return false;
 }
 
 template<bool mainThread>
 inline bool
-ThrowMethodFailedWithDetails(JSContext* cx, nsresult rv,
+ThrowMethodFailedWithDetails(JSContext* cx, const ErrorResult& rv,
                              const char* /* ifaceName */,
                              const char* /* memberName */)
 {
-  return Throw<mainThread>(cx, rv);
+  return Throw<mainThread>(cx, rv.ErrorCode());
 }
 
 inline bool
 IsDOMClass(const JSClass* clasp)
 {
   return clasp->flags & JSCLASS_IS_DOMJSCLASS;
 }
 
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -62,19 +62,22 @@ DOMInterfaces = {
         ]
     },
     'resultNotAddRefed': [ 'upload', 'responseXML' ]
 },
 {
     'workers': True,
     'nativeType': 'mozilla::dom::workers::XMLHttpRequest',
     'headerFile': 'mozilla/dom/workers/bindings/XMLHttpRequest.h',
-    'infallible': [
-        'readyState', 'statusText'
-    ]
+    'infallible': {
+        'all': ['readyState', 'statusText' ],
+        'getterOnly': [ 'timeout', 'withCredentials', 'mozBackgroundRequest',
+                        'responseType', 'responseXML', 'channel', 'multipart' ]
+    }
+
 }],
 
 'XMLHttpRequestUpload': [
 {
     'nativeType': 'nsXMLHttpRequestUpload',
     'headerFile': 'nsXMLHttpRequest.h',
     'prefable': True
 },
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -1605,18 +1605,18 @@ class CGCallGenerator(CGThing):
             self.cgRoot.prepend(result)
             if not resultOutParam:
                 call = CGWrapper(call, pre="result = ")
 
         call = CGWrapper(call)
         self.cgRoot.append(call)
 
         if isFallible:
-            self.cgRoot.prepend(CGGeneric("nsresult rv = NS_OK;"))
-            self.cgRoot.append(CGGeneric("if (NS_FAILED(rv)) {"))
+            self.cgRoot.prepend(CGGeneric("ErrorResult rv;"))
+            self.cgRoot.append(CGGeneric("if (rv.Failed()) {"))
             self.cgRoot.append(CGIndenter(CGGeneric(errorReport)))
             self.cgRoot.append(CGGeneric("}"))
 
     def define(self):
         return self.cgRoot.define()
 
 class CGPerSignatureCall(CGThing):
     """
new file mode 100644
--- /dev/null
+++ b/dom/bindings/ErrorResult.h
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
+/* vim: set ts=2 sw=2 et tw=79: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/**
+ * A struct for tracking exceptions that need to be thrown to JS.
+ */
+
+#ifndef mozilla_ErrorResult_h
+#define mozilla_ErrorResult_h
+
+#include "nscore.h"
+
+namespace mozilla {
+
+class ErrorResult {
+public:
+  ErrorResult() {
+    mResult = NS_OK;
+  }
+
+  void Throw(nsresult rv) {
+    MOZ_ASSERT(NS_FAILED(rv), "Please don't try throwing success");
+    mResult = rv;
+  }
+
+  // In the future, we can add overloads of Throw that take more
+  // interesting things, like strings or DOM exception types or
+  // something if desired.
+
+  // Backwards-compat to make conversion simpler.  We don't call
+  // Throw() here because people can easily pass success codes to
+  // this.
+  void operator=(nsresult rv) {
+    mResult = rv;
+  }
+
+  bool Failed() const {
+    return NS_FAILED(mResult);
+  }
+
+  nsresult ErrorCode() const {
+    return mResult;
+  }
+
+private:
+  nsresult mResult;
+};
+
+} // namespace mozilla
+
+#endif /* mozilla_ErrorResult_h */
--- a/dom/bindings/Makefile.in
+++ b/dom/bindings/Makefile.in
@@ -40,17 +40,21 @@ globalgen_targets := \
   $(NULL)
 
 CPPSRCS = \
   $(binding_cpp_files) \
   $(filter %.cpp, $(globalgen_targets)) \
   BindingUtils.cpp \
   $(NULL)
 
-EXPORTS_NAMESPACES = $(binding_include_path)
+EXPORTS_NAMESPACES = $(binding_include_path) mozilla
+
+EXPORTS_mozilla = \
+  ErrorResult.h \
+  $(NULL)
 
 EXPORTS_$(binding_include_path) = \
   DOMJSClass.h \
   PrototypeList.h \
   RegisterBindings.h \
   Nullable.h \
   PrimitiveConversions.h \
   TypedArray.h \
--- a/dom/workers/EventListenerManager.cpp
+++ b/dom/workers/EventListenerManager.cpp
@@ -9,16 +9,17 @@
 #include "jsfriendapi.h"
 #include "js/Vector.h"
 #include "mozilla/Util.h"
 
 #include "Events.h"
 #include "EventTarget.h"
 
 USING_WORKERS_NAMESPACE
+using mozilla::ErrorResult;
 
 namespace {
 
 struct ListenerCollection : PRCList
 {
   jsid mTypeId;
   PRCList mListenerHead;
 
@@ -189,28 +190,28 @@ EventListenerManager::FinalizeInternal(J
 #ifdef DEBUG
   PR_INIT_CLIST(&mCollectionHead);
 #endif
 }
 
 void
 EventListenerManager::Add(JSContext* aCx, const jsid& aType,
                           JSObject* aListener, Phase aPhase,
-                          bool aWantsUntrusted, nsresult& aRv)
+                          bool aWantsUntrusted, ErrorResult& aRv)
 {
   MOZ_ASSERT(aListener);
 
   ListenerCollection* collection =
     GetCollectionForType(&mCollectionHead, aType);
   if (!collection) {
     ListenerCollection* head =
       static_cast<ListenerCollection*>(&mCollectionHead);
     collection = ListenerCollection::Add(aCx, head, aType);
     if (!collection) {
-      aRv = NS_ERROR_OUT_OF_MEMORY;
+      aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
       return;
     }
   }
 
   for (PRCList* elem = PR_NEXT_LINK(&collection->mListenerHead);
        elem != &collection->mListenerHead;
        elem = PR_NEXT_LINK(elem)) {
     ListenerData* listenerData = static_cast<ListenerData*>(elem);
@@ -220,17 +221,17 @@ EventListenerManager::Add(JSContext* aCx
     }
   }
 
   ListenerData* listenerData =
     ListenerData::Add(aCx,
                       static_cast<ListenerData*>(&collection->mListenerHead),
                       aListener, aPhase, aWantsUntrusted);
   if (!listenerData) {
-    aRv = NS_ERROR_OUT_OF_MEMORY;
+    aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
     return;
   }
 }
 
 void
 EventListenerManager::Remove(JSContext* aCx, const jsid& aType,
                              JSObject* aListener, Phase aPhase,
                              bool aClearEmpty)
@@ -274,56 +275,56 @@ EventListenerManager::GetEventListener(c
   }
     }
 
   return NULL;
 }
 
 bool
 EventListenerManager::DispatchEvent(JSContext* aCx, const EventTarget& aTarget,
-                                    JSObject* aEvent, nsresult& aRv) const
+                                    JSObject* aEvent, ErrorResult& aRv) const
 {
   using namespace mozilla::dom::workers::events;
 
   if (!IsSupportedEventClass(aEvent)) {
-    aRv = NS_ERROR_FAILURE;
+    aRv.Throw(NS_ERROR_FAILURE);
     return false;
   }
 
   jsval val;
   if (!JS_GetProperty(aCx, aEvent, "target", &val)) {
-    aRv = NS_ERROR_FAILURE;
+    aRv.Throw(NS_ERROR_FAILURE);
     return false;
   }
 
   if (!JSVAL_IS_NULL(val)) {
     // Already has a target, must be recursively dispatched. Throw.
-    aRv = NS_ERROR_FAILURE;
+    aRv.Throw(NS_ERROR_FAILURE);
     return false;
   }
 
   if (PR_CLIST_IS_EMPTY(&mCollectionHead)) {
     return false;
   }
 
   JSString* eventType;
   JSBool eventIsTrusted;
 
   if (!JS_GetProperty(aCx, aEvent, "type", &val) ||
       !(eventType = JS_ValueToString(aCx, val)) ||
       !(eventType = JS_InternJSString(aCx, eventType))) {
-    aRv = NS_ERROR_FAILURE;
+    aRv.Throw(NS_ERROR_FAILURE);
     return false;
   }
 
   // We have already ensure that the event is one of our types of events so
   // there is no need to worry about this property being faked.
   if (!JS_GetProperty(aCx, aEvent, "isTrusted", &val) ||
       !JS_ValueToBoolean(aCx, val, &eventIsTrusted)) {
-    aRv = NS_ERROR_FAILURE;
+    aRv.Throw(NS_ERROR_FAILURE);
     return false;
   }
 
   ListenerCollection* collection =
     GetCollectionForType(&mCollectionHead,
                          INTERNED_STRING_TO_JSID(aCx, eventType));
   if (!collection) {
     return false;
@@ -336,17 +337,17 @@ EventListenerManager::DispatchEvent(JSCo
        elem != &collection->mListenerHead;
        elem = PR_NEXT_LINK(elem)) {
     ListenerData* listenerData = static_cast<ListenerData*>(elem);
 
     // Listeners that don't want untrusted events will be skipped if this is an
     // untrusted event.
     if ((eventIsTrusted || listenerData->mWantsUntrusted) &&
         !listeners.append(listenerData->mListener)) {
-      aRv = NS_ERROR_OUT_OF_MEMORY;
+      aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
       return false;
     }
   }
 
   if (listeners.empty()) {
     return false;
   }
 
@@ -363,53 +364,53 @@ EventListenerManager::DispatchEvent(JSCo
     // out of memory or the operation callback has indicated that we should
     // stop running.
 
     jsval listenerVal = OBJECT_TO_JSVAL(listeners[index]);
 
     JSObject* listenerObj;
     if (!JS_ValueToObject(aCx, listenerVal, &listenerObj)) {
       if (!JS_ReportPendingException(aCx)) {
-        aRv = NS_ERROR_FAILURE;
+        aRv.Throw(NS_ERROR_FAILURE);
         return false;
       }
       continue;
     }
 
     static const char sHandleEventChars[] = "handleEvent";
 
     JSObject* thisObj = aTarget.GetJSObject();
 
     JSBool hasHandleEvent;
     if (!JS_HasProperty(aCx, listenerObj, sHandleEventChars, &hasHandleEvent)) {
       if (!JS_ReportPendingException(aCx)) {
-        aRv = NS_ERROR_FAILURE;
+        aRv.Throw(NS_ERROR_FAILURE);
         return false;
       }
       continue;
     }
 
     if (hasHandleEvent) {
       if (!JS_GetProperty(aCx, listenerObj, sHandleEventChars, &listenerVal)) {
         if (!JS_ReportPendingException(aCx)) {
-          aRv = NS_ERROR_FAILURE;
+          aRv.Throw(NS_ERROR_FAILURE);
           return false;
         }
         continue;
       }
 
       thisObj = listenerObj;
     }
 
     jsval argv[] = { OBJECT_TO_JSVAL(aEvent) };
     jsval rval = JSVAL_VOID;
     if (!JS_CallFunctionValue(aCx, thisObj, listenerVal, ArrayLength(argv),
                               argv, &rval)) {
       if (!JS_ReportPendingException(aCx)) {
-        aRv = NS_ERROR_FAILURE;
+        aRv.Throw(NS_ERROR_FAILURE);
         return false;
       }
       continue;
     }
   }
 
   return EventWasCanceled(aEvent);
 }
--- a/dom/workers/EventListenerManager.h
+++ b/dom/workers/EventListenerManager.h
@@ -5,16 +5,18 @@
 
 #ifndef mozilla_dom_workers_listenermanager_h__
 #define mozilla_dom_workers_listenermanager_h__
 
 #include "mozilla/dom/workers/Workers.h"
 
 #include "prclist.h"
 
+#include "mozilla/ErrorResult.h"
+
 BEGIN_WORKERS_NAMESPACE
 
 class EventTarget;
 
 // XXX Current impl doesn't divide into phases.
 // XXX Current impl doesn't handle event target chains.
 class EventListenerManager
 {
@@ -51,17 +53,17 @@ public:
     All = 0,
     Capturing,
     Onfoo,
     Bubbling
   };
 
   void
   AddEventListener(JSContext* aCx, const jsid& aType, JSObject* aListener,
-                   bool aCapturing, bool aWantsUntrusted, nsresult& aRv)
+                   bool aCapturing, bool aWantsUntrusted, ErrorResult& aRv)
   {
     Add(aCx, aType, aListener, aCapturing ? Capturing : Bubbling,
         aWantsUntrusted, aRv);
   }
 
   void
   RemoveEventListener(JSContext* aCx, const jsid& aType, JSObject* aListener,
                       bool aCapturing)
@@ -69,24 +71,24 @@ public:
     if (PR_CLIST_IS_EMPTY(&mCollectionHead)) {
       return;
     }
     Remove(aCx, aType, aListener, aCapturing ? Capturing : Bubbling, true);
   }
 
   bool
   DispatchEvent(JSContext* aCx, const EventTarget& aTarget, JSObject* aEvent,
-                nsresult& aRv) const;
+                ErrorResult& aRv) const;
 
   JSObject*
   GetEventListener(const jsid& aType) const;
 
   void
   SetEventListener(JSContext* aCx, const jsid& aType, JSObject* aListener,
-                   nsresult& aRv)
+                   ErrorResult& aRv)
   {
     JSObject* existing = GetEventListener(aType);
     if (existing) {
       Remove(aCx, aType, existing, Onfoo, false);
     }
 
     if (aListener) {
       Add(aCx, aType, aListener, Onfoo, false, aRv);
@@ -109,17 +111,17 @@ private:
   void
   TraceInternal(JSTracer* aTrc) const;
 
   void
   FinalizeInternal(JSFreeOp* aFop);
 
   void
   Add(JSContext* aCx, const jsid& aType, JSObject* aListener, Phase aPhase,
-      bool aWantsUntrusted, nsresult& aRv);
+      bool aWantsUntrusted, ErrorResult& aRv);
 
   void
   Remove(JSContext* aCx, const jsid& aType, JSObject* aListener, Phase aPhase,
          bool aClearEmpty);
 
   bool
   HasListenersForTypeInternal(JSContext* aCx, const jsid& aType) const;
 };
--- a/dom/workers/EventTarget.cpp
+++ b/dom/workers/EventTarget.cpp
@@ -1,99 +1,100 @@
 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "EventTarget.h"
 
 USING_WORKERS_NAMESPACE
+using mozilla::ErrorResult;
 
 void
 EventTarget::_Trace(JSTracer* aTrc)
 {
   mListenerManager._Trace(aTrc);
   DOMBindingBase::_Trace(aTrc);
 }
 
 void
 EventTarget::_Finalize(JSFreeOp* aFop)
 {
   mListenerManager._Finalize(aFop);
   DOMBindingBase::_Finalize(aFop);
 }
 
 JSObject*
-EventTarget::GetEventListener(const nsAString& aType, nsresult& aRv) const
+EventTarget::GetEventListener(const nsAString& aType, ErrorResult& aRv) const
 {
   JSContext* cx = GetJSContext();
 
   JSString* type =
     JS_NewUCStringCopyN(cx, aType.BeginReading(), aType.Length());
   if (!type || !(type = JS_InternJSString(cx, type))) {
-    aRv = NS_ERROR_OUT_OF_MEMORY;
+    aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
     return NULL;
   }
 
   return mListenerManager.GetEventListener(INTERNED_STRING_TO_JSID(cx, type));
 }
 
 void
 EventTarget::SetEventListener(const nsAString& aType, JSObject* aListener,
-                              nsresult& aRv)
+                              ErrorResult& aRv)
 {
   JSContext* cx = GetJSContext();
 
   JSString* type =
     JS_NewUCStringCopyN(cx, aType.BeginReading(), aType.Length());
   if (!type || !(type = JS_InternJSString(cx, type))) {
-    aRv = NS_ERROR_OUT_OF_MEMORY;
+    aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
     return;
   }
 
   mListenerManager.SetEventListener(cx, INTERNED_STRING_TO_JSID(cx, type),
                                     aListener, aRv);
 }
 
 void
 EventTarget::AddEventListener(const nsAString& aType, JSObject* aListener,
                               bool aCapturing, Nullable<bool> aWantsUntrusted,
-                              nsresult& aRv)
+                              ErrorResult& aRv)
 {
   if (!aListener) {
     return;
   }
 
   JSContext* cx = GetJSContext();
 
   JSString* type =
     JS_NewUCStringCopyN(cx, aType.BeginReading(), aType.Length());
   if (!type || !(type = JS_InternJSString(cx, type))) {
-    aRv = NS_ERROR_OUT_OF_MEMORY;
+    aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
     return;
   }
 
   bool wantsUntrusted = !aWantsUntrusted.IsNull() && aWantsUntrusted.Value();
   mListenerManager.AddEventListener(cx, INTERNED_STRING_TO_JSID(cx, type),
                                     aListener, aCapturing, wantsUntrusted,
                                     aRv);
 }
 
 void
 EventTarget::RemoveEventListener(const nsAString& aType, JSObject* aListener,
-                                 bool aCapturing, nsresult& aRv)
+                                 bool aCapturing, ErrorResult& aRv)
 {
   if (!aListener) {
     return;
   }
 
   JSContext* cx = GetJSContext();
 
   JSString* type =
     JS_NewUCStringCopyN(cx, aType.BeginReading(), aType.Length());
   if (!type || !(type = JS_InternJSString(cx, type))) {
-    aRv = NS_ERROR_OUT_OF_MEMORY;
+    aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
     return;
   }
 
   mListenerManager.RemoveEventListener(cx, INTERNED_STRING_TO_JSID(cx, type),
                                        aListener, aCapturing);
 }
--- a/dom/workers/EventTarget.h
+++ b/dom/workers/EventTarget.h
@@ -7,16 +7,17 @@
 #define mozilla_dom_workers_eventtarget_h__
 
 #include "mozilla/dom/workers/bindings/DOMBindingBase.h"
 
 // I hate having to export this...
 #include "mozilla/dom/workers/bindings/EventListenerManager.h"
 
 #include "mozilla/dom/Nullable.h"
+#include "mozilla/ErrorResult.h"
 
 using namespace mozilla::dom;
 
 BEGIN_WORKERS_NAMESPACE
 
 class EventTarget : public DOMBindingBase
 {
   EventListenerManager mListenerManager;
@@ -33,34 +34,35 @@ public:
   virtual void
   _Trace(JSTracer* aTrc) MOZ_OVERRIDE;
 
   virtual void
   _Finalize(JSFreeOp* aFop) MOZ_OVERRIDE;
 
   void
   AddEventListener(const nsAString& aType, JSObject* aListener,
-                   bool aCapture, Nullable<bool> aWantsUntrusted, nsresult& aRv);
+                   bool aCapture, Nullable<bool> aWantsUntrusted,
+                   ErrorResult& aRv);
 
   void
   RemoveEventListener(const nsAString& aType, JSObject* aListener,
-                      bool aCapture, nsresult& aRv);
+                      bool aCapture, ErrorResult& aRv);
 
   bool
-  DispatchEvent(JSObject* aEvent, nsresult& aRv) const
+  DispatchEvent(JSObject* aEvent, ErrorResult& aRv) const
   {
     return mListenerManager.DispatchEvent(GetJSContext(), *this, aEvent, aRv);
   }
 
   JSObject*
-  GetEventListener(const nsAString& aType, nsresult& aRv) const;
+  GetEventListener(const nsAString& aType, ErrorResult& aRv) const;
 
   void
   SetEventListener(const nsAString& aType, JSObject* aListener,
-                   nsresult& aRv);
+                   ErrorResult& aRv);
 
   bool
   HasListeners() const
   {
     return mListenerManager.HasListeners();
   }
 };
 
--- a/dom/workers/Worker.cpp
+++ b/dom/workers/Worker.cpp
@@ -51,16 +51,17 @@
   (JSPROP_ENUMERATE | JSPROP_SHARED)
 
 #define FUNCTION_FLAGS \
   JSPROP_ENUMERATE
 
 USING_WORKERS_NAMESPACE
 
 using namespace mozilla::dom;
+using mozilla::ErrorResult;
 
 namespace {
 
 class Worker
 {
   static DOMJSClass sClass;
   static JSPropertySpec sProperties[];
   static JSFunctionSpec sFunctions[];
@@ -193,20 +194,20 @@ private:
 
     const char* name = sEventStrings[JSID_TO_INT(aIdval)];
     WorkerPrivate* worker = GetInstancePrivate(aCx, aObj, name);
     if (!worker) {
       return !JS_IsExceptionPending(aCx);
     }
 
     NS_ConvertASCIItoUTF16 nameStr(name + 2);
-    nsresult rv = NS_OK;
+    ErrorResult rv;
     JSObject* listener = worker->GetEventListener(nameStr, rv);
 
-    if (NS_FAILED(rv)) {
+    if (rv.Failed()) {
       JS_ReportError(aCx, "Failed to get listener!");
     }
 
     *aVp = listener ? OBJECT_TO_JSVAL(listener) : JSVAL_NULL;
     return true;
   }
 
   static JSBool
@@ -223,20 +224,20 @@ private:
     }
 
     JSObject* listener;
     if (!JS_ValueToObject(aCx, *aVp, &listener)) {
       return false;
     }
 
     NS_ConvertASCIItoUTF16 nameStr(name + 2);
-    nsresult rv = NS_OK;
+    ErrorResult rv;
     worker->SetEventListener(nameStr, listener, rv);
 
-    if (NS_FAILED(rv)) {
+    if (rv.Failed()) {
       JS_ReportError(aCx, "Failed to set listener!");
       return false;
     }
 
     return true;
   }
 
   static JSBool
--- a/dom/workers/WorkerScope.cpp
+++ b/dom/workers/WorkerScope.cpp
@@ -172,22 +172,22 @@ private:
     JS_ASSERT(JSID_TO_INT(aIdval) >= 0 && JSID_TO_INT(aIdval) < STRING_COUNT);
 
     const char* name = sEventStrings[JSID_TO_INT(aIdval)];
     WorkerGlobalScope* scope = GetInstancePrivate(aCx, aObj, name);
     if (!scope) {
       return false;
     }
 
-    nsresult rv = NS_OK;
+    ErrorResult rv;
 
     JSObject* listener =
       scope->GetEventListener(NS_ConvertASCIItoUTF16(name + 2), rv);
 
-    if (NS_FAILED(rv)) {
+    if (rv.Failed()) {
       JS_ReportError(aCx, "Failed to get event listener!");
       return false;
     }
 
     *aVp = listener ? OBJECT_TO_JSVAL(listener) : JSVAL_NULL;
     return true;
   }
 
@@ -204,20 +204,20 @@ private:
       return false;
     }
 
     if (JSVAL_IS_PRIMITIVE(*aVp)) {
       JS_ReportError(aCx, "Not an event listener!");
       return false;
     }
 
-    nsresult rv = NS_OK;
+    ErrorResult rv;
     scope->SetEventListener(NS_ConvertASCIItoUTF16(name + 2),
                             JSVAL_TO_OBJECT(*aVp), rv);
-    if (NS_FAILED(rv)) {
+    if (rv.Failed()) {
       JS_ReportError(aCx, "Failed to set event listener!");
       return false;
     }
 
     return true;
   }
 
   static WorkerGlobalScope*
@@ -336,22 +336,22 @@ private:
   GetOnErrorListener(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
   {
     const char* name = sEventStrings[STRING_onerror];
     WorkerGlobalScope* scope = GetInstancePrivate(aCx, aObj, name);
     if (!scope) {
       return false;
     }
 
-    nsresult rv = NS_OK;
+    ErrorResult rv;
 
     JSObject* adaptor =
       scope->GetEventListener(NS_ConvertASCIItoUTF16(name + 2), rv);
 
-    if (NS_FAILED(rv)) {
+    if (rv.Failed()) {
       JS_ReportError(aCx, "Failed to get event listener!");
       return false;
     }
 
     if (!adaptor) {
       *aVp = JSVAL_NULL;
       return true;
     }
@@ -389,21 +389,21 @@ private:
     if (!listener) {
       return false;
     }
 
     js::SetFunctionNativeReserved(listener, SLOT_wrappedScope,
                                   OBJECT_TO_JSVAL(aObj));
     js::SetFunctionNativeReserved(listener, SLOT_wrappedFunction, *aVp);
 
-    nsresult rv = NS_OK;
+    ErrorResult rv;
 
     scope->SetEventListener(NS_ConvertASCIItoUTF16(name + 2), listener, rv);
 
-    if (NS_FAILED(rv)) {
+    if (rv.Failed()) {
       JS_ReportError(aCx, "Failed to set event listener!");
       return false;
     }
 
     return true;
   }
 
   static JSBool
@@ -740,22 +740,22 @@ private:
     JS_ASSERT(JSID_TO_INT(aIdval) >= 0 && JSID_TO_INT(aIdval) < STRING_COUNT);
 
     const char* name = sEventStrings[JSID_TO_INT(aIdval)];
     DedicatedWorkerGlobalScope* scope = GetInstancePrivate(aCx, aObj, name);
     if (!scope) {
       return false;
     }
 
-    nsresult rv = NS_OK;
+    ErrorResult rv;
 
     JSObject* listener =
       scope->GetEventListener(NS_ConvertASCIItoUTF16(name + 2), rv);
 
-    if (NS_FAILED(rv)) {
+    if (rv.Failed()) {
       JS_ReportError(aCx, "Failed to get event listener!");
       return false;
     }
 
     *aVp = listener ? OBJECT_TO_JSVAL(listener) : JSVAL_NULL;
     return true;
   }
 
@@ -772,22 +772,22 @@ private:
       return false;
     }
 
     if (JSVAL_IS_PRIMITIVE(*aVp)) {
       JS_ReportError(aCx, "Not an event listener!");
       return false;
     }
 
-    nsresult rv = NS_OK;
+    ErrorResult rv;
 
     scope->SetEventListener(NS_ConvertASCIItoUTF16(name + 2),
                             JSVAL_TO_OBJECT(*aVp), rv);
 
-    if (NS_FAILED(rv)) {
+    if (rv.Failed()) {
       JS_ReportError(aCx, "Failed to set event listener!");
       return false;
     }
 
     return true;
   }
 
   static DedicatedWorkerGlobalScope*
--- a/dom/workers/XMLHttpRequest.cpp
+++ b/dom/workers/XMLHttpRequest.cpp
@@ -27,16 +27,17 @@
 #include "WorkerPrivate.h"
 #include "XMLHttpRequestUpload.h"
 
 #include "DOMBindingInlines.h"
 
 USING_WORKERS_NAMESPACE
 
 using mozilla::dom::workers::exceptions::ThrowDOMExceptionForNSResult;
+using mozilla::ErrorResult;
 
 // XXX Need to figure this out...
 #define UNCATCHABLE_EXCEPTION NS_ERROR_OUT_OF_MEMORY
 
 /**
  *  XMLHttpRequest in workers
  *
  *  XHR in workers is implemented by proxying calls/events/etc between the
@@ -1442,25 +1443,25 @@ void
 XMLHttpRequest::_Finalize(JSFreeOp* aFop)
 {
   ReleaseProxy(XHRIsGoingAway);
   XMLHttpRequestEventTarget::_Finalize(aFop);
 }
 
 // static
 XMLHttpRequest*
-XMLHttpRequest::_Constructor(JSContext* aCx, JSObject* aGlobal, nsresult& aRv)
+XMLHttpRequest::_Constructor(JSContext* aCx, JSObject* aGlobal, ErrorResult& aRv)
 {
   WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
   MOZ_ASSERT(workerPrivate);
 
   nsRefPtr<XMLHttpRequest> xhr = new XMLHttpRequest(aCx, workerPrivate);
 
   if (!Wrap(aCx, aGlobal, xhr)) {
-    aRv = NS_ERROR_FAILURE;
+    aRv.Throw(NS_ERROR_FAILURE);
     return NULL;
   }
 
   xhr->mJSObject = xhr->GetJSObject();
   return xhr;
 }
 
 void
@@ -1496,105 +1497,106 @@ XMLHttpRequest::ReleaseProxy(ReleaseType
       if (!runnable->Dispatch(nsnull)) {
         NS_ERROR("Failed to dispatch teardown runnable!");
       }
     }
   }
 }
 
 void
-XMLHttpRequest::MaybePin(nsresult& aRv)
+XMLHttpRequest::MaybePin(ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mJSObjectRooted) {
     return;
   }
 
   JSContext* cx = GetJSContext();
 
   if (!JS_AddNamedObjectRoot(cx, &mJSObject, "XMLHttpRequest mJSObject")) {
-    aRv = NS_ERROR_FAILURE;
+    aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 
   if (!mWorkerPrivate->AddFeature(cx, this)) {
     JS_RemoveObjectRoot(cx, &mJSObject);
-    aRv = NS_ERROR_FAILURE;
+    aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 
   mJSObjectRooted = true;
 }
 
 void
-XMLHttpRequest::MaybeDispatchPrematureAbortEvents(nsresult& aRv)
+XMLHttpRequest::MaybeDispatchPrematureAbortEvents(ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
   MOZ_ASSERT(mProxy);
 
   mStateData.mReadyState = 4;
 
   if (mProxy->mSeenUploadLoadStart) {
     MOZ_ASSERT(mUpload);
 
     JSObject* target = mUpload->GetJSObject();
     MOZ_ASSERT(target);
 
     DispatchPrematureAbortEvent(target, STRING_abort, true, aRv);
-    if (NS_FAILED(aRv)) {
+    if (aRv.Failed()) {
       return;
     }
 
     DispatchPrematureAbortEvent(target, STRING_loadend, true, aRv);
-    if (NS_FAILED(aRv)) {
+    if (aRv.Failed()) {
       return;
     }
 
     mProxy->mSeenUploadLoadStart = false;
   }
 
   if (mProxy->mSeenLoadStart) {
     JSObject* target = GetJSObject();
     MOZ_ASSERT(target);
 
     DispatchPrematureAbortEvent(target, STRING_readystatechange, false, aRv);
-    if (NS_FAILED(aRv)) {
+    if (aRv.Failed()) {
       return;
     }
 
     DispatchPrematureAbortEvent(target, STRING_abort, false, aRv);
-    if (NS_FAILED(aRv)) {
+    if (aRv.Failed()) {
       return;
     }
 
     DispatchPrematureAbortEvent(target, STRING_loadend, false, aRv);
-    if (NS_FAILED(aRv)) {
+    if (aRv.Failed()) {
       return;
     }
 
     mProxy->mSeenLoadStart = false;
   }
 }
 
 void
 XMLHttpRequest::DispatchPrematureAbortEvent(JSObject* aTarget,
                                             uint8_t aEventType,
-                                            bool aUploadTarget, nsresult& aRv)
+                                            bool aUploadTarget,
+                                            ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
   MOZ_ASSERT(mProxy);
   MOZ_ASSERT(aTarget);
   MOZ_ASSERT(aEventType <= STRING_COUNT);
 
   JSContext* cx = GetJSContext();
 
   JSString* type = JS_NewStringCopyZ(cx, sEventStrings[aEventType]);
   if (!type) {
-    aRv = NS_ERROR_OUT_OF_MEMORY;
+    aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
     return;
   }
 
   JSObject* event;
   if (aEventType == STRING_readystatechange) {
     event = events::CreateGenericEvent(cx, type, false, false, false);
   }
   else if (aUploadTarget) {
@@ -1606,23 +1608,23 @@ XMLHttpRequest::DispatchPrematureAbortEv
   else {
     event = events::CreateProgressEvent(cx, type,
                                         mProxy->mLastLengthComputable,
                                         mProxy->mLastLoaded,
                                         mProxy->mLastTotal);
   }
 
   if (!event) {
-    aRv = NS_ERROR_FAILURE;
+    aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 
   bool dummy;
   if (!events::DispatchEventToTarget(cx, aTarget, event, &dummy)) {
-    aRv = NS_ERROR_FAILURE;
+    aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 }
 
 void
 XMLHttpRequest::Unpin()
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
@@ -1637,24 +1639,24 @@ XMLHttpRequest::Unpin()
 
   mJSObjectRooted = false;
 }
 
 void
 XMLHttpRequest::SendInternal(const nsAString& aStringBody,
                              JSAutoStructuredCloneBuffer& aBody,
                              nsTArray<nsCOMPtr<nsISupports> >& aClonedObjects,
-                             nsresult& aRv)
+                             ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   bool hasUploadListeners = mUpload ? mUpload->HasListeners() : false;
 
   MaybePin(aRv);
-  if (NS_FAILED(aRv)) {
+  if (aRv.Failed()) {
     return;
   }
 
   AutoUnpinXHR autoUnpin(this);
 
   PRUint32 syncQueueKey = PR_UINT32_MAX;
   if (mProxy->mIsSyncXHR) {
     syncQueueKey = mWorkerPrivate->CreateNewSyncLoop();
@@ -1674,17 +1676,17 @@ XMLHttpRequest::SendInternal(const nsASt
   autoUnpin.Clear();
 
   // The event loop was spun above, make sure we aren't canceled already.
   if (mCanceled) {
     return;
   }
 
   if (mProxy->mIsSyncXHR && !mWorkerPrivate->RunSyncLoop(cx, syncQueueKey)) {
-    aRv = NS_ERROR_FAILURE;
+    aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 }
 
 bool
 XMLHttpRequest::Notify(JSContext* aCx, Status aStatus)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
@@ -1696,476 +1698,476 @@ XMLHttpRequest::Notify(JSContext* aCx, S
   }
 
   return true;
 }
 
 void
 XMLHttpRequest::Open(const nsAString& aMethod, const nsAString& aUrl,
                      bool aAsync, const nsAString& aUser,
-                     const nsAString& aPassword, nsresult& aRv)
+                     const nsAString& aPassword, ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mCanceled) {
-    aRv = UNCATCHABLE_EXCEPTION;
+    aRv.Throw(UNCATCHABLE_EXCEPTION);
     return;
   }
 
   if (mProxy) {
     MaybeDispatchPrematureAbortEvents(aRv);
-    if (NS_FAILED(aRv)) {
+    if (aRv.Failed()) {
       return;
     }
   }
   else {
     mProxy = new Proxy(this);
   }
 
   mProxy->mOuterEventStreamId++;
 
   nsRefPtr<OpenRunnable> runnable =
     new OpenRunnable(mWorkerPrivate, mProxy, NS_ConvertUTF16toUTF8(aMethod),
                      NS_ConvertUTF16toUTF8(aUrl), aUser, aPassword, mMultipart,
                      mBackgroundRequest, mWithCredentials, mTimeout);
 
   if (!runnable->Dispatch(GetJSContext())) {
     ReleaseProxy();
-    aRv = NS_ERROR_FAILURE;
+    aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 
   mProxy->mIsSyncXHR = !aAsync;
 }
 
 void
 XMLHttpRequest::SetRequestHeader(const nsAString& aHeader,
-                                 const nsAString& aValue, nsresult& aRv)
+                                 const nsAString& aValue, ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mCanceled) {
-    aRv = UNCATCHABLE_EXCEPTION;
+    aRv.Throw(UNCATCHABLE_EXCEPTION);
     return;
   }
 
   if (!mProxy) {
-    aRv = NS_ERROR_DOM_INVALID_STATE_ERR;
+    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
 
   nsRefPtr<SetRequestHeaderRunnable> runnable =
     new SetRequestHeaderRunnable(mWorkerPrivate, mProxy,
                                  NS_ConvertUTF16toUTF8(aHeader),
                                  NS_ConvertUTF16toUTF8(aValue));
   if (!runnable->Dispatch(GetJSContext())) {
-    aRv = NS_ERROR_FAILURE;
+    aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 }
 
 void
-XMLHttpRequest::SetTimeout(uint32_t aTimeout, nsresult& aRv)
+XMLHttpRequest::SetTimeout(uint32_t aTimeout, ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mCanceled) {
-    aRv = UNCATCHABLE_EXCEPTION;
+    aRv.Throw(UNCATCHABLE_EXCEPTION);
     return;
   }
 
   mTimeout = aTimeout;
 
   if (!mProxy) {
     // Open may not have been called yet, in which case we'll handle the
     // timeout in OpenRunnable.
     return;
   }
 
   nsRefPtr<SetTimeoutRunnable> runnable =
     new SetTimeoutRunnable(mWorkerPrivate, mProxy, aTimeout);
   if (!runnable->Dispatch(GetJSContext())) {
-    aRv = NS_ERROR_FAILURE;
+    aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 }
 
 void
-XMLHttpRequest::SetWithCredentials(bool aWithCredentials, nsresult& aRv)
+XMLHttpRequest::SetWithCredentials(bool aWithCredentials, ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mCanceled) {
-    aRv = UNCATCHABLE_EXCEPTION;
+    aRv.Throw(UNCATCHABLE_EXCEPTION);
     return;
   }
 
   mWithCredentials = aWithCredentials;
 
   if (!mProxy) {
     // Open may not have been called yet, in which case we'll handle the
     // credentials in OpenRunnable.
     return;
   }
 
   nsRefPtr<SetWithCredentialsRunnable> runnable =
     new SetWithCredentialsRunnable(mWorkerPrivate, mProxy, aWithCredentials);
   if (!runnable->Dispatch(GetJSContext())) {
-    aRv = NS_ERROR_FAILURE;
+    aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 }
 
 void
-XMLHttpRequest::SetMultipart(bool aMultipart, nsresult& aRv)
+XMLHttpRequest::SetMultipart(bool aMultipart, ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mCanceled) {
-    aRv = UNCATCHABLE_EXCEPTION;
+    aRv.Throw(UNCATCHABLE_EXCEPTION);
     return;
   }
 
   mMultipart = aMultipart;
 
   if (!mProxy) {
     // Open may not have been called yet, in which case we'll handle the
     // multipart in OpenRunnable.
     return;
   }
 
   nsRefPtr<SetMultipartRunnable> runnable =
     new SetMultipartRunnable(mWorkerPrivate, mProxy, aMultipart);
   if (!runnable->Dispatch(GetJSContext())) {
-    aRv = NS_ERROR_FAILURE;
+    aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 }
 
 void
 XMLHttpRequest::SetMozBackgroundRequest(bool aBackgroundRequest,
-                                        nsresult& aRv)
+                                        ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mCanceled) {
-    aRv = UNCATCHABLE_EXCEPTION;
+    aRv.Throw(UNCATCHABLE_EXCEPTION);
     return;
   }
 
   mBackgroundRequest = aBackgroundRequest;
 
   if (!mProxy) {
     // Open may not have been called yet, in which case we'll handle the
     // background request in OpenRunnable.
     return;
   }
 
   nsRefPtr<SetBackgroundRequestRunnable> runnable =
     new SetBackgroundRequestRunnable(mWorkerPrivate, mProxy,
                                      aBackgroundRequest);
   if (!runnable->Dispatch(GetJSContext())) {
-    aRv = NS_ERROR_FAILURE;
+    aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 }
 
 XMLHttpRequestUpload*
-XMLHttpRequest::GetUpload(nsresult& aRv)
+XMLHttpRequest::GetUpload(ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mCanceled) {
-    aRv = UNCATCHABLE_EXCEPTION;
+    aRv.Throw(UNCATCHABLE_EXCEPTION);
     return NULL;
   }
 
   if (!mUpload) {
     XMLHttpRequestUpload* upload =
       XMLHttpRequestUpload::Create(GetJSContext(), this);
 
     if (!upload) {
-      aRv = NS_ERROR_FAILURE;
+      aRv.Throw(NS_ERROR_FAILURE);
       return NULL;
     }
 
     mUpload = upload;
   }
 
   return mUpload;
 }
 
 void
-XMLHttpRequest::Send(nsresult& aRv)
+XMLHttpRequest::Send(ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mCanceled) {
-    aRv = UNCATCHABLE_EXCEPTION;
+    aRv.Throw(UNCATCHABLE_EXCEPTION);
     return;
   }
 
   if (!mProxy) {
-    aRv = NS_ERROR_DOM_INVALID_STATE_ERR;
+    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
 
   // Nothing to clone.
   JSAutoStructuredCloneBuffer buffer;
   nsTArray<nsCOMPtr<nsISupports> > clonedObjects;
 
   SendInternal(NullString(), buffer, clonedObjects, aRv);
 }
 
 void
-XMLHttpRequest::Send(const nsAString& aBody, nsresult& aRv)
+XMLHttpRequest::Send(const nsAString& aBody, ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mCanceled) {
-    aRv = UNCATCHABLE_EXCEPTION;
+    aRv.Throw(UNCATCHABLE_EXCEPTION);
     return;
   }
 
   if (!mProxy) {
-    aRv = NS_ERROR_DOM_INVALID_STATE_ERR;
+    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
 
   // Nothing to clone.
   JSAutoStructuredCloneBuffer buffer;
   nsTArray<nsCOMPtr<nsISupports> > clonedObjects;
 
   SendInternal(aBody, buffer, clonedObjects, aRv);
 }
 
 void
-XMLHttpRequest::Send(JSObject* aBody, nsresult& aRv)
+XMLHttpRequest::Send(JSObject* aBody, ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
   MOZ_ASSERT(aBody);
 
   if (mCanceled) {
-    aRv = UNCATCHABLE_EXCEPTION;
+    aRv.Throw(UNCATCHABLE_EXCEPTION);
     return;
   }
 
   if (!mProxy) {
-    aRv = NS_ERROR_DOM_INVALID_STATE_ERR;
+    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
 
   JSContext* cx = GetJSContext();
 
   jsval valToClone;
   if (JS_IsArrayBufferObject(aBody, cx) || file::GetDOMBlobFromJSObject(aBody)) {
     valToClone = OBJECT_TO_JSVAL(aBody);
   }
   else {
     JSString* bodyStr = JS_ValueToString(cx, OBJECT_TO_JSVAL(aBody));
     if (!bodyStr) {
-      aRv = NS_ERROR_OUT_OF_MEMORY;
+      aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
       return;
     }
     valToClone = STRING_TO_JSVAL(bodyStr);
   }
 
   JSStructuredCloneCallbacks* callbacks =
     mWorkerPrivate->IsChromeWorker() ?
     ChromeWorkerStructuredCloneCallbacks(false) :
     WorkerStructuredCloneCallbacks(false);
 
   nsTArray<nsCOMPtr<nsISupports> > clonedObjects;
 
   JSAutoStructuredCloneBuffer buffer;
   if (!buffer.write(cx, valToClone, callbacks, &clonedObjects)) {
-    aRv = NS_ERROR_DOM_DATA_CLONE_ERR;
+    aRv.Throw(NS_ERROR_DOM_DATA_CLONE_ERR);
     return;
   }
 
   SendInternal(EmptyString(), buffer, clonedObjects, aRv);
 }
 
 void
-XMLHttpRequest::SendAsBinary(const nsAString& aBody, nsresult& aRv)
+XMLHttpRequest::SendAsBinary(const nsAString& aBody, ErrorResult& aRv)
 {
   NS_NOTYETIMPLEMENTED("Implement me!");
-  aRv = NS_ERROR_NOT_IMPLEMENTED;
+  aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
+  return;
 }
 
 void
-XMLHttpRequest::Abort(nsresult& aRv)
+XMLHttpRequest::Abort(ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mCanceled) {
-    aRv = UNCATCHABLE_EXCEPTION;
-    return;
+    aRv.Throw(UNCATCHABLE_EXCEPTION);
   }
 
   if (!mProxy) {
     return;
   }
 
   MaybeDispatchPrematureAbortEvents(aRv);
-  if (NS_FAILED(aRv)) {
+  if (aRv.Failed()) {
     return;
   }
 
   mProxy->mOuterEventStreamId++;
 
   nsRefPtr<AbortRunnable> runnable = new AbortRunnable(mWorkerPrivate, mProxy);
   if (!runnable->Dispatch(GetJSContext())) {
-    aRv = NS_ERROR_FAILURE;
+    aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 }
 
 void
 XMLHttpRequest::GetResponseHeader(const nsAString& aHeader,
-                                  nsAString& aResponseHeader, nsresult& aRv)
+                                  nsAString& aResponseHeader, ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mCanceled) {
-    aRv = UNCATCHABLE_EXCEPTION;
+    aRv.Throw(UNCATCHABLE_EXCEPTION);
     return;
   }
 
   if (!mProxy) {
-    aRv = NS_ERROR_DOM_INVALID_STATE_ERR;
+    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
 
   nsCString value;
   nsRefPtr<GetResponseHeaderRunnable> runnable =
     new GetResponseHeaderRunnable(mWorkerPrivate, mProxy,
                                   NS_ConvertUTF16toUTF8(aHeader), value);
   if (!runnable->Dispatch(GetJSContext())) {
-    aRv = NS_ERROR_FAILURE;
+    aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 
   aResponseHeader = NS_ConvertUTF8toUTF16(value);
 }
 
 void
 XMLHttpRequest::GetAllResponseHeaders(nsAString& aResponseHeaders,
-                                      nsresult& aRv)
+                                      ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mCanceled) {
-    aRv = UNCATCHABLE_EXCEPTION;
+    aRv.Throw(UNCATCHABLE_EXCEPTION);
     return;
   }
 
   if (!mProxy) {
-    aRv = NS_ERROR_DOM_INVALID_STATE_ERR;
+    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
 
   nsString responseHeaders;
   nsRefPtr<GetAllResponseHeadersRunnable> runnable =
     new GetAllResponseHeadersRunnable(mWorkerPrivate, mProxy, responseHeaders);
   if (!runnable->Dispatch(GetJSContext())) {
-    aRv = NS_ERROR_FAILURE;
+    aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 
   aResponseHeaders = responseHeaders;
 }
 
 void
-XMLHttpRequest::OverrideMimeType(const nsAString& aMimeType, nsresult& aRv)
+XMLHttpRequest::OverrideMimeType(const nsAString& aMimeType, ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mCanceled) {
-    aRv = UNCATCHABLE_EXCEPTION;
+    aRv.Throw(UNCATCHABLE_EXCEPTION);
     return;
   }
 
   // We're supposed to throw if the state is not OPENED or HEADERS_RECEIVED. We
   // can detect OPENED really easily but we can't detect HEADERS_RECEIVED in a
   // non-racy way until the XHR state machine actually runs on this thread
   // (bug 671047). For now we're going to let this work only if the Send()
   // method has not been called.
   if (!mProxy || SendInProgress()) {
-    aRv = NS_ERROR_DOM_INVALID_STATE_ERR;
+    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
 
   nsRefPtr<OverrideMimeTypeRunnable> runnable =
     new OverrideMimeTypeRunnable(mWorkerPrivate, mProxy, aMimeType);
   if (!runnable->Dispatch(GetJSContext())) {
-    aRv = NS_ERROR_FAILURE;
+    aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 }
 
 void
 XMLHttpRequest::SetResponseType(XMLHttpRequestResponseType aResponseType,
-                                nsresult& aRv)
+                                ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mCanceled) {
-    aRv = UNCATCHABLE_EXCEPTION;
+    aRv.Throw(UNCATCHABLE_EXCEPTION);
     return;
   }
 
   if (!mProxy || SendInProgress()) {
-    aRv = NS_ERROR_DOM_INVALID_STATE_ERR;
+    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
 
   // "document" is fine for the main thread but not for a worker. Short-circuit
   // that here.
   if (aResponseType == XMLHttpRequestResponseTypeValues::document) {
     return;
   }
 
   nsString responseType;
   ConvertResponseTypeToString(aResponseType, responseType);
 
   nsRefPtr<SetResponseTypeRunnable> runnable =
     new SetResponseTypeRunnable(mWorkerPrivate, mProxy, responseType);
   if (!runnable->Dispatch(GetJSContext())) {
-    aRv = NS_ERROR_FAILURE;
+    aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 
   nsString acceptedResponseTypeString;
   runnable->GetResponseType(acceptedResponseTypeString);
 
   mResponseType = ConvertStringToResponseType(acceptedResponseTypeString);
 }
 
 jsval
-XMLHttpRequest::GetResponse(nsresult& aRv)
+XMLHttpRequest::GetResponse(ErrorResult& aRv)
 {
   if (NS_SUCCEEDED(mStateData.mResponseTextResult) &&
       JSVAL_IS_VOID(mStateData.mResponse)) {
     MOZ_ASSERT(mStateData.mResponseText.Length());
     MOZ_ASSERT(NS_SUCCEEDED(mStateData.mResponseResult));
 
     JSString* str =
       JS_NewUCStringCopyN(GetJSContext(), mStateData.mResponseText.get(),
                           mStateData.mResponseText.Length());
     if (!str) {
-      aRv = NS_ERROR_OUT_OF_MEMORY;
+      aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
       return JSVAL_VOID;
     }
 
     mStateData.mResponse = STRING_TO_JSVAL(str);
   }
 
   aRv = mStateData.mResponseResult;
   return mStateData.mResponse;
 }
 
 void
-XMLHttpRequest::GetResponseText(nsAString& aResponseText, nsresult& aRv)
+XMLHttpRequest::GetResponseText(nsAString& aResponseText, ErrorResult& aRv)
 {
   aRv = mStateData.mResponseTextResult;
   aResponseText = mStateData.mResponseText;
 }
--- a/dom/workers/XMLHttpRequest.h
+++ b/dom/workers/XMLHttpRequest.h
@@ -63,163 +63,163 @@ protected:
 public:
   virtual void
   _Trace(JSTracer* aTrc) MOZ_OVERRIDE;
 
   virtual void
   _Finalize(JSFreeOp* aFop) MOZ_OVERRIDE;
 
   static XMLHttpRequest*
-  _Constructor(JSContext* aCx, JSObject* aGlobal, nsresult& aRv);
+  _Constructor(JSContext* aCx, JSObject* aGlobal, ErrorResult& aRv);
 
   void
   Unpin();
 
   bool
   Notify(JSContext* aCx, Status aStatus) MOZ_OVERRIDE;
 
 #define IMPL_GETTER_AND_SETTER(_type)                                          \
   JSObject*                                                                    \
-  GetOn##_type(nsresult& aRv)                                                  \
+  GetOn##_type(ErrorResult& aRv)                                               \
   {                                                                            \
     return GetEventListener(NS_LITERAL_STRING(#_type), aRv);                   \
   }                                                                            \
                                                                                \
   void                                                                         \
-  SetOn##_type(JSObject* aListener, nsresult& aRv)                             \
+  SetOn##_type(JSObject* aListener, ErrorResult& aRv)                          \
   {                                                                            \
     SetEventListener(NS_LITERAL_STRING(#_type), aListener, aRv);               \
   }
 
   IMPL_GETTER_AND_SETTER(readystatechange)
 
 #undef IMPL_GETTER_AND_SETTER
 
   uint16_t
   GetReadyState() const
   {
     return mStateData.mReadyState;
   }
 
   void
   Open(const nsAString& aMethod, const nsAString& aUrl, bool aAsync,
-       const nsAString& aUser, const nsAString& aPassword, nsresult& aRv);
+       const nsAString& aUser, const nsAString& aPassword, ErrorResult& aRv);
 
   void
   SetRequestHeader(const nsAString& aHeader, const nsAString& aValue,
-                   nsresult& aRv);
+                   ErrorResult& aRv);
 
   uint32_t
-  GetTimeout(nsresult& aRv) const
+  GetTimeout() const
   {
     return mTimeout;
   }
 
   void
-  SetTimeout(uint32_t aTimeout, nsresult& aRv);
+  SetTimeout(uint32_t aTimeout, ErrorResult& aRv);
 
   bool
-  GetWithCredentials(nsresult& aRv) const
+  GetWithCredentials() const
   {
     return mWithCredentials;
   }
 
   void
-  SetWithCredentials(bool aWithCredentials, nsresult& aRv);
+  SetWithCredentials(bool aWithCredentials, ErrorResult& aRv);
 
   bool
-  GetMultipart(nsresult& aRv) const
+  GetMultipart() const
   {
     return mMultipart;
   }
 
   void
-  SetMultipart(bool aMultipart, nsresult& aRv);
+  SetMultipart(bool aMultipart, ErrorResult& aRv);
 
   bool
-  GetMozBackgroundRequest(nsresult& aRv) const
+  GetMozBackgroundRequest() const
   {
     return mBackgroundRequest;
   }
 
   void
-  SetMozBackgroundRequest(bool aBackgroundRequest, nsresult& aRv);
+  SetMozBackgroundRequest(bool aBackgroundRequest, ErrorResult& aRv);
 
   XMLHttpRequestUpload*
-  GetUpload(nsresult& aRv);
+  GetUpload(ErrorResult& aRv);
 
   void
-  Send(nsresult& aRv);
+  Send(ErrorResult& aRv);
 
   void
-  Send(const nsAString& aBody, nsresult& aRv);
+  Send(const nsAString& aBody, ErrorResult& aRv);
 
   void
-  Send(JSObject* aBody, nsresult& aRv);
+  Send(JSObject* aBody, ErrorResult& aRv);
 
   void
-  SendAsBinary(const nsAString& aBody, nsresult& aRv);
+  SendAsBinary(const nsAString& aBody, ErrorResult& aRv);
 
   void
-  Abort(nsresult& aRv);
+  Abort(ErrorResult& aRv);
 
   uint16_t
-  GetStatus(nsresult& aRv) const
+  GetStatus(ErrorResult& aRv) const
   {
     aRv = mStateData.mStatusResult;
     return mStateData.mStatus;
   }
 
   void
   GetStatusText(nsAString& aStatusText) const
   {
     aStatusText = mStateData.mStatusText;
   }
 
   void
   GetResponseHeader(const nsAString& aHeader, nsAString& aResponseHeader,
-                    nsresult& aRv);
+                    ErrorResult& aRv);
 
   void
-  GetAllResponseHeaders(nsAString& aResponseHeaders, nsresult& aRv);
+  GetAllResponseHeaders(nsAString& aResponseHeaders, ErrorResult& aRv);
 
   void
-  OverrideMimeType(const nsAString& aMimeType, nsresult& aRv);
+  OverrideMimeType(const nsAString& aMimeType, ErrorResult& aRv);
 
   XMLHttpRequestResponseType
-  GetResponseType(nsresult& aRv) const
+  GetResponseType() const
   {
     return mResponseType;
   }
 
   void
-  SetResponseType(XMLHttpRequestResponseType aResponseType, nsresult& aRv);
+  SetResponseType(XMLHttpRequestResponseType aResponseType, ErrorResult& aRv);
 
   jsval
-  GetResponse(nsresult& aRv);
+  GetResponse(ErrorResult& aRv);
 
   void
-  GetResponseText(nsAString& aResponseText, nsresult& aRv);
+  GetResponseText(nsAString& aResponseText, ErrorResult& aRv);
 
   JSObject*
-  GetResponseXML(nsresult& aRv) const
+  GetResponseXML() const
   {
     return NULL;
   }
 
   JSObject*
-  GetChannel(nsresult& aRv) const
+  GetChannel() const
   {
     return NULL;
   }
 
   JS::Value
-  GetInterface(JSObject* aIID, nsresult& aRv)
+  GetInterface(JSObject* aIID, ErrorResult& aRv)
   {
-    aRv = NS_ERROR_FAILURE;
+    aRv.Throw(NS_ERROR_FAILURE);
     return JSVAL_NULL;
   }
 
   XMLHttpRequestUpload*
   GetUploadObjectNoCreate() const
   {
     return mUpload;
   }
@@ -239,33 +239,33 @@ public:
 
 private:
   enum ReleaseType { Default, XHRIsGoingAway, WorkerIsGoingAway };
 
   void
   ReleaseProxy(ReleaseType aType = Default);
 
   void
-  MaybePin(nsresult& aRv);
+  MaybePin(ErrorResult& aRv);
 
   void
-  MaybeDispatchPrematureAbortEvents(nsresult& aRv);
+  MaybeDispatchPrematureAbortEvents(ErrorResult& aRv);
 
   void
   DispatchPrematureAbortEvent(JSObject* aTarget, uint8_t aEventType,
-                              bool aUploadTarget, nsresult& aRv);
+                              bool aUploadTarget, ErrorResult& aRv);
 
   bool
   SendInProgress() const
   {
     return mJSObjectRooted;
   }
 
   void
   SendInternal(const nsAString& aStringBody,
                JSAutoStructuredCloneBuffer& aBody,
                nsTArray<nsCOMPtr<nsISupports> >& aClonedObjects,
-               nsresult& aRv);
+               ErrorResult& aRv);
 };
 
 END_WORKERS_NAMESPACE
 
 #endif // mozilla_dom_workers_xmlhttprequest_h__
--- a/dom/workers/XMLHttpRequestEventTarget.h
+++ b/dom/workers/XMLHttpRequestEventTarget.h
@@ -24,23 +24,23 @@ public:
   virtual void
   _Trace(JSTracer* aTrc) MOZ_OVERRIDE;
 
   virtual void
   _Finalize(JSFreeOp* aFop) MOZ_OVERRIDE;
 
 #define IMPL_GETTER_AND_SETTER(_type)                                          \
   JSObject*                                                                    \
-  GetOn##_type(nsresult& aRv)                                                  \
+  GetOn##_type(ErrorResult& aRv)                                               \
   {                                                                            \
     return GetEventListener(NS_LITERAL_STRING(#_type), aRv);                   \
   }                                                                            \
                                                                                \
   void                                                                         \
-  SetOn##_type(JSObject* aListener, nsresult& aRv)                             \
+  SetOn##_type(JSObject* aListener, ErrorResult& aRv)                          \
   {                                                                            \
     SetEventListener(NS_LITERAL_STRING(#_type), aListener, aRv);               \
   }
 
   IMPL_GETTER_AND_SETTER(loadstart)
   IMPL_GETTER_AND_SETTER(progress)
   IMPL_GETTER_AND_SETTER(abort)
   IMPL_GETTER_AND_SETTER(error)
--- a/gfx/ycbcr/yuv_row_arm.s
+++ b/gfx/ycbcr/yuv_row_arm.s
@@ -325,8 +325,12 @@ s42xbily_neon_tail:
     VST1.16     {D22[2]},[r0,:16],r14
     VST1.16     {D22[1]},[r0,:16],r14
     VST1.16     {D22[0]},[r0,:16]
 s42xbily_neon_done:
     VPOP        {Q4-Q7}                @ 16 words.
     LDMFD       r13!,{r4-r9,PC}        @ 8 words.
     .fnend
     .size ScaleYCbCr42xToRGB565_BilinearY_Row_NEON, .-ScaleYCbCr42xToRGB565_BilinearY_Row_NEON
+
+#if defined(__ELF__)&&defined(__linux__)
+    .section .note.GNU-stack,"",%progbits
+#endif
--- a/js/src/jsfriendapi.cpp
+++ b/js/src/jsfriendapi.cpp
@@ -238,29 +238,16 @@ JS_DefineFunctionsWithHelp(JSContext *cx
             if (!DefineHelpProperty(cx, fun, "help", fs->help))
                 return false;
         }
     }
 
     return true;
 }
 
-AutoPreserveCompartment::AutoPreserveCompartment(JSContext *cx
-                                                 JS_GUARD_OBJECT_NOTIFIER_PARAM_NO_INIT)
-  : cx(cx), oldCompartment(cx->compartment)
-{
-    JS_GUARD_OBJECT_NOTIFIER_INIT;
-}
-
-AutoPreserveCompartment::~AutoPreserveCompartment()
-{
-    /* The old compartment may have been destroyed, so we can't use cx->setCompartment. */
-    cx->compartment = oldCompartment;
-}
-
 AutoSwitchCompartment::AutoSwitchCompartment(JSContext *cx, JSCompartment *newCompartment
                                              JS_GUARD_OBJECT_NOTIFIER_PARAM_NO_INIT)
   : cx(cx), oldCompartment(cx->compartment)
 {
     JS_GUARD_OBJECT_NOTIFIER_INIT;
     cx->setCompartment(newCompartment);
 }
 
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -222,26 +222,16 @@ typedef bool
   * DEBUG-only method to dump the complete object graph of heap-allocated things.
   * fp is the file for the dump output.
   */
 extern JS_FRIEND_API(void)
 DumpHeapComplete(JSRuntime *rt, FILE *fp);
 
 #endif
 
-class JS_FRIEND_API(AutoPreserveCompartment) {
-  private:
-    JSContext *cx;
-    JSCompartment *oldCompartment;
-  public:
-    AutoPreserveCompartment(JSContext *cx JS_GUARD_OBJECT_NOTIFIER_PARAM);
-    ~AutoPreserveCompartment();
-    JS_DECL_USE_GUARD_OBJECT_NOTIFIER
-};
-
 class JS_FRIEND_API(AutoSwitchCompartment) {
   private:
     JSContext *cx;
     JSCompartment *oldCompartment;
   public:
     AutoSwitchCompartment(JSContext *cx, JSCompartment *newCompartment
                           JS_GUARD_OBJECT_NOTIFIER_PARAM);
     AutoSwitchCompartment(JSContext *cx, JSObject *target JS_GUARD_OBJECT_NOTIFIER_PARAM);
--- a/js/xpconnect/loader/mozJSComponentLoader.cpp
+++ b/js/xpconnect/loader/mozJSComponentLoader.cpp
@@ -652,19 +652,16 @@ mozJSComponentLoader::GlobalForLocation(
                                         jsval *exception)
 {
     nsresult rv;
 
     JSCLContextHelper cx(this);
 
     JS_AbortIfWrongThread(JS_GetRuntime(cx));
 
-    // preserve caller's compartment
-    js::AutoPreserveCompartment pc(cx);
-
     nsCOMPtr<nsIXPCScriptable> backstagePass;
     rv = mRuntimeService->GetBackstagePass(getter_AddRefs(backstagePass));
     NS_ENSURE_SUCCESS(rv, rv);
 
     JSCLAutoErrorReporterSetter aers(cx, mozJSLoaderErrorReporter);
 
     nsCOMPtr<nsIXPConnect> xpc =
         do_GetService(kXPConnectServiceContractID, &rv);
--- a/media/libtheora/lib/Makefile.in
+++ b/media/libtheora/lib/Makefile.in
@@ -128,17 +128,16 @@ ifeq ($(OS_TARGET),Android)
 DEFINES += -D__linux__
 endif
 
 THEORA_ASFILES  = \
   armbits.s \
   armfrag.s \
   armidct.s \
   armloop.s \
-  armopts.s \
   $(NULL)
 
 ASFILES = $(patsubst %.s,%-gnu.$(ASM_SUFFIX),$(THEORA_ASFILES))
 
 # These flags are a lie; they're just used to enable the requisite
 # opcodes; actual arch detection is done at runtime.
 ASFLAGS = -march=armv7-a -mfpu=neon
 
--- a/mobile/android/base/AndroidManifest.xml.in
+++ b/mobile/android/base/AndroidManifest.xml.in
@@ -13,17 +13,16 @@
               android:targetSdkVersion="14"/>
 
 #include ../sync/manifests/SyncAndroidManifest_permissions.xml.in
 
     <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
     <uses-permission android:name="android.permission.INTERNET"/>
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
-    <uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION"/>
     <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
 
     <uses-permission android:name="android.permission.WAKE_LOCK"/>
     <uses-permission android:name="android.permission.VIBRATE"/>
     <uses-permission android:name="@ANDROID_PACKAGE_NAME@.permissions.PASSWORD_PROVIDER"/>
 
 #ifdef MOZ_WEBSMS_BACKEND
     <!-- WebSMS -->
--- a/mobile/android/base/BrowserToolbar.java
+++ b/mobile/android/base/BrowserToolbar.java
@@ -185,17 +185,19 @@ public class BrowserToolbar {
             }
         });
 
         mProgressSpinner = (AnimationDrawable) resources.getDrawable(R.drawable.progress_spinner);
         
         mStop = (ImageButton) mLayout.findViewById(R.id.stop);
         mStop.setOnClickListener(new Button.OnClickListener() {
             public void onClick(View v) {
-                doStop();
+                Tab tab = Tabs.getInstance().getSelectedTab();
+                if (tab != null)
+                    tab.doStop();
             }
         });
 
         mShadow = (ImageView) mLayout.findViewById(R.id.shadow);
 
         mHandler = new Handler();
         mSlideUpIn = new TranslateAnimation(0, 0, 40, 0);
         mSlideUpOut = new TranslateAnimation(0, 0, 0, -40);
@@ -216,20 +218,16 @@ public class BrowserToolbar {
     private void addTab() {
         GeckoApp.mAppContext.addTab();
     }
 
     private void showTabs() {
         GeckoApp.mAppContext.showTabs();
     }
 
-    private void doStop() {
-        GeckoApp.mAppContext.doStop();
-    }
-
     public int getHighlightColor() {
         return mColor;
     }
 
     public void updateTabCountAndAnimate(int count) {
         if (mCount > count) {
             mTabsCount.setInAnimation(mSlideDownIn);
             mTabsCount.setOutAnimation(mSlideDownOut);
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -504,20 +504,24 @@ abstract public class GeckoApp
                     if (url == null)
                         return false;
 
                     GeckoAppShell.openUriExternal(url, "text/plain", "", "",
                                                   Intent.ACTION_SEND, tab.getTitle());
                 }
                 return true;
             case R.id.reload:
-                doReload();
+                tab = Tabs.getInstance().getSelectedTab();
+                if (tab != null)
+                    tab.doReload();
                 return true;
             case R.id.forward:
-                doForward();
+                tab = Tabs.getInstance().getSelectedTab();
+                if (tab != null)
+                    tab.doForward();
                 return true;
             case R.id.save_as_pdf:
                 GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("SaveAs:PDF", null));
                 return true;
             case R.id.settings:
                 intent = new Intent(this, GeckoPreferences.class);
                 startActivity(intent);
                 return true;
@@ -951,23 +955,16 @@ abstract public class GeckoApp
             } else if (event.equals("DOMFullScreen:Start")) {
                 mDOMFullScreen = true;
             } else if (event.equals("DOMFullScreen:Stop")) {
                 mDOMFullScreen = false;
             } else if (event.equals("Permissions:Data")) {
                 String host = message.getString("host");
                 JSONArray permissions = message.getJSONArray("permissions");
                 showSiteSettingsDialog(host, permissions);
-            } else if (event.equals("Downloads:Done")) {
-                String displayName = message.getString("displayName");
-                String path = message.getString("path");
-                String mimeType = message.getString("mimeType");
-                int size = message.getInt("size");
-
-                handleDownloadDone(displayName, path, mimeType, size);
             } else if (event.equals("CharEncoding:Data")) {
                 final JSONArray charsets = message.getJSONArray("charsets");
                 int selected = message.getInt("selected");
 
                 final int len = charsets.length();
                 final String[] titleArray = new String[len];
                 for (int i = 0; i < len; i++) {
                     JSONObject charset = charsets.getJSONObject(i);
@@ -1323,27 +1320,16 @@ abstract public class GeckoApp
     }
 
     void handleWindowClose(final int tabId) {
         Tabs tabs = Tabs.getInstance();
         Tab tab = tabs.getTab(tabId);
         tabs.closeTab(tab);
     }
 
-    void handleDownloadDone(String displayName, String path, String mimeType, int size) {
-        // DownloadManager.addCompletedDownload is supported in level 12 and higher
-        if (Build.VERSION.SDK_INT >= 12) {
-            DownloadManager dm = (DownloadManager) mAppContext.getSystemService(Context.DOWNLOAD_SERVICE);
-            dm.addCompletedDownload(displayName, displayName,
-                false /* do not use media scanner */,
-                mimeType, path, size,
-                false /* no notification */);
-        }
-    }
-
     void addPluginView(final View view, final Rect rect) {
         mMainHandler.post(new Runnable() { 
             public void run() {
                 Tabs tabs = Tabs.getInstance();
                 Tab tab = tabs.getSelectedTab();
 
                 PluginLayer layer = (PluginLayer) tab.getPluginLayer(view);
                 if (layer == null) {
@@ -1696,17 +1682,16 @@ abstract public class GeckoApp
         GeckoAppShell.registerGeckoEventListener("Gecko:Ready", GeckoApp.mAppContext);
         GeckoAppShell.registerGeckoEventListener("Toast:Show", GeckoApp.mAppContext);
         GeckoAppShell.registerGeckoEventListener("DOMFullScreen:Start", GeckoApp.mAppContext);
         GeckoAppShell.registerGeckoEventListener("DOMFullScreen:Stop", GeckoApp.mAppContext);
         GeckoAppShell.registerGeckoEventListener("ToggleChrome:Hide", GeckoApp.mAppContext);
         GeckoAppShell.registerGeckoEventListener("ToggleChrome:Show", GeckoApp.mAppContext);
         GeckoAppShell.registerGeckoEventListener("ToggleChrome:Focus", GeckoApp.mAppContext);
         GeckoAppShell.registerGeckoEventListener("Permissions:Data", GeckoApp.mAppContext);
-        GeckoAppShell.registerGeckoEventListener("Downloads:Done", GeckoApp.mAppContext);
         GeckoAppShell.registerGeckoEventListener("CharEncoding:Data", GeckoApp.mAppContext);
         GeckoAppShell.registerGeckoEventListener("CharEncoding:State", GeckoApp.mAppContext);
         GeckoAppShell.registerGeckoEventListener("Update:Restart", GeckoApp.mAppContext);
         GeckoAppShell.registerGeckoEventListener("Tab:HasTouchListener", GeckoApp.mAppContext);
         GeckoAppShell.registerGeckoEventListener("Session:StatePurged", GeckoApp.mAppContext);
         GeckoAppShell.registerGeckoEventListener("Bookmark:Insert", GeckoApp.mAppContext);
         GeckoAppShell.registerGeckoEventListener("Accessibility:Event", GeckoApp.mAppContext);
 
@@ -2044,17 +2029,16 @@ abstract public class GeckoApp
         GeckoAppShell.unregisterGeckoEventListener("Menu:Add", GeckoApp.mAppContext);
         GeckoAppShell.unregisterGeckoEventListener("Menu:Remove", GeckoApp.mAppContext);
         GeckoAppShell.unregisterGeckoEventListener("Gecko:Ready", GeckoApp.mAppContext);
         GeckoAppShell.unregisterGeckoEventListener("Toast:Show", GeckoApp.mAppContext);
         GeckoAppShell.unregisterGeckoEventListener("ToggleChrome:Hide", GeckoApp.mAppContext);
         GeckoAppShell.unregisterGeckoEventListener("ToggleChrome:Show", GeckoApp.mAppContext);
         GeckoAppShell.unregisterGeckoEventListener("ToggleChrome:Focus", GeckoApp.mAppContext);
         GeckoAppShell.unregisterGeckoEventListener("Permissions:Data", GeckoApp.mAppContext);
-        GeckoAppShell.unregisterGeckoEventListener("Downloads:Done", GeckoApp.mAppContext);
         GeckoAppShell.unregisterGeckoEventListener("CharEncoding:Data", GeckoApp.mAppContext);
         GeckoAppShell.unregisterGeckoEventListener("CharEncoding:State", GeckoApp.mAppContext);
         GeckoAppShell.unregisterGeckoEventListener("Tab:HasTouchListener", GeckoApp.mAppContext);
         GeckoAppShell.unregisterGeckoEventListener("Session:StatePurged", GeckoApp.mAppContext);
         GeckoAppShell.unregisterGeckoEventListener("Bookmark:Insert", GeckoApp.mAppContext);
 
         if (mFavicons != null)
             mFavicons.close();
@@ -2528,43 +2512,16 @@ abstract public class GeckoApp
                     intent.putExtra(AwesomeBar.CURRENT_URL_KEY, url);
                 }
             }
         }
         startActivityForResult(intent, mActivityResultHandlerMap.put(mAwesomebarResultHandler));
         return true;
     }
 
-    public boolean doReload() {
-        Log.i(LOGTAG, "Reload requested");
-        Tab tab = Tabs.getInstance().getSelectedTab();
-        if (tab == null)
-            return false;
-
-        return tab.doReload();
-    }
-
-    public boolean doForward() {
-        Log.i(LOGTAG, "Forward requested");
-        Tab tab = Tabs.getInstance().getSelectedTab();
-        if (tab == null)
-            return false;
-
-        return tab.doForward();
-    }
-
-    public boolean doStop() {
-        Log.i(LOGTAG, "Stop requested");
-        Tab tab = Tabs.getInstance().getSelectedTab();
-        if (tab == null)
-            return false;
-
-        return tab.doStop();
-    }
-
     @Override
     public void onBackPressed() {
         if (mDoorHangerPopup.isShowing()) {
             mDoorHangerPopup.dismiss();
             return;
         }
 
         if (mSiteIdentityPopup.isShowing()) {
--- a/mobile/android/chrome/content/downloads.js
+++ b/mobile/android/chrome/content/downloads.js
@@ -134,31 +134,16 @@ var Downloads = {
           this._dlmgr = Cc["@mozilla.org/download-manager;1"].getService(Ci.nsIDownloadManager);
         this._progressAlert = new AlertDownloadProgressListener();
         this._dlmgr.addListener(this._progressAlert);
       }
 
       NativeWindow.toast.show(Strings.browser.GetStringFromName("alertDownloadsToast"), "long");
     } else if (aTopic == "dl-done") {
       msgKey = "alertDownloadsDone";
-
-      // In order to get the fileSize to be correct for "Save as PDF", we need
-      // let the local file be safely written before accessing it.
-      setTimeout(function() {
-        let message = {
-          gecko: {
-            type: "Downloads:Done",
-            displayName: download.displayName,
-            path: download.targetFile.path,
-            size: download.targetFile.fileSize,
-            mimeType: download.MIMEInfo ? download.MIMEInfo.type : ""
-          }
-        };
-        sendMessageToJava(message);
-      }, 0);
     }
 
     if (msgKey)
       this.showAlert(download, Strings.browser.formatStringFromName(msgKey, [download.displayName], 1));
   },
 
   QueryInterface: function (aIID) {
     if (!aIID.equals(Ci.nsIObserver) &&
--- a/mobile/android/themes/core/aboutDownloads.css
+++ b/mobile/android/themes/core/aboutDownloads.css
@@ -69,16 +69,17 @@ li:active .details {
 }
 
 .icon {
   width: 32px;
   height: 32px;
   position: absolute;
   top: 27px;
   left: 27px;
+  pointer-events: none;
 }
 
 .details {
   margin-left: 86px;
   padding: 10px;
   min-height: 66px;
   background-image: url("chrome://browser/skin/images/row-bg-light.png");
 }
--- a/widget/xpwidgets/nsBaseWidget.cpp
+++ b/widget/xpwidgets/nsBaseWidget.cpp
@@ -815,17 +815,17 @@ nsBaseWidget::GetShouldAccelerate()
   bool accelerateByDefault = false;
 # endif
 
 #else
   bool accelerateByDefault = false;
 #endif
 
   // we should use AddBoolPrefVarCache
-  bool disableAcceleration =
+  bool disableAcceleration = (mWindowType == eWindowType_popup) || 
     Preferences::GetBool("layers.acceleration.disabled", false);
   mForceLayersAcceleration =
     Preferences::GetBool("layers.acceleration.force-enabled", false);
 
   const char *acceleratedEnv = PR_GetEnv("MOZ_ACCELERATED");
   accelerateByDefault = accelerateByDefault ||
                         (acceleratedEnv && (*acceleratedEnv != '0'));