mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -05:00
fix(op_crate/web): fix atob to throw spec aligned DOMException (#8798)
This commit is contained in:
parent
1a6ce29f3d
commit
b0821fe9ce
2 changed files with 16 additions and 1 deletions
|
@ -50,6 +50,21 @@ unitTest(function atobThrows2(): void {
|
||||||
assert(threw);
|
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 {
|
unitTest(function btoaFailed(): void {
|
||||||
const text = "你好";
|
const text = "你好";
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
|
|
|
@ -105,7 +105,7 @@
|
||||||
if (rem === 1 || /[^+/0-9A-Za-z]/.test(s)) {
|
if (rem === 1 || /[^+/0-9A-Za-z]/.test(s)) {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
"The string to be decoded is not correctly encoded",
|
"The string to be decoded is not correctly encoded",
|
||||||
"DataDecodeError",
|
"InvalidCharacterError",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue