summaryrefslogtreecommitdiff
path: root/core/error_builder_test.js
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@gmail.com>2021-05-03 17:30:41 +0200
committerGitHub <noreply@github.com>2021-05-03 17:30:41 +0200
commitd21380728f7d16f1a5b7362b2e2b5c46ff8a8070 (patch)
tree190e3a83254cf1d4c36ec03d4ce688cf657d27c8 /core/error_builder_test.js
parent7bc03523d075ae4a5a508f9bdf59a1686f7bcdce (diff)
fix(core): error registration could pollute constructors (#10422)
Co-authored-by: Luca Casonato <lucacasonato@yahoo.com>
Diffstat (limited to 'core/error_builder_test.js')
-rw-r--r--core/error_builder_test.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/core/error_builder_test.js b/core/error_builder_test.js
new file mode 100644
index 000000000..aae47c6cd
--- /dev/null
+++ b/core/error_builder_test.js
@@ -0,0 +1,30 @@
+const { core } = Deno;
+
+class DOMException {
+ constructor(message, code) {
+ this.msg = message;
+ this.code = code;
+ }
+}
+
+core.registerErrorBuilder(
+ "DOMExceptionOperationError",
+ function DOMExceptionOperationError(msg) {
+ return new DOMException(msg, "OperationError");
+ },
+);
+
+try {
+ core.opSync("op_err", undefined, null);
+ throw new Error("op_err didn't throw!");
+} catch (err) {
+ if (!(err instanceof DOMException)) {
+ throw new Error("err not DOMException");
+ }
+ if (err.msg !== "abc") {
+ throw new Error("err.message is incorrect");
+ }
+ if (err.code !== "OperationError") {
+ throw new Error("err.code is incorrect");
+ }
+}