mirror of
https://github.com/denoland/deno.git
synced 2024-12-23 15:49:44 -05:00
ec8e9d4f5b
This is a quick first refactoring to split the tests out of runtime and move runtime-related code to a top-level runtime module. There will be a followup to refactor imports a bit, but this is the major change that will most likely conflict with other work and I want to merge it early.
32 lines
732 B
JavaScript
32 lines
732 B
JavaScript
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
const { core } = Deno;
|
|
const { ops } = core;
|
|
|
|
class DOMException {
|
|
constructor(message, code) {
|
|
this.msg = message;
|
|
this.code = code;
|
|
}
|
|
}
|
|
|
|
core.registerErrorBuilder(
|
|
"DOMExceptionOperationError",
|
|
function DOMExceptionOperationError(msg) {
|
|
return new DOMException(msg, "OperationError");
|
|
},
|
|
);
|
|
|
|
try {
|
|
ops.op_err();
|
|
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");
|
|
}
|
|
}
|