diff options
Diffstat (limited to 'op_crates/web/08_text_encoding.js')
-rw-r--r-- | op_crates/web/08_text_encoding.js | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/op_crates/web/08_text_encoding.js b/op_crates/web/08_text_encoding.js index c9d708740..c3e622c99 100644 --- a/op_crates/web/08_text_encoding.js +++ b/op_crates/web/08_text_encoding.js @@ -26,6 +26,7 @@ "use strict"; ((window) => { + const webidl = window.__bootstrap.webidl; const core = Deno.core; const CONTINUE = null; @@ -124,13 +125,17 @@ } function btoa(s) { + s = webidl.converters.DOMString(s, { + prefix: "Failed to execute 'bota'", + context: "Argument 1", + }); const byteArray = []; for (let i = 0; i < s.length; i++) { const charCode = s[i].charCodeAt(0); if (charCode > 0xff) { - throw new TypeError( - "The string to be encoded contains characters " + - "outside of the Latin1 range.", + throw new DOMException( + "The string to be encoded contains characters outside of the Latin1 range.", + "InvalidCharacterError", ); } byteArray.push(charCode); |