Skip to content
Merged
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
2 changes: 1 addition & 1 deletion test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2545,7 +2545,7 @@ def test_html5_core(self, opts):
self.btest_exit('test_html5_core.c', cflags=opts)

def test_html5_remove_event_listener(self):
self.btest_exit('test_html5_remove_event_listener.c')
self.btest_exit('test_html5_remove_event_listener.c', cflags=[f'-DSAFARI_SUPPORT={int(not self.is_wasm64())}'])

@parameterized({
'': ([],),
Expand Down
22 changes: 22 additions & 0 deletions test/test_html5_remove_event_listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ bool mouse_callback_1(int eventType, const EmscriptenMouseEvent *e, void *userDa
return 0;
}

bool screen_callback(int eventType, const EmscriptenFullscreenChangeEvent *fullscreenChangeEvent, void *userData) {
printf("screen_callback: eventType=%d, userData=%s\n", eventType, (char const *) userData);
return 0;
}

void checkCount(int count) {
int eventHandlersCount = EM_ASM_INT({ return JSEvents.eventHandlers.length; });
printf("Detected [%d] handlers\n", eventHandlersCount);
Expand Down Expand Up @@ -130,5 +135,22 @@ int main() {

checkCount(2);

// internally, emscripten_set_fullscreenchange_callback can set 2 event handlers ("webkitfullscreenchange" and "fullscreenchange")
ret = emscripten_set_fullscreenchange_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, useCapture, screen_callback);
ASSERT_RESULT(emscripten_set_fullscreenchange_callback);

#if SAFARI_SUPPORT == 1
// 2 events handlers are set when there is safari support
checkCount(4);
#else
checkCount(3);
#endif

// we make sure that the 2 event handlers get removed (#25846)
ret = emscripten_html5_remove_event_listener(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, EMSCRIPTEN_EVENT_FULLSCREENCHANGE, screen_callback);
ASSERT_RESULT(emscripten_html5_remove_event_listener);

checkCount(2);

return 0;
}