diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-01-18 00:43:53 +0100 |
---|---|---|
committer | Ry Dahl <ry@tinyclouds.org> | 2020-01-17 18:43:53 -0500 |
commit | 5fa056e53be6d17ab746629ea0eaa89fe817141b (patch) | |
tree | c32c4ab39577a2dc14da3843e3223395c5a7ea54 /cli/tests | |
parent | d7203092039d3c46ca8480ff8eecf612deb2b2f6 (diff) |
workers: minimal error handling and async module loading (#3665)
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/026_workers.ts | 6 | ||||
-rw-r--r-- | cli/tests/026_workers.ts.out | 3 | ||||
-rw-r--r-- | cli/tests/subdir/test_worker.js | 12 |
3 files changed, 21 insertions, 0 deletions
diff --git a/cli/tests/026_workers.ts b/cli/tests/026_workers.ts index f45fc4b77..7ac1a0f32 100644 --- a/cli/tests/026_workers.ts +++ b/cli/tests/026_workers.ts @@ -11,4 +11,10 @@ jsWorker.onmessage = (e): void => { tsWorker.postMessage("Hello World"); }; +jsWorker.onerror = (e: Event): void => { + e.preventDefault(); + console.log("called onerror in script"); + jsWorker.postMessage("Hello World"); +}; + jsWorker.postMessage("Hello World"); diff --git a/cli/tests/026_workers.ts.out b/cli/tests/026_workers.ts.out index 7538cc867..92f7550ad 100644 --- a/cli/tests/026_workers.ts.out +++ b/cli/tests/026_workers.ts.out @@ -1,4 +1,7 @@ Hello World +called onerror in worker +called onerror in script +Hello World Received js: Hello World Hello World Received ts: Hello World diff --git a/cli/tests/subdir/test_worker.js b/cli/tests/subdir/test_worker.js index 53d38ba96..cec5bdf9b 100644 --- a/cli/tests/subdir/test_worker.js +++ b/cli/tests/subdir/test_worker.js @@ -1,7 +1,19 @@ +let thrown = false; + onmessage = function(e) { console.log(e.data); + if (thrown === false) { + thrown = true; + throw new SyntaxError("[test error]"); + } + postMessage(e.data); workerClose(); }; + +onerror = function() { + console.log("called onerror in worker"); + return false; +}; |