Bug 1014466 - Part 1: Only send readystatechange event when state changed. r=khuey
☠☠ backed out by 0c006b5d36c8 ☠ ☠
authorShian-Yow Wu <swu@mozilla.com>
Fri, 06 Jun 2014 12:17:53 +0800
changeset 206228 b85f5ec213926ad06398d2c59cf199f8373e16f1
parent 206227 f3d257065b3371878d0cf1b79e9800ebfc029925
child 206229 355e895f7ae9cf81a85514a25404a04ae3303be9
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs1014466
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1014466 - Part 1: Only send readystatechange event when state changed. r=khuey
dom/workers/XMLHttpRequest.cpp
--- a/dom/workers/XMLHttpRequest.cpp
+++ b/dom/workers/XMLHttpRequest.cpp
@@ -1664,17 +1664,22 @@ XMLHttpRequest::MaybePin(ErrorResult& aR
 }
 
 void
 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);
 
     DispatchPrematureAbortEvent(mUpload, NS_LITERAL_STRING("abort"), true,
                                 aRv);
     if (aRv.Failed()) {
       return;
@@ -1685,20 +1690,22 @@ XMLHttpRequest::MaybeDispatchPrematureAb
     if (aRv.Failed()) {
       return;
     }
 
     mProxy->mSeenUploadLoadStart = false;
   }
 
   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);
     if (aRv.Failed()) {
       return;
     }
 
     DispatchPrematureAbortEvent(this, NS_LITERAL_STRING("loadend"), false,