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 266250 aaf1311249a8
parent 266249 7898db26f3f8
child 266251 81f2a1546715
push id4800
push userryanvm@gmail.com
push date2015-06-12 15:43 +0000
treeherdermozilla-beta@aaf1311249a8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent, abillings
bugs1169867
milestone39.0
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
@@ -1876,16 +1876,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;