Bug 1712861 - Get rid of NS_ERROR_DOM_INVALID_ACCESS_XHR_TIMEOUT_AND_RESPONSETYPE_UNSUPPORTED_FOR_SYNC; r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D115946
This commit is contained in:
@@ -305,7 +305,6 @@ const ErrorCodes = {
|
||||
NS_ERROR_DOM_INVALID_STATE_XHR_HAS_WRONG_RESPONSETYPE_FOR_RESPONSEXML: 0x805303fe,
|
||||
NS_ERROR_DOM_INVALID_STATE_XHR_HAS_WRONG_RESPONSETYPE_FOR_RESPONSETEXT: 0x805303ff,
|
||||
NS_ERROR_DOM_INVALID_STATE_XHR_CHUNKED_RESPONSETYPES_UNSUPPORTED_FOR_SYNC: 0x80530400,
|
||||
NS_ERROR_DOM_INVALID_ACCESS_XHR_TIMEOUT_AND_RESPONSETYPE_UNSUPPORTED_FOR_SYNC: 0x80530401,
|
||||
NS_ERROR_DOM_JS_DECODING_ERROR: 0x80530402,
|
||||
NS_ERROR_DOM_IMAGE_INACTIVE_DOCUMENT: 0x80530403,
|
||||
NS_ERROR_DOM_IMAGE_INVALID_REQUEST: 0x80530404,
|
||||
|
||||
@@ -144,7 +144,6 @@ DOM4_MSG_DEF(InvalidStateError, "Cannot set 'responseType' property on XMLHttpRe
|
||||
DOM4_MSG_DEF(InvalidStateError, "Cannot call 'overrideMimeType()' on XMLHttpRequest after 'send()' (when its state is LOADING or DONE).", NS_ERROR_DOM_INVALID_STATE_XHR_MUST_NOT_BE_LOADING_OR_DONE_OVERRIDE_MIME_TYPE)
|
||||
DOM4_MSG_DEF(InvalidStateError, "responseXML is only available if responseType is '' or 'document'.", NS_ERROR_DOM_INVALID_STATE_XHR_HAS_WRONG_RESPONSETYPE_FOR_RESPONSEXML)
|
||||
DOM4_MSG_DEF(InvalidStateError, "responseText is only available if responseType is '' or 'text'.", NS_ERROR_DOM_INVALID_STATE_XHR_HAS_WRONG_RESPONSETYPE_FOR_RESPONSETEXT)
|
||||
DOM4_MSG_DEF(InvalidAccessError, "synchronous XMLHttpRequests do not support timeout and responseType.", NS_ERROR_DOM_INVALID_ACCESS_XHR_TIMEOUT_AND_RESPONSETYPE_UNSUPPORTED_FOR_SYNC)
|
||||
|
||||
/* Image decode errors. */
|
||||
DOM4_MSG_DEF(EncodingError, "Node bound to inactive document.", NS_ERROR_DOM_IMAGE_INACTIVE_DOCUMENT)
|
||||
|
||||
@@ -169,11 +169,6 @@ static void AddLoadFlags(nsIRequest* request, nsLoadFlags newFlags) {
|
||||
}
|
||||
|
||||
// We are in a sync event loop.
|
||||
#define NOT_CALLABLE_IN_SYNC_SEND \
|
||||
if (mFlagSyncLooping || mEventDispatchingSuspended) { \
|
||||
return NS_ERROR_DOM_INVALID_STATE_XHR_HAS_INVALID_CONTEXT; \
|
||||
}
|
||||
|
||||
#define NOT_CALLABLE_IN_SYNC_SEND_RV \
|
||||
if (mFlagSyncLooping || mEventDispatchingSuspended) { \
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_XHR_HAS_INVALID_CONTEXT); \
|
||||
@@ -662,8 +657,8 @@ void XMLHttpRequestMainThread::SetResponseType(
|
||||
if (HasOrHasHadOwner() && mState != XMLHttpRequest_Binding::UNSENT &&
|
||||
mFlagSynchronous) {
|
||||
LogMessage("ResponseTypeSyncXHRWarning", GetOwner());
|
||||
aRv.Throw(
|
||||
NS_ERROR_DOM_INVALID_ACCESS_XHR_TIMEOUT_AND_RESPONSETYPE_UNSUPPORTED_FOR_SYNC);
|
||||
aRv.ThrowInvalidAccessError(
|
||||
"synchronous XMLHttpRequests do not support timeout and responseType");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1386,18 +1381,15 @@ void XMLHttpRequestMainThread::Open(const nsACString& aMethod,
|
||||
const nsAString& aUsername,
|
||||
const nsAString& aPassword,
|
||||
ErrorResult& aRv) {
|
||||
nsresult rv =
|
||||
Open(aMethod, NS_ConvertUTF16toUTF8(aUrl), aAsync, aUsername, aPassword);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
}
|
||||
Open(aMethod, NS_ConvertUTF16toUTF8(aUrl), aAsync, aUsername, aPassword, aRv);
|
||||
}
|
||||
|
||||
nsresult XMLHttpRequestMainThread::Open(const nsACString& aMethod,
|
||||
void XMLHttpRequestMainThread::Open(const nsACString& aMethod,
|
||||
const nsACString& aUrl, bool aAsync,
|
||||
const nsAString& aUsername,
|
||||
const nsAString& aPassword) {
|
||||
NOT_CALLABLE_IN_SYNC_SEND
|
||||
const nsAString& aPassword,
|
||||
ErrorResult& aRv) {
|
||||
NOT_CALLABLE_IN_SYNC_SEND_RV
|
||||
|
||||
// Gecko-specific
|
||||
if (!aAsync && !DontWarnAboutSyncXHR() && GetOwner() &&
|
||||
@@ -1414,12 +1406,15 @@ nsresult XMLHttpRequestMainThread::Open(const nsACString& aMethod,
|
||||
if (!responsibleDocument) {
|
||||
// This could be because we're no longer current or because we're in some
|
||||
// non-window context...
|
||||
nsresult rv = CheckCurrentGlobalCorrectness();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return NS_ERROR_DOM_INVALID_STATE_XHR_HAS_INVALID_CONTEXT;
|
||||
if (NS_WARN_IF(NS_FAILED(CheckCurrentGlobalCorrectness()))) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_XHR_HAS_INVALID_CONTEXT);
|
||||
return;
|
||||
}
|
||||
}
|
||||
NS_ENSURE_TRUE(mPrincipal, NS_ERROR_NOT_INITIALIZED);
|
||||
if (!mPrincipal) {
|
||||
aRv.Throw(NS_ERROR_NOT_INITIALIZED);
|
||||
return;
|
||||
}
|
||||
|
||||
// Gecko-specific
|
||||
if (!aAsync && responsibleDocument && GetOwner()) {
|
||||
@@ -1438,9 +1433,9 @@ nsresult XMLHttpRequestMainThread::Open(const nsACString& aMethod,
|
||||
|
||||
// Steps 2-4
|
||||
nsAutoCString method;
|
||||
nsresult rv = FetchUtil::GetValidRequestMethod(aMethod, method);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
aRv = FetchUtil::GetValidRequestMethod(aMethod, method);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Steps 5-6
|
||||
@@ -1460,15 +1455,19 @@ nsresult XMLHttpRequestMainThread::Open(const nsACString& aMethod,
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> parsedURL;
|
||||
rv = NS_NewURI(getter_AddRefs(parsedURL), aUrl, originCharset, baseURI);
|
||||
nsresult rv =
|
||||
NS_NewURI(getter_AddRefs(parsedURL), aUrl, originCharset, baseURI);
|
||||
if (NS_FAILED(rv)) {
|
||||
if (rv == NS_ERROR_MALFORMED_URI) {
|
||||
return NS_ERROR_DOM_MALFORMED_URI;
|
||||
aRv.Throw(NS_ERROR_DOM_MALFORMED_URI);
|
||||
return;
|
||||
}
|
||||
return rv;
|
||||
aRv.Throw(rv);
|
||||
return;
|
||||
}
|
||||
if (NS_WARN_IF(NS_FAILED(CheckCurrentGlobalCorrectness()))) {
|
||||
return NS_ERROR_DOM_INVALID_STATE_XHR_HAS_INVALID_CONTEXT;
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_XHR_HAS_INVALID_CONTEXT);
|
||||
return;
|
||||
}
|
||||
|
||||
// Step 7
|
||||
@@ -1499,7 +1498,9 @@ nsresult XMLHttpRequestMainThread::Open(const nsACString& aMethod,
|
||||
if (mResponseType != XMLHttpRequestResponseType::_empty) {
|
||||
LogMessage("ResponseTypeSyncXHRWarning", GetOwner());
|
||||
}
|
||||
return NS_ERROR_DOM_INVALID_ACCESS_XHR_TIMEOUT_AND_RESPONSETYPE_UNSUPPORTED_FOR_SYNC;
|
||||
aRv.ThrowInvalidAccessError(
|
||||
"synchronous XMLHttpRequests do not support timeout and responseType");
|
||||
return;
|
||||
}
|
||||
|
||||
// Step 10
|
||||
@@ -1532,8 +1533,6 @@ nsresult XMLHttpRequestMainThread::Open(const nsACString& aMethod,
|
||||
mState = XMLHttpRequest_Binding::OPENED;
|
||||
FireReadystatechangeEvent();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void XMLHttpRequestMainThread::SetOriginAttributes(
|
||||
@@ -3148,8 +3147,8 @@ void XMLHttpRequestMainThread::SetTimeout(uint32_t aTimeout, ErrorResult& aRv) {
|
||||
/* Timeout is not supported for synchronous requests with an owning window,
|
||||
per XHR2 spec. */
|
||||
LogMessage("TimeoutSyncXHRWarning", GetOwner());
|
||||
aRv.Throw(
|
||||
NS_ERROR_DOM_INVALID_ACCESS_XHR_TIMEOUT_AND_RESPONSETYPE_UNSUPPORTED_FOR_SYNC);
|
||||
aRv.ThrowInvalidAccessError(
|
||||
"synchronous XMLHttpRequests do not support timeout and responseType");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -275,8 +275,9 @@ class XMLHttpRequestMainThread final : public XMLHttpRequest,
|
||||
bool aAsync, const nsAString& aUsername,
|
||||
const nsAString& aPassword, ErrorResult& aRv) override;
|
||||
|
||||
nsresult Open(const nsACString& aMethod, const nsACString& aUrl, bool aAsync,
|
||||
const nsAString& aUsername, const nsAString& aPassword);
|
||||
void Open(const nsACString& aMethod, const nsACString& aUrl, bool aAsync,
|
||||
const nsAString& aUsername, const nsAString& aPassword,
|
||||
ErrorResult& aRv);
|
||||
|
||||
virtual void SetRequestHeader(const nsACString& aName,
|
||||
const nsACString& aValue,
|
||||
|
||||
@@ -739,11 +739,6 @@ with modules["DOM"]:
|
||||
] = FAILURE(
|
||||
1024
|
||||
) # NOQA: E501
|
||||
errors[
|
||||
"NS_ERROR_DOM_INVALID_ACCESS_XHR_TIMEOUT_AND_RESPONSETYPE_UNSUPPORTED_FOR_SYNC"
|
||||
] = FAILURE(
|
||||
1025
|
||||
) # NOQA: E501
|
||||
|
||||
# When manipulating the bytecode cache with the JS API, some transcoding
|
||||
# errors, such as a different bytecode format can cause failures of the
|
||||
|
||||
Reference in New Issue
Block a user