summaryrefslogtreecommitdiff
path: root/runtime/js/99_main.js
diff options
context:
space:
mode:
authorLuca Casonato <lucacasonato@yahoo.com>2021-06-05 23:10:07 +0200
committerGitHub <noreply@github.com>2021-06-05 23:10:07 +0200
commitc73ef5fa143b473677d4cab069241ff018e0c971 (patch)
treef13f3ddb1741a81138240c36846e2a23fd562a02 /runtime/js/99_main.js
parentbb0c90cadbb99784681a2acac1fd65ac7f802297 (diff)
refactor(web): use encoding_rs for text encoding (#10844)
This commit removes all JS based text encoding / text decoding. Instead encoding now happens in Rust via encoding_rs (already in tree). This implementation retains stream support, but adds the last missing encodings. We are incredibly close to 100% WPT on text encoding now. This should reduce our baseline heap by quite a bit.
Diffstat (limited to 'runtime/js/99_main.js')
-rw-r--r--runtime/js/99_main.js16
1 files changed, 12 insertions, 4 deletions
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js
index d64625993..7ec422c1f 100644
--- a/runtime/js/99_main.js
+++ b/runtime/js/99_main.js
@@ -16,6 +16,8 @@ delete Object.prototype.__proto__;
const errorStack = window.__bootstrap.errorStack;
const os = window.__bootstrap.os;
const timers = window.__bootstrap.timers;
+ const base64 = window.__bootstrap.base64;
+ const encoding = window.__bootstrap.encoding;
const Console = window.__bootstrap.console.Console;
const worker = window.__bootstrap.worker;
const signals = window.__bootstrap.signals;
@@ -198,6 +200,12 @@ delete Object.prototype.__proto__;
return new DOMException(msg, "NotSupported");
},
);
+ core.registerErrorBuilder(
+ "DOMExceptionInvalidCharacterError",
+ function DOMExceptionInvalidCharacterError(msg) {
+ return new DOMException(msg, "InvalidCharacterError");
+ },
+ );
}
class Navigator {
@@ -277,8 +285,8 @@ delete Object.prototype.__proto__;
),
Request: util.nonEnumerable(fetch.Request),
Response: util.nonEnumerable(fetch.Response),
- TextDecoder: util.nonEnumerable(TextDecoder),
- TextEncoder: util.nonEnumerable(TextEncoder),
+ TextDecoder: util.nonEnumerable(encoding.TextDecoder),
+ TextEncoder: util.nonEnumerable(encoding.TextEncoder),
TransformStream: util.nonEnumerable(streams.TransformStream),
URL: util.nonEnumerable(url.URL),
URLSearchParams: util.nonEnumerable(url.URLSearchParams),
@@ -295,8 +303,8 @@ delete Object.prototype.__proto__;
TransformStreamDefaultController: util.nonEnumerable(
streams.TransformStreamDefaultController,
),
- atob: util.writable(atob),
- btoa: util.writable(btoa),
+ atob: util.writable(base64.atob),
+ btoa: util.writable(base64.btoa),
clearInterval: util.writable(timers.clearInterval),
clearTimeout: util.writable(timers.clearTimeout),
console: util.writable(