aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-01-14 14:49:08 -0800
committerAlon Zakai <alonzakai@gmail.com>2014-01-14 14:49:29 -0800
commit836ca84817da520a818bf568470e6f853864410c (patch)
treebcfd016f6b2cdefdb84254615a052813a9899248 /tests
parentc8529f6fa67bc6f5adada4fc3f9804c852371c50 (diff)
fix double start bug #1992 in browser as well
Diffstat (limited to 'tests')
-rw-r--r--tests/doublestart.c23
-rw-r--r--tests/test_browser.py13
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/doublestart.c b/tests/doublestart.c
new file mode 100644
index 00000000..533e6308
--- /dev/null
+++ b/tests/doublestart.c
@@ -0,0 +1,23 @@
+#include <stdio.h>
+#include <emscripten.h>
+
+int times = 0;
+
+void later(void* nada) {
+ int result = times;
+ REPORT_RESULT();
+}
+
+void main_loop(void) {
+ static int cnt = 0;
+ if (++cnt >= 10) emscripten_cancel_main_loop();
+}
+
+int main(void) {
+ emscripten_async_call(later, NULL, 2000);
+ times++;
+ printf("This should only appear once.\n");
+ emscripten_set_main_loop(main_loop, 10, 0);
+ return 0;
+}
+
diff --git a/tests/test_browser.py b/tests/test_browser.py
index 23022604..eed18a3d 100644
--- a/tests/test_browser.py
+++ b/tests/test_browser.py
@@ -1751,3 +1751,16 @@ keydown(100);keyup(100); // trigger the end
self.btest(path_from_root('tests', 'glew.c'), args=['-s', 'LEGACY_GL_EMULATION=1'], expected='1')
self.btest(path_from_root('tests', 'glew.c'), args=['-DGLEW_MX'], expected='1')
self.btest(path_from_root('tests', 'glew.c'), args=['-s', 'LEGACY_GL_EMULATION=1', '-DGLEW_MX'], expected='1')
+
+ def test_doublestart_bug(self):
+ open('pre.js', 'w').write(r'''
+if (typeof Module === 'undefined') Module = eval('(function() { try { return Module || {} } catch(e) { return {} } })()');
+if (!Module['preRun']) Module['preRun'] = [];
+Module["preRun"].push(function () {
+ Module['addRunDependency']('test_run_dependency');
+ Module['removeRunDependency']('test_run_dependency');
+});
+''')
+
+ self.btest('doublestart.c', args=['--pre-js', 'pre.js', '-o', 'test.html'], expected='1')
+