зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1695216 - XMLHttpRequest should reset response upon receiving a bad chunk. r=annevk,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D124989
This commit is contained in:
Родитель
ac10d619ce
Коммит
9f3565b9fb
|
@ -2239,6 +2239,17 @@ XMLHttpRequestMainThread::OnStopRequest(nsIRequest* request, nsresult status) {
|
|||
|
||||
mErrorLoad = ErrorType::eUnreachable;
|
||||
mResponseXML = nullptr;
|
||||
|
||||
// Handle network errors specifically per spec.
|
||||
if (NS_ERROR_GET_MODULE(status) == NS_ERROR_MODULE_NETWORK) {
|
||||
IgnoredErrorResult rv;
|
||||
RequestErrorSteps(ProgressEventType::error, NS_ERROR_DOM_NETWORK_ERR, rv);
|
||||
// RequestErrorSteps sets state to DONE, but because we are throwing an
|
||||
// error, a progress event is never fired. Calling ChangeStateToDone
|
||||
// ensures that.
|
||||
ChangeStateToDone(wasSync);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// If we're uninitialized at this point, we encountered an error
|
||||
|
|
|
@ -1695,6 +1695,11 @@ void XMLHttpRequestWorker::SendInternal(const BodyExtractorBase* aBody,
|
|||
autoUnpin.Clear();
|
||||
|
||||
bool succeeded = autoSyncLoop->Run();
|
||||
// If the XHR failed, throw a network error.
|
||||
if (mProxy->mXHR->ErrorCode() !=
|
||||
static_cast<uint16_t>(XMLHttpRequestMainThread::ErrorType::eOK)) {
|
||||
aRv.Throw(NS_ERROR_DOM_NETWORK_ERR);
|
||||
}
|
||||
mStateData->mFlagSend = false;
|
||||
|
||||
// Don't clobber an existing exception that we may have thrown on aRv
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
[response-body-errors.any.html]
|
||||
[Asynchronous XMLHttpRequest should clear response on bad chunk]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[response-body-errors.any.worker.html]
|
||||
[Synchronous XMLHttpRequest should throw on bad chunk]
|
||||
expected: FAIL
|
||||
|
||||
[Asynchronous XMLHttpRequest should clear response on bad chunk]
|
||||
expected: FAIL
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// This will transmit two chunks TEST_CHUNK and then garbage, which should result in an error.
|
||||
const url = "/fetch/api/resources/bad-chunk-encoding.py?ms=1&count=2";
|
||||
const url = "/fetch/api/resources/bad-chunk-encoding.py?ms=100&count=2";
|
||||
|
||||
test(() => {
|
||||
client = new XMLHttpRequest();
|
||||
|
|
Загрузка…
Ссылка в новой задаче