mirror of
https://github.com/denoland/deno.git
synced 2025-09-24 19:32:30 +00:00
fix: add io ops to worker to fix fetch (#4054)
This commit is contained in:
parent
6dd9643845
commit
d9efb8c02a
5 changed files with 37 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
import { test, assert, assertEquals } from "./test_util.ts";
|
||||
import { test, testPerm, assert, assertEquals } from "./test_util.ts";
|
||||
|
||||
export interface ResolvableMethods<T> {
|
||||
resolve: (value?: T | PromiseLike<T>) => void;
|
||||
|
@ -82,3 +82,24 @@ test(async function workerThrowsWhenExecuting(): Promise<void> {
|
|||
|
||||
await promise;
|
||||
});
|
||||
|
||||
testPerm({ net: true }, async function workerCanUseFetch(): Promise<void> {
|
||||
const promise = createResolvable();
|
||||
|
||||
const fetchingWorker = new Worker("../tests/subdir/fetching_worker.js", {
|
||||
type: "module"
|
||||
});
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
fetchingWorker.onerror = (e: any): void => {
|
||||
e.preventDefault();
|
||||
promise.reject(e.message);
|
||||
};
|
||||
|
||||
fetchingWorker.onmessage = (e): void => {
|
||||
assert(e.data === "Done!");
|
||||
promise.resolve();
|
||||
};
|
||||
|
||||
await promise;
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue