diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-12-02 16:17:23 -0500 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-12-02 16:17:23 -0500 |
commit | a42f659391fcbd0b85b29e5b8725b48a364eb20e (patch) | |
tree | 1bdf2e538a4bc630dbb39bfac40a3dea7369b671 /tests/hello_world_worker.cpp | |
parent | 10b92e403dd2128fb3df40658eb88bbc7c7bd517 (diff) |
fix file preloading in workers and add test
Diffstat (limited to 'tests/hello_world_worker.cpp')
-rw-r--r-- | tests/hello_world_worker.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/hello_world_worker.cpp b/tests/hello_world_worker.cpp index 5ea26d91..5b673df8 100644 --- a/tests/hello_world_worker.cpp +++ b/tests/hello_world_worker.cpp @@ -1,9 +1,17 @@ +#include <string.h> #include <stdio.h> #include <emscripten.h> int main() { printf("you should not see this text when in a worker!\n"); // this should not crash, but also should not show up anywhere if you are in a worker - emscripten_run_script("if (typeof postMessage !== 'undefined') { postMessage('hello from worker!') }"); + FILE *f = fopen("file.dat", "r"); + char buffer[100]; + memset(buffer, 0, 100); + buffer[0] = 0; + fread(buffer, 10, 1, f); + char buffer2[100]; + sprintf(buffer2, "if (typeof postMessage !== 'undefined') { postMessage('hello from worker, and |%s|') }", buffer); + emscripten_run_script(buffer2); } |