diff options
Diffstat (limited to 'dom/xhr/XMLHttpRequestWorker.cpp')
-rw-r--r-- | dom/xhr/XMLHttpRequestWorker.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/dom/xhr/XMLHttpRequestWorker.cpp b/dom/xhr/XMLHttpRequestWorker.cpp index f61383baf..e7193a279 100644 --- a/dom/xhr/XMLHttpRequestWorker.cpp +++ b/dom/xhr/XMLHttpRequestWorker.cpp @@ -1148,8 +1148,8 @@ EventRunnable::PreDispatch(WorkerPrivate* /* unused */) } else { bool doClone = true; JS::Rooted<JS::Value> transferable(cx); - JS::Rooted<JSObject*> obj(cx, response.isObjectOrNull() ? - response.toObjectOrNull() : nullptr); + JS::Rooted<JSObject*> obj(cx, response.isObject() ? + &response.toObject() : nullptr); if (obj && JS_IsArrayBufferObject(obj)) { // Use cached response if the arraybuffer has been transfered. if (mProxy->mArrayBufferResponseWasTransferred) { @@ -1669,7 +1669,9 @@ XMLHttpRequestWorker::MaybeDispatchPrematureAbortEvents(ErrorResult& aRv) // Only send readystatechange event when state changed. bool isStateChanged = false; - if (mStateData.mReadyState != 4) { + if ((mStateData.mReadyState == 1 && mStateData.mFlagSend) || + mStateData.mReadyState == 2 || + mStateData.mReadyState == 3) { isStateChanged = true; mStateData.mReadyState = 4; } @@ -1811,6 +1813,8 @@ XMLHttpRequestWorker::SendInternal(SendRunnable* aRunnable, aRunnable->SetSyncLoopTarget(syncLoopTarget); aRunnable->SetHaveUploadListeners(hasUploadListeners); + mStateData.mFlagSend = true; + aRunnable->Dispatch(aRv); if (aRv.Failed()) { // Dispatch() may have spun the event loop and we may have already unrooted. @@ -1837,6 +1841,7 @@ XMLHttpRequestWorker::SendInternal(SendRunnable* aRunnable, if (!autoSyncLoop->Run() && !aRv.Failed()) { aRv.Throw(NS_ERROR_FAILURE); } + mStateData.mFlagSend = false; } bool |