summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/039_worker_deno_ns.test2
-rw-r--r--tests/039_worker_deno_ns.ts25
-rw-r--r--tests/039_worker_deno_ns.ts.out4
-rw-r--r--tests/039_worker_deno_ns/has_ns.ts10
-rw-r--r--tests/039_worker_deno_ns/maybe_ns.ts1
-rw-r--r--tests/039_worker_deno_ns/no_ns.ts10
6 files changed, 52 insertions, 0 deletions
diff --git a/tests/039_worker_deno_ns.test b/tests/039_worker_deno_ns.test
new file mode 100644
index 000000000..da282cc7b
--- /dev/null
+++ b/tests/039_worker_deno_ns.test
@@ -0,0 +1,2 @@
+args: run --reload tests/039_worker_deno_ns.ts
+output: tests/039_worker_deno_ns.ts.out
diff --git a/tests/039_worker_deno_ns.ts b/tests/039_worker_deno_ns.ts
new file mode 100644
index 000000000..1c6830c22
--- /dev/null
+++ b/tests/039_worker_deno_ns.ts
@@ -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", {
+ 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");
diff --git a/tests/039_worker_deno_ns.ts.out b/tests/039_worker_deno_ns.ts.out
new file mode 100644
index 000000000..9b2f90099
--- /dev/null
+++ b/tests/039_worker_deno_ns.ts.out
@@ -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
diff --git a/tests/039_worker_deno_ns/has_ns.ts b/tests/039_worker_deno_ns/has_ns.ts
new file mode 100644
index 000000000..15e729f63
--- /dev/null
+++ b/tests/039_worker_deno_ns/has_ns.ts
@@ -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);
+ };
+ }
+};
diff --git a/tests/039_worker_deno_ns/maybe_ns.ts b/tests/039_worker_deno_ns/maybe_ns.ts
new file mode 100644
index 000000000..0bcbd1f97
--- /dev/null
+++ b/tests/039_worker_deno_ns/maybe_ns.ts
@@ -0,0 +1 @@
+postMessage("maybe_ns.ts: is window.Deno available: " + !!window.Deno);
diff --git a/tests/039_worker_deno_ns/no_ns.ts b/tests/039_worker_deno_ns/no_ns.ts
new file mode 100644
index 000000000..4cee98bea
--- /dev/null
+++ b/tests/039_worker_deno_ns/no_ns.ts
@@ -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);
+ };
+ }
+};