Bug 447689 - clean up XMLHttpRequest::Open so XHR readyState=1 events are fired according to spec. r=baku

This commit is contained in:
Thomas Wisniewski 2016-07-15 11:33:17 -04:00
Родитель 342a16f1a3
Коммит 0564cc02ae
7 изменённых файлов: 20 добавлений и 36 удалений

Просмотреть файл

@ -1004,7 +1004,7 @@ XMLHttpRequestMainThread::GetStatusText(nsACString& aStatusText,
} }
void void
XMLHttpRequestMainThread::CloseRequestWithError(const ProgressEventType aType) XMLHttpRequestMainThread::CloseRequest()
{ {
if (mChannel) { if (mChannel) {
mChannel->Cancel(NS_BINDING_ABORTED); mChannel->Cancel(NS_BINDING_ABORTED);
@ -1012,6 +1012,13 @@ XMLHttpRequestMainThread::CloseRequestWithError(const ProgressEventType aType)
if (mTimeoutTimer) { if (mTimeoutTimer) {
mTimeoutTimer->Cancel(); mTimeoutTimer->Cancel();
} }
}
void
XMLHttpRequestMainThread::CloseRequestWithError(const ProgressEventType aType)
{
CloseRequest();
uint32_t responseLength = mResponseBody.Length(); uint32_t responseLength = mResponseBody.Length();
ResetResponse(); ResetResponse();
@ -1404,17 +1411,8 @@ XMLHttpRequestMainThread::Open(const nsACString& inMethod, const nsACString& url
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
if (mState == State::opened || mState == State::headers_received || CloseRequest(); // spec step 10
mState == State::loading) { ResetResponse(); // (part of) spec step 11
// IE aborts as well
Abort();
// XXX We should probably send a warning to the JS console
// that load was aborted and event listeners were cleared
// since this looks like a situation that could happen
// by accident and you could spend a lot of time wondering
// why things didn't work.
}
mFlagSend = false; mFlagSend = false;
@ -1542,7 +1540,9 @@ XMLHttpRequestMainThread::Open(const nsACString& inMethod, const nsACString& url
} }
} }
ChangeState(State::opened); if (mState != State::opened) {
ChangeState(State::opened);
}
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -761,6 +761,11 @@ protected:
// that this request is associated with. // that this request is associated with.
nsCString mNetworkInterfaceId; nsCString mNetworkInterfaceId;
/**
* Close the XMLHttpRequest's channels.
*/
void CloseRequest();
/** /**
* Close the XMLHttpRequest's channels and dispatch appropriate progress * Close the XMLHttpRequest's channels and dispatch appropriate progress
* events. * events.

Просмотреть файл

@ -1488,10 +1488,9 @@ SendRunnable::RunOnMainThread(ErrorResult& aRv)
variant = wvariant; variant = wvariant;
} }
// Send() has been already called. // Send() has been already called, reset the proxy.
if (mProxy->mWorkerPrivate) { if (mProxy->mWorkerPrivate) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); mProxy->Reset();
return;
} }
mProxy->mWorkerPrivate = mWorkerPrivate; mProxy->mWorkerPrivate = mWorkerPrivate;

Просмотреть файл

@ -1,5 +0,0 @@
[open-open-send.htm]
type: testharness
[XMLHttpRequest: open() - open() - send()]
expected: FAIL

Просмотреть файл

@ -1,5 +0,0 @@
[open-open-sync-send.htm]
type: testharness
[XMLHttpRequest: open() - open() (sync) - send()]
expected: FAIL

Просмотреть файл

@ -1,5 +0,0 @@
[open-send-open.htm]
type: testharness
[XMLHttpRequest: open() - send() - open()]
expected: FAIL

Просмотреть файл

@ -1,5 +0,0 @@
[open-sync-open-send.htm]
type: testharness
[XMLHttpRequest: open() (sync) - send() - open()]
expected: FAIL