1 #include <emscripten.h> 2 #include <emscripten/html5.h> 3 #include <assert.h> 4 5 int funcExecuted = 0; 6 testDone(void * userData)7void testDone(void *userData) 8 { 9 assert((int)userData == 2); 10 assert(funcExecuted == 10); 11 #ifdef REPORT_RESULT 12 REPORT_RESULT(0); 13 #endif 14 } 15 16 long intervalId = 0; 17 tick(void * userData)18void tick(void *userData) 19 { 20 assert((int)userData == 1); 21 ++funcExecuted; 22 if (funcExecuted == 10) 23 { 24 emscripten_set_timeout(testDone, 300, (void*)2); 25 } 26 if (funcExecuted >= 10) 27 { 28 emscripten_clear_interval(intervalId); 29 } 30 } 31 main()32int main() 33 { 34 intervalId = emscripten_set_interval(tick, 100, (void*)1); 35 EM_ASM(noExitRuntime = 1); 36 } 37