Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/browser_harness/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,16 +498,16 @@ def print_update_banner(out=None):


def _chrome_running():
"""Cross-platform best-effort check for a running Chrome/Edge process."""
"""Cross-platform best-effort check for a running Chromium-based browser process."""
import platform, subprocess
system = platform.system()
try:
if system == "Windows":
out = subprocess.check_output(["tasklist"], text=True, timeout=5)
names = ("chrome.exe", "msedge.exe")
names = ("chrome.exe", "msedge.exe", "brave.exe")
else:
out = subprocess.check_output(["ps", "-A", "-o", "comm="], text=True, timeout=5)
names = ("Google Chrome", "chrome", "chromium", "Microsoft Edge", "msedge")
names = ("Google Chrome", "chrome", "chromium", "Microsoft Edge", "msedge", "Brave Browser", "brave-browser", "brave")
return any(n.lower() in out.lower() for n in names)
except Exception:
return False
Expand Down
16 changes: 16 additions & 0 deletions tests/unit/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@ def close(self):
self.closed = True


def test_chrome_running_detects_brave_on_windows(monkeypatch):
import platform, subprocess
monkeypatch.setattr(platform, "system", lambda: "Windows")
monkeypatch.setattr(subprocess, "check_output", lambda *a, **kw: "Image Name\nbrave.exe 1234 Console\n")

assert admin._chrome_running()


def test_chrome_running_detects_brave_on_posix(monkeypatch):
import platform, subprocess
monkeypatch.setattr(platform, "system", lambda: "Linux")
monkeypatch.setattr(subprocess, "check_output", lambda *a, **kw: "init\nbrave-browser\nbash\n")

assert admin._chrome_running()


def test_local_chrome_mode_is_false_when_env_provides_remote_cdp():
assert not admin._is_local_chrome_mode({"BU_CDP_WS": "ws://example.test/devtools/browser/1"})

Expand Down