feat: add performance controls for large browser ops
- Add throttled large-operation handling for tab, group, and session commands. - Introduce performance profiles, audible-tab aware gentle mode, and job progress tracking. - Support background session restores with status/cancel commands and lazy placeholders. - Expose new perf and extension CLI groups plus matching Python SDK methods. - Preserve pinned tabs during session snapshots and debounce auto-save updates. - Bump browser-cli and extension versions to 0.10.0 and add pytest-cov to dev deps. - Add coverage for performance controls, background jobs, lazy restores, and tab metadata.
This commit is contained in:
+1
-16
@@ -1,7 +1,6 @@
|
||||
"""Tests for tabs.* commands."""
|
||||
import pytest
|
||||
|
||||
|
||||
def test_tabs_list(browser):
|
||||
tabs = browser("tabs.list")
|
||||
assert isinstance(tabs, list)
|
||||
@@ -12,59 +11,51 @@ def test_tabs_list(browser):
|
||||
assert "url" in first
|
||||
assert "title" in first
|
||||
assert "muted" in first
|
||||
|
||||
assert "groupId" in first
|
||||
|
||||
def test_tabs_count(browser):
|
||||
count = browser("tabs.count", {})
|
||||
tabs = browser("tabs.list")
|
||||
assert count == len(tabs)
|
||||
|
||||
|
||||
def test_tabs_count_with_pattern(browser):
|
||||
count = browser("tabs.count", {"pattern": "http"})
|
||||
assert isinstance(count, int)
|
||||
assert count >= 0
|
||||
|
||||
|
||||
def test_tabs_filter(browser):
|
||||
result = browser("tabs.filter", {"pattern": "http"})
|
||||
assert isinstance(result, list)
|
||||
for tab in result:
|
||||
assert "http" in tab.get("url", "")
|
||||
|
||||
|
||||
def test_tabs_query(browser):
|
||||
result = browser("tabs.query", {"search": "a"})
|
||||
assert isinstance(result, list)
|
||||
|
||||
|
||||
def test_tabs_active_exists(browser):
|
||||
tabs = browser("tabs.list")
|
||||
active = [t for t in tabs if t.get("active")]
|
||||
assert len(active) >= 1, "Expected at least one active tab"
|
||||
|
||||
|
||||
def test_tabs_active_in_window(browser):
|
||||
active = next(t for t in browser("tabs.list") if t.get("active"))
|
||||
result = browser("tabs.active_in_window", {"windowId": active["windowId"]})
|
||||
assert result["id"] == active["id"]
|
||||
assert result["windowId"] == active["windowId"]
|
||||
|
||||
|
||||
def test_tabs_status(browser):
|
||||
result = browser("tabs.status", {})
|
||||
assert isinstance(result, dict)
|
||||
assert "id" in result
|
||||
assert "muted" in result
|
||||
|
||||
|
||||
def test_tabs_html(browser, http_tab):
|
||||
html = browser("tabs.html", {"tabId": http_tab["id"]})
|
||||
assert isinstance(html, str)
|
||||
assert len(html) > 0
|
||||
assert "<html" in html.lower() or "<!doctype" in html.lower()
|
||||
|
||||
|
||||
def test_tabs_close_by_id(browser):
|
||||
result = browser("navigate.open", {"url": "https://example.com", "background": True})
|
||||
tab_id = result["id"]
|
||||
@@ -74,7 +65,6 @@ def test_tabs_close_by_id(browser):
|
||||
tabs = browser("tabs.list")
|
||||
assert tab_id not in [t["id"] for t in tabs]
|
||||
|
||||
|
||||
def test_tabs_dedupe(browser):
|
||||
# Open the same URL twice
|
||||
r1 = browser("navigate.open", {"url": "https://example.com", "background": True})
|
||||
@@ -97,13 +87,11 @@ def test_tabs_dedupe(browser):
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def test_tabs_sort(browser):
|
||||
result = browser("tabs.sort", {"by": "domain"})
|
||||
# No error and at least returns something (None or dict)
|
||||
assert result is None or isinstance(result, dict)
|
||||
|
||||
|
||||
def test_tabs_move_forward(browser):
|
||||
r1 = browser("navigate.open", {"url": "https://example.com", "background": True})
|
||||
r2 = browser("navigate.open", {"url": "https://example.com", "background": True})
|
||||
@@ -116,13 +104,11 @@ def test_tabs_move_forward(browser):
|
||||
browser("tabs.close", {"tabId": id1})
|
||||
browser("tabs.close", {"tabId": id2})
|
||||
|
||||
|
||||
def test_tabs_merge_windows_no_crash(browser):
|
||||
result = browser("tabs.merge_windows")
|
||||
assert isinstance(result, dict)
|
||||
assert "moved" in result
|
||||
|
||||
|
||||
def test_tabs_mute_and_unmute(browser, http_tab):
|
||||
muted = browser("tabs.mute", {"tabId": http_tab["id"]})
|
||||
assert isinstance(muted, dict)
|
||||
@@ -142,7 +128,6 @@ def test_tabs_mute_and_unmute(browser, http_tab):
|
||||
status = browser("tabs.status", {"tabId": http_tab["id"]})
|
||||
assert status["muted"] is False
|
||||
|
||||
|
||||
def test_tabs_mute_requires_explicit_tab_when_multiple_tabs_open(browser):
|
||||
opened = browser("navigate.open", {"url": "https://example.com", "background": True})
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user