|
18 | 18 | import json
|
19 | 19 | import logging
|
20 | 20 | import os
|
| 21 | +import plistlib |
21 | 22 | import psutil
|
22 | 23 | import re
|
23 | 24 | import shlex
|
@@ -215,6 +216,17 @@ def is_safari():
|
215 | 216 | return EMTEST_BROWSER and 'safari' in EMTEST_BROWSER.lower()
|
216 | 217 |
|
217 | 218 |
|
| 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 | + |
218 | 230 | def compiler_for(filename, force_c=False):
|
219 | 231 | if shared.suffix(filename) in ('.cc', '.cxx', '.cpp') and not force_c:
|
220 | 232 | return EMXX
|
@@ -2724,6 +2736,13 @@ def run_browser(self, html_file, expected=None, message=None, timeout=None, extr
|
2724 | 2736 | if DEBUG:
|
2725 | 2737 | print('[browser launch:', html_file, ']')
|
2726 | 2738 | 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 | + |
2727 | 2746 | if expected is not None:
|
2728 | 2747 | try:
|
2729 | 2748 | self.harness_in_queue.put((
|
|
0 commit comments