diff options
author | Dave Nicponski <daven@google.com> | 2014-02-22 22:24:33 -0500 |
---|---|---|
committer | Dave Nicponski <daven@google.com> | 2014-03-03 17:00:11 -0500 |
commit | 168ec74a34743e3b2dc295ada9ccecbc689cf441 (patch) | |
tree | 3fdc392d72c6906893210eda09bd62248e79f9a3 /tests/worker_api_3_worker.cpp | |
parent | 7dc8c2ff08e46c9d9a88ba44bf221a404eeb1e5e (diff) |
Allow multiple worker responses (via messages) if desired.
Add unit test for multiple worker responses.
Test command:
python tests/runner.py browser.test_worker_api_3
Add self to authors file.
Diffstat (limited to 'tests/worker_api_3_worker.cpp')
-rw-r--r-- | tests/worker_api_3_worker.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/worker_api_3_worker.cpp b/tests/worker_api_3_worker.cpp new file mode 100644 index 00000000..db14377a --- /dev/null +++ b/tests/worker_api_3_worker.cpp @@ -0,0 +1,25 @@ +#include <assert.h> +#include <emscripten.h> + +extern "C" { + +// Respond with 0, 1, 2, 3 each with finalResponse=false, and 4 with +// finalResponse=true. +void one(char *data, int size) { + int *x = (int*)data; + + if (*x == 0) { + // Respond 0, 1, 2, 3 + for (int i = 0; i < 4; ++i) { + *x = i; + emscripten_worker_respond_provisionally(data, size); + } + } + + // Respond 4 + *x = 4; + emscripten_worker_respond(data, size); +} + +} + |