From 623ac9e6df660b758aa3da281b6ff2b4db265ef0 Mon Sep 17 00:00:00 2001 From: Leonard Ginters Date: Mon, 19 Oct 2020 23:56:29 +0200 Subject: fix(op_crates/web): TextEncoder should throw RangeError (#8039) This commit changes error type thrown by TextEncoder, when provided encoding is not supported matching Chromium behavior. --- cli/tests/unit/text_encoding_test.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'cli/tests/unit/text_encoding_test.ts') diff --git a/cli/tests/unit/text_encoding_test.ts b/cli/tests/unit/text_encoding_test.ts index 23799fba3..6a9274d02 100644 --- a/cli/tests/unit/text_encoding_test.ts +++ b/cli/tests/unit/text_encoding_test.ts @@ -112,6 +112,17 @@ unitTest(function textDecoderErrorEncoding(): void { assert(didThrow); }); +unitTest(function textDecoderHandlesNotFoundInternalDecoder() { + let didThrow = false; + try { + new TextDecoder("gbk"); + } catch (e) { + didThrow = true; + assert(e instanceof RangeError); + } + assert(didThrow); +}); + unitTest(function textEncoder(): void { const fixture = "𝓽𝓮𝔁𝓽"; const encoder = new TextEncoder(); -- cgit v1.2.3