Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
369 changes: 142 additions & 227 deletions src/library_html5.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions test/code_size/hello_webgl2_wasm.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"a.html.gz": 328,
"a.js": 4531,
"a.js.gz": 2312,
"a.wasm": 10402,
"a.wasm.gz": 6704,
"total": 15387,
"total_gz": 9344
"a.wasm": 10421,
"a.wasm.gz": 6697,
"total": 15406,
"total_gz": 9337
}
8 changes: 4 additions & 4 deletions test/code_size/hello_webgl2_wasm2js.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"a.html": 346,
"a.html.gz": 262,
"a.js": 22199,
"a.js.gz": 11579,
"total": 22545,
"total_gz": 11841
"a.js": 22320,
"a.js.gz": 11639,
"total": 22666,
"total_gz": 11901
}
8 changes: 4 additions & 4 deletions test/code_size/hello_webgl_wasm.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"a.html.gz": 328,
"a.js": 4069,
"a.js.gz": 2158,
"a.wasm": 10402,
"a.wasm.gz": 6704,
"total": 14925,
"total_gz": 9190
"a.wasm": 10421,
"a.wasm.gz": 6697,
"total": 14944,
"total_gz": 9183
}
8 changes: 4 additions & 4 deletions test/code_size/hello_webgl_wasm2js.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"a.html": 346,
"a.html.gz": 262,
"a.js": 21725,
"a.js.gz": 11413,
"total": 22071,
"total_gz": 11675
"a.js": 21846,
"a.js.gz": 11479,
"total": 22192,
"total_gz": 11741
}
23 changes: 9 additions & 14 deletions test/test_html5_mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,12 @@
* found in the LICENSE file.
*/

#include <assert.h>
#include <stdio.h>
#include <emscripten.h>
#include <string.h>
#include <emscripten/html5.h>

void report_result(int result) {
if (result == 0) {
printf("Test successful!\n");
} else {
printf("Test failed!\n");
}
#ifdef REPORT_RESULT
REPORT_RESULT(result);
#endif
}

static inline const char *emscripten_event_type_to_string(int eventType) {
const char *events[] = { "(invalid)", "(none)", "keypress", "keydown", "keyup", "click", "mousedown", "mouseup", "dblclick", "mousemove", "wheel", "resize",
"scroll", "blur", "focus", "focusin", "focusout", "deviceorientation", "devicemotion", "orientationchange", "fullscreenchange", "pointerlockchange",
Expand Down Expand Up @@ -62,7 +52,12 @@ void instruction() {
if (!gotMouseMove) { printf("Please move the mouse on the canvas.\n"); return; }
if (!gotWheel) { printf("Please scroll the mouse wheel.\n"); return; }

if (gotClick && gotMouseDown && gotMouseUp && gotDblClick && gotMouseMove && gotWheel) report_result(0);
if (gotClick && gotMouseDown && gotMouseUp && gotDblClick && gotMouseMove && gotWheel) {
printf("Test successful!\n");
#ifdef REPORT_RESULT
REPORT_RESULT(0);
#endif
}
}

bool mouse_callback(int eventType, const EmscriptenMouseEvent *e, void *userData) {
Expand All @@ -82,7 +77,7 @@ bool mouse_callback(int eventType, const EmscriptenMouseEvent *e, void *userData
if (eventType == EMSCRIPTEN_EVENT_CLICK && e->screenX == -500000) {
printf("ERROR! Received an event to a callback that should have been unregistered!\n");
gotClick = 0;
report_result(1);
assert(false && "Received an event to a callback that should have been unregistered");
}

instruction();
Expand Down Expand Up @@ -141,7 +136,7 @@ int main() {
if (mouseEvent.screenX != 123 || mouseEvent.screenY != 456
|| mouseEvent.clientX != 123 || mouseEvent.clientY != 456) {
printf("ERROR! Incorrect mouse status\n");
report_result(1);
assert(false && "Incorrect mouse status");
}

// Test that unregistering a callback works. Clicks should no longer be received.
Expand Down
Loading