mirror of
https://github.com/denoland/deno.git
synced 2024-12-24 16:19:12 -05:00
fix(runtime): include HTTP op in WebWorker (#10207)
This commit is contained in:
parent
9e6cd91014
commit
15ffdd2624
3 changed files with 35 additions and 0 deletions
10
cli/tests/workers/http_worker.js
Normal file
10
cli/tests/workers/http_worker.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
const listener = Deno.listen({ hostname: "127.0.0.1", port: 4500 });
|
||||
for await (const conn of listener) {
|
||||
(async () => {
|
||||
const requests = Deno.serveHttp(conn);
|
||||
for await (const { respondWith } of requests) {
|
||||
respondWith(new Response("Hello world"));
|
||||
}
|
||||
})();
|
||||
}
|
|
@ -697,3 +697,27 @@ Deno.test({
|
|||
worker.terminate();
|
||||
},
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "Worker with native HTTP",
|
||||
fn: async function () {
|
||||
const worker = new Worker(
|
||||
new URL(
|
||||
"./http_worker.js",
|
||||
import.meta.url,
|
||||
).href,
|
||||
{
|
||||
type: "module",
|
||||
deno: {
|
||||
namespace: true,
|
||||
permissions: "inherit",
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
assert(worker);
|
||||
const response = await fetch("http://localhost:4500");
|
||||
assert(await response.arrayBuffer());
|
||||
worker.terminate();
|
||||
},
|
||||
});
|
||||
|
|
|
@ -261,6 +261,7 @@ impl WebWorker {
|
|||
ops::fs::init(js_runtime);
|
||||
ops::net::init(js_runtime);
|
||||
ops::os::init(js_runtime);
|
||||
ops::http::init(js_runtime);
|
||||
ops::permissions::init(js_runtime);
|
||||
ops::plugin::init(js_runtime);
|
||||
ops::process::init(js_runtime);
|
||||
|
|
Loading…
Reference in a new issue