Bug 1169867 - XMLHttpRequest::SendInternal should not unpin itself when the worker goes away. r=bent, a=2.2+
--- a/dom/workers/XMLHttpRequest.cpp
+++ b/dom/workers/XMLHttpRequest.cpp
@@ -1878,16 +1878,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;