summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration_tests.rs2
-rw-r--r--cli/tests/subdir/nested_worker.js19
-rw-r--r--cli/tests/subdir/sibling_worker.js4
-rw-r--r--cli/tests/subdir/test_worker.js2
-rw-r--r--cli/tests/subdir/test_worker.ts2
-rw-r--r--cli/tests/subdir/throwing_worker.js2
6 files changed, 25 insertions, 6 deletions
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs
index dd242a32a..a42dd439e 100644
--- a/cli/tests/integration_tests.rs
+++ b/cli/tests/integration_tests.rs
@@ -397,12 +397,10 @@ itest!(_026_redirect_javascript {
http_server: true,
});
-/* TODO(ry) Disabled to get #3844 landed faster. Re-enable.
itest!(_026_workers {
args: "run --reload 026_workers.ts",
output: "026_workers.ts.out",
});
-*/
itest!(workers_basic {
args: "run --reload workers_basic.ts",
diff --git a/cli/tests/subdir/nested_worker.js b/cli/tests/subdir/nested_worker.js
new file mode 100644
index 000000000..b0acd70d7
--- /dev/null
+++ b/cli/tests/subdir/nested_worker.js
@@ -0,0 +1,19 @@
+// Specifier should be resolved relative to current file
+const jsWorker = new Worker("./sibling_worker.js", {
+ type: "module",
+ name: "sibling"
+});
+
+jsWorker.onerror = _e => {
+ postMessage({ type: "error" });
+};
+
+jsWorker.onmessage = e => {
+ console.log("js worker on message");
+ postMessage({ type: "msg", text: e });
+ close();
+};
+
+onmessage = function(e) {
+ jsWorker.postMessage(e.data);
+};
diff --git a/cli/tests/subdir/sibling_worker.js b/cli/tests/subdir/sibling_worker.js
new file mode 100644
index 000000000..0e91141ce
--- /dev/null
+++ b/cli/tests/subdir/sibling_worker.js
@@ -0,0 +1,4 @@
+onmessage = e => {
+ postMessage(e.data);
+ close();
+};
diff --git a/cli/tests/subdir/test_worker.js b/cli/tests/subdir/test_worker.js
index f0d9fbed6..70e1d8b73 100644
--- a/cli/tests/subdir/test_worker.js
+++ b/cli/tests/subdir/test_worker.js
@@ -1,6 +1,5 @@
let thrown = false;
-// TODO(bartlomieju): add test for throwing in web worker
if (self.name !== "jsWorker") {
throw Error(`Bad worker name: ${self.name}, expected jsWorker`);
}
@@ -14,7 +13,6 @@ onmessage = function(e) {
}
postMessage(e.data);
-
close();
};
diff --git a/cli/tests/subdir/test_worker.ts b/cli/tests/subdir/test_worker.ts
index bc3f358f8..2ea8f9214 100644
--- a/cli/tests/subdir/test_worker.ts
+++ b/cli/tests/subdir/test_worker.ts
@@ -4,8 +4,6 @@ if (self.name !== "tsWorker") {
onmessage = function(e): void {
console.log(e.data);
-
postMessage(e.data);
-
close();
};
diff --git a/cli/tests/subdir/throwing_worker.js b/cli/tests/subdir/throwing_worker.js
new file mode 100644
index 000000000..56ee4ff88
--- /dev/null
+++ b/cli/tests/subdir/throwing_worker.js
@@ -0,0 +1,2 @@
+// This worker just throws error when it's being executed
+throw Error("Thrown error");