From 88b06a7c8f7bebfc684eb084c8874729ca5c9e08 Mon Sep 17 00:00:00 2001 From: Shian-Yow Wu Date: Fri, 6 Jun 2014 12:12:12 +0100 Subject: [PATCH] Bug 1014466 - Part 1: Only send readystatechange event when state changed. r=khuey --- dom/workers/XMLHttpRequest.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/dom/workers/XMLHttpRequest.cpp b/dom/workers/XMLHttpRequest.cpp index 802098ccb8f7..37a090769a21 100644 --- a/dom/workers/XMLHttpRequest.cpp +++ b/dom/workers/XMLHttpRequest.cpp @@ -1669,7 +1669,12 @@ XMLHttpRequest::MaybeDispatchPrematureAbortEvents(ErrorResult& aRv) mWorkerPrivate->AssertIsOnWorkerThread(); MOZ_ASSERT(mProxy); - mStateData.mReadyState = 4; + // Only send readystatechange event when state changed. + bool isStateChanged = false; + if (mStateData.mReadyState != 4) { + isStateChanged = true; + mStateData.mReadyState = 4; + } if (mProxy->mSeenUploadLoadStart) { MOZ_ASSERT(mUpload); @@ -1690,10 +1695,12 @@ XMLHttpRequest::MaybeDispatchPrematureAbortEvents(ErrorResult& aRv) } if (mProxy->mSeenLoadStart) { - DispatchPrematureAbortEvent(this, NS_LITERAL_STRING("readystatechange"), - false, aRv); - if (aRv.Failed()) { - return; + if (isStateChanged) { + DispatchPrematureAbortEvent(this, NS_LITERAL_STRING("readystatechange"), + false, aRv); + if (aRv.Failed()) { + return; + } } DispatchPrematureAbortEvent(this, NS_LITERAL_STRING("abort"), false, aRv);