Bug 777806. r=bz a=lsblakk
authorAndrew McCreight <amccreight@mozilla.com>
Sun, 05 Aug 2012 08:41:13 -0700
changeset 100439 bc9dfaebe970457c6a715a29b2f6036186d2de2d
parent 100438 411b48cf74814afc9649db63b3e52573e5fa0e70
child 100440 078ece5918e25f7ddfd6060820a6a71fd4d5fb71
push id1233
push useramccreight@mozilla.com
push dateTue, 07 Aug 2012 00:30:59 +0000
treeherdermozilla-beta@bc9dfaebe970 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, lsblakk
bugs777806
milestone15.0
Bug 777806. r=bz a=lsblakk
content/base/src/nsXMLHttpRequest.cpp
content/base/src/nsXMLHttpRequest.h
--- a/content/base/src/nsXMLHttpRequest.cpp
+++ b/content/base/src/nsXMLHttpRequest.cpp
@@ -473,17 +473,17 @@ nsXMLHttpRequest::~nsXMLHttpRequest()
 
   NS_ABORT_IF_FALSE(!(mState & XML_HTTP_REQUEST_SYNCLOOPING), "we rather crash than hang");
   mState &= ~XML_HTTP_REQUEST_SYNCLOOPING;
 
   nsLayoutStatics::Release();
 }
 
 void
-nsXMLHttpRequest::RootResultArrayBuffer()
+nsXMLHttpRequest::RootJSResultObjects()
 {
   nsContentUtils::PreserveWrapper(
     static_cast<nsIDOMEventTarget*>(
       static_cast<nsDOMEventTargetHelper*>(this)), this);
 }
 
 /**
  * This Init method is called from the factory constructor.
@@ -954,16 +954,18 @@ nsXMLHttpRequest::GetResponseText(nsStri
 }
 
 nsresult
 nsXMLHttpRequest::CreateResponseParsedJSON(JSContext* aCx)
 {
   if (!aCx) {
     return NS_ERROR_FAILURE;
   }
+  RootJSResultObjects();
+
   // The Unicode converter has already zapped the BOM if there was one
   if (!JS_ParseJSON(aCx,
                     static_cast<const jschar*>(mResponseText.get()),
                     mResponseText.Length(), &mResultJSON)) {
     return NS_ERROR_FAILURE;
   }
 
   return NS_OK;
@@ -1175,17 +1177,17 @@ nsXMLHttpRequest::GetResponse(JSContext*
     if (!(mResponseType == XML_HTTP_RESPONSE_TYPE_ARRAYBUFFER &&
           mState & XML_HTTP_REQUEST_DONE) &&
         !(mResponseType == XML_HTTP_RESPONSE_TYPE_CHUNKED_ARRAYBUFFER &&
           mInLoadProgressEvent)) {
       return JSVAL_NULL;
     }
 
     if (!mResultArrayBuffer) {
-      RootResultArrayBuffer();
+      RootJSResultObjects();
       aRv = nsContentUtils::CreateArrayBuffer(aCx, mResponseBody,
                                               &mResultArrayBuffer);
       if (aRv.Failed()) {
         return JSVAL_NULL;
       }
     }
     return OBJECT_TO_JSVAL(mResultArrayBuffer);
   }
--- a/content/base/src/nsXMLHttpRequest.h
+++ b/content/base/src/nsXMLHttpRequest.h
@@ -503,17 +503,17 @@ public:
   // This is called by the factory constructor.
   nsresult Init();
 
   void SetRequestObserver(nsIRequestObserver* aObserver);
 
   NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_INHERITED(nsXMLHttpRequest,
                                                                    nsXHREventTarget)
   bool AllowUploadProgress();
-  void RootResultArrayBuffer();
+  void RootJSResultObjects();
 
   virtual void DisconnectFromOwner();
 protected:
   friend class nsMultipartProxyListener;
 
   nsresult DetectCharset();
   nsresult AppendToResponseText(const char * aBuffer, PRUint32 aBufferLen);
   static NS_METHOD StreamReaderFunc(nsIInputStream* in,