summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorLuca Casonato <lucacasonato@yahoo.com>2021-06-06 18:32:06 +0200
committerGitHub <noreply@github.com>2021-06-06 18:32:06 +0200
commita66f327250d9df77816e80e7d411b232f8b08b11 (patch)
tree69f75867a3e0f507d2d62b3a5c2d9b23c9f8a7e5 /core
parentf1deed41e7cc04440a5fb8cdae486ae00513a361 (diff)
tests: run wpt scripts with Deno.core.evalContext (#10852)
This means wpts are now run in script context, and there are better stack traces.
Diffstat (limited to 'core')
-rw-r--r--core/bindings.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/core/bindings.rs b/core/bindings.rs
index 5fb57aac3..fbde856c5 100644
--- a/core/bindings.rs
+++ b/core/bindings.rs
@@ -1,6 +1,7 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
use crate::error::AnyError;
+use crate::resolve_url_or_path;
use crate::JsRuntime;
use crate::Op;
use crate::OpId;
@@ -382,13 +383,21 @@ fn eval_context(
let source = match v8::Local::<v8::String>::try_from(args.get(0)) {
Ok(s) => s,
Err(_) => {
- throw_type_error(scope, "Invalid argument");
+ throw_type_error(scope, "Missing first argument");
return;
}
};
- let url = v8::Local::<v8::String>::try_from(args.get(1))
- .map(|n| Url::from_file_path(n.to_rust_string_lossy(scope)).unwrap());
+ let url = match v8::Local::<v8::String>::try_from(args.get(1)) {
+ Ok(s) => match resolve_url_or_path(&s.to_rust_string_lossy(scope)) {
+ Ok(s) => Some(s),
+ Err(err) => {
+ throw_type_error(scope, &format!("Invalid specifier: {}", err));
+ return;
+ }
+ },
+ Err(_) => None,
+ };
#[derive(Serialize)]
struct Output<'s>(Option<serde_v8::Value<'s>>, Option<ErrInfo<'s>>);