summaryrefslogtreecommitdiffstats
path: root/dom/xhr/XMLHttpRequestMainThread.cpp
diff options
context:
space:
mode:
authorNew Tobin Paradigm <email@mattatobin.com>2018-04-14 03:19:49 -0400
committerGitHub <noreply@github.com>2018-04-14 03:19:49 -0400
commitc73c73b7978d7fc12e0dc07bb7c8f3babd497b8c (patch)
tree83a7c01fdc30d17a884c5c482bec51e60390c9e4 /dom/xhr/XMLHttpRequestMainThread.cpp
parent63d482639cef4e5df364d707a21660c36b576f7b (diff)
parentee15761a5073435d10aba49b3a11245e8331635d (diff)
downloadUXP-c73c73b7978d7fc12e0dc07bb7c8f3babd497b8c.tar
UXP-c73c73b7978d7fc12e0dc07bb7c8f3babd497b8c.tar.gz
UXP-c73c73b7978d7fc12e0dc07bb7c8f3babd497b8c.tar.lz
UXP-c73c73b7978d7fc12e0dc07bb7c8f3babd497b8c.tar.xz
UXP-c73c73b7978d7fc12e0dc07bb7c8f3babd497b8c.zip
Merge pull request #131 from janekptacijarabaci/js_dom_xmlhttprequest_abort_1
Aligned XMLHttpRequest abort() with the spec
Diffstat (limited to 'dom/xhr/XMLHttpRequestMainThread.cpp')
-rw-r--r--dom/xhr/XMLHttpRequestMainThread.cpp69
1 files changed, 67 insertions, 2 deletions
diff --git a/dom/xhr/XMLHttpRequestMainThread.cpp b/dom/xhr/XMLHttpRequestMainThread.cpp
index a47a01aa0..4fd34a993 100644
--- a/dom/xhr/XMLHttpRequestMainThread.cpp
+++ b/dom/xhr/XMLHttpRequestMainThread.cpp
@@ -1081,10 +1081,75 @@ XMLHttpRequestMainThread::CloseRequestWithError(const ProgressEventType aType)
}
void
-XMLHttpRequestMainThread::Abort(ErrorResult& arv)
+XMLHttpRequestMainThread::RequestErrorSteps(const ProgressEventType aEventType,
+ const nsresult aOptionalException,
+ ErrorResult& aRv)
+{
+ // Step 1
+ mState = State::done;
+
+ StopProgressEventTimer();
+
+ // Step 2
+ mFlagSend = false;
+
+ // Step 3
+ ResetResponse();
+
+ // If we're in the destructor, don't risk dispatching an event.
+ if (mFlagDeleted) {
+ mFlagSyncLooping = false;
+ return;
+ }
+
+ // Step 4
+ if (mFlagSynchronous && NS_FAILED(aOptionalException)) {
+ aRv.Throw(aOptionalException);
+ return;
+ }
+
+ // Step 5
+ FireReadystatechangeEvent();
+
+ // Step 6
+ if (mUpload && !mUploadComplete) {
+
+ // Step 6-1
+ mUploadComplete = true;
+
+ // Step 6-2
+ if (mFlagHadUploadListenersOnSend) {
+
+ // Steps 6-3, 6-4 (loadend is fired for us)
+ DispatchProgressEvent(mUpload, aEventType, 0, -1);
+ }
+ }
+
+ // Steps 7 and 8 (loadend is fired for us)
+ DispatchProgressEvent(this, aEventType, 0, -1);
+}
+
+void
+XMLHttpRequestMainThread::Abort(ErrorResult& aRv)
{
mFlagAborted = true;
- CloseRequestWithError(ProgressEventType::abort);
+
+ // Step 1
+ CloseRequest();
+
+ // Step 2
+ if ((mState == State::opened && mFlagSend) ||
+ mState == State::headers_received ||
+ mState == State::loading) {
+ RequestErrorSteps(ProgressEventType::abort, NS_OK, aRv);
+ }
+
+ // Step 3
+ if (mState == State::done) {
+ ChangeState(State::unsent, false); // no ReadystateChange event
+ }
+
+ mFlagSyncLooping = false;
}
NS_IMETHODIMP