Bug 851982 - Regression test. r=smontagu

This commit is contained in:
Masatoshi Kimura 2013-06-21 00:54:40 +09:00
parent cfd5ee2a8a
commit 8f749ee3ff
2 changed files with 49 additions and 1 deletions

View File

@ -13,7 +13,7 @@
<div id="log"></div>
<script>
SimpleTest.expectAssertions(0, 2);
//SimpleTest.expectAssertions(0, 2);
setup({explicit_done: true});
runTest();

View File

@ -43,6 +43,7 @@ function runTextDecoderOptions()
testDecodeABVOption(data, expectedString);
}, "testDecodeABVOption");
test(testDecoderForThaiEncoding, "testDecoderForThaiEncoding");
test(testInvalid2022JP, "testInvalid2022JP");
}
/*
@ -401,3 +402,50 @@ function testCharset(test)
}
assert_true(!test.error, test.msg);
}
function testInvalid2022JP()
{
var inputs = [
[0x80],
[0x1b, 0xFF],
[0x1b, 0x28, 0xFF],
[0x1b, 0x24, 0x80],
[0x1b, 0x24, 0x28, 0x80],
[0x1b, 0x28, 0x4a, 0xFF],
[0x1b, 0x28, 0x49, 0xFF],
[0x1b, 0x24, 0x40, 0x20],
[0x1b, 0x24, 0x41, 0x20],
[0x1b, 0x24, 0x42, 0x20],
[0x1b, 0x24, 0x28, 0x43, 0x20],
[0x1b, 0x24, 0x28, 0x44, 0x20],
[0x1b, 0x24, 0x40, 0x80, 0x21],
[0x1b, 0x24, 0x41, 0xFF, 0x21],
[0x1b, 0x24, 0x42, 0x80, 0x21],
[0x1b, 0x24, 0x28, 0x43, 0xFF, 0x21],
[0x1b, 0x24, 0x28, 0x44, 0x80, 0x21],
[0x1b, 0x24, 0x40, 0x21, 0x20],
[0x1b, 0x24, 0x41, 0x21, 0x20],
[0x1b, 0x24, 0x42, 0x21, 0x20],
[0x1b, 0x24, 0x28, 0x43, 0x21, 0x20],
[0x1b, 0x24, 0x28, 0x44, 0x21, 0x20],
[0x1b, 0x2e, 0xFF],
[0x1b, 0x4e, 0x20],
[0x1b, 0x4e, 0x7F],
[0x1b, 0x2e, 0x41, 0x1b, 0x4e, 0x80],
[0x1b, 0x2e, 0x41, 0x1b, 0x4e, 0xFF],
];
var failureCount = 0;
inputs.forEach(function(input) {
try {
// decode() should never throw unless {fatal: true} is specified
new TextDecoder("iso-2022-jp").decode(new Uint8Array(input));
} catch (e) {
if (e.name !== "EncodingError") {
throw e;
}
failureCount++;
}
});
assert_equals(failureCount, 0, failureCount + " of " + inputs.length + " tests failed");
}