summaryrefslogtreecommitdiff
path: root/tests/testdata/workers/racy_worker.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/testdata/workers/racy_worker.js')
-rw-r--r--tests/testdata/workers/racy_worker.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/testdata/workers/racy_worker.js b/tests/testdata/workers/racy_worker.js
new file mode 100644
index 000000000..0f66c6278
--- /dev/null
+++ b/tests/testdata/workers/racy_worker.js
@@ -0,0 +1,25 @@
+// See issue for details
+// https://github.com/denoland/deno/issues/4080
+//
+// After first received message, this worker schedules
+// [assert(), close(), assert()] ops on the same turn of microtask queue
+// All tasks after close should not make it
+
+onmessage = async function () {
+ let stage = 0;
+ await new Promise((_) => {
+ setTimeout(() => {
+ if (stage !== 0) throw "Unexpected stage";
+ stage = 1;
+ }, 50);
+ setTimeout(() => {
+ if (stage !== 1) throw "Unexpected stage";
+ stage = 2;
+ postMessage("DONE");
+ close();
+ }, 50);
+ setTimeout(() => {
+ throw "This should not be run";
+ }, 50);
+ });
+};