From a66f327250d9df77816e80e7d411b232f8b08b11 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Sun, 6 Jun 2021 18:32:06 +0200 Subject: tests: run wpt scripts with Deno.core.evalContext (#10852) This means wpts are now run in script context, and there are better stack traces. --- core/bindings.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'core') 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::::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::::try_from(args.get(1)) - .map(|n| Url::from_file_path(n.to_rust_string_lossy(scope)).unwrap()); + let url = match v8::Local::::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>, Option>); -- cgit v1.2.3