summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorandy finch <andyfinch7@gmail.com>2019-04-01 15:09:59 -0400
committerRyan Dahl <ry@tinyclouds.org>2019-04-01 15:09:59 -0400
commitb0a23beb8fae964be3cdd8c23c38af66257d34c7 (patch)
tree8f7875c8ca059dfb0a3ade4da7bfb94e57d6e1aa /tests
parent659acadf77fdbeef8579a37839a464feb408437a (diff)
Add web worker JS API (#1993)
* Refactored the way worker polling is scheduled and errors are handled. * Share the worker future as a Shared
Diffstat (limited to 'tests')
-rw-r--r--tests/026_workers.test2
-rw-r--r--tests/026_workers.ts14
-rw-r--r--tests/026_workers.ts.out4
-rw-r--r--tests/error_004_missing_module (renamed from tests/error_004_missing_module.disabled)0
-rw-r--r--tests/error_005_missing_dynamic_import (renamed from tests/error_005_missing_dynamic_import.disabled)0
-rw-r--r--tests/error_006_import_ext_failure (renamed from tests/error_006_import_ext_failure.disabled)0
-rw-r--r--tests/subdir/test_worker.js7
-rw-r--r--tests/subdir/test_worker.ts7
8 files changed, 34 insertions, 0 deletions
diff --git a/tests/026_workers.test b/tests/026_workers.test
new file mode 100644
index 000000000..1c5b6f4e6
--- /dev/null
+++ b/tests/026_workers.test
@@ -0,0 +1,2 @@
+args: tests/026_workers.ts --reload
+output: tests/026_workers.ts.out \ No newline at end of file
diff --git a/tests/026_workers.ts b/tests/026_workers.ts
new file mode 100644
index 000000000..0cf8f53b1
--- /dev/null
+++ b/tests/026_workers.ts
@@ -0,0 +1,14 @@
+const jsWorker = new Worker("tests/subdir/test_worker.js");
+const tsWorker = new Worker("tests/subdir/test_worker.ts");
+
+tsWorker.onmessage = e => {
+ console.log("Received ts: " + e.data);
+};
+
+jsWorker.onmessage = e => {
+ console.log("Received js: " + e.data);
+
+ tsWorker.postMessage("Hello World");
+};
+
+jsWorker.postMessage("Hello World");
diff --git a/tests/026_workers.ts.out b/tests/026_workers.ts.out
new file mode 100644
index 000000000..7538cc867
--- /dev/null
+++ b/tests/026_workers.ts.out
@@ -0,0 +1,4 @@
+Hello World
+Received js: Hello World
+Hello World
+Received ts: Hello World
diff --git a/tests/error_004_missing_module.disabled b/tests/error_004_missing_module
index b94c86004..b94c86004 100644
--- a/tests/error_004_missing_module.disabled
+++ b/tests/error_004_missing_module
diff --git a/tests/error_005_missing_dynamic_import.disabled b/tests/error_005_missing_dynamic_import
index 2acf467c1..2acf467c1 100644
--- a/tests/error_005_missing_dynamic_import.disabled
+++ b/tests/error_005_missing_dynamic_import
diff --git a/tests/error_006_import_ext_failure.disabled b/tests/error_006_import_ext_failure
index 5fe245739..5fe245739 100644
--- a/tests/error_006_import_ext_failure.disabled
+++ b/tests/error_006_import_ext_failure
diff --git a/tests/subdir/test_worker.js b/tests/subdir/test_worker.js
new file mode 100644
index 000000000..53d38ba96
--- /dev/null
+++ b/tests/subdir/test_worker.js
@@ -0,0 +1,7 @@
+onmessage = function(e) {
+ console.log(e.data);
+
+ postMessage(e.data);
+
+ workerClose();
+};
diff --git a/tests/subdir/test_worker.ts b/tests/subdir/test_worker.ts
new file mode 100644
index 000000000..53d38ba96
--- /dev/null
+++ b/tests/subdir/test_worker.ts
@@ -0,0 +1,7 @@
+onmessage = function(e) {
+ console.log(e.data);
+
+ postMessage(e.data);
+
+ workerClose();
+};