summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/tests/integration/run_tests.rs5
-rw-r--r--cli/tests/testdata/eval_context_throw_dom_exception.js2
-rw-r--r--cli/tests/testdata/eval_context_throw_dom_exception.js.out1
-rw-r--r--core/bindings.rs7
-rw-r--r--core/error.rs2
5 files changed, 13 insertions, 4 deletions
diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs
index 0aca09902..39918d170 100644
--- a/cli/tests/integration/run_tests.rs
+++ b/cli/tests/integration/run_tests.rs
@@ -1922,3 +1922,8 @@ itest!(eval_context_throw_with_conflicting_source {
output: "eval_context_throw_with_conflicting_source.ts.out",
exit_code: 1,
});
+
+itest!(eval_context_throw_dom_exception {
+ args: "run eval_context_throw_dom_exception.js",
+ output: "eval_context_throw_dom_exception.js.out",
+});
diff --git a/cli/tests/testdata/eval_context_throw_dom_exception.js b/cli/tests/testdata/eval_context_throw_dom_exception.js
new file mode 100644
index 000000000..b8e99d498
--- /dev/null
+++ b/cli/tests/testdata/eval_context_throw_dom_exception.js
@@ -0,0 +1,2 @@
+const [, errorInfo] = Deno.core.evalContext('throw new DOMException("foo")');
+console.log(errorInfo);
diff --git a/cli/tests/testdata/eval_context_throw_dom_exception.js.out b/cli/tests/testdata/eval_context_throw_dom_exception.js.out
new file mode 100644
index 000000000..39e164083
--- /dev/null
+++ b/cli/tests/testdata/eval_context_throw_dom_exception.js.out
@@ -0,0 +1 @@
+{ thrown: DOMException: foo, isNativeError: true, isCompileError: false }
diff --git a/core/bindings.rs b/core/bindings.rs
index 2fc6b5092..08ae1c655 100644
--- a/core/bindings.rs
+++ b/core/bindings.rs
@@ -1,5 +1,6 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
+use crate::error::is_instance_of_error;
use crate::error::AnyError;
use crate::modules::ModuleMap;
use crate::resolve_url_or_path;
@@ -238,7 +239,7 @@ pub extern "C" fn host_import_module_dynamically_callback(
args: v8::FunctionCallbackArguments,
_rv: v8::ReturnValue| {
let arg = args.get(0);
- if arg.is_native_error() {
+ if is_instance_of_error(scope, arg) {
let message = v8::Exception::create_message(scope, arg);
if message.get_stack_trace(scope).unwrap().get_frame_count() == 0 {
let arg: v8::Local<v8::Object> = arg.try_into().unwrap();
@@ -512,7 +513,7 @@ fn eval_context(
None,
Some(ErrInfo {
thrown: exception.into(),
- is_native_error: exception.is_native_error(),
+ is_native_error: is_instance_of_error(tc_scope, exception),
is_compile_error: true,
}),
);
@@ -529,7 +530,7 @@ fn eval_context(
None,
Some(ErrInfo {
thrown: exception.into(),
- is_native_error: exception.is_native_error(),
+ is_native_error: is_instance_of_error(tc_scope, exception),
is_compile_error: false,
}),
);
diff --git a/core/error.rs b/core/error.rs
index be97a90fb..88cb06887 100644
--- a/core/error.rs
+++ b/core/error.rs
@@ -297,7 +297,7 @@ pub(crate) fn attach_handle_to_error(
/// of `instanceof`. `Value::is_native_error()` also checks for static class
/// inheritance rather than just scanning the prototype chain, which doesn't
/// work with our WebIDL implementation of `DOMException`.
-fn is_instance_of_error<'s>(
+pub(crate) fn is_instance_of_error<'s>(
scope: &mut v8::HandleScope<'s>,
value: v8::Local<v8::Value>,
) -> bool {