refactor: reorganize client transport and extension internals
- Split client, native, remote, serve, markdown, and SDK internals into focused packages with direct imports. - Move local and remote transport framing/protocol helpers behind clearer module boundaries. - Break up the extension injected DOM logic into a separate content dispatch bundle and dedicated content modules. - Add explicit client handling for passive remote discovery without noisy PQ warnings. - Keep behavior covered with updated unit, integration, and extension tests.
This commit is contained in:
+14
-4
@@ -1,5 +1,6 @@
|
||||
"""Tests for tabs.* commands."""
|
||||
import time
|
||||
import uuid
|
||||
import pytest
|
||||
|
||||
def test_tabs_list(browser):
|
||||
@@ -67,9 +68,11 @@ def test_tabs_close_by_id(browser):
|
||||
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})
|
||||
r2 = browser("navigate.open", {"url": "https://example.com", "background": True})
|
||||
# Use a unique URL so pre-existing example.com tabs cannot be selected as
|
||||
# the survivor while both freshly opened duplicates stay open.
|
||||
url = f"https://example.com/?browser-cli-dedupe={uuid.uuid4().hex}"
|
||||
r1 = browser("navigate.open", {"url": url, "background": True})
|
||||
r2 = browser("navigate.open", {"url": url, "background": True})
|
||||
id1, id2 = r1["id"], r2["id"]
|
||||
|
||||
try:
|
||||
@@ -77,7 +80,7 @@ def test_tabs_dedupe(browser):
|
||||
# resolved a URL yet, so wait for both tabs to finish loading first.
|
||||
for _ in range(30):
|
||||
tabs = {t["id"]: t for t in browser("tabs.list")}
|
||||
if all(tabs.get(tid, {}).get("url", "").startswith("http") for tid in (id1, id2)):
|
||||
if all(tabs.get(tid, {}).get("url", "") == url for tid in (id1, id2)):
|
||||
break
|
||||
time.sleep(0.1)
|
||||
else:
|
||||
@@ -85,6 +88,13 @@ def test_tabs_dedupe(browser):
|
||||
|
||||
result = browser("tabs.dedupe")
|
||||
assert isinstance(result, dict)
|
||||
if result.get("jobId"):
|
||||
for _ in range(100):
|
||||
status = browser("jobs.status", {"jobId": result["jobId"]})
|
||||
if status.get("status") in {"done", "error", "cancelled"}:
|
||||
result = status.get("result") or result
|
||||
break
|
||||
time.sleep(0.1)
|
||||
assert result.get("closed", 0) >= 0
|
||||
# At least one of the two duplicates should be gone
|
||||
remaining = browser("tabs.list")
|
||||
|
||||
Reference in New Issue
Block a user