summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/tests/unit/text_encoding_test.ts15
-rw-r--r--op_crates/web/08_text_encoding.js2
2 files changed, 16 insertions, 1 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(() => {
diff --git a/op_crates/web/08_text_encoding.js b/op_crates/web/08_text_encoding.js
index 59c1aba8f..cf435adc5 100644
--- a/op_crates/web/08_text_encoding.js
+++ b/op_crates/web/08_text_encoding.js
@@ -105,7 +105,7 @@
if (rem === 1 || /[^+/0-9A-Za-z]/.test(s)) {
throw new DOMException(
"The string to be decoded is not correctly encoded",
- "DataDecodeError",
+ "InvalidCharacterError",
);
}