Skip to content

Commit a21cc1c

Browse files
committed
Fix running emrun tests on Linux against the Linux system browser. Fix emrun to work around Firefox https://bugzil.la/1996614
1 parent e8408e7 commit a21cc1c

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

emrun.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1768,7 +1768,7 @@ def run(args): # noqa: C901, PLR0912, PLR0915
17681768
if browser_exe == 'cmd':
17691769
url = url.replace('&', '^&')
17701770
url = url.replace('0.0.0.0', 'localhost')
1771-
browser += browser_args + [url]
1771+
browser += browser_args
17721772

17731773
if options.kill_start:
17741774
pname = processname_killed_atexit
@@ -1801,6 +1801,13 @@ def run(cmd):
18011801

18021802
browser += ['-no-remote', '--profile', profile_dir.replace('\\', '/')]
18031803

1804+
# Pass the URL to open as the very last item on the command line, and use the -url xxx parameter
1805+
# to open the url to work around https://bugzil.la/1996614.
1806+
if 'firefox' in browser_exe:
1807+
browser += ['-url', url]
1808+
else:
1809+
browser += [url]
1810+
18041811
if options.system_info:
18051812
logi('Time of run: ' + time.strftime("%x %X"))
18061813
logi(get_system_info(format_json=options.json))

test/browser_common.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from tools import feature_matrix, utils
3838
from tools.feature_matrix import UNSUPPORTED
3939
from tools.shared import DEBUG, EMCC, exit_with_error
40-
from tools.utils import MACOS, WINDOWS, memoize, path_from_root, read_binary
40+
from tools.utils import LINUX, MACOS, WINDOWS, memoize, path_from_root, read_binary
4141

4242
logger = logging.getLogger('common')
4343

@@ -167,6 +167,13 @@ def get_firefox_version():
167167
return UNSUPPORTED
168168
exe_path = shlex.split(EMTEST_BROWSER)[0]
169169
ini_path = os.path.join(os.path.dirname(exe_path), '../Resources/platform.ini' if MACOS else 'platform.ini')
170+
# On Linux, Firefox system installation uses a specific directory structure.
171+
if LINUX and exe_path.startswith('/usr/bin/'):
172+
if os.path.isfile('/usr/lib/firefox-esr/platform.ini'):
173+
ini_path = '/usr/lib/firefox-esr/platform.ini'
174+
elif os.path.isfile('/usr/lib/firefox/platform.ini'):
175+
ini_path = '/usr/lib/firefox/platform.ini'
176+
170177
# Extract the first numeric part before any dot (e.g. "Milestone=102.15.1" → 102)
171178
m = re.search(r"^Milestone=(.*)$", read_file(ini_path), re.MULTILINE)
172179
milestone = m.group(1).strip()
@@ -318,7 +325,17 @@ def configure_test_browser():
318325
return
319326

320327
if not EMTEST_BROWSER:
321-
EMTEST_BROWSER = 'google-chrome'
328+
def find_in_path(cmd):
329+
for path in os.environ['PATH'].split(os.pathsep):
330+
exe_file = os.path.join(path, cmd)
331+
if WINDOWS:
332+
exe_file += '.exe'
333+
if os.path.isfile(exe_file):
334+
return exe_file
335+
336+
EMTEST_BROWSER = find_in_path('google-chrome')
337+
if not EMTEST_BROWSER:
338+
EMTEST_BROWSER = find_in_path('firefox')
322339

323340
if WINDOWS and '"' not in EMTEST_BROWSER and "'" not in EMTEST_BROWSER:
324341
# On Windows env. vars canonically use backslashes as directory delimiters, e.g.

0 commit comments

Comments
 (0)