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
parent 342a16f1a3
commit 0564cc02ae
7 changed files with 20 additions and 36 deletions

View File

@ -1004,7 +1004,7 @@ XMLHttpRequestMainThread::GetStatusText(nsACString& aStatusText,
}
void
XMLHttpRequestMainThread::CloseRequestWithError(const ProgressEventType aType)
XMLHttpRequestMainThread::CloseRequest()
{
if (mChannel) {
mChannel->Cancel(NS_BINDING_ABORTED);
@ -1012,6 +1012,13 @@ XMLHttpRequestMainThread::CloseRequestWithError(const ProgressEventType aType)
if (mTimeoutTimer) {
mTimeoutTimer->Cancel();
}
}
void
XMLHttpRequestMainThread::CloseRequestWithError(const ProgressEventType aType)
{
CloseRequest();
uint32_t responseLength = mResponseBody.Length();
ResetResponse();
@ -1404,17 +1411,8 @@ XMLHttpRequestMainThread::Open(const nsACString& inMethod, const nsACString& url
nsCOMPtr<nsIURI> uri;
if (mState == State::opened || mState == State::headers_received ||
mState == State::loading) {
// 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.
}
CloseRequest(); // spec step 10
ResetResponse(); // (part of) spec step 11
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;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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