From b0821fe9ce017ea1fdec191622f27c31af9c4f0f Mon Sep 17 00:00:00 2001 From: gorogoroumaru Date: Mon, 11 Jan 2021 07:15:32 +0900 Subject: fix(op_crate/web): fix atob to throw spec aligned DOMException (#8798) --- cli/tests/unit/text_encoding_test.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'cli/tests') diff --git a/cli/tests/unit/text_encoding_test.ts b/cli/tests/unit/text_encoding_test.ts index 5ae64cbce..4b7f75232 100644 --- a/cli/tests/unit/text_encoding_test.ts +++ b/cli/tests/unit/text_encoding_test.ts @@ -50,6 +50,21 @@ unitTest(function atobThrows2(): void { assert(threw); }); +unitTest(function atobThrows3(): void { + let threw = false; + try { + atob("foobar!!"); + } catch (e) { + if ( + e instanceof DOMException && + e.toString().startsWith("InvalidCharacterError:") + ) { + threw = true; + } + } + assert(threw); +}); + unitTest(function btoaFailed(): void { const text = "你好"; assertThrows(() => { -- cgit v1.2.3