mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-15 08:53:07 +09:00
Bug 1311798: Align XMLHttpRequest abort() with the spec
This commit is contained in:
parent
e95eff8e11
commit
5cc122a538
4 changed files with 82 additions and 6 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue