diff --git a/test/test_browser.py b/test/test_browser.py index e4e1191770d4c..9ece9a00a2d76 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -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({ '': ([],), diff --git a/test/test_html5_remove_event_listener.c b/test/test_html5_remove_event_listener.c index 394e7afe31ee7..0fde8527e762e 100644 --- a/test/test_html5_remove_event_listener.c +++ b/test/test_html5_remove_event_listener.c @@ -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); @@ -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; }