Skip to content

Commit 30b2eeb

Browse files
committed
Address review
1 parent fa3de84 commit 30b2eeb

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

test/common.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ def configure(data_dir):
139139
class SafariConfig:
140140
default_flags = ('', )
141141
executable_name = 'Safari'
142+
# For the macOS 'open' command, pass
143+
# --new: to make a new Safari app be launched, rather than add a tab to an existing Safari process/window
144+
# --fresh: do not restore old tabs (e.g. if user had old navigated windows open)
145+
# --background: Open the new Safari window behind the current Terminal window, to make following the test run more pleasing (this is for convenience only)
146+
# -a <exe_name>: The path to the executable to open, in this case Safari
147+
launch_prefix = ('open', '--new', '--fresh', '--background', '-a')
142148

143149
@staticmethod
144150
def configure(data_dir):
@@ -2589,6 +2595,8 @@ def browser_open(cls, url):
25892595
config = FirefoxConfig()
25902596
elif is_safari():
25912597
config = SafariConfig()
2598+
elif EMTEST_BROWSER_AUTO_CONFIG:
2599+
exit_with_error(f'EMTEST_BROWSER_AUTO_CONFIG only currently works with firefox, chrome and safari. EMTEST_BROWSER was "{EMTEST_BROWSER}"')
25922600

25932601
# Prepare the browser data directory, if it uses one.
25942602
if EMTEST_BROWSER_AUTO_CONFIG and config and hasattr(config, 'data_dir_flag'):
@@ -2609,22 +2617,15 @@ def browser_open(cls, url):
26092617
# Recreate the new data directory.
26102618
os.mkdir(browser_data_dir)
26112619

2612-
if not config:
2613-
exit_with_error(f'EMTEST_BROWSER_AUTO_CONFIG only currently works with firefox, chrome and safari. EMTEST_BROWSER was "{EMTEST_BROWSER}"')
26142620
if WINDOWS:
26152621
# Escape directory delimiter backslashes for shlex.split.
26162622
browser_data_dir = browser_data_dir.replace('\\', '\\\\')
26172623
config.configure(browser_data_dir)
26182624
browser_args += f' {config.data_dir_flag}"{browser_data_dir}"'
26192625

26202626
browser_args = shlex.split(browser_args)
2621-
if is_safari():
2622-
# For the macOS 'open' command, pass
2623-
# --new: to make a new Safari app be launched, rather than add a tab to an existing Safari process/window
2624-
# --fresh: do not restore old tabs (e.g. if user had old navigated windows open)
2625-
# --background: Open the new Safari window behind the current Terminal window, to make following the test run more pleasing (this is for convenience only)
2626-
# -a <exe_name>: The path to the executable to open, in this case Safari
2627-
browser_args = ['open', '--new', '--fresh', '--background', '-a'] + browser_args
2627+
if hasattr(config, 'launch_prefix'):
2628+
browser_args = list(config.launch_prefix) + browser_args
26282629

26292630
logger.info('Launching browser: %s', str(browser_args))
26302631

@@ -2661,7 +2662,7 @@ def launch_browser_harness_with_proc_snapshot_workaround(cls, parallel_harness,
26612662
# by the delta before->after.
26622663
cls.browser_procs = list(set(procs_after).difference(set(procs_before)))
26632664
if len(cls.browser_procs) == 0:
2664-
logger.warning('Could not detect the launched browser subprocesses. The test harness may not be able to close browser windows if a test hangs, and at harness exit.')
2665+
exit_with_error('Could not detect the launched browser subprocesses. The test harness will not be able to close the browser after testing is done, so aborting the test run here.')
26652666

26662667
# Firefox on Windows quirk:
26672668
# Make sure that each browser window is visible on the desktop. Otherwise

test/test_browser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from urllib.request import urlopen
1919

2020
import common
21-
from common import BrowserCore, RunnerCore, path_from_root, has_browser, Reporting, is_chrome, is_firefox, CHROMIUM_BASED_BROWSERS
21+
from common import BrowserCore, RunnerCore, path_from_root, has_browser, Reporting, is_chrome, is_firefox, is_safari, CHROMIUM_BASED_BROWSERS
2222
from common import create_file, parameterized, ensure_dir, disabled, flaky, test_file, WEBIDL_BINDER
2323
from common import read_file, EMRUN, no_wasm64, no_2gb, no_4gb, copytree, skip_if, skip_if_simple
2424
from common import requires_wasm2js, parameterize, find_browser_test_file, with_all_sjlj

0 commit comments

Comments
 (0)