Bug 1125766 - Throw proper error types for TextEncoder(), TextDecoder() and TextDecoder.decode(). r=bz

This commit is contained in:
Dhi Aurrahman 2015-02-04 18:46:26 +07:00
parent 278751f212
commit e0a3d64aa1
25 changed files with 180 additions and 385 deletions

View File

@ -37,7 +37,7 @@ ArchiveReader::Constructor(const GlobalObject& aGlobal,
nsAutoCString encoding;
if (!EncodingUtils::FindEncodingForLabelNoReplacement(aOptions.mEncoding,
encoding)) {
aError.ThrowTypeError(MSG_ENCODING_NOT_SUPPORTED, &aOptions.mEncoding);
aError.ThrowRangeError(MSG_ENCODING_NOT_SUPPORTED, &aOptions.mEncoding);
return nullptr;
}

View File

@ -63,7 +63,7 @@
new ArchiveReader(binaryFile, { encoding: "random stuff" });
ok(false, "Should have thrown for bogus encoding label.");
} catch (e) {
ok(e instanceof TypeError, "Expected a TypeError");
ok(e instanceof RangeError, "Expected a RangeError");
finishTest();
}
}

View File

@ -159,7 +159,7 @@ WindowNamedPropertiesHandler::defineProperty(JSContext* aCx,
{
ErrorResult rv;
rv.ThrowTypeError(MSG_DEFINEPROPERTY_ON_GSP);
rv.ReportTypeError(aCx);
rv.ReportErrorWithMessage(aCx);
return false;
}

View File

@ -38,8 +38,6 @@ DOM4_MSG_DEF(RangeError, "The method parameter is out of valid range.", NS_ERROR
/* StringEncoding API errors from http://wiki.whatwg.org/wiki/StringEncoding */
DOM4_MSG_DEF(EncodingError, "The given encoding is not supported.", NS_ERROR_DOM_ENCODING_NOT_SUPPORTED_ERR)
DOM4_MSG_DEF(EncodingError, "The encoding must be utf-8, utf-16, or utf-16be.", NS_ERROR_DOM_ENCODING_NOT_UTF_ERR)
DOM4_MSG_DEF(EncodingError, "The decoder failed to convert.", NS_ERROR_DOM_ENCODING_DECODE_ERR)
/* WebCrypto API errors from http://www.w3.org/TR/WebCryptoAPI/ */
DOM4_MSG_DEF(UnknownError, "The operation failed for an unknown transient reason", NS_ERROR_DOM_UNKNOWN_ERR)

View File

@ -50,8 +50,8 @@ namespace mozilla {
namespace dom {
JSErrorFormatString ErrorFormatString[] = {
#define MSG_DEF(_name, _argc, _str) \
{ _str, _argc, JSEXN_TYPEERR },
#define MSG_DEF(_name, _argc, _exn, _str) \
{ _str, _argc, _exn },
#include "mozilla/dom/Errors.msg"
#undef MSG_DEF
};
@ -123,22 +123,20 @@ struct ErrorResult::Message {
};
void
ErrorResult::ThrowTypeError(const dom::ErrNum errorNumber, ...)
ErrorResult::ThrowErrorWithMessage(va_list ap, const dom::ErrNum errorNumber,
nsresult errorType)
{
va_list ap;
va_start(ap, errorNumber);
if (IsJSException()) {
// We have rooted our mJSException, and we don't have the info
// needed to unroot here, so just bail.
va_end(ap);
MOZ_ASSERT(false,
"Ignoring ThrowTypeError call because we have a JS exception");
"Ignoring ThrowErrorWithMessage call because we have a JS exception");
return;
}
if (IsTypeError()) {
if (IsErrorWithMessage()) {
delete mMessage;
}
mResult = NS_ERROR_TYPE_ERR;
mResult = errorType;
Message* message = new Message();
message->mErrorNumber = errorNumber;
uint16_t argCount = dom::GetErrorMessage(nullptr, errorNumber)->argCount;
@ -148,13 +146,30 @@ ErrorResult::ThrowTypeError(const dom::ErrNum errorNumber, ...)
message->mArgs.AppendElement(*va_arg(ap, nsString*));
}
mMessage = message;
}
void
ErrorResult::ThrowTypeError(const dom::ErrNum errorNumber, ...)
{
va_list ap;
va_start(ap, errorNumber);
ThrowErrorWithMessage(ap, errorNumber, NS_ERROR_TYPE_ERR);
va_end(ap);
}
void
ErrorResult::ReportTypeError(JSContext* aCx)
ErrorResult::ThrowRangeError(const dom::ErrNum errorNumber, ...)
{
MOZ_ASSERT(mMessage, "ReportTypeError() can be called only once");
va_list ap;
va_start(ap, errorNumber);
ThrowErrorWithMessage(ap, errorNumber, NS_ERROR_RANGE_ERR);
va_end(ap);
}
void
ErrorResult::ReportErrorWithMessage(JSContext* aCx)
{
MOZ_ASSERT(mMessage, "ReportErrorWithMessage() can be called only once");
Message* message = mMessage;
const uint32_t argCount = message->mArgs.Length();
@ -174,7 +189,7 @@ ErrorResult::ReportTypeError(JSContext* aCx)
void
ErrorResult::ClearMessage()
{
if (IsTypeError()) {
if (IsErrorWithMessage()) {
delete mMessage;
mMessage = nullptr;
}
@ -186,7 +201,7 @@ ErrorResult::ThrowJSException(JSContext* cx, JS::Handle<JS::Value> exn)
MOZ_ASSERT(mMightHaveUnreportedJSException,
"Why didn't you tell us you planned to throw a JS exception?");
if (IsTypeError()) {
if (IsErrorWithMessage()) {
delete mMessage;
}

View File

@ -103,8 +103,8 @@ ThrowMethodFailedWithDetails(JSContext* cx, ErrorResult& rv,
const char* memberName,
bool reportJSContentExceptions = false)
{
if (rv.IsTypeError()) {
rv.ReportTypeError(cx);
if (rv.IsErrorWithMessage()) {
rv.ReportErrorWithMessage(cx);
return false;
}
if (rv.IsJSException()) {

View File

@ -23,7 +23,7 @@ namespace mozilla {
namespace dom {
enum ErrNum {
#define MSG_DEF(_name, _argc, _str) \
#define MSG_DEF(_name, _argc, _exn, _str) \
_name,
#include "mozilla/dom/Errors.msg"
#undef MSG_DEF
@ -51,7 +51,7 @@ public:
#ifdef DEBUG
~ErrorResult() {
MOZ_ASSERT_IF(IsTypeError(), !mMessage);
MOZ_ASSERT_IF(IsErrorWithMessage(), !mMessage);
MOZ_ASSERT(!mMightHaveUnreportedJSException);
}
#endif
@ -59,7 +59,8 @@ public:
void Throw(nsresult rv) {
MOZ_ASSERT(NS_FAILED(rv), "Please don't try throwing success");
MOZ_ASSERT(rv != NS_ERROR_TYPE_ERR, "Use ThrowTypeError()");
MOZ_ASSERT(!IsTypeError(), "Don't overwite TypeError");
MOZ_ASSERT(rv != NS_ERROR_RANGE_ERR, "Use ThrowRangeError()");
MOZ_ASSERT(!IsErrorWithMessage(), "Don't overwrite errors with message");
MOZ_ASSERT(rv != NS_ERROR_DOM_JS_EXCEPTION, "Use ThrowJSException()");
MOZ_ASSERT(!IsJSException(), "Don't overwrite JS exceptions");
MOZ_ASSERT(rv != NS_ERROR_XPC_NOT_ENOUGH_ARGS, "Use ThrowNotEnoughArgsError()");
@ -68,9 +69,10 @@ public:
}
void ThrowTypeError(const dom::ErrNum errorNumber, ...);
void ReportTypeError(JSContext* cx);
void ThrowRangeError(const dom::ErrNum errorNumber, ...);
void ReportErrorWithMessage(JSContext* cx);
void ClearMessage();
bool IsTypeError() const { return ErrorCode() == NS_ERROR_TYPE_ERR; }
bool IsErrorWithMessage() const { return ErrorCode() == NS_ERROR_TYPE_ERR || ErrorCode() == NS_ERROR_RANGE_ERR; }
// Facilities for throwing a preexisting JS exception value via this
// ErrorResult. The contract is that any code which might end up calling
@ -123,7 +125,8 @@ public:
// this.
void operator=(nsresult rv) {
MOZ_ASSERT(rv != NS_ERROR_TYPE_ERR, "Use ThrowTypeError()");
MOZ_ASSERT(!IsTypeError(), "Don't overwite TypeError");
MOZ_ASSERT(rv != NS_ERROR_RANGE_ERR, "Use ThrowRangeError()");
MOZ_ASSERT(!IsErrorWithMessage(), "Don't overwrite errors with message");
MOZ_ASSERT(rv != NS_ERROR_DOM_JS_EXCEPTION, "Use ThrowJSException()");
MOZ_ASSERT(!IsJSException(), "Don't overwrite JS exceptions");
MOZ_ASSERT(rv != NS_ERROR_XPC_NOT_ENOUGH_ARGS, "Use ThrowNotEnoughArgsError()");
@ -142,12 +145,12 @@ public:
private:
nsresult mResult;
struct Message;
// mMessage is set by ThrowTypeError and cleared (and deallocatd) by
// ReportTypeError.
// mMessage is set by ThrowErrorWithMessage and cleared (and deallocated) by
// ReportErrorWithMessage.
// mJSException is set (and rooted) by ThrowJSException and unrooted
// by ReportJSException.
union {
Message* mMessage; // valid when IsTypeError()
Message* mMessage; // valid when IsErrorWithMessage()
JS::Value mJSException; // valid when IsJSException()
};
@ -160,6 +163,8 @@ private:
// Not to be implemented, to make sure people always pass this by
// reference, not by value.
ErrorResult(const ErrorResult&) = delete;
void ThrowErrorWithMessage(va_list ap, const dom::ErrNum errorNumber,
nsresult errorType);
};
/******************************************************************************

View File

@ -19,50 +19,55 @@
* be replaced with a string value when the error is reported.
*/
MSG_DEF(MSG_INVALID_ENUM_VALUE, 3, "{0} '{1}' is not a valid value for enumeration {2}.")
MSG_DEF(MSG_MISSING_ARGUMENTS, 1, "Not enough arguments to {0}.")
MSG_DEF(MSG_NOT_OBJECT, 1, "{0} is not an object.")
MSG_DEF(MSG_NOT_CALLABLE, 1, "{0} is not callable.")
MSG_DEF(MSG_DOES_NOT_IMPLEMENT_INTERFACE, 2, "{0} does not implement interface {1}.")
MSG_DEF(MSG_METHOD_THIS_DOES_NOT_IMPLEMENT_INTERFACE, 2, "'{0}' called on an object that does not implement interface {1}.")
MSG_DEF(MSG_METHOD_THIS_UNWRAPPING_DENIED, 1, "Permission to call '{0}' denied.")
MSG_DEF(MSG_GETTER_THIS_DOES_NOT_IMPLEMENT_INTERFACE, 2, "'{0}' getter called on an object that does not implement interface {1}.")
MSG_DEF(MSG_GETTER_THIS_UNWRAPPING_DENIED, 1, "Permission to call '{0}' getter denied.")
MSG_DEF(MSG_SETTER_THIS_DOES_NOT_IMPLEMENT_INTERFACE, 2, "'{0}' setter called on an object that does not implement interface {1}.")
MSG_DEF(MSG_SETTER_THIS_UNWRAPPING_DENIED, 1, "Permission to call '{0}' setter denied.")
MSG_DEF(MSG_THIS_DOES_NOT_IMPLEMENT_INTERFACE, 1, "\"this\" object does not implement interface {0}.")
MSG_DEF(MSG_NOT_IN_UNION, 2, "{0} could not be converted to any of: {1}.")
MSG_DEF(MSG_ILLEGAL_CONSTRUCTOR, 0, "Illegal constructor.")
MSG_DEF(MSG_CONSTRUCTOR_WITHOUT_NEW, 1, "Constructor {0} requires 'new'")
MSG_DEF(MSG_NO_INDEXED_SETTER, 1, "{0} doesn't have an indexed property setter.")
MSG_DEF(MSG_NO_NAMED_SETTER, 1, "{0} doesn't have a named property setter.")
MSG_DEF(MSG_ENFORCE_RANGE_NON_FINITE, 1, "Non-finite value is out of range for {0}.")
MSG_DEF(MSG_ENFORCE_RANGE_OUT_OF_RANGE, 1, "Value is out of range for {0}.")
MSG_DEF(MSG_NOT_SEQUENCE, 1, "{0} can't be converted to a sequence.")
MSG_DEF(MSG_NOT_DICTIONARY, 1, "{0} can't be converted to a dictionary.")
MSG_DEF(MSG_OVERLOAD_RESOLUTION_FAILED, 3, "Argument {0} is not valid for any of the {1}-argument overloads of {2}.")
MSG_DEF(MSG_GLOBAL_NOT_NATIVE, 0, "Global is not a native object.")
MSG_DEF(MSG_ENCODING_NOT_SUPPORTED, 1, "The given encoding '{0}' is not supported.")
MSG_DEF(MSG_DOM_ENCODING_NOT_UTF, 0, "The encoding must be utf-8, utf-16, or utf-16be.")
MSG_DEF(MSG_NOT_FINITE, 1, "{0} is not a finite floating-point value.")
MSG_DEF(MSG_INVALID_VERSION, 0, "0 (Zero) is not a valid database version.")
MSG_DEF(MSG_INVALID_BYTESTRING, 2, "Cannot convert string to ByteString because the character"
MSG_DEF(MSG_INVALID_ENUM_VALUE, 3, JSEXN_TYPEERR, "{0} '{1}' is not a valid value for enumeration {2}.")
MSG_DEF(MSG_MISSING_ARGUMENTS, 1, JSEXN_TYPEERR, "Not enough arguments to {0}.")
MSG_DEF(MSG_NOT_OBJECT, 1, JSEXN_TYPEERR, "{0} is not an object.")
MSG_DEF(MSG_NOT_CALLABLE, 1, JSEXN_TYPEERR, "{0} is not callable.")
MSG_DEF(MSG_DOES_NOT_IMPLEMENT_INTERFACE, 2, JSEXN_TYPEERR, "{0} does not implement interface {1}.")
MSG_DEF(MSG_METHOD_THIS_DOES_NOT_IMPLEMENT_INTERFACE, 2, JSEXN_TYPEERR, "'{0}' called on an object that does not implement interface {1}.")
MSG_DEF(MSG_METHOD_THIS_UNWRAPPING_DENIED, 1, JSEXN_TYPEERR, "Permission to call '{0}' denied.")
MSG_DEF(MSG_GETTER_THIS_DOES_NOT_IMPLEMENT_INTERFACE, 2, JSEXN_TYPEERR, "'{0}' getter called on an object that does not implement interface {1}.")
MSG_DEF(MSG_GETTER_THIS_UNWRAPPING_DENIED, 1, JSEXN_TYPEERR, "Permission to call '{0}' getter denied.")
MSG_DEF(MSG_SETTER_THIS_DOES_NOT_IMPLEMENT_INTERFACE, 2, JSEXN_TYPEERR, "'{0}' setter called on an object that does not implement interface {1}.")
MSG_DEF(MSG_SETTER_THIS_UNWRAPPING_DENIED, 1, JSEXN_TYPEERR, "Permission to call '{0}' setter denied.")
MSG_DEF(MSG_THIS_DOES_NOT_IMPLEMENT_INTERFACE, 1, JSEXN_TYPEERR, "\"this\" object does not implement interface {0}.")
MSG_DEF(MSG_NOT_IN_UNION, 2, JSEXN_TYPEERR, "{0} could not be converted to any of: {1}.")
MSG_DEF(MSG_ILLEGAL_CONSTRUCTOR, 0, JSEXN_TYPEERR, "Illegal constructor.")
MSG_DEF(MSG_CONSTRUCTOR_WITHOUT_NEW, 1, JSEXN_TYPEERR, "Constructor {0} requires 'new'")
MSG_DEF(MSG_NO_INDEXED_SETTER, 1, JSEXN_TYPEERR, "{0} doesn't have an indexed property setter.")
MSG_DEF(MSG_NO_NAMED_SETTER, 1, JSEXN_TYPEERR, "{0} doesn't have a named property setter.")
MSG_DEF(MSG_ENFORCE_RANGE_NON_FINITE, 1, JSEXN_TYPEERR, "Non-finite value is out of range for {0}.")
MSG_DEF(MSG_ENFORCE_RANGE_OUT_OF_RANGE, 1, JSEXN_TYPEERR, "Value is out of range for {0}.")
MSG_DEF(MSG_NOT_SEQUENCE, 1, JSEXN_TYPEERR, "{0} can't be converted to a sequence.")
MSG_DEF(MSG_NOT_DICTIONARY, 1, JSEXN_TYPEERR, "{0} can't be converted to a dictionary.")
MSG_DEF(MSG_OVERLOAD_RESOLUTION_FAILED, 3, JSEXN_TYPEERR, "Argument {0} is not valid for any of the {1}-argument overloads of {2}.")
MSG_DEF(MSG_GLOBAL_NOT_NATIVE, 0, JSEXN_TYPEERR, "Global is not a native object.")
MSG_DEF(MSG_ENCODING_NOT_SUPPORTED, 1, JSEXN_RANGEERR, "The given encoding '{0}' is not supported.")
MSG_DEF(MSG_DOM_ENCODING_NOT_UTF, 0, JSEXN_RANGEERR, "The encoding must be utf-8, utf-16, or utf-16be.")
MSG_DEF(MSG_DOM_DECODING_FAILED, 0, JSEXN_TYPEERR, "Decoding failed.")
MSG_DEF(MSG_NOT_FINITE, 1, JSEXN_TYPEERR, "{0} is not a finite floating-point value.")
MSG_DEF(MSG_INVALID_VERSION, 0, JSEXN_TYPEERR, "0 (Zero) is not a valid database version.")
MSG_DEF(MSG_INVALID_BYTESTRING, 2, JSEXN_TYPEERR, "Cannot convert string to ByteString because the character"
" at index {0} has value {1} which is greater than 255.")
MSG_DEF(MSG_NOT_DATE, 1, "{0} is not a date.")
MSG_DEF(MSG_INVALID_ADVANCE_COUNT, 0, "0 (Zero) is not a valid advance count.")
MSG_DEF(MSG_DEFINEPROPERTY_ON_GSP, 0, "Not allowed to define a property on the named properties object.")
MSG_DEF(MSG_INVALID_URL, 1, "{0} is not a valid URL.")
MSG_DEF(MSG_METADATA_NOT_CONFIGURED, 0, "Either size or lastModified should be true.")
MSG_DEF(MSG_INVALID_READ_SIZE, 0, "0 (Zero) is not a valid read size.")
MSG_DEF(MSG_HEADERS_IMMUTABLE, 0, "Headers are immutable and cannot be modified.")
MSG_DEF(MSG_INVALID_HEADER_NAME, 1, "{0} is an invalid header name.")
MSG_DEF(MSG_INVALID_HEADER_VALUE, 1, "{0} is an invalid header value.")
MSG_DEF(MSG_INVALID_HEADER_SEQUENCE, 0, "Headers require name/value tuples when being initialized by a sequence.")
MSG_DEF(MSG_PERMISSION_DENIED_TO_PASS_ARG, 1, "Permission denied to pass cross-origin object as {0}.")
MSG_DEF(MSG_MISSING_REQUIRED_DICTIONARY_MEMBER, 1, "Missing required {0}.")
MSG_DEF(MSG_INVALID_REQUEST_METHOD, 1, "Invalid request method {0}.")
MSG_DEF(MSG_REQUEST_BODY_CONSUMED_ERROR, 0, "Request body has already been consumed.")
MSG_DEF(MSG_RESPONSE_INVALID_STATUSTEXT_ERROR, 0, "Response statusText may not contain newline or carriage return.")
MSG_DEF(MSG_FETCH_FAILED, 0, "NetworkError when attempting to fetch resource.")
MSG_DEF(MSG_NO_BODY_ALLOWED_FOR_GET_AND_HEAD, 0, "HEAD or GET Request cannot have a body.")
MSG_DEF(MSG_DEFINE_NON_CONFIGURABLE_PROP_ON_WINDOW, 0, "Not allowed to define a non-configurable property on the WindowProxy object")
MSG_DEF(MSG_NOT_DATE, 1, JSEXN_TYPEERR, "{0} is not a date.")
MSG_DEF(MSG_INVALID_ADVANCE_COUNT, 0, JSEXN_TYPEERR, "0 (Zero) is not a valid advance count.")
MSG_DEF(MSG_DEFINEPROPERTY_ON_GSP, 0, JSEXN_TYPEERR, "Not allowed to define a property on the named properties object.")
MSG_DEF(MSG_INVALID_URL, 1, JSEXN_TYPEERR, "{0} is not a valid URL.")
MSG_DEF(MSG_METADATA_NOT_CONFIGURED, 0, JSEXN_TYPEERR, "Either size or lastModified should be true.")
MSG_DEF(MSG_INVALID_READ_SIZE, 0, JSEXN_TYPEERR, "0 (Zero) is not a valid read size.")
MSG_DEF(MSG_HEADERS_IMMUTABLE, 0, JSEXN_TYPEERR, "Headers are immutable and cannot be modified.")
MSG_DEF(MSG_INVALID_HEADER_NAME, 1, JSEXN_TYPEERR, "{0} is an invalid header name.")
MSG_DEF(MSG_INVALID_HEADER_VALUE, 1, JSEXN_TYPEERR, "{0} is an invalid header value.")
MSG_DEF(MSG_INVALID_HEADER_SEQUENCE, 0, JSEXN_TYPEERR, "Headers require name/value tuples when being initialized by a sequence.")
MSG_DEF(MSG_PERMISSION_DENIED_TO_PASS_ARG, 1, JSEXN_TYPEERR, "Permission denied to pass cross-origin object as {0}.")
MSG_DEF(MSG_MISSING_REQUIRED_DICTIONARY_MEMBER, 1, JSEXN_TYPEERR, "Missing required {0}.")
MSG_DEF(MSG_INVALID_REQUEST_METHOD, 1, JSEXN_TYPEERR, "Invalid request method {0}.")
MSG_DEF(MSG_REQUEST_BODY_CONSUMED_ERROR, 0, JSEXN_TYPEERR, "Request body has already been consumed.")
MSG_DEF(MSG_RESPONSE_INVALID_STATUSTEXT_ERROR, 0, JSEXN_TYPEERR, "Response statusText may not contain newline or carriage return.")
MSG_DEF(MSG_FETCH_FAILED, 0, JSEXN_TYPEERR, "NetworkError when attempting to fetch resource.")
MSG_DEF(MSG_NO_BODY_ALLOWED_FOR_GET_AND_HEAD, 0, JSEXN_TYPEERR, "HEAD or GET Request cannot have a body.")
MSG_DEF(MSG_DEFINE_NON_CONFIGURABLE_PROP_ON_WINDOW, 0, JSEXN_TYPEERR, "Not allowed to define a non-configurable property on the WindowProxy object")
MSG_DEF(MSG_INVALID_ZOOMANDPAN_VALUE_ERROR, 0, JSEXN_RANGEERR, "Invalid zoom and pan value.")
MSG_DEF(MSG_INVALID_TRANSFORM_ANGLE_ERROR, 0, JSEXN_RANGEERR, "Invalid transform angle.")
MSG_DEF(MSG_INVALID_RESPONSE_STATUSCODE_ERROR, 0, JSEXN_RANGEERR, "Invalid response status code.")
MSG_DEF(MSG_INVALID_REDIRECT_STATUSCODE_ERROR, 0, JSEXN_RANGEERR, "Invalid redirect status code.")

View File

@ -20,11 +20,12 @@ TextDecoder::Init(const nsAString& aLabel, const bool aFatal,
{
nsAutoCString encoding;
// Let encoding be the result of getting an encoding from label.
// If encoding is failure or replacement, throw a TypeError.
// If encoding is failure or replacement, throw a RangeError
// (https://encoding.spec.whatwg.org/#dom-textdecoder).
if (!EncodingUtils::FindEncodingForLabelNoReplacement(aLabel, encoding)) {
nsAutoString label(aLabel);
EncodingUtils::TrimSpaceCharacters(label);
aRv.ThrowTypeError(MSG_ENCODING_NOT_SUPPORTED, &label);
aRv.ThrowRangeError(MSG_ENCODING_NOT_SUPPORTED, &label);
return;
}
InitWithEncoding(encoding, aFatal);
@ -81,7 +82,7 @@ TextDecoder::Decode(const char* aInput, const int32_t aLength,
mDecoder->Reset();
if (rv == NS_OK_UDEC_MOREINPUT) {
if (mFatal) {
aRv.Throw(NS_ERROR_DOM_ENCODING_DECODE_ERR);
aRv.ThrowTypeError(MSG_DOM_DECODING_FAILED);
} else {
// Need to emit a decode error manually
// to simulate the EOF handling of the Encoding spec.
@ -91,7 +92,7 @@ TextDecoder::Decode(const char* aInput, const int32_t aLength,
}
if (NS_FAILED(rv)) {
aRv.Throw(NS_ERROR_DOM_ENCODING_DECODE_ERR);
aRv.ThrowTypeError(MSG_DOM_DECODING_FAILED);
}
}

View File

@ -18,16 +18,16 @@ TextEncoder::Init(const nsAString& aEncoding, ErrorResult& aRv)
// Let encoding be the result of getting an encoding from label.
// If encoding is failure, or is none of utf-8, utf-16, and utf-16be,
// throw a TypeError.
// throw a RangeError (https://encoding.spec.whatwg.org/#dom-textencoder).
if (!EncodingUtils::FindEncodingForLabel(label, mEncoding)) {
aRv.ThrowTypeError(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.ThrowTypeError(MSG_DOM_ENCODING_NOT_UTF);
aRv.ThrowRangeError(MSG_DOM_ENCODING_NOT_UTF);
return;
}

View File

@ -35,7 +35,7 @@ function testBOMEncodingUTF8() {
// test valid encoding provided with invalid byte OM also provided.
data = [0xFF, 0xFE, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27];
testBOMCharset({encoding: "utf-8", fatal: true, data: data, error: "EncodingError",
testBOMCharset({encoding: "utf-8", fatal: true, data: data, error: "TypeError",
msg: "valid utf-8 encoding provided with invalid utf-8 fatal BOM test."});
// test valid encoding provided with invalid byte OM also provided.
@ -46,7 +46,7 @@ function testBOMEncodingUTF8() {
// test empty encoding provided with invalid byte OM also provided.
data = [0xFF, 0xFE, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27];
testBOMCharset({encoding: "", data: data, error: "TypeError",
testBOMCharset({encoding: "", data: data, error: "RangeError",
msg: "empty encoding provided with invalid utf-8 BOM test."});
}
@ -88,7 +88,7 @@ function testMoreBOMEncoding() {
// Testing user provided encoding is UTF-8 & bom encoding is utf-16be
data = [0xFE, 0xFF, 0x22, 0xd0, 0x92, 0xd1, 0x81, 0xd0, 0xb5, 0x20, 0xd1, 0x81, 0xd1, 0x87, 0xd0, 0xb0, 0xd1, 0x81, 0xd1, 0x82, 0xd0, 0xbb, 0xd0, 0xb8, 0xd0, 0xb2, 0xd1, 0x8b, 0xd0, 0xb5, 0x20, 0xd1, 0x81, 0xd0, 0xb5, 0xd0, 0xbc, 0xd1, 0x8c, 0xd0, 0xb8, 0x20, 0xd0, 0xbf, 0xd0, 0xbe, 0xd1, 0x85, 0xd0, 0xbe, 0xd0, 0xb6, 0xd0, 0xb8, 0x20, 0xd0, 0xb4, 0xd1, 0x80, 0xd1, 0x83, 0xd0, 0xb3, 0x20, 0xd0, 0xbd, 0xd0, 0xb0, 0x20, 0xd0, 0xb4, 0xd1, 0x80, 0xd1, 0x83, 0xd0, 0xb3, 0xd0, 0xb0, 0x2c, 0x20, 0xd0, 0xba, 0xd0, 0xb0, 0xd0, 0xb6, 0xd0, 0xb4, 0xd0, 0xb0, 0xd1, 0x8f, 0x20, 0xd0, 0xbd, 0xd0, 0xb5, 0xd1, 0x81, 0xd1, 0x87, 0xd0, 0xb0, 0xd1, 0x81, 0xd1, 0x82, 0xd0, 0xbb, 0xd0, 0xb8, 0xd0, 0xb2, 0xd0, 0xb0, 0xd1, 0x8f, 0x20, 0xd1, 0x81, 0xd0, 0xb5, 0xd0, 0xbc, 0xd1, 0x8c, 0xd1, 0x8f, 0x20, 0xd0, 0xbd, 0xd0, 0xb5, 0xd1, 0x81, 0xd1, 0x87, 0xd0, 0xb0, 0xd1, 0x81, 0xd1, 0x82, 0xd0, 0xbb, 0xd0, 0xb8, 0xd0, 0xb2, 0xd0, 0xb0, 0x20, 0xd0, 0xbf, 0xd0, 0xbe, 0x2d, 0xd1, 0x81, 0xd0, 0xb2, 0xd0, 0xbe, 0xd0, 0xb5, 0xd0, 0xbc, 0xd1, 0x83, 0x2e, 0x22];
testBOMCharset({encoding: "utf-8", fatal: true, data: data, error: "EncodingError",
testBOMCharset({encoding: "utf-8", fatal: true, data: data, error: "TypeError",
msg: "test decoder invalid BOM encoding for valid utf-8 fatal provided label."});
testBOMCharset({encoding: "utf-8", data: data, expected: "\ufffd\ufffd" + expectedString,
@ -104,7 +104,7 @@ function testMoreBOMEncoding() {
+ "\u03B0\u03B1\u03B2\u03B3\u03B4\u03B5\u03B6\u03B7\u03B8\u03B9\u03BA\u03BB\u03BC\u03BD\u03BE\u03BF"
+ "\u03C0\u03C1\u03C2\u03C3\u03C4\u03C5\u03C6\u03C7\u03C8\u03C9\u03CA\u03CB\u03CC\u03CD\u03CE";
testBOMCharset({encoding: "greek", fatal: true, data: data, error: "EncodingError",
testBOMCharset({encoding: "greek", fatal: true, data: data, error: "TypeError",
msg: "test decoder encoding provided with invalid BOM encoding for greek."});
testBOMCharset({encoding: "greek", data: data, expected: expectedString,

View File

@ -68,25 +68,38 @@ function testConstructorFatalOption(data, expectedString)
function testConstructorEncodingOption(aData, aExpectedString)
{
function errorMessage(encoding) {
return `The given encoding '${String(encoding).trim()}' is not supported.`;
}
// valid encoding passed
testCharset({encoding: "iso-8859-11", input: aData, expected: aExpectedString,
var encoding = "iso-8859-11";
testCharset({encoding: encoding, input: aData, expected: aExpectedString,
msg: "decoder testing constructor valid encoding."});
// invalid encoding passed
testCharset({encoding: "asdfasdf", input: aData, error: "TypeError",
msg: "constructor encoding, invalid encoding test."});
// passing spaces for encoding
testCharset({encoding: " ", input: aData, error: "TypeError",
encoding = " ";
testCharset({encoding: encoding, input: aData, error: "RangeError",
errorMessage: errorMessage(encoding),
msg: "constructor encoding, spaces encoding test."});
// passing null for encoding
testCharset({encoding: null, input: aData, error: "TypeError",
// invalid encoding passed
encoding = "asdfasdf";
testCharset({encoding: encoding, input: aData, error: "RangeError",
errorMessage: errorMessage(encoding),
msg: "constructor encoding, invalid encoding test."});
// null encoding passed
encoding = null;
testCharset({encoding: encoding, input: aData, error: "RangeError",
errorMessage: errorMessage(encoding),
msg: "constructor encoding, \"null\" encoding test."});
// empty encoding passed
testCharset({encoding: "", input: aData, error: "TypeError",
msg: "constuctor encoding, empty encoding test."});
encoding = "";
testCharset({encoding: encoding, input: aData, error: "RangeError",
errorMessage: errorMessage(encoding),
msg: "constructor encoding, empty encoding test."});
// replacement character test
aExpectedString = "\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd"
@ -170,8 +183,8 @@ function testDecodeStreamOption(data, expectedString)
], msg: "decode() stream test utf-8."});
testCharset({encoding: "utf-8", fatal: true, array: [
{input: [0xC2], error: "EncodingError"},
{input: [0x80], error: "EncodingError"},
{input: [0xC2], error: "TypeError"},
{input: [0x80], error: "TypeError"},
], msg: "decode() stream test utf-8 fatal."});
}
@ -351,7 +364,7 @@ function testDecoderGetEncoding()
{encoding: "utf-16le", labels: ["utf-16", "utf-16le"]},
{encoding: "utf-16be", labels: ["utf-16be"]},
{encoding: "x-user-defined", labels: ["x-user-defined"]},
{error: "TypeError", labels: ["x-windows-949", "\u0130SO-8859-1", "csiso2022kr", "iso-2022-kr", "iso-2022-cn", "iso-2022-cn-ext", "replacement", "hz-gb-2312"]},
{error: "RangeError", labels: ["x-windows-949", "\u0130SO-8859-1", "csiso2022kr", "iso-2022-kr", "iso-2022-cn", "iso-2022-cn-ext", "replacement", "hz-gb-2312"]},
];
for (var le of labelEncodings) {
@ -376,6 +389,9 @@ function testCharset(test)
var decoder = new TextDecoder(test.encoding, fatal);
} catch (e) {
assert_equals(e.name, test.error, test.msg + " error thrown from the constructor.");
if (test.errorMessage) {
assert_equals(e.message, test.errorMessage, test.msg + " error thrown from the constructor.");
}
return;
}
@ -439,7 +455,7 @@ function testInvalid2022JP()
// decode() should never throw unless {fatal: true} is specified
(new TextDecoder("iso-2022-jp")).decode(new Uint8Array(input));
} catch (e) {
if (e.name !== "EncodingError") {
if (e.name !== "TypeError") {
throw e;
}
failureCount++;

View File

@ -90,31 +90,44 @@ function testEncodeUTF16ToUTF16()
function testConstructorEncodingOption(aData, aExpectedString)
{
function errorMessage(encoding) {
return `The given encoding '${String(encoding).trim()}' is not supported.`;
}
// valid encoding passed
testSingleString({encoding: "UTF-8", input: aData, expected: aExpectedString,
var encoding = "UTF-8";
testSingleString({encoding: encoding, input: aData, expected: aExpectedString,
msg: "testing encoding with valid utf-8 encoding."});
// passing spaces for encoding
testSingleString({encoding: " ", input: aData, error: "TypeError",
encoding = " ";
testSingleString({encoding: encoding, input: aData, error: "RangeError",
errorMessage: errorMessage(encoding),
msg: "constructor encoding, spaces encoding test."});
// invalid encoding passed
testSingleString({encoding: "asdfasdf", input: aData, error: "TypeError",
encoding = "asdfasdf";
testSingleString({encoding: encoding, input: aData, error: "RangeError",
errorMessage: errorMessage(encoding),
msg: "constructor encoding, invalid encoding test."});
// null encoding passed
testSingleString({encoding: null, input: aData, error: "TypeError",
encoding = null;
testSingleString({encoding: encoding, input: aData, error: "RangeError",
errorMessage: errorMessage(encoding),
msg: "constructor encoding, \"null\" encoding test."});
// null encoding passed
testSingleString({encoding: "", input: aData, error: "TypeError",
// empty encoding passed
encoding = "";
testSingleString({encoding: encoding, input: aData, error: "RangeError",
errorMessage: errorMessage(encoding),
msg: "constructor encoding, empty encoding test."});
}
function testEncodingValues(aData, aExpectedString)
{
var encoding = "ISO-8859-11";
testSingleString({encoding: aData, input: encoding, error: "TypeError",
testSingleString({encoding: aData, input: encoding, error: "RangeError",
msg: "encoder encoding values test."});
}
@ -136,7 +149,10 @@ function testSingleString(test)
var stream = test.stream ? {stream: true} : null;
outText = (new TextEncoder(test.encoding)).encode(test.input, stream);
} catch (e) {
assert_equals(e.name, test.error, test.msg);
assert_equals(e.name, test.error, test.msg + " error thrown from the constructor.");
if (test.errorMessage) {
assert_equals(e.message, test.errorMessage, test.msg + " error thrown from the constructor.");
}
return;
}
assert_true(!test.error, test.msg);

View File

@ -43,7 +43,7 @@ test(
bad.forEach(
function(t) {
assert_throws({name: 'EncodingError'}, function () {
assert_throws({name: 'TypeError'}, function () {
new TextDecoder(t.encoding, {fatal: true}).decode(new Uint8Array(t.input));
});
});
@ -186,15 +186,15 @@ test(
test(
function () {
assert_throws({name: 'EncodingError'}, function() { new TextDecoder("utf-8", {fatal: true}).decode(new Uint8Array([0xff])); });
assert_throws({name: 'TypeError'}, function() { new TextDecoder("utf-8", {fatal: true}).decode(new Uint8Array([0xff])); });
// This should not hang:
new TextDecoder("utf-8").decode(new Uint8Array([0xff]));
assert_throws({name: 'EncodingError'}, function() { new TextDecoder("utf-16", {fatal: true}).decode(new Uint8Array([0x00])); });
assert_throws({name: 'TypeError'}, function() { new TextDecoder("utf-16", {fatal: true}).decode(new Uint8Array([0x00])); });
// This should not hang:
new TextDecoder("utf-16").decode(new Uint8Array([0x00]));
assert_throws({name: 'EncodingError'}, function() { new TextDecoder("utf-16be", {fatal: true}).decode(new Uint8Array([0x00])); });
assert_throws({name: 'TypeError'}, function() { new TextDecoder("utf-16be", {fatal: true}).decode(new Uint8Array([0x00])); });
// This should not hang:
new TextDecoder("utf-16be").decode(new Uint8Array([0x00]));
},
@ -215,7 +215,7 @@ test(
legacy_encodings.forEach(function(encoding) {
assert_equals(new TextDecoder(encoding).encoding, encoding);
assert_throws({name: 'TypeError'}, function() { new TextEncoder(encoding); });
assert_throws({name: 'RangeError'}, function() { new TextEncoder(encoding); });
});
},
"Non-UTF encodings supported only for decode, not encode"

View File

@ -95,7 +95,7 @@ Response::Redirect(const GlobalObject& aGlobal, const nsAString& aUrl,
}
if (aStatus != 301 && aStatus != 302 && aStatus != 303 && aStatus != 307 && aStatus != 308) {
aRv.Throw(NS_ERROR_RANGE_ERR);
aRv.ThrowRangeError(MSG_INVALID_REDIRECT_STATUSCODE_ERROR);
return nullptr;
}
@ -122,7 +122,7 @@ Response::Constructor(const GlobalObject& aGlobal,
const ResponseInit& aInit, ErrorResult& aRv)
{
if (aInit.mStatus < 200 || aInit.mStatus > 599) {
aRv.Throw(NS_ERROR_RANGE_ERR);
aRv.ThrowRangeError(MSG_INVALID_RESPONSE_STATUSCODE_ERROR);
return nullptr;
}

View File

@ -471,7 +471,7 @@ SVGSVGElement::SetZoomAndPan(uint16_t aZoomAndPan, ErrorResult& rv)
return;
}
rv.Throw(NS_ERROR_RANGE_ERR);
rv.ThrowRangeError(MSG_INVALID_ZOOMANDPAN_VALUE_ERROR, &aZoomAndPan);
}
//----------------------------------------------------------------------

View File

@ -260,7 +260,7 @@ SVGTransform::SetSkewX(float angle, ErrorResult& rv)
}
if (!IsFinite(tan(angle * kRadPerDegree))) {
rv.Throw(NS_ERROR_RANGE_ERR);
rv.ThrowRangeError(MSG_INVALID_TRANSFORM_ANGLE_ERROR);
return;
}
@ -283,7 +283,7 @@ SVGTransform::SetSkewY(float angle, ErrorResult& rv)
}
if (!IsFinite(tan(angle * kRadPerDegree))) {
rv.Throw(NS_ERROR_RANGE_ERR);
rv.ThrowRangeError(MSG_INVALID_TRANSFORM_ANGLE_ERROR);
return;
}

View File

@ -59,7 +59,7 @@ SVGViewElement::SetZoomAndPan(uint16_t aZoomAndPan, ErrorResult& rv)
return;
}
rv.Throw(NS_ERROR_RANGE_ERR);
rv.ThrowRangeError(MSG_INVALID_ZOOMANDPAN_VALUE_ERROR);
}
//----------------------------------------------------------------------

View File

@ -1,20 +0,0 @@
[api-replacement-encodings.html]
type: testharness
[The "replacement" label should not be a known encoding.]
expected: FAIL
[Label for "replacement" should be rejected by API: csiso2022kr]
expected: FAIL
[Label for "replacement" should be rejected by API: hz-gb-2312]
expected: FAIL
[Label for "replacement" should be rejected by API: iso-2022-cn]
expected: FAIL
[Label for "replacement" should be rejected by API: iso-2022-cn-ext]
expected: FAIL
[Label for "replacement" should be rejected by API: iso-2022-kr]
expected: FAIL

View File

@ -1,8 +0,0 @@
[textdecoder-fatal-streaming.html]
type: testharness
[Fatal flag, non-streaming cases]
expected: FAIL
[Fatal flag, streaming cases]
expected: FAIL

View File

@ -1,104 +0,0 @@
[textdecoder-fatal.html]
type: testharness
[Fatal flag: utf-8 - invalid code]
expected: FAIL
[Fatal flag: utf-8 - ends early]
expected: FAIL
[Fatal flag: utf-8 - ends early 2]
expected: FAIL
[Fatal flag: utf-8 - invalid trail]
expected: FAIL
[Fatal flag: utf-8 - invalid trail 2]
expected: FAIL
[Fatal flag: utf-8 - invalid trail 3]
expected: FAIL
[Fatal flag: utf-8 - invalid trail 4]
expected: FAIL
[Fatal flag: utf-8 - invalid trail 5]
expected: FAIL
[Fatal flag: utf-8 - invalid trail 6]
expected: FAIL
[Fatal flag: utf-8 - > 0x10FFFF]
expected: FAIL
[Fatal flag: utf-8 - obsolete lead byte]
expected: FAIL
[Fatal flag: utf-8 - overlong U+0000 - 2 bytes]
expected: FAIL
[Fatal flag: utf-8 - overlong U+0000 - 3 bytes]
expected: FAIL
[Fatal flag: utf-8 - overlong U+0000 - 4 bytes]
expected: FAIL
[Fatal flag: utf-8 - overlong U+0000 - 5 bytes]
expected: FAIL
[Fatal flag: utf-8 - overlong U+0000 - 6 bytes]
expected: FAIL
[Fatal flag: utf-8 - overlong U+007F - 2 bytes]
expected: FAIL
[Fatal flag: utf-8 - overlong U+007F - 3 bytes]
expected: FAIL
[Fatal flag: utf-8 - overlong U+007F - 4 bytes]
expected: FAIL
[Fatal flag: utf-8 - overlong U+007F - 5 bytes]
expected: FAIL
[Fatal flag: utf-8 - overlong U+007F - 6 bytes]
expected: FAIL
[Fatal flag: utf-8 - overlong U+07FF - 3 bytes]
expected: FAIL
[Fatal flag: utf-8 - overlong U+07FF - 4 bytes]
expected: FAIL
[Fatal flag: utf-8 - overlong U+07FF - 5 bytes]
expected: FAIL
[Fatal flag: utf-8 - overlong U+07FF - 6 bytes]
expected: FAIL
[Fatal flag: utf-8 - overlong U+FFFF - 4 bytes]
expected: FAIL
[Fatal flag: utf-8 - overlong U+FFFF - 5 bytes]
expected: FAIL
[Fatal flag: utf-8 - overlong U+FFFF - 6 bytes]
expected: FAIL
[Fatal flag: utf-8 - overlong U+10FFFF - 5 bytes]
expected: FAIL
[Fatal flag: utf-8 - overlong U+10FFFF - 6 bytes]
expected: FAIL
[Fatal flag: utf-8 - lead surrogate]
expected: FAIL
[Fatal flag: utf-8 - trail surrogate]
expected: FAIL
[Fatal flag: utf-8 - surrogate pair]
expected: FAIL
[Fatal flag: utf-16le - truncated code unit]
expected: FAIL

View File

@ -1,17 +0,0 @@
[textdecoder-utf16-surrogates.html]
type: testharness
[utf-16le - lone surrogate lead (fatal flag set)]
expected: FAIL
[utf-16le - lone surrogate trail (fatal flag set)]
expected: FAIL
[utf-16le - unmatched surrogate lead (fatal flag set)]
expected: FAIL
[utf-16le - unmatched surrogate trail (fatal flag set)]
expected: FAIL
[utf-16le - swapped surrogate pair (fatal flag set)]
expected: FAIL

View File

@ -1,110 +0,0 @@
[textencoder-constructor-non-utf.html]
type: testharness
[Non-UTF encodings supported only for decode, not encode: ibm866]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: iso-8859-2]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: iso-8859-3]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: iso-8859-4]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: iso-8859-5]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: iso-8859-6]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: iso-8859-7]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: iso-8859-8]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: iso-8859-8-i]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: iso-8859-10]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: iso-8859-13]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: iso-8859-14]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: iso-8859-15]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: iso-8859-16]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: koi8-r]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: koi8-u]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: macintosh]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: windows-874]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: windows-1250]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: windows-1251]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: windows-1252]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: windows-1253]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: windows-1254]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: windows-1255]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: windows-1256]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: windows-1257]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: windows-1258]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: x-mac-cyrillic]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: gbk]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: gb18030]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: big5]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: euc-jp]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: iso-2022-jp]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: shift_jis]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: euc-kr]
expected: FAIL
[Non-UTF encodings supported only for decode, not encode: x-user-defined]
expected: FAIL

View File

@ -337,7 +337,7 @@ AbstractFile.read = function read(path, bytes, options = {}) {
let decoder;
try {
decoder = new TextDecoder(options.encoding);
} catch (ex if ex instanceof TypeError) {
} catch (ex if ex instanceof RangeError) {
throw OS.File.Error.invalidArgument("Decode");
}
return decoder.decode(buffer);

View File

@ -497,13 +497,11 @@
ERROR(NS_ERROR_RANGE_ERR, FAILURE(27)),
/* StringEncoding API errors from http://wiki.whatwg.org/wiki/StringEncoding */
ERROR(NS_ERROR_DOM_ENCODING_NOT_SUPPORTED_ERR, FAILURE(28)),
ERROR(NS_ERROR_DOM_ENCODING_NOT_UTF_ERR, FAILURE(29)),
ERROR(NS_ERROR_DOM_ENCODING_DECODE_ERR, FAILURE(30)),
ERROR(NS_ERROR_DOM_INVALID_POINTER_ERR, FAILURE(31)),
ERROR(NS_ERROR_DOM_INVALID_POINTER_ERR, FAILURE(29)),
/* WebCrypto API errors from http://www.w3.org/TR/WebCryptoAPI/ */
ERROR(NS_ERROR_DOM_UNKNOWN_ERR, FAILURE(32)),
ERROR(NS_ERROR_DOM_DATA_ERR, FAILURE(33)),
ERROR(NS_ERROR_DOM_OPERATION_ERR, FAILURE(34)),
ERROR(NS_ERROR_DOM_UNKNOWN_ERR, FAILURE(30)),
ERROR(NS_ERROR_DOM_DATA_ERR, FAILURE(31)),
ERROR(NS_ERROR_DOM_OPERATION_ERR, FAILURE(32)),
/* DOM error codes defined by us */
ERROR(NS_ERROR_DOM_SECMAN_ERR, FAILURE(1001)),
ERROR(NS_ERROR_DOM_WRONG_TYPE_ERR, FAILURE(1002)),