Bug 1341272 - Set readyState to DONE during synchronous XMLHttpRequest failure, r=baku
authorShawn Huang <shuang@mozilla.com>
Mon, 27 Mar 2017 15:21:57 +0800
changeset 397880 8e3e5dc30f91015a3a33bdc184c06cd2e0a219d3
parent 397879 6cf486eef1c32531fcdc94e89fda6ee2cec27e9c
child 397881 9577ddeaafd85554c2a855f385a87472a089d5c0
child 398012 a65b7088f02eafaa9c244dc1a340b198f037a0e8
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1341272
milestone55.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 1341272 - Set readyState to DONE during synchronous XMLHttpRequest failure, r=baku
dom/xhr/XMLHttpRequestMainThread.cpp
testing/web-platform/meta/XMLHttpRequest/send-network-error-sync-events.sub.htm.ini
--- a/dom/xhr/XMLHttpRequestMainThread.cpp
+++ b/dom/xhr/XMLHttpRequestMainThread.cpp
@@ -2729,16 +2729,17 @@ XMLHttpRequestMainThread::InitiateFetch(
     // ref to us to be extra safe.
     mChannel->SetNotificationCallbacks(mNotificationCallbacks);
     mChannel = nullptr;
 
     mErrorLoad = true;
 
     // Per spec, we throw on sync errors, but not async.
     if (mFlagSynchronous) {
+      mState = State::done;
       return NS_ERROR_DOM_NETWORK_ERR;
     }
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
@@ -3013,16 +3014,17 @@ XMLHttpRequestMainThread::SendInternal(c
       DispatchProgressEvent(mUpload, ProgressEventType::loadstart,
                             0, mUploadTotal);
     }
   }
 
   if (!mChannel) {
     // Per spec, silently fail on async request failures; throw for sync.
     if (mFlagSynchronous) {
+      mState = State::done;
       return NS_ERROR_DOM_NETWORK_ERR;
     } else {
       // Defer the actual sending of async events just in case listeners
       // are attached after the send() method is called.
       NS_DispatchToCurrentThread(
         NewRunnableMethod<ProgressEventType>(this,
           &XMLHttpRequestMainThread::CloseRequestWithError,
           ProgressEventType::error));
deleted file mode 100644
--- a/testing/web-platform/meta/XMLHttpRequest/send-network-error-sync-events.sub.htm.ini
+++ /dev/null
@@ -1,8 +0,0 @@
-[send-network-error-sync-events.sub.htm]
-  type: testharness
-  [XmlHttpRequest: The send() method: Throw a "throw an "NetworkError" exception when Network error happens (synchronous flag is set)]
-    expected: FAIL
-
-  [XMLHttpRequest: The send() method: Throw a "throw an "NetworkError" exception when Network error happens (synchronous flag is set)]
-    expected: FAIL
-