зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1197893 - Check the number of arguments for ThrowTypeError() and ThrowRangeError() at compile time. r=peterv
This commit is contained in:
Родитель
7f51dcc335
Коммит
404740a102
|
@ -37,7 +37,7 @@ ArchiveReader::Constructor(const GlobalObject& aGlobal,
|
|||
nsAutoCString encoding;
|
||||
if (!EncodingUtils::FindEncodingForLabelNoReplacement(aOptions.mEncoding,
|
||||
encoding)) {
|
||||
aError.ThrowRangeError(MSG_ENCODING_NOT_SUPPORTED, &aOptions.mEncoding);
|
||||
aError.ThrowRangeError<MSG_ENCODING_NOT_SUPPORTED>(&aOptions.mEncoding);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ URL::Constructor(nsISupports* aParent, const nsAString& aUrl,
|
|||
nsresult rv = NS_NewURI(getter_AddRefs(baseUri), aBase, nullptr, nullptr,
|
||||
nsContentUtils::GetIOService());
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
aRv.ThrowTypeError(MSG_INVALID_URL, &aBase);
|
||||
aRv.ThrowTypeError<MSG_INVALID_URL>(&aBase);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ URL::Constructor(nsISupports* aParent, const nsAString& aUrl, nsIURI* aBase,
|
|||
nsresult rv = NS_NewURI(getter_AddRefs(uri), aUrl, nullptr, aBase,
|
||||
nsContentUtils::GetIOService());
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
aRv.ThrowTypeError(MSG_INVALID_URL, &aUrl);
|
||||
aRv.ThrowTypeError<MSG_INVALID_URL>(&aUrl);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -230,7 +230,7 @@ URL::SetHref(const nsAString& aHref, ErrorResult& aRv)
|
|||
rv = ioService->NewURI(href, nullptr, nullptr, getter_AddRefs(uri));
|
||||
if (NS_FAILED(rv)) {
|
||||
nsAutoString label(aHref);
|
||||
aRv.ThrowTypeError(MSG_INVALID_URL, &label);
|
||||
aRv.ThrowTypeError<MSG_INVALID_URL>(&label);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ WindowNamedPropertiesHandler::defineProperty(JSContext* aCx,
|
|||
JS::ObjectOpResult &result) const
|
||||
{
|
||||
ErrorResult rv;
|
||||
rv.ThrowTypeError(MSG_DEFINEPROPERTY_ON_GSP);
|
||||
rv.ThrowTypeError<MSG_DEFINEPROPERTY_ON_GSP>();
|
||||
rv.ReportErrorWithMessage(aCx);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -37,6 +37,16 @@ enum ErrNum {
|
|||
Err_Limit
|
||||
};
|
||||
|
||||
// Debug-only compile-time table of the number of arguments of each error, for use in static_assert.
|
||||
#ifdef DEBUG
|
||||
uint16_t constexpr ErrorFormatNumArgs[] = {
|
||||
#define MSG_DEF(_name, _argc, _exn, _str) \
|
||||
_argc,
|
||||
#include "mozilla/dom/Errors.msg"
|
||||
#undef MSG_DEF
|
||||
};
|
||||
#endif
|
||||
|
||||
uint16_t
|
||||
GetErrorArgCount(const ErrNum aErrorNumber);
|
||||
|
||||
|
@ -114,16 +124,16 @@ public:
|
|||
return rv;
|
||||
}
|
||||
|
||||
template<typename... Ts>
|
||||
void ThrowTypeError(const dom::ErrNum errorNumber, Ts... messageArgs)
|
||||
template<dom::ErrNum errorNumber, typename... Ts>
|
||||
void ThrowTypeError(Ts... messageArgs)
|
||||
{
|
||||
ThrowErrorWithMessage(errorNumber, NS_ERROR_TYPE_ERR, messageArgs...);
|
||||
ThrowErrorWithMessage<errorNumber>(NS_ERROR_TYPE_ERR, messageArgs...);
|
||||
}
|
||||
|
||||
template<typename... Ts>
|
||||
void ThrowRangeError(const dom::ErrNum errorNumber, Ts... messageArgs)
|
||||
template<dom::ErrNum errorNumber, typename... Ts>
|
||||
void ThrowRangeError(Ts... messageArgs)
|
||||
{
|
||||
ThrowErrorWithMessage(errorNumber, NS_ERROR_RANGE_ERR, messageArgs...);
|
||||
ThrowErrorWithMessage<errorNumber>(NS_ERROR_RANGE_ERR, messageArgs...);
|
||||
}
|
||||
|
||||
void ReportErrorWithMessage(JSContext* cx);
|
||||
|
@ -211,9 +221,12 @@ private:
|
|||
// and returns the arguments array from that Message.
|
||||
nsTArray<nsString>& CreateErrorMessageHelper(const dom::ErrNum errorNumber, nsresult errorType);
|
||||
|
||||
template<typename... Ts>
|
||||
void ThrowErrorWithMessage(const dom::ErrNum errorNumber, nsresult errorType, Ts... messageArgs)
|
||||
template<dom::ErrNum errorNumber, typename... Ts>
|
||||
void ThrowErrorWithMessage(nsresult errorType, Ts... messageArgs)
|
||||
{
|
||||
static_assert(dom::ErrorFormatNumArgs[errorNumber] == sizeof...(messageArgs),
|
||||
"Pass in the right number of arguments");
|
||||
|
||||
if (IsJSException()) {
|
||||
// We have rooted our mJSException, and we don't have the info
|
||||
// needed to unroot here, so just bail.
|
||||
|
|
|
@ -47,7 +47,7 @@ IsValidPutRequestURL(const nsAString& aUrl, ErrorResult& aRv)
|
|||
|
||||
if (!validScheme) {
|
||||
NS_NAMED_LITERAL_STRING(label, "Request");
|
||||
aRv.ThrowTypeError(MSG_INVALID_URL_SCHEME, &label, &aUrl);
|
||||
aRv.ThrowTypeError<MSG_INVALID_URL_SCHEME>(&label, &aUrl);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ IsValidPutRequestMethod(const Request& aRequest, ErrorResult& aRv)
|
|||
aRequest.GetMethod(method);
|
||||
if (!method.LowerCaseEqualsLiteral("get")) {
|
||||
NS_ConvertASCIItoUTF16 label(method);
|
||||
aRv.ThrowTypeError(MSG_INVALID_REQUEST_METHOD, &label);
|
||||
aRv.ThrowTypeError<MSG_INVALID_REQUEST_METHOD>(&label);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ private:
|
|||
Fail()
|
||||
{
|
||||
ErrorResult rv;
|
||||
rv.ThrowTypeError(MSG_FETCH_FAILED);
|
||||
rv.ThrowTypeError<MSG_FETCH_FAILED>();
|
||||
mPromise->MaybeReject(rv);
|
||||
}
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ TypeUtils::ToCacheRequest(CacheRequest& aOut, InternalRequest* aIn,
|
|||
if (aSchemeAction == TypeErrorOnInvalidScheme) {
|
||||
NS_NAMED_LITERAL_STRING(label, "Request");
|
||||
NS_ConvertUTF8toUTF16 urlUTF16(url);
|
||||
aRv.ThrowTypeError(MSG_INVALID_URL_SCHEME, &label, &urlUTF16);
|
||||
aRv.ThrowTypeError<MSG_INVALID_URL_SCHEME>(&label, &urlUTF16);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ TypeUtils::ToCacheResponseWithoutBody(CacheResponse& aOut,
|
|||
nsRefPtr<InternalHeaders> headers = aIn.UnfilteredHeaders();
|
||||
MOZ_ASSERT(headers);
|
||||
if (HasVaryStar(headers)) {
|
||||
aRv.ThrowTypeError(MSG_RESPONSE_HAS_VARY_STAR);
|
||||
aRv.ThrowTypeError<MSG_RESPONSE_HAS_VARY_STAR>();
|
||||
return;
|
||||
}
|
||||
ToHeadersEntryList(aOut.headers(), headers);
|
||||
|
@ -235,7 +235,7 @@ void
|
|||
TypeUtils::ToCacheResponse(CacheResponse& aOut, Response& aIn, ErrorResult& aRv)
|
||||
{
|
||||
if (aIn.BodyUsed()) {
|
||||
aRv.ThrowTypeError(MSG_FETCH_BODY_CONSUMED_ERROR);
|
||||
aRv.ThrowTypeError<MSG_FETCH_BODY_CONSUMED_ERROR>();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -458,7 +458,7 @@ TypeUtils::CheckAndSetBodyUsed(Request* aRequest, BodyAction aBodyAction,
|
|||
}
|
||||
|
||||
if (aRequest->BodyUsed()) {
|
||||
aRv.ThrowTypeError(MSG_FETCH_BODY_CONSUMED_ERROR);
|
||||
aRv.ThrowTypeError<MSG_FETCH_BODY_CONSUMED_ERROR>();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ TextDecoder::Init(const nsAString& aLabel, const bool aFatal,
|
|||
if (!EncodingUtils::FindEncodingForLabelNoReplacement(aLabel, encoding)) {
|
||||
nsAutoString label(aLabel);
|
||||
EncodingUtils::TrimSpaceCharacters(label);
|
||||
aRv.ThrowRangeError(MSG_ENCODING_NOT_SUPPORTED, &label);
|
||||
aRv.ThrowRangeError<MSG_ENCODING_NOT_SUPPORTED>(&label);
|
||||
return;
|
||||
}
|
||||
InitWithEncoding(encoding, aFatal);
|
||||
|
@ -83,7 +83,7 @@ TextDecoder::Decode(const char* aInput, const int32_t aLength,
|
|||
mDecoder->Reset();
|
||||
if (rv == NS_OK_UDEC_MOREINPUT) {
|
||||
if (mFatal) {
|
||||
aRv.ThrowTypeError(MSG_DOM_DECODING_FAILED);
|
||||
aRv.ThrowTypeError<MSG_DOM_DECODING_FAILED>();
|
||||
} else {
|
||||
// Need to emit a decode error manually
|
||||
// to simulate the EOF handling of the Encoding spec.
|
||||
|
@ -93,7 +93,7 @@ TextDecoder::Decode(const char* aInput, const int32_t aLength,
|
|||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.ThrowTypeError(MSG_DOM_DECODING_FAILED);
|
||||
aRv.ThrowTypeError<MSG_DOM_DECODING_FAILED>();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,14 +21,14 @@ TextEncoder::Init(const nsAString& aEncoding, ErrorResult& aRv)
|
|||
// If encoding is failure, or is none of utf-8, utf-16, and utf-16be,
|
||||
// throw a RangeError (https://encoding.spec.whatwg.org/#dom-textencoder).
|
||||
if (!EncodingUtils::FindEncodingForLabel(label, mEncoding)) {
|
||||
aRv.ThrowRangeError(MSG_ENCODING_NOT_SUPPORTED, &label);
|
||||
aRv.ThrowRangeError<MSG_ENCODING_NOT_SUPPORTED>(&label);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mEncoding.EqualsLiteral("UTF-8") &&
|
||||
!mEncoding.EqualsLiteral("UTF-16LE") &&
|
||||
!mEncoding.EqualsLiteral("UTF-16BE")) {
|
||||
aRv.ThrowRangeError(MSG_DOM_ENCODING_NOT_UTF);
|
||||
aRv.ThrowRangeError<MSG_DOM_ENCODING_NOT_UTF>();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ MainThreadFetchResolver::OnResponseAvailableInternal(InternalResponse* aResponse
|
|||
mPromise->MaybeResolve(mResponse);
|
||||
} else {
|
||||
ErrorResult result;
|
||||
result.ThrowTypeError(MSG_FETCH_FAILED);
|
||||
result.ThrowTypeError<MSG_FETCH_FAILED>();
|
||||
mPromise->MaybeReject(result);
|
||||
}
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ public:
|
|||
promise->MaybeResolve(response);
|
||||
} else {
|
||||
ErrorResult result;
|
||||
result.ThrowTypeError(MSG_FETCH_FAILED);
|
||||
result.ThrowTypeError<MSG_FETCH_FAILED>();
|
||||
promise->MaybeReject(result);
|
||||
}
|
||||
return true;
|
||||
|
@ -1476,7 +1476,7 @@ FetchBody<Derived>::ConsumeBody(ConsumeType aType, ErrorResult& aRv)
|
|||
{
|
||||
mConsumeType = aType;
|
||||
if (BodyUsed()) {
|
||||
aRv.ThrowTypeError(MSG_FETCH_BODY_CONSUMED_ERROR);
|
||||
aRv.ThrowTypeError<MSG_FETCH_BODY_CONSUMED_ERROR>();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ FetchUtil::ConsumeFormData(nsIGlobalObject* aParent, const nsCString& aMimeType,
|
|||
if (isValidFormDataMimeType) {
|
||||
FormDataParser parser(aMimeType, aStr, aParent);
|
||||
if (!parser.Parse()) {
|
||||
aRv.ThrowTypeError(MSG_BAD_FORMDATA);
|
||||
aRv.ThrowTypeError<MSG_BAD_FORMDATA>();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ FetchUtil::ConsumeFormData(nsIGlobalObject* aParent, const nsCString& aMimeType,
|
|||
return fd.forget();
|
||||
}
|
||||
|
||||
aRv.ThrowTypeError(MSG_BAD_FORMDATA);
|
||||
aRv.ThrowTypeError<MSG_BAD_FORMDATA>();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -185,7 +185,7 @@ InternalHeaders::IsInvalidName(const nsACString& aName, ErrorResult& aRv)
|
|||
{
|
||||
if (!NS_IsValidHTTPToken(aName)) {
|
||||
NS_ConvertUTF8toUTF16 label(aName);
|
||||
aRv.ThrowTypeError(MSG_INVALID_HEADER_NAME, &label);
|
||||
aRv.ThrowTypeError<MSG_INVALID_HEADER_NAME>(&label);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -198,7 +198,7 @@ InternalHeaders::IsInvalidValue(const nsACString& aValue, ErrorResult& aRv)
|
|||
{
|
||||
if (!NS_IsReasonableHTTPHeaderValue(aValue)) {
|
||||
NS_ConvertUTF8toUTF16 label(aValue);
|
||||
aRv.ThrowTypeError(MSG_INVALID_HEADER_VALUE, &label);
|
||||
aRv.ThrowTypeError<MSG_INVALID_HEADER_VALUE>(&label);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -208,7 +208,7 @@ bool
|
|||
InternalHeaders::IsImmutable(ErrorResult& aRv) const
|
||||
{
|
||||
if (mGuard == HeadersGuardEnum::Immutable) {
|
||||
aRv.ThrowTypeError(MSG_HEADERS_IMMUTABLE);
|
||||
aRv.ThrowTypeError<MSG_HEADERS_IMMUTABLE>();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -259,7 +259,7 @@ InternalHeaders::Fill(const Sequence<Sequence<nsCString>>& aInit, ErrorResult& a
|
|||
for (uint32_t i = 0; i < aInit.Length() && !aRv.Failed(); ++i) {
|
||||
const Sequence<nsCString>& tuple = aInit[i];
|
||||
if (tuple.Length() != 2) {
|
||||
aRv.ThrowTypeError(MSG_INVALID_HEADER_SEQUENCE);
|
||||
aRv.ThrowTypeError<MSG_INVALID_HEADER_SEQUENCE>();
|
||||
return;
|
||||
}
|
||||
Append(tuple[0], tuple[1], aRv);
|
||||
|
|
|
@ -83,7 +83,7 @@ GetRequestURLFromDocument(nsIDocument* aDocument, const nsAString& aInput,
|
|||
nsCOMPtr<nsIURI> resolvedURI;
|
||||
aRv = NS_NewURI(getter_AddRefs(resolvedURI), aInput, nullptr, baseURI);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
aRv.ThrowTypeError(MSG_INVALID_URL, &aInput);
|
||||
aRv.ThrowTypeError<MSG_INVALID_URL>(&aInput);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ GetRequestURLFromDocument(nsIDocument* aDocument, const nsAString& aInput,
|
|||
nsAutoCString credentials;
|
||||
unused << resolvedURI->GetUserPass(credentials);
|
||||
if (!credentials.IsEmpty()) {
|
||||
aRv.ThrowTypeError(MSG_URL_HAS_CREDENTIALS, &aInput);
|
||||
aRv.ThrowTypeError<MSG_URL_HAS_CREDENTIALS>(&aInput);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ GetRequestURLFromChrome(const nsAString& aInput, nsAString& aRequestURL,
|
|||
nsCOMPtr<nsIURI> uri;
|
||||
aRv = NS_NewURI(getter_AddRefs(uri), aInput, nullptr, nullptr);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
aRv.ThrowTypeError(MSG_INVALID_URL, &aInput);
|
||||
aRv.ThrowTypeError<MSG_INVALID_URL>(&aInput);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ GetRequestURLFromChrome(const nsAString& aInput, nsAString& aRequestURL,
|
|||
nsAutoCString credentials;
|
||||
unused << uri->GetUserPass(credentials);
|
||||
if (!credentials.IsEmpty()) {
|
||||
aRv.ThrowTypeError(MSG_URL_HAS_CREDENTIALS, &aInput);
|
||||
aRv.ThrowTypeError<MSG_URL_HAS_CREDENTIALS>(&aInput);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,7 @@ GetRequestURLFromWorker(const GlobalObject& aGlobal, const nsAString& aInput,
|
|||
nsRefPtr<workers::URL> url =
|
||||
workers::URL::Constructor(aGlobal, aInput, baseURL, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
aRv.ThrowTypeError(MSG_INVALID_URL, &aInput);
|
||||
aRv.ThrowTypeError<MSG_INVALID_URL>(&aInput);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ GetRequestURLFromWorker(const GlobalObject& aGlobal, const nsAString& aInput,
|
|||
}
|
||||
|
||||
if (!username.IsEmpty() || !password.IsEmpty()) {
|
||||
aRv.ThrowTypeError(MSG_URL_HAS_CREDENTIALS, &aInput);
|
||||
aRv.ThrowTypeError<MSG_URL_HAS_CREDENTIALS>(&aInput);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -214,7 +214,7 @@ Request::Constructor(const GlobalObject& aGlobal,
|
|||
inputReq->GetBody(getter_AddRefs(body));
|
||||
if (body) {
|
||||
if (inputReq->BodyUsed()) {
|
||||
aRv.ThrowTypeError(MSG_FETCH_BODY_CONSUMED_ERROR);
|
||||
aRv.ThrowTypeError<MSG_FETCH_BODY_CONSUMED_ERROR>();
|
||||
return nullptr;
|
||||
}
|
||||
temporaryBody = body;
|
||||
|
@ -267,7 +267,7 @@ Request::Constructor(const GlobalObject& aGlobal,
|
|||
NS_NAMED_LITERAL_STRING(sourceDescription, "'mode' member of RequestInit");
|
||||
NS_NAMED_LITERAL_STRING(value, "cors-with-forced-preflight");
|
||||
NS_NAMED_LITERAL_STRING(type, "RequestMode");
|
||||
aRv.ThrowTypeError(MSG_INVALID_ENUM_VALUE, &sourceDescription, &value, &type);
|
||||
aRv.ThrowTypeError<MSG_INVALID_ENUM_VALUE>(&sourceDescription, &value, &type);
|
||||
return nullptr;
|
||||
}
|
||||
RequestMode mode = aInit.mMode.WasPassed() ? aInit.mMode.Value() : fallbackMode;
|
||||
|
@ -307,7 +307,7 @@ Request::Constructor(const GlobalObject& aGlobal,
|
|||
nsresult rv = FetchUtil::GetValidRequestMethod(method, outMethod);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ConvertUTF8toUTF16 label(method);
|
||||
aRv.ThrowTypeError(MSG_INVALID_REQUEST_METHOD, &label);
|
||||
aRv.ThrowTypeError<MSG_INVALID_REQUEST_METHOD>(&label);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -341,7 +341,7 @@ Request::Constructor(const GlobalObject& aGlobal,
|
|||
nsAutoCString method;
|
||||
request->GetMethod(method);
|
||||
NS_ConvertUTF8toUTF16 label(method);
|
||||
aRv.ThrowTypeError(MSG_INVALID_REQUEST_METHOD, &label);
|
||||
aRv.ThrowTypeError<MSG_INVALID_REQUEST_METHOD>(&label);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -362,7 +362,7 @@ Request::Constructor(const GlobalObject& aGlobal,
|
|||
request->GetMethod(method);
|
||||
// method is guaranteed to be uppercase due to step 14.2 above.
|
||||
if (method.EqualsLiteral("HEAD") || method.EqualsLiteral("GET")) {
|
||||
aRv.ThrowTypeError(MSG_NO_BODY_ALLOWED_FOR_GET_AND_HEAD);
|
||||
aRv.ThrowTypeError<MSG_NO_BODY_ALLOWED_FOR_GET_AND_HEAD>();
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -412,7 +412,7 @@ already_AddRefed<Request>
|
|||
Request::Clone(ErrorResult& aRv) const
|
||||
{
|
||||
if (BodyUsed()) {
|
||||
aRv.ThrowTypeError(MSG_FETCH_BODY_CONSUMED_ERROR);
|
||||
aRv.ThrowTypeError<MSG_FETCH_BODY_CONSUMED_ERROR>();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ Response::Redirect(const GlobalObject& aGlobal, const nsAString& aUrl,
|
|||
}
|
||||
|
||||
if (aStatus != 301 && aStatus != 302 && aStatus != 303 && aStatus != 307 && aStatus != 308) {
|
||||
aRv.ThrowRangeError(MSG_INVALID_REDIRECT_STATUSCODE_ERROR);
|
||||
aRv.ThrowRangeError<MSG_INVALID_REDIRECT_STATUSCODE_ERROR>();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ Response::Constructor(const GlobalObject& aGlobal,
|
|||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
|
||||
if (aInit.mStatus < 200 || aInit.mStatus > 599) {
|
||||
aRv.ThrowRangeError(MSG_INVALID_RESPONSE_STATUSCODE_ERROR);
|
||||
aRv.ThrowRangeError<MSG_INVALID_RESPONSE_STATUSCODE_ERROR>();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -142,13 +142,13 @@ Response::Constructor(const GlobalObject& aGlobal,
|
|||
statusText.BeginReading(start);
|
||||
statusText.EndReading(end);
|
||||
if (FindCharInReadable('\r', start, end)) {
|
||||
aRv.ThrowTypeError(MSG_RESPONSE_INVALID_STATUSTEXT_ERROR);
|
||||
aRv.ThrowTypeError<MSG_RESPONSE_INVALID_STATUSTEXT_ERROR>();
|
||||
return nullptr;
|
||||
}
|
||||
// Reset iterator since FindCharInReadable advances it.
|
||||
statusText.BeginReading(start);
|
||||
if (FindCharInReadable('\n', start, end)) {
|
||||
aRv.ThrowTypeError(MSG_RESPONSE_INVALID_STATUSTEXT_ERROR);
|
||||
aRv.ThrowTypeError<MSG_RESPONSE_INVALID_STATUSTEXT_ERROR>();
|
||||
return nullptr;
|
||||
}
|
||||
} else {
|
||||
|
@ -199,7 +199,7 @@ Response::Constructor(const GlobalObject& aGlobal,
|
|||
|
||||
if (aBody.WasPassed()) {
|
||||
if (aInit.mStatus == 204 || aInit.mStatus == 205 || aInit.mStatus == 304) {
|
||||
aRv.ThrowTypeError(MSG_RESPONSE_NULL_STATUS_WITH_BODY);
|
||||
aRv.ThrowTypeError<MSG_RESPONSE_NULL_STATUS_WITH_BODY>();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -226,7 +226,7 @@ already_AddRefed<Response>
|
|||
Response::Clone(ErrorResult& aRv) const
|
||||
{
|
||||
if (BodyUsed()) {
|
||||
aRv.ThrowTypeError(MSG_FETCH_BODY_CONSUMED_ERROR);
|
||||
aRv.ThrowTypeError<MSG_FETCH_BODY_CONSUMED_ERROR>();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -359,7 +359,7 @@ FileHandleBase::CheckStateAndArgumentsForRead(uint64_t aSize, ErrorResult& aRv)
|
|||
|
||||
// Argument checking for read
|
||||
if (!aSize) {
|
||||
aRv.ThrowTypeError(MSG_INVALID_READ_SIZE);
|
||||
aRv.ThrowTypeError<MSG_INVALID_READ_SIZE>();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -520,7 +520,7 @@ IDBCursor::Advance(uint32_t aCount, ErrorResult &aRv)
|
|||
AssertIsOnOwningThread();
|
||||
|
||||
if (!aCount) {
|
||||
aRv.ThrowTypeError(MSG_INVALID_ADVANCE_COUNT);
|
||||
aRv.ThrowTypeError<MSG_INVALID_ADVANCE_COUNT>();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -657,7 +657,7 @@ IDBFactory::OpenInternal(nsIPrincipal* aPrincipal,
|
|||
uint64_t version = 0;
|
||||
if (!aDeleting && aVersion.WasPassed()) {
|
||||
if (aVersion.Value() < 1) {
|
||||
aRv.ThrowTypeError(MSG_INVALID_VERSION);
|
||||
aRv.ThrowTypeError<MSG_INVALID_VERSION>();
|
||||
return nullptr;
|
||||
}
|
||||
version = aVersion.Value();
|
||||
|
|
|
@ -75,7 +75,7 @@ IDBFileHandle::GetMetadata(const IDBFileMetadataParameters& aParameters,
|
|||
|
||||
// Argument checking for get metadata.
|
||||
if (!aParameters.mSize && !aParameters.mLastModified) {
|
||||
aRv.ThrowTypeError(MSG_METADATA_NOT_CONFIGURED);
|
||||
aRv.ThrowTypeError<MSG_METADATA_NOT_CONFIGURED>();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -988,7 +988,7 @@ MediaRecorder::Constructor(const GlobalObject& aGlobal,
|
|||
// Pretending that this constructor is not defined.
|
||||
NS_NAMED_LITERAL_STRING(argStr, "Argument 1 of MediaRecorder.constructor");
|
||||
NS_NAMED_LITERAL_STRING(typeStr, "MediaStream");
|
||||
aRv.ThrowTypeError(MSG_DOES_NOT_IMPLEMENT_INTERFACE, &argStr, &typeStr);
|
||||
aRv.ThrowTypeError<MSG_DOES_NOT_IMPLEMENT_INTERFACE>(&argStr, &typeStr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -815,7 +815,7 @@ Notification::Constructor(const GlobalObject& aGlobal,
|
|||
ServiceWorkerGlobalScope* scope = nullptr;
|
||||
UNWRAP_WORKER_OBJECT(ServiceWorkerGlobalScope, aGlobal.Get(), scope);
|
||||
if (scope) {
|
||||
aRv.ThrowTypeError(MSG_NOTIFICATION_NO_CONSTRUCTOR_IN_SERVICEWORKER);
|
||||
aRv.ThrowTypeError<MSG_NOTIFICATION_NO_CONSTRUCTOR_IN_SERVICEWORKER>();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -2320,7 +2320,7 @@ Notification::ShowPersistentNotification(nsIGlobalObject *aGlobal,
|
|||
if (NS_WARN_IF(NS_FAILED(loadChecker->Result()))) {
|
||||
if (loadChecker->Result() == NS_ERROR_NOT_AVAILABLE) {
|
||||
nsAutoString scope(aScope);
|
||||
aRv.ThrowTypeError(MSG_NO_ACTIVE_WORKER, &scope);
|
||||
aRv.ThrowTypeError<MSG_NO_ACTIVE_WORKER>(&scope);
|
||||
} else {
|
||||
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
||||
}
|
||||
|
@ -2341,7 +2341,7 @@ Notification::ShowPersistentNotification(nsIGlobalObject *aGlobal,
|
|||
// "If permission for notification’s origin is not "granted", reject promise with a TypeError exception, and terminate these substeps."
|
||||
if (NS_WARN_IF(aRv.Failed()) || permission == NotificationPermission::Denied) {
|
||||
ErrorResult result;
|
||||
result.ThrowTypeError(MSG_NOTIFICATION_PERMISSION_DENIED);
|
||||
result.ThrowTypeError<MSG_NOTIFICATION_PERMISSION_DENIED>();
|
||||
p->MaybeReject(result);
|
||||
return p.forget();
|
||||
}
|
||||
|
|
|
@ -470,7 +470,7 @@ SVGSVGElement::SetZoomAndPan(uint16_t aZoomAndPan, ErrorResult& rv)
|
|||
return;
|
||||
}
|
||||
|
||||
rv.ThrowRangeError(MSG_INVALID_ZOOMANDPAN_VALUE_ERROR);
|
||||
rv.ThrowRangeError<MSG_INVALID_ZOOMANDPAN_VALUE_ERROR>();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -260,7 +260,7 @@ SVGTransform::SetSkewX(float angle, ErrorResult& rv)
|
|||
}
|
||||
|
||||
if (!IsFinite(tan(angle * kRadPerDegree))) {
|
||||
rv.ThrowRangeError(MSG_INVALID_TRANSFORM_ANGLE_ERROR);
|
||||
rv.ThrowRangeError<MSG_INVALID_TRANSFORM_ANGLE_ERROR>();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -283,7 +283,7 @@ SVGTransform::SetSkewY(float angle, ErrorResult& rv)
|
|||
}
|
||||
|
||||
if (!IsFinite(tan(angle * kRadPerDegree))) {
|
||||
rv.ThrowRangeError(MSG_INVALID_TRANSFORM_ANGLE_ERROR);
|
||||
rv.ThrowRangeError<MSG_INVALID_TRANSFORM_ANGLE_ERROR>();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ SVGViewElement::SetZoomAndPan(uint16_t aZoomAndPan, ErrorResult& rv)
|
|||
return;
|
||||
}
|
||||
|
||||
rv.ThrowRangeError(MSG_INVALID_ZOOMANDPAN_VALUE_ERROR);
|
||||
rv.ThrowRangeError<MSG_INVALID_ZOOMANDPAN_VALUE_ERROR>();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -168,7 +168,7 @@ ServiceWorkerContainer::Register(const nsAString& aScriptURL,
|
|||
nsCOMPtr<nsIURI> scriptURI;
|
||||
rv = NS_NewURI(getter_AddRefs(scriptURI), aScriptURL, nullptr, baseURI);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
aRv.ThrowTypeError(MSG_INVALID_URL, &aScriptURL);
|
||||
aRv.ThrowTypeError<MSG_INVALID_URL>(&aScriptURL);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -190,7 +190,7 @@ ServiceWorkerContainer::Register(const nsAString& aScriptURL,
|
|||
nsAutoCString spec;
|
||||
scriptURI->GetSpec(spec);
|
||||
NS_ConvertUTF8toUTF16 wSpec(spec);
|
||||
aRv.ThrowTypeError(MSG_INVALID_SCOPE, &defaultScope, &wSpec);
|
||||
aRv.ThrowTypeError<MSG_INVALID_SCOPE>(&defaultScope, &wSpec);
|
||||
return nullptr;
|
||||
}
|
||||
} else {
|
||||
|
@ -201,7 +201,7 @@ ServiceWorkerContainer::Register(const nsAString& aScriptURL,
|
|||
nsAutoCString spec;
|
||||
baseURI->GetSpec(spec);
|
||||
NS_ConvertUTF8toUTF16 wSpec(spec);
|
||||
aRv.ThrowTypeError(MSG_INVALID_SCOPE, &aOptions.mScope.Value(), &wSpec);
|
||||
aRv.ThrowTypeError<MSG_INVALID_SCOPE>(&aOptions.mScope.Value(), &wSpec);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -704,7 +704,7 @@ ServiceWorkerRegistrationMainThread::ShowNotification(JSContext* aCx,
|
|||
|
||||
nsRefPtr<workers::ServiceWorker> worker = GetActive();
|
||||
if (!worker) {
|
||||
aRv.ThrowTypeError(MSG_NO_ACTIVE_WORKER, &mScope);
|
||||
aRv.ThrowTypeError<MSG_NO_ACTIVE_WORKER>(&mScope);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче