From d9efb8c02a0036d755c35e8e9c88d58bd45a9e2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Fri, 21 Feb 2020 10:35:41 -0500 Subject: fix: add io ops to worker to fix fetch (#4054) --- cli/js/workers_test.ts | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'cli/js/workers_test.ts') diff --git a/cli/js/workers_test.ts b/cli/js/workers_test.ts index 9cb4f4a07..eccf83f65 100644 --- a/cli/js/workers_test.ts +++ b/cli/js/workers_test.ts @@ -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 { resolve: (value?: T | PromiseLike) => void; @@ -82,3 +82,24 @@ test(async function workerThrowsWhenExecuting(): Promise { await promise; }); + +testPerm({ net: true }, async function workerCanUseFetch(): Promise { + 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; +}); -- cgit v1.2.3