Skip to content

Commit 3f9f71f

Browse files
authored
Simplify test_html5_remove_event_listener.c (#25876)
Simplify test_html5_remove_event_listener.c to not have separate cases for SAFARI_SUPPORT. Fixes #25535 (comment)
1 parent 098b805 commit 3f9f71f

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/lib/libhtml5.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,7 @@ var LibraryHTML5 = {
10841084

10851085
#if MIN_SAFARI_VERSION != TARGET_NOT_SUPPORTED
10861086
// As of Safari 13.0.3 on macOS Catalina 10.15.1 still ships with prefixed webkitfullscreenchange. TODO: revisit this check once Safari ships unprefixed version.
1087+
// TODO: When this block is removed, also change test/test_html5_remove_event_listener.c test expectation on emscripten_set_fullscreenchange_callback().
10871088
registerFullscreenChangeEventCallback(target, userData, useCapture, callbackfunc, {{{ cDefs.EMSCRIPTEN_EVENT_FULLSCREENCHANGE }}}, "webkitfullscreenchange", targetThread);
10881089
#endif
10891090

test/test_browser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2545,7 +2545,7 @@ def test_html5_core(self, opts):
25452545
self.btest_exit('test_html5_core.c', cflags=opts)
25462546

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

25502550
@parameterized({
25512551
'': ([],),

test/test_html5_remove_event_listener.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ void checkCount(int count) {
5656
assert(count == eventHandlersCount);
5757
}
5858

59+
void checkCountBetween(int minCount, int maxCount) {
60+
int eventHandlersCount = EM_ASM_INT({ return JSEvents.eventHandlers.length; });
61+
printf("Detected [%d] handlers\n", eventHandlersCount);
62+
assert(minCount <= eventHandlersCount && eventHandlersCount <= maxCount);
63+
}
64+
5965
int main() {
6066
bool useCapture = true;
6167
void *userData3 = "3";
@@ -139,12 +145,9 @@ int main() {
139145
ret = emscripten_set_fullscreenchange_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, useCapture, screen_callback);
140146
ASSERT_RESULT(emscripten_set_fullscreenchange_callback);
141147

142-
#if SAFARI_SUPPORT == 1
143148
// 2 events handlers are set when there is safari support
144-
checkCount(4);
145-
#else
146-
checkCount(3);
147-
#endif
149+
// TODO: change to checkCount(3) after prefixed Safari fallback is removed.
150+
checkCountBetween(3, 4);
148151

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

0 commit comments

Comments
 (0)