6fa931aa36
Testing / remote-protocol-compat (0.9.5) (push) Successful in 56s
Testing / remote-protocol-compat (0.9.3) (push) Successful in 59s
Testing / test (push) Successful in 1m1s
Build & Publish Package / publish (push) Successful in 33s
Package Extension / package-extension (push) Successful in 36s
- Gate TCP serve commands with safe-by-default policies, per-key allow tokens, per-key rate limiting, and audit labels. - Reuse authenticated encrypted remote sessions and parallelize/caches multi-browser fanout to reduce repeated handshake roundtrips. - Increase paged native-host batch size with extension-side byte budgeting to speed large tab listings safely. - Point install output at public Chrome Web Store / Firefox AMO listings by default, with --dev preserving unpacked workflows. - Share search-engine metadata between CLI and SDK and bump the package/extension version to 0.16.0. - Cover the new security, pooling, paging, install, and fanout behavior with expanded Python and extension tests.
59 lines
1.8 KiB
Python
59 lines
1.8 KiB
Python
"""
|
|
Shared pytest fixtures for browser-cli integration tests.
|
|
|
|
Tests that require a live browser connection use the `browser` fixture and
|
|
target the `testing` browser profile.
|
|
They are automatically skipped if the native host socket is not reachable.
|
|
"""
|
|
import time
|
|
import pytest
|
|
from browser_cli.client import send_command, BrowserNotConnected
|
|
from browser_cli.remote import pool as _remote_pool
|
|
|
|
TEST_BROWSER_PROFILE = "testing"
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _clear_remote_pool():
|
|
"""Close any pooled remote connections between tests so a connection opened
|
|
against one test's throwaway server can't leak into the next."""
|
|
yield
|
|
_remote_pool.close_all()
|
|
|
|
@pytest.fixture(scope="session")
|
|
def browser():
|
|
"""Returns a connected send_command callable for the testing profile, or skips the test."""
|
|
try:
|
|
send_command("tabs.list", profile=TEST_BROWSER_PROFILE)
|
|
except (BrowserNotConnected, RuntimeError) as e:
|
|
pytest.skip(
|
|
f"Browser 'testing' not connected — start Brave/Chrome with the extension loaded for that profile ({e})"
|
|
)
|
|
|
|
def _browser(command, args=None):
|
|
return send_command(command, args, profile=TEST_BROWSER_PROFILE)
|
|
|
|
return _browser
|
|
|
|
@pytest.fixture()
|
|
def http_tab(browser):
|
|
"""Opens a dedicated http/https tab for the current test and returns its tab info."""
|
|
created = browser("navigate.open", {"url": "https://example.com", "background": True})
|
|
tab_id = created["id"]
|
|
|
|
tab = None
|
|
try:
|
|
for _ in range(30):
|
|
tabs = browser("tabs.list")
|
|
tab = next((t for t in tabs if t.get("id") == tab_id and t.get("url", "").startswith("http")), None)
|
|
if tab is not None:
|
|
break
|
|
time.sleep(0.1)
|
|
if tab is None:
|
|
pytest.skip("Dedicated http/https test tab did not finish loading")
|
|
yield tab
|
|
finally:
|
|
try:
|
|
browser("tabs.close", {"tabId": tab_id})
|
|
except Exception:
|
|
pass
|