mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 09:31:22 -05:00
tests: run wpt scripts with Deno.core.evalContext (#10852)
This means wpts are now run in script context, and there are better stack traces.
This commit is contained in:
parent
f1deed41e7
commit
a66f327250
4 changed files with 43 additions and 29 deletions
|
@ -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>>);
|
||||
|
|
|
@ -3,10 +3,11 @@ import {
|
|||
dirname,
|
||||
fromFileUrl,
|
||||
join,
|
||||
toFileUrl,
|
||||
} from "https://deno.land/std@0.84.0/path/mod.ts";
|
||||
export { dirname, join };
|
||||
export { dirname, fromFileUrl, join, toFileUrl };
|
||||
export { existsSync } from "https://deno.land/std@0.84.0/fs/mod.ts";
|
||||
export { readLines } from "https://deno.land/std@0.84.0/io/mod.ts";
|
||||
export { readLines } from "https://deno.land/std@0.97.0/io/mod.ts";
|
||||
export { delay } from "https://deno.land/std@0.84.0/async/delay.ts";
|
||||
|
||||
export const ROOT_PATH = dirname(dirname(fromFileUrl(import.meta.url)));
|
||||
|
|
|
@ -634,7 +634,7 @@
|
|||
"jsapi": {
|
||||
"constructor": {
|
||||
"compile.any.html": true,
|
||||
"instantiate-bad-imports.any.html": false,
|
||||
"instantiate-bad-imports.any.html": true,
|
||||
"instantiate.any.html": [
|
||||
"Synchronous options handling: Buffer argument"
|
||||
],
|
||||
|
@ -653,21 +653,15 @@
|
|||
"Table interface: operation set(unsigned long, optional any)"
|
||||
],
|
||||
"instance": {
|
||||
"constructor-bad-imports.any.html": false,
|
||||
"constructor-bad-imports.any.html": true,
|
||||
"constructor-caching.any.html": true,
|
||||
"constructor.any.html": true,
|
||||
"exports.any.html": [
|
||||
"Setting (sloppy mode)"
|
||||
],
|
||||
"exports.any.html": true,
|
||||
"toString.any.html": true
|
||||
},
|
||||
"interface.any.html": [
|
||||
"WebAssembly: property descriptor"
|
||||
],
|
||||
"interface.any.html": true,
|
||||
"memory": {
|
||||
"buffer.any.html": [
|
||||
"Setting (sloppy mode)"
|
||||
],
|
||||
"buffer.any.html": true,
|
||||
"constructor.any.html": true,
|
||||
"grow.any.html": true,
|
||||
"toString.any.html": true,
|
||||
|
@ -687,9 +681,7 @@
|
|||
"constructor.any.html": true,
|
||||
"get-set.any.html": true,
|
||||
"grow.any.html": true,
|
||||
"length.any.html": [
|
||||
"Setting (sloppy mode)"
|
||||
],
|
||||
"length.any.html": true,
|
||||
"toString.any.html": true,
|
||||
"constructor-reftypes.tentative.any.html": [
|
||||
"initialize externref table with default value",
|
||||
|
@ -1217,4 +1209,4 @@
|
|||
"set.any.html": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
import { delay, join, readLines, ROOT_PATH } from "../util.js";
|
||||
import { delay, join, readLines, ROOT_PATH, toFileUrl } from "../util.js";
|
||||
import { assert, ManifestTestOptions, release, runPy } from "./utils.ts";
|
||||
import { DOMParser } from "https://deno.land/x/deno_dom@v0.1.3-alpha2/deno-dom-wasm.ts";
|
||||
|
||||
|
@ -140,20 +140,32 @@ async function generateBundle(location: URL): Promise<string> {
|
|||
assert(doc, "document should have been parsed");
|
||||
const scripts = doc.getElementsByTagName("script");
|
||||
const scriptContents = [];
|
||||
let inlineScriptCount = 0;
|
||||
for (const script of scripts) {
|
||||
const src = script.getAttribute("src");
|
||||
if (src === "/resources/testharnessreport.js") {
|
||||
scriptContents.push(
|
||||
await Deno.readTextFile(
|
||||
join(ROOT_PATH, "./tools/wpt/testharnessreport.js"),
|
||||
),
|
||||
const url = toFileUrl(
|
||||
join(ROOT_PATH, "./tools/wpt/testharnessreport.js"),
|
||||
);
|
||||
const contents = await Deno.readTextFile(url);
|
||||
scriptContents.push([url.href, contents]);
|
||||
} else if (src) {
|
||||
const res = await fetch(new URL(src, location));
|
||||
scriptContents.push(await res.text());
|
||||
const url = new URL(src, location);
|
||||
const res = await fetch(url);
|
||||
if (res.ok) {
|
||||
const contents = await res.text();
|
||||
scriptContents.push([url.href, contents]);
|
||||
}
|
||||
} else {
|
||||
scriptContents.push(script.textContent);
|
||||
const url = new URL(`#${inlineScriptCount}`, location);
|
||||
inlineScriptCount++;
|
||||
scriptContents.push([url.href, script.textContent]);
|
||||
}
|
||||
}
|
||||
return scriptContents.join("\n");
|
||||
|
||||
return scriptContents.map(([url, contents]) =>
|
||||
`Deno.core.evalContext(${JSON.stringify(contents)}, ${
|
||||
JSON.stringify(url)
|
||||
});`
|
||||
).join("\n");
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue