Bug 1169867 - XMLHttpRequest::SendInternal should not unpin itself when the worker goes away. r=bent, a=abillings
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 12 Jun 2015 10:06:19 -0400
changeset 275040 1b69a66f875651d6f44d694dbf40e2c076c404d8
parent 275039 93978bbbf4219cafe9b089cdaaed1086f5ce1b14
child 275041 3527e2751686fa3a546beac34695a1221bcd9efb
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent, abillings
bugs1169867
milestone40.0a2
Bug 1169867 - XMLHttpRequest::SendInternal should not unpin itself when the worker goes away. r=bent, a=abillings
dom/workers/XMLHttpRequest.cpp
--- a/dom/workers/XMLHttpRequest.cpp
+++ b/dom/workers/XMLHttpRequest.cpp
@@ -1877,16 +1877,21 @@ XMLHttpRequest::SendInternal(const nsASt
   mProxy->mOuterChannelId++;
 
   JSContext* cx = mWorkerPrivate->GetJSContext();
 
   nsRefPtr<SendRunnable> runnable =
     new SendRunnable(mWorkerPrivate, mProxy, aStringBody, Move(aBody),
                      aClonedObjects, syncLoopTarget, hasUploadListeners);
   if (!runnable->Dispatch(cx)) {
+    // Dispatch() may have spun the event loop and we may have already unrooted.
+    // If so we don't want autoUnpin to try again.
+    if (!mRooted) {
+      autoUnpin.Clear();
+    }
     aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 
   if (!isSyncXHR)  {
     autoUnpin.Clear();
     MOZ_ASSERT(!autoSyncLoop);
     return;