From 1a6249c9717288e37873b692abac831f11c30f4e Mon Sep 17 00:00:00 2001 From: Andreu Botella Date: Sat, 25 Sep 2021 04:26:57 +0200 Subject: chore(workers): Test that closing a worker closes any child workers (#12215) Before #12156, closing a worker which had children would cause a panic (https://github.com/denoland/deno/issues/11342#issuecomment-918327693). After that PR, closing a worker will also close any child workers. --- cli/tests/testdata/workers/close_nested_child.js | 7 +++++++ cli/tests/testdata/workers/close_nested_parent.js | 13 +++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 cli/tests/testdata/workers/close_nested_child.js create mode 100644 cli/tests/testdata/workers/close_nested_parent.js (limited to 'cli/tests/testdata/workers') diff --git a/cli/tests/testdata/workers/close_nested_child.js b/cli/tests/testdata/workers/close_nested_child.js new file mode 100644 index 000000000..627a176aa --- /dev/null +++ b/cli/tests/testdata/workers/close_nested_child.js @@ -0,0 +1,7 @@ +// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. + +console.log("Starting the child worker"); + +setTimeout(() => { + console.log("The child worker survived the death of the parent!!!"); +}, 2000); diff --git a/cli/tests/testdata/workers/close_nested_parent.js b/cli/tests/testdata/workers/close_nested_parent.js new file mode 100644 index 000000000..c528632ce --- /dev/null +++ b/cli/tests/testdata/workers/close_nested_parent.js @@ -0,0 +1,13 @@ +// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. + +console.log("Starting the parent worker"); + +new Worker( + new URL("./close_nested_child.js", import.meta.url), + { type: "module" }, +); + +self.addEventListener("message", () => { + console.log("Closing"); + self.close(); +}); -- cgit v1.2.3