()
| 339 | |
| 340 | |
| 341 | def configure_test_browser(): |
| 342 | global EMTEST_BROWSER |
| 343 | |
| 344 | if not has_browser(): |
| 345 | return |
| 346 | |
| 347 | if not EMTEST_BROWSER: |
| 348 | EMTEST_BROWSER = 'google-chrome' |
| 349 | if not shutil.which(EMTEST_BROWSER): |
| 350 | EMTEST_BROWSER = 'firefox' |
| 351 | if not shutil.which(EMTEST_BROWSER): |
| 352 | # FIXME: This should really be an error, but this code currently also runs for non-browser tests. |
| 353 | EMTEST_BROWSER = 'default-browser-not-found' |
| 354 | |
| 355 | if MACOS and os.path.isdir('/Applications/Safari.app'): |
| 356 | EMTEST_BROWSER = '/Applications/Safari.app' |
| 357 | elif WINDOWS: |
| 358 | for browser in [ |
| 359 | f'{os.getenv("ProgramFiles(x86)", "")}\\Microsoft\\Edge\\Application\\msedge.exe', |
| 360 | f'{os.getenv("ProgramFiles", "")}\\Mozilla Firefox\\firefox.exe', |
| 361 | f'{os.getenv("LOCALAPPDATA", "")}\\Google\\Chrome SxS\\Application\\chrome.exe']: |
| 362 | if os.path.isfile(browser): |
| 363 | EMTEST_BROWSER = browser |
| 364 | |
| 365 | if WINDOWS and '"' not in EMTEST_BROWSER and "'" not in EMTEST_BROWSER: |
| 366 | # On Windows env. vars canonically use backslashes as directory delimiters, e.g. |
| 367 | # set EMTEST_BROWSER=C:\Program Files\Mozilla Firefox\firefox.exe |
| 368 | # and spaces are not escaped. But make sure to also support args, e.g. |
| 369 | # set EMTEST_BROWSER="C:\Users\clb\AppData\Local\Google\Chrome SxS\Application\chrome.exe" --enable-unsafe-webgpu |
| 370 | EMTEST_BROWSER = '"' + EMTEST_BROWSER.replace("\\", "\\\\") + '"' |
| 371 | |
| 372 | if EMTEST_BROWSER_AUTO_CONFIG: |
| 373 | config = get_browser_config() |
| 374 | if config: |
| 375 | EMTEST_BROWSER += ' ' + ' '.join(config.default_flags) |
| 376 | if EMTEST_HEADLESS == 1: |
| 377 | EMTEST_BROWSER += f" {config.headless_flags}" |
| 378 | if EMTEST_COS_EXTENSION_PATH and is_chrome(): |
| 379 | EMTEST_BROWSER += f' --load-extension="{EMTEST_COS_EXTENSION_PATH}"' |
| 380 | |
| 381 | |
| 382 | # Create a server and a web page. When a test runs, we tell the server about it, |
nothing calls this directly
no test coverage detected