summaryrefslogtreecommitdiff
path: root/cli/tests/workers/racy_worker.js
diff options
context:
space:
mode:
authorTim Ramlot <42113979+inteon@users.noreply.github.com>2021-05-11 21:09:09 +0200
committerGitHub <noreply@github.com>2021-05-11 21:09:09 +0200
commit635253bd3a3895f49e6c9606beb852da22fee205 (patch)
treecec9d75354b4e985a376f888564ecb63c99f2643 /cli/tests/workers/racy_worker.js
parent0d319161bc19a520df653bc0c8386f14a68efbdb (diff)
feat(runtime/worker): Structured cloning worker message passing (#9323)
This commit upgrade "Worker.postMessage()" implementation to use structured clone algorithm instead of non-spec compliant JSON serialization.
Diffstat (limited to 'cli/tests/workers/racy_worker.js')
-rw-r--r--cli/tests/workers/racy_worker.js34
1 files changed, 19 insertions, 15 deletions
diff --git a/cli/tests/workers/racy_worker.js b/cli/tests/workers/racy_worker.js
index 83756b791..0f66c6278 100644
--- a/cli/tests/workers/racy_worker.js
+++ b/cli/tests/workers/racy_worker.js
@@ -1,21 +1,25 @@
// See issue for details
// https://github.com/denoland/deno/issues/4080
//
-// After first call to `postMessage() this worker schedules
-// [close(), postMessage()] ops on the same turn of microtask queue
-// (because message is rather big).
-// Only single `postMessage()` call should make it
-// to host, ie. after calling `close()` no more code should be run.
+// 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
-setTimeout(() => {
- close();
-}, 50);
-
-while (true) {
- await new Promise((done) => {
+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(() => {
- postMessage({ buf: new Array(999999) });
- done();
- });
+ throw "This should not be run";
+ }, 50);
});
-}
+};