Skip to content

Commit 66a595d

Browse files
committed
Add Safari version parsing to gate hacks to older versions
1 parent 5d0adb5 commit 66a595d

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

test/common.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import json
1919
import logging
2020
import os
21+
import plistlib
2122
import psutil
2223
import re
2324
import shlex
@@ -215,6 +216,17 @@ def is_safari():
215216
return EMTEST_BROWSER and 'safari' in EMTEST_BROWSER.lower()
216217

217218

219+
def get_safari_version():
220+
plist_path = os.path.join(EMTEST_BROWSER.strip(), 'Contents', 'version.plist')
221+
version_str = plistlib.load(open(plist_path, 'rb')).get('CFBundleShortVersionString')
222+
# Split into parts (major.minor.patch)
223+
parts = (version_str.split('.') + ['0', '0', '0'])[:3]
224+
# Convert each part into integers, discarding any trailing string, e.g. '13a' -> 13.
225+
parts = [int(re.match(r"\d+", s).group()) if re.match(r"\d+", s) else 0 for s in parts]
226+
# Return version as XXYYZZ
227+
return parts[0] * 10000 + parts[1] * 100 + parts[2]
228+
229+
218230
def compiler_for(filename, force_c=False):
219231
if shared.suffix(filename) in ('.cc', '.cxx', '.cpp') and not force_c:
220232
return EMXX
@@ -2724,6 +2736,13 @@ def run_browser(self, html_file, expected=None, message=None, timeout=None, extr
27242736
if DEBUG:
27252737
print('[browser launch:', html_file, ']')
27262738
assert not (message and expected), 'run_browser expects `expected` or `message`, but not both'
2739+
2740+
# Needed at least for version Safari Version 17.6 (17618.3.11.11.7, 17618)
2741+
if is_safari() and get_safari_version() < 180000: # TODO: Find accurate version cutoff
2742+
# Old Safari cannot handle running multiple browser pages in the same browser instance
2743+
# So restart the browser between each browser test.
2744+
self.browser_restart()
2745+
27272746
if expected is not None:
27282747
try:
27292748
self.harness_in_queue.put((

test/test_browser.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ def is_swiftshader(_):
142142

143143
no_firefox = skip_if('no_firefox', lambda _: is_firefox(), 'firefox is not supported')
144144

145+
no_safari = skip_if('no_safari', lambda _: is_safari(), 'safari is not supported')
146+
145147

146148
def is_jspi(args):
147149
return '-sASYNCIFY=2' in args
@@ -3356,6 +3358,7 @@ def test_async_returnvalue(self, args):
33563358
create_file('filey.txt', 'sync_tunnel\nsync_tunnel_bool\n')
33573359
self.btest('test_async_returnvalue.c', '0', cflags=['-sASSERTIONS', '-sASYNCIFY', '-sASYNCIFY_IGNORE_INDIRECT', '--js-library', test_file('browser/test_async_returnvalue.js')] + args)
33583360

3361+
@no_safari('TODO: Fails in Safari Version 17.6 (17618.3.11.11.7, 17618)')
33593362
def test_async_bad_list(self):
33603363
self.btest('test_async_bad_list.c', '0', cflags=['-sASYNCIFY', '-sASYNCIFY_ONLY=waka', '--profiling'])
33613364

0 commit comments

Comments
 (0)