diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-01-28 21:29:02 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-01-28 21:29:02 -0800 |
commit | 687b8cfa3d105a634b3c9cfbc5fc287f1517fae3 (patch) | |
tree | eea2952d7673296ba6a8cd2384061fc3ad270473 /tests/hello_world_gles_shell.html | |
parent | c516fa7758636e15a7077c658db3c74533c7ee38 (diff) | |
parent | b6ebeed2cfcebb220f2ce700c7cbe484e62cd2e2 (diff) |
Merge branch 'master' into llvmopts
Diffstat (limited to 'tests/hello_world_gles_shell.html')
-rw-r--r-- | tests/hello_world_gles_shell.html | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/hello_world_gles_shell.html b/tests/hello_world_gles_shell.html new file mode 100644 index 00000000..ad2c5a87 --- /dev/null +++ b/tests/hello_world_gles_shell.html @@ -0,0 +1,55 @@ +<html> + <head> + <title>Emscripten-Generated Code</title> + <body> + <center> + <canvas id='canvas' width='256' height='256'></canvas> + </center> + <hr> + <div id='output'></div> + <hr> + <script type='text/javascript'> + /** + * TODO: Encapsulate this part in a reusable token such as + * EMSCRIPTEN_ENVIRONMENT so that we can share code + * between the default shell and custom ones. + */ + // connect to canvas + var Module = { + print: (function() { + var element = document.getElementById('output'); + return function(text) { + element.innerHTML += text.replace('\n', '<br>', 'g') + '<br>'; + }; + })(), + canvas: document.getElementById('canvas') + }; + + // The compiled code + {{{ SCRIPT_CODE }}} + + // Test code + function simulateKeyEvent(keyCode) { + var event = document.createEvent("KeyboardEvent"); + event.initKeyEvent("keydown", true, true, window, + 0, 0, 0, 0, keyCode, 0); + document.body.dispatchEvent(event); + } + function reportResult(result) { + var xhr = new XMLHttpRequest(); + xhr.open('GET', 'http://localhost:8888/report_gl_result?' + result, true); + xhr.send(); + } + function doTest() { + var firstImage = Module.canvas.toDataURL(); + simulateKeyEvent(0x25 /* DOM_VK_LEFT */); + setTimeout(function() { + var secondImage = Module.canvas.toDataURL(); + reportResult(firstImage != secondImage); + }, 0); + } + addEventListener("load", doTest, false); + </script> + </body> +</html> + |