Bug 1564930 - Improve "XHR must not be LOADING or DONE" error messages. r=baku

The previous error message suggested that this is an internal error message
pointing out a bad state in the XHR state machine, when in fact this is
a user error (calling `overrideMimeType()` or setting `responseType()` after
`send()`).

This commit improves and disambiguates the error messages, pointing out to
the user what they did wrong, like other browsers do.

Differential Revision: https://phabricator.services.mozilla.com/D37659
This commit is contained in:
Niklas Hambüchen
2019-07-12 22:51:10 +00:00
parent 37ace63442
commit ce9b21868d
5 changed files with 8 additions and 6 deletions

View File

@@ -632,7 +632,7 @@ void XMLHttpRequestMainThread::SetResponseType(
if (mState == XMLHttpRequest_Binding::LOADING ||
mState == XMLHttpRequest_Binding::DONE) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_XHR_MUST_NOT_BE_LOADING_OR_DONE);
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_XHR_MUST_NOT_BE_LOADING_OR_DONE_RESPONSE_TYPE);
return;
}
@@ -3101,7 +3101,7 @@ void XMLHttpRequestMainThread::OverrideMimeType(const nsAString& aMimeType,
if (mState == XMLHttpRequest_Binding::LOADING ||
mState == XMLHttpRequest_Binding::DONE) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_XHR_MUST_NOT_BE_LOADING_OR_DONE);
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_XHR_MUST_NOT_BE_LOADING_OR_DONE_OVERRIDE_MIME_TYPE);
return;
}