diff options
author | gorogoroumaru <zokutyou2@gmail.com> | 2021-01-11 07:15:32 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-11 09:15:32 +1100 |
commit | b0821fe9ce017ea1fdec191622f27c31af9c4f0f (patch) | |
tree | 7ab8c24d7a01f2dae996c1194d899ada90ce6ff7 /cli/tests/unit | |
parent | 1a6ce29f3d11e5f0d0d022914e3f9fbcfa487294 (diff) |
fix(op_crate/web): fix atob to throw spec aligned DOMException (#8798)
Diffstat (limited to 'cli/tests/unit')
-rw-r--r-- | cli/tests/unit/text_encoding_test.ts | 15 |
1 files changed, 15 insertions, 0 deletions
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(() => { |