forked from denoland/deno
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
715aab4
commit d4f063e
Showing
6 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
args: run --reload tests/039_worker_deno_ns.ts | ||
output: tests/039_worker_deno_ns.ts.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const w1 = new Worker("./tests/039_worker_deno_ns/has_ns.ts"); | ||
const w2 = new Worker("./tests/039_worker_deno_ns/no_ns.ts", { | ||
deno: { noDenoNamespace: true } | ||
}); | ||
let w1MsgCount = 0; | ||
let w2MsgCount = 0; | ||
w1.onmessage = (msg): void => { | ||
console.log(msg.data); | ||
w1MsgCount++; | ||
if (w1MsgCount === 1) { | ||
w1.postMessage("CONTINUE"); | ||
} else { | ||
w2.postMessage("START"); | ||
} | ||
}; | ||
w2.onmessage = (msg): void => { | ||
console.log(msg.data); | ||
w2MsgCount++; | ||
if (w2MsgCount === 1) { | ||
w2.postMessage("CONTINUE"); | ||
} else { | ||
Deno.exit(0); | ||
} | ||
}; | ||
w1.postMessage("START"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
has_ns.ts: is window.Deno available: true | ||
[SPAWNED BY has_ns.ts] maybe_ns.ts: is window.Deno available: true | ||
no_ns.ts: is window.Deno available: false | ||
[SPAWNED BY no_ns.ts] maybe_ns.ts: is window.Deno available: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
onmessage = (msg): void => { | ||
if (msg.data === "START") { | ||
postMessage("has_ns.ts: is window.Deno available: " + !!window.Deno); | ||
} else { | ||
const worker = new Worker("./tests/039_worker_deno_ns/maybe_ns.ts"); | ||
worker.onmessage = (msg): void => { | ||
postMessage("[SPAWNED BY has_ns.ts] " + msg.data); | ||
}; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
postMessage("maybe_ns.ts: is window.Deno available: " + !!window.Deno); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
onmessage = (msg): void => { | ||
if (msg.data === "START") { | ||
postMessage("no_ns.ts: is window.Deno available: " + !!window.Deno); | ||
} else { | ||
const worker = new Worker("./tests/039_worker_deno_ns/maybe_ns.ts"); | ||
worker.onmessage = (msg): void => { | ||
postMessage("[SPAWNED BY no_ns.ts] " + msg.data); | ||
}; | ||
} | ||
}; |