Bug 1169867 - XMLHttpRequest::SendInternal should not unpin itself when the worker goes away. r=bent, a=2.0+
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 12 Jun 2015 10:06:19 -0400
changeset 204895 d78115b1ed80ae7cb106a89fd07ecccc10767400
parent 204894 3789134b1d19292794587c3dcfa04e03783d93bb
child 204896 29e09069315c447abf61a48c8d9481f1ac2ee87e
push id822
push userryanvm@gmail.com
push dateMon, 15 Jun 2015 15:18:26 +0000
treeherdermozilla-b2g32_v2_0@d78115b1ed80 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent, 2
bugs1169867
milestone32.0
Bug 1169867 - XMLHttpRequest::SendInternal should not unpin itself when the worker goes away. r=bent, a=2.0+
dom/workers/XMLHttpRequest.cpp
--- a/dom/workers/XMLHttpRequest.cpp
+++ b/dom/workers/XMLHttpRequest.cpp
@@ -1871,16 +1871,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.empty());
     return;