mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 801487 - Change some exceptions from EncodingError to TypeError. r=sicking
This commit is contained in:
parent
32a0cfd0f7
commit
c95b61723c
@ -31,11 +31,10 @@ TextDecoder::Init(const nsAString& aEncoding,
|
||||
return;
|
||||
}
|
||||
|
||||
// Run the steps to get an encoding from Encoding.
|
||||
// Let encoding be the result of getting an encoding from label.
|
||||
// If encoding is failure, throw a TypeError.
|
||||
if (!EncodingUtils::FindEncodingForLabel(label, mEncoding)) {
|
||||
// If the steps result in failure,
|
||||
// throw a "EncodingError" exception and terminate these steps.
|
||||
aRv.Throw(NS_ERROR_DOM_ENCODING_NOT_SUPPORTED_ERR);
|
||||
aRv.ThrowTypeError(MSG_ENCODING_NOT_SUPPORTED, &label);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -18,21 +18,18 @@ TextEncoder::Init(const nsAString& aEncoding,
|
||||
nsAutoString label(aEncoding);
|
||||
EncodingUtils::TrimSpaceCharacters(label);
|
||||
|
||||
// Run the steps to get an encoding from Encoding.
|
||||
// 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.
|
||||
if (!EncodingUtils::FindEncodingForLabel(label, mEncoding)) {
|
||||
// If the steps result in failure,
|
||||
// throw an "EncodingError" exception and terminate these steps.
|
||||
aRv.Throw(NS_ERROR_DOM_ENCODING_NOT_SUPPORTED_ERR);
|
||||
aRv.ThrowTypeError(MSG_ENCODING_NOT_SUPPORTED, &label);
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, if the Name of the returned encoding is not one of
|
||||
// "utf-8", "utf-16", or "utf-16be" throw an "EncodingError" exception
|
||||
// and terminate these steps.
|
||||
if (PL_strcasecmp(mEncoding, "utf-8") &&
|
||||
PL_strcasecmp(mEncoding, "utf-16le") &&
|
||||
PL_strcasecmp(mEncoding, "utf-16be")) {
|
||||
aRv.Throw(NS_ERROR_DOM_ENCODING_NOT_UTF_ERR);
|
||||
aRv.ThrowTypeError(MSG_DOM_ENCODING_NOT_UTF);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -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: "EncodingError",
|
||||
testBOMCharset({encoding: "", data: data, error: "TypeError",
|
||||
msg: "empty encoding provided with invalid utf-8 BOM test."});
|
||||
}
|
||||
|
||||
|
@ -72,19 +72,19 @@ function testConstructorEncodingOption(aData, aExpectedString)
|
||||
msg: "decoder testing constructor valid encoding."});
|
||||
|
||||
// invalid encoding passed
|
||||
testCharset({encoding: "asdfasdf", input: aData, error: "EncodingError",
|
||||
testCharset({encoding: "asdfasdf", input: aData, error: "TypeError",
|
||||
msg: "constructor encoding, invalid encoding test."});
|
||||
|
||||
// passing spaces for encoding
|
||||
testCharset({encoding: " ", input: aData, error: "EncodingError",
|
||||
testCharset({encoding: " ", input: aData, error: "TypeError",
|
||||
msg: "constructor encoding, spaces encoding test."});
|
||||
|
||||
// passing null for encoding
|
||||
testCharset({encoding: null, input: aData, error: "EncodingError",
|
||||
testCharset({encoding: null, input: aData, error: "TypeError",
|
||||
msg: "constructor encoding, \"null\" encoding test."});
|
||||
|
||||
// empty encoding passed
|
||||
testCharset({encoding: "", input: aData, error: "EncodingError",
|
||||
testCharset({encoding: "", input: aData, error: "TypeError",
|
||||
msg: "constuctor encoding, empty encoding test."});
|
||||
|
||||
// replacement character test
|
||||
@ -337,7 +337,7 @@ function testDecoderGetEncoding()
|
||||
{encoding: "utf-16", labels: ["utf-16", "utf-16le"]},
|
||||
{encoding: "utf-16be", labels: ["utf-16be"]},
|
||||
{encoding: "x-user-defined", labels: ["x-user-defined"]},
|
||||
{error: "EncodingError", labels: ["x-windows-949", "\u0130SO-8859-1"]},
|
||||
{error: "TypeError", labels: ["x-windows-949", "\u0130SO-8859-1"]},
|
||||
];
|
||||
|
||||
for (var le of labelEncodings) {
|
||||
|
@ -95,26 +95,26 @@ function testConstructorEncodingOption(aData, aExpectedString)
|
||||
msg: "testing encoding with valid utf-8 encoding."});
|
||||
|
||||
// passing spaces for encoding
|
||||
testSingleString({encoding: " ", input: aData, error: "EncodingError",
|
||||
testSingleString({encoding: " ", input: aData, error: "TypeError",
|
||||
msg: "constructor encoding, spaces encoding test."});
|
||||
|
||||
// invalid encoding passed
|
||||
testSingleString({encoding: "asdfasdf", input: aData, error: "EncodingError",
|
||||
testSingleString({encoding: "asdfasdf", input: aData, error: "TypeError",
|
||||
msg: "constructor encoding, invalid encoding test."});
|
||||
|
||||
// null encoding passed
|
||||
testSingleString({encoding: null, input: aData, error: "EncodingError",
|
||||
testSingleString({encoding: null, input: aData, error: "TypeError",
|
||||
msg: "constructor encoding, \"null\" encoding test."});
|
||||
|
||||
// null encoding passed
|
||||
testSingleString({encoding: "", input: aData, error: "EncodingError",
|
||||
testSingleString({encoding: "", input: aData, error: "TypeError",
|
||||
msg: "constructor encoding, empty encoding test."});
|
||||
}
|
||||
|
||||
function testEncodingValues(aData, aExpectedString)
|
||||
{
|
||||
var encoding = "ISO-8859-11";
|
||||
testSingleString({encoding: aData, input: encoding, error: "EncodingError",
|
||||
testSingleString({encoding: aData, input: encoding, error: "TypeError",
|
||||
msg: "encoder encoding values test."});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user