diff --git a/src/shell.html b/src/shell.html index d66e49c1c..1df842b1e 100644 --- a/src/shell.html +++ b/src/shell.html @@ -1212,7 +1212,7 @@
- +
diff --git a/src/shell_minimal.html b/src/shell_minimal.html index 1286b2deb..711a52511 100644 --- a/src/shell_minimal.html +++ b/src/shell_minimal.html @@ -54,7 +54,7 @@
- +

diff --git a/tests/canvas_focus.c b/tests/canvas_focus.c new file mode 100644 index 000000000..aa1454082 --- /dev/null +++ b/tests/canvas_focus.c @@ -0,0 +1,35 @@ +/* + * Copyright 2017 The Emscripten Authors. All rights reserved. + * Emscripten is available under two separate licenses, the MIT license and the + * University of Illinois/NCSA Open Source License. Both these licenses can be + * found in the LICENSE file. + */ + +#include +#include +#include +#include +#include + +EM_BOOL key_callback(int eventType, const EmscriptenKeyboardEvent *e, void *userData) +{ + static int i = 0; + printf("key_callback %d\n", i); + i++; +#ifdef REPORT_RESULT + REPORT_RESULT(1); +#endif + return 0; +} + +int main() +{ + emscripten_set_keypress_callback("#canvas", 0, 1, key_callback); + EM_ASM({ + var event = new KeyboardEvent("keypress", { 'keyCode': 38, 'charCode': 38, 'view': window, 'bubbles': true, 'cancelable': true }); + // Focus, then send an event, same as if the user clicked on it for focus. + Module.canvas.focus(); + document.activeElement.dispatchEvent(event); + Module['noExitRuntime'] = true; + }); +} diff --git a/tests/test_browser.py b/tests/test_browser.py index 79a74c5cc..df5a53873 100644 --- a/tests/test_browser.py +++ b/tests/test_browser.py @@ -877,6 +877,9 @@ keydown(100);keyup(100); // trigger the end self.btest('sdl_key_proxy.c', '223092870', args=['--proxy-to-worker', '--pre-js', 'pre.js', '-s', '''EXPORTED_FUNCTIONS=['_main', '_one']''', '-lSDL', '-lGL'], manual_reference=True, post_build=post) + def test_canvas_focus(self): + self.btest('canvas_focus.c', '1') + def test_keydown_preventdefault_proxy(self): def post(): html = open('test.html').read()