Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

refactor(cdp): centralize session disposal

ldm049ea8a3e1cfc
diff --git a/moli-cdp-smoke/README.md b/moli-cdp-smoke/README.md
index 5e028858b..387cadb58 100644
--- a/moli-cdp-smoke/README.md
+++ b/moli-cdp-smoke/README.md
@@ -106,7 +106,8 @@ modes, the browser-level flattened-auto-attach requirement, repeated Tab
auto-attach reconciliation without duplicate sessions, stable Tab-to-Page
ownership across foreground changes, `Target.createTarget` foreground and
background behavior, Page visibility changes, screencast visibility
-`true -> false -> true` across demotion and close-driven promotion, and a real
+`true -> false -> true` across foreground changes and fallback selection after
+close, and a real
default discovery target that is not recreated after close. It also drives a
real middle-button press/release through `Input.dispatchMouseEvent` and checks
that the trusted `auxclick` anchor default action leaves the source visible and
@@ -199,7 +200,7 @@ Covered well:
response/event crossover, foreign flattened and legacy session rejection,
and staged peer-disconnect isolation.
- Raw CDP websocket command flow for `Runtime.evaluate(awaitPromise=true)` resolving page `fetch()`, timer-triggered `fetch()`, and WebSocket echo work without any follow-up client command; emitted `Runtime.executionContextCreated.uniqueId` round-tripping through DevTools-shaped `Runtime.evaluate` and `Runtime.callFunctionOn`; Chromium-calibrated pre-commit navigation suspension where DOM/Runtime/Debugger main-thread commands wait while `Performance.getMetrics`, `Runtime.terminateExecution`, and browser commands remain dispatchable; `Debugger.pause` responding before `Debugger.paused`, interrupting an in-flight `Runtime.evaluate`, and resuming that evaluation; commands queued behind a winning `Debugger.resume` completing through normal owner dispatch rather than synthetic cancellation; deterministic nested-function `Debugger.stepOut` response/resumed/caller-pause ordering; browser-global Tracing ownership across independent browser/page WebSocket frontends, including exactly one response for a synchronously completed start and the stop-before-start-ack `end response -> start error -> data -> complete` sequence; shared worker target discovery through `Target.getTargets`, worker-session `Runtime.executionContextCreated` / console log replay, and `Profiler.enable` / `Profiler.start` / `Profiler.stop` through `Target.setAutoAttach`; plus Chromium-calibrated DedicatedWorker target creation/update/attach ordering, exact worker-isolate Runtime/Console routing, `Inspector.workerScriptLoaded`, terminate, and owner-navigation cleanup.
-- The default raw `inspector-routing` group is the executable DevToolsSession boundary matrix. It covers per-session Main/IO FIFO and exactly-once completion, IO preemption of non-yielding JavaScript, DedicatedWorker and SharedWorker interrupt overtaking plus FIFO recovery, all 13 methods in Chromium 147's `ShouldSendOnIO`, normal debugger-pause pumping of one mixed V8/Page/DOM Main receiver, instrumentation-pause IO-only behavior, navigation replacement, auxiliary-session detach, BrowserContext teardown with interrupts in flight, and `Page.crash`. Every scenario runs in an isolated target and records its Chromium-derived contract.
+- The default raw `inspector-routing` group is the executable DevToolsSession boundary matrix. It covers per-session Main/IO FIFO and exactly-once completion, IO preemption of non-yielding JavaScript, DedicatedWorker and SharedWorker interrupt overtaking plus FIFO recovery, all 13 methods in Chromium 147's `ShouldSendOnIO`, normal debugger-pause pumping of one mixed V8/Page/DOM Main receiver, instrumentation-pause IO-only behavior, navigation replacement, attached-session detach, BrowserContext teardown with interrupts in flight, and `Page.crash`. Every scenario runs in an isolated target and records its Chromium-derived contract.
- The focused raw `agent-episode` group copies the recorded RL
`Runtime.evaluate(awaitPromise=true)` observe/fill/click path. It requires the
action response before destructive cross-document realm events, observes only
@@ -209,7 +210,7 @@ Covered well:
live DOM text; sampled `innerText` is recorded but may remain stale until the
next layout refresh by design.
- The focused raw `dom-parser-mutations` group holds a parser-blocking head script after an early head-only `DOM.getDocument` and requires Chromium's exact root-agent sequence: commit `DOM.documentUpdated`, parser-tail BODY `DOM.childNodeInserted`, DCL `DOM.documentUpdated`, then `Page.domContentEventFired`. It also proves that the early frontend node id is stale after the DCL barrier and that a refreshed snapshot contains the complete BODY.
-- Optional Puppeteer over CDP group for `puppeteer.connect()`, reconnecting an existing parked-then-promoted Page through a fresh browser session, browser-target and page-target `CDPSession`, `page.goto()`, `page.reload()`, selector-backed DOM activation navigation, same-document hash and History API navigation, `page.evaluate(fetch)`, keyboard input via `page.type()`, CSS / `$eval` / XPath element selection, and DOM interactions across text input, textarea, label/checkbox, radio, select, details/summary, disabled button, and form submission. It also covers `ElementHandle.boundingBox()` / `evaluate()` / `uploadFile()`, DedicatedWorker `workercreated` / `WebWorker.evaluate()` / exact-once worker-session console routing / explicit terminate / navigation-destroy lifecycle, current-viewport `page.screenshot({captureBeyondViewport:false})`, alert and console events, browser-session download behavior/events/artifact with peer-session event isolation, request interception `respond()` / `continue()`, page-scoped `CDPSession` Network event observation, and layout-backed `page.click()` dispatch.
+- Optional Puppeteer over CDP group for `puppeteer.connect()`, reconnecting an existing background Page and selecting it through a fresh browser session, browser-target and page-target `CDPSession`, `page.goto()`, `page.reload()`, selector-backed DOM activation navigation, same-document hash and History API navigation, `page.evaluate(fetch)`, keyboard input via `page.type()`, CSS / `$eval` / XPath element selection, and DOM interactions across text input, textarea, label/checkbox, radio, select, details/summary, disabled button, and form submission. It also covers `ElementHandle.boundingBox()` / `evaluate()` / `uploadFile()`, DedicatedWorker `workercreated` / `WebWorker.evaluate()` / exact-once worker-session console routing / explicit terminate / navigation-destroy lifecycle, current-viewport `page.screenshot({captureBeyondViewport:false})`, alert and console events, browser-session download behavior/events/artifact with peer-session event isolation, request interception `respond()` / `continue()`, page-scoped `CDPSession` Network event observation, and layout-backed `page.click()` dispatch.
- `browser.new_context()`, `context.new_page()`, multiple pages in one context, target switching, popup-scoped `page.route()` plus `evaluate(fetch)`, popup CDPSession response-stage body / stream / fulfill / fail flows, and held multi-context route / response-stage resume without cross-context Network event bleed.
- Top-level navigation, redirect final URL/response, reload-like click navigation, and history back/forward.
- Reload, same-document hash navigation, `history.pushState()` observation, Playwright `add_init_script()` page/context injection, `page.exposeFunction()` / `page.exposeBinding()` plus context-level exposed functions, and basic `domcontentloaded` / `load` / `networkidle` load-state waits with a parser-discovered delayed image.
@@ -219,7 +220,7 @@ Covered well:
JSHandle values, primitive/ElementHandle arguments, and timeout errors, plus
Playwright `page.wait_for_selector()` / `locator.wait_for()` attached,
visible, hidden, detached, and enabled-click auto-wait behavior.
-- Chromium inspector-protocol derived samples for `Page.domContentEventFired` before `Page.loadEventFired`, `Page.frameStartedLoading` / `Page.frameStoppedLoading`, non-empty `Page.frameAttached.parentFrameId`, `Page.getFrameTree`, dynamic and nested child-frame event fan-out across auxiliary sessions with session-local lifecycle/disable state, `Page.navigate` fragment navigation, `Page.getAppManifest` default/loading/parsing/error/redirect/dynamic-link contracts, successful-result caching and link invalidation, plus its `Manifest` Network request and terminal lifecycle, `Page.getLayoutMetrics`, `Runtime.executionContextCreated`, `Runtime.evaluate(returnByValue)` and exception details, session-local `Input.setIgnoreInputEvents` aggregation/navigation/detach behavior, `Input.insertText` bypass, idle `Input.cancelDragging`, `Audits.issueAdded` Quirks/CSP shape, replay ordering, navigation storage reset and session-local enable/disable, `Log.entryAdded` network metadata, buffered replay ordering, session-local delivery cursors, target-shared `Log.clear`, violations-report state and validation, `IO.resolveBlob` session-local object resolution and reopenable `blob:<uuid>` streams, session-local `Performance.enable/disable`, strict time-domain transitions, disabled `Performance.getMetrics`, `Emulation.setCPUThrottlingRate`, `Profiler.start` / `Profiler.stop` CPU profiles and CPU-throttling profile workflow, error contracts, auxiliary CDP-session profiler isolation across navigation and detach/reattach, `console.profile` / `console.profileEnd`, precise coverage / best-effort coverage including not-started error, counter reset, and detailed block coverage, `DOM.getAttributes`, `DOM.querySelector(All)` including default-depth node-path publication through ordered `DOM.setChildNodes` events, deep ancestry expansion, repeat suppression, and the chromedp `NodeReady` contract, live `DOMDebugger.getEventListeners`, session-owned event-listener breakpoint pause/re-pause/navigation/detach behavior, session-owned XHR/fetch breakpoint URL matching, synchronous pause data, navigation/child-frame/worker scope, multi-owner sequencing and detach behavior, live-node DOM mutation breakpoints for single-node and multi-child `DocumentFragment` insertion batches, connected-node removal/insertion phases with one pre-pause `DOM.childNodeRemoved`, same-value attributes and node removal with owner/peer data, parser mutation no-pause behavior, unbound-node path ordering, disable/navigation cleanup, and the `DOM.getNodeForLocation` hit-test capability boundary.
+- Chromium inspector-protocol derived samples for `Page.domContentEventFired` before `Page.loadEventFired`, `Page.frameStartedLoading` / `Page.frameStoppedLoading`, non-empty `Page.frameAttached.parentFrameId`, `Page.getFrameTree`, dynamic and nested child-frame event fan-out across attached sessions with session-local lifecycle/disable state, `Page.navigate` fragment navigation, `Page.getAppManifest` default/loading/parsing/error/redirect/dynamic-link contracts, successful-result caching and link invalidation, plus its `Manifest` Network request and terminal lifecycle, `Page.getLayoutMetrics`, `Runtime.executionContextCreated`, `Runtime.evaluate(returnByValue)` and exception details, session-local `Input.setIgnoreInputEvents` aggregation/navigation/detach behavior, `Input.insertText` bypass, idle `Input.cancelDragging`, `Audits.issueAdded` Quirks/CSP shape, replay ordering, navigation storage reset and session-local enable/disable, `Log.entryAdded` network metadata, buffered replay ordering, session-local delivery cursors, target-shared `Log.clear`, violations-report state and validation, `IO.resolveBlob` session-local object resolution and reopenable `blob:<uuid>` streams, session-local `Performance.enable/disable`, strict time-domain transitions, disabled `Performance.getMetrics`, `Emulation.setCPUThrottlingRate`, `Profiler.start` / `Profiler.stop` CPU profiles and CPU-throttling profile workflow, error contracts, attached CDP-session profiler isolation across navigation and detach/reattach, `console.profile` / `console.profileEnd`, precise coverage / best-effort coverage including not-started error, counter reset, and detailed block coverage, `DOM.getAttributes`, `DOM.querySelector(All)` including default-depth node-path publication through ordered `DOM.setChildNodes` events, deep ancestry expansion, repeat suppression, and the chromedp `NodeReady` contract, live `DOMDebugger.getEventListeners`, session-owned event-listener breakpoint pause/re-pause/navigation/detach behavior, session-owned XHR/fetch breakpoint URL matching, synchronous pause data, navigation/child-frame/worker scope, multi-owner sequencing and detach behavior, live-node DOM mutation breakpoints for single-node and multi-child `DocumentFragment` insertion batches, connected-node removal/insertion phases with one pre-pause `DOM.childNodeRemoved`, same-value attributes and node removal with owner/peer data, parser mutation no-pause behavior, unbound-node path ordering, disable/navigation cleanup, and the `DOM.getNodeForLocation` hit-test capability boundary.
- Raw `Input.dispatchKeyEvent` and `Input.dispatchMouseEvent` commands whose DOM handlers initiate a top-level Page replacement; both command responses must remain successful and the replacement Page must immediately accept follow-up CDP work. Focused Rust coverage separately holds the renderer ACK so the cleanup branch itself is deterministic.
- Chromium-calibrated `Tracing` browser-global ownership, duplicate start and peer end errors, data-source start acknowledgement before the `Tracing.start` response, exactly-once synchronous start responses, stop-before-ack response/error ordering, response-before-data ordering, cross-session clock markers, bounded `ReportEvents`, JSON `ReturnAsStream` through `IO.read`, and owner-detach cleanup. The CPU-profiler configuration additionally requires real V8 `Profile` / `ProfileChunk` events, non-empty samples with aligned `timeDeltas`, and named hot functions across navigation replacement, dedicated/shared worker teardown, and closed page targets. The same content contract is applied to the real agent-browser profiler artifact. Proto, gzip, Perfetto, system tracing, and periodic buffer reporting remain explicit unsupported boundaries rather than mock output.
- Chromium-calibrated live DOM mutation mirroring and editing: shallow/deep `DOM.getDocument` projections, `DOM.characterDataModified`, `DOM.childNodeCountUpdated`, `DOM.childNodeInserted`, `DOM.childNodeRemoved`, and event-before-response contracts for `DOM.moveTo`, `DOM.setAttributesAsText`, `DOM.setNodeName`, `DOM.setNodeValue`, and `DOM.setOuterHTML`, including same-value character-data writes, processing-instruction `xml` renaming, and returned frontend node identity.
@@ -231,7 +232,7 @@ Covered well:
- Playwright upstream derived samples for route request metadata, `page.route()` precedence over `context.route()`, context fallback, `times`, fallback chaining, terminal fulfill/abort routing, `route.fulfill()` cookies/headers, successful `page.pdf()` stream transport, page/main-frame/browser `CDPSession.send()`, session Network event delivery, unknown command errors, and post-detach command rejection.
- Request interception for main documents, page `fetch()` / `XMLHttpRequest`, worker `fetch()` / `XMLHttpRequest`, page `fetch()` response-stage pause / continue / fulfill / fail, page XHR response-stage `Fetch.getResponseBody`, page fetch response-stage `Fetch.takeResponseBodyAsStream` / `IO.read`, and basic page/worker fetch plus worker XHR `Fetch.authRequired` / `continueWithAuth` flows. `CancelAuth` coverage requires the challenged `401` response and body to remain observable, allows a configured response-stage pause, completes with `Network.loadingFinished` rather than `Network.loadingFailed`, and includes a top-level navigation driven by a separate Playwright CDP session.
- Dedicated worker `postMessage` round trips and same-URL/same-name SharedWorker port reuse, including worker-global identity and connection-count assertions.
-- Auxiliary `CDPSession` observation for `Network.requestWillBeSent`, `Network.responseReceived`, `Network.loadingFinished`, and `Network.loadingFailed`, including fetch/XHR POST body, request/response-header fidelity, and redirect-chain event ordering.
+- Attached `CDPSession` observation for `Network.requestWillBeSent`, `Network.responseReceived`, `Network.loadingFinished`, and `Network.loadingFailed`, including fetch/XHR POST body, request/response-header fidelity, and redirect-chain event ordering.
- Chromium-derived `Network.requestWillBeSentExtraInfo` / `Network.responseReceivedExtraInfo` correlation for normal HTTP documents, no-cookie redirects, cache revalidation, ordinary page `Fetch.continueRequest`, page and worker Basic auth, and requests sent before the server resets the connection without response bytes, both on the initial request and after a completed redirect hop. Worker coverage includes Fetch and XHR, with XHR held through a response-stage pause; worker `CancelAuth` requires one initial unauthenticated request ExtraInfo and one raw `401` response ExtraInfo. Coverage includes transport-generated `Host` / `Accept-Encoding`, per-hop exchange counts and status sequence, path-mismatched cookies using the public `NotOnPath` blocked reason, auth retries retaining the initial unauthenticated request headers, `Fetch.authRequired` rounds correlated only by `Fetch.requestId` without a non-standard `networkId`, a raw `304` ExtraInfo response paired with the merged cached `200` response, `redirectHasExtraInfo`, and `hasExtraInfo` without assuming an order CDP does not guarantee. Fetch interception also verifies Chromium's shared `XHR` type for page Fetch, XHR, and EventSource requests under each of the `Fetch`, `XHR`, and `EventSource` filters, while Network events retain their distinct high-level types. Reset cases require the complete observed request/redirect ExtraInfo set, no final response event, and a successful `Page.navigate` result carrying `net::ERR_CONNECTION_RESET` in `errorText`; they do not assume ExtraInfo precedes `loadingFailed` or that Chromium will not later finish its internal error document. Response-stage interception also verifies that original transport ExtraInfo is visible before `Fetch.requestPaused`, while a `Fetch.continueResponse` status/header override changes the later `Network.responseReceived` without emitting duplicate ExtraInfo.
- The focused `error-document` group turns the reset-before-response fixture into an end-to-end failed-navigation gate. It checks the direct and redirected event order, the split between internal frame URL and user-visible Target/history URL, `unreachableUrl`, independent loader/realm generations, old-global retirement, consecutive failures, successful recovery, and concurrent target isolation. Every scenario requires Runtime to remain usable after the failure, so the pre-fix permanent `NoDocumentLoaded` state fails the smoke rather than being hidden by a later successful navigation.
- Chromium-derived proxy authentication coverage uses a real local proxy and per-browser-context proxy configuration. HTTP Basic authentication must expose the initial unauthenticated target request headers and final `200` response through ExtraInfo without leaking `Proxy-Authorization`; an HTTPS `CONNECT` challenge canceled through Fetch must expose proxy origin, a `407` response with `hasExtraInfo=false`, and `Network.loadingFailed` without treating CONNECT headers as target-request ExtraInfo.
@@ -288,7 +289,7 @@ Covered well:
Documents, 204 responses, and transport failures, including response/request
correlation and retained-Document checks.
- Viewport resize, the explicit Playwright-generated screenshot clip boundary, and Chromium-calibrated geolocation
- position/unavailable/clear behavior across navigation and auxiliary CDP sessions.
+ position/unavailable/clear behavior across navigation and attached CDP sessions.
- localStorage, sessionStorage, basic IndexedDB, multi-context cookie isolation,
Blob DevTools UUID storage-partition isolation, and browser-context profile
overrides for user agent, locale, timezone, extra headers, and navigation
diff --git a/moli-cdp-smoke/moli_cdp_smoke/groups/browser_semantics.py b/moli-cdp-smoke/moli_cdp_smoke/groups/browser_semantics.py
index 68c6553af..ca6035bd4 100644
--- a/moli-cdp-smoke/moli_cdp_smoke/groups/browser_semantics.py
+++ b/moli-cdp-smoke/moli_cdp_smoke/groups/browser_semantics.py
@@ -187,11 +187,11 @@ def _semantic_scenarios() -> tuple[
),
(
"cdp_contract_multi_session_child_frame_realm_routing",
- "Enabling Runtime on an auxiliary target session does not block another attached client from evaluating in a child-frame realm.",
+ "Enabling Runtime on an attached target session does not block another attached client from evaluating in a child-frame realm.",
"Chromium multi-session Runtime and frame-realm behavior",
[
"Target.attachToTarget through Playwright",
- "Runtime.enable on auxiliary CDPSession",
+ "Runtime.enable on attached CDPSession",
"Page.navigate to iframe document",
"Runtime.evaluate in child frame through Playwright",
],
diff --git a/moli-cdp-smoke/moli_cdp_smoke/groups/chromium_cdp.py b/moli-cdp-smoke/moli_cdp_smoke/groups/chromium_cdp.py
index 40da30e03..1177db5aa 100644
--- a/moli-cdp-smoke/moli_cdp_smoke/groups/chromium_cdp.py
+++ b/moli-cdp-smoke/moli_cdp_smoke/groups/chromium_cdp.py
@@ -50,8 +50,8 @@ async def run_chromium_cdp_group(state: SmokeState) -> None:
await _verify_chromium_profiler_nested_console_profile_sample(state)
await _verify_chromium_profiler_parameterless_profile_end_sample(state)
await _verify_chromium_profiler_navigation_profile_continuity_sample(state)
- await _verify_chromium_profiler_auxiliary_session_navigation_profile_continuity_sample(state)
- await _verify_chromium_profiler_auxiliary_session_detach_clears_state_sample(state)
+ await _verify_chromium_profiler_attached_session_navigation_profile_continuity_sample(state)
+ await _verify_chromium_profiler_attached_session_detach_clears_state_sample(state)
await _verify_chromium_profiler_precise_coverage_error_sample(state)
await _verify_chromium_profiler_precise_coverage_sample(state)
await _verify_chromium_profiler_precise_coverage_counter_reset_sample(state)
@@ -2191,7 +2191,7 @@ async def _verify_chromium_child_frame_multi_session_fanout_sample(
)
for url in (outer_url, nested_url)
),
- "both auxiliary sessions child Page event fan-out",
+ "both attached sessions child Page event fan-out",
)
page_only_batch = page_only_events[page_only_start:]
@@ -3641,21 +3641,21 @@ async def _verify_chromium_io_resolve_blob_sample(state: SmokeState) -> None:
"Runtime.evaluate",
{"expression": "({owner: 'non-blob-session'})", "returnByValue": False},
)
- auxiliary_blob = await blob_session.send(
+ attached_blob = await blob_session.send(
"Runtime.evaluate",
- {"expression": "new Blob(['auxiliary'])", "returnByValue": False},
+ {"expression": "new Blob(['attached'])", "returnByValue": False},
)
- auxiliary_object_id = auxiliary_blob.get("result", {}).get("objectId")
- auxiliary_resolution = await blob_session.send(
+ attached_object_id = attached_blob.get("result", {}).get("objectId")
+ attached_resolution = await blob_session.send(
"IO.resolveBlob",
- {"objectId": auxiliary_object_id},
+ {"objectId": attached_object_id},
)
- if not auxiliary_resolution.get("uuid"):
- raise SmokeError(f"auxiliary IO.resolveBlob should succeed: {auxiliary_resolution}")
+ if not attached_resolution.get("uuid"):
+ raise SmokeError(f"attached IO.resolveBlob should succeed: {attached_resolution}")
cross_session_error = await _send_cdp_expect_optional_error(
non_blob_session,
"IO.resolveBlob",
- {"objectId": auxiliary_object_id},
+ {"objectId": attached_object_id},
)
if cross_session_error is None:
raise SmokeError("IO.resolveBlob must unwrap objectId in the calling Inspector session")
@@ -3721,27 +3721,27 @@ async def _verify_chromium_performance_enable_sample(state: SmokeState) -> None:
await state.cdp.send("Performance.enable", {"timeDomain": None})
await state.cdp.send("Performance.disable")
- auxiliary = await state.context.new_cdp_session(state.page)
+ attached = await state.context.new_cdp_session(state.page)
try:
primary_disabled = await _performance_metrics(state.cdp)
- auxiliary_disabled = await _performance_metrics(auxiliary)
- if primary_disabled or auxiliary_disabled:
+ attached_disabled = await _performance_metrics(attached)
+ if primary_disabled or attached_disabled:
raise SmokeError(
"Performance.getMetrics should be empty before each Inspector session is enabled"
)
await state.cdp.send("Performance.enable")
- if await _performance_metrics(auxiliary):
- raise SmokeError("Performance.enable must not enable an auxiliary Inspector session")
- await auxiliary.send("Performance.enable", {"timeDomain": "threadTicks"})
- if not await _performance_metrics(state.cdp) or not await _performance_metrics(auxiliary):
+ if await _performance_metrics(attached):
+ raise SmokeError("Performance.enable must not enable an attached Inspector session")
+ await attached.send("Performance.enable", {"timeDomain": "threadTicks"})
+ if not await _performance_metrics(state.cdp) or not await _performance_metrics(attached):
raise SmokeError("enabled Performance sessions should each expose metrics")
await state.cdp.send("Performance.disable")
- if not await _performance_metrics(auxiliary):
+ if not await _performance_metrics(attached):
raise SmokeError("disabling one Performance session must not disable another")
- await auxiliary.send("Performance.disable")
+ await attached.send("Performance.disable")
finally:
- await auxiliary.detach()
+ await attached.detach()
state.record("chromium_performance_enable_sample")
@@ -4240,22 +4240,22 @@ async def _verify_chromium_profiler_navigation_profile_continuity_sample(state:
state.record("chromium_profiler_navigation_profile_continuity_sample")
-async def _verify_chromium_profiler_auxiliary_session_navigation_profile_continuity_sample(state: SmokeState) -> None:
- await _navigate_with_cdp_until_dom_ready(state, f"{state.fixture}/plain?profiler-aux-navigation-before")
- aux_cdp = await state.context.new_cdp_session(state.page)
+async def _verify_chromium_profiler_attached_session_navigation_profile_continuity_sample(state: SmokeState) -> None:
+ await _navigate_with_cdp_until_dom_ready(state, f"{state.fixture}/plain?profiler-attached-navigation-before")
+ attached_cdp = await state.context.new_cdp_session(state.page)
await state.cdp.send("Profiler.enable")
- await aux_cdp.send("Profiler.enable")
- await aux_cdp.send("Profiler.setSamplingInterval", {"interval": 100})
- await aux_cdp.send("Profiler.start")
+ await attached_cdp.send("Profiler.enable")
+ await attached_cdp.send("Profiler.setSamplingInterval", {"interval": 100})
+ await attached_cdp.send("Profiler.start")
try:
primary_stop_before = await _send_cdp_expect_optional_error(state.cdp, "Profiler.stop", {})
if not primary_stop_before or "No recording profiles found" not in str(primary_stop_before):
raise SmokeError(
- "Primary CDP session must not observe auxiliary Profiler.start recording: "
+ "Primary CDP session must not observe attached Profiler.start recording: "
f"{primary_stop_before}"
)
- before = await aux_cdp.send(
+ before = await attached_cdp.send(
"Runtime.evaluate",
{
"expression": """
@@ -4275,16 +4275,16 @@ async def _verify_chromium_profiler_auxiliary_session_navigation_profile_continu
assert_equal(
before.get("result", {}).get("value"),
True,
- "Chromium Profiler auxiliary pre-navigation work sample",
+ "Chromium Profiler attached pre-navigation work sample",
)
- await aux_cdp.send(
+ await attached_cdp.send(
"Page.navigate",
- {"url": f"{state.fixture}/plain?profiler-aux-navigation-after"},
+ {"url": f"{state.fixture}/plain?profiler-attached-navigation-after"},
)
await state.page.wait_for_load_state("load", timeout=10_000)
- after = await aux_cdp.send(
+ after = await attached_cdp.send(
"Runtime.evaluate",
{
"expression": """
@@ -4304,34 +4304,34 @@ async def _verify_chromium_profiler_auxiliary_session_navigation_profile_continu
assert_equal(
after.get("result", {}).get("value"),
True,
- "Chromium Profiler auxiliary post-navigation work sample",
+ "Chromium Profiler attached post-navigation work sample",
)
- profile_result = await aux_cdp.send("Profiler.stop")
+ profile_result = await attached_cdp.send("Profiler.stop")
primary_stop_after = await _send_cdp_expect_optional_error(state.cdp, "Profiler.stop", {})
if not primary_stop_after or "No recording profiles found" not in str(primary_stop_after):
raise SmokeError(
- "Primary CDP session must stay isolated after auxiliary Profiler.stop: "
+ "Primary CDP session must stay isolated after attached Profiler.stop: "
f"{primary_stop_after}"
)
finally:
- await aux_cdp.send("Profiler.disable")
+ await attached_cdp.send("Profiler.disable")
await state.cdp.send("Profiler.disable")
profile = profile_result.get("profile") or {}
- _assert_profile_tree_shape(profile, "auxiliary Profiler.stop navigation continuity profile")
+ _assert_profile_tree_shape(profile, "attached Profiler.stop navigation continuity profile")
function_names = _profile_function_names(profile)
- # As above, navigation restores the auxiliary session's recording state, not samples from the
+ # As above, navigation restores the attached session's recording state, not samples from the
# disposed isolate. Session isolation and replacement-backend sampling are the stable contract.
if "chromiumProfilerAuxAfterNavigationWork" not in function_names:
raise SmokeError(
- "Auxiliary Profiler.stop after navigation should include post-navigation work "
+ "Attached Profiler.stop after navigation should include post-navigation work "
f"function; names={sorted(function_names)}"
)
- state.record("chromium_profiler_auxiliary_session_navigation_profile_continuity_sample")
+ state.record("chromium_profiler_attached_session_navigation_profile_continuity_sample")
-async def _verify_chromium_profiler_auxiliary_session_detach_clears_state_sample(state: SmokeState) -> None:
+async def _verify_chromium_profiler_attached_session_detach_clears_state_sample(state: SmokeState) -> None:
await _navigate_with_cdp_until_dom_ready(state, f"{state.fixture}/plain?profiler-session-detach")
old_cdp = await state.context.new_cdp_session(state.page)
await old_cdp.send("Profiler.enable")
@@ -4343,19 +4343,19 @@ async def _verify_chromium_profiler_auxiliary_session_detach_clears_state_sample
start_error = await _send_cdp_expect_optional_error(new_cdp, "Profiler.start", {})
if not start_error or "Profiler is not enabled" not in str(start_error):
raise SmokeError(
- "New auxiliary CDP session must not inherit detached Profiler.enable/start state: "
+ "New attached CDP session must not inherit detached Profiler.enable/start state: "
f"{start_error}"
)
stop_error = await _send_cdp_expect_optional_error(new_cdp, "Profiler.stop", {})
if not stop_error or "No recording profiles found" not in str(stop_error):
raise SmokeError(
- "New auxiliary CDP session must not inherit detached recording state: "
+ "New attached CDP session must not inherit detached recording state: "
f"{stop_error}"
)
finally:
await new_cdp.detach()
- state.record("chromium_profiler_auxiliary_session_detach_clears_state_sample")
+ state.record("chromium_profiler_attached_session_detach_clears_state_sample")
async def _verify_chromium_profiler_precise_coverage_error_sample(state: SmokeState) -> None:
diff --git a/moli-cdp-smoke/moli_cdp_smoke/groups/core.py b/moli-cdp-smoke/moli_cdp_smoke/groups/core.py
index 08408b4ee..3f4f6e3ec 100644
--- a/moli-cdp-smoke/moli_cdp_smoke/groups/core.py
+++ b/moli-cdp-smoke/moli_cdp_smoke/groups/core.py
@@ -495,12 +495,12 @@ async def run_core_group(state: SmokeState) -> None:
lambda: _network_request_finished_for_url(
popup_network_events, f"{fixture}/api?popup-cdp=1"
),
- "popup auxiliary CDPSession Network events",
+ "popup attached CDPSession Network events",
)
finally:
await popup_cdp.detach()
await cdp_popup.close()
- state.record("popup_auxiliary_cdp_session_network_events")
+ state.record("popup_attached_cdp_session_network_events")
await page.goto(f"{fixture}/plain", wait_until="load", timeout=10_000)
async with page.expect_popup(timeout=5_000) as precedence_popup_info:
@@ -593,8 +593,8 @@ async def run_core_group(state: SmokeState) -> None:
assert_equal(await page.text_content("main"), "history b", "history goForward text")
state.record("history_back_forward")
- parked_page = await context.new_page()
- await parked_page.goto(f"{fixture}/plain", wait_until="load", timeout=10_000)
+ background_page = await context.new_page()
+ await background_page.goto(f"{fixture}/plain", wait_until="load", timeout=10_000)
await page.bring_to_front()
back_after_switch = await page.go_back(wait_until="load", timeout=10_000)
assert_equal(page.url, f"{fixture}/history-a", "history goBack URL after target switch")
@@ -602,7 +602,7 @@ async def run_core_group(state: SmokeState) -> None:
forward_after_switch = await page.go_forward(wait_until="load", timeout=10_000)
assert_equal(page.url, f"{fixture}/history-b", "history goForward URL after target switch")
assert_equal(forward_after_switch.url if forward_after_switch else None, f"{fixture}/history-b", "history goForward response URL after target switch")
- await parked_page.close()
+ await background_page.close()
state.record("history_back_forward_after_target_switch")
await page.goto(f"{fixture}/plain", wait_until="load", timeout=10_000)
diff --git a/moli-cdp-smoke/moli_cdp_smoke/groups/emulation_storage.py b/moli-cdp-smoke/moli_cdp_smoke/groups/emulation_storage.py
index 52bfc8346..785d14088 100644
--- a/moli-cdp-smoke/moli_cdp_smoke/groups/emulation_storage.py
+++ b/moli-cdp-smoke/moli_cdp_smoke/groups/emulation_storage.py
@@ -56,7 +56,7 @@ async def run_geolocation_override_smoke(browser: Any, fixture: str, results: li
page = await context.new_page()
await page.goto(f"{fixture}/plain", wait_until="load", timeout=10_000)
primary = await context.new_cdp_session(page)
- auxiliary = await context.new_cdp_session(page)
+ attached = await context.new_cdp_session(page)
try:
await primary.send(
"Emulation.setGeolocationOverride",
@@ -80,14 +80,14 @@ async def run_geolocation_override_smoke(browser: Any, fixture: str, results: li
assert_equal(unavailable.get("ok"), False, "CDP explicit unavailable result")
assert_equal(unavailable.get("code"), 2, "CDP explicit unavailable error code")
- await auxiliary.send(
+ await attached.send(
"Emulation.setGeolocationOverride",
{"latitude": 35, "longitude": 139, "accuracy": 3},
)
assert_equal(
await _read_geolocation(page),
{"ok": True, "latitude": 35, "longitude": 139, "accuracy": 3},
- "CDP auxiliary session geolocation override",
+ "CDP attached session geolocation override",
)
await primary.send("Emulation.clearGeolocationOverride")
@@ -95,7 +95,7 @@ async def run_geolocation_override_smoke(browser: Any, fixture: str, results: li
assert_equal(cleared.get("ok"), False, "CDP geolocation clear restores provider")
record(results, "geolocation_override_set_unavailable_clear")
finally:
- await auxiliary.detach()
+ await attached.detach()
await primary.detach()
finally:
await context.close()
diff --git a/moli-cdp-smoke/moli_cdp_smoke/groups/inspector_routing.py b/moli-cdp-smoke/moli_cdp_smoke/groups/inspector_routing.py
index 83c86d416..0822f7b34 100644
--- a/moli-cdp-smoke/moli_cdp_smoke/groups/inspector_routing.py
+++ b/moli-cdp-smoke/moli_cdp_smoke/groups/inspector_routing.py
@@ -16,7 +16,7 @@ class InspectorRoutingPage:
browser_context_id: str
target_id: str
primary_session_id: str
- auxiliary_session_id: str
+ attached_session_id: str
async def run_inspector_routing_group(
@@ -258,7 +258,7 @@ for (;;) {}"""
})()""",
"returnByValue": True,
},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
main_two_id = await client.send(
"Runtime.evaluate",
@@ -266,7 +266,7 @@ for (;;) {}"""
"expression": "globalThis.__inspectorRoutingMainOrder.push('m2')",
"returnByValue": True,
},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
observed = await _recv_for(client, 0.2)
blocked_ids = {run_id, main_one_id, main_two_id}
@@ -280,16 +280,16 @@ for (;;) {}"""
source_one_id = await client.send(
"Debugger.getScriptSource",
{"scriptId": script_id},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
source_two_id = await client.send(
"Debugger.getScriptSource",
{"scriptId": script_id},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
terminate_id = await client.send(
"Runtime.terminateExecution",
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
expected_ids = {
run_id,
@@ -373,7 +373,7 @@ for (;;) {}"""
results,
"raw_cdp_active_javascript_main_io_lane_matrix",
contract=(
- "An auxiliary IO lane interrupts non-yielding JavaScript owned by another "
+ "An attached IO lane interrupts non-yielding JavaScript owned by another "
"session; IO and Main remain FIFO within their own lanes, each command responds "
"once, and the isolate recovers."
),
@@ -716,7 +716,7 @@ inspectorRoutingHotLoop();"""
await _wait_for_witness(fixture, expected_count=1)
pause_id = await client.send(
"Debugger.pause",
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
pause_response: dict[str, Any] | None = None
@@ -725,7 +725,7 @@ inspectorRoutingHotLoop();"""
deadline = asyncio.get_running_loop().time() + 5.0
while pause_response is None or paused_events.keys() != {
page.primary_session_id,
- page.auxiliary_session_id,
+ page.attached_session_id,
}:
remaining = deadline - asyncio.get_running_loop().time()
if remaining <= 0:
@@ -745,14 +745,14 @@ inspectorRoutingHotLoop();"""
pause_response = message
session_id = message.get("sessionId")
if (
- session_id in {page.primary_session_id, page.auxiliary_session_id}
+ session_id in {page.primary_session_id, page.attached_session_id}
and message.get("method") == "Debugger.paused"
):
paused_events[session_id] = message
if "error" in pause_response:
raise SmokeError(f"Debugger.pause failed during active JS: {pause_response}")
- call_frames = paused_events[page.auxiliary_session_id].get("params", {}).get(
+ call_frames = paused_events[page.attached_session_id].get("params", {}).get(
"callFrames"
)
if not isinstance(call_frames, list) or not call_frames:
@@ -798,7 +798,7 @@ inspectorRoutingHotLoop();"""
("Debugger.setBreakpointsActive", {"active": True}),
]
catalog_ids = [
- await client.send(method, params, session_id=page.auxiliary_session_id)
+ await client.send(method, params, session_id=page.attached_session_id)
for method, params in catalog
]
catalog_responses, catalog_seen = await _recv_responses(
@@ -835,7 +835,7 @@ inspectorRoutingHotLoop();"""
await client.send(
"Debugger.getScriptSource",
{"scriptId": script_id},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
for _ in range(32)
]
@@ -872,7 +872,7 @@ inspectorRoutingHotLoop();"""
await client.send(
"Debugger.removeBreakpoint",
{"breakpointId": breakpoint_id},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
for breakpoint_id in breakpoint_ids
]
@@ -887,7 +887,7 @@ inspectorRoutingHotLoop();"""
resume_id = await client.send(
"Debugger.resume",
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
resume_response, resume_seen = await client.recv_until_id(resume_id, timeout=5)
if "error" in resume_response:
@@ -902,7 +902,7 @@ inspectorRoutingHotLoop();"""
for message in resume_seen
if message.get("method") == "Debugger.resumed"
}
- for session_id in (page.primary_session_id, page.auxiliary_session_id):
+ for session_id in (page.primary_session_id, page.attached_session_id):
if session_id not in resumed_sessions:
resume_seen.append(
await _recv_until_session_event(
@@ -917,7 +917,7 @@ inspectorRoutingHotLoop();"""
follower_id = await client.send(
"Runtime.evaluate",
{"expression": "21 * 2", "returnByValue": True},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
early_after_resume = await _recv_for(client, 0.1)
if any(message.get("id") in {run_id, follower_id} for message in early_after_resume):
@@ -928,7 +928,7 @@ inspectorRoutingHotLoop();"""
terminate_id = await client.send(
"Runtime.terminateExecution",
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
final_responses, final_seen = await _recv_responses(
client,
@@ -982,12 +982,12 @@ async def _nested_v8_main_receiver_matrix(
) -> None:
dom_enable_id = await client.send(
"DOM.enable",
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
await client.recv_until_id(dom_enable_id, timeout=5)
frame_tree_id = await client.send(
"Page.getFrameTree",
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
frame_tree, _ = await client.recv_until_id(frame_tree_id, timeout=5)
frame_id = (
@@ -1001,7 +1001,7 @@ async def _nested_v8_main_receiver_matrix(
isolated_id = await client.send(
"Page.createIsolatedWorld",
{"frameId": frame_id, "worldName": "inspector-routing-nested-main"},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
isolated, _ = await client.recv_until_id(isolated_id, timeout=5)
isolated_context_id = isolated.get("result", {}).get("executionContextId")
@@ -1018,7 +1018,7 @@ async def _nested_v8_main_receiver_matrix(
deadline = asyncio.get_running_loop().time() + 5.0
while paused_events.keys() != {
page.primary_session_id,
- page.auxiliary_session_id,
+ page.attached_session_id,
}:
remaining = deadline - asyncio.get_running_loop().time()
if remaining <= 0:
@@ -1032,32 +1032,32 @@ async def _nested_v8_main_receiver_matrix(
raise SmokeError("debugger evaluation completed before Debugger.paused")
session_id = message.get("sessionId")
if (
- session_id in {page.primary_session_id, page.auxiliary_session_id}
+ session_id in {page.primary_session_id, page.attached_session_id}
and message.get("method") == "Debugger.paused"
):
paused_events[session_id] = message
- call_frames = paused_events[page.auxiliary_session_id].get("params", {}).get(
+ call_frames = paused_events[page.attached_session_id].get("params", {}).get(
"callFrames"
)
if not isinstance(call_frames, list) or not call_frames:
raise SmokeError(
- "auxiliary Debugger.paused event has no call frame: "
- f"{paused_events[page.auxiliary_session_id]}"
+ "attached Debugger.paused event has no call frame: "
+ f"{paused_events[page.attached_session_id]}"
)
call_frame_id = call_frames[0].get("callFrameId")
if not isinstance(call_frame_id, str) or not call_frame_id:
- raise SmokeError(f"auxiliary pause has no callFrameId: {call_frames[0]}")
+ raise SmokeError(f"attached pause has no callFrameId: {call_frames[0]}")
cross_session_ids: dict[str, list[int]] = {
page.primary_session_id: [],
- page.auxiliary_session_id: [],
+ page.attached_session_id: [],
}
cross_session_expected_values: dict[int, int] = {}
for index in range(32):
for session_id, base in (
(page.primary_session_id, 1000),
- (page.auxiliary_session_id, 2000),
+ (page.attached_session_id, 2000),
):
message_id = await client.send(
"Runtime.evaluate",
@@ -1109,7 +1109,7 @@ async def _nested_v8_main_receiver_matrix(
),
"returnByValue": True,
},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
for index in range(1, 4)
]
@@ -1131,7 +1131,7 @@ async def _nested_v8_main_receiver_matrix(
object_id = await client.send(
"Runtime.evaluate",
{"expression": "({answer: 42})"},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
object_response, _ = await client.recv_until_id(object_id, timeout=5)
remote_object_id = (
@@ -1144,7 +1144,7 @@ async def _nested_v8_main_receiver_matrix(
await client.send(
"Runtime.getProperties",
{"objectId": remote_object_id, "ownProperties": True},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
for _ in range(256)
]
@@ -1183,7 +1183,7 @@ async def _nested_v8_main_receiver_matrix(
),
"ownProperties": True,
},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
mixed_property_ids.append(message_id)
mixed_property_should_succeed[message_id] = should_succeed
@@ -1223,7 +1223,7 @@ async def _nested_v8_main_receiver_matrix(
"functionDeclaration": "function () { return this.answer + 1; }",
"returnByValue": True,
},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
called, _ = await client.recv_until_id(call_id, timeout=5)
assert_equal(
@@ -1240,7 +1240,7 @@ async def _nested_v8_main_receiver_matrix(
"expression": "40 + 2",
"returnByValue": True,
},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
for _ in range(64)
]
@@ -1274,7 +1274,7 @@ async def _nested_v8_main_receiver_matrix(
"expression": "globalThis.__nestedExplicitContext = 44",
"returnByValue": True,
},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
context_evaluate, _ = await client.recv_until_id(context_evaluate_id, timeout=5)
assert_equal(
@@ -1285,7 +1285,7 @@ async def _nested_v8_main_receiver_matrix(
resume_id = await client.send(
"Debugger.resume",
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
responses, resume_seen = await _recv_responses(
client,
@@ -1293,14 +1293,14 @@ async def _nested_v8_main_receiver_matrix(
timeout=5,
)
if "error" in responses[resume_id]:
- raise SmokeError(f"auxiliary Debugger.resume failed: {responses[resume_id]}")
+ raise SmokeError(f"attached Debugger.resume failed: {responses[resume_id]}")
assert_equal(
responses[paused_evaluate_id]
.get("result", {})
.get("result", {})
.get("value"),
42,
- "nested Main original evaluation after auxiliary resume",
+ "nested Main original evaluation after attached resume",
)
resumed_sessions = {
message.get("sessionId")
@@ -1323,7 +1323,7 @@ async def _nested_v8_main_receiver_matrix(
contract=(
"A normal debugger pause pumps V8-backed commands from the Main DevTools "
"receiver for every attached session, including explicit-context Runtime and "
- "call-frame/object commands; an auxiliary IO resume releases the original "
+ "call-frame/object commands; an attached IO resume releases the original "
"JavaScript stack."
),
source="Chromium nested main-thread RunLoop executable probe",
@@ -1359,12 +1359,12 @@ async def _nested_non_v8_main_receiver_matrix(
) -> None:
dom_enable_id = await client.send(
"DOM.enable",
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
await client.recv_until_id(dom_enable_id, timeout=5)
initial_tree_id = await client.send(
"Page.getFrameTree",
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
initial_tree, _ = await client.recv_until_id(initial_tree_id, timeout=5)
frame_id = (
@@ -1412,7 +1412,7 @@ async def _nested_non_v8_main_receiver_matrix(
("DOM.getDocument", {"depth": 0}),
]
command_ids = [
- await client.send(method, params, session_id=page.auxiliary_session_id)
+ await client.send(method, params, session_id=page.attached_session_id)
for method, params in commands
]
seen = await _recv_for(client, 1.0)
@@ -1429,7 +1429,7 @@ async def _nested_non_v8_main_receiver_matrix(
resume_id = await client.send(
"Debugger.resume",
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
after_resume, resume_seen = await _recv_responses(
client,
@@ -1520,7 +1520,7 @@ async def _performance_io_during_active_javascript(
) -> None:
performance_enable_id = await client.send(
"Performance.enable",
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
await client.recv_until_id(performance_enable_id, timeout=5)
await _reset_witness(fixture)
@@ -1542,11 +1542,11 @@ async def _performance_io_during_active_javascript(
follower_id = await client.send(
"Runtime.evaluate",
{"expression": "6 * 7", "returnByValue": True},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
metrics_id = await client.send(
"Performance.getMetrics",
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
metrics, before_terminate = await client.recv_until_id(metrics_id, timeout=5)
if any(message.get("id") in {busy_id, follower_id} for message in before_terminate):
@@ -1582,7 +1582,7 @@ async def _performance_io_during_active_javascript(
terminate_id = await client.send(
"Runtime.terminateExecution",
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
responses, after_terminate = await _recv_responses(
client,
@@ -1596,7 +1596,7 @@ async def _performance_io_during_active_javascript(
)
performance_disable_id = await client.send(
"Performance.disable",
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
await client.recv_until_id(performance_disable_id, timeout=5)
record_contract(
@@ -1637,7 +1637,7 @@ async def _mixed_io_agent_response_order(
"sourceURL": "inspector-routing-mixed-io.js",
"persistScript": True,
},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
compile_response, _ = await client.recv_until_id(compile_id, timeout=5)
script_id = compile_response.get("result", {}).get("scriptId")
@@ -1648,7 +1648,7 @@ async def _mixed_io_agent_response_order(
performance_enable_id = await client.send(
"Performance.enable",
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
await client.recv_until_id(performance_enable_id, timeout=5)
@@ -1658,7 +1658,7 @@ async def _mixed_io_agent_response_order(
(
await client.send(
"Performance.getMetrics",
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
),
"Performance.getMetrics",
)
@@ -1668,7 +1668,7 @@ async def _mixed_io_agent_response_order(
await client.send(
"Debugger.getScriptSource",
{"scriptId": script_id},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
),
"Debugger.getScriptSource",
)
@@ -1678,7 +1678,7 @@ async def _mixed_io_agent_response_order(
await client.send(
"Emulation.setScriptExecutionDisabled",
{"value": False},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
),
"Emulation.setScriptExecutionDisabled",
)
@@ -1688,7 +1688,7 @@ async def _mixed_io_agent_response_order(
await client.send(
"Debugger.getScriptSource",
{"scriptId": script_id},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
),
"Debugger.getScriptSource",
)
@@ -1729,7 +1729,7 @@ async def _mixed_io_agent_response_order(
performance_disable_id = await client.send(
"Performance.disable",
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
await client.recv_until_id(performance_disable_id, timeout=5)
record_contract(
@@ -1775,13 +1775,13 @@ async def _script_execution_disabled_io_during_active_javascript(
follower_id = await client.send(
"Runtime.evaluate",
{"expression": "40 + 2", "returnByValue": True},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
disable_id = await client.send(
"Emulation.setScriptExecutionDisabled",
{"value": True},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
disable_response, disable_seen = await client.recv_until_id(disable_id, timeout=5)
if "error" in disable_response:
@@ -1798,7 +1798,7 @@ async def _script_execution_disabled_io_during_active_javascript(
enable_id = await client.send(
"Emulation.setScriptExecutionDisabled",
{"value": False},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
enable_response, enable_seen = await client.recv_until_id(enable_id, timeout=5)
if "error" in enable_response:
@@ -1814,7 +1814,7 @@ async def _script_execution_disabled_io_during_active_javascript(
terminate_id = await client.send(
"Runtime.terminateExecution",
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
responses, termination_seen = await _recv_responses(
client,
@@ -1860,7 +1860,7 @@ async def _instrumentation_pause_io_only_receiver(
breakpoint_id = await client.send(
"Debugger.setInstrumentationBreakpoint",
{"instrumentation": "beforeScriptExecution"},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
breakpoint_response, _ = await client.recv_until_id(breakpoint_id, timeout=5)
instrumentation_breakpoint_id = breakpoint_response.get("result", {}).get(
@@ -1875,16 +1875,16 @@ async def _instrumentation_pause_io_only_receiver(
run_id = await client.send(
"Runtime.evaluate",
{"expression": source, "returnByValue": True},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
paused_events = await _recv_paused_for_both_sessions(client, page, run_id)
- auxiliary_pause = paused_events[page.auxiliary_session_id]
+ attached_pause = paused_events[page.attached_session_id]
assert_equal(
- auxiliary_pause.get("params", {}).get("reason"),
+ attached_pause.get("params", {}).get("reason"),
"instrumentation",
"instrumentation pause reason",
)
- call_frames = auxiliary_pause.get("params", {}).get("callFrames")
+ call_frames = attached_pause.get("params", {}).get("callFrames")
script_id = (
call_frames[0].get("location", {}).get("scriptId")
if isinstance(call_frames, list)
@@ -1894,7 +1894,7 @@ async def _instrumentation_pause_io_only_receiver(
)
if not isinstance(script_id, str) or not script_id:
raise SmokeError(
- f"instrumentation pause returned no script id: {auxiliary_pause}"
+ f"instrumentation pause returned no script id: {attached_pause}"
)
main_follower_id = await client.send(
@@ -1912,12 +1912,12 @@ async def _instrumentation_pause_io_only_receiver(
source_id = await client.send(
"Debugger.getScriptSource",
{"scriptId": script_id},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
remove_id = await client.send(
"Debugger.removeBreakpoint",
{"breakpointId": instrumentation_breakpoint_id},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
io_responses, io_seen = await _recv_responses(
client,
@@ -1937,7 +1937,7 @@ async def _instrumentation_pause_io_only_receiver(
resume_id = await client.send(
"Debugger.resume",
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
pending_after_resume = {run_id, main_follower_id}.difference(
early_command_responses
@@ -1987,7 +1987,7 @@ async def _instrumentation_pause_io_only_receiver(
"Debugger.resume",
],
observed={
- "pauseReason": auxiliary_pause.get("params", {}).get("reason"),
+ "pauseReason": attached_pause.get("params", {}).get("reason"),
"messagesWhileMainBlocked": len(blocked),
"ioMessages": len(io_seen),
"resumeMessages": len(resume_seen),
@@ -2046,16 +2046,16 @@ async def _navigation_replacement_during_active_javascript(
navigate_id = await client.send(
"Page.navigate",
{"url": destination},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
source_id = await client.send(
"Debugger.getScriptSource",
{"scriptId": script_id},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
terminate_id = await client.send(
"Runtime.terminateExecution",
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
expected_ids = {busy_id, navigate_id, source_id, terminate_id}
@@ -2199,13 +2199,13 @@ for (;;) {}"""
await client.send(
"Debugger.getScriptSource",
{"scriptId": script_id},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
for _ in range(32)
]
detach_id = await client.send(
"Target.detachFromTarget",
- {"sessionId": page.auxiliary_session_id},
+ {"sessionId": page.attached_session_id},
)
detach_completed = False
try:
@@ -2236,7 +2236,7 @@ for (;;) {}"""
)
if "error" in completed[terminate_id]:
raise SmokeError(
- "primary session could not terminate JavaScript after auxiliary detach: "
+ "primary session could not terminate JavaScript after attached detach: "
f"{completed[terminate_id]}"
)
termination_confirmed = True
@@ -2345,7 +2345,7 @@ for (;;) {}"""
await client.send(
"Debugger.getScriptSource",
{"scriptId": script_id},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
for _ in range(64)
]
@@ -2392,7 +2392,7 @@ for (;;) {}"""
stale_session_id = await client.send(
"Runtime.evaluate",
{"expression": "1"},
- session_id=page.auxiliary_session_id,
+ session_id=page.attached_session_id,
)
stale_responses, stale_seen = await _recv_responses(
client,
@@ -2512,7 +2512,7 @@ async def _page_crash_io_during_active_javascript(
await _wait_for_witness(fixture, expected_count=1)
crash_id = await client.send(
"Page.crash",
- session_id=crash_page.auxiliary_session_id,
+ session_id=crash_page.attached_session_id,
)
seen: list[dict[str, Any]] = []
@@ -2630,15 +2630,15 @@ async def _create_page(client: RawCdpClient, url: str) -> InspectorRoutingPage:
):
saw_load = True
- auxiliary_session_id = await _attach(client, target_id)
+ attached_session_id = await _attach(client, target_id)
for method in ("Runtime.enable", "Debugger.enable"):
- message_id = await client.send(method, session_id=auxiliary_session_id)
+ message_id = await client.send(method, session_id=attached_session_id)
await client.recv_until_id(message_id, timeout=5)
return InspectorRoutingPage(
browser_context_id=browser_context_id,
target_id=target_id,
primary_session_id=primary_session_id,
- auxiliary_session_id=auxiliary_session_id,
+ attached_session_id=attached_session_id,
)
@@ -2661,7 +2661,7 @@ async def _recv_paused_for_both_sessions(
) -> dict[str, dict[str, Any]]:
paused_events: dict[str, dict[str, Any]] = {}
seen: list[dict[str, Any]] = []
- expected_sessions = {page.primary_session_id, page.auxiliary_session_id}
+ expected_sessions = {page.primary_session_id, page.attached_session_id}
deadline = asyncio.get_running_loop().time() + 5.0
while paused_events.keys() != expected_sessions:
remaining = deadline - asyncio.get_running_loop().time()
diff --git a/moli-cdp-smoke/moli_cdp_smoke/groups/multi_page.py b/moli-cdp-smoke/moli_cdp_smoke/groups/multi_page.py
index d8bd42c40..ef804046b 100644
--- a/moli-cdp-smoke/moli_cdp_smoke/groups/multi_page.py
+++ b/moli-cdp-smoke/moli_cdp_smoke/groups/multi_page.py
@@ -633,7 +633,7 @@ async def _target_local_session_events(
await wait_until(
lambda index=index, token=token: token
in _console_values(collectors[index + len(pages)]),
- f"auxiliary console event for target {index}",
+ f"attached console event for target {index}",
)
for index, token in enumerate(tokens):
other_tokens = set(tokens) - {token}
@@ -651,7 +651,7 @@ async def _target_local_session_events(
"Runtime.evaluate",
{"expression": "21 * 2", "returnByValue": True},
)
- assert_equal(runtime_value(surviving), 42, "auxiliary after primary detach")
+ assert_equal(runtime_value(surviving), 42, "attached after primary detach")
replacement = await context.new_cdp_session(pages[1])
sessions.append(replacement)
replacement_read = await _send_cdp(
diff --git a/moli-cdp-smoke/moli_cdp_smoke/groups/target_semantics.py b/moli-cdp-smoke/moli_cdp_smoke/groups/target_semantics.py
index 13d20a493..1bec5d37a 100644
--- a/moli-cdp-smoke/moli_cdp_smoke/groups/target_semantics.py
+++ b/moli-cdp-smoke/moli_cdp_smoke/groups/target_semantics.py
@@ -847,7 +847,7 @@ async def _screencast_visibility_follows_foreground(
session_id=screencast_session_id,
)
- stage = "demote screencast Page by creating foreground target"
+ stage = "move screencast Page to background by creating foreground target"
second, creation_seen = await _raw_command(
client,
"Target.createTarget",
@@ -866,7 +866,7 @@ async def _screencast_visibility_follows_foreground(
session_id=screencast_session_id,
)
- stage = "close foreground target and promote screencast Page"
+ stage = "close foreground target and reselect screencast Page"
_, close_seen = await _raw_command(
client,
"Target.closeTarget",
diff --git a/moli-core/src/page/js_evaluation.rs b/moli-core/src/page/js_evaluation.rs
index 278a07e0e..df6641c64 100644
--- a/moli-core/src/page/js_evaluation.rs
+++ b/moli-core/src/page/js_evaluation.rs
@@ -794,7 +794,7 @@ impl Page {
if self.renderer_devtools_command_session_id.as_deref() == inspector_session_id {
// `runtime_session_owner_slot_mut` stamps the current frontend
// session onto the Page before command construction. Do not leave
- // a detached auxiliary session as the fallback provenance for a
+ // a detached child session as the fallback provenance for a
// later owner-side observation that is not itself entered through
// a CDP session lookup.
self.renderer_devtools_command_session_id = None;
diff --git a/moli-page-types/src/inspector_identity.rs b/moli-page-types/src/inspector_identity.rs
index b64faf223..445f36625 100644
--- a/moli-page-types/src/inspector_identity.rs
+++ b/moli-page-types/src/inspector_identity.rs
@@ -7,13 +7,15 @@ use std::{
/// Destination that owns the terminal response of one renderer Inspector
/// command.
///
-/// Frontend DevTools commands may publish directly through their concrete
-/// session capability. Internal protocol adapters retain a private command
-/// reply channel even when they synthesize the same CDP method.
+/// Every external Page or Worker command publishes through `SessionSink`.
+/// `AdapterReply` is reserved for commands synthesized by protocol adapters
+/// (Classic/WebDriver BiDi and the non-flat Target transport); its
+/// result is consumed internally and is never emitted as a frontend terminal
+/// response.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum RendererInspectorResponseDelivery {
- CommandReply,
- DevToolsSession,
+ AdapterReply,
+ SessionSink,
}
static NEXT_RENDERER_DEVTOOLS_AGENT_TOKEN: AtomicU64 = AtomicU64::new(1);
diff --git a/moli-protocol-server/src/protocol_server/tests/cdp_dynamic_page.rs b/moli-protocol-server/src/protocol_server/tests/cdp_dynamic_page.rs
index 195051df9..ef841cad4 100644
--- a/moli-protocol-server/src/protocol_server/tests/cdp_dynamic_page.rs
+++ b/moli-protocol-server/src/protocol_server/tests/cdp_dynamic_page.rs
@@ -1246,7 +1246,7 @@ async fn tab_websocket_stays_bound_to_its_page_when_a_popup_becomes_active() {
response_by_id(&restored_opener, 10)["result"]["result"]["value"],
json!(&opener_url)
);
- let parked_popup = send_cdp_command(
+ let background_popup = send_cdp_command(
&mut popup_tab,
4,
"Runtime.evaluate",
@@ -1255,14 +1255,14 @@ async fn tab_websocket_stays_bound_to_its_page_when_a_popup_becomes_active() {
)
.await;
assert_eq!(
- response_by_id(&parked_popup, 4)["result"]["result"]["value"],
+ response_by_id(&background_popup, 4)["result"]["result"]["value"],
json!(popup_final_url)
);
let restored_opener_surface = evaluate_page_surface(&mut opener, 11).await;
assert_page_surface_active(&restored_opener_surface, true);
- let demoted_popup = evaluate_page_surface(&mut popup, 12).await;
- assert_page_surface_active(&demoted_popup, false);
+ let background_popup_surface = evaluate_page_surface(&mut popup, 12).await;
+ assert_page_surface_active(&background_popup_surface, false);
abort_test_cdp_server(server).await;
}
@@ -2609,9 +2609,9 @@ async fn websocket_cdp_puppeteer_reconnect_recreates_session_owned_runtime_conte
.expect("created target id")
.to_owned();
assert_ne!(created_target_id, DEFAULT_TARGET_ID);
- // Materializing a second Page parks the old default Page. Puppeteer's
- // first Page command promotes that existing target back to the active
- // slot, which is the reconnect lifecycle that regressed.
+ // Materializing a second Page leaves the old default Page in the
+ // background. Puppeteer's first Page command selects that existing target
+ // again, which is the reconnect lifecycle that regressed.
let target_id = DEFAULT_TARGET_ID.to_owned();
let (mut browser, _) =
diff --git a/moli-protocol-server/src/protocol_server/tests/websocket.rs b/moli-protocol-server/src/protocol_server/tests/websocket.rs
index 8715c78b5..41ff2dcf4 100644
--- a/moli-protocol-server/src/protocol_server/tests/websocket.rs
+++ b/moli-protocol-server/src/protocol_server/tests/websocket.rs
@@ -1675,7 +1675,7 @@ async fn websocket_cdp_active_js_interrupt_preserves_main_and_io_lanes_across_se
)
.await;
- let auxiliary_attach = send_cdp_command(
+ let attached_session_response = send_cdp_command(
&mut socket,
6,
"Target.attachToTarget",
@@ -1683,16 +1683,16 @@ async fn websocket_cdp_active_js_interrupt_preserves_main_and_io_lanes_across_se
json!({ "targetId": primary.target_id, "flatten": true }),
)
.await;
- let auxiliary_session_id = auxiliary_attach
+ let attached_session_id = attached_session_response
.iter()
.find(|message| message["id"] == json!(6_u64))
.and_then(|message| message["result"]["sessionId"].as_str())
- .expect("auxiliary session id")
+ .expect("attached session id")
.to_owned();
for (id, method, session_id) in [
(7, "Debugger.enable", primary.session_id.as_str()),
- (8, "Runtime.enable", auxiliary_session_id.as_str()),
- (9, "Debugger.enable", auxiliary_session_id.as_str()),
+ (8, "Runtime.enable", attached_session_id.as_str()),
+ (9, "Debugger.enable", attached_session_id.as_str()),
] {
let enabled = send_cdp_command(&mut socket, id, method, Some(session_id), json!({})).await;
assert!(
@@ -1745,7 +1745,7 @@ for (;;) {}"#;
&mut socket,
12,
"Runtime.evaluate",
- Some(&auxiliary_session_id),
+ Some(&attached_session_id),
json!({
"expression": "(globalThis.__moliMainLane ??= []).push('m1')",
"returnByValue": true,
@@ -1756,7 +1756,7 @@ for (;;) {}"#;
&mut socket,
13,
"Runtime.evaluate",
- Some(&auxiliary_session_id),
+ Some(&attached_session_id),
json!({
"expression": "globalThis.__moliMainLane.push('m2')",
"returnByValue": true,
@@ -1772,7 +1772,7 @@ for (;;) {}"#;
{observed:#?}"
);
- // All three commands use the auxiliary session's IO lane. The two source
+ // All three commands use the attached session's IO lane. The two source
// lookups prove FIFO before terminateExecution releases the Main owner.
for (id, method, params) in [
(
@@ -1787,7 +1787,7 @@ for (;;) {}"#;
),
(16, "Runtime.terminateExecution", json!({})),
] {
- send_cdp_command_without_wait(&mut socket, id, method, Some(&auxiliary_session_id), params)
+ send_cdp_command_without_wait(&mut socket, id, method, Some(&attached_session_id), params)
.await;
}
@@ -1826,7 +1826,7 @@ for (;;) {}"#;
assert_eq!(
response["result"]["scriptSource"],
json!(busy_source),
- "IO source lookup {id} must reach the live auxiliary Inspector session: \
+ "IO source lookup {id} must reach the live attached Inspector session: \
{observed:#?}"
);
}
@@ -1842,7 +1842,7 @@ for (;;) {}"#;
);
assert!(
position(16) < position(12) && position(12) < position(13),
- "IO may overtake Main, but the auxiliary Main lane must remain FIFO: {observed:#?}"
+ "IO may overtake Main, but the attached Main lane must remain FIFO: {observed:#?}"
);
assert_eq!(
observed
@@ -5485,7 +5485,7 @@ async fn websocket_cdp_debugger_step_out_responds_before_resumed_and_caller_paus
}
#[tokio::test]
-async fn websocket_cdp_debugger_pause_allows_auxiliary_main_thread_commands() {
+async fn websocket_cdp_debugger_pause_allows_attached_main_thread_commands() {
let (cdp_addr, protocol_server) = spawn_test_protocol_server().await;
let (mut socket, _) = connect_async(format!(
"ws://{cdp_addr}/devtools/browser/{DEFAULT_BROWSER_ID}"
@@ -5516,7 +5516,7 @@ async fn websocket_cdp_debugger_pause_allows_auxiliary_main_thread_commands() {
"Debugger.enable should complete before the pause witness: {enabled:#?}"
);
- let auxiliary_attach = send_cdp_command(
+ let attached_session_response = send_cdp_command(
&mut socket,
5,
"Target.attachToTarget",
@@ -5524,31 +5524,31 @@ async fn websocket_cdp_debugger_pause_allows_auxiliary_main_thread_commands() {
json!({ "targetId": session.target_id, "flatten": true }),
)
.await;
- let auxiliary_session_id = auxiliary_attach
+ let attached_session_id = attached_session_response
.iter()
.find(|message| message["id"] == json!(5_u64))
.and_then(|message| message["result"]["sessionId"].as_str())
- .expect("auxiliary session id")
+ .expect("attached session id")
.to_owned();
- let auxiliary_enabled = send_cdp_command(
+ let attached_enabled = send_cdp_command(
&mut socket,
50,
"Debugger.enable",
- Some(&auxiliary_session_id),
+ Some(&attached_session_id),
json!({}),
)
.await;
assert!(
- auxiliary_enabled
+ attached_enabled
.iter()
.any(|message| message["id"] == json!(50_u64) && message.get("error").is_none()),
- "auxiliary Debugger.enable should create its V8 inspector session: {auxiliary_enabled:#?}"
+ "attached Debugger.enable should create its V8 inspector session: {attached_enabled:#?}"
);
let isolated_world = send_cdp_command(
&mut socket,
49,
"Page.createIsolatedWorld",
- Some(&auxiliary_session_id),
+ Some(&attached_session_id),
json!({
"frameId": session.target_id,
"worldName": "nested-main-owner-boundary",
@@ -5589,78 +5589,78 @@ async fn websocket_cdp_debugger_pause_allows_auxiliary_main_thread_commands() {
"Runtime.evaluate must remain pending while the renderer owner is paused: {observed:#?}"
);
if observed.iter().all(|message| {
- message["sessionId"].as_str() != Some(auxiliary_session_id.as_str())
+ message["sessionId"].as_str() != Some(attached_session_id.as_str())
|| message["method"] != json!("Debugger.paused")
}) {
observed.extend(
recv_until_match(&mut socket, |message| {
- message["sessionId"].as_str() == Some(auxiliary_session_id.as_str())
+ message["sessionId"].as_str() == Some(attached_session_id.as_str())
&& message["method"] == json!("Debugger.paused")
})
.await,
);
}
- let auxiliary_call_frame_id = observed
+ let attached_call_frame_id = observed
.iter()
.find(|message| {
- message["sessionId"].as_str() == Some(auxiliary_session_id.as_str())
+ message["sessionId"].as_str() == Some(attached_session_id.as_str())
&& message["method"] == json!("Debugger.paused")
})
.and_then(|message| message["params"]["callFrames"][0]["callFrameId"].as_str())
- .expect("auxiliary Debugger.paused callFrameId")
+ .expect("attached Debugger.paused callFrameId")
.to_owned();
// Chromium's normal debugger loop pumps its main-thread DevTools receiver.
- // This command must therefore reach the auxiliary V8 session even though
+ // This command must therefore reach the attached V8 session even though
// the ordinary Page owner turn that entered the pause has not returned.
- let auxiliary_evaluate = tokio::time::timeout(
+ let attached_evaluate = tokio::time::timeout(
Duration::from_secs(5),
send_cdp_command(
&mut socket,
7,
"Runtime.evaluate",
- Some(&auxiliary_session_id),
+ Some(&attached_session_id),
json!({ "expression": "21 * 2", "returnByValue": true }),
),
)
.await
- .expect("auxiliary Main Runtime.evaluate must complete in the debugger loop");
+ .expect("attached Main Runtime.evaluate must complete in the debugger loop");
assert!(
- auxiliary_evaluate.iter().any(|message| {
+ attached_evaluate.iter().any(|message| {
message["id"] == json!(7_u64)
- && message["sessionId"] == json!(auxiliary_session_id)
+ && message["sessionId"] == json!(attached_session_id)
&& message["result"]["result"]["value"] == json!(42)
}),
- "pause-loop Main Runtime.evaluate should complete before resume: {auxiliary_evaluate:#?}"
+ "pause-loop Main Runtime.evaluate should complete before resume: {attached_evaluate:#?}"
);
- let auxiliary_object = tokio::time::timeout(
+ let attached_object = tokio::time::timeout(
Duration::from_secs(5),
send_cdp_command(
&mut socket,
51,
"Runtime.evaluate",
- Some(&auxiliary_session_id),
+ Some(&attached_session_id),
json!({ "expression": "({ answer: 42 })" }),
),
)
.await
.expect("object-valued Main Runtime.evaluate must complete in the debugger loop");
assert!(
- auxiliary_object.iter().any(|message| {
+ attached_object.iter().any(|message| {
message["id"] == json!(51_u64)
- && message["sessionId"] == json!(auxiliary_session_id)
+ && message["sessionId"] == json!(attached_session_id)
&& message["result"]["result"]["type"] == json!("object")
&& message["result"]["result"]["objectId"]
.as_str()
.is_some_and(|object_id| !object_id.is_empty())
}),
- "pause-loop object response must remain owner-independent: {auxiliary_object:#?}"
+ "pause-loop object response must remain owner-independent: {attached_object:#?}"
);
- let auxiliary_object_id = auxiliary_object
+ let attached_object_id = attached_object
.iter()
.find(|message| message["id"] == json!(51_u64))
.and_then(|message| message["result"]["result"]["objectId"].as_str())
- .expect("auxiliary Runtime.evaluate objectId")
+ .expect("attached Runtime.evaluate objectId")
.to_owned();
let properties = timeout(
@@ -5669,8 +5669,8 @@ async fn websocket_cdp_debugger_pause_allows_auxiliary_main_thread_commands() {
&mut socket,
53,
"Runtime.getProperties",
- Some(&auxiliary_session_id),
- json!({ "objectId": auxiliary_object_id, "ownProperties": true }),
+ Some(&attached_session_id),
+ json!({ "objectId": attached_object_id, "ownProperties": true }),
),
)
.await
@@ -5696,9 +5696,9 @@ async fn websocket_cdp_debugger_pause_allows_auxiliary_main_thread_commands() {
&mut socket,
54,
"Runtime.callFunctionOn",
- Some(&auxiliary_session_id),
+ Some(&attached_session_id),
json!({
- "objectId": auxiliary_object_id,
+ "objectId": attached_object_id,
"functionDeclaration": "function () { return this.answer + 1; }",
"returnByValue": true,
}),
@@ -5719,9 +5719,9 @@ async fn websocket_cdp_debugger_pause_allows_auxiliary_main_thread_commands() {
&mut socket,
55,
"Debugger.evaluateOnCallFrame",
- Some(&auxiliary_session_id),
+ Some(&attached_session_id),
json!({
- "callFrameId": auxiliary_call_frame_id,
+ "callFrameId": attached_call_frame_id,
"expression": "40 + 2",
"returnByValue": true,
}),
@@ -5733,7 +5733,7 @@ async fn websocket_cdp_debugger_pause_allows_auxiliary_main_thread_commands() {
call_frame_evaluate.iter().any(|message| {
message["id"] == json!(55_u64) && message["result"]["result"]["value"] == json!(42)
}),
- "nested Main must evaluate against the auxiliary paused call frame: \
+ "nested Main must evaluate against the attached paused call frame: \
{call_frame_evaluate:#?}"
);
@@ -5742,7 +5742,7 @@ async fn websocket_cdp_debugger_pause_allows_auxiliary_main_thread_commands() {
json!({
"id": 52_u64,
"method": "Runtime.evaluate",
- "sessionId": auxiliary_session_id,
+ "sessionId": attached_session_id,
"params": {
"expression": "Promise.resolve(43)",
"awaitPromise": true,
@@ -5761,7 +5761,7 @@ async fn websocket_cdp_debugger_pause_allows_auxiliary_main_thread_commands() {
&mut socket,
56,
"Runtime.evaluate",
- Some(&auxiliary_session_id),
+ Some(&attached_session_id),
json!({
"contextId": isolated_context_id,
"expression": "globalThis.__nestedInspectorContext = 44",
@@ -5774,7 +5774,7 @@ async fn websocket_cdp_debugger_pause_allows_auxiliary_main_thread_commands() {
assert!(
explicit_context_evaluate.iter().any(|message| {
message["id"] == json!(56_u64)
- && message["sessionId"] == json!(auxiliary_session_id)
+ && message["sessionId"] == json!(attached_session_id)
&& message["result"]["result"]["value"] == json!(44)
}),
"nested Main must dispatch an explicit native Inspector context without Page owner: \
@@ -5786,7 +5786,7 @@ async fn websocket_cdp_debugger_pause_allows_auxiliary_main_thread_commands() {
&mut socket,
8,
"Debugger.resume",
- Some(&auxiliary_session_id),
+ Some(&attached_session_id),
json!({}),
)
.await,
@@ -5814,7 +5814,7 @@ async fn websocket_cdp_debugger_pause_allows_auxiliary_main_thread_commands() {
assert!(
observed.iter().any(|message| {
message["id"] == json!(52_u64)
- && message["sessionId"] == json!(auxiliary_session_id)
+ && message["sessionId"] == json!(attached_session_id)
&& message["result"]["result"]["value"] == json!(43)
}),
"awaitPromise should settle after Debugger.resume without a deferred-reply deadlock: \
@@ -6912,7 +6912,7 @@ async fn websocket_cdp_runtime_self_navigation_gate_is_not_applied_to_next_comma
}
#[tokio::test]
-async fn websocket_cdp_window_open_self_navigation_reaches_auxiliary_page_session() {
+async fn websocket_cdp_window_open_self_navigation_reaches_attached_page_session() {
async fn plain() -> impl IntoResponse {
(
[(axum::http::header::CONTENT_TYPE.as_str(), "text/html")],
@@ -6978,7 +6978,7 @@ async fn websocket_cdp_window_open_self_navigation_reaches_auxiliary_page_sessio
.and_then(|message| message["result"]["sessionId"].as_str())
.expect("browser session id")
.to_owned();
- let auxiliary_attach = send_cdp_command(
+ let attached_session_response = send_cdp_command(
&mut socket,
7,
"Target.attachToTarget",
@@ -6986,13 +6986,13 @@ async fn websocket_cdp_window_open_self_navigation_reaches_auxiliary_page_sessio
json!({ "targetId": target_id }),
)
.await;
- let auxiliary_session_id = auxiliary_attach
+ let attached_session_id = attached_session_response
.iter()
.find(|message| message["id"] == json!(7_u64))
.and_then(|message| message["result"]["sessionId"].as_str())
- .expect("auxiliary session id")
+ .expect("attached session id")
.to_owned();
- assert_ne!(auxiliary_session_id, primary_session_id);
+ assert_ne!(attached_session_id, primary_session_id);
for (id, method) in [
(8_u64, "Page.enable"),
@@ -7003,7 +7003,7 @@ async fn websocket_cdp_window_open_self_navigation_reaches_auxiliary_page_sessio
&mut socket,
id,
method,
- Some(&auxiliary_session_id),
+ Some(&attached_session_id),
json!({}),
)
.await;
@@ -7013,13 +7013,13 @@ async fn websocket_cdp_window_open_self_navigation_reaches_auxiliary_page_sessio
let mut initial_navigation =
cdp_navigate_and_wait_for_load(&mut socket, 11, &primary_session_id, &plain_url).await;
if !initial_navigation.iter().any(|message| {
- message["sessionId"].as_str() == Some(auxiliary_session_id.as_str())
+ message["sessionId"].as_str() == Some(attached_session_id.as_str())
&& message["method"] == json!("Page.frameNavigated")
&& message["params"]["frame"]["url"] == json!(plain_url)
}) {
initial_navigation.append(
&mut recv_until_match(&mut socket, |message| {
- message["sessionId"].as_str() == Some(auxiliary_session_id.as_str())
+ message["sessionId"].as_str() == Some(attached_session_id.as_str())
&& message["method"] == json!("Page.frameNavigated")
&& message["params"]["frame"]["url"] == json!(plain_url)
})
@@ -7027,11 +7027,11 @@ async fn websocket_cdp_window_open_self_navigation_reaches_auxiliary_page_sessio
);
}
if !initial_navigation.iter().any(|message| {
- message["sessionId"].as_str() == Some(auxiliary_session_id.as_str())
+ message["sessionId"].as_str() == Some(attached_session_id.as_str())
&& message["method"] == json!("Page.loadEventFired")
}) {
let _ = recv_until_match(&mut socket, |message| {
- message["sessionId"].as_str() == Some(auxiliary_session_id.as_str())
+ message["sessionId"].as_str() == Some(attached_session_id.as_str())
&& message["method"] == json!("Page.loadEventFired")
})
.await;
@@ -7118,7 +7118,7 @@ async fn websocket_cdp_window_open_self_navigation_reaches_auxiliary_page_sessio
let routed_to_target = matches!(
message["sessionId"].as_str(),
Some(session_id)
- if session_id == primary_session_id || session_id == auxiliary_session_id
+ if session_id == primary_session_id || session_id == attached_session_id
);
routed_to_target
&& (message["method"] == json!("Runtime.executionContextsCleared")
@@ -7133,13 +7133,13 @@ async fn websocket_cdp_window_open_self_navigation_reaches_auxiliary_page_sessio
"Runtime.callFunctionOn response must precede command-caused navigation output on every session attached to the target: {navigation_messages:#?}"
);
if !navigation_messages.iter().any(|message| {
- message["sessionId"].as_str() == Some(auxiliary_session_id.as_str())
+ message["sessionId"].as_str() == Some(attached_session_id.as_str())
&& message["method"] == json!("Page.frameNavigated")
&& message["params"]["frame"]["url"] == json!(history_url)
}) {
navigation_messages.append(
&mut recv_until_match(&mut socket, |message| {
- message["sessionId"].as_str() == Some(auxiliary_session_id.as_str())
+ message["sessionId"].as_str() == Some(attached_session_id.as_str())
&& message["method"] == json!("Page.frameNavigated")
&& message["params"]["frame"]["url"] == json!(history_url)
})
@@ -7147,12 +7147,12 @@ async fn websocket_cdp_window_open_self_navigation_reaches_auxiliary_page_sessio
);
}
if !navigation_messages.iter().any(|message| {
- message["sessionId"].as_str() == Some(auxiliary_session_id.as_str())
+ message["sessionId"].as_str() == Some(attached_session_id.as_str())
&& message["method"] == json!("Page.loadEventFired")
}) {
navigation_messages.append(
&mut recv_until_match(&mut socket, |message| {
- message["sessionId"].as_str() == Some(auxiliary_session_id.as_str())
+ message["sessionId"].as_str() == Some(attached_session_id.as_str())
&& message["method"] == json!("Page.loadEventFired")
})
.await,
@@ -7162,40 +7162,40 @@ async fn websocket_cdp_window_open_self_navigation_reaches_auxiliary_page_sessio
let started = navigation_messages
.iter()
.position(|message| {
- message["sessionId"].as_str() == Some(auxiliary_session_id.as_str())
+ message["sessionId"].as_str() == Some(attached_session_id.as_str())
&& message["method"] == json!("Page.frameStartedNavigating")
&& message["params"]["url"] == json!(history_url)
})
- .expect("auxiliary session should receive Page.frameStartedNavigating for _self URL");
+ .expect("attached session should receive Page.frameStartedNavigating for _self URL");
let navigated = navigation_messages
.iter()
.position(|message| {
- message["sessionId"].as_str() == Some(auxiliary_session_id.as_str())
+ message["sessionId"].as_str() == Some(attached_session_id.as_str())
&& message["method"] == json!("Page.frameNavigated")
&& message["params"]["frame"]["url"] == json!(history_url)
})
- .expect("auxiliary session should receive Page.frameNavigated for _self URL");
+ .expect("attached session should receive Page.frameNavigated for _self URL");
let loaded = navigation_messages
.iter()
.enumerate()
.find_map(|(index, message)| {
(index > navigated
- && message["sessionId"].as_str() == Some(auxiliary_session_id.as_str())
+ && message["sessionId"].as_str() == Some(attached_session_id.as_str())
&& message["method"] == json!("Page.loadEventFired"))
.then_some(index)
})
- .expect("auxiliary session should receive Page.loadEventFired after _self frameNavigated");
+ .expect("attached session should receive Page.loadEventFired after _self frameNavigated");
assert!(
started < navigated && navigated < loaded,
- "auxiliary Page event order should be started < navigated < load: {navigation_messages:#?}"
+ "attached Page event order should be started < navigated < load: {navigation_messages:#?}"
);
assert!(
navigation_messages.iter().any(|message| {
- message["sessionId"].as_str() == Some(auxiliary_session_id.as_str())
+ message["sessionId"].as_str() == Some(attached_session_id.as_str())
&& message["method"] == json!("Network.requestWillBeSent")
&& message["params"]["request"]["url"] == json!(history_url)
}),
- "auxiliary Network session should observe the _self document request: {navigation_messages:#?}"
+ "attached Network session should observe the _self document request: {navigation_messages:#?}"
);
navigation_messages.append(
diff --git a/moli-protocol/src/conn.rs b/moli-protocol/src/conn.rs
index 6e708a9d3..95c716886 100644
--- a/moli-protocol/src/conn.rs
+++ b/moli-protocol/src/conn.rs
@@ -585,9 +585,9 @@ pub(crate) use state::{
TargetPageSlot, TargetRuntimeSessionState,
};
pub(crate) use target::{
- PreparedTargetAttach, PreparedTargetHostClosure, PreparedTargetHostDelta,
- TargetAttachSessionCommit, TargetBindingCleanupAction, TargetBindingCleanupPlan,
- TargetClosureCleanupPlan, TargetEventPlan, TargetSessionDetachCleanupPlan,
+ PreparedTargetAttach, PreparedTargetHostClosure, PreparedTargetHostDelta, SessionDisposalPlan,
+ SessionDisposalTarget, TargetAttachSessionCommit, TargetClosureCleanupPlan, TargetEventPlan,
+ TargetSessionDetachCleanupPlan,
};
use target::{
TargetClosurePlan, TargetControlPlane, TargetHostDelta, target_destroyed_automation_events,
@@ -1147,8 +1147,6 @@ pub struct CdpConnection {
// Browser/session routing state.
pub browser_context: Option<BrowserContext>,
pub inactive_browser_contexts: Vec<BrowserContext>,
- /// When true, every newly-created target is immediately auto-attached.
- pub auto_attach: bool,
/// Root/browser owner Target discovery mirror for diagnostics and
/// cross-crate schedulers. Event routing uses `target_handlers`.
pub(crate) target_discovery_enabled: bool,
@@ -1159,13 +1157,17 @@ pub struct CdpConnection {
pub(crate) target_discovery_filter: Option<Vec<DevToolsTargetFilterEntry>>,
/// Chromium/Playwright auto-attach can ask new targets to wait until
/// Runtime.runIfWaitingForDebugger before their initial document proceeds.
- pub auto_attach_wait_for_debugger_on_start: bool,
// Insertion order is protocol state: the first matching owner supplies
- // the primary auto-attached Page session, while later owners attach as
- // auxiliary sessions. A randomized HashMap iteration order made that
+ // the primary auto-attached Page session, while later owners contribute
+ // additional attached sessions. A randomized HashMap iteration order made that
// choice vary between otherwise identical processes.
auto_attach_owner_sessions: IndexMap<Option<String>, AutoAttachOwnerPolicy>,
target_control: TargetControlPlane,
+ /// Allows old unit-test fixtures that install only the target-side half of
+ /// a session binding to remain usable while production routing is checked
+ /// separately against the committed control-plane registry.
+ #[cfg(test)]
+ allow_incomplete_session_fixture_routes: bool,
default_target_lifecycle: DefaultTargetLifecycle,
service_worker_auto_attach_related_owners: Vec<ServiceWorkerAutoAttachRelatedOwner>,
service_worker_pause_on_start_owner_sessions: HashSet<Option<String>>,
@@ -1469,13 +1471,13 @@ impl CdpConnection {
Self {
browser_context: None,
inactive_browser_contexts: Vec::new(),
- auto_attach: false,
target_discovery_enabled: false,
target_info_change_events_enabled: false,
target_discovery_filter: None,
- auto_attach_wait_for_debugger_on_start: false,
auto_attach_owner_sessions: IndexMap::new(),
target_control: TargetControlPlane::default(),
+ #[cfg(test)]
+ allow_incomplete_session_fixture_routes: true,
default_target_lifecycle: DefaultTargetLifecycle::default(),
service_worker_auto_attach_related_owners: Vec::new(),
service_worker_pause_on_start_owner_sessions: HashSet::new(),
@@ -3094,7 +3096,7 @@ impl CdpConnection {
"permissionOverrideCount": self.permission_overrides.len(),
"pageNavigationEngineCount": page_navigation_engine_count,
"pageNavigationEngineKeys": page_engine_keys,
- "autoAttach": self.auto_attach,
+ "autoAttach": self.auto_attach_enabled(),
"targetDiscoveryEnabled": self.target_discovery_enabled,
"targetInfoChangeEventsEnabled": self.target_info_change_events_enabled,
"activeNavigationEngine": {
@@ -3399,7 +3401,7 @@ impl CdpConnection {
})
}
- pub(crate) fn close_default_target_placeholder(
+ pub(crate) async fn close_default_target_placeholder(
&mut self,
target_id: &str,
) -> Option<TargetEventPlan> {
@@ -3413,10 +3415,15 @@ impl CdpConnection {
let target_host_closure = self.prepare_target_host_closure(DEFAULT_CDP_PAGE_TARGET_ID);
let (detached_info_deltas, destroyed_deltas) = target_host_closure.into_parts();
let mut plan = self.prepared_target_host_deltas_event_plan(detached_info_deltas);
- plan.extend(self.detach_closed_top_level_target_sessions_event_plan(
+ if let Some(tab_cleanup) = self.take_closed_top_level_target_sessions_cleanup_plan(
DEFAULT_CDP_PAGE_TARGET_ID,
Some("Render process gone."),
- ));
+ ) {
+ plan.extend(
+ self.dispose_target_closure_sessions_event_plan_async(tab_cleanup, None)
+ .await,
+ );
+ }
let closed = self.default_target_lifecycle.close_placeholder(target_id);
debug_assert!(closed, "validated default placeholder must close");
plan.extend(self.prepared_target_host_deltas_event_plan(destroyed_deltas));
@@ -3468,10 +3475,13 @@ impl CdpConnection {
&mut self,
tab_target_id: &str,
session_id: String,
- auxiliary: bool,
+ is_attached_session: bool,
) -> bool {
- self.target_control
- .assign_session_to_tab_target(tab_target_id, session_id, auxiliary)
+ self.target_control.assign_session_to_tab_target(
+ tab_target_id,
+ session_id,
+ is_attached_session,
+ )
}
pub(crate) fn remove_tab_session(&mut self, session_id: &str) -> Option<String> {
@@ -3493,14 +3503,12 @@ impl CdpConnection {
Some(closure_plan)
}
- pub(crate) fn detach_closed_top_level_target_sessions_event_plan(
+ pub(crate) fn take_closed_top_level_target_sessions_cleanup_plan(
&mut self,
page_target_id: &str,
reason: Option<&str>,
- ) -> TargetEventPlan {
- let Some(closure_plan) = self.remove_tab_for_page_target(page_target_id) else {
- return TargetEventPlan::default();
- };
+ ) -> Option<TargetClosureCleanupPlan> {
+ let closure_plan = self.remove_tab_for_page_target(page_target_id)?;
debug_assert!(
closure_plan
.destroyed_target_ids()
@@ -3509,10 +3517,11 @@ impl CdpConnection {
let target = closure_plan.tab_target();
let tab_target_id = target.id().to_owned();
let tab_session_ids = target.session_ids();
- self.detach_target_closure_cleanup_event_plan(
- TargetClosureCleanupPlan::new(tab_target_id, reason, tab_session_ids),
- None,
- )
+ Some(TargetClosureCleanupPlan::new(
+ tab_target_id,
+ reason,
+ tab_session_ids,
+ ))
}
pub(crate) fn rollback_top_level_target_tab_sessions_without_event(
diff --git a/moli-protocol/src/conn/browser_context/lifecycle.rs b/moli-protocol/src/conn/browser_context/lifecycle.rs
index 451270d61..2df560514 100644
--- a/moli-protocol/src/conn/browser_context/lifecycle.rs
+++ b/moli-protocol/src/conn/browser_context/lifecycle.rs
@@ -74,7 +74,7 @@ impl CdpConnection {
{
let removed = self.browser_context.take();
if self.browser_context.is_none() && !self.inactive_browser_contexts.is_empty() {
- self.promote_inactive_browser_context_index_to_active(0);
+ self.select_inactive_browser_context_as_active(0);
}
self.invalidate_resource_runtime_async().await;
self.restore_preferred_browser_context_async(
@@ -108,7 +108,7 @@ impl CdpConnection {
self.invalidate_resource_runtime_async().await;
}
- fn promote_inactive_browser_context_index_to_active(&mut self, index: usize) {
+ fn select_inactive_browser_context_as_active(&mut self, index: usize) {
self.browser_context = Some(self.inactive_browser_contexts.swap_remove(index));
}
diff --git a/moli-protocol/src/conn/browser_context/network_owner.rs b/moli-protocol/src/conn/browser_context/network_owner.rs
index dc2d12df9..ef444b498 100644
--- a/moli-protocol/src/conn/browser_context/network_owner.rs
+++ b/moli-protocol/src/conn/browser_context/network_owner.rs
@@ -72,7 +72,7 @@ impl TargetNetworkListenerOwnerMut<'_> {
DevToolsSessionKey::Attached(session_id) => self
.target
.runtime_slot()
- .auxiliary_network_events_enabled_for_session(session_id),
+ .attached_network_events_enabled_for_session(session_id),
}
}
@@ -121,7 +121,7 @@ impl TargetNetworkListenerOwnerMut<'_> {
if self.is_attached_session() {
if let Some(session_id) = listener_session_id.as_deref() {
self.runtime_slot_mut()
- .enable_auxiliary_network_events(session_id);
+ .enable_attached_network_events(session_id);
}
} else {
self.set_primary_network_enabled(true);
@@ -139,7 +139,7 @@ impl TargetNetworkListenerOwnerMut<'_> {
if self.is_attached_session() {
if let Some(session_id) = listener_session_id.as_deref() {
self.runtime_slot_mut()
- .disable_auxiliary_network_events(session_id);
+ .disable_attached_network_events(session_id);
}
} else {
self.set_primary_network_enabled(false);
@@ -875,7 +875,7 @@ mod tests {
}
}
- fn parked_session_state_mut(state: &mut PageTargetHost) -> TargetSessionStateMut<'_> {
+ fn background_session_state_mut(state: &mut PageTargetHost) -> TargetSessionStateMut<'_> {
TargetSessionStateMut {
devtools_session_state: &mut state.devtools_sessions
[moli_page_types::DevToolsSessionKey::Primary],
@@ -884,7 +884,7 @@ mod tests {
}
}
- fn connection_with_background_auxiliary_session() -> CdpConnection {
+ fn connection_with_background_attached_session() -> CdpConnection {
let mut conn = CdpConnection::default();
let mut browser_context = BrowserContext::new("BID-background".to_owned());
browser_context.insert_page_target_host(PageTargetHost::with_url(
@@ -894,7 +894,7 @@ mod tests {
));
assert!(
browser_context
- .assign_auxiliary_session_to_target("TID-background", "SID-aux".to_owned())
+ .assign_attached_session_to_target("TID-background", "SID-attached".to_owned())
);
conn.browser_context = Some(browser_context);
conn
@@ -944,7 +944,7 @@ mod tests {
}
#[test]
- fn target_session_state_mut_applies_active_and_parked_network_fields() {
+ fn target_session_state_mut_applies_active_and_background_network_fields() {
let mut active = BrowserContext::new_with_page_for_test("BID-active", "TID-active");
{
let network = &mut active
@@ -1023,47 +1023,57 @@ mod tests {
Some("cellular3g")
);
- let mut parked = PageTargetHost::empty("TID-network-owner-test".to_owned());
+ let mut background = PageTargetHost::empty("TID-network-owner-test".to_owned());
{
- let network = &mut parked.devtools_sessions.primary_mut().network_session_state;
+ let network = &mut background
+ .devtools_sessions
+ .primary_mut()
+ .network_session_state;
network.network_enabled = true;
network.cache_disabled = true;
network.bypass_service_worker = true;
- network.blocked_url_patterns = vec!["*://parked-blocked.test/*".to_owned()];
- network.extra_headers = vec![("X-Test".to_owned(), "parked".to_owned())];
+ network.blocked_url_patterns = vec!["*://background-blocked.test/*".to_owned()];
+ network.extra_headers = vec![("X-Test".to_owned(), "background".to_owned())];
}
- let parked_offline = parked_session_state_mut(&mut parked).set_emulated_network_conditions(
- true,
- 50.0,
- 2048.0,
- 512.0,
- Some("cellular4g".to_owned()),
- );
+ let background_offline = background_session_state_mut(&mut background)
+ .set_emulated_network_conditions(
+ true,
+ 50.0,
+ 2048.0,
+ 512.0,
+ Some("cellular4g".to_owned()),
+ );
- assert!(parked.effective_policy().cache_disabled());
- assert!(parked.effective_policy().bypass_service_worker());
+ assert!(background.effective_policy().cache_disabled());
+ assert!(background.effective_policy().bypass_service_worker());
+ assert_eq!(
+ background.effective_policy().blocked_url_patterns(),
+ vec!["*://background-blocked.test/*"]
+ );
+ assert_eq!(
+ background.effective_policy().extra_headers(),
+ vec![("X-Test".to_owned(), "background".to_owned())]
+ );
+ assert!(background_offline);
+ assert!(background.network_policy.network_offline());
+ assert_eq!(background.network_policy.emulated_network_latency(), 50.0);
assert_eq!(
- parked.effective_policy().blocked_url_patterns(),
- vec!["*://parked-blocked.test/*"]
+ background.network_policy.emulated_download_throughput(),
+ 2048.0
);
assert_eq!(
- parked.effective_policy().extra_headers(),
- vec![("X-Test".to_owned(), "parked".to_owned())]
+ background.network_policy.emulated_upload_throughput(),
+ 512.0
);
- assert!(parked_offline);
- assert!(parked.network_policy.network_offline());
- assert_eq!(parked.network_policy.emulated_network_latency(), 50.0);
- assert_eq!(parked.network_policy.emulated_download_throughput(), 2048.0);
- assert_eq!(parked.network_policy.emulated_upload_throughput(), 512.0);
assert_eq!(
- parked.network_policy.emulated_connection_type(),
+ background.network_policy.emulated_connection_type(),
Some("cellular4g")
);
}
#[test]
fn repeated_background_primary_network_enable_preserves_observation_cursor() {
- let mut conn = connection_with_background_auxiliary_session();
+ let mut conn = connection_with_background_attached_session();
assert!(conn.enable_network_listener_for_session_owner(Some("SID-background")));
conn.runtime_session_owner_slot_mut(Some("SID-background"))
@@ -1082,36 +1092,36 @@ mod tests {
}
#[test]
- fn repeated_background_auxiliary_network_enable_preserves_observation_cursor() {
- let mut conn = connection_with_background_auxiliary_session();
+ fn repeated_background_attached_network_enable_preserves_observation_cursor() {
+ let mut conn = connection_with_background_attached_session();
- assert!(conn.enable_network_listener_for_session_owner(Some("SID-aux")));
- conn.runtime_session_owner_slot_mut(Some("SID-aux"))
- .expect("background auxiliary runtime slot")
- .set_session_observation_cursor_at_counts_for_test(Some("SID-aux"), 7, 0);
+ assert!(conn.enable_network_listener_for_session_owner(Some("SID-attached")));
+ conn.runtime_session_owner_slot_mut(Some("SID-attached"))
+ .expect("background attached runtime slot")
+ .set_session_observation_cursor_at_counts_for_test(Some("SID-attached"), 7, 0);
- assert!(conn.enable_network_listener_for_session_owner(Some("SID-aux")));
+ assert!(conn.enable_network_listener_for_session_owner(Some("SID-attached")));
assert_eq!(
- conn.runtime_session_owner_slot(Some("SID-aux"))
- .expect("background auxiliary runtime slot")
- .emitted_subresource_record_count_for_session_for_test(Some("SID-aux")),
+ conn.runtime_session_owner_slot(Some("SID-attached"))
+ .expect("background attached runtime slot")
+ .emitted_subresource_record_count_for_session_for_test(Some("SID-attached")),
7,
- "idempotent Network.enable must not rewind the background auxiliary cursor"
+ "idempotent Network.enable must not rewind the background attached cursor"
);
}
#[test]
- fn background_primary_network_disable_preserves_auxiliary_listener_artifacts() {
- let mut conn = connection_with_background_auxiliary_session();
+ fn background_primary_network_disable_preserves_attached_listener_artifacts() {
+ let mut conn = connection_with_background_attached_session();
assert!(conn.enable_network_listener_for_session_owner(Some("SID-background")));
- assert!(conn.enable_network_listener_for_session_owner(Some("SID-aux")));
+ assert!(conn.enable_network_listener_for_session_owner(Some("SID-attached")));
conn.runtime_session_owner_slot_mut(Some("SID-background"))
.expect("background runtime slot")
.record_captured_response_body(
"REQ-shared".to_owned(),
"shared body".to_owned(),
- [None::<String>, Some("SID-aux".to_owned())],
+ [None::<String>, Some("SID-attached".to_owned())],
);
conn.runtime_session_owner_slot_mut(Some("SID-background"))
.expect("background runtime slot")
@@ -1127,12 +1137,12 @@ mod tests {
.runtime_session_owner_slot(Some("SID-background"))
.expect("background runtime slot");
assert!(!slot.primary_network_events_enabled());
- assert!(slot.auxiliary_network_events_enabled_for_session("SID-aux"));
+ assert!(slot.attached_network_events_enabled_for_session("SID-attached"));
let shared = slot
.captured_response_body("REQ-shared")
- .expect("shared body should remain while auxiliary can observe it");
+ .expect("shared body should remain while attached can observe it");
assert!(!shared.is_visible_to_session(None));
- assert!(shared.is_visible_to_session(Some("SID-aux")));
+ assert!(shared.is_visible_to_session(Some("SID-attached")));
assert!(
slot.captured_response_body("REQ-primary-only").is_none(),
"primary-only body should be dropped when primary Network is disabled"
@@ -1140,40 +1150,40 @@ mod tests {
}
#[test]
- fn background_auxiliary_network_disable_preserves_primary_listener_artifacts() {
- let mut conn = connection_with_background_auxiliary_session();
+ fn background_attached_network_disable_preserves_primary_listener_artifacts() {
+ let mut conn = connection_with_background_attached_session();
assert!(conn.enable_network_listener_for_session_owner(Some("SID-background")));
- assert!(conn.enable_network_listener_for_session_owner(Some("SID-aux")));
+ assert!(conn.enable_network_listener_for_session_owner(Some("SID-attached")));
conn.runtime_session_owner_slot_mut(Some("SID-background"))
.expect("background runtime slot")
.record_captured_response_body(
"REQ-shared".to_owned(),
"shared body".to_owned(),
- [None::<String>, Some("SID-aux".to_owned())],
+ [None::<String>, Some("SID-attached".to_owned())],
);
conn.runtime_session_owner_slot_mut(Some("SID-background"))
.expect("background runtime slot")
.record_captured_response_body(
"REQ-aux-only".to_owned(),
"aux body".to_owned(),
- [Some("SID-aux".to_owned())],
+ [Some("SID-attached".to_owned())],
);
- assert!(conn.disable_network_listener_for_session_owner(Some("SID-aux")));
+ assert!(conn.disable_network_listener_for_session_owner(Some("SID-attached")));
let slot = conn
.runtime_session_owner_slot(Some("SID-background"))
.expect("background runtime slot");
assert!(slot.primary_network_events_enabled());
- assert!(!slot.auxiliary_network_events_enabled_for_session("SID-aux"));
+ assert!(!slot.attached_network_events_enabled_for_session("SID-attached"));
let shared = slot
.captured_response_body("REQ-shared")
.expect("shared body should remain while primary can observe it");
assert!(shared.is_visible_to_session(None));
- assert!(!shared.is_visible_to_session(Some("SID-aux")));
+ assert!(!shared.is_visible_to_session(Some("SID-attached")));
assert!(
slot.captured_response_body("REQ-aux-only").is_none(),
- "auxiliary-only body should be dropped when auxiliary Network is disabled"
+ "attached-only body should be dropped when attached Network is disabled"
);
}
diff --git a/moli-protocol/src/conn/browser_context/page_owner.rs b/moli-protocol/src/conn/browser_context/page_owner.rs
index 8d3e37083..f0cd35ec5 100644
--- a/moli-protocol/src/conn/browser_context/page_owner.rs
+++ b/moli-protocol/src/conn/browser_context/page_owner.rs
@@ -1013,7 +1013,7 @@ mod tests {
}
}
- fn parked_session_state_mut(state: &mut PageTargetHost) -> TargetSessionStateMut<'_> {
+ fn background_session_state_mut(state: &mut PageTargetHost) -> TargetSessionStateMut<'_> {
TargetSessionStateMut {
devtools_session_state: &mut state.devtools_sessions
[moli_page_types::DevToolsSessionKey::Primary],
@@ -1023,7 +1023,7 @@ mod tests {
}
#[test]
- fn page_session_state_mut_applies_same_flags_to_active_and_parked_state() {
+ fn page_session_state_mut_applies_same_flags_to_active_and_background_state() {
let mut font_families = serde_json::Map::new();
font_families.insert("standard".to_owned(), serde_json::json!("Inter"));
@@ -1084,51 +1084,53 @@ mod tests {
.enabled()
);
- let mut parked = PageTargetHost::empty("TID-page-owner-test".to_owned());
- parked_session_state_mut(&mut parked).set_console_enabled(true);
- parked_session_state_mut(&mut parked).set_log_enabled(true);
- parked_session_state_mut(&mut parked).set_page_file_chooser_opened_event_enabled(true);
- parked_session_state_mut(&mut parked).set_page_bypass_csp_enabled(true);
- parked_session_state_mut(&mut parked).set_page_font_families(font_families.clone());
- parked_session_state_mut(&mut parked).set_page_intercept_file_chooser_dialog_enabled(true);
+ let mut background = PageTargetHost::empty("TID-page-owner-test".to_owned());
+ background_session_state_mut(&mut background).set_console_enabled(true);
+ background_session_state_mut(&mut background).set_log_enabled(true);
+ background_session_state_mut(&mut background)
+ .set_page_file_chooser_opened_event_enabled(true);
+ background_session_state_mut(&mut background).set_page_bypass_csp_enabled(true);
+ background_session_state_mut(&mut background).set_page_font_families(font_families.clone());
+ background_session_state_mut(&mut background)
+ .set_page_intercept_file_chooser_dialog_enabled(true);
assert!(
- parked_session_state_mut(&mut parked)
+ background_session_state_mut(&mut background)
.enable_performance(PerformanceTimeDomain::TimeTicks)
);
assert!(
- parked.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
+ background.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
.console_output_session_state
.console_enabled
);
assert!(
- parked.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
+ background.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
.page_session_state
.log_enabled
);
assert!(
- parked.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
+ background.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
.page_session_state
.page_file_chooser_opened_event_enabled
);
assert!(
- parked.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
+ background.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
.page_session_state
.page_bypass_csp_enabled
);
assert_eq!(
- parked.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
+ background.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
.page_session_state
.page_font_families,
font_families
);
assert!(
- parked.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
+ background.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
.page_session_state
.page_intercept_file_chooser_dialog_enabled
);
assert!(
- parked.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
+ background.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
.page_session_state
.performance
.enabled()
@@ -1147,11 +1149,11 @@ mod tests {
inactive.set_active_target_id("TID-inactive".to_owned());
assert!(
inactive
- .assign_auxiliary_session_to_target("TID-inactive", "SID-inactive-a".to_owned(),)
+ .assign_attached_session_to_target("TID-inactive", "SID-inactive-a".to_owned(),)
);
assert!(
inactive
- .assign_auxiliary_session_to_target("TID-inactive", "SID-inactive-b".to_owned(),)
+ .assign_attached_session_to_target("TID-inactive", "SID-inactive-b".to_owned(),)
);
let inactive_runtime = inactive.renderer_runtime();
diff --git a/moli-protocol/src/conn/browser_context/runtime_owner.rs b/moli-protocol/src/conn/browser_context/runtime_owner.rs
index 3aeb63e23..960deb040 100644
--- a/moli-protocol/src/conn/browser_context/runtime_owner.rs
+++ b/moli-protocol/src/conn/browser_context/runtime_owner.rs
@@ -172,7 +172,7 @@ impl CdpConnection {
let session_id =
self.ensure_service_worker_runtime_listener_session_for_route(&route)?;
return Some(
- self.process_message_with_turn_outcome_async(
+ self.process_nested_target_message_adapter_async(
&json!({
"id": 0_u64,
"sessionId": session_id,
@@ -192,7 +192,7 @@ impl CdpConnection {
let session_id =
self.ensure_shared_worker_runtime_listener_session_for_route(&route)?;
return Some(
- self.process_message_with_turn_outcome_async(
+ self.process_nested_target_message_adapter_async(
&json!({
"id": 0_u64,
"sessionId": session_id,
@@ -219,7 +219,7 @@ impl CdpConnection {
if matches!(route, CdpSessionRoute::ServiceWorkerTarget { .. }) {
let session_id = self.service_worker_runtime_listener_session_for_route(&route)?;
return Some(
- self.process_message_with_turn_outcome_async(
+ self.process_nested_target_message_adapter_async(
&json!({
"id": 0_u64,
"sessionId": session_id,
@@ -238,7 +238,7 @@ impl CdpConnection {
) {
let session_id = self.shared_worker_runtime_listener_session_for_route(&route)?;
return Some(
- self.process_message_with_turn_outcome_async(
+ self.process_nested_target_message_adapter_async(
&json!({
"id": 0_u64,
"sessionId": session_id,
@@ -311,20 +311,24 @@ impl CdpConnection {
&mut self,
route: &CdpSessionRoute,
) -> Option<String> {
- if let Some(session_id) = self.service_worker_runtime_listener_session_for_route(route) {
- return Some(session_id);
- }
- let CdpSessionRoute::ServiceWorkerTarget {
- browser_context_id,
- target_id,
- } = route
- else {
- return None;
+ let session_id = match self.service_worker_runtime_listener_session_for_route(route) {
+ Some(session_id) => session_id,
+ None => {
+ let CdpSessionRoute::ServiceWorkerTarget {
+ browser_context_id,
+ target_id,
+ } = route
+ else {
+ return None;
+ };
+ let session_id = service_worker_runtime_listener_session_id(target_id);
+ self.browser_context_by_id_mut(browser_context_id)?
+ .assign_session_to_service_worker_target(target_id, session_id.clone())
+ .then_some(session_id)?
+ }
};
- let session_id = service_worker_runtime_listener_session_id(target_id);
- self.browser_context_by_id_mut(browser_context_id)?
- .assign_session_to_service_worker_target(target_id, session_id.clone())
- .then_some(session_id)
+ self.commit_worker_runtime_listener_session_route(&session_id, route)?;
+ Some(session_id)
}
fn shared_worker_runtime_listener_session_for_route(
@@ -360,30 +364,57 @@ impl CdpConnection {
&mut self,
route: &CdpSessionRoute,
) -> Option<String> {
- if let Some(session_id) = self.shared_worker_runtime_listener_session_for_route(route) {
- return Some(session_id);
- }
- match route {
- CdpSessionRoute::SharedWorkerTarget {
- browser_context_id,
- target_id,
- } => {
- let session_id = shared_worker_runtime_listener_session_id(target_id);
- self.browser_context_by_id_mut(browser_context_id)?
- .assign_session_to_shared_worker_target(target_id, session_id.clone())
- .then_some(session_id)
- }
- CdpSessionRoute::DedicatedWorkerTarget {
- browser_context_id,
- target_id,
- } => {
- let session_id = dedicated_worker_runtime_listener_session_id(target_id);
- self.browser_context_by_id_mut(browser_context_id)?
- .assign_session_to_dedicated_worker_target(target_id, session_id.clone())
- .then_some(session_id)
- }
- _ => None,
+ let session_id = match self.shared_worker_runtime_listener_session_for_route(route) {
+ Some(session_id) => session_id,
+ None => match route {
+ CdpSessionRoute::SharedWorkerTarget {
+ browser_context_id,
+ target_id,
+ } => {
+ let session_id = shared_worker_runtime_listener_session_id(target_id);
+ self.browser_context_by_id_mut(browser_context_id)?
+ .assign_session_to_shared_worker_target(target_id, session_id.clone())
+ .then_some(session_id)?
+ }
+ CdpSessionRoute::DedicatedWorkerTarget {
+ browser_context_id,
+ target_id,
+ } => {
+ let session_id = dedicated_worker_runtime_listener_session_id(target_id);
+ self.browser_context_by_id_mut(browser_context_id)?
+ .assign_session_to_dedicated_worker_target(target_id, session_id.clone())
+ .then_some(session_id)?
+ }
+ _ => return None,
+ },
+ };
+ self.commit_worker_runtime_listener_session_route(&session_id, route)?;
+ Some(session_id)
+ }
+
+ fn commit_worker_runtime_listener_session_route(
+ &mut self,
+ session_id: &str,
+ route: &CdpSessionRoute,
+ ) -> Option<()> {
+ if self.target_control.attached_session_route(session_id) == Some(route) {
+ return Some(());
}
+ let target_id = match route {
+ CdpSessionRoute::SharedWorkerTarget { target_id, .. }
+ | CdpSessionRoute::DedicatedWorkerTarget { target_id, .. }
+ | CdpSessionRoute::ServiceWorkerTarget { target_id, .. } => target_id.clone(),
+ _ => return None,
+ };
+ self.target_control.commit_attached_session(
+ session_id.to_owned(),
+ None,
+ &target_id,
+ Some(route.clone()),
+ false,
+ false,
+ );
+ Some(())
}
}
@@ -405,7 +436,7 @@ mod tests {
use moli_shared_worker::SharedWorkerInstanceId;
use serde_json::json;
- use crate::conn::{BrowserContext, CdpConnection, SharedWorkerTargetState};
+ use crate::conn::{BrowserContext, CdpConnection, CdpSessionRoute, SharedWorkerTargetState};
#[test]
fn runtime_listener_session_ids_are_worker_type_scoped() {
@@ -426,6 +457,7 @@ mod tests {
#[tokio::test]
async fn runtime_listener_enable_uses_shared_worker_target_session() {
let mut conn = CdpConnection::new();
+ conn.require_committed_session_routes_for_test();
let mut browser_context = BrowserContext::new("BID-shared".to_owned());
browser_context.insert_shared_worker_target(SharedWorkerTargetState::new(
RendererOwnerLocalHostId::new_for_testing(1),
@@ -451,6 +483,16 @@ mod tests {
.is_some(),
"Runtime listener should attach a target-local SharedWorker session"
);
+ assert_eq!(
+ conn.session_route(Some(
+ "SID-bidi-runtime-listener-shared-worker-TID-shared-worker"
+ )),
+ Some(CdpSessionRoute::SharedWorkerTarget {
+ browser_context_id: "BID-shared".to_owned(),
+ target_id: "TID-shared-worker".to_owned(),
+ }),
+ "Runtime listener should commit its exact route before dispatch"
+ );
assert!(
messages.iter().any(|message| {
message["id"] == json!(0)
diff --git a/moli-protocol/src/conn/browser_context/target_session_owner.rs b/moli-protocol/src/conn/browser_context/target_session_owner.rs
index 7c229885b..281182d79 100644
--- a/moli-protocol/src/conn/browser_context/target_session_owner.rs
+++ b/moli-protocol/src/conn/browser_context/target_session_owner.rs
@@ -63,7 +63,7 @@ fn empty_pending_fetch_state() -> super::fetch_owner::SessionOwnerPendingFetchSt
pub(crate) struct ClosedPageTarget {
pub(crate) target_id: String,
pub(crate) primary_session_id: Option<String>,
- pub(crate) auxiliary_session_ids: Vec<String>,
+ pub(crate) attached_session_ids: Vec<String>,
}
impl ClosedPageTarget {
@@ -71,18 +71,18 @@ impl ClosedPageTarget {
self.primary_session_id
.as_deref()
.into_iter()
- .chain(self.auxiliary_session_ids.iter().map(String::as_str))
+ .chain(self.attached_session_ids.iter().map(String::as_str))
}
pub(crate) fn into_detach_cleanup_plan(
self,
reason: Option<&str>,
) -> crate::conn::TargetClosureCleanupPlan {
- crate::conn::TargetClosureCleanupPlan::from_primary_and_auxiliary_sessions(
+ crate::conn::TargetClosureCleanupPlan::from_primary_and_attached_sessions(
self.target_id,
reason,
self.primary_session_id,
- self.auxiliary_session_ids,
+ self.attached_session_ids,
)
}
}
@@ -1349,14 +1349,14 @@ impl CdpConnection {
let (
mut target,
primary_session_id,
- auxiliary_session_ids,
+ attached_session_ids,
collected_network_data_artifacts,
) = {
let browser_context = self.browser_context.as_mut()?;
let target = browser_context.take_page_target_for_close(target_id)?;
let collected_network_data_artifacts =
target.runtime_slot.collected_network_data_artifacts();
- let auxiliary_session_ids = target
+ let attached_session_ids = target
.devtools_sessions
.attached_session_ids()
.map(str::to_owned)
@@ -1365,7 +1365,7 @@ impl CdpConnection {
(
target,
primary_session_id,
- auxiliary_session_ids,
+ attached_session_ids,
collected_network_data_artifacts,
)
};
@@ -1375,7 +1375,7 @@ impl CdpConnection {
Some(ClosedPageTarget {
target_id: target_id.to_owned(),
primary_session_id,
- auxiliary_session_ids,
+ attached_session_ids,
})
}
@@ -1850,7 +1850,7 @@ impl CdpConnection {
/// source snapshot is being captured.
///
/// The renderer uses `None` for the target's primary inspector session and
- /// the concrete CDP session id for auxiliary sessions. Deferred protocol
+ /// the concrete CDP session id for attached sessions. Deferred protocol
/// output must translate that renderer-local convention once, at capture
/// time. Looking it up again during drain could route an old Page's
/// response or notification through a replacement Page or an unrelated
@@ -1950,7 +1950,7 @@ impl CdpConnection {
/// Resolves one concrete Page attachment for a target-owned event.
///
- /// The primary Page session is preferred, followed by a stable auxiliary
+ /// The primary Page session is preferred, followed by a stable attached
/// session. The implicit `None` attachment is valid only for the currently
/// active browser context and target; an unattached background target has
/// no protocol destination.
@@ -1971,7 +1971,7 @@ impl CdpConnection {
let session_id = primary_session_id
.or_else(|| {
browser_context
- .auxiliary_session_ids_for_target(target_id)
+ .attached_session_ids_for_target(target_id)
.into_iter()
.next()
})
@@ -2015,7 +2015,7 @@ impl CdpConnection {
self.target_owner_identity_for_session(session_id)
}
- pub(crate) fn target_devtools_auxiliary_session_id_for_session(
+ pub(crate) fn target_devtools_attached_session_id_for_session(
&self,
session_id: Option<&str>,
) -> Option<Option<String>> {
@@ -2106,9 +2106,9 @@ impl CdpConnection {
let primary_event_session_id =
primary_session_id.or_else(|| owner.session_id().map(str::to_owned));
session_ids.push(primary_event_session_id.clone());
- for auxiliary_session_id in browser_context.auxiliary_session_ids_for_target(&target_id) {
- if primary_event_session_id.as_deref() != Some(auxiliary_session_id.as_str()) {
- session_ids.push(Some(auxiliary_session_id));
+ for attached_session_id in browser_context.attached_session_ids_for_target(&target_id) {
+ if primary_event_session_id.as_deref() != Some(attached_session_id.as_str()) {
+ session_ids.push(Some(attached_session_id));
}
}
session_ids
@@ -2504,10 +2504,10 @@ mod tests {
}
}
- fn parked_target_context() -> BrowserContext {
- let mut context = BrowserContext::new("BID-parked".to_owned());
+ fn background_target_context() -> BrowserContext {
+ let mut context = BrowserContext::new("BID-background".to_owned());
context.insert_page_target_host(crate::conn::PageTargetHost::with_url(
- "TID-parked".to_owned(),
+ "TID-background".to_owned(),
None,
"about:blank".to_owned(),
));
@@ -2515,7 +2515,7 @@ mod tests {
}
#[test]
- fn target_session_owner_mut_mutates_active_and_parked_owner_state() {
+ fn target_session_owner_mut_mutates_active_and_background_owner_state() {
let mut active = BrowserContext::new_with_page_for_test("BID-active", "TID-active");
{
let mut owner = TargetSessionOwnerMut {
@@ -2536,11 +2536,11 @@ mod tests {
.is_crashed()
);
- let mut parked = parked_target_context();
+ let mut background = background_target_context();
{
let mut owner = TargetSessionOwnerMut {
- browser_context: &mut parked,
- target_id: "TID-parked".to_owned(),
+ browser_context: &mut background,
+ target_id: "TID-background".to_owned(),
command_session_id: None,
session_key: DevToolsSessionKey::Primary,
};
@@ -2549,8 +2549,8 @@ mod tests {
});
}
assert!(
- parked
- .background_target("TID-parked")
+ background
+ .background_target("TID-background")
.expect("background target must exist")
.owner_state
.target_crash_state
@@ -2580,14 +2580,12 @@ mod tests {
.set_page_attachment_id_for_test(2);
assert!(
browser_context
- .assign_auxiliary_session_to_target("TID-active", "SID-active-aux".to_owned(),)
- );
- assert!(
- browser_context.assign_auxiliary_session_to_target(
- "TID-background",
- "SID-background-aux".to_owned(),
- )
+ .assign_attached_session_to_target("TID-active", "SID-active-attached".to_owned(),)
);
+ assert!(browser_context.assign_attached_session_to_target(
+ "TID-background",
+ "SID-background-attached".to_owned(),
+ ));
conn.browser_context = Some(browser_context);
assert_eq!(
@@ -2610,38 +2608,40 @@ mod tests {
"primary background-target session uses the target's default renderer inspector session"
);
assert_eq!(
- conn.target_renderer_runtime_inspector_session_id_for_session(Some("SID-active-aux")),
- Some("SID-active-aux".to_owned()),
- "auxiliary active-target session owns a distinct renderer inspector session"
+ conn.target_renderer_runtime_inspector_session_id_for_session(Some(
+ "SID-active-attached"
+ )),
+ Some("SID-active-attached".to_owned()),
+ "attached active-target session owns a distinct renderer inspector session"
);
assert_eq!(
conn.target_renderer_runtime_inspector_session_id_for_session(Some(
- "SID-background-aux"
+ "SID-background-attached"
)),
- Some("SID-background-aux".to_owned()),
- "auxiliary background-target session owns a distinct renderer inspector session"
+ Some("SID-background-attached".to_owned()),
+ "attached background-target session owns a distinct renderer inspector session"
);
let default_route = conn
.target_page_protocol_attachment_identity_for_renderer_inspector_owner(
- &crate::conn::CommandOwnerScope::for_session("SID-active-aux"),
+ &crate::conn::CommandOwnerScope::for_session("SID-active-attached"),
None,
)
.expect("default inspector route should resolve through the target primary session");
assert_eq!(default_route.session_id(), Some("SID-active-primary"));
- let auxiliary_route = conn
+ let attached_route = conn
.target_page_protocol_attachment_identity_for_renderer_inspector_owner(
&crate::conn::CommandOwnerScope::for_session("SID-active-primary"),
- Some("SID-active-aux"),
+ Some("SID-active-attached"),
)
- .expect("auxiliary inspector route should retain its exact protocol attachment");
- assert_eq!(auxiliary_route.session_id(), Some("SID-active-aux"));
+ .expect("attached inspector route should retain its exact protocol attachment");
+ assert_eq!(attached_route.session_id(), Some("SID-active-attached"));
assert!(
conn.target_page_protocol_attachment_identity_for_renderer_inspector_owner(
&crate::conn::CommandOwnerScope::for_session("SID-active-primary"),
- Some("SID-background-aux"),
+ Some("SID-background-attached"),
)
.is_none(),
"a renderer batch must not borrow an inspector session attached to another target"
@@ -2649,7 +2649,7 @@ mod tests {
}
#[test]
- fn target_session_owner_mut_mutates_active_and_parked_fetch_state() {
+ fn target_session_owner_mut_mutates_active_and_background_fetch_state() {
let mut active = BrowserContext::new_with_page_for_test("BID-active", "TID-active");
{
let mut owner = TargetSessionOwnerMut {
@@ -2670,31 +2670,31 @@ mod tests {
.has_pending_subresource_fetch_for_test("FETCH-active")
);
- let mut parked = parked_target_context();
+ let mut background = background_target_context();
{
let mut owner = TargetSessionOwnerMut {
- browser_context: &mut parked,
- target_id: "TID-parked".to_owned(),
+ browser_context: &mut background,
+ target_id: "TID-background".to_owned(),
command_session_id: None,
session_key: DevToolsSessionKey::Primary,
};
assert!(owner.register_pending_subresource_fetch_request(
- "FETCH-parked".to_owned(),
+ "FETCH-background".to_owned(),
pending_subresource_fetch(2),
));
}
assert!(
- parked
- .background_target("TID-parked")
+ background
+ .background_target("TID-background")
.expect("background target must exist")
.fetch_owner
.pending_state()
- .has_pending_subresource_fetch_for_test("FETCH-parked")
+ .has_pending_subresource_fetch_for_test("FETCH-background")
);
}
#[test]
- fn target_session_owner_mut_configures_and_resets_active_and_parked_fetch_state() {
+ fn target_session_owner_mut_configures_and_resets_active_and_background_fetch_state() {
let patterns = vec![FetchInterceptionPattern {
url_pattern: "*".to_owned(),
resource_type_filter: None,
@@ -2737,37 +2737,37 @@ mod tests {
.has_pending_subresource_fetch_for_test("FETCH-active")
);
- let mut parked = parked_target_context();
+ let mut background = background_target_context();
{
let mut owner = TargetSessionOwnerMut {
- browser_context: &mut parked,
- target_id: "TID-parked".to_owned(),
+ browser_context: &mut background,
+ target_id: "TID-background".to_owned(),
command_session_id: None,
session_key: DevToolsSessionKey::Primary,
};
assert_eq!(
- owner.configure_fetch(Some("SID-parked".to_owned()), true, patterns),
+ owner.configure_fetch(Some("SID-background".to_owned()), true, patterns),
(true, None)
);
assert!(owner.register_pending_subresource_fetch_request(
- "FETCH-parked".to_owned(),
+ "FETCH-background".to_owned(),
pending_subresource_fetch(22),
));
- let (pending, subresource_config, page_update_required) =
- owner.reset_fetch_config_for_session_and_drain_pending_state(Some("SID-parked"));
+ let (pending, subresource_config, page_update_required) = owner
+ .reset_fetch_config_for_session_and_drain_pending_state(Some("SID-background"));
assert_eq!(subresource_config, (false, None));
assert!(page_update_required);
assert_eq!(pending.3.len(), 1);
}
assert!(
- parked
- .background_target("TID-parked")
+ background
+ .background_target("TID-background")
.filter(|target| target.has_non_default_session_state())
.is_none_or(|state| !state.fetch_owner.is_enabled())
);
assert!(
- parked
- .background_target("TID-parked")
+ background
+ .background_target("TID-background")
.expect("background target must exist")
.fetch_owner
.pending_state()
@@ -2776,7 +2776,7 @@ mod tests {
}
#[test]
- fn target_session_owner_mut_snapshots_active_and_parked_navigation_history() {
+ fn target_session_owner_mut_snapshots_active_and_background_navigation_history() {
let mut active = BrowserContext::new_with_page_for_test("BID-active", "TID-active");
active
.active_page_target_mut()
@@ -2800,28 +2800,28 @@ mod tests {
assert_eq!(entries[0].url, "https://active.example/");
}
- let mut parked = parked_target_context();
- parked
- .background_target_mut("TID-parked")
+ let mut background = background_target_context();
+ background
+ .background_target_mut("TID-background")
.expect("background target must exist")
.owner_state
.record_loaded_page_navigation_history((
- "https://parked.example/".to_owned(),
- "parked".to_owned(),
+ "https://background.example/".to_owned(),
+ "background".to_owned(),
));
{
let mut owner = TargetSessionOwnerMut {
- browser_context: &mut parked,
- target_id: "TID-parked".to_owned(),
+ browser_context: &mut background,
+ target_id: "TID-background".to_owned(),
command_session_id: None,
session_key: DevToolsSessionKey::Primary,
};
let (current_index, entries) = owner
.navigation_history_snapshot()
- .expect("parked history should snapshot");
+ .expect("background history should snapshot");
assert_eq!(current_index, 0);
assert_eq!(entries.len(), 1);
- assert_eq!(entries[0].url, "https://parked.example/");
+ assert_eq!(entries[0].url, "https://background.example/");
}
}
@@ -2927,32 +2927,32 @@ mod tests {
#[test]
fn target_session_owner_mut_prepares_background_navigation_request_preflight() {
- let mut parked = BrowserContext::new_with_page_for_test("BID-parked", "TID-active");
- parked
+ let mut background = BrowserContext::new_with_page_for_test("BID-background", "TID-active");
+ background
.active_page_target_mut()
.set_base_locale_override(Some("zh-CN".to_owned()));
- parked
+ background
.active_page_target_mut()
.network_policy
.set_browser_identity_override(test_browser_identity("Active-Only-UA"));
- parked.replace_default_browser_identity_override_for_test(test_browser_identity(
+ background.replace_default_browser_identity_override_for_test(test_browser_identity(
"Browser-Context-Default-UA",
));
- parked.insert_page_target_host(crate::conn::PageTargetHost::with_url(
- "TID-parked".to_owned(),
- Some("SID-parked".to_owned()),
+ background.insert_page_target_host(crate::conn::PageTargetHost::with_url(
+ "TID-background".to_owned(),
+ Some("SID-background".to_owned()),
"about:blank".to_owned(),
));
{
- let state = parked
- .background_target_mut("TID-parked")
+ let state = background
+ .background_target_mut("TID-background")
.expect("background target must exist");
state.runtime_slot.enable_primary_network_events();
state
.network_policy
- .push_extra_header(("X-Owner".to_owned(), "parked".to_owned()));
+ .push_extra_header(("X-Owner".to_owned(), "background".to_owned()));
state.fetch_owner.configure(
- Some("SID-parked".to_owned()),
+ Some("SID-background".to_owned()),
false,
vec![FetchInterceptionPattern {
url_pattern: "*".to_owned(),
@@ -2961,27 +2961,27 @@ mod tests {
}],
);
}
- parked
- .background_target_mut("TID-parked")
+ background
+ .background_target_mut("TID-background")
.expect("background target should exist")
.runtime_slot
.record_captured_response_body(
"REQ-old".to_owned(),
"old body".to_owned(),
- vec![Some("SID-parked".to_owned())],
+ vec![Some("SID-background".to_owned())],
);
assert!(
- parked
- .background_target("TID-parked")
+ background
+ .background_target("TID-background")
.expect("background target should exist")
.runtime_slot()
.has_captured_response_body("REQ-old")
);
let mut owner = TargetSessionOwnerMut {
- browser_context: &mut parked,
- target_id: "TID-parked".to_owned(),
- command_session_id: Some("SID-parked".to_owned()),
+ browser_context: &mut background,
+ target_id: "TID-background".to_owned(),
+ command_session_id: Some("SID-background".to_owned()),
session_key: DevToolsSessionKey::Primary,
};
let mut network_request_id_allocator = ConnectionNetworkRequestIdAllocator::default();
@@ -2995,8 +2995,8 @@ mod tests {
)
.expect("background preflight should prepare");
- assert_eq!(preflight.frame_id, "TID-parked");
- assert_eq!(preflight.session_id.as_deref(), Some("SID-parked"));
+ assert_eq!(preflight.frame_id, "TID-background");
+ assert_eq!(preflight.session_id.as_deref(), Some("SID-background"));
assert_eq!(
preflight.document_fetch_request_stage,
Some(FetchRequestStage::Response)
@@ -3010,8 +3010,8 @@ mod tests {
Some("INT-1")
);
assert!(
- !parked
- .background_target("TID-parked")
+ !background
+ .background_target("TID-background")
.expect("background target should exist")
.runtime_slot()
.has_captured_response_body("REQ-old")
@@ -3019,7 +3019,7 @@ mod tests {
assert!(
preflight
.request_headers
- .contains(&("X-Owner".to_owned(), "parked".to_owned()))
+ .contains(&("X-Owner".to_owned(), "background".to_owned()))
);
assert!(
preflight
@@ -3047,21 +3047,21 @@ mod tests {
#[test]
fn target_session_owner_mut_observes_background_data_url_navigation_with_network_listener() {
- let mut parked = BrowserContext::new("BID-parked".to_owned());
- parked.insert_page_target_host(crate::conn::PageTargetHost::with_url(
- "TID-parked".to_owned(),
- Some("SID-parked".to_owned()),
+ let mut background = BrowserContext::new("BID-background".to_owned());
+ background.insert_page_target_host(crate::conn::PageTargetHost::with_url(
+ "TID-background".to_owned(),
+ Some("SID-background".to_owned()),
"about:blank".to_owned(),
));
- parked
- .background_target_mut("TID-parked")
+ background
+ .background_target_mut("TID-background")
.expect("background target must exist")
.runtime_slot
.enable_primary_network_events();
let mut owner = TargetSessionOwnerMut {
- browser_context: &mut parked,
- target_id: "TID-parked".to_owned(),
+ browser_context: &mut background,
+ target_id: "TID-background".to_owned(),
command_session_id: None,
session_key: DevToolsSessionKey::Primary,
};
@@ -3076,8 +3076,8 @@ mod tests {
)
.expect("background data URL preflight should prepare");
- assert_eq!(preflight.frame_id, "TID-parked");
- assert_eq!(preflight.session_id.as_deref(), Some("SID-parked"));
+ assert_eq!(preflight.frame_id, "TID-background");
+ assert_eq!(preflight.session_id.as_deref(), Some("SID-background"));
assert_eq!(preflight.document_fetch_request_stage, None);
assert_eq!(
preflight.document_request_id.as_deref(),
@@ -3094,18 +3094,18 @@ mod tests {
#[test]
fn target_session_owner_ref_snapshots_background_navigation_load_inputs() {
- let mut parked = BrowserContext::new_with_page_for_test("BID-parked", "TID-active");
- parked
+ let mut background = BrowserContext::new_with_page_for_test("BID-background", "TID-active");
+ background
.active_page_target_mut()
.set_base_locale_override(Some("zh-CN".to_owned()));
- parked.insert_page_target_host(crate::conn::PageTargetHost::with_url(
- "TID-parked".to_owned(),
- Some("SID-parked".to_owned()),
- "https://parked.example/start".to_owned(),
+ background.insert_page_target_host(crate::conn::PageTargetHost::with_url(
+ "TID-background".to_owned(),
+ Some("SID-background".to_owned()),
+ "https://background.example/start".to_owned(),
));
{
- let state = parked
- .background_target_mut("TID-parked")
+ let state = background
+ .background_target_mut("TID-background")
.expect("background target must exist");
state.set_base_locale_override(Some("fr-FR".to_owned()));
state.set_base_timezone_override(Some("Europe/Paris".to_owned()));
@@ -3122,10 +3122,10 @@ mod tests {
network.blocked_url_patterns = vec!["*.blocked.test".to_owned()];
state
.network_policy
- .push_extra_header(("X-Owner".to_owned(), "parked".to_owned()));
+ .push_extra_header(("X-Owner".to_owned(), "background".to_owned()));
state.emulated_media.media = Some("print".to_owned());
state.fetch_owner.configure(
- Some("SID-parked".to_owned()),
+ Some("SID-background".to_owned()),
false,
vec![FetchInterceptionPattern {
url_pattern: "*".to_owned(),
@@ -3134,8 +3134,8 @@ mod tests {
}],
);
}
- parked
- .background_target_mut("TID-parked")
+ background
+ .background_target_mut("TID-background")
.expect("background target must exist")
.owner_state
.document_start_scripts
@@ -3144,58 +3144,58 @@ mod tests {
DocumentStartScript {
registry_key: None,
devtools_session: None,
- source: "globalThis.fromParkedPreload = true;".to_owned(),
+ source: "globalThis.fromBackgroundPreload = true;".to_owned(),
world_name: Some("utility".to_owned()),
has_bidi_channel_argument: false,
bidi_channel_handoffs: Vec::new(),
},
));
- parked
- .background_target_mut("TID-parked")
+ background
+ .background_target_mut("TID-background")
.expect("background target must exist")
.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
.upsert_runtime_binding_definition(
- "fromParkedBinding".to_owned(),
+ "fromBackgroundBinding".to_owned(),
Some("utility".to_owned()),
);
let owner = TargetSessionOwnerRef {
- browser_context: &parked,
- target_id: "TID-parked".to_owned(),
+ browser_context: &background,
+ target_id: "TID-background".to_owned(),
session_key: DevToolsSessionKey::Primary,
};
let inputs = owner.navigation_load_inputs();
- assert_eq!(inputs.browser_context_id.as_deref(), Some("BID-parked"));
+ assert_eq!(inputs.browser_context_id.as_deref(), Some("BID-background"));
assert!(
inputs
.renderer_runtime
.runtime()
- .shares_state_with(&parked.renderer_runtime()),
+ .shares_state_with(&background.renderer_runtime()),
"background navigation must reuse the browser-context renderer runtime"
);
assert_eq!(
inputs.navigation_initiator_url.as_ref().map(Url::as_str),
- Some("https://parked.example/start")
+ Some("https://background.example/start")
);
assert!(
inputs
.document_start_scripts
.iter()
- .any(|script| script.source == "globalThis.fromParkedPreload = true;")
+ .any(|script| script.source == "globalThis.fromBackgroundPreload = true;")
);
assert_eq!(
inputs.runtime_bindings,
vec![RuntimeBindingDefinition {
devtools_session: Some(moli_page_types::DevToolsSessionKey::Primary),
- name: "fromParkedBinding".to_owned(),
+ name: "fromBackgroundBinding".to_owned(),
execution_context_name: Some("utility".to_owned()),
}]
);
assert!(
inputs
.extra_http_headers
- .contains(&("X-Owner".to_owned(), "parked".to_owned()))
+ .contains(&("X-Owner".to_owned(), "background".to_owned()))
);
assert!(
inputs
@@ -3230,15 +3230,15 @@ mod tests {
#[test]
fn target_session_owner_mut_prepares_background_navigation_commit_state() {
- let mut parked = BrowserContext::new("BID-parked".to_owned());
- parked.insert_page_target_host(crate::conn::PageTargetHost::with_url(
- "TID-parked".to_owned(),
- Some("SID-parked".to_owned()),
+ let mut background = BrowserContext::new("BID-background".to_owned());
+ background.insert_page_target_host(crate::conn::PageTargetHost::with_url(
+ "TID-background".to_owned(),
+ Some("SID-background".to_owned()),
"about:blank".to_owned(),
));
{
- let state = parked
- .background_target_mut("TID-parked")
+ let state = background
+ .background_target_mut("TID-background")
.expect("background target must exist");
state.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
.page_session_state
@@ -3247,7 +3247,7 @@ mod tests {
.runtime_session_state
.runtime_frontend_enabled = true;
state.fetch_owner.configure(
- Some("SID-parked".to_owned()),
+ Some("SID-background".to_owned()),
false,
vec![FetchInterceptionPattern {
url_pattern: "*".to_owned(),
@@ -3259,8 +3259,8 @@ mod tests {
let commit_state = {
let mut owner = TargetSessionOwnerMut {
- browser_context: &mut parked,
- target_id: "TID-parked".to_owned(),
+ browser_context: &mut background,
+ target_id: "TID-background".to_owned(),
command_session_id: None,
session_key: DevToolsSessionKey::Primary,
};
@@ -3269,23 +3269,23 @@ mod tests {
.expect("background navigation commit state should prepare")
};
- assert_eq!(commit_state.browser_context_id, "BID-parked");
+ assert_eq!(commit_state.browser_context_id, "BID-background");
assert!(commit_state.runtime_frontend_enabled);
assert_eq!(
- parked
- .background_target("TID-parked")
+ background
+ .background_target("TID-background")
.expect("background target")
.target_url(),
"about:blank",
"preparing commit state should not mutate target identity"
);
let navigation_url = Url::parse("https://nav.example/path").unwrap();
- parked
- .background_target_mut("TID-parked")
+ background
+ .background_target_mut("TID-background")
.expect("background target")
.set_target_secure_context_type("InsecureScheme".to_owned());
let main_document_commit = RendererMainDocumentCommit {
- frame_id: "TID-parked".to_owned(),
+ frame_id: "TID-background".to_owned(),
loader_id: "LOADER-nav".to_owned(),
url: navigation_url.to_string(),
unreachable_url: None,
@@ -3295,8 +3295,8 @@ mod tests {
};
{
let mut owner = TargetSessionOwnerMut {
- browser_context: &mut parked,
- target_id: "TID-parked".to_owned(),
+ browser_context: &mut background,
+ target_id: "TID-background".to_owned(),
command_session_id: None,
session_key: DevToolsSessionKey::Primary,
};
@@ -3305,15 +3305,15 @@ mod tests {
.expect("background navigation identity should commit")
};
assert_eq!(
- parked
- .background_target("TID-parked")
+ background
+ .background_target("TID-background")
.expect("background target")
.target_url(),
"https://nav.example/path"
);
assert_eq!(
- parked
- .background_target("TID-parked")
+ background
+ .background_target("TID-background")
.expect("background target")
.target_identity()
.secure_context_type(),
@@ -3324,15 +3324,15 @@ mod tests {
#[test]
fn target_session_owner_mut_clears_background_navigation_history_update() {
- let mut parked = BrowserContext::new("BID-parked".to_owned());
- parked.insert_page_target_host(crate::conn::PageTargetHost::with_url(
- "TID-parked".to_owned(),
- Some("SID-parked".to_owned()),
+ let mut background = BrowserContext::new("BID-background".to_owned());
+ background.insert_page_target_host(crate::conn::PageTargetHost::with_url(
+ "TID-background".to_owned(),
+ Some("SID-background".to_owned()),
"about:blank".to_owned(),
));
{
- let owner_state = &mut parked
- .background_target_mut("TID-parked")
+ let owner_state = &mut background
+ .background_target_mut("TID-background")
.expect("background target must exist")
.owner_state;
owner_state.record_loaded_page_navigation_history((
@@ -3343,8 +3343,8 @@ mod tests {
}
{
let mut owner = TargetSessionOwnerMut {
- browser_context: &mut parked,
- target_id: "TID-parked".to_owned(),
+ browser_context: &mut background,
+ target_id: "TID-background".to_owned(),
command_session_id: None,
session_key: DevToolsSessionKey::Primary,
};
@@ -3352,16 +3352,16 @@ mod tests {
.clear_pending_navigation_history_update()
.expect("background history update should clear");
}
- parked
- .background_target_mut("TID-parked")
+ background
+ .background_target_mut("TID-background")
.expect("background target must exist")
.owner_state
.record_loaded_page_navigation_history((
"https://new.example/".to_owned(),
"new".to_owned(),
));
- let (_, entries) = parked
- .background_target_mut("TID-parked")
+ let (_, entries) = background
+ .background_target_mut("TID-background")
.expect("background target must exist")
.owner_state
.navigation_history_snapshot(None);
@@ -3383,21 +3383,21 @@ mod tests {
.await
.expect("page should load");
let page_url = page.final_url().clone();
- let mut parked = BrowserContext::new("BID-parked".to_owned());
- parked.insert_page_target_host(crate::conn::PageTargetHost::with_url(
- "TID-parked".to_owned(),
- Some("SID-parked".to_owned()),
+ let mut background = BrowserContext::new("BID-background".to_owned());
+ background.insert_page_target_host(crate::conn::PageTargetHost::with_url(
+ "TID-background".to_owned(),
+ Some("SID-background".to_owned()),
"about:blank".to_owned(),
));
- let initial_attachment_id = parked
- .background_target("TID-parked")
+ let initial_attachment_id = background
+ .background_target("TID-background")
.expect("background target")
.page_attachment_id();
{
let mut owner = TargetSessionOwnerMut {
- browser_context: &mut parked,
- target_id: "TID-parked".to_owned(),
+ browser_context: &mut background,
+ target_id: "TID-background".to_owned(),
command_session_id: None,
session_key: DevToolsSessionKey::Primary,
};
@@ -3412,16 +3412,16 @@ mod tests {
.expect("background page Inspector binding should activate");
}
- let target = parked
- .background_target("TID-parked")
+ let target = background
+ .background_target("TID-background")
.expect("background target");
assert!(target.has_loaded_page());
assert!(
target.page_attachment_id().is_some()
&& target.page_attachment_id() != initial_attachment_id
);
- let (_, entries) = parked
- .background_target_mut("TID-parked")
+ let (_, entries) = background
+ .background_target_mut("TID-background")
.expect("background target must exist")
.owner_state
.navigation_history_snapshot(None);
@@ -3535,7 +3535,7 @@ mod tests {
}
#[test]
- fn connection_target_owner_reference_reads_and_mutates_active_and_parked_state() {
+ fn connection_target_owner_reference_reads_and_mutates_active_and_background_state() {
let mut conn = CdpConnection::default();
let mut browser_context = BrowserContext::new("BID-1".to_owned());
browser_context.set_active_target_id("TID-active".to_owned());
@@ -3598,15 +3598,17 @@ mod tests {
browser_context.set_active_target_id("TID-page-events".to_owned());
browser_context.attach_active_session("SID-primary".to_owned());
assert!(
- browser_context.assign_auxiliary_session_to_target(
+ browser_context.assign_attached_session_to_target(
"TID-page-events",
"SID-page-enabled".to_owned(),
)
);
- assert!(browser_context.assign_auxiliary_session_to_target(
- "TID-page-events",
- "SID-lifecycle-only".to_owned(),
- ));
+ assert!(
+ browser_context.assign_attached_session_to_target(
+ "TID-page-events",
+ "SID-lifecycle-only".to_owned(),
+ )
+ );
conn.browser_context = Some(browser_context);
for session_id in ["SID-primary", "SID-lifecycle-only"] {
@@ -3625,7 +3627,7 @@ mod tests {
Some("SID-page-enabled"),
|state| state.page_session_state.page_domain_enabled = true,
)
- .expect("Page-enabled auxiliary session should be mutable");
+ .expect("Page-enabled attached session should be mutable");
assert_eq!(
conn.subscribed_page_event_session_ids_for_session_owner(Some("SID-primary")),
vec![Some("SID-page-enabled".to_owned())]
@@ -3652,12 +3654,12 @@ mod tests {
browser_context.set_active_target_id("TID-runtime-events".to_owned());
browser_context.attach_active_session("SID-runtime-a".to_owned());
assert!(
- browser_context.assign_auxiliary_session_to_target(
+ browser_context.assign_attached_session_to_target(
"TID-runtime-events",
"SID-runtime-b".to_owned(),
)
);
- assert!(browser_context.assign_auxiliary_session_to_target(
+ assert!(browser_context.assign_attached_session_to_target(
"TID-runtime-events",
"SID-runtime-disabled".to_owned(),
));
@@ -3670,7 +3672,7 @@ mod tests {
conn.with_target_devtools_session_state_for_session_mut(Some("SID-runtime-b"), |state| {
state.runtime_session_state.runtime_frontend_enabled = true
})
- .expect("Runtime-enabled auxiliary session should be mutable");
+ .expect("Runtime-enabled attached session should be mutable");
assert_eq!(
conn.runtime_event_protocol_attachments_for_owner(
&crate::conn::CommandOwnerScope::for_session("SID-runtime-a")
@@ -3749,7 +3751,7 @@ mod tests {
}
#[test]
- fn connection_runtime_slot_reference_reads_and_mutates_active_background_and_auxiliary_slots() {
+ fn connection_runtime_slot_reference_reads_and_mutates_active_background_and_attached_slots() {
let mut conn = CdpConnection::default();
let mut active = BrowserContext::new_with_page_for_test("BID-active", "TID-active");
active.set_active_target_id("TID-active".to_owned());
@@ -3766,12 +3768,10 @@ mod tests {
.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
.page_session_state
.log_enabled = true;
- assert!(
- active.assign_auxiliary_session_to_target(
- "TID-background",
- "SID-aux-background".to_owned()
- )
- );
+ assert!(active.assign_attached_session_to_target(
+ "TID-background",
+ "SID-attached-background".to_owned()
+ ));
let mut inactive = BrowserContext::new("BID-inactive".to_owned());
inactive.set_active_target_id("TID-inactive".to_owned());
@@ -3779,12 +3779,14 @@ mod tests {
inactive
.active_page_target_mut()
.devtools_sessions
- .ensure_attached("SID-aux-inactive")
+ .ensure_attached("SID-attached-inactive")
.console_output_session_state
.console_enabled = true;
assert!(
- inactive
- .assign_auxiliary_session_to_target("TID-inactive", "SID-aux-inactive".to_owned())
+ inactive.assign_attached_session_to_target(
+ "TID-inactive",
+ "SID-attached-inactive".to_owned()
+ )
);
conn.browser_context = Some(active);
@@ -3796,8 +3798,8 @@ mod tests {
conn.runtime_session_owner_slot_mut(Some("SID-background"))
.expect("background runtime slot should be mutable")
.set_page_attachment_id_for_test(22);
- conn.runtime_session_owner_slot_mut(Some("SID-aux-inactive"))
- .expect("inactive auxiliary runtime slot should be mutable")
+ conn.runtime_session_owner_slot_mut(Some("SID-attached-inactive"))
+ .expect("inactive attached runtime slot should be mutable")
.set_page_attachment_id_for_test(33);
assert_eq!(
@@ -3815,15 +3817,15 @@ mod tests {
Some(22)
);
assert_eq!(
- conn.runtime_session_owner_slot(Some("SID-aux-background"))
- .expect("background auxiliary runtime slot should be readable")
+ conn.runtime_session_owner_slot(Some("SID-attached-background"))
+ .expect("background attached runtime slot should be readable")
.page_attachment_id()
.map(crate::conn::TargetPageAttachmentId::get),
Some(22)
);
assert_eq!(
- conn.runtime_session_owner_slot(Some("SID-aux-inactive"))
- .expect("inactive auxiliary runtime slot should be readable")
+ conn.runtime_session_owner_slot(Some("SID-attached-inactive"))
+ .expect("inactive attached runtime slot should be readable")
.page_attachment_id()
.map(crate::conn::TargetPageAttachmentId::get),
Some(33)
@@ -3839,7 +3841,7 @@ mod tests {
Some("SID-background")
);
assert_eq!(
- conn.runtime_session_owner_primary_session_id(Some("SID-aux-background"))
+ conn.runtime_session_owner_primary_session_id(Some("SID-attached-background"))
.as_deref(),
Some("SID-background")
);
@@ -3849,16 +3851,16 @@ mod tests {
Some("https://background.example/")
);
assert_eq!(
- conn.runtime_session_owner_target_url(Some("SID-aux-inactive"))
+ conn.runtime_session_owner_target_url(Some("SID-attached-inactive"))
.as_deref(),
Some("https://inactive.example/")
);
assert_eq!(
- conn.target_owner_identity_for_session(Some("SID-aux-background")),
+ conn.target_owner_identity_for_session(Some("SID-attached-background")),
Some(("BID-active".to_owned(), Some("TID-background".to_owned())))
);
assert_eq!(
- conn.target_owner_identity_for_session(Some("SID-aux-inactive")),
+ conn.target_owner_identity_for_session(Some("SID-attached-inactive")),
Some(("BID-inactive".to_owned(), Some("TID-inactive".to_owned())))
);
assert!(
@@ -3867,8 +3869,8 @@ mod tests {
.log_enabled
);
assert!(
- conn.target_devtools_session_state_for_session(Some("SID-aux-inactive"))
- .expect("inactive auxiliary DevTools session state should be readable")
+ conn.target_devtools_session_state_for_session(Some("SID-attached-inactive"))
+ .expect("inactive attached DevTools session state should be readable")
.console_output_session_state
.console_enabled
);
@@ -3893,7 +3895,7 @@ mod tests {
.background_target("TID-background-dialog")
.filter(|target| target.has_non_default_session_state())
.is_none(),
- "a background target with default protocol settings should not allocate parked overrides"
+ "a background target with default protocol settings should not allocate background overrides"
);
conn.browser_context = Some(browser_context);
diff --git a/moli-protocol/src/conn/command_owner_scope.rs b/moli-protocol/src/conn/command_owner_scope.rs
index 769a00498..944d427af 100644
--- a/moli-protocol/src/conn/command_owner_scope.rs
+++ b/moli-protocol/src/conn/command_owner_scope.rs
@@ -160,21 +160,21 @@ mod tests {
}
#[test]
- fn explicit_target_preserves_matching_auxiliary_session_authority() {
+ fn explicit_target_preserves_matching_attached_session_authority() {
let mut conn = CdpConnection::default();
let mut browser_context = BrowserContext::new_with_page_for_test("BID-owner", "TID-owner");
browser_context.attach_active_session("SID-primary");
assert!(
browser_context
- .assign_auxiliary_session_to_target("TID-owner", "SID-auxiliary".to_owned(),)
+ .assign_attached_session_to_target("TID-owner", "SID-attached".to_owned(),)
);
conn.browser_context = Some(browser_context);
let owner = conn
- .command_owner_scope_for_devtools_context(&page_context("SID-auxiliary", "TID-owner"))
- .expect("matching auxiliary attachment should own the command");
+ .command_owner_scope_for_devtools_context(&page_context("SID-attached", "TID-owner"))
+ .expect("matching attached attachment should own the command");
- assert_eq!(owner.session_id(), Some("SID-auxiliary"));
+ assert_eq!(owner.session_id(), Some("SID-attached"));
assert!(owner.explicit_route().is_none());
}
diff --git a/moli-protocol/src/conn/command_view.rs b/moli-protocol/src/conn/command_view.rs
index 19ea8b1cd..8bcdf0a94 100644
--- a/moli-protocol/src/conn/command_view.rs
+++ b/moli-protocol/src/conn/command_view.rs
@@ -106,11 +106,9 @@ impl<'a> Cmd<'a> {
self.renderer_policy
}
- pub(crate) fn terminal_response_delivery(
- &self,
- default: RendererInspectorResponseDelivery,
- ) -> RendererInspectorResponseDelivery {
- self.terminal_response_delivery_override.unwrap_or(default)
+ pub(crate) fn terminal_response_delivery(&self) -> RendererInspectorResponseDelivery {
+ self.terminal_response_delivery_override
+ .unwrap_or(RendererInspectorResponseDelivery::SessionSink)
}
/// Build the protocol-neutral command context for shared DevTools command
diff --git a/moli-protocol/src/conn/devtools_command.rs b/moli-protocol/src/conn/devtools_command.rs
index 23887abec..82fcce665 100644
--- a/moli-protocol/src/conn/devtools_command.rs
+++ b/moli-protocol/src/conn/devtools_command.rs
@@ -92,7 +92,7 @@ impl DevToolsCommandDispatchOutcome {
/// an exact renderer response fence.
///
/// This deliberately remains a checked, narrow operation. If the command
- /// later starts producing auxiliary output, its owning call site fails
+ /// later starts producing additional output, its owning call site fails
/// immediately instead of silently losing that output.
#[track_caller]
pub fn into_parts(
diff --git a/moli-protocol/src/conn/dispatch.rs b/moli-protocol/src/conn/dispatch.rs
index 7a315aab7..562171684 100644
--- a/moli-protocol/src/conn/dispatch.rs
+++ b/moli-protocol/src/conn/dispatch.rs
@@ -1256,13 +1256,13 @@ impl CdpConnection {
.await
}
- pub(crate) async fn process_message_with_command_reply_turn_outcome_async(
+ pub(crate) async fn process_nested_target_message_adapter_async(
&mut self,
raw: &str,
) -> CdpRendererOwnerTurnOutcome {
self.process_message_with_terminal_response_delivery_async(
raw,
- Some(moli_page_types::RendererInspectorResponseDelivery::CommandReply),
+ Some(moli_page_types::RendererInspectorResponseDelivery::AdapterReply),
)
.await
}
diff --git a/moli-protocol/src/conn/dispatch_tests.rs b/moli-protocol/src/conn/dispatch_tests.rs
index 6b4cf1e3c..c274aa179 100644
--- a/moli-protocol/src/conn/dispatch_tests.rs
+++ b/moli-protocol/src/conn/dispatch_tests.rs
@@ -333,7 +333,7 @@ async fn assert_bidi_fetch_action_consumes_background_request(
.expect("browser context")
.active_target_id(),
Some("TID-active"),
- "resolving a BiDi request id must not promote the background target"
+ "resolving a BiDi request id must not activate the background target"
);
}
@@ -779,7 +779,7 @@ async fn bidi_fetch_control_resolves_background_request_owner() {
.expect("browser context")
.active_target_id(),
Some("TID-active"),
- "resolving a BiDi request id must not promote the background target"
+ "resolving a BiDi request id must not activate the background target"
);
}
@@ -1119,7 +1119,7 @@ async fn devtools_create_target_uses_reference_target_browser_context_when_unspe
reference_context
.background_target("TID-reference")
.is_some(),
- "the reference context's previous active target should be demoted inside the same browser context"
+ "the reference context's previous active target should be deactivated inside the same browser context"
);
}
@@ -1179,7 +1179,7 @@ async fn devtools_create_target_explicit_browser_context_overrides_reference_tar
assert_eq!(
reference_context.active_target_id(),
Some("TID-reference"),
- "reference context should not be demoted when explicit browser context is provided"
+ "reference context should not be deactivated when explicit browser context is provided"
);
}
@@ -1600,7 +1600,7 @@ async fn devtools_runtime_command_uses_background_initial_document_without_resol
.any(|script| script
.source
.contains("defineGetter(document, 'hidden', () => true)")),
- "background initial document lifecycle should include parked document surface script"
+ "background initial document lifecycle should include background document surface script"
);
let (name_result, _) = conn
@@ -1675,7 +1675,7 @@ async fn devtools_runtime_command_uses_background_initial_document_without_resol
"hidden": true,
"visibilityState": "hidden"
}),
- "default background initial document should install parked document surfaces"
+ "default background initial document should install background document surfaces"
);
let browser_context = conn.browser_context.as_ref().expect("browser context");
@@ -2310,12 +2310,13 @@ async fn target_lifecycle_ensure_installs_initial_about_blank_page_for_active_ta
"immediate target create path should still only stage owner metadata before lifecycle ensure"
);
+ let initial_document_owner = CommandOwnerScope::capture(&conn, None);
let pending = conn
- .start_initial_document_page_ensure_for_session_owner(None)
+ .start_initial_document_page_ensure_for_owner(&initial_document_owner)
.expect("target lifecycle ensure should start active initial page")
.expect("fresh initial target should pend active initial document page build");
let joined_pending = conn
- .start_initial_document_page_ensure_for_session_owner(None)
+ .start_initial_document_page_ensure_for_owner(&initial_document_owner)
.expect("second ensure should join the active initial page build")
.expect("second ensure should wait for the active initial page build");
let completed = pending
@@ -2341,7 +2342,7 @@ async fn target_lifecycle_ensure_installs_initial_about_blank_page_for_active_ta
);
assert!(
- conn.start_initial_document_page_ensure_for_session_owner(None)
+ conn.start_initial_document_page_ensure_for_owner(&initial_document_owner)
.expect("second target lifecycle ensure should succeed")
.is_none(),
"second ensure should be a no-op"
@@ -2374,8 +2375,9 @@ async fn stale_initial_document_page_build_does_not_overwrite_committed_page() {
panic!("expected create target result");
};
+ let initial_document_owner = CommandOwnerScope::capture(&conn, None);
let pending = conn
- .start_initial_document_page_ensure_for_session_owner(None)
+ .start_initial_document_page_ensure_for_owner(&initial_document_owner)
.expect("target lifecycle ensure should start active initial page")
.expect("fresh initial target should pend active initial document page build");
let real_page_url = "data:text/html,<title>real-page</title>";
@@ -3163,7 +3165,7 @@ async fn devtools_create_target_can_activate_created_target() {
assert_eq!(
browser_context.active_target_id(),
Some("TID-2"),
- "activate=true should promote the created target instead of staging it"
+ "activate=true should activate the created target instead of staging it"
);
assert!(
browser_context
@@ -3176,7 +3178,7 @@ async fn devtools_create_target_can_activate_created_target() {
.background_targets()
.find(|target| target.target_id() == "TID-1")
.is_some_and(|target| target.has_loaded_page()),
- "the previous active page should move into the demoted target slot"
+ "the previous target should retain its loaded page after deactivation"
);
let (first_realms_before_second_navigation, _) = conn
@@ -3190,7 +3192,7 @@ async fn devtools_create_target_can_activate_created_target() {
.await
.into_parts();
first_realms_before_second_navigation
- .expect("demoted first target realms should remain readable before second navigation");
+ .expect("deactivated first target realms should remain readable before second navigation");
let (second_navigate, _, _, _) = conn
.execute_devtools_command(DevToolsCommand::Navigate(DevToolsNavigateCommand {
context: DevToolsCommandContext {
@@ -3216,7 +3218,7 @@ async fn devtools_create_target_can_activate_created_target() {
.await
.into_parts();
let DevToolsCommandResult::Realms(first_realms) =
- first_realms.expect("demoted first target realms should remain readable")
+ first_realms.expect("deactivated first target realms should remain readable")
else {
panic!("expected realms result");
};
@@ -3224,7 +3226,7 @@ async fn devtools_create_target_can_activate_created_target() {
first_realms.realms.iter().any(|realm| {
realm.frame_id.as_ref().map(|frame_id| frame_id.as_str()) == Some("TID-1")
}),
- "demoted target should keep its window realm"
+ "deactivated target should keep its window realm"
);
let (all_realms, _) = conn
@@ -3248,7 +3250,7 @@ async fn devtools_create_target_can_activate_created_target() {
&& realm.context_type.as_deref() == Some("default")
})
.and_then(|realm| realm.realm_id.as_ref())
- .expect("all-context getRealms should include the demoted target default realm");
+ .expect("all-context getRealms should include the deactivated target default realm");
let second_realm_id = all_realms
.realms
.iter()
@@ -7670,7 +7672,7 @@ async fn command_dispatch_completes_target_close_without_legacy_fallback() {
.expect("browser context should remain loaded")
.active_target_identity()
.is_none(),
- "closing the active target should leave the active slot empty"
+ "closing the selected target should leave the context without an active target"
);
}
diff --git a/moli-protocol/src/conn/inspector_route.rs b/moli-protocol/src/conn/inspector_route.rs
index 57bd22bee..38f16f281 100644
--- a/moli-protocol/src/conn/inspector_route.rs
+++ b/moli-protocol/src/conn/inspector_route.rs
@@ -275,14 +275,12 @@ mod tests {
));
assert!(
browser_context
- .assign_auxiliary_session_to_target("TID-active", "SID-active-aux".to_owned(),)
- );
- assert!(
- browser_context.assign_auxiliary_session_to_target(
- "TID-background",
- "SID-background-aux".to_owned(),
- )
+ .assign_attached_session_to_target("TID-active", "SID-active-attached".to_owned(),)
);
+ assert!(browser_context.assign_attached_session_to_target(
+ "TID-background",
+ "SID-background-attached".to_owned(),
+ ));
let mut conn = CdpConnection::default();
conn.browser_context = Some(browser_context);
@@ -290,9 +288,11 @@ mod tests {
&CommandOwnerScope::for_session("SID-active-primary"),
vec![
batch(DevToolsSessionKey::Primary),
- batch(DevToolsSessionKey::Attached("SID-active-aux".to_owned())),
batch(DevToolsSessionKey::Attached(
- "SID-background-aux".to_owned(),
+ "SID-active-attached".to_owned(),
+ )),
+ batch(DevToolsSessionKey::Attached(
+ "SID-background-attached".to_owned(),
)),
batch(DevToolsSessionKey::Attached("SID-unknown".to_owned())),
],
@@ -302,7 +302,7 @@ mod tests {
assert_eq!(filtered[0].session, DevToolsSessionKey::Primary);
assert_eq!(
filtered[1].session,
- DevToolsSessionKey::Attached("SID-active-aux".to_owned())
+ DevToolsSessionKey::Attached("SID-active-attached".to_owned())
);
}
@@ -320,8 +320,10 @@ mod tests {
browser_context.set_active_target_id("TID-state-route".to_owned());
browser_context.attach_active_session("SID-state-primary".to_owned());
assert!(
- browser_context
- .assign_auxiliary_session_to_target("TID-state-route", "SID-state-aux".to_owned(),)
+ browser_context.assign_attached_session_to_target(
+ "TID-state-route",
+ "SID-state-attached".to_owned(),
+ )
);
browser_context.set_loaded_page_async(page).await;
let current = browser_context
@@ -357,16 +359,18 @@ mod tests {
Some(accepted_state.clone())
);
- let auxiliary_state = V8InspectorSessionState::from_bytes(vec![7, 8]);
- let mut auxiliary = batch(DevToolsSessionKey::Attached("SID-state-aux".to_owned()));
- auxiliary.agent_token = current.agent_token();
- auxiliary.v8_state_update = Some(auxiliary_state.clone());
- auxiliary.bind_renderer_agent_attachment(current.id());
+ let attached_state = V8InspectorSessionState::from_bytes(vec![7, 8]);
+ let mut attached = batch(DevToolsSessionKey::Attached(
+ "SID-state-attached".to_owned(),
+ ));
+ attached.agent_token = current.agent_token();
+ attached.v8_state_update = Some(attached_state.clone());
+ attached.bind_renderer_agent_attachment(current.id());
assert_eq!(
ctx.conn
.route_current_renderer_inspector_output_for_owner(
&CommandOwnerScope::for_session("SID-state-primary"),
- vec![auxiliary],
+ vec![attached],
)
.len(),
1
@@ -378,12 +382,12 @@ mod tests {
.expect("browser context")
.active_page_target()
.devtools_sessions
- .attached("SID-state-aux")
- .expect("auxiliary session state")
+ .attached("SID-state-attached")
+ .expect("attached session state")
.inspector_session_state
.v8_state,
- Some(auxiliary_state),
- "auxiliary session cookies must remain isolated from the primary session"
+ Some(attached_state),
+ "attached session cookies must remain isolated from the primary session"
);
let rejected_state = V8InspectorSessionState::from_bytes(vec![9, 9, 9]);
diff --git a/moli-protocol/src/conn/page_state/page_targets.rs b/moli-protocol/src/conn/page_state/page_targets.rs
index 1a21bc2f4..197dd81db 100644
--- a/moli-protocol/src/conn/page_state/page_targets.rs
+++ b/moli-protocol/src/conn/page_state/page_targets.rs
@@ -1,6 +1,8 @@
//! Stable page-target registry behavior and foreground target selection.
-use super::super::state::{TargetPageAbsenceReason, TargetSessionStorageNamespace};
+use super::super::state::{
+ EffectiveTargetPolicy, TargetPageAbsenceReason, TargetSessionStorageNamespace,
+};
use super::super::{
BrowserContext, DedicatedWorkerTargetState, PageTargetHost, ServiceWorkerTargetState,
SharedWorkerTargetState, TargetIdentityState, TargetInitialEmptyDocumentCreator,
@@ -262,7 +264,7 @@ impl BrowserContext {
true
}
- pub(crate) fn assign_auxiliary_session_to_target(
+ pub(crate) fn assign_attached_session_to_target(
&mut self,
target_id: &str,
session_id: String,
@@ -274,14 +276,15 @@ impl BrowserContext {
true
}
- pub(crate) fn auxiliary_target_id_for_session(&self, session_id: &str) -> Option<&str> {
+ #[cfg(test)]
+ pub(crate) fn attached_target_id_for_session(&self, session_id: &str) -> Option<&str> {
self.page_targets
.iter()
.find(|target| target.devtools_sessions.attached(session_id).is_some())
.map(PageTargetHost::target_id)
}
- pub(crate) fn auxiliary_session_ids_for_target(&self, target_id: &str) -> Vec<String> {
+ pub(crate) fn attached_session_ids_for_target(&self, target_id: &str) -> Vec<String> {
let mut session_ids = self
.page_target(target_id)
.into_iter()
@@ -302,53 +305,86 @@ impl BrowserContext {
} else {
Vec::new()
};
- session_ids.extend(self.auxiliary_session_ids_for_target(target_id));
+ session_ids.extend(self.attached_session_ids_for_target(target_id));
session_ids.sort();
session_ids.dedup();
session_ids
}
- pub(crate) fn remove_auxiliary_session(&mut self, session_id: &str) -> Option<String> {
- let target_id = self.auxiliary_target_id_for_session(session_id)?.to_owned();
- if let Some(target) = self.page_target_mut(&target_id) {
- target
- .runtime_slot
- .remove_auxiliary_network_session(session_id);
- target.fetch_owner.remove_fetch_session(Some(session_id));
- target
- .runtime_slot
- .remove_network_session_observation_cursor(Some(session_id));
- let disposed = target.devtools_sessions.dispose(
- session_id,
- &moli_page_types::DevToolsSessionKey::Attached(session_id.to_owned()),
- );
- debug_assert!(
- disposed.is_some(),
- "attached session must remain registered until disposal"
- );
+ /// Commits removal of a Page session after all domain handlers have run.
+ ///
+ /// This deliberately has no renderer or domain side effects. Disposal
+ /// keeps the registry entry live while handlers resolve their exact Page,
+ /// then reaches this single irreversible step.
+ pub(crate) fn remove_page_session_binding(
+ &mut self,
+ target_id: &str,
+ session_id: &str,
+ session_key: &moli_page_types::DevToolsSessionKey,
+ ) -> bool {
+ self.page_target_mut(target_id)
+ .and_then(|target| target.devtools_sessions.dispose(session_id, session_key))
+ .is_some()
+ }
+
+ pub(crate) async fn clear_devtools_network_session_policy_async(
+ &mut self,
+ target_id: &str,
+ session_key: &moli_page_types::DevToolsSessionKey,
+ ) -> anyhow::Result<()> {
+ let Some(target) = self.page_target_mut(target_id) else {
+ return Ok(());
+ };
+ let previous = target.effective_policy();
+ let listener_session_id = session_key.wire_session_id().map(str::to_owned);
+ match session_key {
+ moli_page_types::DevToolsSessionKey::Primary => {
+ target.runtime_slot.disable_primary_network_events();
+ }
+ moli_page_types::DevToolsSessionKey::Attached(attached_session_id) => {
+ target
+ .runtime_slot
+ .remove_attached_network_session(attached_session_id);
+ }
}
- Some(target_id)
+ target
+ .runtime_slot
+ .remove_network_session_observation_cursor(listener_session_id.as_deref());
+ target
+ .runtime_slot
+ .remove_captured_response_body_visibility_for_session(listener_session_id.as_deref());
+ if !target.runtime_slot.has_network_event_listeners() {
+ target.runtime_slot.clear_captured_response_bodies();
+ target.runtime_slot.clear_websocket_request_ids();
+ }
+ target.clear_devtools_network_state(session_key);
+ self.apply_effective_devtools_policy_delta_async(target_id, previous)
+ .await?;
+ Ok(())
}
- pub(crate) async fn clear_target_session_overrides_async(
+ pub(crate) async fn clear_devtools_emulation_session_policy_async(
&mut self,
- session_id: &str,
+ target_id: &str,
+ session_key: &moli_page_types::DevToolsSessionKey,
) -> anyhow::Result<bool> {
- let Some((target_id, session_key)) = self.page_targets.iter().find_map(|target| {
- target
- .devtools_sessions
- .key_for_wire_session_id(session_id)
- .map(|session_key| (target.target_id().to_owned(), session_key))
- }) else {
+ let Some(target) = self.page_target_mut(target_id) else {
return Ok(false);
};
+ let previous = target.effective_policy();
+ target.clear_devtools_emulation_state(session_key);
+ self.apply_effective_devtools_policy_delta_async(target_id, previous)
+ .await
+ }
- let Some(target) = self.page_target_mut(&target_id) else {
+ async fn apply_effective_devtools_policy_delta_async(
+ &mut self,
+ target_id: &str,
+ previous: EffectiveTargetPolicy,
+ ) -> anyhow::Result<bool> {
+ let Some(target) = self.page_target(target_id) else {
return Ok(false);
};
- let previous = target.effective_policy();
- target.clear_devtools_network_state(&session_key);
- target.clear_devtools_emulation_state(&session_key);
let effective = target.effective_policy();
let delta = previous.delta(&effective);
let browser_identity_changed = delta.browser_identity_changed();
@@ -368,7 +404,7 @@ impl BrowserContext {
.map(str::to_owned)
.or_else(|| self.default_timezone_override.clone());
let page = self
- .page_target_mut(&target_id)
+ .page_target_mut(target_id)
.and_then(|target| target.runtime_slot.loaded_page_mut());
let Some(page) = page else {
return Ok(browser_identity_changed);
@@ -404,7 +440,7 @@ impl BrowserContext {
Ok(browser_identity_changed)
}
- pub(crate) async fn dispose_primary_page_session_async(
+ pub(crate) async fn reset_primary_page_session_target_state_async(
&mut self,
target_id: &str,
session_id: &str,
@@ -416,7 +452,7 @@ impl BrowserContext {
if !target.is_session(session_id) {
return Ok(false);
}
- target.clear_primary_session_scoped_state_fields();
+ target.reset_primary_session_target_state_fields();
let effective_headers = self.effective_extra_headers_for_target(target_id);
let target = self
@@ -436,67 +472,73 @@ impl BrowserContext {
} else {
self.generated_surface_override_script_for_background_target(target_id)
};
- let cleared_emulated_media = moli_core::page::EmulatedMediaOverrides::default();
-
if let Some(page) = self
.page_target_mut(target_id)
.and_then(|target| target.runtime_slot.loaded_page_mut())
{
- page.set_network_request_policy_async(
- &effective_headers,
- effective_policy.bypass_service_worker(),
- effective_policy.cache_disabled(),
- effective_policy.blocked_url_patterns(),
- )
- .await
- .map_err(|error| {
- anyhow::anyhow!("failed to clear page network request policy: {error}")
- })?;
- page.set_network_offline_async(false)
- .await
- .map_err(|error| anyhow::anyhow!("failed to clear page offline state: {error}"))?;
- page.set_script_execution_disabled_async(false)
+ let mut first_error = None;
+ if let Err(error) = page
+ .set_network_request_policy_async(
+ &effective_headers,
+ effective_policy.bypass_service_worker(),
+ effective_policy.cache_disabled(),
+ effective_policy.blocked_url_patterns(),
+ )
.await
- .map_err(|error| {
+ {
+ first_error = Some(anyhow::anyhow!(
+ "failed to clear page network request policy: {error}"
+ ));
+ }
+ if let Err(error) = page.set_network_offline_async(false).await {
+ first_error.get_or_insert_with(|| {
+ anyhow::anyhow!("failed to clear page offline state: {error}")
+ });
+ }
+ if let Err(error) = page.set_script_execution_disabled_async(false).await {
+ first_error.get_or_insert_with(|| {
anyhow::anyhow!("failed to clear page script execution disabled state: {error}")
- })?;
- page.set_cpu_throttling_rate_async(1.0)
- .await
- .map_err(|error| {
- anyhow::anyhow!("failed to clear page CPU throttling rate: {error}")
- })?;
- page.set_emulated_media_async(&cleared_emulated_media)
- .await
- .map_err(|error| anyhow::anyhow!("failed to clear page emulated media: {error}"))?;
- page.set_locale_override_async(effective_locale.as_deref())
+ });
+ }
+ if let Err(error) = page
+ .set_locale_override_async(effective_locale.as_deref())
.await
- .map_err(|error| anyhow::anyhow!("failed to restore page locale: {error}"))?;
- page.set_timezone_override_async(effective_timezone.as_deref())
+ {
+ first_error.get_or_insert_with(|| {
+ anyhow::anyhow!("failed to restore page locale: {error}")
+ });
+ }
+ if let Err(error) = page
+ .set_timezone_override_async(effective_timezone.as_deref())
.await
- .map_err(|error| anyhow::anyhow!("failed to restore page timezone: {error}"))?;
- if let Some(surface_script) = surface_script {
- page.run_page_surface_override_script_async(&surface_script.source)
+ {
+ first_error.get_or_insert_with(|| {
+ anyhow::anyhow!("failed to restore page timezone: {error}")
+ });
+ }
+ if let Some(surface_script) = surface_script
+ && let Err(error) = page
+ .run_page_surface_override_script_async(&surface_script.source)
.await
- .map_err(|error| {
- anyhow::anyhow!("failed to restore page surface overrides: {error}")
- })?;
+ {
+ first_error.get_or_insert_with(|| {
+ anyhow::anyhow!("failed to restore page surface overrides: {error}")
+ });
+ }
+ if let Some(error) = first_error {
+ return Err(error);
}
}
- let disposed = self
- .page_target_mut(target_id)
- .expect("disposing page target must remain registered")
- .devtools_sessions
- .dispose(session_id, &moli_page_types::DevToolsSessionKey::Primary);
- Ok(disposed.is_some())
+ Ok(true)
}
#[cfg(test)]
- pub(crate) fn enable_auxiliary_network_events(&mut self, session_id: &str) {
- if self.auxiliary_target_id_for_session(session_id).is_some() {
+ pub(crate) fn enable_attached_network_events(&mut self, session_id: &str) {
+ if self.attached_target_id_for_session(session_id).is_some() {
self.active_page_target_mut()
.runtime_slot
- .enable_auxiliary_network_events(session_id);
+ .enable_attached_network_events(session_id);
}
}
@@ -547,9 +589,10 @@ impl BrowserContext {
else {
return false;
};
- target.runtime_slot.disable_primary_network_events();
- target.detach_session();
- true
+ target
+ .devtools_sessions
+ .dispose(session_id, &moli_page_types::DevToolsSessionKey::Primary)
+ .is_some()
}
#[cfg(test)]
@@ -710,8 +753,8 @@ impl BrowserContext {
pub(crate) fn devtools_target_info(&self, target_id: &str) -> Option<DevToolsTargetInfo> {
if let Some(target) = self.page_target(target_id) {
- let attached = target.has_session()
- || !self.auxiliary_session_ids_for_target(target_id).is_empty();
+ let attached =
+ target.has_session() || !self.attached_session_ids_for_target(target_id).is_empty();
return Some(DevToolsTargetInfo {
target_id: Some(DevToolsTargetId::from(target_id)),
kind: DevToolsTargetKind::Page,
@@ -805,13 +848,6 @@ impl BrowserContext {
.find(|target| target.target_id == target_id)
}
- pub(crate) fn shared_worker_target_id_for_session(&self, session_id: &str) -> Option<&str> {
- self.shared_worker_targets
- .values()
- .find(|target| target.is_session(session_id))
- .map(|target| target.target_id.as_str())
- }
-
pub(crate) fn has_shared_worker_target(&self, target_id: &str) -> bool {
self.shared_worker_target(target_id).is_some()
}
@@ -889,13 +925,6 @@ impl BrowserContext {
.find(|target| target.target_id == target_id)
}
- pub(crate) fn dedicated_worker_target_id_for_session(&self, session_id: &str) -> Option<&str> {
- self.dedicated_worker_targets
- .values()
- .find(|target| target.is_session(session_id))
- .map(|target| target.target_id.as_str())
- }
-
pub(crate) fn has_dedicated_worker_target(&self, target_id: &str) -> bool {
self.dedicated_worker_target(target_id).is_some()
}
@@ -1010,13 +1039,6 @@ impl BrowserContext {
.find(|target| target.target_id == target_id)
}
- pub(crate) fn service_worker_target_id_for_session(&self, session_id: &str) -> Option<&str> {
- self.service_worker_targets
- .values()
- .find(|target| target.is_session(session_id))
- .map(|target| target.target_id.as_str())
- }
-
pub(crate) fn has_service_worker_target(&self, target_id: &str) -> bool {
self.service_worker_target(target_id).is_some()
}
@@ -1219,8 +1241,8 @@ mod tests {
use super::*;
use crate::conn::state::{PerformanceTimeDomain, TargetPerformanceSessionState};
use crate::conn::{
- DevToolsSessionState, DocumentStartScript, FetchInterceptionPattern, FetchRequestStage,
- TargetPageSessionState, TargetRuntimeSessionState,
+ DevToolsSessionState, DocumentStartScript, TargetPageSessionState,
+ TargetRuntimeSessionState,
};
use crate::testing::TestContext;
use serde_json::json;
@@ -1327,7 +1349,7 @@ mod tests {
#[test]
fn changing_foreground_selection_retains_each_session_storage_namespace() {
- let mut context = BrowserContext::new("BC-demoted-storage".to_owned());
+ let mut context = BrowserContext::new("BC-deactivated-storage".to_owned());
context.set_active_target_id("TID-first");
let first_session_storage = context.page_storage_handles().session_storage_store.clone();
assert!(
@@ -1446,59 +1468,18 @@ mod tests {
assert_eq!(host.owner_state.next_document_start_script_id, 7);
}
- #[test]
- fn remove_auxiliary_session_drops_session_local_fetch_config() {
- let mut context = BrowserContext::new("BC-1".to_owned());
- context.set_active_target_id("TID-active".to_owned());
- context.attach_active_session("SID-active".to_owned());
- assert!(
- context.assign_auxiliary_session_to_target("TID-active", "SID-aux".to_owned()),
- "auxiliary session should attach to active target"
- );
- context.active_page_target_mut().fetch_owner.configure(
- Some("SID-aux".to_owned()),
- false,
- vec![FetchInterceptionPattern {
- url_pattern: "*".to_owned(),
- resource_type_filter: None,
- request_stage: FetchRequestStage::Request,
- }],
- );
- assert!(
- context
- .active_page_target()
- .fetch_owner
- .config_snapshot()
- .is_enabled()
- );
-
- assert_eq!(
- context.remove_auxiliary_session("SID-aux").as_deref(),
- Some("TID-active")
- );
-
- assert!(
- !context
- .active_page_target()
- .fetch_owner
- .config_snapshot()
- .is_enabled(),
- "detaching the auxiliary target session must remove its Fetch.enable config"
- );
- }
-
#[tokio::test(flavor = "multi_thread")]
async fn selecting_another_foreground_target_preserves_page_session_and_owner_state() {
let mut ctx = TestContext::new();
let active_page = ctx
.conn
- .load_page_via_runtime_async("data:text/html,<title>demote-active</title>")
+ .load_page_via_runtime_async("data:text/html,<title>deactivate-active</title>")
.await
.expect("active page should load");
- let mut context = BrowserContext::new("BC-demote".to_owned());
- context.set_active_target_id("TID-demote".to_owned());
- context.attach_active_session("SID-demote".to_owned());
+ let mut context = BrowserContext::new("BC-deactivate".to_owned());
+ context.set_active_target_id("TID-deactivate".to_owned());
+ context.attach_active_session("SID-deactivate".to_owned());
context.set_target_url(active_page.final_url().as_str().to_owned());
context.active_page_target_mut().devtools_sessions
[moli_page_types::DevToolsSessionKey::Primary]
@@ -1548,11 +1529,11 @@ mod tests {
.owner_state
.document_start_scripts
.push((
- "script-demote".to_owned(),
+ "script-deactivate".to_owned(),
DocumentStartScript {
registry_key: None,
devtools_session: None,
- source: "globalThis.demoted = true".to_owned(),
+ source: "globalThis.deactivated = true".to_owned(),
world_name: None,
has_bidi_channel_argument: false,
bidi_channel_handoffs: Vec::new(),
@@ -1591,17 +1572,17 @@ mod tests {
assert_eq!(context.active_target_id(), Some("TID-selected"));
assert!(
context
- .page_target("TID-demote")
+ .page_target("TID-deactivate")
.is_some_and(|host| host.has_loaded_page()),
"changing foreground selection must retain the loaded page in its stable host"
);
assert_eq!(context.background_target_count(), 1);
let background_target = &context.background_target_at(0).unwrap();
- assert_eq!(background_target.target_id(), "TID-demote");
- assert_eq!(background_target.session_id(), Some("SID-demote"));
+ assert_eq!(background_target.target_id(), "TID-deactivate");
+ assert_eq!(background_target.session_id(), Some("SID-deactivate"));
assert_eq!(
background_target.target_url(),
- "data:text/html,<title>demote-active</title>"
+ "data:text/html,<title>deactivate-active</title>"
);
assert!(
background_target.has_loaded_page(),
@@ -1630,7 +1611,7 @@ mod tests {
);
assert!(
context
- .background_target("TID-demote")
+ .background_target("TID-deactivate")
.filter(|target| target.has_non_default_session_state())
.is_some_and(|state| state.devtools_sessions
[moli_page_types::DevToolsSessionKey::Primary]
@@ -1639,7 +1620,7 @@ mod tests {
"session-scoped Runtime.enable state must remain owned by the target"
);
let background_state = context
- .background_target("TID-demote")
+ .background_target("TID-deactivate")
.filter(|target| target.has_non_default_session_state())
.expect("background target should retain page session state");
assert!(
@@ -1701,7 +1682,7 @@ mod tests {
);
assert_eq!(
context
- .background_target("TID-demote")
+ .background_target("TID-deactivate")
.expect("previous target must remain registered")
.owner_state
.next_document_start_script_id,
@@ -1710,7 +1691,7 @@ mod tests {
);
assert_eq!(
context
- .background_target("TID-demote")
+ .background_target("TID-deactivate")
.expect("background target should retain owner state")
.owner_state
.document_start_scripts
@@ -1719,7 +1700,7 @@ mod tests {
"document-start scripts must remain target-owned"
);
let background_runtime = &context
- .background_target("TID-demote")
+ .background_target("TID-deactivate")
.expect("background target should retain network state")
.runtime_slot;
assert_eq!(background_runtime.next_fetch_request_id_for_test(), 77);
@@ -1736,7 +1717,7 @@ mod tests {
#[test]
fn staging_background_target_in_empty_context_leaves_foreground_empty() {
- let mut context = BrowserContext::new("BC-demote-empty".to_owned());
+ let mut context = BrowserContext::new("BC-deactivate-empty".to_owned());
context.stage_background_target(
"TID-existing-bg".to_owned(),
Some("SID-existing-bg".to_owned()),
@@ -1759,7 +1740,7 @@ mod tests {
#[test]
fn selecting_new_target_preserves_previous_pending_initial_document_reason() {
- let mut context = BrowserContext::new("BC-demote-pending".to_owned());
+ let mut context = BrowserContext::new("BC-deactivate-pending".to_owned());
context.set_active_target_id("TID-old-active");
context.set_target_url("about:blank#old".to_owned());
context.begin_active_target_initial_empty_document("about:blank#old".to_owned());
@@ -1791,8 +1772,8 @@ mod tests {
}
#[tokio::test]
- async fn background_target_promote_without_page_preserves_pending_initial_document_reason() {
- let mut context = BrowserContext::new("BC-promote-pending".to_owned());
+ async fn background_target_activate_without_page_preserves_pending_initial_document_reason() {
+ let mut context = BrowserContext::new("BC-activate-pending".to_owned());
context.stage_background_target(
"TID-pending-bg".to_owned(),
Some("SID-pending-bg".to_owned()),
@@ -1832,7 +1813,7 @@ mod tests {
.await
.expect("second loaded page should load");
- let mut context = BrowserContext::new("BC-promote-first".to_owned());
+ let mut context = BrowserContext::new("BC-activate-first".to_owned());
context.stage_background_target(
"TID-empty".to_owned(),
Some("SID-empty".to_owned()),
@@ -1908,7 +1889,7 @@ mod tests {
.and_then(|target| target.runtime_slot().current_renderer_attachment())
.map(|attachment| attachment.id()),
Some(second_attachment.id()),
- "promoting one target must not replace another background target's route lease"
+ "activating one target must not replace another background target's route lease"
);
}
@@ -1976,7 +1957,7 @@ mod tests {
#[tokio::test]
async fn background_target_selection_preserves_nested_page_session_state() {
- let mut context = BrowserContext::new("BC-promote".to_owned());
+ let mut context = BrowserContext::new("BC-activate".to_owned());
context.stage_background_target(
"TID-bg".to_owned(),
Some("SID-bg".to_owned()),
diff --git a/moli-protocol/src/conn/page_state/surfaces.rs b/moli-protocol/src/conn/page_state/surfaces.rs
index a5444b065..924adfca6 100644
--- a/moli-protocol/src/conn/page_state/surfaces.rs
+++ b/moli-protocol/src/conn/page_state/surfaces.rs
@@ -701,59 +701,79 @@ impl CdpConnection {
return Ok(());
}
+ let mut first_error = None;
for registry_key in registry_keys {
- let pending = self
- .runtime_session_owner_slot_mut(Some(session_id))
- .ok()
- .and_then(|slot| slot.loaded_page_mut())
- .ok_or_else(|| {
+ let result: anyhow::Result<()> = async {
+ let pending = self
+ .runtime_session_owner_slot_mut(Some(session_id))
+ .ok()
+ .and_then(|slot| slot.loaded_page_mut())
+ .ok_or_else(|| {
+ anyhow::anyhow!(
+ "page disappeared while removing detached-session document-start scripts"
+ )
+ })?
+ .start_remove_document_start_script_by_registry_key(&registry_key)
+ .map_err(|error| {
+ anyhow::anyhow!(
+ "failed to start detached-session document-start script cleanup: {error}"
+ )
+ })?;
+ let completion = pending.wait().await.map_err(|error| {
anyhow::anyhow!(
- "page disappeared while removing detached-session document-start scripts"
+ "detached-session document-start script cleanup was canceled: {error}"
)
- })?
- .start_remove_document_start_script_by_registry_key(&registry_key)
+ })?;
+ let page = self
+ .runtime_session_owner_slot_mut(Some(session_id))
+ .ok()
+ .and_then(|slot| slot.loaded_page_mut())
+ .ok_or_else(|| {
+ anyhow::anyhow!(
+ "page disappeared while finishing detached-session document-start script cleanup"
+ )
+ })?;
+ page.finish_unit_runtime_page_command(
+ completion,
+ "remove detached-session document-start script",
+ )
.map_err(|error| {
anyhow::anyhow!(
- "failed to start detached-session document-start script cleanup: {error}"
+ "failed to finish detached-session document-start script cleanup: {error}"
)
})?;
- let completion = pending.wait().await.map_err(|error| {
- anyhow::anyhow!(
- "detached-session document-start script cleanup was canceled: {error}"
+ self.with_target_owner_state_for_session_mut(
+ Some(session_id),
+ |owner_state| {
+ owner_state.remove_document_start_script_registry_key_for_session(
+ &devtools_session,
+ &registry_key,
+ )
+ },
)
- })?;
- let page = self
- .runtime_session_owner_slot_mut(Some(session_id))
- .ok()
- .and_then(|slot| slot.loaded_page_mut())
.ok_or_else(|| {
anyhow::anyhow!(
- "page disappeared while finishing detached-session document-start script cleanup"
+ "session owner disappeared during document-start script cleanup"
)
})?;
- page.finish_unit_runtime_page_command(
- completion,
- "remove detached-session document-start script",
- )
- .map_err(|error| {
- anyhow::anyhow!(
- "failed to finish detached-session document-start script cleanup: {error}"
- )
- })?;
- self.with_target_owner_state_for_session_mut(Some(session_id), |owner_state| {
- owner_state.remove_document_start_script_registry_key_for_session(
- &devtools_session,
- &registry_key,
- )
- })
- .ok_or_else(|| {
- anyhow::anyhow!("session owner disappeared during document-start script cleanup")
- })?;
+ Ok(())
+ }
+ .await;
+ if let Err(error) = result {
+ first_error.get_or_insert(error);
+ }
+ }
+
+ // Keep unresolved registry keys as cleanup authority. The centralized
+ // session disposer will either retry after the renderer disappears or
+ // keep the session binding alive; clearing them here would orphan a
+ // script that may still execute in a later Document.
+ if let Some(error) = first_error {
+ return Err(error);
}
// Scripts without a renderer registry key never require a renderer
- // round trip. Successful keyed removals have already been committed,
- // so a later retry cannot revisit a renderer object that is gone.
+ // round trip. Successful keyed removals have already been committed.
self.with_target_owner_state_for_session_mut(Some(session_id), |owner_state| {
owner_state.remove_document_start_scripts_for_session(&devtools_session)
})
diff --git a/moli-protocol/src/conn/popup_activation_work.rs b/moli-protocol/src/conn/popup_activation_work.rs
index dd6623a2f..2f148f0ed 100644
--- a/moli-protocol/src/conn/popup_activation_work.rs
+++ b/moli-protocol/src/conn/popup_activation_work.rs
@@ -1,6 +1,6 @@
use super::{CdpConnection, CdpSessionRoute, CommandOwnerScope};
-/// Foreground activation for one already-created auxiliary target.
+/// Foreground selection for one already-created popup Page target.
///
/// Target creation and navigation have separate lifetimes. In particular, a
/// target waiting for `Runtime.runIfWaitingForDebugger` must still become the
diff --git a/moli-protocol/src/conn/runtime_eval.rs b/moli-protocol/src/conn/runtime_eval.rs
index 2b8fb5990..e45b2e17f 100644
--- a/moli-protocol/src/conn/runtime_eval.rs
+++ b/moli-protocol/src/conn/runtime_eval.rs
@@ -326,9 +326,9 @@ pub struct PendingRuntimeProtocolMessageDispatch {
enum RuntimeProtocolResponseRoute {
// The receiver is consumed before renderer completion is projected. It is
// absent for fire-and-forget commands and for replay, where the original
- // dispatch still owns the command-reply waiter.
- CommandReply(Option<RuntimeInspectorResponseReceiver>),
- DevToolsSession,
+ // dispatch still owns the adapter-reply waiter.
+ AdapterReply(Option<RuntimeInspectorResponseReceiver>),
+ SessionSink,
}
impl RuntimeProtocolResponseRoute {
@@ -337,15 +337,15 @@ impl RuntimeProtocolResponseRoute {
receiver: Option<RuntimeInspectorResponseReceiver>,
) -> Self {
match delivery {
- RendererInspectorResponseDelivery::CommandReply => Self::CommandReply(Some(
- receiver.expect("a registered command-reply route must allocate its receiver"),
+ RendererInspectorResponseDelivery::AdapterReply => Self::AdapterReply(Some(
+ receiver.expect("a registered adapter-reply route must allocate its receiver"),
)),
- RendererInspectorResponseDelivery::DevToolsSession => {
+ RendererInspectorResponseDelivery::SessionSink => {
assert!(
receiver.is_none(),
- "a DevTools session response cannot retain a command-reply receiver"
+ "a session-sink response cannot retain an adapter-reply receiver"
);
- Self::DevToolsSession
+ Self::SessionSink
}
}
}
@@ -354,26 +354,26 @@ impl RuntimeProtocolResponseRoute {
delivery: RendererInspectorResponseDelivery,
) -> Self {
match delivery {
- RendererInspectorResponseDelivery::CommandReply => Self::CommandReply(None),
- RendererInspectorResponseDelivery::DevToolsSession => Self::DevToolsSession,
+ RendererInspectorResponseDelivery::AdapterReply => Self::AdapterReply(None),
+ RendererInspectorResponseDelivery::SessionSink => Self::SessionSink,
}
}
- const fn command_reply_without_receiver() -> Self {
- Self::CommandReply(None)
+ const fn adapter_reply_without_receiver() -> Self {
+ Self::AdapterReply(None)
}
const fn delivery(&self) -> RendererInspectorResponseDelivery {
match self {
- Self::CommandReply(_) => RendererInspectorResponseDelivery::CommandReply,
- Self::DevToolsSession => RendererInspectorResponseDelivery::DevToolsSession,
+ Self::AdapterReply(_) => RendererInspectorResponseDelivery::AdapterReply,
+ Self::SessionSink => RendererInspectorResponseDelivery::SessionSink,
}
}
- fn take_command_reply_receiver(&mut self) -> Option<RuntimeInspectorResponseReceiver> {
+ fn take_adapter_reply_receiver(&mut self) -> Option<RuntimeInspectorResponseReceiver> {
match self {
- Self::CommandReply(receiver) => receiver.take(),
- Self::DevToolsSession => None,
+ Self::AdapterReply(receiver) => receiver.take(),
+ Self::SessionSink => None,
}
}
}
@@ -449,7 +449,7 @@ struct CompletedWorkerRuntimeProtocolDispatch {
}
impl CompletedWorkerRuntimeProtocolDispatch {
- fn command_reply(messages: Vec<RendererRuntimeInspectorMessage>) -> Self {
+ fn adapter_reply(messages: Vec<RendererRuntimeInspectorMessage>) -> Self {
Self {
messages,
session_response_predecessor: None,
@@ -697,7 +697,7 @@ impl CompletedRuntimeProtocolMessageDispatch {
pub(crate) fn take_deferred_response_receiver(
&mut self,
) -> Option<RuntimeInspectorResponseReceiver> {
- self.response_route.take_command_reply_receiver()
+ self.response_route.take_adapter_reply_receiver()
}
pub(crate) const fn response_delivery(&self) -> RendererInspectorResponseDelivery {
@@ -713,7 +713,7 @@ impl CompletedSharedWorkerRuntimeProtocolMessageDispatch {
pub(crate) fn take_deferred_response_receiver(
&mut self,
) -> Option<RuntimeInspectorResponseReceiver> {
- self.response_route.take_command_reply_receiver()
+ self.response_route.take_adapter_reply_receiver()
}
pub(crate) const fn response_delivery(&self) -> RendererInspectorResponseDelivery {
@@ -737,7 +737,7 @@ impl CompletedServiceWorkerRuntimeProtocolMessageDispatch {
pub(crate) fn take_deferred_response_receiver(
&mut self,
) -> Option<RuntimeInspectorResponseReceiver> {
- self.response_route.take_command_reply_receiver()
+ self.response_route.take_adapter_reply_receiver()
}
pub(crate) const fn response_delivery(&self) -> RendererInspectorResponseDelivery {
@@ -3020,7 +3020,7 @@ impl CdpConnection {
}
let (browser_context_id, target_id) = self.target_owner_identity_for_session(session_id)?;
let devtools_session_id =
- self.target_devtools_auxiliary_session_id_for_session(session_id)?;
+ self.target_devtools_attached_session_id_for_session(session_id)?;
Some(RuntimeRemoteObjectOwnerIdentity::Page {
browser_context_id,
target_id,
@@ -3132,14 +3132,22 @@ impl CdpConnection {
false
}
- pub(crate) async fn release_shared_worker_runtime_remote_objects_for_session_best_effort_async(
+ pub(crate) async fn release_worker_runtime_remote_objects_for_session_best_effort_async(
&mut self,
session_id: &str,
) {
- let Some((object_groups, object_ids)) = self
- .shared_worker_target_for_session_mut(Some(session_id))
- .map(|target| target.take_runtime_remote_object_cleanup_plan(session_id))
- else {
+ let service_worker = matches!(
+ self.session_route(Some(session_id)),
+ Some(CdpSessionRoute::ServiceWorkerTarget { .. })
+ );
+ let cleanup_plan = if service_worker {
+ self.service_worker_target_for_session_mut(Some(session_id))
+ .map(|target| target.take_runtime_remote_object_cleanup_plan(session_id))
+ } else {
+ self.shared_worker_target_for_session_mut(Some(session_id))
+ .map(|target| target.take_runtime_remote_object_cleanup_plan(session_id))
+ };
+ let Some((object_groups, object_ids)) = cleanup_plan else {
return;
};
if object_groups.is_empty() && object_ids.is_empty() {
@@ -3154,18 +3162,26 @@ impl CdpConnection {
"params": { "objectGroup": object_group }
})
.to_string();
- if let Err(error) = self
- .dispatch_shared_worker_runtime_helper_protocol_message_for_session_async(
+ let release = if service_worker {
+ self.dispatch_service_worker_runtime_helper_protocol_message_for_session_async(
Some(session_id),
&raw_json,
command_id,
)
.await
- {
+ } else {
+ self.dispatch_shared_worker_runtime_helper_protocol_message_for_session_async(
+ Some(session_id),
+ &raw_json,
+ command_id,
+ )
+ .await
+ };
+ if let Err(error) = release {
tracing::warn!(
object_group = %object_group,
error = %error,
- "failed to release shared worker Runtime object group during target detach"
+ "failed to release worker Runtime object group during target detach"
);
}
command_id = command_id.saturating_add(1);
@@ -3177,18 +3193,26 @@ impl CdpConnection {
"params": { "objectId": object_id }
})
.to_string();
- if let Err(error) = self
- .dispatch_shared_worker_runtime_helper_protocol_message_for_session_async(
+ let release = if service_worker {
+ self.dispatch_service_worker_runtime_helper_protocol_message_for_session_async(
Some(session_id),
&raw_json,
command_id,
)
.await
- {
+ } else {
+ self.dispatch_shared_worker_runtime_helper_protocol_message_for_session_async(
+ Some(session_id),
+ &raw_json,
+ command_id,
+ )
+ .await
+ };
+ if let Err(error) = release {
tracing::warn!(
object_id = %object_id,
error = %error,
- "failed to release shared worker Runtime object during target detach"
+ "failed to release worker Runtime object during target detach"
);
}
command_id = command_id.saturating_add(1);
@@ -4485,7 +4509,7 @@ impl CdpConnection {
session_id,
raw_json,
None,
- RuntimeProtocolResponseRoute::command_reply_without_receiver(),
+ RuntimeProtocolResponseRoute::adapter_reply_without_receiver(),
)
}
@@ -4529,7 +4553,7 @@ impl CdpConnection {
(
WorkerRuntimeTarget::Shared(instance_id),
Some(response),
- RendererInspectorResponseDelivery::CommandReply,
+ RendererInspectorResponseDelivery::AdapterReply,
) => Box::pin(async move {
renderer_runtime
.dispatch_shared_worker_runtime_protocol_message_with_deferred_response(
@@ -4539,12 +4563,12 @@ impl CdpConnection {
response,
)
.await
- .map(CompletedWorkerRuntimeProtocolDispatch::command_reply)
+ .map(CompletedWorkerRuntimeProtocolDispatch::adapter_reply)
}),
(
WorkerRuntimeTarget::Shared(instance_id),
Some(response),
- RendererInspectorResponseDelivery::DevToolsSession,
+ RendererInspectorResponseDelivery::SessionSink,
) => {
let inspector_session_id =
inspector_session_id.ok_or_else(|| "UnknownSession".to_owned())?;
@@ -4563,7 +4587,7 @@ impl CdpConnection {
(
WorkerRuntimeTarget::Shared(instance_id),
None,
- RendererInspectorResponseDelivery::CommandReply,
+ RendererInspectorResponseDelivery::AdapterReply,
) => Box::pin(async move {
renderer_runtime
.dispatch_shared_worker_runtime_protocol_message(
@@ -4572,12 +4596,12 @@ impl CdpConnection {
raw_json,
)
.await
- .map(CompletedWorkerRuntimeProtocolDispatch::command_reply)
+ .map(CompletedWorkerRuntimeProtocolDispatch::adapter_reply)
}),
(
WorkerRuntimeTarget::Dedicated(instance_id),
Some(response),
- RendererInspectorResponseDelivery::CommandReply,
+ RendererInspectorResponseDelivery::AdapterReply,
) => Box::pin(async move {
renderer_runtime
.dispatch_dedicated_worker_runtime_protocol_message_with_deferred_response(
@@ -4587,12 +4611,12 @@ impl CdpConnection {
response,
)
.await
- .map(CompletedWorkerRuntimeProtocolDispatch::command_reply)
+ .map(CompletedWorkerRuntimeProtocolDispatch::adapter_reply)
}),
(
WorkerRuntimeTarget::Dedicated(instance_id),
Some(response),
- RendererInspectorResponseDelivery::DevToolsSession,
+ RendererInspectorResponseDelivery::SessionSink,
) => {
let inspector_session_id =
inspector_session_id.ok_or_else(|| "UnknownSession".to_owned())?;
@@ -4611,7 +4635,7 @@ impl CdpConnection {
(
WorkerRuntimeTarget::Dedicated(instance_id),
None,
- RendererInspectorResponseDelivery::CommandReply,
+ RendererInspectorResponseDelivery::AdapterReply,
) => Box::pin(async move {
renderer_runtime
.dispatch_dedicated_worker_runtime_protocol_message(
@@ -4620,10 +4644,10 @@ impl CdpConnection {
raw_json,
)
.await
- .map(CompletedWorkerRuntimeProtocolDispatch::command_reply)
+ .map(CompletedWorkerRuntimeProtocolDispatch::adapter_reply)
}),
- (_, None, RendererInspectorResponseDelivery::DevToolsSession) => {
- return Err("DevToolsSessionResponseSenderMissing".to_owned());
+ (_, None, RendererInspectorResponseDelivery::SessionSink) => {
+ return Err("SessionResponseSenderMissing".to_owned());
}
};
Ok(PendingSharedWorkerRuntimeProtocolMessageDispatch {
@@ -4638,16 +4662,51 @@ impl CdpConnection {
session_id: Option<&str>,
raw_json: &str,
command_id: u64,
- ) -> Result<Vec<RendererRuntimeInspectorMessage>, String> {
- let descriptor = RendererCommandDescriptor::from_synthesized_payload(raw_json.to_owned())?;
+ ) -> anyhow::Result<Vec<RendererRuntimeInspectorMessage>> {
+ let descriptor = RendererCommandDescriptor::from_synthesized_payload(raw_json.to_owned())
+ .map_err(anyhow::Error::msg)?;
let pending = self
.start_shared_worker_runtime_protocol_message_for_session_with_deferred_response(
session_id, descriptor, command_id,
- )?;
- let mut completed = pending.wait().await?;
+ )
+ .map_err(anyhow::Error::msg)?;
+ let mut completed = pending.wait().await.map_err(anyhow::Error::msg)?;
+ let response_rx = completed.take_deferred_response_receiver();
+ let mut messages = self
+ .complete_shared_worker_runtime_protocol_message_for_session(completed)
+ .map_err(anyhow::Error::msg)?;
+ if let Some(response_rx) = response_rx
+ && let Some(message) = self
+ .await_registered_runtime_inspector_response_for_session_owner_async(
+ session_id,
+ command_id,
+ response_rx,
+ )
+ .await
+ {
+ messages.push(message);
+ }
+ Ok(messages)
+ }
+
+ async fn dispatch_service_worker_runtime_helper_protocol_message_for_session_async(
+ &mut self,
+ session_id: Option<&str>,
+ raw_json: &str,
+ command_id: u64,
+ ) -> anyhow::Result<Vec<RendererRuntimeInspectorMessage>> {
+ let descriptor = RendererCommandDescriptor::from_synthesized_payload(raw_json.to_owned())
+ .map_err(anyhow::Error::msg)?;
+ let pending = self
+ .start_service_worker_runtime_protocol_message_for_session_with_deferred_response(
+ session_id, descriptor, command_id,
+ )
+ .map_err(anyhow::Error::msg)?;
+ let mut completed = pending.wait().await.map_err(anyhow::Error::msg)?;
let response_rx = completed.take_deferred_response_receiver();
- let mut messages =
- self.complete_shared_worker_runtime_protocol_message_for_session(completed)?;
+ let mut messages = self
+ .complete_service_worker_runtime_protocol_message_for_session(completed)
+ .map_err(anyhow::Error::msg)?;
if let Some(response_rx) = response_rx
&& let Some(message) = self
.await_registered_runtime_inspector_response_for_session_owner_async(
@@ -4685,7 +4744,7 @@ impl CdpConnection {
session_id,
raw_json,
None,
- RuntimeProtocolResponseRoute::command_reply_without_receiver(),
+ RuntimeProtocolResponseRoute::adapter_reply_without_receiver(),
)
}
@@ -4723,7 +4782,7 @@ impl CdpConnection {
let response_delivery = response_route.delivery();
let pending: ServiceWorkerRuntimeProtocolDispatchFuture = Box::pin(async move {
match (response_sender, response_delivery) {
- (Some(response), RendererInspectorResponseDelivery::CommandReply) => {
+ (Some(response), RendererInspectorResponseDelivery::AdapterReply) => {
renderer_runtime
.dispatch_service_worker_runtime_protocol_message_with_deferred_response(
version_id,
@@ -4732,9 +4791,9 @@ impl CdpConnection {
response,
)
.await
- .map(CompletedWorkerRuntimeProtocolDispatch::command_reply)
+ .map(CompletedWorkerRuntimeProtocolDispatch::adapter_reply)
}
- (Some(response), RendererInspectorResponseDelivery::DevToolsSession) => {
+ (Some(response), RendererInspectorResponseDelivery::SessionSink) => {
let inspector_session_id =
inspector_session_id.ok_or_else(|| "UnknownSession".to_owned())?;
renderer_runtime
@@ -4747,16 +4806,16 @@ impl CdpConnection {
.await
.map(CompletedWorkerRuntimeProtocolDispatch::devtools_session)
}
- (None, RendererInspectorResponseDelivery::CommandReply) => renderer_runtime
+ (None, RendererInspectorResponseDelivery::AdapterReply) => renderer_runtime
.dispatch_service_worker_runtime_protocol_message(
version_id,
inspector_session_id,
raw_json,
)
.await
- .map(CompletedWorkerRuntimeProtocolDispatch::command_reply),
- (None, RendererInspectorResponseDelivery::DevToolsSession) => {
- Err("DevToolsSessionResponseSenderMissing".to_owned())
+ .map(CompletedWorkerRuntimeProtocolDispatch::adapter_reply),
+ (None, RendererInspectorResponseDelivery::SessionSink) => {
+ Err("SessionResponseSenderMissing".to_owned())
}
}
});
@@ -5079,7 +5138,7 @@ impl CdpConnection {
owner: owner.clone(),
route,
pending,
- response_route: RuntimeProtocolResponseRoute::command_reply_without_receiver(),
+ response_route: RuntimeProtocolResponseRoute::adapter_reply_without_receiver(),
})
}
@@ -5188,7 +5247,7 @@ impl CdpConnection {
owner: owner.clone(),
route,
pending: PendingRuntimeProtocolMessageDispatchKind::Page(pending),
- response_route: RuntimeProtocolResponseRoute::command_reply_without_receiver(),
+ response_route: RuntimeProtocolResponseRoute::adapter_reply_without_receiver(),
})
}
@@ -5352,7 +5411,7 @@ impl CdpConnection {
RendererCommandReplay::PerformanceGetMetrics => {
debug_assert_eq!(
response_delivery,
- RendererInspectorResponseDelivery::DevToolsSession
+ RendererInspectorResponseDelivery::SessionSink
);
let pending = self
.runtime_session_owner_page_mut(frontend_session_id.as_deref())
@@ -5395,7 +5454,7 @@ impl CdpConnection {
RendererCommandReplay::SetScriptExecutionDisabled { disabled } => {
debug_assert_eq!(
response_delivery,
- RendererInspectorResponseDelivery::DevToolsSession
+ RendererInspectorResponseDelivery::SessionSink
);
let pending = self
.runtime_session_owner_page_mut(frontend_session_id.as_deref())
@@ -5472,7 +5531,7 @@ impl CdpConnection {
};
let dispatch_sender = response_sender.clone();
match response_delivery {
- RendererInspectorResponseDelivery::CommandReply => match dispatch {
+ RendererInspectorResponseDelivery::AdapterReply => match dispatch {
CdpRendererCommandReplayDispatch::ResolveRuntimeContext => page
.start_runtime_protocol_message_for_inspector_session_with_context_resolution_and_deferred_response(
renderer_inspector_session_id,
@@ -5489,7 +5548,7 @@ impl CdpConnection {
)
.map(PendingRuntimeProtocolMessageDispatchKind::Page),
},
- RendererInspectorResponseDelivery::DevToolsSession => {
+ RendererInspectorResponseDelivery::SessionSink => {
debug_assert_eq!(
dispatch,
CdpRendererCommandReplayDispatch::Direct,
@@ -5618,7 +5677,7 @@ impl CdpConnection {
correlation: RendererCommandCorrelation,
message: &str,
) {
- if response_delivery == RendererInspectorResponseDelivery::CommandReply {
+ if response_delivery == RendererInspectorResponseDelivery::AdapterReply {
send_renderer_replacement_error(response_sender, correlation, message);
return;
}
@@ -5673,11 +5732,11 @@ impl CdpConnection {
for termination in terminations {
let (frontend_session_id, termination) = termination.into_parts();
match termination {
- PreparedRendererCallTermination::CommandReply {
+ PreparedRendererCallTermination::AdapterReply {
correlation,
response_sender,
} => send_renderer_replacement_error(&response_sender, correlation, reason),
- PreparedRendererCallTermination::DevToolsSession { correlation } => self
+ PreparedRendererCallTermination::SessionSink { correlation } => self
.settle_devtools_session_renderer_error(
&mut events,
frontend_session_id.as_deref(),
@@ -6407,15 +6466,6 @@ impl CdpConnection {
})
}
- pub(crate) async fn apply_runtime_binding_state_for_session_owner_async(
- &mut self,
- session_id: Option<&str>,
- ) -> Result<(), String> {
- let owner = CommandOwnerScope::capture(self, session_id);
- self.apply_runtime_binding_state_for_owner_async(&owner)
- .await
- }
-
pub(crate) async fn apply_runtime_binding_state_for_owner_async(
&mut self,
owner: &CommandOwnerScope,
@@ -6620,74 +6670,74 @@ mod tests {
use moli_core::page::{MAX_INSPECTOR_PROTOCOL_VALUE_DEPTH, is_renderer_backend_node_id};
#[test]
- fn registered_command_reply_route_owns_exactly_one_receiver() {
+ fn registered_adapter_reply_route_owns_exactly_one_receiver() {
let (_response_tx, response_rx) = tokio::sync::oneshot::channel();
let mut route = RuntimeProtocolResponseRoute::for_registered_delivery(
- RendererInspectorResponseDelivery::CommandReply,
+ RendererInspectorResponseDelivery::AdapterReply,
Some(response_rx),
);
assert_eq!(
route.delivery(),
- RendererInspectorResponseDelivery::CommandReply
+ RendererInspectorResponseDelivery::AdapterReply
);
- assert!(route.take_command_reply_receiver().is_some());
- assert!(route.take_command_reply_receiver().is_none());
+ assert!(route.take_adapter_reply_receiver().is_some());
+ assert!(route.take_adapter_reply_receiver().is_none());
}
#[test]
- #[should_panic(expected = "registered command-reply route must allocate its receiver")]
- fn registered_command_reply_route_rejects_a_missing_receiver() {
+ #[should_panic(expected = "registered adapter-reply route must allocate its receiver")]
+ fn registered_adapter_reply_route_rejects_a_missing_receiver() {
let _ = RuntimeProtocolResponseRoute::for_registered_delivery(
- RendererInspectorResponseDelivery::CommandReply,
+ RendererInspectorResponseDelivery::AdapterReply,
None,
);
}
#[test]
- fn registered_devtools_session_route_has_no_command_reply_receiver() {
+ fn registered_devtools_session_route_has_no_adapter_reply_receiver() {
let mut route = RuntimeProtocolResponseRoute::for_registered_delivery(
- RendererInspectorResponseDelivery::DevToolsSession,
+ RendererInspectorResponseDelivery::SessionSink,
None,
);
assert_eq!(
route.delivery(),
- RendererInspectorResponseDelivery::DevToolsSession
+ RendererInspectorResponseDelivery::SessionSink
);
- assert!(route.take_command_reply_receiver().is_none());
+ assert!(route.take_adapter_reply_receiver().is_none());
}
#[test]
- #[should_panic(expected = "DevTools session response cannot retain a command-reply receiver")]
- fn devtools_session_route_rejects_command_reply_receiver() {
+ #[should_panic(expected = "session-sink response cannot retain an adapter-reply receiver")]
+ fn devtools_session_route_rejects_adapter_reply_receiver() {
let (_response_tx, response_rx) = tokio::sync::oneshot::channel();
let _ = RuntimeProtocolResponseRoute::for_registered_delivery(
- RendererInspectorResponseDelivery::DevToolsSession,
+ RendererInspectorResponseDelivery::SessionSink,
Some(response_rx),
);
}
#[test]
fn replay_response_routes_never_claim_a_second_local_receiver() {
- let mut command_reply = RuntimeProtocolResponseRoute::without_local_receiver_for_delivery(
- RendererInspectorResponseDelivery::CommandReply,
+ let mut adapter_reply = RuntimeProtocolResponseRoute::without_local_receiver_for_delivery(
+ RendererInspectorResponseDelivery::AdapterReply,
);
let mut devtools_session =
RuntimeProtocolResponseRoute::without_local_receiver_for_delivery(
- RendererInspectorResponseDelivery::DevToolsSession,
+ RendererInspectorResponseDelivery::SessionSink,
);
assert_eq!(
- command_reply.delivery(),
- RendererInspectorResponseDelivery::CommandReply
+ adapter_reply.delivery(),
+ RendererInspectorResponseDelivery::AdapterReply
);
assert_eq!(
devtools_session.delivery(),
- RendererInspectorResponseDelivery::DevToolsSession
+ RendererInspectorResponseDelivery::SessionSink
);
- assert!(command_reply.take_command_reply_receiver().is_none());
- assert!(devtools_session.take_command_reply_receiver().is_none());
+ assert!(adapter_reply.take_adapter_reply_receiver().is_none());
+ assert!(devtools_session.take_adapter_reply_receiver().is_none());
}
#[test]
@@ -6794,7 +6844,7 @@ mod tests {
browser_context.attach_active_session("SID-active".to_owned());
assert!(
browser_context
- .assign_auxiliary_session_to_target("TID-active", "SID-auxiliary".to_owned(),)
+ .assign_attached_session_to_target("TID-active", "SID-attached".to_owned(),)
);
conn.browser_context = Some(browser_context);
@@ -6803,8 +6853,8 @@ mod tests {
vec!["same-wire-id".to_owned()],
);
conn.register_runtime_remote_object_ids_for_session_owner(
- Some("SID-auxiliary"),
- vec!["same-wire-id".to_owned(), "auxiliary-only".to_owned()],
+ Some("SID-attached"),
+ vec!["same-wire-id".to_owned(), "attached-only".to_owned()],
);
assert!(
@@ -6817,16 +6867,16 @@ mod tests {
);
assert!(
conn.validate_runtime_remote_object_ids_for_session_owner(
- Some("SID-auxiliary"),
+ Some("SID-attached"),
&["same-wire-id".to_owned()],
)
.is_ok(),
- "the same V8 wire id can independently belong to the auxiliary session"
+ "the same V8 wire id can independently belong to the attached session"
);
assert_eq!(
conn.validate_runtime_remote_object_ids_for_session_owner(
Some("SID-active"),
- &["auxiliary-only".to_owned()],
+ &["attached-only".to_owned()],
),
Err("Cannot find object with given id".to_owned()),
"an id known only to another session must remain inaccessible"
@@ -6893,7 +6943,7 @@ mod tests {
RendererCommandDescriptor::from_frontend_policy(
frontend.json().to_owned(),
frontend.renderer_policy(),
- RendererInspectorResponseDelivery::DevToolsSession,
+ RendererInspectorResponseDelivery::SessionSink,
)
}
@@ -6914,14 +6964,14 @@ mod tests {
RendererCommandDescriptor::from_frontend_policy(
frontend.json().to_owned(),
frontend.renderer_policy(),
- RendererInspectorResponseDelivery::DevToolsSession,
+ RendererInspectorResponseDelivery::SessionSink,
),
)
.expect("frontend response correlation should register");
let (correlation, response_sender, response_receiver) = prepared.into_parts();
assert!(
response_receiver.is_none(),
- "DevToolsSession delivery must not allocate a command-reply receiver"
+ "SessionSink delivery must not allocate an adapter-reply receiver"
);
drop(response_sender);
correlation
@@ -7017,9 +7067,9 @@ mod tests {
let mut browser_context = BrowserContext::new("BID-navigation-sessions".to_owned());
browser_context.set_active_target_id("TID-navigation-sessions".to_owned());
browser_context.attach_active_session("SID-navigation-primary".to_owned());
- assert!(browser_context.assign_auxiliary_session_to_target(
+ assert!(browser_context.assign_attached_session_to_target(
"TID-navigation-sessions",
- "SID-navigation-auxiliary".to_owned(),
+ "SID-navigation-attached".to_owned(),
));
conn.browser_context = Some(browser_context);
@@ -7033,18 +7083,18 @@ mod tests {
devtools_session_renderer_command_descriptor_for_test(71),
)
.expect("primary frontend response correlation should register");
- let auxiliary = conn
+ let attached = conn
.try_register_renderer_call_for_session_owner(
- Some("SID-navigation-auxiliary"),
+ Some("SID-navigation-attached"),
71,
Some(old_attachment),
devtools_session_renderer_command_descriptor_for_test(71),
)
- .expect("auxiliary frontend response correlation should register");
+ .expect("attached frontend response correlation should register");
let (primary_correlation, primary_sender, primary_receiver) = primary.into_parts();
- let (auxiliary_correlation, auxiliary_sender, auxiliary_receiver) = auxiliary.into_parts();
+ let (attached_correlation, attached_sender, attached_receiver) = attached.into_parts();
assert!(primary_receiver.is_none());
- assert!(auxiliary_receiver.is_none());
+ assert!(attached_receiver.is_none());
let replacements = {
let browser_context = conn
@@ -7066,7 +7116,7 @@ mod tests {
assert!(replays.is_empty());
for (correlation, sender) in [
(primary_correlation, primary_sender),
- (auxiliary_correlation, auxiliary_sender),
+ (attached_correlation, attached_sender),
] {
assert!(
sender
@@ -7083,11 +7133,8 @@ mod tests {
Some(primary_correlation)
);
assert_eq!(
- conn.renderer_call_for_frontend_for_session_owner(
- Some("SID-navigation-auxiliary"),
- 71,
- ),
- Some(auxiliary_correlation)
+ conn.renderer_call_for_frontend_for_session_owner(Some("SID-navigation-attached"), 71,),
+ Some(attached_correlation)
);
let termination_events = conn.terminate_prepared_renderer_calls_after_navigation(
@@ -7113,7 +7160,7 @@ mod tests {
session_ids,
std::collections::BTreeSet::from([
"SID-navigation-primary".to_owned(),
- "SID-navigation-auxiliary".to_owned(),
+ "SID-navigation-attached".to_owned(),
])
);
assert!(
@@ -7121,7 +7168,7 @@ mod tests {
.is_none()
);
assert!(
- conn.renderer_runtime_command_cause_for_frontend(Some("SID-navigation-auxiliary"), 71,)
+ conn.renderer_runtime_command_cause_for_frontend(Some("SID-navigation-attached"), 71,)
.is_none()
);
}
@@ -7367,14 +7414,14 @@ mod tests {
RendererCommandDescriptor::from_frontend_policy(
frontend.json().to_owned(),
frontend.renderer_policy(),
- RendererInspectorResponseDelivery::DevToolsSession,
+ RendererInspectorResponseDelivery::SessionSink,
),
)
.expect("frontend response correlation should register");
let (correlation, response_sender, response_receiver) = prepared.into_parts();
assert!(
response_receiver.is_none(),
- "DevToolsSession delivery must not allocate a legacy command-reply receiver"
+ "SessionSink delivery must not allocate an adapter-reply receiver"
);
drop(response_sender);
let mut messages = vec![
@@ -7456,7 +7503,7 @@ mod tests {
RendererCommandDescriptor::from_frontend_policy(
get_properties.json().to_owned(),
get_properties.renderer_policy(),
- RendererInspectorResponseDelivery::DevToolsSession,
+ RendererInspectorResponseDelivery::SessionSink,
),
)
.expect("getProperties response correlation should register");
@@ -7921,7 +7968,7 @@ mod tests {
.is_some_and(|state| state.devtools_sessions
[moli_page_types::DevToolsSessionKey::Primary]
.has_pending_inspector_awaits()),
- "parked DevTools session should physically store its pending await"
+ "background DevTools session should physically store its pending await"
);
}
@@ -8209,7 +8256,7 @@ mod tests {
.expect("non-await command should register");
let (correlation, old_sender, response_receiver) = prepared.into_parts();
let response_receiver = response_receiver
- .expect("a synthesized CommandReply call must allocate a response receiver");
+ .expect("a synthesized AdapterReply call must allocate a response receiver");
let mut direct_events = Vec::new();
let mut claimed_events = Vec::new();
diff --git a/moli-protocol/src/conn/runtime_load.rs b/moli-protocol/src/conn/runtime_load.rs
index aac7569ab..5750a7b96 100644
--- a/moli-protocol/src/conn/runtime_load.rs
+++ b/moli-protocol/src/conn/runtime_load.rs
@@ -1765,14 +1765,6 @@ impl CdpConnection {
}))
}
- pub(crate) fn start_initial_document_page_ensure_for_session_owner(
- &mut self,
- session_id: Option<&str>,
- ) -> Result<Option<PendingInitialDocumentPageBuild>, String> {
- let owner = CommandOwnerScope::capture(self, session_id);
- self.start_initial_document_page_ensure_for_owner(&owner)
- }
-
pub(crate) fn start_initial_document_page_ensure_for_owner(
&mut self,
owner: &CommandOwnerScope,
diff --git a/moli-protocol/src/conn/state/browser_context.rs b/moli-protocol/src/conn/state/browser_context.rs
index 6e2226c5e..e554607dc 100644
--- a/moli-protocol/src/conn/state/browser_context.rs
+++ b/moli-protocol/src/conn/state/browser_context.rs
@@ -826,7 +826,7 @@ impl BrowserContext {
let runtime_session_diagnostics = active_target
.map(|target| {
let primary = target.devtools_sessions.primary();
- let auxiliary_pending_inspector_await_count: usize = target
+ let attached_pending_inspector_await_count: usize = target
.devtools_sessions
.attached_states()
.map(DevToolsSessionState::pending_inspector_await_count)
@@ -837,10 +837,10 @@ impl BrowserContext {
"inspectorTargetCrashedDelivered": primary.runtime_session_state.inspector_target_crashed_delivered(),
"profilerCommandStateSource": "renderer-v8-inspector-agent",
"v8InspectorStateBytes": primary.inspector_session_state.v8_state.as_ref().map_or(0, |state| state.len()),
- "auxiliaryDevToolsSessionStateCount": target.devtools_sessions.attached_len(),
+ "attachedDevToolsSessionStateCount": target.devtools_sessions.attached_len(),
"pendingInspectorAwaitCount": target.devtools_sessions.pending_inspector_await_count(),
"primaryPendingInspectorAwaitCount": primary.pending_inspector_await_count(),
- "auxiliaryPendingInspectorAwaitCount": auxiliary_pending_inspector_await_count,
+ "attachedPendingInspectorAwaitCount": attached_pending_inspector_await_count,
})
})
.unwrap_or(Value::Null);
@@ -907,7 +907,7 @@ impl BrowserContext {
.iter()
.filter(|info| info.attached)
.count(),
- "auxiliaryTargetSessionCount": self
+ "attachedTargetSessionCount": self
.page_targets
.iter()
.map(|target| target.devtools_sessions.attached_len())
diff --git a/moli-protocol/src/conn/state/devtools_session.rs b/moli-protocol/src/conn/state/devtools_session.rs
index 66539c765..adbd8b622 100644
--- a/moli-protocol/src/conn/state/devtools_session.rs
+++ b/moli-protocol/src/conn/state/devtools_session.rs
@@ -95,6 +95,7 @@ impl DevToolsSessionRegistry {
self.primary_session_id = Some(session_id);
}
+ #[cfg(test)]
pub(crate) fn detach_primary(&mut self) -> Option<String> {
self.primary_session_id.take()
}
diff --git a/moli-protocol/src/conn/state/page_target_host.rs b/moli-protocol/src/conn/state/page_target_host.rs
index 76f03b3ba..d408a5a02 100644
--- a/moli-protocol/src/conn/state/page_target_host.rs
+++ b/moli-protocol/src/conn/state/page_target_host.rs
@@ -162,6 +162,7 @@ impl PageTargetHost {
self.devtools_sessions.attach_primary(session_id);
}
+ #[cfg(test)]
pub(crate) fn detach_session(&mut self) -> Option<String> {
self.devtools_sessions.detach_primary()
}
diff --git a/moli-protocol/src/conn/state/pending_renderer_command.rs b/moli-protocol/src/conn/state/pending_renderer_command.rs
index 634debbc0..b744879c6 100644
--- a/moli-protocol/src/conn/state/pending_renderer_command.rs
+++ b/moli-protocol/src/conn/state/pending_renderer_command.rs
@@ -92,7 +92,7 @@ impl RendererCommandDescriptor {
// Internal Classic/BiDi adapters own their reply channel. A
// method being eligible for frontend session output must never
// redirect a synthesized adapter command implicitly.
- response_delivery: RendererInspectorResponseDelivery::CommandReply,
+ response_delivery: RendererInspectorResponseDelivery::AdapterReply,
frontend_payload,
})
}
@@ -239,14 +239,14 @@ pub(crate) struct PreparedRendererCallReplay {
pub(crate) enum PreparedRendererCallTermination {
/// Internal adapters await a private receiver, so navigation rotates the
/// lease to a synthetic terminal completion owned by the replacement.
- CommandReply {
+ AdapterReply {
correlation: RendererCommandCorrelation,
response_sender: RendererRuntimeInspectorResponseSender,
},
/// Frontend calls remain owned by their protocol session. Navigation only
/// revokes the retired renderer lease; the session consumes this original
/// correlation when it emits the terminal response directly.
- DevToolsSession {
+ SessionSink {
correlation: RendererCommandCorrelation,
},
}
@@ -255,7 +255,7 @@ impl PreparedRendererCallTermination {
#[cfg(test)]
pub(crate) const fn correlation(&self) -> RendererCommandCorrelation {
match self {
- Self::CommandReply { correlation, .. } | Self::DevToolsSession { correlation } => {
+ Self::AdapterReply { correlation, .. } | Self::SessionSink { correlation } => {
*correlation
}
}
@@ -481,7 +481,7 @@ impl<T> PendingRendererCommandRegistry<T> {
.descriptor
.response_delivery();
match response_delivery {
- RendererInspectorResponseDelivery::DevToolsSession => {
+ RendererInspectorResponseDelivery::SessionSink => {
let call = self
.renderer_calls_by_frontend
.get(&frontend_command_id)
@@ -489,7 +489,7 @@ impl<T> PendingRendererCommandRegistry<T> {
if !call.response_channel.try_revoke_active_lease() {
continue;
}
- terminations.push(PreparedRendererCallTermination::DevToolsSession {
+ terminations.push(PreparedRendererCallTermination::SessionSink {
correlation: RendererCommandCorrelation {
frontend_command_id,
renderer_call_id: call.renderer_call_id,
@@ -498,7 +498,7 @@ impl<T> PendingRendererCommandRegistry<T> {
});
continue;
}
- RendererInspectorResponseDelivery::CommandReply => {}
+ RendererInspectorResponseDelivery::AdapterReply => {}
}
let renderer_call_id = self.allocate_renderer_call_id()?;
@@ -529,7 +529,7 @@ impl<T> PendingRendererCommandRegistry<T> {
call.renderer_call_id = renderer_call_id;
call.dispatched_attachment_id = Some(terminal_attachment_id);
- terminations.push(PreparedRendererCallTermination::CommandReply {
+ terminations.push(PreparedRendererCallTermination::AdapterReply {
correlation: RendererCommandCorrelation {
frontend_command_id,
renderer_call_id,
@@ -756,20 +756,20 @@ mod tests {
fn same_frontend_id_is_independent_across_session_owned_registries() {
let id = FrontendCommandId::new(9);
let mut primary = PendingRendererCommandRegistry::default();
- let mut auxiliary = PendingRendererCommandRegistry::default();
+ let mut attached = PendingRendererCommandRegistry::default();
primary.try_insert(id, "primary").unwrap();
- auxiliary.try_insert(id, "auxiliary").unwrap();
+ attached.try_insert(id, "attached").unwrap();
assert_eq!(primary.remove(id), Some("primary"));
- assert_eq!(auxiliary.remove(id), Some("auxiliary"));
+ assert_eq!(attached.remove(id), Some("attached"));
}
#[test]
fn renderer_call_ids_are_internal_and_session_scoped() {
let large_frontend_id = FrontendCommandId::new(i32::MAX as u64 + 41);
let mut primary = PendingRendererCommandRegistry::<()>::default();
- let mut auxiliary = PendingRendererCommandRegistry::<()>::default();
+ let mut attached = PendingRendererCommandRegistry::<()>::default();
let primary_first = primary
.try_register_renderer_call(
@@ -779,7 +779,7 @@ mod tests {
)
.unwrap()
.correlation();
- let auxiliary_first = auxiliary
+ let attached_first = attached
.try_register_renderer_call(
large_frontend_id,
None,
@@ -797,15 +797,15 @@ mod tests {
.correlation();
assert_eq!(primary_first.renderer_call_id(), RendererCallId::new(1));
- assert_eq!(auxiliary_first.renderer_call_id(), RendererCallId::new(1));
+ assert_eq!(attached_first.renderer_call_id(), RendererCallId::new(1));
assert_eq!(primary_second.renderer_call_id(), RendererCallId::new(2));
assert_eq!(
primary.take_frontend_command_for_renderer(RendererCallId::new(1)),
Some(primary_first)
);
assert_eq!(
- auxiliary.take_renderer_call_for_frontend(large_frontend_id),
- Some(auxiliary_first)
+ attached.take_renderer_call_for_frontend(large_frontend_id),
+ Some(attached_first)
);
}
@@ -930,7 +930,7 @@ mod tests {
let descriptor = RendererCommandDescriptor::from_frontend_policy(
normalized_payload.clone(),
ingress.renderer_policy(),
- RendererInspectorResponseDelivery::CommandReply,
+ RendererInspectorResponseDelivery::AdapterReply,
);
assert_eq!(descriptor.frontend_payload(), normalized_payload);
@@ -952,12 +952,12 @@ mod tests {
let page_descriptor = RendererCommandDescriptor::from_frontend_policy(
frontend.json().to_owned(),
frontend.renderer_policy(),
- RendererInspectorResponseDelivery::DevToolsSession,
+ RendererInspectorResponseDelivery::SessionSink,
);
let worker_descriptor = RendererCommandDescriptor::from_frontend_policy(
frontend.json().to_owned(),
frontend.renderer_policy(),
- RendererInspectorResponseDelivery::DevToolsSession,
+ RendererInspectorResponseDelivery::SessionSink,
);
let adapter_descriptor =
RendererCommandDescriptor::from_synthesized_payload(frontend.json().to_owned())
@@ -965,16 +965,16 @@ mod tests {
assert_eq!(
page_descriptor.response_delivery(),
- RendererInspectorResponseDelivery::DevToolsSession
+ RendererInspectorResponseDelivery::SessionSink
);
assert_eq!(
worker_descriptor.response_delivery(),
- RendererInspectorResponseDelivery::DevToolsSession,
+ RendererInspectorResponseDelivery::SessionSink,
"external Worker commands must publish through their DevTools session"
);
assert_eq!(
adapter_descriptor.response_delivery(),
- RendererInspectorResponseDelivery::CommandReply,
+ RendererInspectorResponseDelivery::AdapterReply,
"method policy must not redirect an internal adapter reply to a frontend session"
);
}
@@ -988,7 +988,7 @@ mod tests {
let performance_descriptor = RendererCommandDescriptor::performance_get_metrics(
performance.json().to_owned(),
performance.renderer_policy(),
- RendererInspectorResponseDelivery::DevToolsSession,
+ RendererInspectorResponseDelivery::SessionSink,
);
assert_eq!(
performance_descriptor.replay(),
@@ -996,7 +996,7 @@ mod tests {
);
assert_eq!(
performance_descriptor.response_delivery(),
- RendererInspectorResponseDelivery::DevToolsSession
+ RendererInspectorResponseDelivery::SessionSink
);
let emulation = ParsedCdpCommand::parse_str(
@@ -1007,7 +1007,7 @@ mod tests {
emulation.json().to_owned(),
emulation.renderer_policy(),
true,
- RendererInspectorResponseDelivery::DevToolsSession,
+ RendererInspectorResponseDelivery::SessionSink,
);
assert_eq!(
emulation_descriptor.replay(),
@@ -1015,12 +1015,12 @@ mod tests {
);
assert_eq!(
emulation_descriptor.response_delivery(),
- RendererInspectorResponseDelivery::DevToolsSession
+ RendererInspectorResponseDelivery::SessionSink
);
}
#[tokio::test]
- async fn session_replay_rotates_renderer_id_and_lease_without_command_reply_receiver() {
+ async fn session_replay_rotates_renderer_id_and_lease_without_adapter_reply_receiver() {
let frontend_id = FrontendCommandId::new(41);
let old_attachment = RendererAgentAttachmentId::allocate();
let new_attachment = RendererAgentAttachmentId::allocate();
@@ -1041,14 +1041,14 @@ mod tests {
RendererCommandDescriptor::from_frontend_policy(
frontend.json().to_owned(),
frontend.renderer_policy(),
- RendererInspectorResponseDelivery::DevToolsSession,
+ RendererInspectorResponseDelivery::SessionSink,
),
)
.unwrap();
let (old_correlation, old_sender, response_receiver) = prepared.into_parts();
assert!(
response_receiver.is_none(),
- "DevToolsSession delivery must not allocate a command-reply receiver"
+ "SessionSink delivery must not allocate an adapter-reply receiver"
);
let mut replays = registry
@@ -1071,7 +1071,7 @@ mod tests {
assert_eq!(payload["id"], frontend_id.get());
assert_eq!(
replay.response_delivery(),
- RendererInspectorResponseDelivery::DevToolsSession,
+ RendererInspectorResponseDelivery::SessionSink,
"attachment replacement must preserve the frontend session output capability"
);
@@ -1125,7 +1125,7 @@ mod tests {
.unwrap();
let (correlation, sender, response_receiver) = prepared.into_parts();
let response_receiver = response_receiver
- .expect("a synthesized CommandReply call must allocate a response receiver");
+ .expect("a synthesized AdapterReply call must allocate a response receiver");
sender
.send(serde_json::json!({
"id": correlation.renderer_call_id().get(),
@@ -1156,7 +1156,7 @@ mod tests {
}
#[tokio::test]
- async fn command_reply_termination_rotates_attachment_and_invalidates_old_response_lease() {
+ async fn adapter_reply_termination_rotates_attachment_and_invalidates_old_response_lease() {
let frontend_id = FrontendCommandId::new(42);
let old_attachment = RendererAgentAttachmentId::allocate();
let new_attachment = RendererAgentAttachmentId::allocate();
@@ -1170,7 +1170,7 @@ mod tests {
.unwrap();
let (old_correlation, old_sender, response_receiver) = prepared.into_parts();
let response_receiver = response_receiver
- .expect("a synthesized CommandReply call must allocate a response receiver");
+ .expect("a synthesized AdapterReply call must allocate a response receiver");
let mut terminations = registry
.prepare_terminations_from_attachment(old_attachment, new_attachment)
@@ -1201,12 +1201,12 @@ mod tests {
"replacement must invalidate an old renderer callback before Page teardown"
);
- let PreparedRendererCallTermination::CommandReply {
+ let PreparedRendererCallTermination::AdapterReply {
correlation,
response_sender,
} = termination
else {
- panic!("a synthesized command must use CommandReply termination")
+ panic!("a synthesized command must use AdapterReply termination")
};
assert_eq!(correlation, terminal_correlation);
response_sender
@@ -1260,7 +1260,7 @@ mod tests {
RendererCommandDescriptor::from_frontend_policy(
frontend.json().to_owned(),
frontend.renderer_policy(),
- RendererInspectorResponseDelivery::DevToolsSession,
+ RendererInspectorResponseDelivery::SessionSink,
),
)
.unwrap();
@@ -1277,7 +1277,7 @@ mod tests {
assert_eq!(termination.correlation(), old_correlation);
assert!(matches!(
termination,
- PreparedRendererCallTermination::DevToolsSession {
+ PreparedRendererCallTermination::SessionSink {
correlation
} if correlation == old_correlation
));
@@ -1327,9 +1327,9 @@ mod tests {
let (_, first_sender, first_receiver) = first.into_parts();
let (_, second_sender, second_receiver) = second.into_parts();
let first_receiver = first_receiver
- .expect("a synthesized CommandReply call must allocate a response receiver");
+ .expect("a synthesized AdapterReply call must allocate a response receiver");
let second_receiver = second_receiver
- .expect("a synthesized CommandReply call must allocate a response receiver");
+ .expect("a synthesized AdapterReply call must allocate a response receiver");
let terminated = registry.terminate_all_renderer_calls("Inspector detached");
diff --git a/moli-protocol/src/conn/state/runtime_slot.rs b/moli-protocol/src/conn/state/runtime_slot.rs
index 3c552efc5..f1ca360b6 100644
--- a/moli-protocol/src/conn/state/runtime_slot.rs
+++ b/moli-protocol/src/conn/state/runtime_slot.rs
@@ -926,21 +926,21 @@ impl TargetRuntimeSlot {
self.network_agent.has_event_listeners()
}
- pub(crate) fn enable_auxiliary_network_events(&mut self, session_id: &str) {
- self.network_agent.enable_auxiliary_events(session_id);
+ pub(crate) fn enable_attached_network_events(&mut self, session_id: &str) {
+ self.network_agent.enable_attached_events(session_id);
}
- pub(crate) fn disable_auxiliary_network_events(&mut self, session_id: &str) -> bool {
- self.network_agent.disable_auxiliary_events(session_id)
+ pub(crate) fn disable_attached_network_events(&mut self, session_id: &str) -> bool {
+ self.network_agent.disable_attached_events(session_id)
}
- pub(crate) fn remove_auxiliary_network_session(&mut self, session_id: &str) {
- self.network_agent.remove_auxiliary_session(session_id);
+ pub(crate) fn remove_attached_network_session(&mut self, session_id: &str) {
+ self.network_agent.remove_attached_session(session_id);
}
- pub(crate) fn auxiliary_network_events_enabled_for_session(&self, session_id: &str) -> bool {
+ pub(crate) fn attached_network_events_enabled_for_session(&self, session_id: &str) -> bool {
self.network_agent
- .auxiliary_events_enabled_for_session(session_id)
+ .attached_events_enabled_for_session(session_id)
}
pub(crate) fn network_event_session_ids(
@@ -1233,9 +1233,9 @@ impl TargetRuntimeSlot {
}
#[cfg(test)]
- pub(crate) fn has_auxiliary_network_events_for_session(&self, session_id: &str) -> bool {
+ pub(crate) fn has_attached_network_events_for_session(&self, session_id: &str) -> bool {
self.network_agent
- .has_auxiliary_events_for_session(session_id)
+ .has_attached_events_for_session(session_id)
}
#[cfg(test)]
diff --git a/moli-protocol/src/conn/state/service_worker_target.rs b/moli-protocol/src/conn/state/service_worker_target.rs
index 938afeee7..468d77a5c 100644
--- a/moli-protocol/src/conn/state/service_worker_target.rs
+++ b/moli-protocol/src/conn/state/service_worker_target.rs
@@ -493,6 +493,16 @@ impl ServiceWorkerTargetState {
state.clear_runtime_remote_object_tracking();
}
+ pub(crate) fn take_runtime_remote_object_cleanup_plan(
+ &mut self,
+ session_id: &str,
+ ) -> (Vec<String>, Vec<String>) {
+ let Some(state) = self.session_state_mut(session_id) else {
+ return (Vec::new(), Vec::new());
+ };
+ state.take_runtime_remote_object_cleanup_plan()
+ }
+
pub(crate) fn record_runtime_contexts_reported_to_frontend(&mut self, session_id: &str) {
let Some(state) = self.session_state_mut(session_id) else {
return;
diff --git a/moli-protocol/src/conn/state/session.rs b/moli-protocol/src/conn/state/session.rs
index 4fedf0d2d..678fee8ef 100644
--- a/moli-protocol/src/conn/state/session.rs
+++ b/moli-protocol/src/conn/state/session.rs
@@ -199,26 +199,26 @@ impl PageTargetHost {
|| self.fetch_owner.config_snapshot() != super::fetch::TargetFetchConfig::default()
}
- pub(crate) fn clear_primary_session_scoped_state_fields(&mut self) {
- *self.devtools_sessions.primary_mut() = Default::default();
- self.runtime_slot.disable_primary_network_events();
+ /// Clears target-level state owned by the primary DevTools handlers.
+ ///
+ /// Per-session handler state, Fetch state, and Network observation state
+ /// have their own disposal steps. Keeping them out of this helper makes
+ /// the final session-registry removal a pure commit operation.
+ pub(crate) fn reset_primary_session_target_state_fields(&mut self) {
self.network_policy.clear_session_scoped_state();
self.http_proxy_override = None;
self.http_no_proxy_override = None;
self.tls_verify_host_override = None;
self.network_conditions = None;
self.geolocation_override = None;
- self.emulated_media = EmulatedMediaOverrides::default();
self.emulated_device_metrics = None;
- self.cpu_throttling_rate = 1.0;
+ self.input_intercept_drags_enabled = false;
+ self.input_drag_intercepted = false;
self.touch_emulation_enabled = false;
self.emit_touch_events_for_mouse = false;
self.focus_emulation_enabled = false;
self.script_execution_disabled = false;
self.css_enabled = false;
- self.fetch_owner.remove_fetch_session(None);
- self.runtime_slot
- .remove_network_session_observation_cursor(None);
}
}
diff --git a/moli-protocol/src/conn/state/tests.rs b/moli-protocol/src/conn/state/tests.rs
index 9e930b4af..f644ba2d0 100644
--- a/moli-protocol/src/conn/state/tests.rs
+++ b/moli-protocol/src/conn/state/tests.rs
@@ -93,7 +93,7 @@ fn page_domain_subscription_generation_tracks_distinct_enable_lifetimes() {
assert_eq!(
state,
TargetPageSessionState::default(),
- "internal subscription generations must not keep default parked state alive"
+ "internal subscription generations must not keep default background state alive"
);
state.enable_page_domain(19);
@@ -308,7 +308,7 @@ fn target_fetch_owner_keeps_fetch_enable_configs_per_session() {
}],
);
owner.configure(
- Some("SID-aux".to_owned()),
+ Some("SID-attached".to_owned()),
false,
vec![FetchInterceptionPattern {
url_pattern: "https://example.test/aux".to_owned(),
@@ -339,7 +339,7 @@ fn target_fetch_owner_keeps_fetch_enable_configs_per_session() {
(true, Some(SubresourceResourceType::Fetch))
);
- let aux = owner.config_snapshot_for_session(Some("SID-aux"));
+ let aux = owner.config_snapshot_for_session(Some("SID-attached"));
assert!(aux.is_enabled());
assert!(!aux.handle_auth_requests());
assert_eq!(aux.patterns().len(), 1);
@@ -365,7 +365,7 @@ fn target_fetch_owner_keeps_fetch_enable_configs_per_session() {
);
assert!(
owner
- .config_snapshot_for_session(Some("SID-aux"))
+ .config_snapshot_for_session(Some("SID-attached"))
.is_enabled()
);
}
@@ -1340,11 +1340,11 @@ fn background_target_mutates_owner_state_in_place() {
};
assert_eq!(identifier, "1");
- let parked_state = &target.owner_state;
- assert_eq!(parked_state.next_document_start_script_id, 1);
- assert_eq!(parked_state.document_start_scripts.len(), 1);
+ let background_state = &target.owner_state;
+ assert_eq!(background_state.next_document_start_script_id, 1);
+ assert_eq!(background_state.document_start_scripts.len(), 1);
assert!(
- !parked_state
+ !background_state
.console_output_state
.has_unemitted_console_domain(7, 3)
);
diff --git a/moli-protocol/src/conn/target/activation.rs b/moli-protocol/src/conn/target/activation.rs
index 2ed07dd00..6a72d417b 100644
--- a/moli-protocol/src/conn/target/activation.rs
+++ b/moli-protocol/src/conn/target/activation.rs
@@ -26,7 +26,7 @@ impl TargetActivationTransition {
self.previous_active_target_id.as_deref()
}
- fn previous_backgrounded_target_id(&self) -> Option<&str> {
+ fn deactivated_target_id(&self) -> Option<&str> {
self.previous_active_target_id()
.filter(|target_id| *target_id != self.selected_target_id())
}
@@ -36,7 +36,7 @@ impl TargetActivationTransition {
}
}
-/// Successful target selection and the Page events caused by its surface move.
+/// Successful target selection and the Page events caused by its visibility change.
///
/// The events stay attached to the completion so every activation entry point
/// must preserve their position relative to its own response or owner action.
@@ -62,7 +62,7 @@ impl CdpConnection {
&mut self,
transition: &TargetActivationTransition,
) -> CompletedTargetActivation {
- let Some(previous_target_id) = transition.previous_backgrounded_target_id() else {
+ let Some(previous_target_id) = transition.deactivated_target_id() else {
return CompletedTargetActivation::new(Vec::new());
};
let protocol_events = self
@@ -99,7 +99,7 @@ impl CdpConnection {
.and_then(BrowserContext::active_target_id_owned);
let transition = TargetActivationTransition::new(target_id, previous_active_target_id);
let hidden_screencast_sessions = transition
- .previous_backgrounded_target_id()
+ .deactivated_target_id()
.map(|active_target_id| self.page_screencast_session_ids_for_target(active_target_id))
.unwrap_or_default();
let Some(browser_context) = self.browser_context.as_mut() else {
diff --git a/moli-protocol/src/conn/target/auto_attach_owner.rs b/moli-protocol/src/conn/target/auto_attach_owner.rs
index 437ffbbc9..5bbb6c235 100644
--- a/moli-protocol/src/conn/target/auto_attach_owner.rs
+++ b/moli-protocol/src/conn/target/auto_attach_owner.rs
@@ -1,34 +1,14 @@
use crate::conn::{AutoAttachOwnerPolicy, CdpConnection, CdpTargetFilter};
impl CdpConnection {
- fn sync_auto_attach_flags_from_owners(&mut self) {
- self.auto_attach = !self.auto_attach_owner_sessions.is_empty();
- self.auto_attach_wait_for_debugger_on_start = self
- .auto_attach_owner_sessions
- .values()
- .any(|policy| policy.wait_for_debugger_on_start);
- }
-
- pub(crate) fn has_auto_attach_owner(&self, session_id: Option<&str>) -> bool {
- self.auto_attach_owner_sessions
- .contains_key(&session_id.map(str::to_owned))
- }
-
- pub(crate) fn auto_attach_owner_count(&self) -> usize {
- self.auto_attach_owner_sessions.len()
+ pub(crate) fn auto_attach_enabled(&self) -> bool {
+ !self.auto_attach_owner_sessions.is_empty()
}
pub(crate) fn auto_attach_owner_sessions_for_target_type(
&self,
target_type: &str,
) -> Vec<Option<String>> {
- if self.auto_attach_owner_sessions.is_empty() && self.auto_attach {
- return CdpTargetFilter::default_auto_attach()
- .matches(target_type)
- .then_some(None)
- .into_iter()
- .collect();
- }
self.auto_attach_owner_sessions
.iter()
.filter(|(_, policy)| policy.target_filter.matches(target_type))
@@ -44,18 +24,12 @@ impl CdpConnection {
self.auto_attach_owner_sessions
.get(&session_id.map(str::to_owned))
.is_some_and(|policy| policy.target_filter.matches(target_type))
- || (self.auto_attach_owner_sessions.is_empty()
- && self.auto_attach
- && CdpTargetFilter::default_auto_attach().matches(target_type))
}
pub(crate) fn auto_attach_owner_waits_for_debugger_on_start(
&self,
session_id: Option<&str>,
) -> bool {
- if self.auto_attach_owner_sessions.is_empty() && self.auto_attach {
- return self.auto_attach_wait_for_debugger_on_start;
- }
self.auto_attach_owner_sessions
.get(&session_id.map(str::to_owned))
.is_some_and(|policy| policy.wait_for_debugger_on_start)
@@ -82,14 +56,12 @@ impl CdpConnection {
} else {
self.auto_attach_owner_sessions.shift_remove(&key);
}
- self.sync_auto_attach_flags_from_owners();
}
pub(crate) fn clear_auto_attach_owner(&mut self, session_id: Option<&str>) {
self.clear_service_worker_auto_attach_related_owner(session_id);
let key = session_id.map(str::to_owned);
self.auto_attach_owner_sessions.shift_remove(&key);
- self.sync_auto_attach_flags_from_owners();
}
}
diff --git a/moli-protocol/src/conn/target/control.rs b/moli-protocol/src/conn/target/control.rs
index c9b4b93ff..f298b8e13 100644
--- a/moli-protocol/src/conn/target/control.rs
+++ b/moli-protocol/src/conn/target/control.rs
@@ -46,10 +46,10 @@ impl TargetControlPlane {
&mut self,
tab_target_id: &str,
session_id: String,
- auxiliary: bool,
+ is_attached_session: bool,
) -> bool {
self.graph
- .assign_session_to_tab_target(tab_target_id, session_id, auxiliary)
+ .assign_session_to_tab_target(tab_target_id, session_id, is_attached_session)
}
pub(crate) fn remove_tab_session(&mut self, session_id: &str) -> Option<String> {
@@ -770,7 +770,7 @@ mod tests {
#[test]
fn target_closure_cleanup_event_plan_detaches_declared_sessions() {
let mut control = TargetControlPlane::default();
- for session_id in ["SID-primary", "SID-aux"] {
+ for session_id in ["SID-primary", "SID-attached"] {
control.commit_attached_session_event(
session_id.to_owned(),
None,
@@ -790,7 +790,7 @@ mod tests {
crate::conn::TargetClosureCleanupPlan::new(
"TID-page",
Some("Render process gone."),
- ["SID-primary".to_owned(), "SID-aux".to_owned()],
+ ["SID-primary".to_owned(), "SID-attached".to_owned()],
),
None,
);
@@ -801,7 +801,7 @@ mod tests {
.iter()
.map(|session| (session.target_id(), session.session_id()))
.collect::<Vec<_>>(),
- vec![("TID-page", "SID-primary"), ("TID-page", "SID-aux")]
+ vec![("TID-page", "SID-primary"), ("TID-page", "SID-attached")]
);
assert_eq!(plan.into_background_events().len(), 2);
}
diff --git a/moli-protocol/src/conn/target/graph.rs b/moli-protocol/src/conn/target/graph.rs
index f4bd64e7e..04d8e9c5d 100644
--- a/moli-protocol/src/conn/target/graph.rs
+++ b/moli-protocol/src/conn/target/graph.rs
@@ -38,23 +38,23 @@ impl TargetHostDelta {
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub(crate) struct TargetSessionSet {
primary_session_id: Option<String>,
- auxiliary_session_ids: HashSet<String>,
+ attached_session_ids: HashSet<String>,
}
impl TargetSessionSet {
pub(crate) fn has_session(&self) -> bool {
- self.primary_session_id.is_some() || !self.auxiliary_session_ids.is_empty()
+ self.primary_session_id.is_some() || !self.attached_session_ids.is_empty()
}
fn primary_session_id(&self) -> Option<&str> {
self.primary_session_id.as_deref()
}
- fn insert_session(&mut self, session_id: String, auxiliary: bool) {
- if !auxiliary && self.primary_session_id.is_none() {
+ fn insert_session(&mut self, session_id: String, is_attached_session: bool) {
+ if !is_attached_session && self.primary_session_id.is_none() {
self.primary_session_id = Some(session_id);
} else {
- self.auxiliary_session_ids.insert(session_id);
+ self.attached_session_ids.insert(session_id);
}
}
@@ -63,14 +63,14 @@ impl TargetSessionSet {
self.primary_session_id = None;
return true;
}
- self.auxiliary_session_ids.remove(session_id)
+ self.attached_session_ids.remove(session_id)
}
fn session_ids(&self) -> Vec<String> {
self.primary_session_id
.iter()
.cloned()
- .chain(self.auxiliary_session_ids.iter().cloned())
+ .chain(self.attached_session_ids.iter().cloned())
.collect()
}
}
@@ -213,7 +213,7 @@ impl TargetGraph {
&mut self,
tab_target_id: &str,
session_id: String,
- auxiliary: bool,
+ is_attached_session: bool,
) -> bool {
self.remove_tab_session(&session_id);
let Some(target) = self.tabs.get_mut(tab_target_id) else {
@@ -221,7 +221,7 @@ impl TargetGraph {
};
target
.sessions
- .insert_session(session_id.clone(), auxiliary);
+ .insert_session(session_id.clone(), is_attached_session);
self.tab_session_to_tab
.insert(session_id, tab_target_id.to_owned());
true
diff --git a/moli-protocol/src/conn/target/mod.rs b/moli-protocol/src/conn/target/mod.rs
index ca21c295a..5e834bd0e 100644
--- a/moli-protocol/src/conn/target/mod.rs
+++ b/moli-protocol/src/conn/target/mod.rs
@@ -22,9 +22,9 @@ pub(crate) use session::{
CommittedAttachSession, DetachedTargetSession, PreparedAttachSession, TargetSessionRegistry,
};
pub(crate) use transaction::{
- PreparedTargetAttach, PreparedTargetHostClosure, PreparedTargetHostDelta,
- TargetAttachRollbackPlan, TargetAttachSessionCommit, TargetAutoAttachedSessionDetachPlan,
- TargetBindingCleanupAction, TargetBindingCleanupPlan, TargetClosureCleanupPlan,
- TargetEventPlan, TargetSessionDetachCleanupPlan,
+ PreparedTargetAttach, PreparedTargetHostClosure, PreparedTargetHostDelta, SessionDisposalPlan,
+ SessionDisposalTarget, TargetAttachRollbackPlan, TargetAttachSessionCommit,
+ TargetAutoAttachedSessionDetachPlan, TargetClosureCleanupPlan, TargetEventPlan,
+ TargetSessionDetachCleanupPlan,
};
pub(crate) use worker_session::TargetWorkerProtocolAttachmentIdentity;
diff --git a/moli-protocol/src/conn/target/route.rs b/moli-protocol/src/conn/target/route.rs
index 3bd8f8ca1..ab4979ed0 100644
--- a/moli-protocol/src/conn/target/route.rs
+++ b/moli-protocol/src/conn/target/route.rs
@@ -1,4 +1,4 @@
-use crate::conn::{BrowserContext, CdpConnection};
+use crate::conn::CdpConnection;
use moli_page_types::DevToolsSessionKey;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
@@ -173,24 +173,23 @@ impl CdpConnection {
pub(crate) fn session_route(&self, session_id: Option<&str>) -> Option<CdpSessionRoute> {
let session_id = session_id?;
- if let Some(route) = self.target_control.attached_session_route(session_id) {
- return Some(route.clone());
+ let committed = self
+ .target_control
+ .attached_session_route(session_id)
+ .cloned();
+ if committed.is_some() {
+ return committed;
}
-
- // The remaining lookups cover only the interval after a target-owned
- // binding is prepared and before its Target.attachedToTarget event is
- // committed. Committed sessions always resolve from target_control.
- if let Some(tab_target_id) = self.tab_target_id_for_session_id(session_id)
- && let Some(browser_context_id) =
- self.browser_context_id_for_tab_target_id(tab_target_id)
- {
- return Some(CdpSessionRoute::TabTarget {
- browser_context_id,
- tab_target_id: tab_target_id.to_owned(),
- });
+ #[cfg(test)]
+ if self.allow_incomplete_session_fixture_routes {
+ return self.bound_session_route_for_test(session_id, None);
}
- self.browser_contexts()
- .find_map(|bc| prepared_browser_context_session_route(bc, session_id))
+ None
+ }
+
+ #[cfg(test)]
+ pub(crate) fn require_committed_session_routes_for_test(&mut self) {
+ self.allow_incomplete_session_fixture_routes = false;
}
pub(crate) fn target_session_route_for_target_id(
@@ -291,51 +290,11 @@ impl CdpConnection {
.any(|browser_context| browser_context.has_attached_child_frame_id(frame_id))
}
}
-fn prepared_browser_context_session_route(
- browser_context: &BrowserContext,
- session_id: &str,
-) -> Option<CdpSessionRoute> {
- if let Some((target, session_key)) = browser_context.page_targets.iter().find_map(|target| {
- target
- .devtools_sessions
- .key_for_wire_session_id(session_id)
- .map(|session_key| (target, session_key))
- }) {
- return Some(CdpSessionRoute::PageTarget {
- browser_context_id: browser_context.id.clone(),
- target_id: target.target_id().to_owned(),
- session_key,
- });
- }
-
- browser_context
- .shared_worker_target_id_for_session(session_id)
- .map(|target_id| CdpSessionRoute::SharedWorkerTarget {
- browser_context_id: browser_context.id.clone(),
- target_id: target_id.to_owned(),
- })
- .or_else(|| {
- browser_context
- .dedicated_worker_target_id_for_session(session_id)
- .map(|target_id| CdpSessionRoute::DedicatedWorkerTarget {
- browser_context_id: browser_context.id.clone(),
- target_id: target_id.to_owned(),
- })
- .or_else(|| {
- browser_context
- .service_worker_target_id_for_session(session_id)
- .map(|target_id| CdpSessionRoute::ServiceWorkerTarget {
- browser_context_id: browser_context.id.clone(),
- target_id: target_id.to_owned(),
- })
- })
- })
-}
#[cfg(test)]
mod tests {
use super::*;
- use crate::conn::PageTargetHost;
+ use crate::conn::{BrowserContext, PageTargetHost};
#[test]
fn committed_page_session_route_is_stable_across_foreground_selection() {
@@ -377,42 +336,13 @@ mod tests {
}
#[test]
- fn prepared_page_sessions_resolve_from_their_target_registry() {
- let mut browser_context = BrowserContext::new("BID-route".to_owned());
- browser_context.set_active_target_id("TID-active");
- browser_context.attach_active_session("SID-active");
-
- let mut background = PageTargetHost::with_url(
- "TID-background".to_owned(),
- Some("SID-background".to_owned()),
- "about:blank".to_owned(),
- );
- background.devtools_sessions.ensure_attached("SID-attached");
- assert!(browser_context.insert_page_target_host(background));
+ fn target_binding_is_not_globally_routable_before_session_commit() {
+ let mut connection = CdpConnection::new();
+ connection.require_committed_session_routes_for_test();
+ let mut browser_context = BrowserContext::new_with_page_for_test("BID-route", "TID-page");
+ browser_context.attach_active_session("SID-prepared");
+ connection.browser_context = Some(browser_context);
- assert_eq!(
- prepared_browser_context_session_route(&browser_context, "SID-active"),
- Some(CdpSessionRoute::PageTarget {
- browser_context_id: "BID-route".to_owned(),
- target_id: "TID-active".to_owned(),
- session_key: DevToolsSessionKey::Primary,
- })
- );
- assert_eq!(
- prepared_browser_context_session_route(&browser_context, "SID-background"),
- Some(CdpSessionRoute::PageTarget {
- browser_context_id: "BID-route".to_owned(),
- target_id: "TID-background".to_owned(),
- session_key: DevToolsSessionKey::Primary,
- })
- );
- assert_eq!(
- prepared_browser_context_session_route(&browser_context, "SID-attached"),
- Some(CdpSessionRoute::PageTarget {
- browser_context_id: "BID-route".to_owned(),
- target_id: "TID-background".to_owned(),
- session_key: DevToolsSessionKey::Attached("SID-attached".to_owned()),
- })
- );
+ assert_eq!(connection.session_route(Some("SID-prepared")), None);
}
}
diff --git a/moli-protocol/src/conn/target/session_binding.rs b/moli-protocol/src/conn/target/session_binding.rs
index 180cf94cd..28954c817 100644
--- a/moli-protocol/src/conn/target/session_binding.rs
+++ b/moli-protocol/src/conn/target/session_binding.rs
@@ -2,20 +2,50 @@ use crate::conn::CdpConnection;
use crate::devtools_runtime::DevToolsTargetInfo;
use super::{
- CdpSessionRoute, PreparedTargetAttach, TargetAttachRollbackPlan, TargetAttachSessionCommit,
- TargetAutoAttachedSessionDetachPlan, TargetBindingCleanupAction, TargetBindingCleanupPlan,
+ CdpSessionRoute, PreparedTargetAttach, SessionDisposalPlan, SessionDisposalTarget,
+ TargetAttachRollbackPlan, TargetAttachSessionCommit, TargetAutoAttachedSessionDetachPlan,
TargetClosureCleanupPlan, TargetEventPlan, TargetSessionDetachCleanupPlan,
};
impl CdpConnection {
- pub(crate) async fn clear_target_session_overrides_async(
+ pub(crate) async fn clear_devtools_network_session_policy_async(
&mut self,
session_id: &str,
) -> anyhow::Result<()> {
- let browser_identity_changed = match self.browser_context.as_mut() {
+ let Some(CdpSessionRoute::PageTarget {
+ browser_context_id,
+ target_id,
+ session_key,
+ }) = self.session_route(Some(session_id))
+ else {
+ return Ok(());
+ };
+
+ let Some(browser_context) = self.browser_context_by_id_mut(&browser_context_id) else {
+ return Ok(());
+ };
+ browser_context
+ .clear_devtools_network_session_policy_async(&target_id, &session_key)
+ .await
+ }
+
+ pub(crate) async fn clear_devtools_emulation_session_policy_async(
+ &mut self,
+ session_id: &str,
+ ) -> anyhow::Result<()> {
+ let Some(CdpSessionRoute::PageTarget {
+ browser_context_id,
+ target_id,
+ session_key,
+ }) = self.session_route(Some(session_id))
+ else {
+ return Ok(());
+ };
+
+ let browser_identity_changed = match self.browser_context_by_id_mut(&browser_context_id) {
Some(browser_context) => {
browser_context
- .clear_target_session_overrides_async(session_id)
+ .clear_devtools_emulation_session_policy_async(&target_id, &session_key)
.await?
}
None => false,
@@ -56,49 +86,42 @@ impl CdpConnection {
);
}
- fn clear_browser_session_owner_state(&mut self, session_id: &str) -> bool {
- if !self.is_browser_session_id(Some(session_id)) {
- return false;
- }
- self.download_behavior
- .set_browser_events_enabled_for_session(Some(session_id), false);
- self.cancel_tracing_for_session_owner(Some(session_id));
- self.clear_auto_attach_owner(Some(session_id));
- self.clear_target_discovery_for_owner(Some(session_id));
- self.set_service_worker_pause_on_start_owner(Some(session_id), false);
- self.set_dedicated_worker_pause_on_start_owner(Some(session_id), false);
- true
- }
-
- pub(crate) fn detach_browser_session_owner_without_event(
+ pub(crate) fn commit_browser_session_disposal_without_event(
&mut self,
- session_id: &str,
- ) -> Option<TargetEventPlan> {
- if !self.clear_browser_session_owner_state(session_id) {
- return None;
- }
- let rollback_plan = self.rollback_attached_session_without_event(session_id);
- Some(rollback_plan)
+ plan: &SessionDisposalPlan,
+ ) -> anyhow::Result<TargetEventPlan> {
+ anyhow::ensure!(
+ matches!(plan.target(), SessionDisposalTarget::Browser)
+ && self.is_browser_session_id(Some(plan.session_id())),
+ "InvalidSessionId"
+ );
+ Ok(self.rollback_attached_session_without_event(plan.session_id()))
}
- pub(crate) fn detach_browser_session_owner_event_plan(
+ pub(crate) fn commit_browser_session_disposal_event_plan(
&mut self,
- session_id: &str,
- ) -> Option<TargetEventPlan> {
+ plan: &SessionDisposalPlan,
+ ) -> anyhow::Result<TargetEventPlan> {
+ anyhow::ensure!(
+ matches!(plan.target(), SessionDisposalTarget::Browser)
+ && self.is_browser_session_id(Some(plan.session_id())),
+ "InvalidSessionId"
+ );
let owner_session_id = self
.target_control
- .attached_session_owner_session_id(session_id)
+ .attached_session_owner_session_id(plan.session_id())
.map(str::to_owned);
- if !self.clear_browser_session_owner_state(session_id) {
- return None;
- }
- let plan = self.target_control.detach_attached_session_event_plan(
- session_id,
- None,
- owner_session_id.as_deref(),
- );
- self.clear_detached_target_session_owner_state(session_id);
- plan
+ let session_id = plan.session_id().to_owned();
+ let event_plan = self
+ .target_control
+ .detach_attached_session_event_plan(
+ plan.session_id(),
+ None,
+ owner_session_id.as_deref(),
+ )
+ .ok_or_else(|| anyhow::anyhow!("InvalidSessionId"))?;
+ self.remove_detached_session_control_owner(&session_id);
+ Ok(event_plan)
}
pub(crate) fn release_root_target_frontend_owner_without_event(&mut self) {
@@ -114,9 +137,14 @@ impl CdpConnection {
&mut self,
session_id: &str,
) -> bool {
+ let Some(browser_context_id) = self
+ .session_route(Some(session_id))
+ .and_then(|route| route.browser_context_id().map(str::to_owned))
+ else {
+ return false;
+ };
let released = self
- .browser_context
- .as_mut()
+ .browser_context_by_id_mut(&browser_context_id)
.is_some_and(|browser_context| {
browser_context
.release_primary_session_binding_preserving_frontend_state(session_id)
@@ -133,11 +161,21 @@ impl CdpConnection {
session_id: String,
owner_session_id: Option<&str>,
) {
- let target_id = self.non_browser_target_id_for_session(Some(&session_id));
- self.register_auto_attached_session_for_target(
+ let route = self.bound_session_route_for_test(&session_id, None);
+ let target_id = route.as_ref().and_then(|route| match route {
+ CdpSessionRoute::TabTarget { tab_target_id, .. } => Some(tab_target_id.clone()),
+ CdpSessionRoute::PageTarget { target_id, .. }
+ | CdpSessionRoute::SharedWorkerTarget { target_id, .. }
+ | CdpSessionRoute::DedicatedWorkerTarget { target_id, .. }
+ | CdpSessionRoute::ServiceWorkerTarget { target_id, .. } => Some(target_id.clone()),
+ CdpSessionRoute::Browser | CdpSessionRoute::BrowserContext { .. } => None,
+ });
+ self.target_control.commit_auto_attached_session_for_target(
session_id,
owner_session_id,
target_id.as_deref(),
+ route,
+ false,
);
}
@@ -148,7 +186,7 @@ impl CdpConnection {
owner_session_id: Option<&str>,
target_id: Option<&str>,
) {
- let route = self.session_route(Some(&session_id));
+ let route = self.bound_session_route_for_test(&session_id, target_id);
self.target_control.commit_auto_attached_session_for_target(
session_id,
owner_session_id,
@@ -158,6 +196,103 @@ impl CdpConnection {
);
}
+ #[cfg(test)]
+ pub(crate) fn register_bound_session_for_test(&mut self, session_id: &str) {
+ let route = self
+ .bound_session_route_for_test(session_id, None)
+ .unwrap_or_else(|| panic!("test session {session_id} must own a concrete route"));
+ let target_id = match &route {
+ CdpSessionRoute::TabTarget { tab_target_id, .. } => tab_target_id.as_str(),
+ CdpSessionRoute::PageTarget { target_id, .. }
+ | CdpSessionRoute::SharedWorkerTarget { target_id, .. }
+ | CdpSessionRoute::DedicatedWorkerTarget { target_id, .. }
+ | CdpSessionRoute::ServiceWorkerTarget { target_id, .. } => target_id.as_str(),
+ CdpSessionRoute::Browser => "browser",
+ CdpSessionRoute::BrowserContext { browser_context_id } => browser_context_id.as_str(),
+ };
+ self.target_control.commit_attached_session(
+ session_id.to_owned(),
+ None,
+ target_id,
+ Some(route.clone()),
+ false,
+ false,
+ );
+ }
+
+ #[cfg(test)]
+ pub(crate) fn bound_session_route_for_test(
+ &self,
+ session_id: &str,
+ wanted_target_id: Option<&str>,
+ ) -> Option<CdpSessionRoute> {
+ if let Some(tab_target_id) = self.tab_target_id_for_session_id(session_id)
+ && wanted_target_id.is_none_or(|target_id| target_id == tab_target_id)
+ {
+ return Some(CdpSessionRoute::TabTarget {
+ browser_context_id: self.browser_context_id_for_tab_target_id(tab_target_id)?,
+ tab_target_id: tab_target_id.to_owned(),
+ });
+ }
+ self.browser_contexts().find_map(|browser_context| {
+ if let Some((target, session_key)) =
+ browser_context.page_targets.iter().find_map(|target| {
+ (wanted_target_id.is_none_or(|target_id| target_id == target.target_id()))
+ .then(|| {
+ target
+ .devtools_sessions
+ .key_for_wire_session_id(session_id)
+ .map(|session_key| (target, session_key))
+ })
+ .flatten()
+ })
+ {
+ return Some(CdpSessionRoute::PageTarget {
+ browser_context_id: browser_context.id.clone(),
+ target_id: target.target_id().to_owned(),
+ session_key,
+ });
+ }
+ browser_context
+ .shared_worker_targets
+ .values()
+ .find(|target| {
+ target.is_session(session_id)
+ && wanted_target_id.is_none_or(|wanted| wanted == target.target_id)
+ })
+ .map(|target| CdpSessionRoute::SharedWorkerTarget {
+ browser_context_id: browser_context.id.clone(),
+ target_id: target.target_id.clone(),
+ })
+ .or_else(|| {
+ browser_context
+ .dedicated_worker_targets
+ .values()
+ .find(|target| {
+ target.is_session(session_id)
+ && wanted_target_id.is_none_or(|wanted| wanted == target.target_id)
+ })
+ .map(|target| CdpSessionRoute::DedicatedWorkerTarget {
+ browser_context_id: browser_context.id.clone(),
+ target_id: target.target_id.clone(),
+ })
+ })
+ .or_else(|| {
+ browser_context
+ .service_worker_targets
+ .values()
+ .find(|target| {
+ target.is_session(session_id)
+ && wanted_target_id.is_none_or(|wanted| wanted == target.target_id)
+ })
+ .map(|target| CdpSessionRoute::ServiceWorkerTarget {
+ browser_context_id: browser_context.id.clone(),
+ target_id: target.target_id.clone(),
+ })
+ })
+ })
+ }
+
pub(crate) fn commit_prepared_attach_event_plan(
&mut self,
prepared: PreparedTargetAttach,
@@ -193,7 +328,7 @@ impl CdpConnection {
session_id,
owner_session_id.as_deref(),
&target_id,
- route,
+ Some(route),
auto_attached,
waiting_for_debugger,
target_info.clone(),
@@ -205,53 +340,37 @@ impl CdpConnection {
plan
}
- pub(crate) fn prepare_auto_attach_session_commit(
- &self,
- session_id: impl Into<String>,
- owner_session_id: Option<String>,
- waiting_for_debugger: bool,
- ) -> TargetAttachSessionCommit {
- let session_id = session_id.into();
- let route = self.session_route(Some(&session_id));
- TargetAttachSessionCommit::auto_attached(session_id, owner_session_id, waiting_for_debugger)
- .with_route(route)
- }
-
- pub(crate) fn prepare_direct_attach_session_commit(
- &self,
- session_id: impl Into<String>,
- owner_session_id: Option<String>,
- waiting_for_debugger: bool,
- ) -> TargetAttachSessionCommit {
- let session_id = session_id.into();
- let route = self.session_route(Some(&session_id));
- TargetAttachSessionCommit::direct(session_id, owner_session_id, waiting_for_debugger)
- .with_route(route)
- }
-
pub(crate) fn attach_tab_target_session_event_plan(
&mut self,
session_id: String,
owner_session_id: Option<&str>,
tab_target_id: &str,
- auxiliary: bool,
+ is_attached_session: bool,
) -> Result<TargetEventPlan, &'static str> {
- if !self.assign_session_to_tab_target(tab_target_id, session_id.clone(), auxiliary) {
+ let Some(browser_context_id) = self.browser_context_id_for_tab_target_id(tab_target_id)
+ else {
+ return Err("UnknownTargetId");
+ };
+ if !self.assign_session_to_tab_target(
+ tab_target_id,
+ session_id.clone(),
+ is_attached_session,
+ ) {
return Err("UnknownTargetId");
}
- let prepared_session = self.prepare_direct_attach_session_commit(
+ let prepared_session = TargetAttachSessionCommit::direct(
session_id,
owner_session_id.map(str::to_owned),
+ CdpSessionRoute::TabTarget {
+ browser_context_id,
+ tab_target_id: tab_target_id.to_owned(),
+ },
false,
);
let Some(target_info) = self.tab_target_info(tab_target_id) else {
self.rollback_prepared_attach_session_sync_without_event(&prepared_session);
return Err("UnknownTargetId");
};
- if prepared_session.route().is_none() {
- self.rollback_prepared_attach_session_sync_without_event(&prepared_session);
- return Err("InvalidSessionId");
- }
Ok(
self.commit_prepared_attach_event_plan(PreparedTargetAttach::new(
tab_target_id,
@@ -268,28 +387,28 @@ impl CdpConnection {
target_id: &str,
) -> Result<TargetEventPlan, &'static str> {
let session_id_for_binding = session_id.clone();
- let target_info = {
+ let (browser_context_id, target_info) = {
let Some(bc) = self.browser_context.as_mut() else {
return Err("BrowserContextNotLoaded");
};
if !bc.assign_session_to_shared_worker_target(target_id, session_id_for_binding) {
return Err("UnknownTargetId");
}
- bc.devtools_target_info(target_id)
+ (bc.id.clone(), bc.devtools_target_info(target_id))
};
- let prepared_session = self.prepare_direct_attach_session_commit(
+ let prepared_session = TargetAttachSessionCommit::direct(
session_id,
owner_session_id.map(str::to_owned),
+ CdpSessionRoute::SharedWorkerTarget {
+ browser_context_id,
+ target_id: target_id.to_owned(),
+ },
false,
);
let Some(target_info) = target_info else {
self.rollback_prepared_attach_session_sync_without_event(&prepared_session);
return Err("UnknownTargetId");
};
- if prepared_session.route().is_none() {
- self.rollback_prepared_attach_session_sync_without_event(&prepared_session);
- return Err("InvalidSessionId");
- }
Ok(
self.commit_prepared_attach_event_plan(PreparedTargetAttach::new(
target_id,
@@ -306,28 +425,28 @@ impl CdpConnection {
target_id: &str,
) -> Result<TargetEventPlan, &'static str> {
let session_id_for_binding = session_id.clone();
- let target_info = {
+ let (browser_context_id, target_info) = {
let Some(bc) = self.browser_context.as_mut() else {
return Err("BrowserContextNotLoaded");
};
if !bc.assign_session_to_service_worker_target(target_id, session_id_for_binding) {
return Err("UnknownTargetId");
}
- bc.devtools_target_info(target_id)
+ (bc.id.clone(), bc.devtools_target_info(target_id))
};
- let prepared_session = self.prepare_direct_attach_session_commit(
+ let prepared_session = TargetAttachSessionCommit::direct(
session_id,
owner_session_id.map(str::to_owned),
+ CdpSessionRoute::ServiceWorkerTarget {
+ browser_context_id,
+ target_id: target_id.to_owned(),
+ },
false,
);
let Some(target_info) = target_info else {
self.rollback_prepared_attach_session_sync_without_event(&prepared_session);
return Err("UnknownTargetId");
};
- if prepared_session.route().is_none() {
- self.rollback_prepared_attach_session_sync_without_event(&prepared_session);
- return Err("InvalidSessionId");
- }
Ok(
self.commit_prepared_attach_event_plan(PreparedTargetAttach::new(
target_id,
@@ -344,28 +463,28 @@ impl CdpConnection {
target_id: &str,
) -> Result<TargetEventPlan, &'static str> {
let session_id_for_binding = session_id.clone();
- let target_info = {
+ let (browser_context_id, target_info) = {
let Some(bc) = self.browser_context.as_mut() else {
return Err("BrowserContextNotLoaded");
};
if !bc.assign_session_to_dedicated_worker_target(target_id, session_id_for_binding) {
return Err("UnknownTargetId");
}
- bc.devtools_target_info(target_id)
+ (bc.id.clone(), bc.devtools_target_info(target_id))
};
- let prepared_session = self.prepare_direct_attach_session_commit(
+ let prepared_session = TargetAttachSessionCommit::direct(
session_id,
owner_session_id.map(str::to_owned),
+ CdpSessionRoute::DedicatedWorkerTarget {
+ browser_context_id,
+ target_id: target_id.to_owned(),
+ },
false,
);
let Some(target_info) = target_info else {
self.rollback_prepared_attach_session_sync_without_event(&prepared_session);
return Err("UnknownTargetId");
};
- if prepared_session.route().is_none() {
- self.rollback_prepared_attach_session_sync_without_event(&prepared_session);
- return Err("InvalidSessionId");
- }
Ok(
self.commit_prepared_dedicated_worker_attach_event_plan(PreparedTargetAttach::new(
target_id,
@@ -380,18 +499,34 @@ impl CdpConnection {
tab_target_id: &str,
session_id: String,
owner_session_id: Option<&str>,
- ) -> bool {
+ ) -> Option<CdpSessionRoute> {
+ let browser_context_id = self.browser_context_id_for_tab_target_id(tab_target_id)?;
self.assign_session_to_tab_target(tab_target_id, session_id, owner_session_id.is_some())
+ .then(|| CdpSessionRoute::TabTarget {
+ browser_context_id,
+ tab_target_id: tab_target_id.to_owned(),
+ })
}
pub(crate) fn prepare_auto_attached_page_session_binding(
&mut self,
target_id: &str,
session_id: String,
- ) -> bool {
- self.browser_context
- .as_mut()
- .is_some_and(|bc| bc.assign_auto_attached_session_to_target(target_id, session_id))
+ ) -> Option<CdpSessionRoute> {
+ let browser_context = self.browser_context.as_mut()?;
+ let browser_context_id = browser_context.id.clone();
+ if !browser_context.assign_auto_attached_session_to_target(target_id, session_id.clone()) {
+ return None;
+ }
+ let session_key = browser_context
+ .page_target(target_id)?
+ .devtools_sessions
+ .key_for_wire_session_id(&session_id)?;
+ Some(CdpSessionRoute::PageTarget {
+ browser_context_id,
+ target_id: target_id.to_owned(),
+ session_key,
+ })
}
pub(crate) fn prepare_auto_attached_page_session_binding_in_browser_context(
@@ -399,39 +534,65 @@ impl CdpConnection {
browser_context_id: &str,
target_id: &str,
session_id: String,
- ) -> bool {
- self.browser_context_by_id_mut(browser_context_id)
- .is_some_and(|bc| bc.assign_auto_attached_session_to_target(target_id, session_id))
+ ) -> Option<CdpSessionRoute> {
+ let browser_context = self.browser_context_by_id_mut(browser_context_id)?;
+ if !browser_context.assign_auto_attached_session_to_target(target_id, session_id.clone()) {
+ return None;
+ }
+ let session_key = browser_context
+ .page_target(target_id)?
+ .devtools_sessions
+ .key_for_wire_session_id(&session_id)?;
+ Some(CdpSessionRoute::PageTarget {
+ browser_context_id: browser_context_id.to_owned(),
+ target_id: target_id.to_owned(),
+ session_key,
+ })
}
pub(crate) fn prepare_auto_attached_shared_worker_session_binding(
&mut self,
target_id: &str,
session_id: String,
- ) -> bool {
- self.browser_context
- .as_mut()
- .is_some_and(|bc| bc.assign_session_to_shared_worker_target(target_id, session_id))
+ ) -> Option<CdpSessionRoute> {
+ let browser_context = self.browser_context.as_mut()?;
+ let browser_context_id = browser_context.id.clone();
+ browser_context
+ .assign_session_to_shared_worker_target(target_id, session_id)
+ .then(|| CdpSessionRoute::SharedWorkerTarget {
+ browser_context_id,
+ target_id: target_id.to_owned(),
+ })
}
pub(crate) fn prepare_auto_attached_dedicated_worker_session_binding(
&mut self,
target_id: &str,
session_id: String,
- ) -> bool {
- self.browser_context
- .as_mut()
- .is_some_and(|bc| bc.assign_session_to_dedicated_worker_target(target_id, session_id))
+ ) -> Option<CdpSessionRoute> {
+ let browser_context = self.browser_context.as_mut()?;
+ let browser_context_id = browser_context.id.clone();
+ browser_context
+ .assign_session_to_dedicated_worker_target(target_id, session_id)
+ .then(|| CdpSessionRoute::DedicatedWorkerTarget {
+ browser_context_id,
+ target_id: target_id.to_owned(),
+ })
}
pub(crate) fn prepare_auto_attached_service_worker_session_binding(
&mut self,
target_id: &str,
session_id: String,
- ) -> bool {
- self.browser_context
- .as_mut()
- .is_some_and(|bc| bc.assign_session_to_service_worker_target(target_id, session_id))
+ ) -> Option<CdpSessionRoute> {
+ let browser_context = self.browser_context.as_mut()?;
+ let browser_context_id = browser_context.id.clone();
+ browser_context
+ .assign_session_to_service_worker_target(target_id, session_id)
+ .then(|| CdpSessionRoute::ServiceWorkerTarget {
+ browser_context_id,
+ target_id: target_id.to_owned(),
+ })
}
pub(crate) fn prepare_auto_attached_shared_worker_session_binding_info_in_browser_context(
@@ -511,7 +672,7 @@ impl CdpConnection {
.target_control
.rollback_attached_session_without_event(session_id);
for session_id in plan.rolled_back_session_ids() {
- self.clear_detached_target_session_owner_state(session_id);
+ self.remove_detached_session_control_owner(session_id);
}
plan
}
@@ -552,7 +713,7 @@ impl CdpConnection {
.detached_sessions()
.iter()
.any(|session| session.target_id() == target_id && session.was_waiting_for_debugger());
- self.clear_detached_target_session_owner_state(session_id);
+ self.remove_detached_session_control_owner(session_id);
if let Some(attached_state_delta_plan) = attached_state_delta_plan {
plan.extend(attached_state_delta_plan);
}
@@ -565,7 +726,38 @@ impl CdpConnection {
plan
}
- pub(crate) fn detach_target_closure_cleanup_event_plan(
+ pub(crate) async fn dispose_target_closure_sessions_event_plan_async(
+ &mut self,
+ cleanup_plan: TargetClosureCleanupPlan,
+ parent_session_id: Option<&str>,
+ ) -> TargetEventPlan {
+ let session_ids = cleanup_plan
+ .session_ids()
+ .map(str::to_owned)
+ .collect::<Vec<_>>();
+ for session_id in session_ids {
+ let Some(route) = self.session_route(Some(&session_id)) else {
+ tracing::warn!(
+ session_id,
+ "closed target session no longer has an authoritative route"
+ );
+ continue;
+ };
+ let Some(disposal_plan) = SessionDisposalPlan::for_session_route(&session_id, &route)
+ else {
+ tracing::warn!(
+ session_id,
+ "closed target session does not support target disposal"
+ );
+ continue;
+ };
+ crate::domains::target::dispose_closed_session_domains_async(self, &disposal_plan)
+ .await;
+ }
+ self.commit_target_closure_session_detachment_events(cleanup_plan, parent_session_id)
+ }
+
+ fn commit_target_closure_session_detachment_events(
&mut self,
cleanup_plan: TargetClosureCleanupPlan,
parent_session_id: Option<&str>,
@@ -574,7 +766,7 @@ impl CdpConnection {
.target_control
.detach_target_closure_cleanup_event_plan(cleanup_plan, parent_session_id);
for session in plan.detached_sessions() {
- self.clear_detached_target_session_owner_state(session.session_id());
+ self.remove_detached_session_control_owner(session.session_id());
}
plan
}
@@ -604,8 +796,8 @@ impl CdpConnection {
) -> TargetEventPlan {
if let Some(cleanup_plan) = rollback_plan.cleanup_plan() {
if matches!(
- cleanup_plan.action(),
- TargetBindingCleanupAction::PageTarget {
+ cleanup_plan.target(),
+ SessionDisposalTarget::PageTarget {
session_key: moli_page_types::DevToolsSessionKey::Primary,
..
}
@@ -615,45 +807,50 @@ impl CdpConnection {
"primary Page target rollback requires async binding cleanup"
);
} else {
- self.execute_target_binding_cleanup_without_event_sync(cleanup_plan);
+ self.rollback_prepared_session_binding_sync(cleanup_plan);
}
}
self.rollback_attached_session_without_event(rollback_plan.session_id())
}
- fn execute_target_binding_cleanup_without_event_sync(
- &mut self,
- cleanup_plan: &TargetBindingCleanupPlan,
- ) {
- match cleanup_plan.action() {
- TargetBindingCleanupAction::PageTarget {
- session_key: moli_page_types::DevToolsSessionKey::Attached(_),
+ /// Removes a prepared binding before any asynchronous domain work has
+ /// started. Once a prepared session can own renderer resources, callers
+ /// must use the asynchronous SessionDisposalPlan executor instead.
+ fn rollback_prepared_session_binding_sync(&mut self, cleanup_plan: &SessionDisposalPlan) {
+ match cleanup_plan.target() {
+ SessionDisposalTarget::PageTarget {
+ target_id,
+ session_key: session_key @ moli_page_types::DevToolsSessionKey::Attached(_),
..
} => {
- if let Some(bc) = self.browser_context.as_mut() {
- let _ = bc.remove_auxiliary_session(cleanup_plan.session_id());
+ if let Some(bc) = self.session_disposal_browser_context_mut(cleanup_plan) {
+ let _ = bc.remove_page_session_binding(
+ target_id,
+ cleanup_plan.session_id(),
+ session_key,
+ );
}
}
- TargetBindingCleanupAction::TabTarget { .. } => {
+ SessionDisposalTarget::Browser => {}
+ SessionDisposalTarget::TabTarget { .. } => {
self.remove_tab_session(cleanup_plan.session_id());
}
- TargetBindingCleanupAction::SharedWorkerTarget { .. } => {
- if let Some(bc) = self.browser_context.as_mut() {
+ SessionDisposalTarget::SharedWorkerTarget { .. } => {
+ if let Some(bc) = self.session_disposal_browser_context_mut(cleanup_plan) {
let _ = bc.detach_shared_worker_target_session(cleanup_plan.session_id());
}
}
- TargetBindingCleanupAction::DedicatedWorkerTarget { .. } => {
- if let Some(bc) = self.browser_context.as_mut() {
+ SessionDisposalTarget::DedicatedWorkerTarget { .. } => {
+ if let Some(bc) = self.session_disposal_browser_context_mut(cleanup_plan) {
let _ = bc.detach_dedicated_worker_target_session(cleanup_plan.session_id());
}
}
- TargetBindingCleanupAction::ServiceWorkerTarget { .. } => {
- if let Some(bc) = self.browser_context.as_mut() {
+ SessionDisposalTarget::ServiceWorkerTarget { .. } => {
+ if let Some(bc) = self.session_disposal_browser_context_mut(cleanup_plan) {
let _ = bc.detach_service_worker_target_session(cleanup_plan.session_id());
}
}
- TargetBindingCleanupAction::None
- | TargetBindingCleanupAction::PageTarget {
+ SessionDisposalTarget::PageTarget {
session_key: moli_page_types::DevToolsSessionKey::Primary,
..
} => {}
@@ -664,37 +861,19 @@ impl CdpConnection {
&mut self,
rollback_plan: TargetAttachRollbackPlan,
) -> TargetEventPlan {
- let Some(browser_context_id) = rollback_plan.browser_context_id().map(str::to_owned) else {
- return self.rollback_attached_session_without_event(rollback_plan.session_id());
- };
- if !self
- .activate_browser_context_by_id_async(&browser_context_id)
- .await
+ if let Some(cleanup_plan) = rollback_plan.cleanup_plan()
+ && let Err(error) =
+ crate::domains::target::dispose_uncommitted_session_async(self, cleanup_plan).await
{
- return self.rollback_attached_session_without_event(rollback_plan.session_id());
- }
-
- if let Some(cleanup_plan) = rollback_plan.cleanup_plan() {
- if let Err(error) = self
- .remove_document_start_scripts_for_detached_session_async(cleanup_plan.session_id())
- .await
- {
- tracing::warn!(
- session_id = rollback_plan.session_id(),
- %error,
- "failed to remove target scripts during attach rollback"
- );
- }
- if let Err(error) = self
- .execute_target_binding_cleanup_without_event_async(cleanup_plan)
- .await
- {
- tracing::warn!(
- session_id = rollback_plan.session_id(),
- %error,
- "failed to clean prepared target binding during attach rollback"
- );
- }
+ tracing::warn!(
+ session_id = rollback_plan.session_id(),
+ %error,
+ "failed to clean prepared target binding during attach rollback"
+ );
+ // Keep both the domain binding and its control-plane route as
+ // retry authority. Dropping only the latter would make any
+ // renderer-owned state unreachable.
+ return TargetEventPlan::default();
}
self.rollback_attached_session_without_event(rollback_plan.session_id())
}
@@ -716,102 +895,102 @@ impl CdpConnection {
self.rollback_attached_session_without_event(detach_plan.session_id())
}
- pub(crate) async fn execute_target_binding_cleanup_without_event_async(
+ pub(crate) fn commit_session_disposal(
&mut self,
- cleanup_plan: &TargetBindingCleanupPlan,
+ cleanup_plan: &SessionDisposalPlan,
) -> anyhow::Result<()> {
- match cleanup_plan.action() {
- TargetBindingCleanupAction::PageTarget {
+ match cleanup_plan.target() {
+ SessionDisposalTarget::Browser => anyhow::bail!("InvalidSessionId"),
+ SessionDisposalTarget::PageTarget {
+ browser_context_id,
target_id,
- session_key: moli_page_types::DevToolsSessionKey::Primary,
- } => {
- if let Some(bc) = self.browser_context.as_mut() {
- let disposed = bc
- .dispose_primary_page_session_async(target_id, cleanup_plan.session_id())
- .await?;
- if !disposed {
- anyhow::bail!("InvalidSessionId");
- }
- }
- }
- TargetBindingCleanupAction::PageTarget {
- session_key: moli_page_types::DevToolsSessionKey::Attached(_),
- ..
+ session_key,
} => {
- if let Some(bc) = self.browser_context.as_mut() {
- let _ = bc.remove_auxiliary_session(cleanup_plan.session_id());
- }
+ let bc = self
+ .browser_context_by_id_mut(browser_context_id)
+ .ok_or_else(|| anyhow::anyhow!("InvalidSessionId"))?;
+ anyhow::ensure!(
+ bc.remove_page_session_binding(
+ target_id,
+ cleanup_plan.session_id(),
+ session_key,
+ ),
+ "InvalidSessionId"
+ );
}
- TargetBindingCleanupAction::TabTarget { .. } => {
- self.remove_tab_session(cleanup_plan.session_id());
+ SessionDisposalTarget::TabTarget { tab_target_id, .. } => {
+ let removed_target_id = self
+ .remove_tab_session(cleanup_plan.session_id())
+ .ok_or_else(|| anyhow::anyhow!("InvalidSessionId"))?;
+ anyhow::ensure!(removed_target_id == *tab_target_id, "UnknownTargetId");
}
- TargetBindingCleanupAction::SharedWorkerTarget { .. } => {
- if let Some(bc) = self.browser_context.as_mut() {
- let _ = bc.detach_shared_worker_target_session(cleanup_plan.session_id());
- }
+ SessionDisposalTarget::SharedWorkerTarget {
+ browser_context_id,
+ target_id,
+ } => {
+ let bc = self
+ .browser_context_by_id_mut(browser_context_id)
+ .ok_or_else(|| anyhow::anyhow!("InvalidSessionId"))?;
+ let removed_target_id = bc
+ .detach_shared_worker_target_session(cleanup_plan.session_id())
+ .ok_or_else(|| anyhow::anyhow!("InvalidSessionId"))?;
+ anyhow::ensure!(removed_target_id == *target_id, "UnknownTargetId");
}
- TargetBindingCleanupAction::DedicatedWorkerTarget { .. } => {
- if let Some(bc) = self.browser_context.as_mut() {
- let _ = bc.detach_dedicated_worker_target_session(cleanup_plan.session_id());
- }
+ SessionDisposalTarget::DedicatedWorkerTarget {
+ browser_context_id,
+ target_id,
+ } => {
+ let bc = self
+ .browser_context_by_id_mut(browser_context_id)
+ .ok_or_else(|| anyhow::anyhow!("InvalidSessionId"))?;
+ let removed_target_id = bc
+ .detach_dedicated_worker_target_session(cleanup_plan.session_id())
+ .ok_or_else(|| anyhow::anyhow!("InvalidSessionId"))?;
+ anyhow::ensure!(removed_target_id == *target_id, "UnknownTargetId");
}
- TargetBindingCleanupAction::ServiceWorkerTarget { .. } => {
- if let Some(bc) = self.browser_context.as_mut() {
- let _ = bc.detach_service_worker_target_session(cleanup_plan.session_id());
- }
+ SessionDisposalTarget::ServiceWorkerTarget {
+ browser_context_id,
+ target_id,
+ } => {
+ let bc = self
+ .browser_context_by_id_mut(browser_context_id)
+ .ok_or_else(|| anyhow::anyhow!("InvalidSessionId"))?;
+ let removed_target_id = bc
+ .detach_service_worker_target_session(cleanup_plan.session_id())
+ .ok_or_else(|| anyhow::anyhow!("InvalidSessionId"))?;
+ anyhow::ensure!(removed_target_id == *target_id, "UnknownTargetId");
}
- TargetBindingCleanupAction::None => {}
}
Ok(())
}
- pub(crate) async fn execute_target_binding_cleanup_for_session_without_event_async(
+ fn session_disposal_browser_context_mut(
&mut self,
- session_id: &str,
- ) -> anyhow::Result<bool> {
- let Some(route) = self.session_route(Some(session_id)) else {
- return Ok(false);
- };
- self.cancel_tracing_for_session_owner_async(Some(session_id))
- .await;
- let cleanup_plan = TargetBindingCleanupPlan::from_route(session_id, &route);
- self.execute_target_binding_cleanup_without_event_async(&cleanup_plan)
- .await?;
- Ok(true)
+ cleanup_plan: &SessionDisposalPlan,
+ ) -> Option<&mut crate::conn::BrowserContext> {
+ let browser_context_id = cleanup_plan.browser_context_id()?;
+ self.browser_context_by_id_mut(browser_context_id)
}
- pub(crate) async fn detach_session_with_binding_cleanup_event_plan_async(
+ pub(crate) fn commit_target_session_detachment_event_plan(
&mut self,
cleanup_plan: TargetSessionDetachCleanupPlan,
- ) -> anyhow::Result<TargetEventPlan> {
- let session_id = cleanup_plan.session_id().to_owned();
- let target_id = cleanup_plan.target_id().to_owned();
- let reason = cleanup_plan.reason().map(str::to_owned);
- let parent_session_id = cleanup_plan
- .parent_session_id()
- .or_else(|| {
- self.target_control
- .attached_session_owner_session_id(&session_id)
- })
- .map(str::to_owned);
- let cleaned = self
- .execute_target_binding_cleanup_for_session_without_event_async(&session_id)
- .await?;
- if !cleaned {
- anyhow::bail!("InvalidSessionId");
- }
- Ok(self.detach_known_session_event_plan(
- &target_id,
- &session_id,
- reason.as_deref(),
- parent_session_id.as_deref(),
- ))
+ ) -> TargetEventPlan {
+ self.commit_target_session_detachment_event_plan_inner(cleanup_plan, true)
}
- pub(crate) async fn detach_dedicated_worker_session_with_binding_cleanup_event_plan_async(
+ pub(crate) fn commit_target_session_detachment_after_prepared_state_delta_event_plan(
&mut self,
cleanup_plan: TargetSessionDetachCleanupPlan,
- ) -> anyhow::Result<TargetEventPlan> {
+ ) -> TargetEventPlan {
+ self.commit_target_session_detachment_event_plan_inner(cleanup_plan, false)
+ }
+
+ fn commit_target_session_detachment_event_plan_inner(
+ &mut self,
+ cleanup_plan: TargetSessionDetachCleanupPlan,
+ emit_attached_state_delta: bool,
+ ) -> TargetEventPlan {
let session_id = cleanup_plan.session_id().to_owned();
let target_id = cleanup_plan.target_id().to_owned();
let reason = cleanup_plan.reason().map(str::to_owned);
@@ -822,49 +1001,25 @@ impl CdpConnection {
.attached_session_owner_session_id(&session_id)
})
.map(str::to_owned);
- let cleaned = self
- .execute_target_binding_cleanup_for_session_without_event_async(&session_id)
- .await?;
- if !cleaned {
- anyhow::bail!("InvalidSessionId");
- }
- Ok(
+ if emit_attached_state_delta {
+ self.detach_known_session_event_plan(
+ &target_id,
+ &session_id,
+ reason.as_deref(),
+ parent_session_id.as_deref(),
+ )
+ } else {
self.detach_known_session_event_plan_with_attached_state_delta(
&target_id,
&session_id,
reason.as_deref(),
parent_session_id.as_deref(),
false,
- ),
- )
- }
-
- pub(crate) fn detach_dedicated_worker_session_after_target_removal_event_plan(
- &mut self,
- cleanup_plan: TargetSessionDetachCleanupPlan,
- ) -> TargetEventPlan {
- let parent_session_id = cleanup_plan
- .parent_session_id()
- .or_else(|| {
- self.target_control
- .attached_session_owner_session_id(cleanup_plan.session_id())
- })
- .map(str::to_owned);
- self.detach_known_session_event_plan_with_attached_state_delta(
- cleanup_plan.target_id(),
- cleanup_plan.session_id(),
- cleanup_plan.reason(),
- parent_session_id.as_deref(),
- false,
- )
+ )
+ }
}
- fn clear_detached_target_session_owner_state(&mut self, session_id: &str) {
- self.download_behavior
- .set_browser_events_enabled_for_session(Some(session_id), false);
- self.cancel_tracing_for_session_owner(Some(session_id));
- self.clear_auto_attach_owner(Some(session_id));
- self.set_service_worker_pause_on_start_owner(Some(session_id), false);
+ fn remove_detached_session_control_owner(&mut self, session_id: &str) {
self.target_control.remove_owner(Some(session_id));
}
diff --git a/moli-protocol/src/conn/target/transaction.rs b/moli-protocol/src/conn/target/transaction.rs
index 7baed267d..d4e4352db 100644
--- a/moli-protocol/src/conn/target/transaction.rs
+++ b/moli-protocol/src/conn/target/transaction.rs
@@ -182,7 +182,7 @@ impl PreparedTargetHostClosure {
pub(crate) struct TargetAttachSessionCommit {
session_id: String,
owner_session_id: Option<String>,
- route: Option<CdpSessionRoute>,
+ route: CdpSessionRoute,
auto_attached: bool,
waiting_for_debugger: bool,
}
@@ -191,13 +191,14 @@ impl TargetAttachSessionCommit {
pub(crate) fn new(
session_id: impl Into<String>,
owner_session_id: Option<String>,
+ route: CdpSessionRoute,
auto_attached: bool,
waiting_for_debugger: bool,
) -> Self {
Self {
session_id: session_id.into(),
owner_session_id,
- route: None,
+ route,
auto_attached,
waiting_for_debugger,
}
@@ -206,30 +207,39 @@ impl TargetAttachSessionCommit {
pub(crate) fn auto_attached(
session_id: impl Into<String>,
owner_session_id: Option<String>,
+ route: CdpSessionRoute,
waiting_for_debugger: bool,
) -> Self {
- Self::new(session_id, owner_session_id, true, waiting_for_debugger)
+ Self::new(
+ session_id,
+ owner_session_id,
+ route,
+ true,
+ waiting_for_debugger,
+ )
}
pub(crate) fn direct(
session_id: impl Into<String>,
owner_session_id: Option<String>,
+ route: CdpSessionRoute,
waiting_for_debugger: bool,
) -> Self {
- Self::new(session_id, owner_session_id, false, waiting_for_debugger)
- }
-
- pub(crate) fn with_route(mut self, route: Option<CdpSessionRoute>) -> Self {
- self.route = route;
- self
+ Self::new(
+ session_id,
+ owner_session_id,
+ route,
+ false,
+ waiting_for_debugger,
+ )
}
pub(crate) fn session_id(&self) -> &str {
&self.session_id
}
- pub(crate) fn route(&self) -> Option<&CdpSessionRoute> {
- self.route.as_ref()
+ pub(crate) fn route(&self) -> &CdpSessionRoute {
+ &self.route
}
#[cfg(test)]
@@ -237,9 +247,7 @@ impl TargetAttachSessionCommit {
self.waiting_for_debugger
}
- pub(crate) fn into_parts(
- self,
- ) -> (String, Option<String>, Option<CdpSessionRoute>, bool, bool) {
+ pub(crate) fn into_parts(self) -> (String, Option<String>, CdpSessionRoute, bool, bool) {
(
self.session_id,
self.owner_session_id,
@@ -294,75 +302,142 @@ impl PreparedTargetAttach {
}
#[derive(Clone, Debug, PartialEq, Eq)]
-pub(crate) struct TargetBindingCleanupPlan {
+pub(crate) struct SessionDisposalPlan {
session_id: String,
- action: TargetBindingCleanupAction,
+ target: SessionDisposalTarget,
}
-impl TargetBindingCleanupPlan {
- pub(crate) fn from_route(session_id: &str, route: &CdpSessionRoute) -> Self {
- Self {
+impl SessionDisposalPlan {
+ /// Freezes the exact binding that must remain alive while every domain
+ /// handler disables its session-owned state.
+ ///
+ /// Callers must execute the domain cleanup phase before committing this
+ /// plan's binding removal. Keeping both phases tied to one value prevents
+ /// detach paths from resolving the session again after asynchronous work.
+ pub(crate) fn for_session_route(session_id: &str, route: &CdpSessionRoute) -> Option<Self> {
+ Some(Self {
session_id: session_id.to_owned(),
- action: TargetBindingCleanupAction::from_route(route),
- }
+ target: SessionDisposalTarget::from_route(route)?,
+ })
}
pub(crate) fn session_id(&self) -> &str {
&self.session_id
}
- pub(crate) fn action(&self) -> &TargetBindingCleanupAction {
- &self.action
+ pub(crate) fn browser_context_id(&self) -> Option<&str> {
+ self.target.browser_context_id()
+ }
+
+ pub(crate) fn target(&self) -> &SessionDisposalTarget {
+ &self.target
+ }
+
+ pub(crate) fn target_id(&self) -> Option<&str> {
+ self.target.target_id()
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
-pub(crate) enum TargetBindingCleanupAction {
- None,
+pub(crate) enum SessionDisposalTarget {
+ Browser,
PageTarget {
+ browser_context_id: String,
target_id: String,
session_key: DevToolsSessionKey,
},
TabTarget {
+ browser_context_id: String,
tab_target_id: String,
},
SharedWorkerTarget {
+ browser_context_id: String,
target_id: String,
},
DedicatedWorkerTarget {
+ browser_context_id: String,
target_id: String,
},
ServiceWorkerTarget {
+ browser_context_id: String,
target_id: String,
},
}
-impl TargetBindingCleanupAction {
- fn from_route(route: &CdpSessionRoute) -> Self {
- match route {
+impl SessionDisposalTarget {
+ fn from_route(route: &CdpSessionRoute) -> Option<Self> {
+ Some(match route {
CdpSessionRoute::PageTarget {
+ browser_context_id,
target_id,
session_key,
- ..
} => Self::PageTarget {
+ browser_context_id: browser_context_id.clone(),
target_id: target_id.clone(),
session_key: session_key.clone(),
},
- CdpSessionRoute::TabTarget { tab_target_id, .. } => Self::TabTarget {
+ CdpSessionRoute::TabTarget {
+ browser_context_id,
+ tab_target_id,
+ } => Self::TabTarget {
+ browser_context_id: browser_context_id.clone(),
tab_target_id: tab_target_id.clone(),
},
- CdpSessionRoute::SharedWorkerTarget { target_id, .. } => Self::SharedWorkerTarget {
+ CdpSessionRoute::SharedWorkerTarget {
+ browser_context_id,
+ target_id,
+ } => Self::SharedWorkerTarget {
+ browser_context_id: browser_context_id.clone(),
target_id: target_id.clone(),
},
- CdpSessionRoute::DedicatedWorkerTarget { target_id, .. } => {
- Self::DedicatedWorkerTarget {
- target_id: target_id.clone(),
- }
- }
- CdpSessionRoute::ServiceWorkerTarget { target_id, .. } => Self::ServiceWorkerTarget {
+ CdpSessionRoute::DedicatedWorkerTarget {
+ browser_context_id,
+ target_id,
+ } => Self::DedicatedWorkerTarget {
+ browser_context_id: browser_context_id.clone(),
target_id: target_id.clone(),
},
- CdpSessionRoute::Browser | CdpSessionRoute::BrowserContext { .. } => Self::None,
+ CdpSessionRoute::ServiceWorkerTarget {
+ browser_context_id,
+ target_id,
+ } => Self::ServiceWorkerTarget {
+ browser_context_id: browser_context_id.clone(),
+ target_id: target_id.clone(),
+ },
+ CdpSessionRoute::Browser => Self::Browser,
+ CdpSessionRoute::BrowserContext { .. } => return None,
+ })
+ }
+
+ pub(crate) fn browser_context_id(&self) -> Option<&str> {
+ match self {
+ Self::Browser => None,
+ Self::PageTarget {
+ browser_context_id, ..
+ }
+ | Self::TabTarget {
+ browser_context_id, ..
+ }
+ | Self::SharedWorkerTarget {
+ browser_context_id, ..
+ }
+ | Self::DedicatedWorkerTarget {
+ browser_context_id, ..
+ }
+ | Self::ServiceWorkerTarget {
+ browser_context_id, ..
+ } => Some(browser_context_id),
+ }
+ }
+
+ pub(crate) fn target_id(&self) -> Option<&str> {
+ match self {
+ Self::PageTarget { target_id, .. }
+ | Self::SharedWorkerTarget { target_id, .. }
+ | Self::DedicatedWorkerTarget { target_id, .. }
+ | Self::ServiceWorkerTarget { target_id, .. } => Some(target_id),
+ Self::TabTarget { tab_target_id, .. } => Some(tab_target_id),
+ Self::Browser => None,
}
}
}
@@ -370,13 +445,12 @@ impl TargetBindingCleanupAction {
#[derive(Clone, Debug, PartialEq, Eq)]
pub(crate) struct TargetAttachRollbackPlan {
session_id: String,
- route: Option<CdpSessionRoute>,
- cleanup_plan: Option<TargetBindingCleanupPlan>,
+ cleanup_plan: Option<SessionDisposalPlan>,
}
impl TargetAttachRollbackPlan {
pub(crate) fn from_prepared_attach_session(prepared: &TargetAttachSessionCommit) -> Self {
- Self::from_session_route(prepared.session_id(), prepared.route().cloned())
+ Self::from_session_route(prepared.session_id(), Some(prepared.route().clone()))
}
pub(crate) fn from_session_route(
@@ -386,10 +460,9 @@ impl TargetAttachRollbackPlan {
let session_id = session_id.into();
let cleanup_plan = route
.as_ref()
- .map(|route| TargetBindingCleanupPlan::from_route(&session_id, route));
+ .and_then(|route| SessionDisposalPlan::for_session_route(&session_id, route));
Self {
session_id,
- route,
cleanup_plan,
}
}
@@ -398,26 +471,15 @@ impl TargetAttachRollbackPlan {
&self.session_id
}
- pub(crate) fn browser_context_id(&self) -> Option<&str> {
- self.route
- .as_ref()
- .and_then(CdpSessionRoute::browser_context_id)
- }
-
- pub(crate) fn cleanup_plan(&self) -> Option<&TargetBindingCleanupPlan> {
+ pub(crate) fn cleanup_plan(&self) -> Option<&SessionDisposalPlan> {
self.cleanup_plan.as_ref()
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub(crate) enum TargetAutoAttachedSessionDetachPlan {
- Rollback {
- session_id: String,
- },
- Detach {
- browser_context_id: String,
- cleanup_plan: TargetBindingCleanupPlan,
- },
+ Rollback { session_id: String },
+ Detach { cleanup_plan: SessionDisposalPlan },
}
impl TargetAutoAttachedSessionDetachPlan {
@@ -429,36 +491,26 @@ impl TargetAutoAttachedSessionDetachPlan {
let Some(route) = route else {
return Self::Rollback { session_id };
};
- let Some(browser_context_id) = route.browser_context_id().map(str::to_owned) else {
+ if matches!(route, CdpSessionRoute::Browser) {
return Self::Rollback { session_id };
- };
- let cleanup_plan = TargetBindingCleanupPlan::from_route(&session_id, &route);
- Self::Detach {
- browser_context_id,
- cleanup_plan,
+ }
+ match SessionDisposalPlan::for_session_route(&session_id, &route) {
+ Some(cleanup_plan) => Self::Detach { cleanup_plan },
+ None => Self::Rollback { session_id },
}
}
pub(crate) fn session_id(&self) -> &str {
match self {
Self::Rollback { session_id } => session_id,
- Self::Detach { cleanup_plan, .. } => cleanup_plan.session_id(),
+ Self::Detach { cleanup_plan } => cleanup_plan.session_id(),
}
}
- pub(crate) fn browser_context_id(&self) -> Option<&str> {
+ pub(crate) fn cleanup_plan(&self) -> Option<&SessionDisposalPlan> {
match self {
Self::Rollback { .. } => None,
- Self::Detach {
- browser_context_id, ..
- } => Some(browser_context_id),
- }
- }
-
- pub(crate) fn cleanup_plan(&self) -> Option<&TargetBindingCleanupPlan> {
- match self {
- Self::Rollback { .. } => None,
- Self::Detach { cleanup_plan, .. } => Some(cleanup_plan),
+ Self::Detach { cleanup_plan } => Some(cleanup_plan),
}
}
}
@@ -483,16 +535,16 @@ impl TargetClosureCleanupPlan {
}
}
- pub(crate) fn from_primary_and_auxiliary_sessions(
+ pub(crate) fn from_primary_and_attached_sessions(
target_id: impl Into<String>,
reason: Option<&str>,
primary_session_id: Option<String>,
- auxiliary_session_ids: Vec<String>,
+ attached_session_ids: Vec<String>,
) -> Self {
Self::new(
target_id,
reason,
- primary_session_id.into_iter().chain(auxiliary_session_ids),
+ primary_session_id.into_iter().chain(attached_session_ids),
)
}
@@ -556,10 +608,9 @@ impl TargetSessionDetachCleanupPlan {
#[cfg(test)]
mod tests {
use super::{
- PreparedTargetAttach, PreparedTargetHostDelta, TargetAttachRollbackPlan,
- TargetAttachSessionCommit, TargetAutoAttachedSessionDetachPlan, TargetBindingCleanupAction,
- TargetBindingCleanupPlan, TargetClosureCleanupPlan, TargetEventPlan,
- TargetSessionDetachCleanupPlan,
+ PreparedTargetAttach, PreparedTargetHostDelta, SessionDisposalPlan, SessionDisposalTarget,
+ TargetAttachRollbackPlan, TargetAttachSessionCommit, TargetAutoAttachedSessionDetachPlan,
+ TargetClosureCleanupPlan, TargetEventPlan, TargetSessionDetachCleanupPlan,
};
use crate::conn::CdpSessionRoute;
use crate::devtools_runtime::{DevToolsTargetId, DevToolsTargetInfo, DevToolsTargetKind};
@@ -567,8 +618,15 @@ mod tests {
#[test]
fn target_binding_cleanup_plan_maps_route_to_cleanup_action() {
+ let browser =
+ SessionDisposalPlan::for_session_route("SID-browser", &CdpSessionRoute::Browser)
+ .expect("Browser sessions require domain cleanup");
+ assert_eq!(browser.target(), &SessionDisposalTarget::Browser);
+ assert_eq!(browser.browser_context_id(), None);
+ assert_eq!(browser.target_id(), None);
+
assert_eq!(
- TargetBindingCleanupPlan::from_route(
+ SessionDisposalPlan::for_session_route(
"SID-active",
&CdpSessionRoute::PageTarget {
browser_context_id: "BID-1".to_owned(),
@@ -576,15 +634,17 @@ mod tests {
session_key: DevToolsSessionKey::Primary,
},
)
- .action(),
- &TargetBindingCleanupAction::PageTarget {
+ .expect("Page routes require binding cleanup")
+ .target(),
+ &SessionDisposalTarget::PageTarget {
+ browser_context_id: "BID-1".to_owned(),
target_id: "TID-active".to_owned(),
session_key: DevToolsSessionKey::Primary,
},
);
assert_eq!(
- TargetBindingCleanupPlan::from_route(
+ SessionDisposalPlan::for_session_route(
"SID-bg",
&CdpSessionRoute::PageTarget {
browser_context_id: "BID-1".to_owned(),
@@ -592,23 +652,27 @@ mod tests {
session_key: DevToolsSessionKey::Primary,
},
)
- .action(),
- &TargetBindingCleanupAction::PageTarget {
+ .expect("Page routes require binding cleanup")
+ .target(),
+ &SessionDisposalTarget::PageTarget {
+ browser_context_id: "BID-1".to_owned(),
target_id: "TID-bg".to_owned(),
session_key: DevToolsSessionKey::Primary,
},
);
assert_eq!(
- TargetBindingCleanupPlan::from_route(
+ SessionDisposalPlan::for_session_route(
"SID-tab",
&CdpSessionRoute::TabTarget {
browser_context_id: "BID-1".to_owned(),
tab_target_id: "TAB-TID-page".to_owned(),
},
)
- .action(),
- &TargetBindingCleanupAction::TabTarget {
+ .expect("Tab routes require binding cleanup")
+ .target(),
+ &SessionDisposalTarget::TabTarget {
+ browser_context_id: "BID-1".to_owned(),
tab_target_id: "TAB-TID-page".to_owned()
},
);
@@ -616,22 +680,22 @@ mod tests {
#[test]
fn target_closure_cleanup_plan_preserves_target_reason_and_sessions() {
- let plan = TargetClosureCleanupPlan::from_primary_and_auxiliary_sessions(
+ let plan = TargetClosureCleanupPlan::from_primary_and_attached_sessions(
"TID-page",
Some("Render process gone."),
Some("SID-primary".to_owned()),
- vec!["SID-aux".to_owned()],
+ vec!["SID-attached".to_owned()],
);
assert_eq!(plan.target_id(), "TID-page");
assert_eq!(plan.reason(), Some("Render process gone."));
assert_eq!(
plan.session_ids().collect::<Vec<_>>(),
- vec!["SID-primary", "SID-aux"]
+ vec!["SID-primary", "SID-attached"]
);
assert_eq!(
plan.into_session_ids(),
- vec!["SID-primary".to_owned(), "SID-aux".to_owned()]
+ vec!["SID-primary".to_owned(), "SID-attached".to_owned()]
);
}
@@ -668,16 +732,16 @@ mod tests {
let commit = TargetAttachSessionCommit::auto_attached(
"SID-child",
Some("SID-owner".to_owned()),
+ CdpSessionRoute::Browser,
true,
- )
- .with_route(Some(CdpSessionRoute::Browser));
+ );
assert_eq!(
commit.into_parts(),
(
"SID-child".to_owned(),
Some("SID-owner".to_owned()),
- Some(CdpSessionRoute::Browser),
+ CdpSessionRoute::Browser,
true,
true
)
@@ -702,10 +766,11 @@ mod tests {
"TID-page",
target_info.clone(),
[
- TargetAttachSessionCommit::direct("SID-1", None, false),
+ TargetAttachSessionCommit::direct("SID-1", None, CdpSessionRoute::Browser, false),
TargetAttachSessionCommit::auto_attached(
"SID-2",
Some("SID-owner".to_owned()),
+ CdpSessionRoute::Browser,
true,
),
],
@@ -721,7 +786,7 @@ mod tests {
(
"SID-2".to_owned(),
Some("SID-owner".to_owned()),
- None,
+ CdpSessionRoute::Browser,
true,
true
)
@@ -733,24 +798,25 @@ mod tests {
let prepared = TargetAttachSessionCommit::auto_attached(
"SID-worker",
Some("SID-owner".to_owned()),
+ CdpSessionRoute::SharedWorkerTarget {
+ browser_context_id: "BID-1".to_owned(),
+ target_id: "TID-worker".to_owned(),
+ },
false,
- )
- .with_route(Some(CdpSessionRoute::SharedWorkerTarget {
- browser_context_id: "BID-1".to_owned(),
- target_id: "TID-worker".to_owned(),
- }));
+ );
let rollback = TargetAttachRollbackPlan::from_prepared_attach_session(&prepared);
assert_eq!(rollback.session_id(), "SID-worker");
- assert_eq!(rollback.browser_context_id(), Some("BID-1"));
let cleanup = rollback
.cleanup_plan()
.expect("route-backed rollback should include binding cleanup");
assert_eq!(cleanup.session_id(), "SID-worker");
+ assert_eq!(cleanup.browser_context_id(), Some("BID-1"));
assert_eq!(
- cleanup.action(),
- &TargetBindingCleanupAction::SharedWorkerTarget {
+ cleanup.target(),
+ &SessionDisposalTarget::SharedWorkerTarget {
+ browser_context_id: "BID-1".to_owned(),
target_id: "TID-worker".to_owned()
}
);
@@ -767,14 +833,15 @@ mod tests {
);
assert_eq!(plan.session_id(), "SID-worker");
- assert_eq!(plan.browser_context_id(), Some("BID-1"));
let cleanup = plan
.cleanup_plan()
.expect("auto-attached worker detach should include binding cleanup");
assert_eq!(cleanup.session_id(), "SID-worker");
+ assert_eq!(cleanup.browser_context_id(), Some("BID-1"));
assert_eq!(
- cleanup.action(),
- &TargetBindingCleanupAction::SharedWorkerTarget {
+ cleanup.target(),
+ &SessionDisposalTarget::SharedWorkerTarget {
+ browser_context_id: "BID-1".to_owned(),
target_id: "TID-worker".to_owned()
}
);
@@ -786,7 +853,6 @@ mod tests {
let plan =
TargetAutoAttachedSessionDetachPlan::from_session_route("SID-browser", route);
assert_eq!(plan.session_id(), "SID-browser");
- assert_eq!(plan.browser_context_id(), None);
assert!(plan.cleanup_plan().is_none());
}
}
diff --git a/moli-protocol/src/conn/target/worker_session.rs b/moli-protocol/src/conn/target/worker_session.rs
index ccfdb460d..68e59473a 100644
--- a/moli-protocol/src/conn/target/worker_session.rs
+++ b/moli-protocol/src/conn/target/worker_session.rs
@@ -152,30 +152,6 @@ impl CdpConnection {
}
}
- /// Captures the exact renderer worker and protocol attachment addressed by
- /// `session_id`.
- ///
- /// The attachment scope lives with the SharedWorker target's per-session
- /// state. Holding this weak identity across a publication-capture boundary does
- /// not keep a normally detached session alive and cannot be rebound by a
- /// later current-session lookup.
- pub(crate) fn shared_worker_protocol_attachment_identity_for_session(
- &self,
- session_id: Option<&str>,
- ) -> Option<TargetSharedWorkerProtocolAttachmentIdentity> {
- let session_id = session_id?;
- let CdpSessionRoute::SharedWorkerTarget {
- browser_context_id,
- target_id,
- } = self.session_route(Some(session_id))?
- else {
- return None;
- };
- self.browser_context_by_id(&browser_context_id)?
- .shared_worker_target(&target_id)?
- .protocol_attachment_identity(&browser_context_id, session_id)
- }
-
pub(crate) fn shared_worker_target_for_session_mut(
&mut self,
session_id: Option<&str>,
diff --git a/moli-protocol/src/conn/tests/mod.rs b/moli-protocol/src/conn/tests/mod.rs
index 86fd078b9..1e621343d 100644
--- a/moli-protocol/src/conn/tests/mod.rs
+++ b/moli-protocol/src/conn/tests/mod.rs
@@ -591,7 +591,7 @@ fn activating_another_target_retains_pending_initial_document_engine() {
.as_mut()
.expect("browser context")
.stage_background_target(
- "TID-promoted".to_owned(),
+ "TID-activated".to_owned(),
None,
"about:blank".to_owned(),
Some("about:blank".to_owned()),
@@ -600,7 +600,7 @@ fn activating_another_target_retains_pending_initial_document_engine() {
conn.browser_context
.as_mut()
.expect("browser context")
- .set_active_target_id("TID-promoted");
+ .set_active_target_id("TID-activated");
let retained = conn
.browser_context_by_id("CTX-pending-target")
@@ -614,7 +614,7 @@ fn activating_another_target_retains_pending_initial_document_engine() {
}
#[tokio::test]
-async fn removing_active_browser_context_switches_engine_to_promoted_context() {
+async fn removing_active_browser_context_switches_engine_to_activated_context() {
let mut conn = CdpConnection::new();
let mut first = conn.new_browser_context("CTX-first".to_owned());
first.set_active_target_id("TID-first");
diff --git a/moli-protocol/src/conn/tests/resource_runtime.rs b/moli-protocol/src/conn/tests/resource_runtime.rs
index f861c8c09..01de1371d 100644
--- a/moli-protocol/src/conn/tests/resource_runtime.rs
+++ b/moli-protocol/src/conn/tests/resource_runtime.rs
@@ -1395,7 +1395,7 @@ async fn session_scoped_process_message_async_restores_previously_active_context
}
#[tokio::test]
-async fn direct_network_enable_routes_to_inactive_active_owner_without_promoting_slot() {
+async fn direct_network_enable_routes_to_inactive_active_owner_without_activating_slot() {
let mut conn = CdpConnection::new();
let mut inactive = BrowserContext::new("BID-B".into());
@@ -1414,13 +1414,13 @@ async fn direct_network_enable_routes_to_inactive_active_owner_without_promoting
);
assert!(
conn.browser_context.is_none(),
- "direct Network.enable should not promote the inactive owner into the active slot"
+ "direct Network.enable should not select the inactive browser context"
);
let inactive = conn
.inactive_browser_contexts
.iter()
.find(|bc| bc.id == "BID-B")
- .expect("inactive owner must remain parked");
+ .expect("inactive owner must remain background");
assert!(
inactive
.active_page_target()
@@ -1430,7 +1430,7 @@ async fn direct_network_enable_routes_to_inactive_active_owner_without_promoting
}
#[tokio::test]
-async fn direct_runtime_evaluate_routes_to_inactive_active_owner_without_promoting_slot() {
+async fn direct_runtime_evaluate_routes_to_inactive_active_owner_without_activating_slot() {
let mut ctx = crate::testing::TestContext::new();
let mut inactive = BrowserContext::new("BID-B".into());
@@ -1469,7 +1469,7 @@ async fn direct_runtime_evaluate_routes_to_inactive_active_owner_without_promoti
assert_eq!(response["sessionId"], json!("SID-B"));
assert!(
ctx.conn.browser_context.is_none(),
- "direct Runtime.evaluate should not promote the inactive owner into the active slot"
+ "direct Runtime.evaluate should not select the inactive browser context"
);
}
@@ -1833,7 +1833,7 @@ async fn direct_runtime_evaluate_same_document_navigation_updates_inactive_owner
.inactive_browser_contexts
.iter()
.find(|bc| bc.id == "BID-same-document")
- .expect("inactive owner should remain parked");
+ .expect("inactive owner should remain background");
assert!(
inactive.target_url().ends_with("#owner-fragment"),
"same-document navigation should update the inactive owner target URL"
@@ -1917,7 +1917,7 @@ async fn direct_runtime_evaluate_javascript_dialog_uses_inactive_background_owne
&& message["params"]["frameId"] == json!("TID-dialog-background")
&& message["params"]["result"] == json!(true)
}),
- "Page.handleJavaScriptDialog should close the owner dialog without promotion: {response:?}"
+ "Page.handleJavaScriptDialog should close the owner dialog without activation: {response:?}"
);
assert!(
response.iter().any(|message| {
@@ -1936,17 +1936,17 @@ async fn direct_runtime_evaluate_javascript_dialog_uses_inactive_background_owne
.inactive_browser_contexts
.iter()
.find(|bc| bc.id == "BID-dialog-background")
- .expect("inactive owner should remain parked");
+ .expect("inactive owner should remain background");
assert!(
inactive
.background_target("TID-dialog-background")
.filter(|target| target.has_non_default_session_state())
- .expect("background page session state should remain parked")
+ .expect("background page session state should remain background")
.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
.page_session_state
.javascript_dialog_state
.is_empty(),
- "handling the dialog should pop the parked session dialog queue"
+ "handling the dialog should pop the background session dialog queue"
);
}
@@ -2024,7 +2024,7 @@ async fn direct_runtime_evaluate_popup_creates_target_in_inactive_background_own
.inactive_browser_contexts
.iter()
.find(|bc| bc.id == "BID-popup-background")
- .expect("inactive owner should remain parked");
+ .expect("inactive owner should remain background");
assert!(
inactive
.background_target(&popup_target_id)
@@ -2172,13 +2172,13 @@ async fn direct_runtime_evaluate_file_chooser_uses_inactive_background_owner() {
}
#[tokio::test]
-async fn direct_runtime_evaluate_routes_to_inactive_auxiliary_owner_without_promoting_slot() {
+async fn direct_runtime_evaluate_routes_to_inactive_attached_owner_without_activating_slot() {
let mut ctx = crate::testing::TestContext::new();
let mut inactive = BrowserContext::new("BID-B".into());
inactive.set_active_target_id("TID-B".to_owned());
inactive.attach_active_session("SID-primary");
- assert!(inactive.assign_auxiliary_session_to_target("TID-B", "SID-aux".to_owned()));
+ assert!(inactive.assign_attached_session_to_target("TID-B", "SID-attached".to_owned()));
inactive.active_page_target_mut().devtools_sessions
[moli_page_types::DevToolsSessionKey::Primary]
.runtime_session_state
@@ -2186,7 +2186,7 @@ async fn direct_runtime_evaluate_routes_to_inactive_auxiliary_owner_without_prom
ctx.conn.inactive_browser_contexts.push(inactive);
ctx.install_navigation_fixture_for_session_owner(
"data:text/html,<!doctype html><title>runtime-direct-aux</title>",
- Some("SID-aux"),
+ Some("SID-attached"),
)
.await;
@@ -2194,7 +2194,7 @@ async fn direct_runtime_evaluate_routes_to_inactive_auxiliary_owner_without_prom
ctx.process_async(json!({
"id": 1,
"method": "Runtime.evaluate",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": {"expression": "document.title", "returnByValue": true}
}))
.await;
@@ -2209,83 +2209,83 @@ async fn direct_runtime_evaluate_routes_to_inactive_auxiliary_owner_without_prom
json!("runtime-direct-aux"),
"{response:?}"
);
- assert_eq!(response["sessionId"], json!("SID-aux"));
+ assert_eq!(response["sessionId"], json!("SID-attached"));
assert!(
ctx.conn.browser_context.is_none(),
- "direct auxiliary Runtime.evaluate should not promote the inactive owner"
+ "direct attached Runtime.evaluate should not activate the inactive owner"
);
}
#[tokio::test]
-async fn direct_network_enable_disable_routes_to_inactive_auxiliary_owner_without_promoting_slot() {
+async fn direct_network_enable_disable_routes_to_inactive_attached_owner_without_activating_slot() {
let mut conn = CdpConnection::new();
let mut inactive = BrowserContext::new("BID-B".into());
inactive.set_active_target_id("TID-B".to_owned());
inactive.attach_active_session("SID-primary");
- assert!(inactive.assign_auxiliary_session_to_target("TID-B", "SID-aux".to_owned()));
+ assert!(inactive.assign_attached_session_to_target("TID-B", "SID-attached".to_owned()));
conn.inactive_browser_contexts.push(inactive);
let response = conn
.process_message_messages_only_for_test(
- r#"{"id":1,"method":"Network.enable","sessionId":"SID-aux"}"#,
+ r#"{"id":1,"method":"Network.enable","sessionId":"SID-attached"}"#,
)
.await;
assert_eq!(
response,
- vec![json!({"id": 1, "result": {}, "sessionId": "SID-aux"})]
+ vec![json!({"id": 1, "result": {}, "sessionId": "SID-attached"})]
);
assert!(
conn.browser_context.is_none(),
- "direct auxiliary Network.enable should not promote the inactive owner"
+ "direct attached Network.enable should not activate the inactive owner"
);
let inactive = conn
.inactive_browser_contexts
.iter()
.find(|bc| bc.id == "BID-B")
- .expect("inactive owner must remain parked");
+ .expect("inactive owner must remain background");
assert!(
!inactive
.active_page_target()
.runtime_slot
.primary_network_events_enabled(),
- "auxiliary Network.enable must not enable the target's primary listener"
+ "attached Network.enable must not enable the target's primary listener"
);
assert!(
inactive
.active_page_target()
.runtime_slot
- .has_auxiliary_network_events_for_session("SID-aux")
+ .has_attached_network_events_for_session("SID-attached")
);
let response = conn
.process_message_messages_only_for_test(
- r#"{"id":2,"method":"Network.disable","sessionId":"SID-aux"}"#,
+ r#"{"id":2,"method":"Network.disable","sessionId":"SID-attached"}"#,
)
.await;
assert_eq!(
response,
- vec![json!({"id": 2, "result": {}, "sessionId": "SID-aux"})]
+ vec![json!({"id": 2, "result": {}, "sessionId": "SID-attached"})]
);
assert!(
conn.browser_context.is_none(),
- "direct auxiliary Network.disable should not promote the inactive owner"
+ "direct attached Network.disable should not activate the inactive owner"
);
let inactive = conn
.inactive_browser_contexts
.iter()
.find(|bc| bc.id == "BID-B")
- .expect("inactive owner must remain parked");
+ .expect("inactive owner must remain background");
assert!(
!inactive
.active_page_target()
.runtime_slot
- .has_auxiliary_network_events_for_session("SID-aux")
+ .has_attached_network_events_for_session("SID-attached")
);
}
#[tokio::test]
-async fn direct_page_preload_routes_to_inactive_active_owner_without_promoting_slot() {
+async fn direct_page_preload_routes_to_inactive_active_owner_without_activating_slot() {
let mut conn = CdpConnection::new();
let mut inactive = BrowserContext::new("BID-B".into());
@@ -2339,7 +2339,7 @@ async fn direct_page_preload_routes_to_inactive_active_owner_without_promoting_s
}
#[tokio::test]
-async fn direct_page_preload_routes_to_inactive_background_owner_without_promoting_slot() {
+async fn direct_page_preload_routes_to_inactive_background_owner_without_activating_slot() {
let mut conn = CdpConnection::new();
let mut inactive = BrowserContext::new("BID-B".into());
@@ -2395,7 +2395,7 @@ async fn direct_page_preload_routes_to_inactive_background_owner_without_promoti
}
#[tokio::test]
-async fn direct_network_enable_routes_to_inactive_background_owner_without_promoting_slot() {
+async fn direct_network_enable_routes_to_inactive_background_owner_without_activating_slot() {
let mut conn = CdpConnection::new();
let mut inactive = BrowserContext::new("BID-B".into());
@@ -2418,13 +2418,13 @@ async fn direct_network_enable_routes_to_inactive_background_owner_without_promo
);
assert!(
conn.browser_context.is_none(),
- "direct background Network.enable should not promote the inactive owner"
+ "direct background Network.enable should not activate the inactive owner"
);
let inactive = conn
.inactive_browser_contexts
.iter()
.find(|bc| bc.id == "BID-B")
- .expect("inactive owner must remain parked");
+ .expect("inactive owner must remain background");
assert!(
inactive
.background_target("TID-background")
@@ -2436,7 +2436,7 @@ async fn direct_network_enable_routes_to_inactive_background_owner_without_promo
}
#[tokio::test]
-async fn direct_auxiliary_network_enable_for_background_target_does_not_enable_primary_listener() {
+async fn direct_attached_network_enable_for_background_target_does_not_enable_primary_listener() {
let mut conn = CdpConnection::new();
let mut inactive = BrowserContext::new("BID-B".into());
@@ -2447,36 +2447,38 @@ async fn direct_auxiliary_network_enable_for_background_target_does_not_enable_p
TargetPageSlot::empty_for_test_fixture(),
));
assert!(
- inactive
- .assign_auxiliary_session_to_target("TID-background", "SID-aux-background".to_owned())
+ inactive.assign_attached_session_to_target(
+ "TID-background",
+ "SID-attached-background".to_owned()
+ )
);
conn.inactive_browser_contexts.push(inactive);
let response = conn
.process_message_messages_only_for_test(
- r#"{"id":1,"method":"Network.enable","sessionId":"SID-aux-background"}"#,
+ r#"{"id":1,"method":"Network.enable","sessionId":"SID-attached-background"}"#,
)
.await;
assert_eq!(
response,
- vec![json!({"id": 1, "result": {}, "sessionId": "SID-aux-background"})]
+ vec![json!({"id": 1, "result": {}, "sessionId": "SID-attached-background"})]
);
let inactive = conn
.inactive_browser_contexts
.iter()
.find(|bc| bc.id == "BID-B")
- .expect("inactive owner must remain parked");
+ .expect("inactive owner must remain background");
assert!(
inactive
.background_target("TID-background")
.filter(|target| target.has_non_default_session_state())
.is_none_or(|state| !state.runtime_slot.primary_network_events_enabled()),
- "auxiliary background Network.enable must not enable the target's primary listener"
+ "attached background Network.enable must not enable the target's primary listener"
);
}
#[tokio::test]
-async fn direct_network_enable_routes_to_active_background_owner_without_promoting_target() {
+async fn direct_network_enable_routes_to_active_background_owner_without_activating_target() {
let mut conn = CdpConnection::new();
let mut active = BrowserContext::new("BID-A".into());
@@ -2506,11 +2508,11 @@ async fn direct_network_enable_routes_to_active_background_owner_without_promoti
assert_eq!(
active.active_target_id(),
Some("TID-active"),
- "direct Network.enable should not promote the background target"
+ "direct Network.enable should not activate the background target"
);
assert!(
active.background_target("TID-background").is_some(),
- "background target should remain parked after direct session execution"
+ "background target should remain background after direct session execution"
);
assert!(
active
@@ -2616,7 +2618,7 @@ async fn direct_network_enable_for_loaded_background_owner_starts_at_network_tai
.inactive_browser_contexts
.iter()
.find(|bc| bc.id == "BID-B")
- .expect("inactive owner must remain parked");
+ .expect("inactive owner must remain background");
let runtime_slot = &inactive
.background_target("TID-background")
.expect("background network target should remain live")
@@ -2676,7 +2678,7 @@ async fn direct_background_command_does_not_emit_active_observable_output_under_
}
#[tokio::test]
-async fn direct_console_routes_to_inactive_active_owner_without_promoting_slot() {
+async fn direct_console_routes_to_inactive_active_owner_without_activating_slot() {
let mut ctx = crate::testing::TestContext::new();
let page_url = "data:text/html,<!doctype html><script>console.warn('boot warning')</script>";
let mut inactive = BrowserContext::new("BID-B".into());
@@ -2714,14 +2716,14 @@ async fn direct_console_routes_to_inactive_active_owner_without_promoting_slot()
);
assert!(
ctx.conn.browser_context.is_none(),
- "direct Console.enable should not promote the inactive owner into the active slot"
+ "direct Console.enable should not select the inactive browser context"
);
let inactive = ctx
.conn
.inactive_browser_contexts
.iter()
.find(|bc| bc.id == "BID-B")
- .expect("inactive owner must remain parked");
+ .expect("inactive owner must remain background");
assert!(
inactive.active_page_target().devtools_sessions
[moli_page_types::DevToolsSessionKey::Primary]
@@ -2751,7 +2753,7 @@ async fn direct_console_routes_to_inactive_active_owner_without_promoting_slot()
);
assert!(
ctx.conn.browser_context.is_none(),
- "direct Console.clearMessages should not promote the inactive owner"
+ "direct Console.clearMessages should not activate the inactive owner"
);
ctx.process_and_wait_for_response_async(json!({
@@ -2767,14 +2769,14 @@ async fn direct_console_routes_to_inactive_active_owner_without_promoting_slot()
);
assert!(
ctx.conn.browser_context.is_none(),
- "direct Console.disable should not promote the inactive owner"
+ "direct Console.disable should not activate the inactive owner"
);
let inactive = ctx
.conn
.inactive_browser_contexts
.iter()
.find(|bc| bc.id == "BID-B")
- .expect("inactive owner must remain parked");
+ .expect("inactive owner must remain background");
assert!(
!inactive.active_page_target().devtools_sessions
[moli_page_types::DevToolsSessionKey::Primary]
@@ -2793,7 +2795,7 @@ async fn direct_console_routes_to_inactive_active_owner_without_promoting_slot()
}
#[tokio::test]
-async fn direct_console_routes_to_inactive_background_owner_without_promoting_slot() {
+async fn direct_console_routes_to_inactive_background_owner_without_activating_slot() {
let mut conn = CdpConnection::new();
let mut inactive = BrowserContext::new("BID-B".into());
@@ -2816,13 +2818,13 @@ async fn direct_console_routes_to_inactive_background_owner_without_promoting_sl
);
assert!(
conn.browser_context.is_none(),
- "direct background Console.enable should not promote the inactive owner"
+ "direct background Console.enable should not activate the inactive owner"
);
let inactive = conn
.inactive_browser_contexts
.iter()
.find(|bc| bc.id == "BID-B")
- .expect("inactive owner must remain parked");
+ .expect("inactive owner must remain background");
assert!(
inactive
.background_target("TID-background")
@@ -2845,13 +2847,13 @@ async fn direct_console_routes_to_inactive_background_owner_without_promoting_sl
);
assert!(
conn.browser_context.is_none(),
- "direct background Console.clearMessages should not promote the inactive owner"
+ "direct background Console.clearMessages should not activate the inactive owner"
);
let inactive = conn
.inactive_browser_contexts
.iter()
.find(|bc| bc.id == "BID-B")
- .expect("inactive owner must remain parked");
+ .expect("inactive owner must remain background");
assert!(
inactive
.background_target("TID-background")
@@ -2874,13 +2876,13 @@ async fn direct_console_routes_to_inactive_background_owner_without_promoting_sl
);
assert!(
conn.browser_context.is_none(),
- "direct background Console.disable should not promote the inactive owner"
+ "direct background Console.disable should not activate the inactive owner"
);
let inactive = conn
.inactive_browser_contexts
.iter()
.find(|bc| bc.id == "BID-B")
- .expect("inactive owner must remain parked");
+ .expect("inactive owner must remain background");
assert!(
inactive
.background_target("TID-background")
@@ -2894,7 +2896,7 @@ async fn direct_console_routes_to_inactive_background_owner_without_promoting_sl
}
#[tokio::test]
-async fn direct_console_routes_to_loaded_background_owner_and_advances_parked_cursor() {
+async fn direct_console_routes_to_loaded_background_owner_and_advances_background_cursor() {
let mut ctx = crate::testing::TestContext::new();
let page_url =
"data:text/html,<!doctype html><script>console.warn('background warning')</script>";
@@ -2942,7 +2944,7 @@ async fn direct_console_routes_to_loaded_background_owner_and_advances_parked_cu
.inactive_browser_contexts
.iter()
.find(|bc| bc.id == "BID-B")
- .expect("inactive owner must remain parked");
+ .expect("inactive owner must remain background");
assert_eq!(
inactive
.background_target("TID-background")
@@ -2970,7 +2972,7 @@ async fn direct_console_routes_to_loaded_background_owner_and_advances_parked_cu
.inactive_browser_contexts
.iter()
.find(|bc| bc.id == "BID-B")
- .expect("inactive owner must remain parked");
+ .expect("inactive owner must remain background");
assert_eq!(
inactive
.background_target("TID-background")
@@ -2984,7 +2986,7 @@ async fn direct_console_routes_to_loaded_background_owner_and_advances_parked_cu
}
#[tokio::test]
-async fn direct_log_enable_routes_to_inactive_active_owner_without_promoting_slot_or_replaying_console_api()
+async fn direct_log_enable_routes_to_inactive_active_owner_without_activating_slot_or_replaying_console_api()
{
let mut conn = CdpConnection::new();
@@ -3018,13 +3020,13 @@ async fn direct_log_enable_routes_to_inactive_active_owner_without_promoting_slo
);
assert!(
conn.browser_context.is_none(),
- "direct Log.enable should not promote the inactive owner into the active slot"
+ "direct Log.enable should not select the inactive browser context"
);
let inactive = conn
.inactive_browser_contexts
.iter()
.find(|bc| bc.id == "BID-B")
- .expect("inactive owner must remain parked");
+ .expect("inactive owner must remain background");
assert!(
inactive.active_page_target().devtools_sessions
[moli_page_types::DevToolsSessionKey::Primary]
@@ -3042,7 +3044,7 @@ async fn direct_log_enable_routes_to_inactive_active_owner_without_promoting_slo
}
#[tokio::test]
-async fn direct_log_enable_routes_to_inactive_background_owner_without_promoting_slot() {
+async fn direct_log_enable_routes_to_inactive_background_owner_without_activating_slot() {
let mut conn = CdpConnection::new();
let mut inactive = BrowserContext::new("BID-B".into());
@@ -3065,13 +3067,13 @@ async fn direct_log_enable_routes_to_inactive_background_owner_without_promoting
);
assert!(
conn.browser_context.is_none(),
- "direct background Log.enable should not promote the inactive owner"
+ "direct background Log.enable should not activate the inactive owner"
);
let inactive = conn
.inactive_browser_contexts
.iter()
.find(|bc| bc.id == "BID-B")
- .expect("inactive owner must remain parked");
+ .expect("inactive owner must remain background");
assert!(
inactive
.background_target("TID-background")
@@ -3120,24 +3122,24 @@ async fn direct_log_enable_routes_to_loaded_background_owner_without_replaying_c
assert_eq!(
response,
vec![json!({"id": 1, "result": {}, "sessionId": "SID-background"})],
- "background Log.enable should not replay loaded parked target console API output"
+ "background Log.enable should not replay loaded background target console API output"
);
let inactive = conn
.inactive_browser_contexts
.iter()
.find(|bc| bc.id == "BID-B")
- .expect("inactive owner must remain parked");
+ .expect("inactive owner must remain background");
assert_eq!(
inactive
.background_target("TID-background")
.filter(|target| target.has_non_default_session_state())
- .expect("parked session state")
+ .expect("background session state")
.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
.console_output_session_state
.log_lifecycle_entries,
0,
- "console API output should not advance the parked session's Log cursor"
+ "console API output should not advance the background session's Log cursor"
);
let response = conn
@@ -3153,7 +3155,7 @@ async fn direct_log_enable_routes_to_loaded_background_owner_without_replaying_c
}
#[tokio::test]
-async fn direct_log_disable_routes_to_inactive_active_owner_without_promoting_slot() {
+async fn direct_log_disable_routes_to_inactive_active_owner_without_activating_slot() {
let mut ctx = crate::testing::TestContext::new();
let page_url = "data:text/html,<!doctype html><script>console.warn('boot warning')</script>";
let mut inactive = BrowserContext::new("BID-B".into());
@@ -3181,14 +3183,14 @@ async fn direct_log_disable_routes_to_inactive_active_owner_without_promoting_sl
);
assert!(
ctx.conn.browser_context.is_none(),
- "direct Log.disable should not promote the inactive owner into the active slot"
+ "direct Log.disable should not select the inactive browser context"
);
let inactive = ctx
.conn
.inactive_browser_contexts
.iter()
.find(|bc| bc.id == "BID-B")
- .expect("inactive owner must remain parked");
+ .expect("inactive owner must remain background");
assert!(
!inactive.active_page_target().devtools_sessions
[moli_page_types::DevToolsSessionKey::Primary]
@@ -3206,7 +3208,7 @@ async fn direct_log_disable_routes_to_inactive_active_owner_without_promoting_sl
}
#[tokio::test]
-async fn direct_log_disable_routes_to_inactive_background_owner_without_promoting_slot() {
+async fn direct_log_disable_routes_to_inactive_background_owner_without_activating_slot() {
let mut conn = CdpConnection::new();
let mut inactive = BrowserContext::new("BID-B".into());
@@ -3235,13 +3237,13 @@ async fn direct_log_disable_routes_to_inactive_background_owner_without_promotin
);
assert!(
conn.browser_context.is_none(),
- "direct background Log.disable should not promote the inactive owner"
+ "direct background Log.disable should not activate the inactive owner"
);
let inactive = conn
.inactive_browser_contexts
.iter()
.find(|bc| bc.id == "BID-B")
- .expect("inactive owner must remain parked");
+ .expect("inactive owner must remain background");
assert!(
inactive
.background_target("TID-background")
@@ -3255,7 +3257,7 @@ async fn direct_log_disable_routes_to_inactive_background_owner_without_promotin
}
#[tokio::test]
-async fn direct_network_policy_routes_to_inactive_active_owner_without_promoting_slot() {
+async fn direct_network_policy_routes_to_inactive_active_owner_without_activating_slot() {
let mut conn = CdpConnection::new();
let mut inactive = BrowserContext::new("BID-B".into());
@@ -3284,7 +3286,7 @@ async fn direct_network_policy_routes_to_inactive_active_owner_without_promoting
);
assert!(
conn.browser_context.is_none(),
- "direct Network policy commands should not promote the inactive owner"
+ "direct Network policy commands should not activate the inactive owner"
);
}
@@ -3292,7 +3294,7 @@ async fn direct_network_policy_routes_to_inactive_active_owner_without_promoting
.inactive_browser_contexts
.iter()
.find(|bc| bc.id == "BID-B")
- .expect("inactive owner must remain parked");
+ .expect("inactive owner must remain background");
assert!(
inactive
.active_page_target()
@@ -3364,7 +3366,7 @@ async fn direct_network_policy_routes_to_inactive_active_owner_without_promoting
}
#[tokio::test]
-async fn direct_network_policy_invalid_params_return_owner_plan_error_without_promoting_slot() {
+async fn direct_network_policy_invalid_params_return_owner_plan_error_without_activating_slot() {
let mut conn = CdpConnection::new();
let mut inactive = BrowserContext::new("BID-B".into());
@@ -3392,7 +3394,7 @@ async fn direct_network_policy_invalid_params_return_owner_plan_error_without_pr
);
assert!(
conn.browser_context.is_none(),
- "invalid direct Network policy commands should not promote the inactive owner"
+ "invalid direct Network policy commands should not activate the inactive owner"
);
}
@@ -3400,7 +3402,7 @@ async fn direct_network_policy_invalid_params_return_owner_plan_error_without_pr
.inactive_browser_contexts
.iter()
.find(|bc| bc.id == "BID-B")
- .expect("inactive owner must remain parked");
+ .expect("inactive owner must remain background");
assert!(
!inactive
.active_page_target()
@@ -3418,7 +3420,7 @@ async fn direct_network_policy_invalid_params_return_owner_plan_error_without_pr
}
#[tokio::test]
-async fn direct_network_policy_routes_to_inactive_background_owner_without_promoting_slot() {
+async fn direct_network_policy_routes_to_inactive_background_owner_without_activating_slot() {
let mut conn = CdpConnection::new();
let mut inactive = BrowserContext::new("BID-B".into());
@@ -3451,7 +3453,7 @@ async fn direct_network_policy_routes_to_inactive_background_owner_without_promo
);
assert!(
conn.browser_context.is_none(),
- "direct background Network policy commands should not promote the inactive owner"
+ "direct background Network policy commands should not activate the inactive owner"
);
}
@@ -3459,7 +3461,7 @@ async fn direct_network_policy_routes_to_inactive_background_owner_without_promo
.inactive_browser_contexts
.iter()
.find(|bc| bc.id == "BID-B")
- .expect("inactive owner must remain parked");
+ .expect("inactive owner must remain background");
let staged = inactive
.background_target("TID-background")
.filter(|target| target.has_non_default_session_state())
diff --git a/moli-protocol/src/domains/accessibility/tests.rs b/moli-protocol/src/domains/accessibility/tests.rs
index 12c016663..0b69ff08a 100644
--- a/moli-protocol/src/domains/accessibility/tests.rs
+++ b/moli-protocol/src/domains/accessibility/tests.rs
@@ -410,7 +410,7 @@ fn renderer_backed_ax_node_id(node: &Value) -> String {
}
#[tokio::test(flavor = "multi_thread")]
-async fn accessibility_loaded_page_methods_target_background_owner_without_promotion() {
+async fn accessibility_loaded_page_methods_target_background_owner_without_activation() {
let mut ctx = TestContext::new();
let background = PageTargetHost::with_url(
"TID-background".to_owned(),
diff --git a/moli-protocol/src/domains/activity/output_ingress/renderer.rs b/moli-protocol/src/domains/activity/output_ingress/renderer.rs
index 59cc37d5f..8a202db83 100644
--- a/moli-protocol/src/domains/activity/output_ingress/renderer.rs
+++ b/moli-protocol/src/domains/activity/output_ingress/renderer.rs
@@ -185,7 +185,7 @@ async fn project_renderer_output_records_for_owner(
match item {
RendererOutputItem::OwnerAction(action) => {
// A Page stream can remain bound to its implicit primary owner while a
- // Runtime command arrives through an auxiliary DevTools session. Owner
+ // Runtime command arrives through an attached DevTools session. Owner
// actions caused by that command (notably modal dialogs) belong to the
// exact inspector attachment, not merely to the stream's base route.
// Asynchronous actions have no command cause; an unbound stream then
@@ -265,7 +265,7 @@ mod tests {
let mut browser_context = BrowserContext::new("BID-owner-action".to_owned());
browser_context.set_active_target_id("TID-owner-action".to_owned());
assert!(
- browser_context.assign_auxiliary_session_to_target(
+ browser_context.assign_attached_session_to_target(
"TID-owner-action",
"SID-owner-action".to_owned(),
)
diff --git a/moli-protocol/src/domains/audits.rs b/moli-protocol/src/domains/audits.rs
index 777c729ef..00a9ac0f2 100644
--- a/moli-protocol/src/domains/audits.rs
+++ b/moli-protocol/src/domains/audits.rs
@@ -228,7 +228,7 @@ mod tests {
.browser_context
.as_mut()
.expect("Audits fixture should retain its browser context")
- .assign_auxiliary_session_to_target("TID-audits", "SID-audits-peer".to_owned())
+ .assign_attached_session_to_target("TID-audits", "SID-audits-peer".to_owned())
);
for (id, session_id) in [(1, "SID-audits"), (2, "SID-audits-peer")] {
diff --git a/moli-protocol/src/domains/css.rs b/moli-protocol/src/domains/css.rs
index 7dbabf0d1..0e3d9256c 100644
--- a/moli-protocol/src/domains/css.rs
+++ b/moli-protocol/src/domains/css.rs
@@ -1008,7 +1008,7 @@ mod tests {
}
#[tokio::test(flavor = "multi_thread")]
- async fn css_loaded_page_methods_target_background_owner_without_promotion() {
+ async fn css_loaded_page_methods_target_background_owner_without_activation() {
let mut ctx = TestContext::new();
let background = PageTargetHost::with_url(
"TID-background".to_owned(),
diff --git a/moli-protocol/src/domains/debugger.rs b/moli-protocol/src/domains/debugger.rs
index 341c15b60..e6bfc5227 100644
--- a/moli-protocol/src/domains/debugger.rs
+++ b/moli-protocol/src/domains/debugger.rs
@@ -398,25 +398,27 @@ mod tests {
}
#[tokio::test]
- async fn debugger_paused_auxiliary_session_detach_wakes_owner() {
+ async fn debugger_paused_attached_session_detach_wakes_owner() {
let mut ctx = TestContext::new();
with_loaded_document(&mut ctx).await;
{
let browser_context = ctx.conn.browser_context.as_mut().expect("browser context");
browser_context.attach_active_session("SID-debugger-primary");
- assert!(
- browser_context.assign_auxiliary_session_to_target(
- "TID-debugger",
- "SID-debugger-aux".to_owned(),
- )
- );
+ assert!(browser_context.assign_attached_session_to_target(
+ "TID-debugger",
+ "SID-debugger-attached".to_owned(),
+ ));
}
+ ctx.conn
+ .register_bound_session_for_test("SID-debugger-primary");
+ ctx.conn
+ .register_bound_session_for_test("SID-debugger-attached");
let enable = command(
&mut ctx,
json!({
"id": 41,
- "sessionId": "SID-debugger-aux",
+ "sessionId": "SID-debugger-attached",
"method": "Debugger.enable"
}),
41,
@@ -427,7 +429,7 @@ mod tests {
&mut ctx,
json!({
"id": 42,
- "sessionId": "SID-debugger-aux",
+ "sessionId": "SID-debugger-attached",
"method": "Runtime.evaluate",
"params": {
"expression": "setTimeout(() => { debugger; globalThis.__afterDebuggerDetach = 1; }, 50); true"
@@ -438,9 +440,9 @@ mod tests {
.await;
assert_eq!(timer["result"]["result"]["value"], json!(true));
- ctx.wait_for_scheduler_message("auxiliary Debugger.paused", |message| {
+ ctx.wait_for_scheduler_message("attached Debugger.paused", |message| {
message["method"] == json!("Debugger.paused")
- && message["sessionId"] == json!("SID-debugger-aux")
+ && message["sessionId"] == json!("SID-debugger-attached")
})
.await;
@@ -453,7 +455,7 @@ mod tests {
"method": "Target.detachFromTarget",
"params": {
"targetId": "TID-debugger",
- "sessionId": "SID-debugger-aux"
+ "sessionId": "SID-debugger-attached"
}
}),
43,
@@ -484,15 +486,17 @@ mod tests {
{
let browser_context = ctx.conn.browser_context.as_mut().expect("browser context");
browser_context.attach_active_session("SID-debugger-primary");
- assert!(
- browser_context.assign_auxiliary_session_to_target(
- "TID-debugger",
- "SID-debugger-aux".to_owned(),
- )
- );
+ assert!(browser_context.assign_attached_session_to_target(
+ "TID-debugger",
+ "SID-debugger-attached".to_owned(),
+ ));
}
+ ctx.conn
+ .register_bound_session_for_test("SID-debugger-primary");
+ ctx.conn
+ .register_bound_session_for_test("SID-debugger-attached");
- for (id, session_id) in [(61, "SID-debugger-primary"), (62, "SID-debugger-aux")] {
+ for (id, session_id) in [(61, "SID-debugger-primary"), (62, "SID-debugger-attached")] {
let enable = command(
&mut ctx,
json!({
@@ -518,7 +522,7 @@ mod tests {
.await;
assert_eq!(timer["result"]["result"]["value"], json!(true));
- for session_id in ["SID-debugger-primary", "SID-debugger-aux"] {
+ for session_id in ["SID-debugger-primary", "SID-debugger-attached"] {
ctx.wait_for_scheduler_message("multi-session Debugger.paused", |message| {
message["method"] == json!("Debugger.paused")
&& message["sessionId"] == json!(session_id)
@@ -537,7 +541,7 @@ mod tests {
)
.await;
assert_eq!(resume["result"], json!({}), "{resume:?}");
- for session_id in ["SID-debugger-primary", "SID-debugger-aux"] {
+ for session_id in ["SID-debugger-primary", "SID-debugger-attached"] {
ctx.wait_for_scheduler_message("multi-session Debugger.resumed", |message| {
message["method"] == json!("Debugger.resumed")
&& message["sessionId"] == json!(session_id)
diff --git a/moli-protocol/src/domains/dom/tests/frames.rs b/moli-protocol/src/domains/dom/tests/frames.rs
index 6caa10fa1..900209bf5 100644
--- a/moli-protocol/src/domains/dom/tests/frames.rs
+++ b/moli-protocol/src/domains/dom/tests/frames.rs
@@ -3766,7 +3766,7 @@ async fn child_frame_describe_node_uses_the_calling_sessions_whitespace_projecti
.await;
let all_session_id = take_response_by_id(&mut ctx, 3)["result"]["sessionId"]
.as_str()
- .expect("auxiliary session id")
+ .expect("attached session id")
.to_owned();
ctx.sent.clear();
@@ -3837,7 +3837,7 @@ async fn child_frame_describe_node_uses_the_calling_sessions_whitespace_projecti
);
assert!(
whitespace_text_node_count(&all_result.node) > 0,
- "the auxiliary session's includeWhitespace=all mode must reach the child-frame root \
+ "the attached session's includeWhitespace=all mode must reach the child-frame root \
snapshot: {all_result:?}"
);
assert_eq!(
@@ -3902,13 +3902,13 @@ async fn child_frame_get_outer_html_preserves_session_and_shadow_inclusion() {
"params": { "targetId": "TID-1" }
}))
.await;
- let auxiliary_session_id = take_response_by_id(&mut ctx, 3)["result"]["sessionId"]
+ let attached_session_id = take_response_by_id(&mut ctx, 3)["result"]["sessionId"]
.as_str()
- .expect("auxiliary session id")
+ .expect("attached session id")
.to_owned();
let cdp_context = DevToolsCommandContext {
protocol: DevToolsProtocol::Cdp,
- session_id: Some(DevToolsSessionId::from(auxiliary_session_id.as_str())),
+ session_id: Some(DevToolsSessionId::from(attached_session_id.as_str())),
target_id: Some(DevToolsTargetId::from(child_frame_id.as_str())),
browser_context_id: None,
};
@@ -3924,7 +3924,7 @@ async fn child_frame_get_outer_html_preserves_session_and_shadow_inclusion() {
.await
.into_parts()
.0
- .expect("auxiliary-session child document describe should run");
+ .expect("attached-session child document describe should run");
let DevToolsCommandResult::DescribeNode(described) = described else {
panic!("expected child describe result");
};
@@ -3933,7 +3933,7 @@ async fn child_frame_get_outer_html_preserves_session_and_shadow_inclusion() {
let host_node_id = host["nodeId"]
.as_u64()
.and_then(|id| u32::try_from(id).ok())
- .expect("auxiliary-session child frontend node id");
+ .expect("attached-session child frontend node id");
let host_backend_node_id = host["backendNodeId"]
.as_u64()
.and_then(|id| u32::try_from(id).ok())
diff --git a/moli-protocol/src/domains/dom/tests/geometry.rs b/moli-protocol/src/domains/dom/tests/geometry.rs
index c935ce563..8d1c9ac39 100644
--- a/moli-protocol/src/domains/dom/tests/geometry.rs
+++ b/moli-protocol/src/domains/dom/tests/geometry.rs
@@ -37,7 +37,7 @@ async fn renderer_backend_node_id_for_live_expression(
}
#[tokio::test(flavor = "multi_thread")]
-async fn dom_resolve_geometry_and_mutation_target_loaded_background_owner_without_promotion() {
+async fn dom_resolve_geometry_and_mutation_target_loaded_background_owner_without_activation() {
let mut ctx = TestContext::new();
let background_url = url::Url::parse("https://background.test/owned").unwrap();
let background = PageTargetHost::with_url(
diff --git a/moli-protocol/src/domains/dom/tests/misc.rs b/moli-protocol/src/domains/dom/tests/misc.rs
index 38fc4dc1a..b77745149 100644
--- a/moli-protocol/src/domains/dom/tests/misc.rs
+++ b/moli-protocol/src/domains/dom/tests/misc.rs
@@ -211,7 +211,7 @@ async fn dom_enable_include_whitespace_controls_inspector_tree_projection() {
}
#[tokio::test(flavor = "multi_thread")]
-async fn dom_document_reads_target_loaded_background_owner_without_promotion() {
+async fn dom_document_reads_target_loaded_background_owner_without_activation() {
let mut ctx = TestContext::new();
let background = PageTargetHost::with_url(
"TID-background".to_owned(),
diff --git a/moli-protocol/src/domains/dom/tests/node_ops.rs b/moli-protocol/src/domains/dom/tests/node_ops.rs
index e71490bc8..3277e38b7 100644
--- a/moli-protocol/src/domains/dom/tests/node_ops.rs
+++ b/moli-protocol/src/domains/dom/tests/node_ops.rs
@@ -747,14 +747,14 @@ async fn dom_mutations_are_projected_from_each_sessions_requested_tree_depth() {
"params": { "targetId": "TID-1" }
}))
.await;
- let auxiliary_session_id = take_response_by_id(&mut ctx, 2)["result"]["sessionId"]
+ let attached_session_id = take_response_by_id(&mut ctx, 2)["result"]["sessionId"]
.as_str()
- .expect("auxiliary session id")
+ .expect("attached session id")
.to_owned();
- assert_ne!(auxiliary_session_id, "SID-primary");
+ assert_ne!(attached_session_id, "SID-primary");
ctx.sent.clear();
- for (id, session_id) in [(3, "SID-primary"), (4, auxiliary_session_id.as_str())] {
+ for (id, session_id) in [(3, "SID-primary"), (4, attached_session_id.as_str())] {
ctx.process_async(json!({
"id": id,
"sessionId": session_id,
@@ -781,15 +781,15 @@ async fn dom_mutations_are_projected_from_each_sessions_requested_tree_depth() {
ctx.process_async(json!({
"id": 6,
- "sessionId": auxiliary_session_id,
+ "sessionId": attached_session_id,
"method": "DOM.getDocument",
"params": { "depth": -1 }
}))
.await;
- let auxiliary_root = take_response_by_id(&mut ctx, 6)["result"]["root"].clone();
- let auxiliary_html_id = find_cdp_node_by_local_name(&auxiliary_root, "html")
+ let attached_root = take_response_by_id(&mut ctx, 6)["result"]["root"].clone();
+ let attached_html_id = find_cdp_node_by_local_name(&attached_root, "html")
.and_then(|node| node["nodeId"].as_u64())
- .expect("auxiliary html node id");
+ .expect("attached html node id");
ctx.sent.clear();
ctx.process_async(json!({
@@ -811,9 +811,9 @@ async fn dom_mutations_are_projected_from_each_sessions_requested_tree_depth() {
&& message["params"]["childNodeCount"] == json!(3)
}));
assert!(messages.iter().any(|message| {
- message["sessionId"] == json!(auxiliary_session_id)
+ message["sessionId"] == json!(attached_session_id)
&& message["method"] == json!("DOM.childNodeInserted")
- && message["params"]["parentNodeId"] == json!(auxiliary_html_id)
+ && message["params"]["parentNodeId"] == json!(attached_html_id)
&& message["params"]["node"]["localName"] == json!("aside")
}));
assert!(!messages.iter().any(|message| {
@@ -823,7 +823,7 @@ async fn dom_mutations_are_projected_from_each_sessions_requested_tree_depth() {
ctx.process_async(json!({
"id": 8,
- "sessionId": auxiliary_session_id,
+ "sessionId": attached_session_id,
"method": "DOM.disable"
}))
.await;
@@ -848,7 +848,7 @@ async fn dom_mutations_are_projected_from_each_sessions_requested_tree_depth() {
assert!(
!messages
.iter()
- .any(|message| message["sessionId"] == json!(auxiliary_session_id))
+ .any(|message| message["sessionId"] == json!(attached_session_id))
);
}
@@ -2474,7 +2474,7 @@ async fn hidden_whitespace_nodes_keep_backend_identity_without_default_frontend_
.await;
let all_session_id = take_response_by_id(&mut ctx, 2)["result"]["sessionId"]
.as_str()
- .expect("auxiliary session id")
+ .expect("attached session id")
.to_owned();
ctx.sent.clear();
diff --git a/moli-protocol/src/domains/dom/tests/search.rs b/moli-protocol/src/domains/dom/tests/search.rs
index 4ea2f3808..a1088883c 100644
--- a/moli-protocol/src/domains/dom/tests/search.rs
+++ b/moli-protocol/src/domains/dom/tests/search.rs
@@ -266,7 +266,7 @@ async fn search_results_keep_hidden_whitespace_positions_session_local() {
.await;
let all_session_id = take_response_by_id(&mut ctx, 90)["result"]["sessionId"]
.as_str()
- .expect("auxiliary session id")
+ .expect("attached session id")
.to_owned();
ctx.sent.clear();
@@ -471,7 +471,7 @@ async fn perform_search_selectors_cover_all_frame_documents_and_author_shadow_ro
}
#[tokio::test(flavor = "multi_thread")]
-async fn dom_search_targets_loaded_background_owner_without_promotion() {
+async fn dom_search_targets_loaded_background_owner_without_activation() {
let mut ctx = TestContext::new();
let background = PageTargetHost::with_url(
"TID-background".to_owned(),
diff --git a/moli-protocol/src/domains/dom/tests/stack_traces.rs b/moli-protocol/src/domains/dom/tests/stack_traces.rs
index 371782e2a..508056663 100644
--- a/moli-protocol/src/domains/dom/tests/stack_traces.rs
+++ b/moli-protocol/src/domains/dom/tests/stack_traces.rs
@@ -186,14 +186,14 @@ async fn node_creation_stack_capture_is_session_local() {
"params": { "targetId": "TID-1" }
}))
.await;
- let auxiliary_session_id = take_response_by_id(&mut ctx, 21)["result"]["sessionId"]
+ let attached_session_id = take_response_by_id(&mut ctx, 21)["result"]["sessionId"]
.as_str()
- .expect("auxiliary session id")
+ .expect("attached session id")
.to_owned();
for (id, session_id) in [
(22, "SID-stack-primary"),
- (23, auxiliary_session_id.as_str()),
+ (23, attached_session_id.as_str()),
] {
ctx.process_async(json!({
"id": id,
@@ -204,7 +204,7 @@ async fn node_creation_stack_capture_is_session_local() {
let _ = take_response_by_id(&mut ctx, id);
}
let primary_root = document_root_node_id(&mut ctx, 24, Some("SID-stack-primary")).await;
- let auxiliary_root = document_root_node_id(&mut ctx, 25, Some(&auxiliary_session_id)).await;
+ let attached_root = document_root_node_id(&mut ctx, 25, Some(&attached_session_id)).await;
set_capture(&mut ctx, 26, Some("SID-stack-primary"), true).await;
ctx.process_async(json!({
@@ -227,11 +227,11 @@ async fn node_creation_stack_capture_is_session_local() {
"#primary-only",
)
.await;
- let auxiliary_node = query_node_id(
+ let attached_node = query_node_id(
&mut ctx,
29,
- Some(&auxiliary_session_id),
- auxiliary_root,
+ Some(&attached_session_id),
+ attached_root,
"#primary-only",
)
.await;
@@ -247,7 +247,7 @@ async fn node_creation_stack_capture_is_session_local() {
.is_some_and(|frames| !frames.is_empty())
);
assert_eq!(
- creation_stack(&mut ctx, 31, Some(&auxiliary_session_id), auxiliary_node).await,
+ creation_stack(&mut ctx, 31, Some(&attached_session_id), attached_node).await,
json!({}),
"a peer session must not inherit another session's capture switch"
);
diff --git a/moli-protocol/src/domains/dom_debugger.rs b/moli-protocol/src/domains/dom_debugger.rs
index 4fa546686..e5406d0dc 100644
--- a/moli-protocol/src/domains/dom_debugger.rs
+++ b/moli-protocol/src/domains/dom_debugger.rs
@@ -1554,7 +1554,7 @@ mod tests {
.await;
{
let browser_context = ctx.conn.browser_context.as_mut().expect("browser context");
- assert!(browser_context.assign_auxiliary_session_to_target(
+ assert!(browser_context.assign_attached_session_to_target(
"TID-1",
"SID-event-breakpoint-owner".to_owned(),
));
@@ -1757,7 +1757,7 @@ mod tests {
{
let browser_context = ctx.conn.browser_context.as_mut().expect("browser context");
- assert!(browser_context.assign_auxiliary_session_to_target(
+ assert!(browser_context.assign_attached_session_to_target(
"TID-1",
"SID-event-breakpoint-owner".to_owned(),
));
@@ -2068,10 +2068,12 @@ mod tests {
load_document(&mut ctx, "<!doctype html><title>XHR owner</title>").await;
{
let browser_context = ctx.conn.browser_context.as_mut().expect("browser context");
- assert!(browser_context.assign_auxiliary_session_to_target(
- "TID-1",
- "SID-xhr-breakpoint-owner".to_owned(),
- ));
+ assert!(
+ browser_context.assign_attached_session_to_target(
+ "TID-1",
+ "SID-xhr-breakpoint-owner".to_owned(),
+ )
+ );
}
let primary_enable = command(
@@ -2214,10 +2216,12 @@ mod tests {
{
let browser_context = ctx.conn.browser_context.as_mut().expect("browser context");
- assert!(browser_context.assign_auxiliary_session_to_target(
- "TID-1",
- "SID-xhr-breakpoint-owner".to_owned(),
- ));
+ assert!(
+ browser_context.assign_attached_session_to_target(
+ "TID-1",
+ "SID-xhr-breakpoint-owner".to_owned(),
+ )
+ );
}
let reattached_enable = command(
&mut ctx,
diff --git a/moli-protocol/src/domains/dom_snapshot.rs b/moli-protocol/src/domains/dom_snapshot.rs
index 83b042c89..efd158332 100644
--- a/moli-protocol/src/domains/dom_snapshot.rs
+++ b/moli-protocol/src/domains/dom_snapshot.rs
@@ -1016,7 +1016,7 @@ mod tests {
}
#[tokio::test(flavor = "multi_thread")]
- async fn capture_snapshot_targets_loaded_background_owner_without_promotion() {
+ async fn capture_snapshot_targets_loaded_background_owner_without_activation() {
let mut ctx = TestContext::new();
let page = ctx
.conn
diff --git a/moli-protocol/src/domains/dom_storage/tests.rs b/moli-protocol/src/domains/dom_storage/tests.rs
index 03ffde750..1723534ad 100644
--- a/moli-protocol/src/domains/dom_storage/tests.rs
+++ b/moli-protocol/src/domains/dom_storage/tests.rs
@@ -543,7 +543,7 @@ async fn dom_storage_resolves_child_frame_storage_ids_without_collapsing_to_top_
}
#[tokio::test(flavor = "multi_thread")]
-async fn dom_storage_mutations_fan_out_to_enabled_primary_and_auxiliary_sessions() {
+async fn dom_storage_mutations_fan_out_to_enabled_primary_and_attached_sessions() {
let (mut ctx, _page_url, _origin, server) = loaded_dom_storage_context().await;
ctx.process_async(json!({
@@ -562,16 +562,16 @@ async fn dom_storage_mutations_fan_out_to_enabled_primary_and_auxiliary_sessions
"params": { "targetId": "TID-DOM-STORAGE" }
}))
.await;
- let auxiliary_session_id = take_result_by_id(&mut ctx, 31)["sessionId"]
+ let attached_session_id = take_result_by_id(&mut ctx, 31)["sessionId"]
.as_str()
- .expect("auxiliary target session id")
+ .expect("attached target session id")
.to_owned();
- assert_ne!(primary_session_id, auxiliary_session_id);
+ assert_ne!(primary_session_id, attached_session_id);
ctx.sent.clear();
for (id, session_id) in [
(32, primary_session_id.as_str()),
- (33, auxiliary_session_id.as_str()),
+ (33, attached_session_id.as_str()),
] {
ctx.process_async(json!({
"id": id,
@@ -603,7 +603,7 @@ async fn dom_storage_mutations_fan_out_to_enabled_primary_and_auxiliary_sessions
.filter_map(|message| message["sessionId"].as_str().map(str::to_owned))
.collect::<Vec<_>>();
event_session_ids.sort();
- let mut expected_session_ids = vec![primary_session_id, auxiliary_session_id];
+ let mut expected_session_ids = vec![primary_session_id, attached_session_id];
expected_session_ids.sort();
assert_eq!(event_session_ids, expected_session_ids);
diff --git a/moli-protocol/src/domains/emulation.rs b/moli-protocol/src/domains/emulation.rs
index 6836589a8..e5faad50c 100644
--- a/moli-protocol/src/domains/emulation.rs
+++ b/moli-protocol/src/domains/emulation.rs
@@ -46,7 +46,7 @@ pub(crate) struct CompletedEmulationCommandDispatch {
enum PendingEmulationRendererDispatch {
Pages(Vec<PendingEmulationPageCommand>),
- IoCommandReply(PendingDevToolsIoCommandDispatch),
+ IoAdapterReply(PendingDevToolsIoCommandDispatch),
IoSessionOutput {
pending: PendingDevToolsIoCommandDispatch,
correlation: RendererCommandCorrelation,
@@ -55,7 +55,7 @@ enum PendingEmulationRendererDispatch {
enum CompletedEmulationRendererDispatch {
Pages(Vec<CompletedEmulationPageCommand>),
- IoCommandReply(Result<CompletedDevToolsIoCommandDispatch, String>),
+ IoAdapterReply(Result<CompletedDevToolsIoCommandDispatch, String>),
IoSessionOutput {
completed: Result<CompletedDevToolsIoCommandDispatch, String>,
correlation: RendererCommandCorrelation,
@@ -155,8 +155,8 @@ impl PendingEmulationCommandDispatch {
}
CompletedEmulationRendererDispatch::Pages(completed)
}
- PendingEmulationRendererDispatch::IoCommandReply(pending) => {
- CompletedEmulationRendererDispatch::IoCommandReply(
+ PendingEmulationRendererDispatch::IoAdapterReply(pending) => {
+ CompletedEmulationRendererDispatch::IoAdapterReply(
pending.wait().await.map_err(|error| error.to_string()),
)
}
@@ -389,11 +389,9 @@ fn start_script_execution_disabled_command(
};
let renderer_inspector_session_id =
conn.target_renderer_runtime_inspector_session_id_for_session(cmd.session_id);
- let response_delivery = cmd.terminal_response_delivery(
- moli_page_types::RendererInspectorResponseDelivery::DevToolsSession,
- );
+ let response_delivery = cmd.terminal_response_delivery();
if cmd.id.is_none()
- || response_delivery == moli_page_types::RendererInspectorResponseDelivery::CommandReply
+ || response_delivery == moli_page_types::RendererInspectorResponseDelivery::AdapterReply
{
let page = loaded_page_mut_for_target_configuration(conn, cmd.session_id)
.expect("the captured Emulation Page must remain loaded synchronously");
@@ -401,7 +399,7 @@ fn start_script_execution_disabled_command(
return EmulationCommandTaskStep::Pending(PendingEmulationCommandDispatch {
command_id: cmd.id,
session_id: cmd.session_id.map(str::to_owned),
- pending: PendingEmulationRendererDispatch::IoCommandReply(pending),
+ pending: PendingEmulationRendererDispatch::IoAdapterReply(pending),
});
}
let command_id = cmd
@@ -427,7 +425,7 @@ fn start_script_execution_disabled_command(
let (correlation, response, response_rx) = prepared.into_parts();
debug_assert!(
response_rx.is_none(),
- "Emulation session output must not allocate a command-reply receiver",
+ "Emulation session output must not allocate an adapter-reply receiver",
);
let pending = loaded_page_mut_for_target_configuration(conn, cmd.session_id)
.filter(|page| page.renderer_agent_attachment_id() == Some(attachment_id))
@@ -2445,7 +2443,7 @@ pub(crate) fn complete_pending_emulation_command(
let session_id = completed.session_id.clone();
let completed_pages = match completed.completed {
CompletedEmulationRendererDispatch::Pages(completed_pages) => completed_pages,
- CompletedEmulationRendererDispatch::IoCommandReply(completed) => {
+ CompletedEmulationRendererDispatch::IoAdapterReply(completed) => {
return match completed {
Ok(CompletedDevToolsIoCommandDispatch::Dispatched) => {
CommandOutputPlan::result(json!({}))
@@ -2453,7 +2451,7 @@ pub(crate) fn complete_pending_emulation_command(
Ok(CompletedDevToolsIoCommandDispatch::SessionResponse { .. }) => {
CommandOutputPlan::error(
-32000,
- "command-reply Emulation dispatch used session output",
+ "adapter-reply Emulation dispatch used session output",
)
}
Err(error) => CommandOutputPlan::error(-32000, error),
@@ -2581,36 +2579,62 @@ fn loaded_page_mut_for_target_configuration<'a>(
.ok()
}
-pub(crate) async fn clear_emulated_media_for_detached_session_async(
+pub(crate) async fn dispose_page_session_async(
conn: &mut CdpConnection,
session_id: &str,
) -> anyhow::Result<()> {
- // Chromium's InspectorEmulationAgent::disable clears media overrides even
- // though the resulting settings are observable by every session on the
- // target. Match that contract when detach preserves the loaded page.
- let overrides = crate::conn::EmulatedMediaOverrides::default();
- let mut changed = false;
+ let mut first_error = conn
+ .clear_devtools_emulation_session_policy_async(session_id)
+ .await
+ .err();
+
+ // InspectorEmulationAgent::disable resets media and CPU throttling for
+ // every renderer session, even though both settings are target-visible.
+ // Keep that intentionally non-aggregated Chromium behavior here.
+ let media = crate::conn::EmulatedMediaOverrides::default();
+ let mut media_changed = false;
+ let mut cpu_changed = false;
if !conn.mutate_emulation_session_state_for_session_owner(Some(session_id), |state| {
if let Some(state) = state {
- changed = *state.emulated_media != overrides;
- *state.emulated_media = overrides.clone();
+ media_changed = *state.emulated_media != media;
+ cpu_changed = *state.cpu_throttling_rate != 1.0;
+ *state.emulated_media = media.clone();
+ *state.cpu_throttling_rate = 1.0;
}
}) {
- return Ok(());
+ return match first_error {
+ Some(error) => Err(error),
+ None => Ok(()),
+ };
}
- if !changed {
- return Ok(());
+ if !media_changed && !cpu_changed {
+ return match first_error {
+ Some(error) => Err(error),
+ None => Ok(()),
+ };
}
- let page_overrides: moli_core::page::EmulatedMediaOverrides = (&overrides).into();
+ let page_media: moli_core::page::EmulatedMediaOverrides = (&media).into();
let Some(page) = loaded_page_mut_for_target_configuration(conn, Some(session_id)) else {
- return Ok(());
+ return match first_error {
+ Some(error) => Err(error),
+ None => Ok(()),
+ };
};
- page.set_emulated_media_async(&page_overrides)
- .await
- .map_err(|error| {
+ if media_changed && let Err(error) = page.set_emulated_media_async(&page_media).await {
+ first_error.get_or_insert_with(|| {
anyhow::anyhow!("failed to clear detached session emulated media: {error}")
- })
+ });
+ }
+ if cpu_changed && let Err(error) = page.set_cpu_throttling_rate_async(1.0).await {
+ first_error.get_or_insert_with(|| {
+ anyhow::anyhow!("failed to clear detached session CPU throttling: {error}")
+ });
+ }
+ match first_error {
+ Some(error) => Err(error),
+ None => Ok(()),
+ }
}
fn single_pending_emulation_dispatch(
diff --git a/moli-protocol/src/domains/emulation/tests.rs b/moli-protocol/src/domains/emulation/tests.rs
index 3b364e4a0..38ab18334 100644
--- a/moli-protocol/src/domains/emulation/tests.rs
+++ b/moli-protocol/src/domains/emulation/tests.rs
@@ -59,8 +59,10 @@ fn install_multi_session_page_state(ctx: &mut TestContext) {
let mut browser_context = BrowserContext::new("BID-1".into());
browser_context.set_active_target_id("TID-1");
browser_context.attach_active_session("SID-primary");
- assert!(browser_context.assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned()));
+ assert!(browser_context.assign_attached_session_to_target("TID-1", "SID-attached".to_owned()));
ctx.conn.browser_context = Some(browser_context);
+ ctx.conn.register_bound_session_for_test("SID-primary");
+ ctx.conn.register_bound_session_for_test("SID-attached");
}
async fn expect_session_command_result(
@@ -262,7 +264,7 @@ async fn script_execution_disabled_completes_through_io_pending_dispatch() {
}
#[tokio::test(flavor = "multi_thread")]
-async fn auxiliary_session_first_io_emulation_response_uses_its_session_host() {
+async fn attached_session_first_io_emulation_response_uses_its_session_host() {
let mut ctx = TestContext::new();
load_session_page_for_pending_emulation_test(&mut ctx).await;
assert!(
@@ -270,22 +272,27 @@ async fn auxiliary_session_first_io_emulation_response_uses_its_session_host() {
.browser_context
.as_mut()
.expect("browser context")
- .assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned())
+ .assign_attached_session_to_target("TID-1", "SID-attached".to_owned())
+ );
+ let owner = crate::conn::CommandOwnerScope::for_route(
+ ctx.conn
+ .bound_session_route_for_test("SID-attached", Some("TID-1"))
+ .expect("attached test session must own its Page route"),
);
ctx.conn
- .apply_runtime_binding_state_for_session_owner_async(Some("SID-aux"))
+ .apply_runtime_binding_state_for_owner_async(&owner)
.await
- .expect("target attachment should establish the auxiliary renderer session");
+ .expect("target attachment should establish the attached renderer session");
ctx.process_async(json!({
"id": 9_111,
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"method": "Emulation.setScriptExecutionDisabled",
"params": { "value": true }
}))
.await;
- ctx.expect_result(9_111, json!({}), Some("SID-aux"));
+ ctx.expect_result(9_111, json!({}), Some("SID-attached"));
assert!(
ctx.conn
.browser_context
@@ -1083,7 +1090,7 @@ async fn multi_session_locale_and_timezone_claims_match_chromium() {
expect_session_command_error(
&mut ctx,
70_002,
- "SID-aux",
+ "SID-attached",
LOCALE,
json!({ "locale": "de-DE" }),
"Another locale override is already in effect",
@@ -1102,7 +1109,7 @@ async fn multi_session_locale_and_timezone_claims_match_chromium() {
expect_session_command_error(
&mut ctx,
70_004,
- "SID-aux",
+ "SID-attached",
TIMEZONE,
json!({ "timezoneId": "America/New_York" }),
"Timezone override is already in effect",
@@ -1111,7 +1118,7 @@ async fn multi_session_locale_and_timezone_claims_match_chromium() {
expect_session_command_result(
&mut ctx,
70_005,
- "SID-aux",
+ "SID-attached",
TIMEZONE,
json!({ "timezoneId": "" }),
)
@@ -1141,7 +1148,7 @@ async fn multi_session_browser_identity_uses_attachment_order_and_field_contribu
install_multi_session_page_state(&mut ctx);
for (id, method, session_id, user_agent) in [
- (71_001, EMULATION_UA, "SID-aux", "Moli/Aux-1"),
+ (71_001, EMULATION_UA, "SID-attached", "Moli/Aux-1"),
(71_002, NETWORK_UA, "SID-primary", "Moli/Primary-1"),
(71_003, EMULATION_UA, "SID-primary", "Moli/Primary-2"),
] {
@@ -1181,7 +1188,7 @@ async fn multi_session_browser_identity_uses_attachment_order_and_field_contribu
expect_session_command_result(
&mut ctx,
71_004,
- "SID-aux",
+ "SID-attached",
NETWORK_UA,
json!({ "userAgent": "" }),
)
@@ -1201,7 +1208,7 @@ async fn multi_session_browser_identity_uses_attachment_order_and_field_contribu
expect_session_command_result(
&mut ctx,
71_005,
- "SID-aux",
+ "SID-attached",
EMULATION_UA,
json!({
"userAgent": "",
@@ -1227,12 +1234,19 @@ async fn multi_session_browser_identity_uses_attachment_order_and_field_contribu
expect_session_command_result(
&mut ctx,
71_006,
- "SID-aux",
+ "SID-attached",
NETWORK_UA,
json!({ "userAgent": "Moli/Aux-2" }),
)
.await;
- expect_session_command_result(&mut ctx, 71_007, "SID-aux", "Network.disable", json!({})).await;
+ expect_session_command_result(
+ &mut ctx,
+ 71_007,
+ "SID-attached",
+ "Network.disable",
+ json!({}),
+ )
+ .await;
assert_eq!(
ctx.conn
.browser_context
@@ -1247,9 +1261,9 @@ async fn multi_session_browser_identity_uses_attachment_order_and_field_contribu
);
ctx.conn
- .clear_target_session_overrides_async("SID-aux")
+ .clear_devtools_emulation_session_policy_async("SID-attached")
.await
- .expect("detaching the auxiliary session should restore the previous UA");
+ .expect("detaching the attached session should restore the previous UA");
assert_eq!(
ctx.conn
.browser_context
@@ -2707,7 +2721,7 @@ async fn locale_and_timezone_overrides_apply_to_locale_date_formatting() {
}
#[tokio::test(flavor = "multi_thread")]
-async fn context_emulated_media_applies_to_loaded_background_page_without_promotion() {
+async fn context_emulated_media_applies_to_loaded_background_page_without_activation() {
let mut ctx = TestContext::new();
let background = PageTargetHost::new(
"TID-background".to_owned(),
@@ -2778,12 +2792,12 @@ async fn context_emulated_media_applies_to_loaded_background_page_without_promot
.as_ref()
.and_then(|browser_context| browser_context.active_target_id()),
Some("TID-active"),
- "context-wide overrides should not promote the loaded background target"
+ "context-wide overrides should not activate the loaded background target"
);
}
#[tokio::test(flavor = "multi_thread")]
-async fn context_locale_override_applies_to_loaded_background_page_without_promotion() {
+async fn context_locale_override_applies_to_loaded_background_page_without_activation() {
let mut ctx = TestContext::new();
let background = PageTargetHost::new(
"TID-background".to_owned(),
@@ -2847,7 +2861,7 @@ async fn context_locale_override_applies_to_loaded_background_page_without_promo
assert_eq!(
browser_context.active_target_id(),
Some("TID-active"),
- "context-wide overrides should not promote the loaded background target"
+ "context-wide overrides should not activate the loaded background target"
);
assert_eq!(
browser_context
@@ -2867,12 +2881,12 @@ async fn context_locale_override_applies_to_loaded_background_page_without_promo
.map(str::to_owned)
})
.is_none(),
- "context-wide locale remains browser-context state, not parked session state"
+ "context-wide locale remains browser-context state, not background session state"
);
}
#[tokio::test(flavor = "multi_thread")]
-async fn session_emulation_routes_to_loaded_background_owner_without_promotion() {
+async fn session_emulation_routes_to_loaded_background_owner_without_activation() {
let mut ctx = TestContext::new();
let background = PageTargetHost::new(
"TID-background".to_owned(),
@@ -2940,7 +2954,7 @@ async fn session_emulation_routes_to_loaded_background_owner_without_promotion()
.as_ref()
.and_then(|browser_context| browser_context.active_target_id()),
Some("TID-active"),
- "session-scoped Emulation should not promote the loaded background target"
+ "session-scoped Emulation should not activate the loaded background target"
);
ctx.process_async(json!({
@@ -2990,14 +3004,20 @@ async fn session_emulation_routes_to_loaded_background_owner_without_promotion()
.is_none(),
"background Emulation should not mutate the active target locale override"
);
- let parked = browser_context
+ let background = browser_context
.background_target("TID-background")
.filter(|target| target.has_non_default_session_state())
- .expect("background parked state");
- assert_eq!(parked.emulated_media.color_scheme.as_deref(), Some("dark"));
- assert_eq!(parked.effective_policy().locale_override(), Some("zh-CN"));
+ .expect("background target state");
assert_eq!(
- parked
+ background.emulated_media.color_scheme.as_deref(),
+ Some("dark")
+ );
+ assert_eq!(
+ background.effective_policy().locale_override(),
+ Some("zh-CN")
+ );
+ assert_eq!(
+ background
.geolocation_override
.as_ref()
.and_then(EmulatedGeolocationOverrideState::position)
@@ -3138,7 +3158,7 @@ async fn generated_surface_refresh_does_not_freeze_match_media_override() {
}
#[tokio::test(flavor = "multi_thread")]
-async fn target_session_detach_clears_emulated_media_before_reattach() {
+async fn target_session_detach_disposes_non_aggregated_emulation_state_before_reattach() {
let mut ctx = TestContext::new();
let mut bc = BrowserContext::new("BID-1".into());
bc.set_active_target_id("TID-1");
@@ -3160,6 +3180,15 @@ async fn target_session_detach_clears_emulated_media_before_reattach() {
.to_owned();
let _ = ctx.take_all();
+ ctx.process_async(json!({
+ "id": 1901,
+ "method": "Emulation.setCPUThrottlingRate",
+ "sessionId": session_id,
+ "params": { "rate": 4 }
+ }))
+ .await;
+ ctx.expect_result(1901, json!({}), Some(&session_id));
+
ctx.process_async(json!({
"id": 191,
"method": "Emulation.setEmulatedMedia",
@@ -3181,6 +3210,17 @@ async fn target_session_detach_clears_emulated_media_before_reattach() {
.await;
ctx.expect_result(192, json!({}), None);
let _ = ctx.take_all();
+ let target = ctx
+ .conn
+ .browser_context
+ .as_ref()
+ .and_then(|browser_context| browser_context.page_target("TID-1"))
+ .expect("detached target remains addressable");
+ assert_eq!(target.cpu_throttling_rate, 1.0);
+ assert_eq!(
+ target.emulated_media,
+ crate::conn::EmulatedMediaOverrides::default()
+ );
ctx.process_async(json!({
"id": 193,
@@ -3212,16 +3252,16 @@ async fn target_session_detach_clears_emulated_media_before_reattach() {
"params": { "targetId": "TID-1", "flatten": true }
}))
.await;
- let auxiliary_session_id = ctx.take_response_by_id(195)["result"]["sessionId"]
+ let attached_session_id = ctx.take_response_by_id(195)["result"]["sessionId"]
.as_str()
- .expect("auxiliary target session id")
+ .expect("attached target session id")
.to_owned();
let _ = ctx.take_all();
ctx.process_async(json!({
"id": 196,
"method": "Emulation.setEmulatedMedia",
- "sessionId": auxiliary_session_id,
+ "sessionId": attached_session_id,
"params": {
"features": [
{ "name": "prefers-color-scheme", "value": "dark" }
@@ -3229,7 +3269,7 @@ async fn target_session_detach_clears_emulated_media_before_reattach() {
}
}))
.await;
- ctx.expect_result(196, json!({}), Some(&auxiliary_session_id));
+ ctx.expect_result(196, json!({}), Some(&attached_session_id));
ctx.process_async(json!({
"id": 197,
@@ -3246,7 +3286,7 @@ async fn target_session_detach_clears_emulated_media_before_reattach() {
ctx.process_async(json!({
"id": 198,
"method": "Target.detachFromTarget",
- "params": { "sessionId": auxiliary_session_id }
+ "params": { "sessionId": attached_session_id }
}))
.await;
ctx.expect_result(198, json!({}), None);
diff --git a/moli-protocol/src/domains/fetch.rs b/moli-protocol/src/domains/fetch.rs
index 9e479c143..5855abecf 100644
--- a/moli-protocol/src/domains/fetch.rs
+++ b/moli-protocol/src/domains/fetch.rs
@@ -19,7 +19,7 @@ use crate::devtools_runtime::{
};
use crate::domains::actions::FetchAction;
use crate::domains::command_output::{CommandOutputPlan, devtools_error_from_cdp_error_parts};
-use crate::domains::{activity, network};
+use crate::domains::{activity, network, page};
use serde_json::json;
#[cfg(test)]
@@ -54,6 +54,86 @@ pub(crate) use subresource::{
subresource_fetch_pause_prepared_outputs_for_renderer_record_async,
};
+/// Disables the Fetch handler owned by one DevTools session and drains every
+/// request that was paused by that handler before its binding is removed.
+pub(in crate::domains) async fn dispose_session_async(
+ conn: &mut CdpConnection,
+ out: &mut Vec<BackgroundProtocolEvent>,
+ session_id: &str,
+) -> anyhow::Result<Option<moli_core::RendererOutputFence>> {
+ dispose_owner_async(conn, out, Some(session_id)).await
+}
+
+pub(in crate::domains) async fn dispose_owner_async(
+ conn: &mut CdpConnection,
+ out: &mut Vec<BackgroundProtocolEvent>,
+ session_id: Option<&str>,
+) -> anyhow::Result<Option<moli_core::RendererOutputFence>> {
+ let Some((pending_fetch_state, pending_page_command)) = conn
+ .start_disable_fetch_for_session_owner(session_id)
+ .map_err(anyhow::Error::msg)?
+ else {
+ return Ok(None);
+ };
+
+ let mut renderer_cleanup_error = None;
+ if let Some(pending_page_command) = pending_page_command {
+ match pending_page_command.wait().await {
+ Ok(completion) => match conn.loaded_page_mut_for_protocol_access(session_id) {
+ Ok(page) => {
+ if let Err(error) = page.finish_set_fetch_subresource_interception(completion) {
+ renderer_cleanup_error = Some(error.context(
+ "failed to finish Fetch interception disable while disposing session",
+ ));
+ }
+ }
+ Err(message) if message == "NoDocumentLoaded" => {}
+ Err(message) => {
+ renderer_cleanup_error = Some(anyhow::anyhow!(
+ "failed to find Page while disposing Fetch handler: {message}"
+ ));
+ }
+ },
+ Err(error) => {
+ renderer_cleanup_error =
+ Some(error.context(
+ "renderer failed Fetch interception disable while disposing session",
+ ));
+ }
+ }
+ }
+
+ let (
+ pending_navigations,
+ pending_auth_navigations,
+ pending_response_navigations,
+ pending_subresource_fetches,
+ pending_subresource_auths,
+ pending_subresource_responses,
+ ) = pending_fetch_state;
+ // Session teardown has no command response to fence. The concrete
+ // renderer publication remains ordered on its own stream and will reach
+ // protocol ingress independently.
+ let predecessor = page::fail_pending_fetch_state_background_events_async(
+ conn,
+ out,
+ session_id,
+ "Target detached",
+ "Target detached",
+ pending_navigations,
+ pending_auth_navigations,
+ pending_response_navigations,
+ pending_subresource_fetches,
+ pending_subresource_auths,
+ pending_subresource_responses,
+ )
+ .await;
+ if let Some(error) = renderer_cleanup_error {
+ return Err(error);
+ }
+ Ok(predecessor)
+}
+
pub(crate) struct PendingFetchCommandDispatch {
command_id: Option<u64>,
owner_scope: CommandOwnerScope,
diff --git a/moli-protocol/src/domains/fetch/commands.rs b/moli-protocol/src/domains/fetch/commands.rs
index 323e75911..07fa5b823 100644
--- a/moli-protocol/src/domains/fetch/commands.rs
+++ b/moli-protocol/src/domains/fetch/commands.rs
@@ -2036,7 +2036,8 @@ mod protocol_neutral_tests {
browser_context.set_active_target_id("TID-chain".to_owned());
browser_context.attach_active_session("SID-primary".to_owned());
assert!(
- browser_context.assign_auxiliary_session_to_target("TID-chain", "SID-aux".to_owned())
+ browser_context
+ .assign_attached_session_to_target("TID-chain", "SID-attached".to_owned())
);
browser_context
.active_page_target_mut()
@@ -2066,7 +2067,7 @@ mod protocol_neutral_tests {
body: None,
request_cookie_report: None,
remaining_sessions: vec![PendingSubresourceFetchRequestStage {
- session_id: Some("SID-aux".to_owned()),
+ session_id: Some("SID-attached".to_owned()),
owner_kind: PendingSubresourceFetchOwnerKind::Fetch,
request_id: "FETCH-aux".to_owned(),
blocked_intercepts: Vec::new(),
@@ -2136,7 +2137,7 @@ mod protocol_neutral_tests {
assert_eq!(out[0]["sessionId"], json!("SID-primary"));
assert_eq!(out[1]["method"], json!("Fetch.requestPaused"));
assert_eq!(paused_message, out[1]);
- assert_eq!(out[1]["sessionId"], json!("SID-aux"));
+ assert_eq!(out[1]["sessionId"], json!("SID-attached"));
assert_eq!(out[1]["params"]["requestId"], json!("FETCH-aux"));
assert_eq!(out[1]["params"]["networkId"], json!("NETWORK-77"));
assert_eq!(
@@ -2156,7 +2157,10 @@ mod protocol_neutral_tests {
"old owner must not be able to consume the chained request"
);
let chained = conn
- .take_pending_subresource_fetch_request_for_session_owner(Some("SID-aux"), "FETCH-aux")
+ .take_pending_subresource_fetch_request_for_session_owner(
+ Some("SID-attached"),
+ "FETCH-aux",
+ )
.expect("next Fetch session should own the chained request");
let (url, method, body, headers) =
chained.accumulated_request_stage_continue_modifications();
@@ -2177,7 +2181,7 @@ mod protocol_neutral_tests {
browser_context.attach_active_session("SID-primary".to_owned());
assert!(
browser_context
- .assign_auxiliary_session_to_target("TID-response-chain", "SID-aux".to_owned())
+ .assign_attached_session_to_target("TID-response-chain", "SID-attached".to_owned())
);
browser_context
.active_page_target_mut()
@@ -2212,7 +2216,7 @@ mod protocol_neutral_tests {
response_body: CapturedBody::from_bytes(br#"{"ok":true}"#.to_vec()),
response_stage_chain: Some(Box::new(PendingSubresourceFetchResponseStageChain {
remaining_sessions: vec![PendingSubresourceFetchResponseStage {
- session_id: Some("SID-aux".to_owned()),
+ session_id: Some("SID-attached".to_owned()),
owner_kind: PendingSubresourceFetchOwnerKind::Fetch,
request_id: "FETCH-response-aux".to_owned(),
blocked_intercepts: Vec::new(),
@@ -2279,7 +2283,7 @@ mod protocol_neutral_tests {
assert_eq!(out[0]["sessionId"], json!("SID-primary"));
assert_eq!(out[1]["method"], json!("Fetch.requestPaused"));
assert_eq!(paused_message, out[1]);
- assert_eq!(out[1]["sessionId"], json!("SID-aux"));
+ assert_eq!(out[1]["sessionId"], json!("SID-attached"));
assert_eq!(out[1]["params"]["requestId"], json!("FETCH-response-aux"));
assert_eq!(out[1]["params"]["networkId"], json!("NETWORK-79"));
assert_eq!(out[1]["params"]["responseStatusCode"], json!(200));
@@ -2299,13 +2303,13 @@ mod protocol_neutral_tests {
);
let chained = conn
.take_pending_subresource_fetch_response_request_for_owner(
- &crate::conn::CommandOwnerScope::for_session("SID-aux"),
- Some("SID-aux"),
+ &crate::conn::CommandOwnerScope::for_session("SID-attached"),
+ Some("SID-attached"),
"FETCH-response-aux",
)
.expect("next Fetch session should own the chained response");
- assert_eq!(chained.owner_session_id.as_deref(), Some("SID-aux"));
- assert_eq!(chained.action_session_id.as_deref(), Some("SID-aux"));
+ assert_eq!(chained.owner_session_id.as_deref(), Some("SID-attached"));
+ assert_eq!(chained.action_session_id.as_deref(), Some("SID-attached"));
assert_eq!(chained.response_status, 200);
}
diff --git a/moli-protocol/src/domains/fetch/tests/basics.rs b/moli-protocol/src/domains/fetch/tests/basics.rs
index 15d173743..c0335b926 100644
--- a/moli-protocol/src/domains/fetch/tests/basics.rs
+++ b/moli-protocol/src/domains/fetch/tests/basics.rs
@@ -87,7 +87,7 @@ fn pending_subresource_fetch_auth(
fn pending_subresource_auth_required_event_carries_typed_sidecar() {
let pending = pending_subresource_fetch_auth(7, "SID-primary");
let event = pending_subresource_auth_required_event(
- Some("SID-aux"),
+ Some("SID-attached"),
"FETCH-7",
&pending,
&[DevToolsNetworkInterceptId::from("intercept-auth")],
@@ -96,7 +96,7 @@ fn pending_subresource_auth_required_event_carries_typed_sidecar() {
let (message, sidecar) = event.into_parts();
assert_eq!(message["method"], "Fetch.authRequired");
- assert_eq!(message["sessionId"], "SID-aux");
+ assert_eq!(message["sessionId"], "SID-attached");
assert_eq!(message["params"]["requestId"], "FETCH-7");
assert!(message["params"].get("networkId").is_none());
assert_eq!(message["params"]["authChallenge"]["realm"], "private");
@@ -153,7 +153,7 @@ async fn enable_and_disable_are_session_local_for_same_target() {
let mut bc = BrowserContext::new("BID-session-fetch".into());
bc.set_active_target_id("TID-session-fetch".to_owned());
bc.attach_active_session("SID-primary".to_owned());
- assert!(bc.assign_auxiliary_session_to_target("TID-session-fetch", "SID-aux".to_owned()));
+ assert!(bc.assign_attached_session_to_target("TID-session-fetch", "SID-attached".to_owned()));
ctx.conn.browser_context = Some(bc);
ctx.process_async(json!({
@@ -171,13 +171,13 @@ async fn enable_and_disable_are_session_local_for_same_target() {
ctx.process_async(json!({
"id": 211,
"method": "Fetch.enable",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": {
"patterns": [{ "urlPattern": "*aux*", "requestStage": "Response", "resourceType": "XHR" }]
}
}))
.await;
- ctx.expect_result(211, json!({}), Some("SID-aux"));
+ ctx.expect_result(211, json!({}), Some("SID-attached"));
{
let bc = ctx.conn.browser_context.as_ref().expect("browser context");
@@ -198,7 +198,7 @@ async fn enable_and_disable_are_session_local_for_same_target() {
let aux = bc
.active_page_target()
.fetch_owner
- .config_snapshot_for_session(Some("SID-aux"));
+ .config_snapshot_for_session(Some("SID-attached"));
assert!(aux.is_enabled());
assert!(!aux.handle_auth_requests());
assert_eq!(aux.patterns().len(), 1);
@@ -228,7 +228,7 @@ async fn enable_and_disable_are_session_local_for_same_target() {
assert!(
bc.active_page_target()
.fetch_owner
- .config_snapshot_for_session(Some("SID-aux"))
+ .config_snapshot_for_session(Some("SID-attached"))
.is_enabled()
);
assert_eq!(
@@ -245,7 +245,7 @@ async fn disable_drains_only_current_session_pending_subresource_fetches() {
let mut bc = BrowserContext::new("BID-session-fetch-pending".into());
bc.set_active_target_id("TID-session-fetch".to_owned());
bc.attach_active_session("SID-primary".to_owned());
- assert!(bc.assign_auxiliary_session_to_target("TID-session-fetch", "SID-aux".to_owned()));
+ assert!(bc.assign_attached_session_to_target("TID-session-fetch", "SID-attached".to_owned()));
ctx.conn.browser_context = Some(bc);
ctx.process_async(json!({
@@ -262,13 +262,13 @@ async fn disable_drains_only_current_session_pending_subresource_fetches() {
ctx.process_async(json!({
"id": 221,
"method": "Fetch.enable",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": {
"patterns": [{ "urlPattern": "*aux*", "requestStage": "Request", "resourceType": "Fetch" }]
}
}))
.await;
- ctx.expect_result(221, json!({}), Some("SID-aux"));
+ ctx.expect_result(221, json!({}), Some("SID-attached"));
{
let fetch_owner = &mut ctx
@@ -284,7 +284,7 @@ async fn disable_drains_only_current_session_pending_subresource_fetches() {
);
fetch_owner.register_pending_subresource_fetch_request(
"FETCH-aux".to_owned(),
- pending_subresource_fetch(2201, "SID-aux"),
+ pending_subresource_fetch(2201, "SID-attached"),
);
}
@@ -307,9 +307,9 @@ async fn disable_drains_only_current_session_pending_subresource_fetches() {
assert!(fetch_owner.has_pending_fetch_request_id_for_test("FETCH-aux"));
assert!(
fetch_owner
- .take_pending_subresource_fetch_request("FETCH-aux", Some("SID-aux"))
+ .take_pending_subresource_fetch_request("FETCH-aux", Some("SID-attached"))
.is_some(),
- "Fetch.disable for primary must not clear auxiliary session pending requests"
+ "Fetch.disable for primary must not clear attached session pending requests"
);
}
@@ -396,7 +396,7 @@ async fn disable_drains_fetch_owned_pending_when_same_session_network_intercept_
}
#[tokio::test(flavor = "multi_thread")]
-async fn enable_targets_loaded_background_owner_without_promotion() {
+async fn enable_targets_loaded_background_owner_without_activation() {
let mut ctx = TestContext::new();
let background = PageTargetHost::with_url(
"TID-background".to_owned(),
@@ -515,7 +515,7 @@ async fn pending_fetch_enable_keeps_background_owner_route_across_completion() {
let staged = bc
.background_target("TID-fetch-background")
.filter(|target| target.has_non_default_session_state())
- .expect("background fetch config should stay parked");
+ .expect("background fetch config should stay background");
assert!(staged.fetch_owner.config_snapshot().is_enabled());
assert_eq!(staged.fetch_owner.config_snapshot().patterns().len(), 1);
assert_eq!(
@@ -588,7 +588,7 @@ async fn enable_targets_inactive_owner_without_activation() {
}
#[tokio::test(flavor = "multi_thread")]
-async fn disable_targets_loaded_background_owner_without_promotion() {
+async fn disable_targets_loaded_background_owner_without_activation() {
let mut ctx = TestContext::new();
let background = PageTargetHost::with_url(
"TID-background".to_owned(),
diff --git a/moli-protocol/src/domains/fetch/tests/navigation_auth.rs b/moli-protocol/src/domains/fetch/tests/navigation_auth.rs
index c0966649f..c29fe1304 100644
--- a/moli-protocol/src/domains/fetch/tests/navigation_auth.rs
+++ b/moli-protocol/src/domains/fetch/tests/navigation_auth.rs
@@ -847,7 +847,7 @@ async fn run_navigation_cdp_fetch_then_bidi_network_auth_required_terminal(
let mut ctx = TestContext::new();
let mut bc = attached_browser_context();
- assert!(bc.assign_auxiliary_session_to_target("TID-1", "SID-fetch".to_owned()));
+ assert!(bc.assign_attached_session_to_target("TID-1", "SID-fetch".to_owned()));
bc.active_page_target_mut()
.runtime_slot
.enable_primary_network_events();
@@ -956,7 +956,7 @@ async fn run_navigation_cdp_fetch_then_bidi_network_auth_required_terminal(
}))
.await;
- let paused = ctx.take_first_matching("auxiliary navigation Fetch.requestPaused", |message| {
+ let paused = ctx.take_first_matching("attached navigation Fetch.requestPaused", |message| {
message["method"] == json!("Fetch.requestPaused")
&& message["sessionId"] == json!("SID-fetch")
&& message["params"]["resourceType"] == json!("Document")
diff --git a/moli-protocol/src/domains/fetch/tests/runtime_auth_response.rs b/moli-protocol/src/domains/fetch/tests/runtime_auth_response.rs
index 73a8acf3b..aba89baea 100644
--- a/moli-protocol/src/domains/fetch/tests/runtime_auth_response.rs
+++ b/moli-protocol/src/domains/fetch/tests/runtime_auth_response.rs
@@ -1530,10 +1530,10 @@ async fn multiple_fetch_sessions_chain_subresource_auth_required_pauses() {
.browser_context
.as_mut()
.unwrap()
- .assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned())
+ .assign_attached_session_to_target("TID-1", "SID-attached".to_owned())
);
- for (id, session_id) in [(35_970, "SID-1"), (35_971, "SID-aux")] {
+ for (id, session_id) in [(35_970, "SID-1"), (35_971, "SID-attached")] {
ctx.process_async(json!({
"id": id,
"method": "Fetch.enable",
@@ -1596,21 +1596,20 @@ async fn multiple_fetch_sessions_chain_subresource_auth_required_pauses() {
wait_until_message(
&mut ctx,
- "SID-aux",
- "auxiliary request-stage pause",
+ "SID-attached",
+ "attached request-stage pause",
|message| {
message["method"] == json!("Fetch.requestPaused")
- && message["sessionId"] == json!("SID-aux")
+ && message["sessionId"] == json!("SID-attached")
&& message["params"]["request"]["url"] == json!(protected_url)
},
)
.await;
- let second_request_pause =
- ctx.take_first_matching("auxiliary request-stage pause", |message| {
- message["method"] == json!("Fetch.requestPaused")
- && message["sessionId"] == json!("SID-aux")
- && message["params"]["request"]["url"] == json!(protected_url)
- });
+ let second_request_pause = ctx.take_first_matching("attached request-stage pause", |message| {
+ message["method"] == json!("Fetch.requestPaused")
+ && message["sessionId"] == json!("SID-attached")
+ && message["params"]["request"]["url"] == json!(protected_url)
+ });
let second_request_id = second_request_pause["params"]["requestId"]
.as_str()
.expect("second request id")
@@ -1620,11 +1619,11 @@ async fn multiple_fetch_sessions_chain_subresource_auth_required_pauses() {
ctx.process_async(json!({
"id": 35_975,
"method": "Fetch.continueRequest",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": { "requestId": second_request_id }
}))
.await;
- ctx.expect_result(35_975, json!({}), Some("SID-aux"));
+ ctx.expect_result(35_975, json!({}), Some("SID-attached"));
wait_until_message(&mut ctx, "SID-1", "primary authRequired pause", |message| {
message["method"] == json!("Fetch.authRequired")
@@ -1655,9 +1654,9 @@ async fn multiple_fetch_sessions_chain_subresource_auth_required_pauses() {
.await;
ctx.expect_result(35_976, json!({}), Some("SID-1"));
- let second_auth = ctx.take_first_matching("auxiliary authRequired pause", |message| {
+ let second_auth = ctx.take_first_matching("attached authRequired pause", |message| {
message["method"] == json!("Fetch.authRequired")
- && message["sessionId"] == json!("SID-aux")
+ && message["sessionId"] == json!("SID-attached")
&& message["params"]["request"]["url"] == json!(protected_url)
});
let second_auth_request_id = second_auth["params"]["requestId"]
@@ -1673,7 +1672,7 @@ async fn multiple_fetch_sessions_chain_subresource_auth_required_pauses() {
ctx.process_async(json!({
"id": 35_977,
"method": "Fetch.continueWithAuth",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": {
"requestId": second_auth_request_id,
"authChallengeResponse": {
@@ -1684,7 +1683,7 @@ async fn multiple_fetch_sessions_chain_subresource_auth_required_pauses() {
}
}))
.await;
- ctx.expect_result(35_977, json!({}), Some("SID-aux"));
+ ctx.expect_result(35_977, json!({}), Some("SID-attached"));
evaluate_until_value_async(
&mut ctx,
diff --git a/moli-protocol/src/domains/fetch/tests/runtime_fetch.rs b/moli-protocol/src/domains/fetch/tests/runtime_fetch.rs
index e6378da0a..d2627f579 100644
--- a/moli-protocol/src/domains/fetch/tests/runtime_fetch.rs
+++ b/moli-protocol/src/domains/fetch/tests/runtime_fetch.rs
@@ -107,7 +107,7 @@ async fn wait_for_auth_required(
})
}
-async fn wait_for_auxiliary_fetch_request_paused(
+async fn wait_for_attached_fetch_request_paused(
ctx: &mut TestContext,
session_id: &str,
url: &str,
@@ -171,7 +171,7 @@ async fn wait_for_background_request_paused(
}
#[tokio::test(flavor = "multi_thread")]
-async fn auxiliary_session_fetch_enable_receives_subresource_request_pause() {
+async fn attached_session_fetch_enable_receives_subresource_request_pause() {
async fn page() -> impl IntoResponse {
(
[(CONTENT_TYPE.as_str(), "text/html")],
@@ -180,7 +180,7 @@ async fn auxiliary_session_fetch_enable_receives_subresource_request_pause() {
}
async fn api() -> impl IntoResponse {
- "auxiliary fetch body"
+ "attached fetch body"
}
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
@@ -205,14 +205,14 @@ async fn auxiliary_session_fetch_enable_receives_subresource_request_pause() {
.browser_context
.as_mut()
.unwrap()
- .assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned())
+ .assign_attached_session_to_target("TID-1", "SID-attached".to_owned())
);
ctx.sent.clear();
ctx.process_async(json!({
"id": 35_900,
"method": "Fetch.enable",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": {
"patterns": [
{ "urlPattern": "*/api", "requestStage": "Request", "resourceType": "Fetch" }
@@ -220,7 +220,7 @@ async fn auxiliary_session_fetch_enable_receives_subresource_request_pause() {
}
}))
.await;
- ctx.expect_result(35_900, json!({}), Some("SID-aux"));
+ ctx.expect_result(35_900, json!({}), Some("SID-attached"));
enable_runtime_async(&mut ctx, "SID-1", 35_901).await;
ctx.process_async(json!({
@@ -241,16 +241,16 @@ async fn auxiliary_session_fetch_enable_receives_subresource_request_pause() {
let _ = take_response_by_id(&mut ctx, 35_902);
let paused = ctx
- .wait_for_scheduler_message("auxiliary-session Fetch.requestPaused", |message| {
+ .wait_for_scheduler_message("attached-session Fetch.requestPaused", |message| {
message["method"] == json!("Fetch.requestPaused")
- && message["sessionId"] == json!("SID-aux")
+ && message["sessionId"] == json!("SID-attached")
&& message["params"]["request"]["url"] == json!(api_url)
&& message["params"]["resourceType"] == json!("XHR")
})
.await;
let request_id = paused["params"]["requestId"]
.as_str()
- .expect("auxiliary fetch request id")
+ .expect("attached fetch request id")
.to_owned();
ctx.sent.clear();
@@ -266,25 +266,22 @@ async fn auxiliary_session_fetch_enable_receives_subresource_request_pause() {
ctx.process_async(json!({
"id": 35_904,
"method": "Fetch.continueRequest",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": { "requestId": request_id }
}))
.await;
- ctx.expect_result(35_904, json!({}), Some("SID-aux"));
+ ctx.expect_result(35_904, json!({}), Some("SID-attached"));
let resolved = evaluate_until_value_async(
&mut ctx,
"SID-1",
35_905,
"globalThis.__lm_aux_fetch_result",
- &json!("auxiliary fetch body"),
- "auxiliary-session fetch result",
+ &json!("attached fetch body"),
+ "attached-session fetch result",
)
.await;
- assert_eq!(
- resolved["result"]["result"]["value"],
- "auxiliary fetch body"
- );
+ assert_eq!(resolved["result"]["result"]["value"], "attached fetch body");
server.abort();
}
@@ -324,7 +321,7 @@ async fn fetch_session_chain_uses_enable_insertion_order_not_session_id_sort() {
.browser_context
.as_mut()
.unwrap()
- .assign_auxiliary_session_to_target("TID-1", "SID-a".to_owned())
+ .assign_attached_session_to_target("TID-1", "SID-a".to_owned())
);
ctx.sent.clear();
@@ -396,7 +393,7 @@ async fn fetch_session_chain_uses_enable_insertion_order_not_session_id_sort() {
.await;
ctx.expect_result(35_920, json!({}), Some("SID-z"));
- let second_pause = wait_for_auxiliary_fetch_request_paused(
+ let second_pause = wait_for_attached_fetch_request_paused(
&mut ctx,
"SID-a",
&api_url,
@@ -432,7 +429,7 @@ async fn fetch_session_chain_uses_enable_insertion_order_not_session_id_sort() {
}
#[tokio::test(flavor = "multi_thread")]
-async fn auxiliary_session_detach_removes_fetch_enable_interception() {
+async fn attached_session_detach_removes_fetch_enable_interception() {
async fn page() -> impl IntoResponse {
(
[(CONTENT_TYPE.as_str(), "text/html")],
@@ -441,7 +438,7 @@ async fn auxiliary_session_detach_removes_fetch_enable_interception() {
}
async fn api() -> impl IntoResponse {
- "detached auxiliary fetch body"
+ "detached attached fetch body"
}
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
@@ -465,14 +462,14 @@ async fn auxiliary_session_detach_removes_fetch_enable_interception() {
.browser_context
.as_mut()
.unwrap()
- .assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned())
+ .assign_attached_session_to_target("TID-1", "SID-attached".to_owned())
);
ctx.sent.clear();
ctx.process_async(json!({
"id": 35_910,
"method": "Fetch.enable",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": {
"patterns": [
{ "urlPattern": "*/api", "requestStage": "Request", "resourceType": "Fetch" }
@@ -480,13 +477,13 @@ async fn auxiliary_session_detach_removes_fetch_enable_interception() {
}
}))
.await;
- ctx.expect_result(35_910, json!({}), Some("SID-aux"));
+ ctx.expect_result(35_910, json!({}), Some("SID-attached"));
enable_runtime_async(&mut ctx, "SID-1", 35_911).await;
ctx.process_async(json!({
"id": 35_912,
"method": "Target.detachFromTarget",
- "params": { "sessionId": "SID-aux" }
+ "params": { "sessionId": "SID-attached" }
}))
.await;
ctx.expect_result(35_912, json!({}), None);
@@ -514,19 +511,19 @@ async fn auxiliary_session_detach_removes_fetch_enable_interception() {
"SID-1",
35_914,
"globalThis.__lm_detached_aux_fetch_result",
- &json!("detached auxiliary fetch body"),
- "fetch after auxiliary detach",
+ &json!("detached attached fetch body"),
+ "fetch after attached detach",
)
.await;
assert_eq!(
resolved["result"]["result"]["value"],
- "detached auxiliary fetch body"
+ "detached attached fetch body"
);
assert!(
ctx.sent
.iter()
.all(|message| message["method"] != json!("Fetch.requestPaused")),
- "detached auxiliary Fetch session must not keep intercepting requests: {:?}",
+ "detached attached Fetch session must not keep intercepting requests: {:?}",
ctx.sent
);
@@ -534,7 +531,7 @@ async fn auxiliary_session_detach_removes_fetch_enable_interception() {
}
#[tokio::test(flavor = "multi_thread")]
-async fn auxiliary_session_fetch_response_stage_body_commands_use_session_owner() {
+async fn attached_session_fetch_response_stage_body_commands_use_session_owner() {
async fn page() -> impl IntoResponse {
(
[(CONTENT_TYPE.as_str(), "text/html")],
@@ -545,8 +542,8 @@ async fn auxiliary_session_fetch_response_stage_body_commands_use_session_owner(
async fn api(axum::extract::Query(query): axum::extract::Query<Value>) -> impl IntoResponse {
let mode = query.get("mode").and_then(Value::as_str).unwrap_or("body");
match mode {
- "stream" => "auxiliary stream body",
- _ => "auxiliary fetch body",
+ "stream" => "attached stream body",
+ _ => "attached fetch body",
}
}
@@ -573,14 +570,14 @@ async fn auxiliary_session_fetch_response_stage_body_commands_use_session_owner(
.browser_context
.as_mut()
.unwrap()
- .assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned())
+ .assign_attached_session_to_target("TID-1", "SID-attached".to_owned())
);
ctx.sent.clear();
ctx.process_async(json!({
"id": 35_920,
"method": "Fetch.enable",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": {
"patterns": [
{ "urlPattern": "*/api*", "requestStage": "Response", "resourceType": "Fetch" }
@@ -588,7 +585,7 @@ async fn auxiliary_session_fetch_response_stage_body_commands_use_session_owner(
}
}))
.await;
- ctx.expect_result(35_920, json!({}), Some("SID-aux"));
+ ctx.expect_result(35_920, json!({}), Some("SID-attached"));
enable_runtime_async(&mut ctx, "SID-1", 35_921).await;
ctx.process_async(json!({
@@ -608,17 +605,17 @@ async fn auxiliary_session_fetch_response_stage_body_commands_use_session_owner(
.await;
let _ = take_response_by_id(&mut ctx, 35_922);
- let paused = wait_for_auxiliary_fetch_request_paused(
+ let paused = wait_for_attached_fetch_request_paused(
&mut ctx,
- "SID-aux",
+ "SID-attached",
&body_url,
Some(200),
- "auxiliary response-stage body pause",
+ "attached response-stage body pause",
)
.await;
let request_id = paused["params"]["requestId"]
.as_str()
- .expect("auxiliary fetch request id")
+ .expect("attached fetch request id")
.to_owned();
ctx.process_async(json!({
@@ -633,31 +630,31 @@ async fn auxiliary_session_fetch_response_stage_body_commands_use_session_owner(
ctx.process_async(json!({
"id": 35_923,
"method": "Fetch.getResponseBody",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": { "requestId": request_id.clone() }
}))
.await;
ctx.expect_result(
35_923,
- json!({ "body": "auxiliary fetch body", "base64Encoded": false }),
- Some("SID-aux"),
+ json!({ "body": "attached fetch body", "base64Encoded": false }),
+ Some("SID-attached"),
);
ctx.process_async(json!({
"id": 35_924,
"method": "Fetch.continueResponse",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": { "requestId": request_id }
}))
.await;
- ctx.expect_result(35_924, json!({}), Some("SID-aux"));
+ ctx.expect_result(35_924, json!({}), Some("SID-attached"));
evaluate_until_value_async(
&mut ctx,
"SID-1",
35_925,
"globalThis.__lm_aux_fetch_body_result",
- &json!("auxiliary fetch body"),
- "auxiliary fetch body result",
+ &json!("attached fetch body"),
+ "attached fetch body result",
)
.await;
@@ -679,17 +676,17 @@ async fn auxiliary_session_fetch_response_stage_body_commands_use_session_owner(
.await;
let _ = take_response_by_id(&mut ctx, 35_926);
- let paused = wait_for_auxiliary_fetch_request_paused(
+ let paused = wait_for_attached_fetch_request_paused(
&mut ctx,
- "SID-aux",
+ "SID-attached",
&stream_url,
Some(200),
- "auxiliary response-stage stream pause",
+ "attached response-stage stream pause",
)
.await;
let request_id = paused["params"]["requestId"]
.as_str()
- .expect("auxiliary fetch stream request id")
+ .expect("attached fetch stream request id")
.to_owned();
ctx.process_async(json!({
@@ -704,7 +701,7 @@ async fn auxiliary_session_fetch_response_stage_body_commands_use_session_owner(
ctx.process_async(json!({
"id": 35_927,
"method": "Fetch.takeResponseBodyAsStream",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": { "requestId": request_id.clone() }
}))
.await;
@@ -716,38 +713,38 @@ async fn auxiliary_session_fetch_response_stage_body_commands_use_session_owner(
ctx.process_async(json!({
"id": 35_928,
"method": "IO.read",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": { "handle": stream }
}))
.await;
ctx.expect_result(
35_928,
- json!({ "base64Encoded": false, "data": "auxiliary stream body", "eof": true }),
- Some("SID-aux"),
+ json!({ "base64Encoded": false, "data": "attached stream body", "eof": true }),
+ Some("SID-attached"),
);
ctx.process_async(json!({
"id": 35_929,
"method": "Fetch.fulfillRequest",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": {
"requestId": request_id,
"responseCode": 200,
"responseHeaders": [
{ "name": "content-type", "value": "text/plain" }
],
- "body": "YXV4aWxpYXJ5IHN0cmVhbSBib2R5"
+ "body": "YXR0YWNoZWQgc3RyZWFtIGJvZHk="
}
}))
.await;
- ctx.expect_result(35_929, json!({}), Some("SID-aux"));
+ ctx.expect_result(35_929, json!({}), Some("SID-attached"));
evaluate_until_value_async(
&mut ctx,
"SID-1",
35_930,
"globalThis.__lm_aux_fetch_stream_result",
- &json!("auxiliary stream body"),
- "auxiliary fetch stream result",
+ &json!("attached stream body"),
+ "attached fetch stream result",
)
.await;
@@ -789,10 +786,10 @@ async fn multiple_fetch_sessions_chain_subresource_response_stage_pauses() {
.browser_context
.as_mut()
.unwrap()
- .assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned())
+ .assign_attached_session_to_target("TID-1", "SID-attached".to_owned())
);
- for (id, session_id) in [(35_940, "SID-1"), (35_941, "SID-aux")] {
+ for (id, session_id) in [(35_940, "SID-1"), (35_941, "SID-attached")] {
ctx.process_async(json!({
"id": id,
"method": "Fetch.enable",
@@ -826,7 +823,7 @@ async fn multiple_fetch_sessions_chain_subresource_response_stage_pauses() {
.await;
let _ = take_response_by_id(&mut ctx, 35_943);
- let first_paused = wait_for_auxiliary_fetch_request_paused(
+ let first_paused = wait_for_attached_fetch_request_paused(
&mut ctx,
"SID-1",
&api_url,
@@ -848,12 +845,12 @@ async fn multiple_fetch_sessions_chain_subresource_response_stage_pauses() {
.await;
ctx.expect_result(35_944, json!({}), Some("SID-1"));
- let second_paused = wait_for_auxiliary_fetch_request_paused(
+ let second_paused = wait_for_attached_fetch_request_paused(
&mut ctx,
- "SID-aux",
+ "SID-attached",
&api_url,
Some(200),
- "second response-stage pause on auxiliary session",
+ "second response-stage pause on attached session",
)
.await;
let second_request_id = second_paused["params"]["requestId"]
@@ -865,24 +862,24 @@ async fn multiple_fetch_sessions_chain_subresource_response_stage_pauses() {
ctx.process_async(json!({
"id": 35_945,
"method": "Fetch.getResponseBody",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": { "requestId": second_request_id.clone() }
}))
.await;
ctx.expect_result(
35_945,
json!({ "body": "multi response body", "base64Encoded": false }),
- Some("SID-aux"),
+ Some("SID-attached"),
);
ctx.process_async(json!({
"id": 35_946,
"method": "Fetch.continueResponse",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": { "requestId": second_request_id }
}))
.await;
- ctx.expect_result(35_946, json!({}), Some("SID-aux"));
+ ctx.expect_result(35_946, json!({}), Some("SID-attached"));
evaluate_until_value_async(
&mut ctx,
"SID-1",
@@ -931,10 +928,10 @@ async fn response_body_stream_taken_blocks_chained_response_stage_continue() {
.browser_context
.as_mut()
.unwrap()
- .assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned())
+ .assign_attached_session_to_target("TID-1", "SID-attached".to_owned())
);
- for (id, session_id) in [(35_948, "SID-1"), (35_949, "SID-aux")] {
+ for (id, session_id) in [(35_948, "SID-1"), (35_949, "SID-attached")] {
ctx.process_async(json!({
"id": id,
"method": "Fetch.enable",
@@ -969,7 +966,7 @@ async fn response_body_stream_taken_blocks_chained_response_stage_continue() {
.await;
let _ = take_response_by_id(&mut ctx, 35_951);
- let first_paused = wait_for_auxiliary_fetch_request_paused(
+ let first_paused = wait_for_attached_fetch_request_paused(
&mut ctx,
"SID-1",
&api_url,
@@ -1027,7 +1024,7 @@ async fn response_body_stream_taken_blocks_chained_response_stage_continue() {
assert!(
!ctx.sent.iter().any(|message| {
message["method"] == json!("Fetch.requestPaused")
- && message["sessionId"] == json!("SID-aux")
+ && message["sessionId"] == json!("SID-attached")
&& message["params"]["request"]["url"] == json!(api_url)
}),
"body-taken response should not advance to next Fetch handler"
@@ -1176,7 +1173,7 @@ async fn response_body_stream_taken_blocks_chained_bidi_response_stage_pause() {
.await;
let _ = take_response_by_id(&mut ctx, 35_960);
- let cdp_pause = wait_for_auxiliary_fetch_request_paused(
+ let cdp_pause = wait_for_attached_fetch_request_paused(
&mut ctx,
"SID-1",
&hit_url,
@@ -1327,10 +1324,10 @@ async fn response_stage_head_override_is_visible_to_chained_fetch_session() {
.browser_context
.as_mut()
.unwrap()
- .assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned())
+ .assign_attached_session_to_target("TID-1", "SID-attached".to_owned())
);
- for (id, session_id) in [(35_950, "SID-1"), (35_951, "SID-aux")] {
+ for (id, session_id) in [(35_950, "SID-1"), (35_951, "SID-attached")] {
ctx.process_async(json!({
"id": id,
"method": "Fetch.enable",
@@ -1366,7 +1363,7 @@ async fn response_stage_head_override_is_visible_to_chained_fetch_session() {
.await;
let _ = take_response_by_id(&mut ctx, 35_953);
- let first_paused = wait_for_auxiliary_fetch_request_paused(
+ let first_paused = wait_for_attached_fetch_request_paused(
&mut ctx,
"SID-1",
&api_url,
@@ -1395,9 +1392,9 @@ async fn response_stage_head_override_is_visible_to_chained_fetch_session() {
.await;
ctx.expect_result(35_954, json!({}), Some("SID-1"));
- let second_paused = wait_for_auxiliary_fetch_request_paused(
+ let second_paused = wait_for_attached_fetch_request_paused(
&mut ctx,
- "SID-aux",
+ "SID-attached",
&api_url,
Some(201),
"second response-stage pause after head override",
@@ -1424,14 +1421,14 @@ async fn response_stage_head_override_is_visible_to_chained_fetch_session() {
ctx.process_async(json!({
"id": 35_955,
"method": "Fetch.continueResponse",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": {
"requestId": second_request_id,
"responsePhrase": "Created"
}
}))
.await;
- ctx.expect_result(35_955, json!({}), Some("SID-aux"));
+ ctx.expect_result(35_955, json!({}), Some("SID-attached"));
evaluate_until_value_async(
&mut ctx,
"SID-1",
@@ -1483,10 +1480,10 @@ async fn response_stage_empty_headers_override_is_visible_to_chained_fetch_sessi
.browser_context
.as_mut()
.unwrap()
- .assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned())
+ .assign_attached_session_to_target("TID-1", "SID-attached".to_owned())
);
- for (id, session_id) in [(35_970, "SID-1"), (35_971, "SID-aux")] {
+ for (id, session_id) in [(35_970, "SID-1"), (35_971, "SID-attached")] {
ctx.process_async(json!({
"id": id,
"method": "Fetch.enable",
@@ -1522,7 +1519,7 @@ async fn response_stage_empty_headers_override_is_visible_to_chained_fetch_sessi
.await;
let _ = take_response_by_id(&mut ctx, 35_973);
- let first_paused = wait_for_auxiliary_fetch_request_paused(
+ let first_paused = wait_for_attached_fetch_request_paused(
&mut ctx,
"SID-1",
&api_url,
@@ -1548,9 +1545,9 @@ async fn response_stage_empty_headers_override_is_visible_to_chained_fetch_sessi
.await;
ctx.expect_result(35_974, json!({}), Some("SID-1"));
- let second_paused = wait_for_auxiliary_fetch_request_paused(
+ let second_paused = wait_for_attached_fetch_request_paused(
&mut ctx,
- "SID-aux",
+ "SID-attached",
&api_url,
Some(201),
"second response-stage pause after empty headers override",
@@ -1571,11 +1568,11 @@ async fn response_stage_empty_headers_override_is_visible_to_chained_fetch_sessi
ctx.process_async(json!({
"id": 35_975,
"method": "Fetch.continueResponse",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": { "requestId": second_request_id }
}))
.await;
- ctx.expect_result(35_975, json!({}), Some("SID-aux"));
+ ctx.expect_result(35_975, json!({}), Some("SID-attached"));
evaluate_until_value_async(
&mut ctx,
"SID-1",
@@ -1627,10 +1624,10 @@ async fn response_stage_partial_head_override_is_rejected_and_preserves_chain()
.browser_context
.as_mut()
.unwrap()
- .assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned())
+ .assign_attached_session_to_target("TID-1", "SID-attached".to_owned())
);
- for (id, session_id) in [(36_020, "SID-1"), (36_021, "SID-aux")] {
+ for (id, session_id) in [(36_020, "SID-1"), (36_021, "SID-attached")] {
ctx.process_async(json!({
"id": id,
"method": "Fetch.enable",
@@ -1666,7 +1663,7 @@ async fn response_stage_partial_head_override_is_rejected_and_preserves_chain()
.await;
let _ = take_response_by_id(&mut ctx, 36_023);
- let first_paused = wait_for_auxiliary_fetch_request_paused(
+ let first_paused = wait_for_attached_fetch_request_paused(
&mut ctx,
"SID-1",
&api_url,
@@ -1704,9 +1701,9 @@ async fn response_stage_partial_head_override_is_rejected_and_preserves_chain()
.await;
ctx.expect_result(36_025, json!({}), Some("SID-1"));
- let second_paused = wait_for_auxiliary_fetch_request_paused(
+ let second_paused = wait_for_attached_fetch_request_paused(
&mut ctx,
- "SID-aux",
+ "SID-attached",
&api_url,
Some(200),
"second response-stage pause after rejected partial override",
@@ -1720,11 +1717,11 @@ async fn response_stage_partial_head_override_is_rejected_and_preserves_chain()
ctx.process_async(json!({
"id": 36_026,
"method": "Fetch.continueResponse",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": { "requestId": second_request_id }
}))
.await;
- ctx.expect_result(36_026, json!({}), Some("SID-aux"));
+ ctx.expect_result(36_026, json!({}), Some("SID-attached"));
evaluate_until_value_async(
&mut ctx,
"SID-1",
@@ -3346,7 +3343,7 @@ xhr.send();
}
#[tokio::test(flavor = "multi_thread")]
-async fn auxiliary_session_fetch_enable_receives_worker_xhr_request_pause() {
+async fn attached_session_fetch_enable_receives_worker_xhr_request_pause() {
async fn page() -> impl IntoResponse {
(
[(CONTENT_TYPE.as_str(), "text/html")],
@@ -3397,14 +3394,14 @@ xhr.send();
.browser_context
.as_mut()
.unwrap()
- .assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned())
+ .assign_attached_session_to_target("TID-1", "SID-attached".to_owned())
);
ctx.sent.clear();
ctx.process_async(json!({
"id": 37_070,
"method": "Fetch.enable",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": {
"patterns": [
{ "urlPattern": "*/worker-api*", "requestStage": "Request", "resourceType": "XHR" }
@@ -3412,7 +3409,7 @@ xhr.send();
}
}))
.await;
- ctx.expect_result(37_070, json!({}), Some("SID-aux"));
+ ctx.expect_result(37_070, json!({}), Some("SID-attached"));
enable_runtime_async(&mut ctx, "SID-1", 37_071).await;
ctx.process_async(json!({
"id": 37_072,
@@ -3432,13 +3429,13 @@ xhr.send();
let paused = wait_for_background_request_paused(
&mut ctx,
- Some("SID-aux"),
+ Some("SID-attached"),
&api_url,
"XHR",
- "auxiliary-session worker xhr requestPaused should surface through renderer publication",
+ "attached-session worker xhr requestPaused should surface through renderer publication",
)
.await;
- assert_eq!(paused["sessionId"], json!("SID-aux"));
+ assert_eq!(paused["sessionId"], json!("SID-attached"));
assert_eq!(paused["params"]["resourceType"], "XHR");
assert_eq!(paused["params"]["request"]["method"], "GET");
diff --git a/moli-protocol/src/domains/fetch/tests/runtime_websocket.rs b/moli-protocol/src/domains/fetch/tests/runtime_websocket.rs
index 4159aa703..bb9b33880 100644
--- a/moli-protocol/src/domains/fetch/tests/runtime_websocket.rs
+++ b/moli-protocol/src/domains/fetch/tests/runtime_websocket.rs
@@ -885,7 +885,7 @@ async fn background_websocket_synthetic_socket_injection_routes_to_session_owner
.as_ref()
.and_then(|browser_context| browser_context.active_target_id()),
Some("TID-active"),
- "background Fetch.dispatchWebSocketMessage should not promote the target"
+ "background Fetch.dispatchWebSocketMessage should not activate the target"
);
server.abort();
diff --git a/moli-protocol/src/domains/input/tests.rs b/moli-protocol/src/domains/input/tests.rs
index 281b6458c..871663288 100644
--- a/moli-protocol/src/domains/input/tests.rs
+++ b/moli-protocol/src/domains/input/tests.rs
@@ -856,19 +856,19 @@ async fn ignore_input_events_is_target_aggregated_and_does_not_block_insert_text
.await;
let browser_context = ctx.conn.browser_context.as_mut().expect("browser context");
browser_context.attach_active_session("SID-primary");
- assert!(browser_context.assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned()));
+ assert!(browser_context.assign_attached_session_to_target("TID-1", "SID-attached".to_owned()));
ctx.process_async(json!({
"id": 30,
"method": "Input.setIgnoreInputEvents",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": { "ignore": true }
}))
.await;
- ctx.expect_result(30, json!({}), Some("SID-aux"));
+ ctx.expect_result(30, json!({}), Some("SID-attached"));
assert!(
ctx.conn
- .target_page_session_state_for_session(Some("SID-aux"))
+ .target_page_session_state_for_session(Some("SID-attached"))
.is_some_and(|state| state.input_events_ignored)
);
assert!(
@@ -950,11 +950,11 @@ async fn ignore_input_events_is_target_aggregated_and_does_not_block_insert_text
ctx.process_async(json!({
"id": 36,
"method": "Input.setIgnoreInputEvents",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": { "ignore": false }
}))
.await;
- ctx.expect_result(36, json!({}), Some("SID-aux"));
+ ctx.expect_result(36, json!({}), Some("SID-attached"));
ctx.process_async(json!({
"id": 37,
"method": "Input.dispatchKeyEvent",
@@ -968,18 +968,21 @@ async fn ignore_input_events_is_target_aggregated_and_does_not_block_insert_text
ctx.process_async(json!({
"id": 38,
"method": "Input.setIgnoreInputEvents",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": { "ignore": true }
}))
.await;
- ctx.expect_result(38, json!({}), Some("SID-aux"));
- assert_eq!(
+ ctx.expect_result(38, json!({}), Some("SID-attached"));
+ assert!(
ctx.conn
.browser_context
.as_mut()
.expect("browser context")
- .remove_auxiliary_session("SID-aux"),
- Some("TID-1".to_owned())
+ .remove_page_session_binding(
+ "TID-1",
+ "SID-attached",
+ &moli_page_types::DevToolsSessionKey::Attached("SID-attached".to_owned()),
+ )
);
ctx.process_async(json!({
"id": 39,
diff --git a/moli-protocol/src/domains/inspector.rs b/moli-protocol/src/domains/inspector.rs
index 6eb0740fd..bbcf6165d 100644
--- a/moli-protocol/src/domains/inspector.rs
+++ b/moli-protocol/src/domains/inspector.rs
@@ -133,12 +133,12 @@ mod tests {
}
#[tokio::test]
- async fn inspector_enable_replays_crash_to_exact_auxiliary_session() {
+ async fn inspector_enable_replays_crash_to_exact_attached_session() {
let mut ctx = TestContext::new();
let mut bc = BrowserContext::new("BID-1".into());
bc.set_active_target_id("TID-1");
bc.attach_active_session("SID-primary");
- assert!(bc.assign_auxiliary_session_to_target("TID-1", "SID-aux".into()));
+ assert!(bc.assign_attached_session_to_target("TID-1", "SID-attached".into()));
bc.active_page_target_mut()
.owner_state
.target_crash_state
@@ -148,13 +148,13 @@ mod tests {
ctx.process_async(json!({
"id": 30,
"method": "Inspector.enable",
- "sessionId": "SID-aux"
+ "sessionId": "SID-attached"
}))
.await;
- ctx.expect_result(30, json!({}), Some("SID-aux"));
+ ctx.expect_result(30, json!({}), Some("SID-attached"));
let event = ctx.take_one();
assert_eq!(event["method"], "Inspector.targetCrashed");
- assert_eq!(event["sessionId"], "SID-aux");
+ assert_eq!(event["sessionId"], "SID-attached");
assert!(
!ctx.conn
.target_runtime_session_state_for_session(Some("SID-primary"))
@@ -163,14 +163,14 @@ mod tests {
);
assert!(
ctx.conn
- .target_runtime_session_state_for_session(Some("SID-aux"))
- .expect("auxiliary runtime session state")
+ .target_runtime_session_state_for_session(Some("SID-attached"))
+ .expect("attached runtime session state")
.inspector_target_crashed_delivered()
);
}
#[tokio::test]
- async fn inspector_enable_replays_background_target_crash_without_promotion() {
+ async fn inspector_enable_replays_background_target_crash_without_activation() {
let mut ctx = TestContext::new();
let mut bc = BrowserContext::new("BID-1".into());
bc.set_active_target_id("TID-active");
@@ -321,7 +321,7 @@ mod tests {
bc.background_target("TID-B")
.filter(|target| target.has_non_default_session_state())
.is_none(),
- "disable should collapse staged parked state back to default"
+ "disable should collapse staged background state back to default"
);
}
}
diff --git a/moli-protocol/src/domains/log.rs b/moli-protocol/src/domains/log.rs
index 6fa8f9769..f6cff2513 100644
--- a/moli-protocol/src/domains/log.rs
+++ b/moli-protocol/src/domains/log.rs
@@ -485,7 +485,7 @@ mod tests {
.browser_context
.as_mut()
.expect("browser context should be loaded");
- assert!(browser_context.assign_auxiliary_session_to_target("TID-1", "SID-2".to_owned()));
+ assert!(browser_context.assign_attached_session_to_target("TID-1", "SID-2".to_owned()));
ctx.process_async(json!({"id": 1, "method": "Log.enable", "sessionId": "SID-1"}))
.await;
ctx.expect_result(1, json!({}), Some("SID-1"));
@@ -691,7 +691,7 @@ mod tests {
.browser_context
.as_mut()
.expect("browser context")
- .assign_auxiliary_session_to_target("TID-1", "SID-2".to_owned())
+ .assign_attached_session_to_target("TID-1", "SID-2".to_owned())
);
ctx.process_async(json!({"id": 1, "method": "Log.enable", "sessionId": "SID-1"}))
@@ -747,8 +747,8 @@ mod tests {
.browser_context
.as_mut()
.expect("browser context should be loaded");
- assert!(browser_context.assign_auxiliary_session_to_target("TID-1", "SID-2".to_owned()));
- assert!(browser_context.assign_auxiliary_session_to_target("TID-1", "SID-3".to_owned()));
+ assert!(browser_context.assign_attached_session_to_target("TID-1", "SID-2".to_owned()));
+ assert!(browser_context.assign_attached_session_to_target("TID-1", "SID-3".to_owned()));
ctx.process_async(json!({"id": 1, "method": "Log.enable", "sessionId": "SID-1"}))
.await;
diff --git a/moli-protocol/src/domains/network.rs b/moli-protocol/src/domains/network.rs
index abf3348eb..d38e18de3 100644
--- a/moli-protocol/src/domains/network.rs
+++ b/moli-protocol/src/domains/network.rs
@@ -49,6 +49,16 @@ pub(crate) mod settings;
#[cfg(test)]
mod tests;
+/// Removes one session's Network contributions, then applies the newly
+/// aggregated target policy before the session disappears.
+pub(in crate::domains) async fn dispose_session_policy_async(
+ conn: &mut CdpConnection,
+ session_id: &str,
+) -> anyhow::Result<()> {
+ conn.clear_devtools_network_session_policy_async(session_id)
+ .await
+}
+
use super::actions::NetworkAction;
use super::command_output::CommandOutputPlan;
pub(crate) use activity::NetworkPreparedOutputSlot;
diff --git a/moli-protocol/src/domains/network/activity.rs b/moli-protocol/src/domains/network/activity.rs
index 85d2aa550..06c3511c7 100644
--- a/moli-protocol/src/domains/network/activity.rs
+++ b/moli-protocol/src/domains/network/activity.rs
@@ -758,7 +758,7 @@ mod tests {
let mut bc = BrowserContext::new("BID-1".into());
bc.set_active_target_id("TID-1");
bc.attach_active_session("SID-1");
- assert!(bc.assign_auxiliary_session_to_target("TID-1", "FETCH-SID".to_owned()));
+ assert!(bc.assign_attached_session_to_target("TID-1", "FETCH-SID".to_owned()));
bc.active_page_target_mut()
.runtime_slot
.set_page_attachment_id_for_test(1);
@@ -817,7 +817,7 @@ mod tests {
let mut bc = BrowserContext::new("BID-1".into());
bc.set_active_target_id("TID-1");
bc.attach_active_session("SID-1");
- assert!(bc.assign_auxiliary_session_to_target("TID-1", "FETCH-SID".to_owned()));
+ assert!(bc.assign_attached_session_to_target("TID-1", "FETCH-SID".to_owned()));
bc.active_page_target_mut()
.runtime_slot
.set_page_attachment_id_for_test(1);
diff --git a/moli-protocol/src/domains/network/agent.rs b/moli-protocol/src/domains/network/agent.rs
index b45769fa0..ffb16cea0 100644
--- a/moli-protocol/src/domains/network/agent.rs
+++ b/moli-protocol/src/domains/network/agent.rs
@@ -25,7 +25,7 @@ enum RendererSubresourceTeardownDisposition {
#[derive(Debug, Clone, Default, PartialEq)]
pub struct TargetNetworkAgentState {
primary_enabled: bool,
- auxiliary_event_session_ids: Vec<String>,
+ attached_event_session_ids: Vec<String>,
output_queue: TargetNetworkOutputQueue,
active_renderer_subresource_requests:
HashMap<SubresourceNetworkRequestHandle, RendererSubresourceTeardownDisposition>,
@@ -315,34 +315,34 @@ impl TargetNetworkAgentState {
self.output_queue.websocket_event_count()
}
- pub(crate) fn enable_auxiliary_events(&mut self, session_id: &str) {
+ pub(crate) fn enable_attached_events(&mut self, session_id: &str) {
if !self
- .auxiliary_event_session_ids
+ .attached_event_session_ids
.iter()
.any(|enabled_session_id| enabled_session_id == session_id)
{
- self.auxiliary_event_session_ids.push(session_id.to_owned());
+ self.attached_event_session_ids.push(session_id.to_owned());
}
}
- pub(crate) fn disable_auxiliary_events(&mut self, session_id: &str) -> bool {
- let previous_len = self.auxiliary_event_session_ids.len();
- self.auxiliary_event_session_ids
+ pub(crate) fn disable_attached_events(&mut self, session_id: &str) -> bool {
+ let previous_len = self.attached_event_session_ids.len();
+ self.attached_event_session_ids
.retain(|enabled_session_id| enabled_session_id != session_id);
- self.auxiliary_event_session_ids.len() != previous_len
+ self.attached_event_session_ids.len() != previous_len
}
- pub(crate) fn remove_auxiliary_session(&mut self, session_id: &str) {
- self.disable_auxiliary_events(session_id);
+ pub(crate) fn remove_attached_session(&mut self, session_id: &str) {
+ self.disable_attached_events(session_id);
self.remove_session_observation_cursor(Some(session_id));
}
pub(crate) fn has_event_listeners(&self) -> bool {
- self.primary_enabled || !self.auxiliary_event_session_ids.is_empty()
+ self.primary_enabled || !self.attached_event_session_ids.is_empty()
}
- pub(crate) fn auxiliary_events_enabled_for_session(&self, session_id: &str) -> bool {
- self.auxiliary_event_session_ids
+ pub(crate) fn attached_events_enabled_for_session(&self, session_id: &str) -> bool {
+ self.attached_event_session_ids
.iter()
.any(|enabled_session_id| enabled_session_id == session_id)
}
@@ -357,7 +357,7 @@ impl TargetNetworkAgentState {
if self.primary_enabled {
session_ids.push(primary_event_session_id.map(str::to_owned));
}
- for session_id in &self.auxiliary_event_session_ids {
+ for session_id in &self.attached_event_session_ids {
if !self.primary_enabled || Some(session_id.as_str()) != primary_event_session_id {
session_ids.push(Some(session_id.clone()));
}
@@ -865,8 +865,8 @@ impl TargetNetworkAgentState {
}
#[cfg(test)]
- pub(crate) fn has_auxiliary_events_for_session(&self, session_id: &str) -> bool {
- self.auxiliary_events_enabled_for_session(session_id)
+ pub(crate) fn has_attached_events_for_session(&self, session_id: &str) -> bool {
+ self.attached_events_enabled_for_session(session_id)
}
#[cfg(test)]
@@ -2451,17 +2451,17 @@ mod tests {
}
#[test]
- fn auxiliary_network_event_sessions_follow_enable_insertion_order() {
+ fn attached_network_event_sessions_follow_enable_insertion_order() {
let mut agent = TargetNetworkAgentState::default();
- agent.enable_auxiliary_events("SID-z");
- agent.enable_auxiliary_events("SID-a");
- agent.enable_auxiliary_events("SID-z");
+ agent.enable_attached_events("SID-z");
+ agent.enable_attached_events("SID-a");
+ agent.enable_attached_events("SID-z");
assert_eq!(
agent.event_session_ids(Some("SID-primary"), Some("SID-primary")),
vec![Some("SID-z".to_owned()), Some("SID-a".to_owned())],
- "auxiliary Network listeners should not be sorted by session id"
+ "attached Network listeners should not be sorted by session id"
);
agent.enable_primary_events();
@@ -2472,11 +2472,11 @@ mod tests {
Some("SID-z".to_owned()),
Some("SID-a".to_owned()),
],
- "primary listener remains first, followed by auxiliary enable order"
+ "primary listener remains first, followed by attached enable order"
);
- assert!(agent.disable_auxiliary_events("SID-z"));
- agent.enable_auxiliary_events("SID-z");
+ assert!(agent.disable_attached_events("SID-z"));
+ agent.enable_attached_events("SID-z");
assert_eq!(
agent.event_session_ids(Some("SID-primary"), Some("SID-primary")),
vec![
@@ -2484,7 +2484,7 @@ mod tests {
Some("SID-a".to_owned()),
Some("SID-z".to_owned()),
],
- "disable then re-enable should append the auxiliary session"
+ "disable then re-enable should append the attached session"
);
}
diff --git a/moli-protocol/src/domains/network/tests/blocked_urls.rs b/moli-protocol/src/domains/network/tests/blocked_urls.rs
index c98ce862e..59051826b 100644
--- a/moli-protocol/src/domains/network/tests/blocked_urls.rs
+++ b/moli-protocol/src/domains/network/tests/blocked_urls.rs
@@ -252,7 +252,7 @@ async fn set_blocked_urls_runtime_fetch_emits_loading_failed() {
);
}
#[tokio::test(flavor = "multi_thread")]
-async fn background_set_blocked_urls_updates_loaded_owner_page_without_promotion() {
+async fn background_set_blocked_urls_updates_loaded_owner_page_without_activation() {
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
let addr = listener.local_addr().unwrap();
let server = tokio::spawn(async move {
@@ -396,7 +396,7 @@ async fn background_set_blocked_urls_updates_loaded_owner_page_without_promotion
);
assert!(
ctx.conn.browser_context.is_none(),
- "direct background Network policy should not promote the owner"
+ "direct background Network policy should not activate the owner"
);
server.abort();
diff --git a/moli-protocol/src/domains/network/tests/navigation.rs b/moli-protocol/src/domains/network/tests/navigation.rs
index dc9231bb2..26af6ecae 100644
--- a/moli-protocol/src/domains/network/tests/navigation.rs
+++ b/moli-protocol/src/domains/network/tests/navigation.rs
@@ -1388,7 +1388,7 @@ async fn first_main_document_transport_failure_commits_error_document() {
let mut bc = BrowserContext::new("BID-1".into());
bc.set_active_target_id("TID-1");
bc.attach_active_session("SID-1");
- assert!(bc.assign_auxiliary_session_to_target("TID-1", "SID-2".to_owned()));
+ assert!(bc.assign_attached_session_to_target("TID-1", "SID-2".to_owned()));
ctx.conn.browser_context = Some(bc);
ctx.enable_page_events_for_test(Some("SID-1"));
ctx.enable_page_events_for_test(Some("SID-2"));
@@ -1571,9 +1571,9 @@ async fn first_main_document_transport_failure_commits_error_document() {
}
}))
.await;
- let auxiliary_evaluate = ctx.take_response_by_id(31);
+ let attached_evaluate = ctx.take_response_by_id(31);
assert_eq!(
- auxiliary_evaluate["result"]["result"]["value"],
+ attached_evaluate["result"]["result"]["value"],
json!(format!("[\"{NETWORK_ERROR_PAGE_URL}\",\"complete\"]"))
);
diff --git a/moli-protocol/src/domains/network/tests/response_body.rs b/moli-protocol/src/domains/network/tests/response_body.rs
index 2dcc6dfbe..c44e13ab9 100644
--- a/moli-protocol/src/domains/network/tests/response_body.rs
+++ b/moli-protocol/src/domains/network/tests/response_body.rs
@@ -33,12 +33,12 @@ async fn get_response_body_respects_recorded_session_visibility() {
bc.active_page_target_mut()
.runtime_slot
.enable_primary_network_events();
- assert!(bc.assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned()));
- bc.enable_auxiliary_network_events("SID-aux");
+ assert!(bc.assign_attached_session_to_target("TID-1", "SID-attached".to_owned()));
+ bc.enable_attached_network_events("SID-attached");
bc.record_captured_response_body(
"REQ-aux-only".to_owned(),
"aux-only body".to_owned(),
- [Some("SID-aux".to_owned())],
+ [Some("SID-attached".to_owned())],
);
ctx.conn.browser_context = Some(bc);
@@ -54,14 +54,14 @@ async fn get_response_body_respects_recorded_session_visibility() {
ctx.process_async(json!({
"id": 7_281,
"method": "Network.getResponseBody",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": { "requestId": "REQ-aux-only" }
}))
.await;
ctx.expect_result(
7_281,
json!({ "body": "aux-only body", "base64Encoded": false }),
- Some("SID-aux"),
+ Some("SID-attached"),
);
}
#[tokio::test(flavor = "multi_thread")]
@@ -73,18 +73,21 @@ async fn get_response_body_requires_calling_session_network_listener() {
bc.active_page_target_mut()
.runtime_slot
.enable_primary_network_events();
- assert!(bc.assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned()));
+ assert!(bc.assign_attached_session_to_target("TID-1", "SID-attached".to_owned()));
bc.record_captured_response_body(
"REQ-shared".to_owned(),
"shared body".to_owned(),
- [Some("SID-primary".to_owned()), Some("SID-aux".to_owned())],
+ [
+ Some("SID-primary".to_owned()),
+ Some("SID-attached".to_owned()),
+ ],
);
ctx.conn.browser_context = Some(bc);
ctx.process_async(json!({
"id": 7_282,
"method": "Network.getResponseBody",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": { "requestId": "REQ-shared" }
}))
.await;
@@ -93,23 +96,23 @@ async fn get_response_body_requires_calling_session_network_listener() {
ctx.process_async(json!({
"id": 7_283,
"method": "Network.enable",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": {}
}))
.await;
- ctx.expect_result(7_283, json!({}), Some("SID-aux"));
+ ctx.expect_result(7_283, json!({}), Some("SID-attached"));
ctx.process_async(json!({
"id": 7_284,
"method": "Network.getResponseBody",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": { "requestId": "REQ-shared" }
}))
.await;
ctx.expect_result(
7_284,
json!({ "body": "shared body", "base64Encoded": false }),
- Some("SID-aux"),
+ Some("SID-attached"),
);
}
#[tokio::test(flavor = "multi_thread")]
@@ -454,15 +457,15 @@ async fn get_request_post_data_respects_recorded_session_visibility() {
bc.active_page_target_mut()
.runtime_slot
.enable_primary_network_events();
- assert!(bc.assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned()));
- bc.enable_auxiliary_network_events("SID-aux");
- bc.record_pending_response_body("REQ-aux-only".to_owned(), [Some("SID-aux".to_owned())]);
+ assert!(bc.assign_attached_session_to_target("TID-1", "SID-attached".to_owned()));
+ bc.enable_attached_network_events("SID-attached");
+ bc.record_pending_response_body("REQ-aux-only".to_owned(), [Some("SID-attached".to_owned())]);
bc.active_page_target_mut()
.runtime_slot
.record_captured_request_body_with_collector_scope(
"REQ-aux-only".to_owned(),
b"aux-only body".to_vec(),
- [Some("SID-aux".to_owned())],
+ [Some("SID-attached".to_owned())],
std::iter::empty::<String>(),
false,
);
@@ -480,14 +483,14 @@ async fn get_request_post_data_respects_recorded_session_visibility() {
ctx.process_async(json!({
"id": 7_289,
"method": "Network.getRequestPostData",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": { "requestId": "REQ-aux-only" }
}))
.await;
ctx.expect_result(
7_289,
json!({ "postData": "aux-only body", "base64Encoded": false }),
- Some("SID-aux"),
+ Some("SID-attached"),
);
}
diff --git a/moli-protocol/src/domains/network/tests/session.rs b/moli-protocol/src/domains/network/tests/session.rs
index d7d1e76f7..fdf87e3c8 100644
--- a/moli-protocol/src/domains/network/tests/session.rs
+++ b/moli-protocol/src/domains/network/tests/session.rs
@@ -255,33 +255,33 @@ async fn commit_configuration_resolves_the_exact_target_network_runtime() {
}
#[tokio::test(flavor = "multi_thread")]
-async fn auxiliary_network_enable_does_not_enable_primary_session() {
+async fn attached_network_enable_does_not_enable_primary_session() {
let mut ctx = TestContext::new();
let mut bc = BrowserContext::new_with_page_for_test("BID-1", "TID-1");
bc.set_active_target_id("TID-1".to_owned());
bc.attach_active_session("SID-primary".to_owned());
- assert!(bc.assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned()));
+ assert!(bc.assign_attached_session_to_target("TID-1", "SID-attached".to_owned()));
ctx.conn.browser_context = Some(bc);
ctx.process_async(json!({
"id": 10_101,
"method": "Network.enable",
- "sessionId": "SID-aux"
+ "sessionId": "SID-attached"
}))
.await;
- ctx.expect_result(10_101, json!({}), Some("SID-aux"));
+ ctx.expect_result(10_101, json!({}), Some("SID-attached"));
let bc = ctx.conn.browser_context.as_ref().unwrap();
assert!(
!bc.active_page_target()
.runtime_slot
.primary_network_events_enabled(),
- "auxiliary Network.enable must not enable the primary session"
+ "attached Network.enable must not enable the primary session"
);
assert!(bc.has_network_event_listeners());
assert_eq!(
bc.network_event_session_ids(Some("SID-primary")),
- vec![Some("SID-aux".to_owned())]
+ vec![Some("SID-attached".to_owned())]
);
}
@@ -291,10 +291,10 @@ async fn page_network_policy_aggregates_enabled_sessions_like_chromium_handlers(
let mut bc = BrowserContext::new_with_page_for_test("BID-1", "TID-1");
bc.set_active_target_id("TID-1".to_owned());
bc.attach_active_session("SID-primary".to_owned());
- assert!(bc.assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned()));
+ assert!(bc.assign_attached_session_to_target("TID-1", "SID-attached".to_owned()));
ctx.conn.browser_context = Some(bc);
- for (id, session_id) in [(20_001, "SID-primary"), (20_002, "SID-aux")] {
+ for (id, session_id) in [(20_001, "SID-primary"), (20_002, "SID-attached")] {
ctx.process_async(json!({
"id": id,
"method": "Network.enable",
@@ -331,25 +331,25 @@ async fn page_network_policy_aggregates_enabled_sessions_like_chromium_handlers(
),
(
20_006,
- "SID-aux",
+ "SID-attached",
"Network.setCacheDisabled",
json!({"cacheDisabled": false}),
),
(
20_007,
- "SID-aux",
+ "SID-attached",
"Network.setBypassServiceWorker",
json!({"bypass": false}),
),
(
20_008,
- "SID-aux",
+ "SID-attached",
"Network.setExtraHTTPHeaders",
json!({"headers": {"X-Aux": "aux", "x-shared": "aux"}}),
),
(
20_012,
- "SID-aux",
+ "SID-attached",
"Network.setBlockedURLs",
json!({"urls": ["*aux-only*", "*shared-pattern*"]}),
),
@@ -541,7 +541,7 @@ async fn enable_after_page_load_does_not_replay_historical_subresource_events()
server.abort();
}
#[tokio::test(flavor = "multi_thread")]
-async fn auxiliary_enable_after_pending_subresource_does_not_replay_history_to_new_session() {
+async fn attached_enable_after_pending_subresource_does_not_replay_history_to_new_session() {
async fn page() -> impl IntoResponse {
(
[(CONTENT_TYPE.as_str(), "text/html")],
@@ -575,7 +575,7 @@ async fn auxiliary_enable_after_pending_subresource_does_not_replay_history_to_n
let mut bc = BrowserContext::new_with_page_for_test("BID-1", "TID-1");
bc.set_active_target_id("TID-1");
bc.attach_active_session("SID-primary");
- assert!(bc.assign_auxiliary_session_to_target("TID-1", "SID-aux".into()));
+ assert!(bc.assign_attached_session_to_target("TID-1", "SID-attached".into()));
ctx.conn.browser_context = Some(bc);
ctx.process_async(json!({
@@ -601,7 +601,7 @@ async fn auxiliary_enable_after_pending_subresource_does_not_replay_history_to_n
wait_until_messages(
&mut ctx,
"SID-primary",
- "primary subresource delivery before auxiliary Network.enable",
+ "primary subresource delivery before attached Network.enable",
|messages| {
messages.iter().any(|message| {
message["method"] == json!("Network.requestWillBeSent")
@@ -628,38 +628,38 @@ async fn auxiliary_enable_after_pending_subresource_does_not_replay_history_to_n
ctx.process_async(json!({
"id": 10_122,
"method": "Network.enable",
- "sessionId": "SID-aux"
+ "sessionId": "SID-attached"
}))
.await;
- ctx.expect_result(10_122, json!({}), Some("SID-aux"));
+ ctx.expect_result(10_122, json!({}), Some("SID-attached"));
ctx.process_async(json!({
"id": 10_123,
"method": "Runtime.evaluate",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": { "expression": "globalThis.__pending_before_aux_network_enable" }
}))
.await;
ctx.expect_result(
10_123,
json!({ "result": { "type": "boolean", "value": true }}),
- Some("SID-aux"),
+ Some("SID-attached"),
);
let messages = ctx.take_all();
assert!(
!messages.iter().any(|message| {
message["method"] == json!("Network.requestWillBeSent")
- && message["sessionId"] == json!("SID-aux")
+ && message["sessionId"] == json!("SID-attached")
&& message["params"]["request"]["url"] == json!(script_url)
}),
- "newly enabled auxiliary listener must not receive subresource events from before its Network.enable"
+ "newly enabled attached listener must not receive subresource events from before its Network.enable"
);
server.abort();
}
#[tokio::test(flavor = "multi_thread")]
-async fn websocket_runtime_activity_broadcasts_to_auxiliary_network_session() {
+async fn websocket_runtime_activity_broadcasts_to_attached_network_session() {
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
let addr = listener.local_addr().unwrap();
let server = tokio::spawn(async move {
@@ -683,8 +683,8 @@ async fn websocket_runtime_activity_broadcasts_to_auxiliary_network_session() {
.enable_primary_network_events();
bc.attach_active_session("SID-primary".to_owned());
bc.set_active_target_id("TID-1".to_owned());
- assert!(bc.assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned()));
- bc.enable_auxiliary_network_events("SID-aux");
+ assert!(bc.assign_attached_session_to_target("TID-1", "SID-attached".to_owned()));
+ bc.enable_attached_network_events("SID-attached");
ctx.conn.browser_context = Some(bc);
ctx.install_navigation_fixture_for_session_owner(&page_url, Some("SID-primary"))
.await;
@@ -708,11 +708,11 @@ async fn websocket_runtime_activity_broadcasts_to_auxiliary_network_session() {
wait_until_messages(
&mut ctx,
- "SID-aux",
- "auxiliary session websocket CDP frame events",
+ "SID-attached",
+ "attached session websocket CDP frame events",
|messages| {
messages.iter().any(|message| {
- message["sessionId"] == json!("SID-aux")
+ message["sessionId"] == json!("SID-attached")
&& message["method"] == json!("Network.webSocketFrameReceived")
&& message["params"]["response"]["payloadLength"] == json!(9)
})
@@ -734,19 +734,19 @@ async fn websocket_runtime_activity_broadcasts_to_auxiliary_network_session() {
.expect("primary websocket request id")
.to_owned();
- let auxiliary_created = ctx
+ let attached_created = ctx
.sent
.iter()
.find(|message| {
- message["sessionId"] == json!("SID-aux")
+ message["sessionId"] == json!("SID-attached")
&& message["method"] == json!("Network.webSocketCreated")
})
- .expect("auxiliary webSocketCreated event");
- assert_eq!(auxiliary_created["params"]["url"], socket_url);
+ .expect("attached webSocketCreated event");
+ assert_eq!(attached_created["params"]["url"], socket_url);
assert_eq!(
- auxiliary_created["params"]["requestId"],
+ attached_created["params"]["requestId"],
json!(request_id),
- "primary and auxiliary sessions must observe the same WebSocket requestId"
+ "primary and attached sessions must observe the same WebSocket requestId"
);
assert!(ctx.sent.iter().any(|message| {
message["sessionId"] == json!("SID-primary")
@@ -755,7 +755,7 @@ async fn websocket_runtime_activity_broadcasts_to_auxiliary_network_session() {
&& message["params"]["response"]["payloadLength"] == json!(9)
}));
assert!(ctx.sent.iter().any(|message| {
- message["sessionId"] == json!("SID-aux")
+ message["sessionId"] == json!("SID-attached")
&& message["method"] == json!("Network.webSocketFrameReceived")
&& message["params"]["requestId"] == json!(request_id)
&& message["params"]["response"]["payloadLength"] == json!(9)
@@ -764,7 +764,7 @@ async fn websocket_runtime_activity_broadcasts_to_auxiliary_network_session() {
server.abort();
}
#[tokio::test(flavor = "multi_thread")]
-async fn auxiliary_network_enable_after_websocket_activity_does_not_replay_history() {
+async fn attached_network_enable_after_websocket_activity_does_not_replay_history() {
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
let addr = listener.local_addr().unwrap();
let server = tokio::spawn(async move {
@@ -788,7 +788,7 @@ async fn auxiliary_network_enable_after_websocket_activity_does_not_replay_histo
.runtime_slot
.enable_primary_network_events();
bc.attach_active_session("SID-primary".to_owned());
- assert!(bc.assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned()));
+ assert!(bc.assign_attached_session_to_target("TID-1", "SID-attached".to_owned()));
ctx.conn.browser_context = Some(bc);
ctx.install_navigation_fixture_for_session_owner(&page_url, Some("SID-primary"))
.await;
@@ -813,7 +813,7 @@ async fn auxiliary_network_enable_after_websocket_activity_does_not_replay_histo
wait_until_messages(
&mut ctx,
"SID-primary",
- "primary websocket history before auxiliary Network.enable",
+ "primary websocket history before attached Network.enable",
|messages| {
let Some(request_id) = messages.iter().find_map(|message| {
(message["sessionId"] == json!("SID-primary")
@@ -840,14 +840,14 @@ async fn auxiliary_network_enable_after_websocket_activity_does_not_replay_histo
ctx.process_async(json!({
"id": 7_112,
"method": "Network.enable",
- "sessionId": "SID-aux"
+ "sessionId": "SID-attached"
}))
.await;
- ctx.expect_result(7_112, json!({}), Some("SID-aux"));
+ ctx.expect_result(7_112, json!({}), Some("SID-attached"));
ctx.process_async(json!({
"id": 7_113,
"method": "Runtime.evaluate",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": { "expression": "42" }
}))
.await;
@@ -855,19 +855,19 @@ async fn auxiliary_network_enable_after_websocket_activity_does_not_replay_histo
assert!(
ctx.sent.iter().all(|message| {
- message["sessionId"] != json!("SID-aux")
+ message["sessionId"] != json!("SID-attached")
|| !message["method"]
.as_str()
.is_some_and(|method| method.starts_with("Network.webSocket"))
}),
- "late auxiliary Network.enable must not replay old WebSocket events: {:?}",
+ "late attached Network.enable must not replay old WebSocket events: {:?}",
ctx.sent
);
server.abort();
}
#[tokio::test(flavor = "multi_thread")]
-async fn fetch_runtime_activity_broadcasts_to_auxiliary_network_session() {
+async fn fetch_runtime_activity_broadcasts_to_attached_network_session() {
async fn data() -> impl IntoResponse {
([(CONTENT_TYPE.as_str(), "text/plain")], "aux body")
}
@@ -893,8 +893,8 @@ async fn fetch_runtime_activity_broadcasts_to_auxiliary_network_session() {
.runtime_slot
.enable_primary_network_events();
bc.attach_active_session("SID-primary".to_owned());
- assert!(bc.assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned()));
- bc.enable_auxiliary_network_events("SID-aux");
+ assert!(bc.assign_attached_session_to_target("TID-1", "SID-attached".to_owned()));
+ bc.enable_attached_network_events("SID-attached");
ctx.conn.browser_context = Some(bc);
ctx.install_navigation_fixture_for_session_owner(&page_url, Some("SID-primary"))
.await;
@@ -914,10 +914,10 @@ async fn fetch_runtime_activity_broadcasts_to_auxiliary_network_session() {
wait_until_messages(
&mut ctx,
"SID-primary",
- "auxiliary session fetch CDP events",
+ "attached session fetch CDP events",
|messages| {
let Some(request_id) = messages.iter().find_map(|message| {
- if message["sessionId"] == json!("SID-aux")
+ if message["sessionId"] == json!("SID-attached")
&& message["method"] == json!("Network.requestWillBeSent")
&& message["params"]["type"] == json!("Fetch")
{
@@ -929,7 +929,7 @@ async fn fetch_runtime_activity_broadcasts_to_auxiliary_network_session() {
return false;
};
messages.iter().any(|message| {
- message["sessionId"] == json!("SID-aux")
+ message["sessionId"] == json!("SID-attached")
&& message["method"] == json!("Network.loadingFinished")
&& message["params"]["requestId"] == json!(request_id)
})
@@ -941,11 +941,11 @@ async fn fetch_runtime_activity_broadcasts_to_auxiliary_network_session() {
let aux_request = messages
.iter()
.find(|message| {
- message["sessionId"] == json!("SID-aux")
+ message["sessionId"] == json!("SID-attached")
&& message["method"] == json!("Network.requestWillBeSent")
&& message["params"]["type"] == json!("Fetch")
})
- .expect("auxiliary fetch request event");
+ .expect("attached fetch request event");
assert_eq!(aux_request["params"]["documentURL"], page_url);
assert_eq!(
aux_request["params"]["request"]["url"],
@@ -953,7 +953,7 @@ async fn fetch_runtime_activity_broadcasts_to_auxiliary_network_session() {
);
let request_id = aux_request["params"]["requestId"]
.as_str()
- .expect("auxiliary fetch request id")
+ .expect("attached fetch request id")
.to_owned();
assert!(messages.iter().any(|message| {
message["sessionId"] == json!("SID-primary")
@@ -964,7 +964,7 @@ async fn fetch_runtime_activity_broadcasts_to_auxiliary_network_session() {
ctx.process_async(json!({
"id": 7_202,
"method": "Network.getResponseBody",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": { "requestId": request_id }
}))
.await;
@@ -974,13 +974,13 @@ async fn fetch_runtime_activity_broadcasts_to_auxiliary_network_session() {
"body": "aux body",
"base64Encoded": false
}),
- Some("SID-aux"),
+ Some("SID-attached"),
);
server.abort();
}
#[tokio::test(flavor = "multi_thread")]
-async fn background_fetch_runtime_activity_broadcasts_to_auxiliary_network_session() {
+async fn background_fetch_runtime_activity_broadcasts_to_attached_network_session() {
async fn data() -> impl IntoResponse {
(
[(CONTENT_TYPE.as_str(), "text/plain")],
@@ -1013,7 +1013,10 @@ async fn background_fetch_runtime_activity_broadcasts_to_auxiliary_network_sessi
let mut bc = BrowserContext::new("BID-background".into());
bc.insert_page_target_host(target);
assert!(
- bc.assign_auxiliary_session_to_target("TID-background", "SID-aux-background".to_owned())
+ bc.assign_attached_session_to_target(
+ "TID-background",
+ "SID-attached-background".to_owned()
+ )
);
ctx.conn.browser_context = Some(bc);
ctx.install_navigation_fixture_for_session_owner(&page_url, Some("SID-background"))
@@ -1022,10 +1025,10 @@ async fn background_fetch_runtime_activity_broadcasts_to_auxiliary_network_sessi
ctx.process_async(json!({
"id": 7_221,
"method": "Network.enable",
- "sessionId": "SID-aux-background"
+ "sessionId": "SID-attached-background"
}))
.await;
- ctx.expect_result(7_221, json!({}), Some("SID-aux-background"));
+ ctx.expect_result(7_221, json!({}), Some("SID-attached-background"));
ctx.sent.clear();
ctx.process_async(json!({
@@ -1042,10 +1045,10 @@ async fn background_fetch_runtime_activity_broadcasts_to_auxiliary_network_sessi
wait_until_messages(
&mut ctx,
"SID-background",
- "background auxiliary session fetch CDP events",
+ "background attached session fetch CDP events",
|messages| {
let Some(request_id) = messages.iter().find_map(|message| {
- if message["sessionId"] == json!("SID-aux-background")
+ if message["sessionId"] == json!("SID-attached-background")
&& message["method"] == json!("Network.requestWillBeSent")
&& message["params"]["type"] == json!("Fetch")
{
@@ -1057,7 +1060,7 @@ async fn background_fetch_runtime_activity_broadcasts_to_auxiliary_network_sessi
return false;
};
messages.iter().any(|message| {
- message["sessionId"] == json!("SID-aux-background")
+ message["sessionId"] == json!("SID-attached-background")
&& message["method"] == json!("Network.loadingFinished")
&& message["params"]["requestId"] == json!(request_id)
})
@@ -1069,11 +1072,11 @@ async fn background_fetch_runtime_activity_broadcasts_to_auxiliary_network_sessi
let aux_request = messages
.iter()
.find(|message| {
- message["sessionId"] == json!("SID-aux-background")
+ message["sessionId"] == json!("SID-attached-background")
&& message["method"] == json!("Network.requestWillBeSent")
&& message["params"]["type"] == json!("Fetch")
})
- .expect("background auxiliary fetch request event");
+ .expect("background attached fetch request event");
assert_eq!(aux_request["params"]["documentURL"], page_url);
assert_eq!(
aux_request["params"]["request"]["url"],
@@ -1083,7 +1086,7 @@ async fn background_fetch_runtime_activity_broadcasts_to_auxiliary_network_sessi
server.abort();
}
#[tokio::test(flavor = "multi_thread")]
-async fn main_document_navigation_broadcasts_to_auxiliary_network_session() {
+async fn main_document_navigation_broadcasts_to_attached_network_session() {
async fn next_page() -> impl IntoResponse {
(
[(CONTENT_TYPE.as_str(), "text/html")],
@@ -1113,8 +1116,8 @@ async fn main_document_navigation_broadcasts_to_auxiliary_network_session() {
.runtime_slot
.enable_primary_network_events();
bc.attach_active_session("SID-primary".to_owned());
- assert!(bc.assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned()));
- bc.enable_auxiliary_network_events("SID-aux");
+ assert!(bc.assign_attached_session_to_target("TID-1", "SID-attached".to_owned()));
+ bc.enable_attached_network_events("SID-attached");
ctx.conn.browser_context = Some(bc);
ctx.install_navigation_fixture_for_session_owner(&page_url, Some("SID-primary"))
.await;
@@ -1136,10 +1139,10 @@ async fn main_document_navigation_broadcasts_to_auxiliary_network_session() {
wait_until_messages(
&mut ctx,
Some("SID-primary"),
- "auxiliary session document navigation CDP events",
+ "attached session document navigation CDP events",
|messages| {
messages.iter().any(|message| {
- message["sessionId"] == json!("SID-aux")
+ message["sessionId"] == json!("SID-attached")
&& message["method"] == json!("Network.loadingFinished")
&& message["params"]["requestId"] == json!(LOADER_ID)
})
@@ -1151,16 +1154,16 @@ async fn main_document_navigation_broadcasts_to_auxiliary_network_session() {
let aux_request = messages
.iter()
.find(|message| {
- message["sessionId"] == json!("SID-aux")
+ message["sessionId"] == json!("SID-attached")
&& message["method"] == json!("Network.requestWillBeSent")
&& message["params"]["type"] == json!("Document")
&& message["params"]["request"]["url"] == json!(next_url)
})
- .expect("auxiliary document request event");
+ .expect("attached document request event");
assert_eq!(aux_request["params"]["requestId"], json!(LOADER_ID));
assert_eq!(aux_request["params"]["loaderId"], json!(LOADER_ID));
assert!(messages.iter().any(|message| {
- message["sessionId"] == json!("SID-aux")
+ message["sessionId"] == json!("SID-attached")
&& message["method"] == json!("Network.responseReceived")
&& message["params"]["requestId"] == json!(LOADER_ID)
&& message["params"]["type"] == json!("Document")
@@ -1176,7 +1179,7 @@ async fn main_document_navigation_broadcasts_to_auxiliary_network_session() {
server.abort();
}
#[tokio::test(flavor = "multi_thread")]
-async fn get_response_body_reads_background_auxiliary_target_slot() {
+async fn get_response_body_reads_background_attached_target_slot() {
let mut ctx = TestContext::new();
let mut bc = BrowserContext::new("BID-1".into());
bc.set_active_target_id("TID-active".to_owned());
@@ -1187,34 +1190,37 @@ async fn get_response_body_reads_background_auxiliary_target_slot() {
"https://background.example/".to_owned(),
));
assert!(
- bc.assign_auxiliary_session_to_target("TID-background", "SID-aux-background".to_owned())
+ bc.assign_attached_session_to_target(
+ "TID-background",
+ "SID-attached-background".to_owned()
+ )
);
ctx.conn.browser_context = Some(bc);
assert!(
ctx.conn
- .enable_network_listener_for_session_owner(Some("SID-aux-background"))
+ .enable_network_listener_for_session_owner(Some("SID-attached-background"))
);
ctx.conn
- .runtime_session_owner_slot_mut(Some("SID-aux-background"))
- .expect("background auxiliary runtime slot")
+ .runtime_session_owner_slot_mut(Some("SID-attached-background"))
+ .expect("background attached runtime slot")
.record_captured_response_body(
"REQ-background".to_owned(),
"background body".to_owned(),
- [Some("SID-aux-background".to_owned())],
+ [Some("SID-attached-background".to_owned())],
);
ctx.process_async(json!({
"id": 7_282,
"method": "Network.getResponseBody",
- "sessionId": "SID-aux-background",
+ "sessionId": "SID-attached-background",
"params": { "requestId": "REQ-background" }
}))
.await;
ctx.expect_result(
7_282,
json!({ "body": "background body", "base64Encoded": false }),
- Some("SID-aux-background"),
+ Some("SID-attached-background"),
);
ctx.process_async(json!({
@@ -1235,50 +1241,53 @@ async fn network_disable_removes_session_response_body_visibility() {
bc.active_page_target_mut()
.runtime_slot
.enable_primary_network_events();
- assert!(bc.assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned()));
- bc.enable_auxiliary_network_events("SID-aux");
+ assert!(bc.assign_attached_session_to_target("TID-1", "SID-attached".to_owned()));
+ bc.enable_attached_network_events("SID-attached");
bc.record_captured_response_body(
"REQ-shared".to_owned(),
"shared body".to_owned(),
- [Some("SID-primary".to_owned()), Some("SID-aux".to_owned())],
+ [
+ Some("SID-primary".to_owned()),
+ Some("SID-attached".to_owned()),
+ ],
);
bc.record_captured_response_body(
"REQ-aux-only".to_owned(),
"aux-only body".to_owned(),
- [Some("SID-aux".to_owned())],
+ [Some("SID-attached".to_owned())],
);
ctx.conn.browser_context = Some(bc);
ctx.process_async(json!({
"id": 7_290,
"method": "Network.disable",
- "sessionId": "SID-aux"
+ "sessionId": "SID-attached"
}))
.await;
- ctx.expect_result(7_290, json!({}), Some("SID-aux"));
+ ctx.expect_result(7_290, json!({}), Some("SID-attached"));
let bc = ctx.conn.browser_context.as_ref().unwrap();
assert!(
bc.has_captured_response_body_for_test("REQ-shared"),
- "shared body remains visible to primary after auxiliary Network.disable"
+ "shared body remains visible to primary after attached Network.disable"
);
assert!(
!bc.has_captured_response_body_for_test("REQ-aux-only"),
- "auxiliary-only body is dropped when that session disables Network"
+ "attached-only body is dropped when that session disables Network"
);
ctx.process_async(json!({
"id": 7_291,
"method": "Network.enable",
- "sessionId": "SID-aux"
+ "sessionId": "SID-attached"
}))
.await;
- ctx.expect_result(7_291, json!({}), Some("SID-aux"));
+ ctx.expect_result(7_291, json!({}), Some("SID-attached"));
ctx.process_async(json!({
"id": 7_292,
"method": "Network.getResponseBody",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": { "requestId": "REQ-shared" }
}))
.await;
@@ -1320,7 +1329,7 @@ async fn disable_clears_enabled_flag_and_captured_bodies() {
assert!(bc.captured_response_bodies_empty_for_test());
}
#[tokio::test(flavor = "multi_thread")]
-async fn primary_network_disable_preserves_auxiliary_network_session() {
+async fn primary_network_disable_preserves_attached_network_session() {
let mut ctx = TestContext::new();
let mut bc = BrowserContext::new("BID-1".into());
bc.set_active_target_id("TID-1".to_owned());
@@ -1328,12 +1337,15 @@ async fn primary_network_disable_preserves_auxiliary_network_session() {
bc.active_page_target_mut()
.runtime_slot
.enable_primary_network_events();
- assert!(bc.assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned()));
- bc.enable_auxiliary_network_events("SID-aux");
+ assert!(bc.assign_attached_session_to_target("TID-1", "SID-attached".to_owned()));
+ bc.enable_attached_network_events("SID-attached");
bc.record_captured_response_body(
"REQ-1".to_owned(),
"body".to_owned(),
- [Some("SID-primary".to_owned()), Some("SID-aux".to_owned())],
+ [
+ Some("SID-primary".to_owned()),
+ Some("SID-attached".to_owned()),
+ ],
);
ctx.conn.browser_context = Some(bc);
@@ -1355,31 +1367,31 @@ async fn primary_network_disable_preserves_auxiliary_network_session() {
assert!(
bc.active_page_target()
.runtime_slot
- .has_auxiliary_network_events_for_session("SID-aux")
+ .has_attached_network_events_for_session("SID-attached")
);
assert!(
bc.has_captured_response_body_for_test("REQ-1"),
- "shared body cache remains observable while an auxiliary Network session is enabled"
+ "shared body cache remains observable while an attached Network session is enabled"
);
assert_eq!(
bc.network_event_session_ids(Some("SID-primary")),
- vec![Some("SID-aux".to_owned())]
+ vec![Some("SID-attached".to_owned())]
);
ctx.process_async(json!({
"id": 10_202,
"method": "Network.disable",
- "sessionId": "SID-aux"
+ "sessionId": "SID-attached"
}))
.await;
- ctx.expect_result(10_202, json!({}), Some("SID-aux"));
+ ctx.expect_result(10_202, json!({}), Some("SID-attached"));
let bc = ctx.conn.browser_context.as_ref().unwrap();
assert!(!bc.has_network_event_listeners());
assert!(bc.captured_response_bodies_empty_for_test());
}
#[tokio::test(flavor = "multi_thread")]
-async fn parser_external_script_navigation_broadcasts_network_events_to_auxiliary_session() {
+async fn parser_external_script_navigation_broadcasts_network_events_to_attached_session() {
const SCRIPT_BODY: &str =
r#"globalThis.__lm_aux_parser_script_loaded = "aux parser script body";"#;
@@ -1419,16 +1431,16 @@ async fn parser_external_script_navigation_broadcasts_network_events_to_auxiliar
let mut bc = BrowserContext::new("BID-1".into());
bc.set_active_target_id("TID-1");
bc.attach_active_session("SID-primary");
- assert!(bc.assign_auxiliary_session_to_target("TID-1", "SID-aux".into()));
+ assert!(bc.assign_attached_session_to_target("TID-1", "SID-attached".into()));
ctx.conn.browser_context = Some(bc);
ctx.process_async(json!({
"id": 70_050,
"method": "Network.enable",
- "sessionId": "SID-aux"
+ "sessionId": "SID-attached"
}))
.await;
- ctx.expect_result(70_050, json!({}), Some("SID-aux"));
+ ctx.expect_result(70_050, json!({}), Some("SID-attached"));
ctx.process_async(json!({
"id": 70_051,
@@ -1440,11 +1452,11 @@ async fn parser_external_script_navigation_broadcasts_network_events_to_auxiliar
wait_until_messages(
&mut ctx,
- Some("SID-aux"),
- "auxiliary parser script network events",
+ Some("SID-attached"),
+ "attached parser script network events",
|messages| {
let Some(request_id) = messages.iter().find_map(|message| {
- if message["sessionId"] == json!("SID-aux")
+ if message["sessionId"] == json!("SID-attached")
&& message["method"] == json!("Network.requestWillBeSent")
&& message["params"]["type"] == json!("Script")
&& message["params"]["request"]["url"] == json!(script_url)
@@ -1457,7 +1469,7 @@ async fn parser_external_script_navigation_broadcasts_network_events_to_auxiliar
return false;
};
messages.iter().any(|message| {
- message["sessionId"] == json!("SID-aux")
+ message["sessionId"] == json!("SID-attached")
&& message["method"] == json!("Network.loadingFinished")
&& message["params"]["requestId"] == json!(request_id)
})
@@ -1469,15 +1481,15 @@ async fn parser_external_script_navigation_broadcasts_network_events_to_auxiliar
let script_request = messages
.iter()
.find(|message| {
- message["sessionId"] == json!("SID-aux")
+ message["sessionId"] == json!("SID-attached")
&& message["method"] == json!("Network.requestWillBeSent")
&& message["params"]["type"] == json!("Script")
&& message["params"]["request"]["url"] == json!(script_url)
})
- .expect("auxiliary session should receive parser script request event");
+ .expect("attached session should receive parser script request event");
let script_request_id = script_request["params"]["requestId"]
.as_str()
- .expect("auxiliary parser script request id")
+ .expect("attached parser script request id")
.to_owned();
ctx.process_async(json!({
@@ -1492,7 +1504,7 @@ async fn parser_external_script_navigation_broadcasts_network_events_to_auxiliar
ctx.process_async(json!({
"id": 70_053,
"method": "Network.getResponseBody",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": { "requestId": script_request_id }
}))
.await;
@@ -1502,7 +1514,7 @@ async fn parser_external_script_navigation_broadcasts_network_events_to_auxiliar
"body": SCRIPT_BODY,
"base64Encoded": false
}),
- Some("SID-aux"),
+ Some("SID-attached"),
);
server.abort();
diff --git a/moli-protocol/src/domains/network/tests/subresource.rs b/moli-protocol/src/domains/network/tests/subresource.rs
index 481d7d56e..954cb8c12 100644
--- a/moli-protocol/src/domains/network/tests/subresource.rs
+++ b/moli-protocol/src/domains/network/tests/subresource.rs
@@ -303,8 +303,10 @@ async fn enabling_and_disabling_sessions_replays_aggregated_headers_to_loaded_pa
let mut bc = BrowserContext::new("BID-1".into());
bc.set_active_target_id("TID-1");
bc.attach_active_session("SID-1");
- assert!(bc.assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned()));
+ assert!(bc.assign_attached_session_to_target("TID-1", "SID-attached".to_owned()));
ctx.conn.browser_context = Some(bc);
+ ctx.conn.register_bound_session_for_test("SID-1");
+ ctx.conn.register_bound_session_for_test("SID-attached");
ctx.process_async(json!({
"id": 50_001,
@@ -319,7 +321,10 @@ async fn enabling_and_disabling_sessions_replays_aggregated_headers_to_loaded_pa
Some("SID-1"),
);
- for (id, session_id, value) in [(50_002, "SID-1", "primary"), (50_003, "SID-aux", "aux")] {
+ for (id, session_id, value) in [
+ (50_002, "SID-1", "primary"),
+ (50_003, "SID-attached", "aux"),
+ ] {
ctx.process_async(json!({
"id": id,
"method": "Network.setExtraHTTPHeaders",
@@ -371,52 +376,54 @@ async fn enabling_and_disabling_sessions_replays_aggregated_headers_to_loaded_pa
ctx.process_async(json!({
"id": 50_007,
"method": "Network.enable",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
}))
.await;
- ctx.expect_result(50_007, json!({}), Some("SID-aux"));
+ ctx.expect_result(50_007, json!({}), Some("SID-attached"));
fetch_header(&mut ctx, 50_008, &api_url, "aux").await;
ctx.process_async(json!({
"id": 50_009,
"method": "Network.disable",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
}))
.await;
- ctx.expect_result(50_009, json!({}), Some("SID-aux"));
+ ctx.expect_result(50_009, json!({}), Some("SID-attached"));
fetch_header(&mut ctx, 50_010, &api_url, "primary").await;
ctx.process_async(json!({
"id": 50_011,
"method": "Network.enable",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
}))
.await;
- ctx.expect_result(50_011, json!({}), Some("SID-aux"));
+ ctx.expect_result(50_011, json!({}), Some("SID-attached"));
fetch_header(&mut ctx, 50_012, &api_url, "primary").await;
ctx.process_async(json!({
"id": 50_013,
"method": "Network.setExtraHTTPHeaders",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": {"headers": {"X-Shared": "aux-after-enable"}},
}))
.await;
- ctx.expect_result(50_013, json!({}), Some("SID-aux"));
+ ctx.expect_result(50_013, json!({}), Some("SID-attached"));
fetch_header(&mut ctx, 50_014, &api_url, "aux-after-enable").await;
ctx.conn
- .clear_target_session_overrides_async("SID-aux")
+ .clear_devtools_network_session_policy_async("SID-attached")
.await
- .expect("detaching the auxiliary session should restore effective request policy");
- assert_eq!(
+ .expect("detaching the attached session should restore effective request policy");
+ assert!(
ctx.conn
.browser_context
.as_mut()
.unwrap()
- .remove_auxiliary_session("SID-aux")
- .as_deref(),
- Some("TID-1")
+ .remove_page_session_binding(
+ "TID-1",
+ "SID-attached",
+ &moli_page_types::DevToolsSessionKey::Attached("SID-attached".to_owned()),
+ )
);
fetch_header(&mut ctx, 50_015, &api_url, "primary").await;
diff --git a/moli-protocol/src/domains/observable_output/emission.rs b/moli-protocol/src/domains/observable_output/emission.rs
index 6d2f948b8..b0a2f0c38 100644
--- a/moli-protocol/src/domains/observable_output/emission.rs
+++ b/moli-protocol/src/domains/observable_output/emission.rs
@@ -813,7 +813,7 @@ mod tests {
}
#[tokio::test(flavor = "multi_thread")]
- async fn target_promotion_transfers_page_attachment_without_retargeting_prepared_output() {
+ async fn target_activation_preserves_page_attachment_ownership_without_retargeting_output() {
let mut ctx = TestContext::new();
let active_page = ctx
.conn
@@ -822,13 +822,13 @@ mod tests {
)
.await
.expect("active test page should load");
- let promoted_page = ctx
+ let activated_page = ctx
.conn
.load_page_via_runtime_async(
- "data:text/html,<!doctype html><script>console.warn('promoted owner')</script>",
+ "data:text/html,<!doctype html><script>console.warn('activated owner')</script>",
)
.await
- .expect("promoted test page should load");
+ .expect("activated test page should load");
let mut bc = BrowserContext::new("BID-1".into());
bc.set_active_target_id("TID-active".to_owned());
@@ -840,32 +840,32 @@ mod tests {
.console_output_session_state
.console_enabled = true;
bc.insert_page_target_host(PageTargetHost::new(
- "TID-promoted".to_owned(),
- Some("SID-promoted".to_owned()),
- TargetIdentityState::with_url("data:text/html,promoted-owner".to_owned()),
- TargetPageSlot::with_loaded_page_for_test(promoted_page),
+ "TID-activated".to_owned(),
+ Some("SID-activated".to_owned()),
+ TargetIdentityState::with_url("data:text/html,activated-owner".to_owned()),
+ TargetPageSlot::with_loaded_page_for_test(activated_page),
));
- bc.background_target_mut("TID-promoted")
+ bc.background_target_mut("TID-activated")
.expect("background target must exist")
.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
.console_output_session_state
.console_enabled = true;
ctx.conn.browser_context = Some(bc);
- let (old_active_attachment, promoted_attachment) = {
+ let (old_active_attachment, activated_attachment) = {
let bc = ctx.conn.browser_context.as_ref().expect("browser context");
(
bc.active_page_target()
.runtime_slot
.page_attachment_id()
.expect("active Page attachment"),
- bc.background_target("TID-promoted")
- .expect("promoted target")
+ bc.background_target("TID-activated")
+ .expect("activated target")
.page_attachment_id()
- .expect("promoted Page attachment"),
+ .expect("activated Page attachment"),
)
};
- assert_ne!(old_active_attachment, promoted_attachment);
+ assert_ne!(old_active_attachment, activated_attachment);
let mut old_active_prepared =
observable_backlog_activity_outputs(&ctx.conn, None).into_prepared_slot();
@@ -876,25 +876,25 @@ mod tests {
.browser_context
.as_mut()
.expect("browser context")
- .select_page_target_async("TID-promoted")
+ .select_page_target_async("TID-activated")
.await
- .expect("target promotion should succeed")
+ .expect("target activation should succeed")
);
{
let bc = ctx.conn.browser_context.as_ref().expect("browser context");
- assert_eq!(bc.active_target_id(), Some("TID-promoted"));
+ assert_eq!(bc.active_target_id(), Some("TID-activated"));
assert_eq!(
bc.active_page_target().runtime_slot.page_attachment_id(),
- Some(promoted_attachment),
- "promotion must transfer the installed Page attachment without reallocating it"
+ Some(activated_attachment),
+ "activation must preserve the selected target's Page attachment"
);
assert_eq!(
bc.background_target("TID-active")
- .expect("previous active target should be parked")
+ .expect("previous active target should be background")
.page_attachment_id(),
Some(old_active_attachment),
- "parking must transfer the previous active Page attachment with its target slot"
+ "deactivation must leave the Page attachment with its original target host"
);
}
@@ -907,7 +907,7 @@ mod tests {
)
.await
.is_none(),
- "prepared output from the old active owner must not materialize on the promoted target"
+ "prepared output from the old active owner must not materialize on the activated target"
);
let old_owner_plan = ObservableActivityEmissionPlan::prepare_async(
@@ -917,7 +917,7 @@ mod tests {
Some(old_active_owner_prepared.outputs_mut_for_test()),
)
.await
- .expect("prepared output must remain addressable through its parked owner");
+ .expect("prepared output must remain addressable through its background owner");
let mut old_owner_out = Vec::new();
old_owner_plan.emit(&mut ctx.conn, &mut old_owner_out, Some("SID-active"));
assert!(old_owner_out.iter().any(|message| {
@@ -925,21 +925,21 @@ mod tests {
&& message["params"]["message"]["text"] == json!("old active owner")
}));
- let mut promoted_prepared =
+ let mut activated_prepared =
observable_backlog_activity_outputs(&ctx.conn, None).into_prepared_slot();
- let promoted_plan = ObservableActivityEmissionPlan::prepare_async(
+ let activated_plan = ObservableActivityEmissionPlan::prepare_async(
ObservableOutputProjectionStep::Console,
&mut ctx.conn,
None,
- Some(promoted_prepared.outputs_mut_for_test()),
+ Some(activated_prepared.outputs_mut_for_test()),
)
.await
- .expect("promoted target current Page output should remain visible");
- let mut promoted_out = Vec::new();
- promoted_plan.emit(&mut ctx.conn, &mut promoted_out, None);
- assert!(promoted_out.iter().any(|message| {
+ .expect("activated target current Page output should remain visible");
+ let mut activated_out = Vec::new();
+ activated_plan.emit(&mut ctx.conn, &mut activated_out, None);
+ assert!(activated_out.iter().any(|message| {
message["method"] == json!("Console.messageAdded")
- && message["params"]["message"]["text"] == json!("promoted owner")
+ && message["params"]["message"]["text"] == json!("activated owner")
}));
}
diff --git a/moli-protocol/src/domains/observable_output/presence.rs b/moli-protocol/src/domains/observable_output/presence.rs
index f0eeed3b9..16274e1b8 100644
--- a/moli-protocol/src/domains/observable_output/presence.rs
+++ b/moli-protocol/src/domains/observable_output/presence.rs
@@ -576,11 +576,11 @@ mod tests {
bc.set_active_target_id("TID-runtime-lifecycle".to_owned());
bc.set_target_url("https://example.test/runtime-lifecycle".to_owned());
bc.attach_active_session("SID-runtime-a".to_owned());
- assert!(bc.assign_auxiliary_session_to_target(
+ assert!(bc.assign_attached_session_to_target(
"TID-runtime-lifecycle",
"SID-runtime-b".to_owned(),
));
- assert!(bc.assign_auxiliary_session_to_target(
+ assert!(bc.assign_attached_session_to_target(
"TID-runtime-lifecycle",
"SID-runtime-disabled".to_owned(),
));
diff --git a/moli-protocol/src/domains/observable_output/runtime_emission.rs b/moli-protocol/src/domains/observable_output/runtime_emission.rs
index 18c6798ff..dc4787cc5 100644
--- a/moli-protocol/src/domains/observable_output/runtime_emission.rs
+++ b/moli-protocol/src/domains/observable_output/runtime_emission.rs
@@ -315,7 +315,7 @@ mod tests {
}
#[test]
- fn runtime_observable_auxiliary_session_uses_own_browser_context() {
+ fn runtime_observable_attached_session_uses_own_browser_context() {
let mut conn = crate::conn::CdpConnection::default();
conn.browser_context = Some(BrowserContext::new("BID-active".to_owned()));
@@ -324,36 +324,38 @@ mod tests {
inactive
.active_page_target_mut()
.devtools_sessions
- .ensure_attached("SID-aux")
+ .ensure_attached("SID-attached")
.runtime_session_state
.runtime_frontend_enabled = true;
- assert!(inactive.assign_auxiliary_session_to_target("TID-inactive", "SID-aux".to_owned()));
+ assert!(
+ inactive.assign_attached_session_to_target("TID-inactive", "SID-attached".to_owned())
+ );
conn.inactive_browser_contexts.push(inactive);
assert!(
retain_unemitted_runtime_observable_prepared_source_for_session_owner(
&conn,
- Some("SID-aux"),
+ Some("SID-attached"),
prepared_source(),
)
.is_some(),
- "auxiliary runtime observable presence should read the inactive owner context"
+ "attached runtime observable presence should read the inactive owner context"
);
mark_runtime_observable_activity_emitted_for_session_owner(
&mut conn,
- Some("SID-aux"),
+ Some("SID-attached"),
HashMap::from([(7, 1)]),
1,
);
assert!(
retain_unemitted_runtime_observable_prepared_source_for_session_owner(
&conn,
- Some("SID-aux"),
+ Some("SID-attached"),
prepared_source(),
)
.is_none(),
- "auxiliary runtime observable mark should write the inactive owner context"
+ "attached runtime observable mark should write the inactive owner context"
);
}
}
diff --git a/moli-protocol/src/domains/page.rs b/moli-protocol/src/domains/page.rs
index e259502bb..39fb16345 100644
--- a/moli-protocol/src/domains/page.rs
+++ b/moli-protocol/src/domains/page.rs
@@ -66,6 +66,16 @@ mod termination;
#[cfg(test)]
mod tests;
+/// Removes renderer-owned Page resources for one DevTools session while its
+/// Inspector binding is still usable for cleanup commands.
+pub(in crate::domains) async fn dispose_session_async(
+ conn: &mut CdpConnection,
+ session_id: &str,
+) -> anyhow::Result<()> {
+ conn.remove_document_start_scripts_for_detached_session_async(session_id)
+ .await
+}
+
fn missing_page_target_error_message(
conn: &CdpConnection,
session_id: Option<&str>,
@@ -2799,22 +2809,24 @@ mod producer_tests {
browser_context.set_active_target_id("TID-dialog-attachment");
browser_context.attach_active_session("SID-primary");
assert!(
- browser_context
- .assign_auxiliary_session_to_target("TID-dialog-attachment", "SID-aux".to_owned(),)
+ browser_context.assign_attached_session_to_target(
+ "TID-dialog-attachment",
+ "SID-attached".to_owned(),
+ )
);
conn.browser_context = Some(browser_context);
- let page_owner = page_residence_identity_for_test(&mut conn, "SID-aux");
+ let page_owner = page_residence_identity_for_test(&mut conn, "SID-attached");
let mut prepared =
ProtocolOutputPayloads::from_slot(super::PagePreparedOutputSlot::from_outputs(
super::PagePreparedOutputs::from_javascript_dialogs_for_test(
page_owner,
- Some("SID-aux"),
- javascript_dialog_scope_for_test(&conn, "SID-aux"),
+ Some("SID-attached"),
+ javascript_dialog_scope_for_test(&conn, "SID-attached"),
"TID-dialog-attachment",
vec![renderer_javascript_dialog_for_test(
renderer_document_identity_for_test(1, 1),
"FRAME-child",
- "auxiliary attachment dialog",
+ "attached-session dialog",
None,
)],
),
@@ -2830,7 +2842,7 @@ mod producer_tests {
assert_eq!(out.len(), 1);
let message = out.remove(0).into_protocol_message();
- assert_eq!(message["sessionId"], json!("SID-aux"));
+ assert_eq!(message["sessionId"], json!("SID-attached"));
assert_eq!(message["params"]["frameId"], json!("FRAME-child"));
assert!(
conn.target_page_session_state_for_session(Some("SID-primary"))
@@ -2840,8 +2852,8 @@ mod producer_tests {
"drain-time session must not acquire another attachment's dialog"
);
assert_eq!(
- conn.target_page_session_state_for_session(Some("SID-aux"))
- .expect("auxiliary session state")
+ conn.target_page_session_state_for_session(Some("SID-attached"))
+ .expect("attached session state")
.javascript_dialog_state
.pending_dialogs()
.len(),
@@ -2856,7 +2868,7 @@ mod producer_tests {
browser_context.set_active_target_id("TID-dialog-detached");
browser_context.attach_active_session("SID-primary");
assert!(
- browser_context.assign_auxiliary_session_to_target(
+ browser_context.assign_attached_session_to_target(
"TID-dialog-detached",
"SID-detached".to_owned(),
)
@@ -2878,13 +2890,15 @@ mod producer_tests {
)],
),
));
- assert_eq!(
+ assert!(
conn.browser_context
.as_mut()
.expect("browser context")
- .remove_auxiliary_session("SID-detached")
- .as_deref(),
- Some("TID-dialog-detached")
+ .remove_page_session_binding(
+ "TID-dialog-detached",
+ "SID-detached",
+ &moli_page_types::DevToolsSessionKey::Attached("SID-detached".to_owned()),
+ )
);
let mut out = Vec::new();
@@ -2901,7 +2915,7 @@ mod producer_tests {
}
#[tokio::test(flavor = "multi_thread")]
- async fn parked_popup_dialog_rejects_a_retired_source_attachment() {
+ async fn pending_popup_dialog_rejects_a_retired_source_attachment() {
const POPUP_ID: u64 = 76;
let mut conn = CdpConnection::default();
@@ -2909,7 +2923,7 @@ mod producer_tests {
browser_context.set_active_target_id("TID-popup-stale-source");
browser_context.attach_active_session("SID-primary");
assert!(
- browser_context.assign_auxiliary_session_to_target(
+ browser_context.assign_attached_session_to_target(
"TID-popup-stale-source",
"SID-source".to_owned(),
)
@@ -2944,16 +2958,18 @@ mod producer_tests {
.await;
assert!(
out.is_empty(),
- "dialog should be parked before popup creation"
+ "dialog should remain pending before popup creation"
);
- assert_eq!(
+ assert!(
conn.browser_context
.as_mut()
.expect("browser context")
- .remove_auxiliary_session("SID-source")
- .as_deref(),
- Some("TID-popup-stale-source")
+ .remove_page_session_binding(
+ "TID-popup-stale-source",
+ "SID-source",
+ &moli_page_types::DevToolsSessionKey::Attached("SID-source".to_owned()),
+ )
);
let mut popup_output =
ProtocolOutputPayloads::from_slot(super::PagePreparedOutputSlot::from_outputs(
@@ -3910,22 +3926,24 @@ mod producer_tests {
}
#[tokio::test(flavor = "multi_thread")]
- async fn child_frame_activity_fans_out_page_events_to_enabled_auxiliary_session() {
+ async fn child_frame_activity_fans_out_page_events_to_enabled_attached_session() {
let mut conn = CdpConnection::default();
let mut bc = BrowserContext::new("BID-child-page-fanout".into());
bc.set_active_target_id("TID-child-page-fanout");
bc.set_target_url("https://example.test/page".to_owned());
bc.attach_active_session("SID-primary");
- assert!(bc.assign_auxiliary_session_to_target(
- "TID-child-page-fanout",
- "SID-auxiliary".to_owned(),
- ));
+ assert!(
+ bc.assign_attached_session_to_target(
+ "TID-child-page-fanout",
+ "SID-attached".to_owned(),
+ )
+ );
conn.browser_context = Some(bc);
- conn.with_target_devtools_session_state_for_session_mut(Some("SID-auxiliary"), |state| {
+ conn.with_target_devtools_session_state_for_session_mut(Some("SID-attached"), |state| {
state.page_session_state.page_domain_enabled = true;
state.page_session_state.page_lifecycle_events = true;
})
- .expect("auxiliary session should expose Page state");
+ .expect("attached session should expose Page state");
let source_document = renderer_document_identity_for_test(1, 1);
bind_renderer_document_for_test(
@@ -3954,10 +3972,10 @@ mod producer_tests {
] {
assert!(
out.iter().any(|message| {
- message["sessionId"] == json!("SID-auxiliary")
+ message["sessionId"] == json!("SID-attached")
&& message["method"] == json!(method)
}),
- "Page-enabled auxiliary session should receive {method}: {out:?}"
+ "Page-enabled attached session should receive {method}: {out:?}"
);
assert!(
!out.iter().any(|message| {
@@ -3968,7 +3986,7 @@ mod producer_tests {
);
}
assert!(out.iter().any(|message| {
- message["sessionId"] == json!("SID-auxiliary")
+ message["sessionId"] == json!("SID-attached")
&& message["method"] == json!("Page.lifecycleEvent")
&& message["params"]["frameId"] == json!("CHILD-FRAME-1")
}));
@@ -4046,10 +4064,10 @@ mod producer_tests {
bc.set_active_target_id("TID-1");
bc.set_target_url("https://example.test/page".to_owned());
bc.attach_active_session("SID-1");
- assert!(bc.assign_auxiliary_session_to_target("TID-1", "SID-AUXILIARY".to_owned(),));
+ assert!(bc.assign_attached_session_to_target("TID-1", "SID-ATTACHED".to_owned(),));
conn.browser_context = Some(bc);
assert!(conn.enable_network_listener_for_session_owner(Some("SID-1")));
- assert!(conn.enable_network_listener_for_session_owner(Some("SID-AUXILIARY")));
+ assert!(conn.enable_network_listener_for_session_owner(Some("SID-ATTACHED")));
let source_document = renderer_document_identity_for_test(1, 1);
bind_renderer_document_for_test(&mut conn, "SID-1", "TID-1", source_document);
let mut background_events = Vec::new();
@@ -4149,7 +4167,7 @@ mod producer_tests {
assert_eq!(finished["params"]["requestId"], json!("LID-CHILD-1"));
assert_eq!(finished["params"]["encodedDataLength"], json!(3));
assert!(out.iter().any(|message| {
- message["sessionId"] == json!("SID-AUXILIARY")
+ message["sessionId"] == json!("SID-ATTACHED")
&& message["method"] == json!("Network.loadingFinished")
&& message["params"]["requestId"] == json!("LID-CHILD-1")
}));
@@ -4170,14 +4188,14 @@ mod producer_tests {
ctx.process_async(json!({
"id": 7_504,
"method": "Network.getResponseBody",
- "sessionId": "SID-AUXILIARY",
+ "sessionId": "SID-ATTACHED",
"params": { "requestId": "LID-CHILD-1" }
}))
.await;
ctx.expect_result(
7_504,
json!({ "body": "AP9h", "base64Encoded": true }),
- Some("SID-AUXILIARY"),
+ Some("SID-ATTACHED"),
);
}
diff --git a/moli-protocol/src/domains/page/termination.rs b/moli-protocol/src/domains/page/termination.rs
index 7fbafd18f..6fb233e3a 100644
--- a/moli-protocol/src/domains/page/termination.rs
+++ b/moli-protocol/src/domains/page/termination.rs
@@ -496,7 +496,7 @@ pub(super) async fn complete_crash_command_dispatch(
// issued the command. Settle every attached session before dropping the
// Page; otherwise a late completion from (for example) the primary
// session can wait forever on a response sender owned by the retired
- // renderer while the crash was issued by an auxiliary session.
+ // renderer while the crash was issued by an attached session.
let target_inspector_session_ids = conn.page_event_session_ids_for_owner(owner);
let mut pending_await_events = Vec::new();
for inspector_session_id in &target_inspector_session_ids {
@@ -699,14 +699,22 @@ pub(crate) async fn complete_page_target_termination_owner_action_async(
));
}
out.extend(conn.prepared_target_host_deltas_event_plan(target_detached_info_deltas));
- out.extend(conn.detach_target_closure_cleanup_event_plan(
- closed.into_detach_cleanup_plan(Some("Render process gone.")),
- None,
- ));
- out.extend(conn.detach_closed_top_level_target_sessions_event_plan(
+ out.extend(
+ conn.dispose_target_closure_sessions_event_plan_async(
+ closed.into_detach_cleanup_plan(Some("Render process gone.")),
+ None,
+ )
+ .await,
+ );
+ if let Some(tab_cleanup) = conn.take_closed_top_level_target_sessions_cleanup_plan(
&closed_target_id,
Some("Render process gone."),
- ));
+ ) {
+ out.extend(
+ conn.dispose_target_closure_sessions_event_plan_async(tab_cleanup, None)
+ .await,
+ );
+ }
out.extend(conn.prepared_target_host_deltas_event_plan(target_destroyed_deltas));
conn.release_idle_navigation_engine_memory_after_target_close();
crate::conn::CdpTurnOutcome::new_with_protocol_events(out, conn.take_scheduler_events())
diff --git a/moli-protocol/src/domains/page/tests/capture.rs b/moli-protocol/src/domains/page/tests/capture.rs
index 619e67dbf..33833dda1 100644
--- a/moli-protocol/src/domains/page/tests/capture.rs
+++ b/moli-protocol/src/domains/page/tests/capture.rs
@@ -485,7 +485,7 @@ async fn capture_screenshot_uses_emulated_device_metrics() {
assert_png_dimensions(&screenshot_png_bytes(&response), 1600, 1200);
}
#[tokio::test(flavor = "multi_thread")]
-async fn capture_screenshot_targets_loaded_background_owner_without_promotion() {
+async fn capture_screenshot_targets_loaded_background_owner_without_activation() {
let mut ctx = TestContext::new();
let background = PageTargetHost::with_url(
"TID-background".to_owned(),
@@ -537,7 +537,7 @@ async fn capture_screenshot_targets_loaded_background_owner_without_promotion()
.as_ref()
.and_then(|browser_context| browser_context.active_target_id()),
Some("TID-active"),
- "background Page.captureScreenshot should not promote the target"
+ "background Page.captureScreenshot should not activate the target"
);
}
#[tokio::test(flavor = "multi_thread")]
@@ -945,7 +945,7 @@ async fn get_layout_metrics_queries_live_renderer_for_loaded_pages() {
);
}
#[tokio::test(flavor = "multi_thread")]
-async fn get_layout_metrics_targets_loaded_background_owner_without_promotion() {
+async fn get_layout_metrics_targets_loaded_background_owner_without_activation() {
let mut ctx = TestContext::new();
let page_url = "data:text/html,<html style='width:2300px;height:1700px'><body style='margin:0;width:2300px;height:1700px'><div style='width:2300px;height:1700px'></div></body></html>";
let background = PageTargetHost::with_url(
@@ -1000,7 +1000,7 @@ async fn get_layout_metrics_targets_loaded_background_owner_without_promotion()
.as_ref()
.and_then(|browser_context| browser_context.active_target_id()),
Some("TID-active"),
- "background Page.getLayoutMetrics should not promote the target"
+ "background Page.getLayoutMetrics should not activate the target"
);
}
#[tokio::test(flavor = "multi_thread")]
diff --git a/moli-protocol/src/domains/page/tests/dialog.rs b/moli-protocol/src/domains/page/tests/dialog.rs
index e0f8a650f..ad63b54f4 100644
--- a/moli-protocol/src/domains/page/tests/dialog.rs
+++ b/moli-protocol/src/domains/page/tests/dialog.rs
@@ -115,7 +115,7 @@ fn retiring_page_scope_and_clearing_dialog_state_dismisses_installed_dialog() {
}
#[tokio::test(flavor = "multi_thread")]
-async fn pending_javascript_dialogs_are_preserved_per_parked_target() {
+async fn pending_javascript_dialogs_are_preserved_per_background_target() {
fn dialog(target_id: &str, message: &str) -> crate::conn::TargetJavaScriptDialog {
target_dialog_for_test(
crate::conn::TargetPageResidenceIdentity::new_for_test(
@@ -546,23 +546,24 @@ async fn handle_javascript_dialog_rejects_when_no_dialog_is_showing() {
}
#[tokio::test(flavor = "multi_thread")]
-async fn javascript_dialog_pending_state_is_session_local_for_active_auxiliary_session() {
+async fn javascript_dialog_pending_state_is_session_local_for_active_attached_session() {
let mut ctx = TestContext::new();
load_bc_with_session(
&mut ctx,
- "BID-dialog-aux",
- "TID-dialog-aux",
+ "BID-dialog-attached",
+ "TID-dialog-attached",
"SID-primary",
"about:blank",
);
let browser_context = ctx.conn.browser_context.as_mut().unwrap();
assert!(
- browser_context.assign_auxiliary_session_to_target("TID-dialog-aux", "SID-aux".to_owned())
+ browser_context
+ .assign_attached_session_to_target("TID-dialog-attached", "SID-attached".to_owned())
);
push_dialog_for_session(
&mut ctx,
- Some("SID-aux"),
- dialog_for_test(Some("TID-dialog-aux"), "alert", "aux dialog"),
+ Some("SID-attached"),
+ dialog_for_test(Some("TID-dialog-attached"), "alert", "aux dialog"),
);
assert!(
ctx.conn
@@ -570,7 +571,7 @@ async fn javascript_dialog_pending_state_is_session_local_for_active_auxiliary_s
.expect("primary page session state")
.javascript_dialog_state
.is_empty(),
- "primary session must not see auxiliary pending dialog"
+ "primary session must not see attached pending dialog"
);
ctx.process_async(json!({
@@ -588,7 +589,7 @@ async fn javascript_dialog_pending_state_is_session_local_for_active_auxiliary_s
ctx.process_async(json!({
"id": 37,
"method": "Page.handleJavaScriptDialog",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": { "accept": true }
}))
.await;
@@ -596,20 +597,20 @@ async fn javascript_dialog_pending_state_is_session_local_for_active_auxiliary_s
.sent
.iter()
.find(|message| message["method"] == json!("Page.javascriptDialogClosed"))
- .expect("auxiliary handle should emit closed event");
- assert_eq!(closed["sessionId"], json!("SID-aux"));
- assert_eq!(closed["params"]["frameId"], json!("TID-dialog-aux"));
+ .expect("attached handle should emit closed event");
+ assert_eq!(closed["sessionId"], json!("SID-attached"));
+ assert_eq!(closed["params"]["frameId"], json!("TID-dialog-attached"));
assert_eq!(closed["params"]["result"], json!(true));
- let auxiliary = take_response_by_id(&mut ctx, 37);
- assert_eq!(auxiliary["sessionId"], json!("SID-aux"));
- assert_eq!(auxiliary["result"], json!({}));
+ let attached = take_response_by_id(&mut ctx, 37);
+ assert_eq!(attached["sessionId"], json!("SID-attached"));
+ assert_eq!(attached["result"], json!({}));
assert!(
ctx.conn
- .target_page_session_state_for_session(Some("SID-aux"))
- .expect("auxiliary page session state")
+ .target_page_session_state_for_session(Some("SID-attached"))
+ .expect("attached page session state")
.javascript_dialog_state
.is_empty(),
- "auxiliary handle should consume only its own dialog"
+ "attached handle should consume only its own dialog"
);
}
diff --git a/moli-protocol/src/domains/page/tests/document_content.rs b/moli-protocol/src/domains/page/tests/document_content.rs
index 731014973..5367726ec 100644
--- a/moli-protocol/src/domains/page/tests/document_content.rs
+++ b/moli-protocol/src/domains/page/tests/document_content.rs
@@ -185,7 +185,7 @@ async fn set_document_content_is_observable_from_another_attached_session() {
.browser_context
.as_mut()
.expect("browser context")
- .assign_auxiliary_session_to_target("TID-1", "SID-2".to_owned())
+ .assign_attached_session_to_target("TID-1", "SID-2".to_owned())
);
for (id, session_id, method, params) in [
@@ -273,7 +273,7 @@ async fn set_document_content_is_observable_from_another_attached_session() {
wait_until_scheduler_message(
&mut ctx,
- "setDocumentContent load event on the auxiliary session",
+ "setDocumentContent load event on the attached session",
|message| {
message["method"] == json!("Page.loadEventFired")
&& message["sessionId"] == json!("SID-2")
@@ -285,7 +285,7 @@ async fn set_document_content_is_observable_from_another_attached_session() {
message["method"] == json!("Page.loadEventFired")
&& message["sessionId"] == json!("SID-1")
}),
- "setDocumentContent lifecycle should fan out to the primary and auxiliary sessions: {:?}",
+ "setDocumentContent lifecycle should fan out to the primary and attached sessions: {:?}",
ctx.sent
);
assert!(
diff --git a/moli-protocol/src/domains/page/tests/frame_tree.rs b/moli-protocol/src/domains/page/tests/frame_tree.rs
index d78a86af4..8b546203e 100644
--- a/moli-protocol/src/domains/page/tests/frame_tree.rs
+++ b/moli-protocol/src/domains/page/tests/frame_tree.rs
@@ -551,7 +551,7 @@ async fn pending_get_frame_tree_after_page_unload_returns_empty_target_tree() {
);
}
#[tokio::test(flavor = "multi_thread")]
-async fn get_frame_tree_targets_loaded_background_owner_without_promotion() {
+async fn get_frame_tree_targets_loaded_background_owner_without_activation() {
let mut ctx = TestContext::new();
let page_url = "data:text/html,<iframe name='background-child'></iframe>";
let background = PageTargetHost::with_url(
@@ -595,7 +595,7 @@ async fn get_frame_tree_targets_loaded_background_owner_without_promotion() {
.as_ref()
.and_then(|browser_context| browser_context.active_target_id()),
Some("TID-active"),
- "background Page.getFrameTree should not promote the target"
+ "background Page.getFrameTree should not activate the target"
);
}
#[tokio::test(flavor = "multi_thread")]
diff --git a/moli-protocol/src/domains/page/tests/lifecycle.rs b/moli-protocol/src/domains/page/tests/lifecycle.rs
index 82cdafda9..f146f1f07 100644
--- a/moli-protocol/src/domains/page/tests/lifecycle.rs
+++ b/moli-protocol/src/domains/page/tests/lifecycle.rs
@@ -1000,18 +1000,18 @@ async fn set_lifecycle_events_enabled_replays_only_protocol_visible_load_state()
}
#[tokio::test(flavor = "multi_thread")]
-async fn set_lifecycle_events_enabled_is_session_local_for_active_auxiliary_session() {
+async fn set_lifecycle_events_enabled_is_session_local_for_active_attached_session() {
let mut ctx = TestContext::new();
load_bc_with_session(
&mut ctx,
- "BID-aux-lifecycle",
+ "BID-attached-lifecycle",
"TID-active",
"SID-primary",
"about:blank",
);
let mut navigation = ctx
.conn
- .load_navigation_via_runtime_async("data:text/html,<body>active auxiliary lifecycle</body>")
+ .load_navigation_via_runtime_async("data:text/html,<body>active attached lifecycle</body>")
.await
.expect("page should load");
let navigation_engine = navigation.take_navigation_engine_replacement();
@@ -1021,9 +1021,11 @@ async fn set_lifecycle_events_enabled_is_session_local_for_active_auxiliary_sess
.active_page_target_mut()
.runtime_slot
.set_loaded_page_for_test(navigation.page);
- assert!(browser_context.assign_auxiliary_session_to_target("TID-active", "SID-aux".to_owned()));
+ assert!(
+ browser_context.assign_attached_session_to_target("TID-active", "SID-attached".to_owned())
+ );
let (binding, initial_events) = ctx.conn.bind_renderer_document_lifecycle_for_owner(
- &crate::conn::CommandOwnerScope::for_session("SID-aux"),
+ &crate::conn::CommandOwnerScope::for_session("SID-attached"),
artifacts,
None,
"TID-active".to_owned(),
@@ -1033,17 +1035,17 @@ async fn set_lifecycle_events_enabled_is_session_local_for_active_auxiliary_sess
assert_eq!(initial_events.len(), 2);
if let Some(navigation_engine) = navigation_engine {
ctx.conn.adopt_loaded_navigation_engine_for_owner(
- &crate::conn::CommandOwnerScope::for_session("SID-aux"),
+ &crate::conn::CommandOwnerScope::for_session("SID-attached"),
navigation_engine,
);
}
- let _ = wait_for_visible_renderer_load(&mut ctx, "SID-aux").await;
+ let _ = wait_for_visible_renderer_load(&mut ctx, "SID-attached").await;
ctx.sent.clear();
ctx.process_async(json!({
"id": 20,
"method": "Page.setLifecycleEventsEnabled",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": { "enabled": true }
}))
.await;
@@ -1055,7 +1057,7 @@ async fn set_lifecycle_events_enabled_is_session_local_for_active_auxiliary_sess
.collect::<Vec<_>>();
assert_eq!(lifecycle_events.len(), 2);
assert!(lifecycle_events.iter().all(|message| {
- message["sessionId"] == json!("SID-aux")
+ message["sessionId"] == json!("SID-attached")
&& message["params"]["frameId"] == json!("TID-active")
}));
assert_eq!(
@@ -1065,7 +1067,7 @@ async fn set_lifecycle_events_enabled_is_session_local_for_active_auxiliary_sess
.collect::<Vec<_>>(),
vec!["DOMContentLoaded", "load"]
);
- ctx.expect_result(20, json!({}), Some("SID-aux"));
+ ctx.expect_result(20, json!({}), Some("SID-attached"));
let browser_context = ctx.conn.browser_context.as_ref().unwrap();
assert!(
@@ -1077,15 +1079,15 @@ async fn set_lifecycle_events_enabled_is_session_local_for_active_auxiliary_sess
);
assert!(
ctx.conn
- .target_page_session_state_for_session(Some("SID-aux"))
- .expect("auxiliary page session state")
+ .target_page_session_state_for_session(Some("SID-attached"))
+ .expect("attached page session state")
.page_lifecycle_events,
- "auxiliary page session should own lifecycle enable"
+ "attached page session should own lifecycle enable"
);
}
#[tokio::test(flavor = "multi_thread")]
-async fn set_lifecycle_events_enabled_is_session_local_for_background_auxiliary_session() {
+async fn set_lifecycle_events_enabled_is_session_local_for_background_attached_session() {
let mut ctx = TestContext::new();
let background = PageTargetHost::with_url(
"TID-background".to_owned(),
@@ -1093,27 +1095,29 @@ async fn set_lifecycle_events_enabled_is_session_local_for_background_auxiliary_
"about:blank".to_owned(),
);
- let mut browser_context = BrowserContext::new("BID-background-aux-lifecycle".to_owned());
+ let mut browser_context = BrowserContext::new("BID-background-attached-lifecycle".to_owned());
browser_context.set_active_target_id("TID-active".to_owned());
browser_context.attach_active_session("SID-active".to_owned());
browser_context.insert_page_target_host(background);
assert!(
- browser_context
- .assign_auxiliary_session_to_target("TID-background", "SID-background-aux".to_owned())
+ browser_context.assign_attached_session_to_target(
+ "TID-background",
+ "SID-background-attached".to_owned()
+ )
);
ctx.conn.browser_context = Some(browser_context);
ctx.install_navigation_fixture_for_session_owner(
- "data:text/html,<body>background auxiliary lifecycle</body>",
- Some("SID-background-aux"),
+ "data:text/html,<body>background attached lifecycle</body>",
+ Some("SID-background-attached"),
)
.await;
- let _ = wait_for_visible_renderer_load(&mut ctx, "SID-background-aux").await;
+ let _ = wait_for_visible_renderer_load(&mut ctx, "SID-background-attached").await;
ctx.sent.clear();
ctx.process_async(json!({
"id": 21,
"method": "Page.setLifecycleEventsEnabled",
- "sessionId": "SID-background-aux",
+ "sessionId": "SID-background-attached",
"params": { "enabled": true }
}))
.await;
@@ -1125,7 +1129,7 @@ async fn set_lifecycle_events_enabled_is_session_local_for_background_auxiliary_
.collect::<Vec<_>>();
assert_eq!(lifecycle_events.len(), 2);
assert!(lifecycle_events.iter().all(|message| {
- message["sessionId"] == json!("SID-background-aux")
+ message["sessionId"] == json!("SID-background-attached")
&& message["params"]["frameId"] == json!("TID-background")
}));
assert_eq!(
@@ -1135,34 +1139,34 @@ async fn set_lifecycle_events_enabled_is_session_local_for_background_auxiliary_
.collect::<Vec<_>>(),
vec!["DOMContentLoaded", "load"]
);
- ctx.expect_result(21, json!({}), Some("SID-background-aux"));
+ ctx.expect_result(21, json!({}), Some("SID-background-attached"));
let browser_context = ctx.conn.browser_context.as_ref().unwrap();
- let parked = browser_context
+ let background = browser_context
.background_target("TID-background")
.filter(|target| target.has_non_default_session_state())
- .expect("background target should retain parked page session state");
+ .expect("background target should retain background page session state");
assert!(
- !parked.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
+ !background.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
.page_session_state
.page_lifecycle_events,
"background primary page session should stay disabled"
);
assert!(
ctx.conn
- .target_page_session_state_for_session(Some("SID-background-aux"))
- .expect("background auxiliary page session state")
+ .target_page_session_state_for_session(Some("SID-background-attached"))
+ .expect("background attached page session state")
.page_lifecycle_events,
- "background auxiliary page session should own lifecycle enable"
+ "background attached page session should own lifecycle enable"
);
}
#[tokio::test(flavor = "multi_thread")]
-async fn page_disable_clears_page_handler_state_for_active_auxiliary_session() {
+async fn page_disable_clears_page_handler_state_for_active_attached_session() {
let mut ctx = TestContext::new();
load_bc_with_session(
&mut ctx,
- "BID-aux-page-disable",
+ "BID-attached-page-disable",
"TID-active",
"SID-primary",
"about:blank",
@@ -1173,22 +1177,24 @@ async fn page_disable_clears_page_handler_state_for_active_auxiliary_session() {
[moli_page_types::DevToolsSessionKey::Primary]
.page_session_state,
);
- assert!(browser_context.assign_auxiliary_session_to_target("TID-active", "SID-aux".to_owned()));
+ assert!(
+ browser_context.assign_attached_session_to_target("TID-active", "SID-attached".to_owned())
+ );
- enable_page_domain_for_session(&mut ctx.conn, "SID-aux");
+ enable_page_domain_for_session(&mut ctx.conn, "SID-attached");
assert_page_domain_enabled(
ctx.conn
- .target_page_session_state_for_session(Some("SID-aux"))
- .expect("active auxiliary page session state"),
+ .target_page_session_state_for_session(Some("SID-attached"))
+ .expect("active attached page session state"),
);
ctx.process_async(json!({
"id": 22,
"method": "Page.disable",
- "sessionId": "SID-aux"
+ "sessionId": "SID-attached"
}))
.await;
- ctx.expect_result(22, json!({}), Some("SID-aux"));
+ ctx.expect_result(22, json!({}), Some("SID-attached"));
let browser_context = ctx.conn.browser_context.as_ref().unwrap();
assert_page_domain_enabled(
@@ -1198,13 +1204,13 @@ async fn page_disable_clears_page_handler_state_for_active_auxiliary_session() {
);
assert_page_domain_disabled(
ctx.conn
- .target_page_session_state_for_session(Some("SID-aux"))
- .expect("active auxiliary page session state"),
+ .target_page_session_state_for_session(Some("SID-attached"))
+ .expect("active attached page session state"),
);
}
#[tokio::test(flavor = "multi_thread")]
-async fn page_disable_clears_page_handler_state_for_background_auxiliary_session() {
+async fn page_disable_clears_page_handler_state_for_background_attached_session() {
let mut ctx = TestContext::new();
let background = PageTargetHost::with_url(
"TID-background".to_owned(),
@@ -1216,8 +1222,10 @@ async fn page_disable_clears_page_handler_state_for_background_auxiliary_session
browser_context.attach_active_session("SID-active".to_owned());
browser_context.insert_page_target_host(background);
assert!(
- browser_context
- .assign_auxiliary_session_to_target("TID-background", "SID-background-aux".to_owned())
+ browser_context.assign_attached_session_to_target(
+ "TID-background",
+ "SID-background-attached".to_owned()
+ )
);
{
let state = browser_context
@@ -1230,33 +1238,34 @@ async fn page_disable_clears_page_handler_state_for_background_auxiliary_session
}
ctx.conn.browser_context = Some(browser_context);
- enable_page_domain_for_session(&mut ctx.conn, "SID-background-aux");
+ enable_page_domain_for_session(&mut ctx.conn, "SID-background-attached");
assert_page_domain_enabled(
ctx.conn
- .target_page_session_state_for_session(Some("SID-background-aux"))
- .expect("background auxiliary page session state"),
+ .target_page_session_state_for_session(Some("SID-background-attached"))
+ .expect("background attached page session state"),
);
ctx.process_async(json!({
"id": 23,
"method": "Page.disable",
- "sessionId": "SID-background-aux"
+ "sessionId": "SID-background-attached"
}))
.await;
- ctx.expect_result(23, json!({}), Some("SID-background-aux"));
+ ctx.expect_result(23, json!({}), Some("SID-background-attached"));
let browser_context = ctx.conn.browser_context.as_ref().unwrap();
- let parked = browser_context
+ let background = browser_context
.background_target("TID-background")
.filter(|target| target.has_non_default_session_state())
- .expect("background target should retain parked page session state");
+ .expect("background target should retain background page session state");
assert_page_domain_enabled(
- &parked.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary].page_session_state,
+ &background.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
+ .page_session_state,
);
assert_page_domain_disabled(
ctx.conn
- .target_page_session_state_for_session(Some("SID-background-aux"))
- .expect("background auxiliary page session state"),
+ .target_page_session_state_for_session(Some("SID-background-attached"))
+ .expect("background attached page session state"),
);
}
@@ -1652,7 +1661,7 @@ async fn runtime_document_close_releases_lifecycle_at_response_flush() {
.browser_context
.as_mut()
.unwrap()
- .assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned())
+ .assign_attached_session_to_target("TID-1", "SID-attached".to_owned())
);
ctx.process_async(json!({
@@ -1665,7 +1674,7 @@ async fn runtime_document_close_releases_lifecycle_at_response_flush() {
ctx.process_async(json!({
"id": 31,
"method": "Page.setLifecycleEventsEnabled",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": { "enabled": true }
}))
.await;
@@ -1678,7 +1687,7 @@ async fn runtime_document_close_releases_lifecycle_at_response_flush() {
ctx.process_async(json!({
"id": 33,
"method": "Runtime.enable",
- "sessionId": "SID-aux"
+ "sessionId": "SID-attached"
}))
.await;
ctx.sent.clear();
@@ -1717,7 +1726,7 @@ async fn runtime_document_close_releases_lifecycle_at_response_flush() {
assert!(
init_messages
.iter()
- .any(|(_, message)| message["sessionId"] == json!("SID-aux"))
+ .any(|(_, message)| message["sessionId"] == json!("SID-attached"))
);
let response_index = immediate
.iter()
@@ -1770,7 +1779,7 @@ async fn runtime_document_close_releases_lifecycle_at_response_flush() {
.map(|message| message["sessionId"].clone())
.collect::<Vec<_>>();
assert!(module_sessions.contains(&json!("SID-1")));
- assert!(module_sessions.contains(&json!("SID-aux")));
+ assert!(module_sessions.contains(&json!("SID-attached")));
}
/// Chromium starts a parser-owned module before DOMContentLoaded, but a
@@ -2233,7 +2242,8 @@ async fn add_script_run_immediately_installs_matching_bindings_into_new_top_leve
);
}
#[tokio::test(flavor = "multi_thread")]
-async fn document_start_script_run_immediately_targets_loaded_background_owner_without_promotion() {
+async fn document_start_script_run_immediately_targets_loaded_background_owner_without_activation()
+{
let mut ctx = TestContext::new();
let background = PageTargetHost::with_url(
"TID-background".to_owned(),
@@ -2288,7 +2298,7 @@ async fn document_start_script_run_immediately_targets_loaded_background_owner_w
.as_ref()
.and_then(|browser_context| browser_context.active_target_id()),
Some("TID-active"),
- "background Page.addScriptToEvaluateOnNewDocument should not promote the target"
+ "background Page.addScriptToEvaluateOnNewDocument should not activate the target"
);
ctx.process_async(json!({
@@ -2569,7 +2579,7 @@ async fn crash_notifies_all_attached_sessions_and_marks_browser_context_crashed(
.await
.expect("page should load");
let bc = ctx.conn.browser_context.as_mut().unwrap();
- assert!(bc.assign_auxiliary_session_to_target("TID-1", "SID-aux".into()));
+ assert!(bc.assign_attached_session_to_target("TID-1", "SID-attached".into()));
let _ = bc
.active_page_target_mut()
.runtime_slot
@@ -2593,9 +2603,9 @@ async fn crash_notifies_all_attached_sessions_and_marks_browser_context_crashed(
let inspector = ctx.take_one();
assert_eq!(inspector["method"], "Inspector.targetCrashed");
assert_eq!(inspector["sessionId"], "SID-1");
- let auxiliary_inspector = ctx.take_one();
- assert_eq!(auxiliary_inspector["method"], "Inspector.targetCrashed");
- assert_eq!(auxiliary_inspector["sessionId"], "SID-aux");
+ let attached_inspector = ctx.take_one();
+ assert_eq!(attached_inspector["method"], "Inspector.targetCrashed");
+ assert_eq!(attached_inspector["sessionId"], "SID-attached");
let bc = ctx.conn.browser_context.as_ref().unwrap();
assert!(
@@ -2612,7 +2622,7 @@ async fn crash_notifies_all_attached_sessions_and_marks_browser_context_crashed(
assert!(
bc.active_page_target()
.devtools_sessions
- .attached("SID-aux")
+ .attached("SID-attached")
.is_some_and(|state| state
.runtime_session_state
.inspector_target_crashed_delivered())
@@ -2636,7 +2646,7 @@ async fn crash_notifies_all_attached_sessions_and_marks_browser_context_crashed(
.await;
let _ = take_response_by_id(&mut ctx, 2471);
let recovery_events = ctx.take_all();
- for session_id in ["SID-1", "SID-aux"] {
+ for session_id in ["SID-1", "SID-attached"] {
assert!(
recovery_events.iter().any(|message| {
message["method"] == json!("Inspector.targetReloadedAfterCrash")
@@ -2657,7 +2667,7 @@ async fn crash_notifies_all_attached_sessions_and_marks_browser_context_crashed(
);
}
#[tokio::test(flavor = "multi_thread")]
-async fn crash_targets_background_owner_without_promotion() {
+async fn crash_targets_background_owner_without_activation() {
let mut ctx = TestContext::new();
let background_page = ctx
.conn
@@ -2712,11 +2722,11 @@ async fn crash_targets_background_owner_without_promotion() {
assert_eq!(
bc.active_target_id(),
Some("TID-active"),
- "background Page.crash should not promote the target"
+ "background Page.crash should not activate the target"
);
let background = bc
.background_target("TID-background")
- .expect("background target should remain parked");
+ .expect("background target should remain background");
assert!(!background.has_loaded_page());
assert!(
!bc.accepts_document_body_completion_event(&background_document_token),
@@ -2785,7 +2795,7 @@ async fn crash_aborts_paused_request_stage_navigation() {
assert_eq!(inspector["sessionId"], "SID-1");
}
#[tokio::test(flavor = "multi_thread")]
-async fn crash_aborts_background_paused_navigation_without_promotion() {
+async fn crash_aborts_background_paused_navigation_without_activation() {
let mut ctx = TestContext::new();
load_bc_with_session(&mut ctx, "BID-1", "TID-active", "SID-active", "about:blank");
ctx.conn
@@ -2853,7 +2863,7 @@ async fn crash_aborts_background_paused_navigation_without_promotion() {
assert_eq!(
bc.active_target_id(),
Some("TID-active"),
- "background Page.crash should not promote the target"
+ "background Page.crash should not activate the target"
);
assert!(
bc.background_target("TID-background")
@@ -3020,7 +3030,7 @@ async fn close_clears_loaded_page_state_and_emits_detached_events() {
bc.active_page_target_mut()
.runtime_slot
.set_next_subresource_fetch_request_id_for_test(5);
- assert!(bc.assign_auxiliary_session_to_target("TID-1", "SID-aux".into()));
+ assert!(bc.assign_attached_session_to_target("TID-1", "SID-attached".into()));
bc.remember_target_window_name("close-me", "TID-1");
bc.target_opener_ids
.insert("TID-popup-after-close".into(), "TID-1".into());
@@ -3042,18 +3052,18 @@ async fn close_clears_loaded_page_state_and_emits_detached_events() {
assert_eq!(detached[0]["method"], "Inspector.detached");
assert_eq!(detached[0]["sessionId"], "SID-1");
assert_eq!(detached[1]["method"], "Inspector.detached");
- assert_eq!(detached[1]["sessionId"], "SID-aux");
+ assert_eq!(detached[1]["sessionId"], "SID-attached");
assert_eq!(detached[2]["method"], "Target.detachedFromTarget");
assert_eq!(detached[2]["params"]["targetId"], "TID-1");
assert_eq!(detached[2]["params"]["sessionId"], "SID-1");
assert_eq!(detached[3]["method"], "Target.detachedFromTarget");
assert_eq!(detached[3]["params"]["targetId"], "TID-1");
- assert_eq!(detached[3]["params"]["sessionId"], "SID-aux");
+ assert_eq!(detached[3]["params"]["sessionId"], "SID-attached");
let bc = ctx.conn.browser_context.as_ref().unwrap();
assert!(!bc.has_active_target());
assert!(!bc.has_active_session());
- assert!(bc.auxiliary_target_id_for_session("SID-aux").is_none());
+ assert!(bc.attached_target_id_for_session("SID-attached").is_none());
assert!(bc.target_id_for_window_name("close-me").is_none());
assert!(!bc.target_opener_ids.contains_key("TID-popup-after-close"));
assert!(
@@ -3154,7 +3164,7 @@ async fn close_aborts_paused_request_stage_navigation_and_clears_state() {
assert!(bc.page_target("TID-1").is_none());
}
#[tokio::test(flavor = "multi_thread")]
-async fn close_aborts_background_paused_navigation_without_promotion() {
+async fn close_aborts_background_paused_navigation_without_activation() {
let mut ctx = TestContext::new();
load_bc_with_session(&mut ctx, "BID-1", "TID-active", "SID-active", "about:blank");
let bc = ctx.conn.browser_context.as_mut().unwrap();
@@ -3163,7 +3173,7 @@ async fn close_aborts_background_paused_navigation_without_promotion() {
Some("SID-background".to_owned()),
"about:blank#background".to_owned(),
));
- assert!(bc.assign_auxiliary_session_to_target("TID-background", "SID-aux".to_owned()));
+ assert!(bc.assign_attached_session_to_target("TID-background", "SID-attached".to_owned()));
bc.background_target_mut("TID-background")
.expect("background target must exist")
.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary] =
@@ -3232,28 +3242,28 @@ async fn close_aborts_background_paused_navigation_without_promotion() {
assert_eq!(inspector["method"], "Inspector.detached");
assert_eq!(inspector["sessionId"], "SID-background");
- let auxiliary_inspector = ctx.take_one();
- assert_eq!(auxiliary_inspector["method"], "Inspector.detached");
- assert_eq!(auxiliary_inspector["sessionId"], "SID-aux");
+ let attached_inspector = ctx.take_one();
+ assert_eq!(attached_inspector["method"], "Inspector.detached");
+ assert_eq!(attached_inspector["sessionId"], "SID-attached");
let primary_detached = ctx.take_one();
assert_eq!(primary_detached["method"], "Target.detachedFromTarget");
assert_eq!(primary_detached["params"]["targetId"], "TID-background");
assert_eq!(primary_detached["params"]["sessionId"], "SID-background");
- let auxiliary_detached = ctx.take_one();
- assert_eq!(auxiliary_detached["method"], "Target.detachedFromTarget");
- assert_eq!(auxiliary_detached["params"]["targetId"], "TID-background");
- assert_eq!(auxiliary_detached["params"]["sessionId"], "SID-aux");
+ let attached_detached = ctx.take_one();
+ assert_eq!(attached_detached["method"], "Target.detachedFromTarget");
+ assert_eq!(attached_detached["params"]["targetId"], "TID-background");
+ assert_eq!(attached_detached["params"]["sessionId"], "SID-attached");
let bc = ctx.conn.browser_context.as_ref().unwrap();
assert_eq!(
bc.active_target_id(),
Some("TID-active"),
- "background Page.close should not promote the target"
+ "background Page.close should not activate the target"
);
assert!(bc.background_target("TID-background").is_none());
- assert!(bc.auxiliary_target_id_for_session("SID-aux").is_none());
+ assert!(bc.attached_target_id_for_session("SID-attached").is_none());
}
#[tokio::test(flavor = "multi_thread")]
async fn close_without_target_loaded_errors() {
@@ -3869,9 +3879,9 @@ async fn screencast_visual_state_is_independent_for_two_sessions_on_one_page() {
.browser_context
.as_mut()
.expect("browser context")
- .assign_auxiliary_session_to_target(
+ .assign_attached_session_to_target(
"TID-screencast-two-sessions",
- "SID-screencast-aux".to_owned(),
+ "SID-screencast-attached".to_owned(),
)
);
ensure_initial_document_for_session(&mut ctx, Some("SID-screencast-primary")).await;
@@ -3896,18 +3906,18 @@ async fn screencast_visual_state_is_independent_for_two_sessions_on_one_page() {
registration
};
let primary = start(&mut ctx.conn, "SID-screencast-primary", 552);
- let auxiliary = start(&mut ctx.conn, "SID-screencast-aux", 553);
+ let attached = start(&mut ctx.conn, "SID-screencast-attached", 553);
let PageScreencastCaptureStart::Pending(primary_capture) =
ctx.conn.start_page_screencast_frame_capture(&primary, None)
else {
panic!("primary session must start its first frame");
};
- let PageScreencastCaptureStart::Pending(auxiliary_capture) = ctx
+ let PageScreencastCaptureStart::Pending(attached_capture) = ctx
.conn
- .start_page_screencast_frame_capture(&auxiliary, None)
+ .start_page_screencast_frame_capture(&attached, None)
else {
- panic!("auxiliary session must start its first frame independently");
+ panic!("attached session must start its first frame independently");
};
let PageScreencastCaptureCompletion::Frame {
event: primary_event,
@@ -3919,21 +3929,21 @@ async fn screencast_visual_state_is_independent_for_two_sessions_on_one_page() {
panic!("primary first capture must emit a frame");
};
let PageScreencastCaptureCompletion::Frame {
- event: auxiliary_event,
- visual_state: auxiliary_state,
+ event: attached_event,
+ visual_state: attached_state,
} = ctx
.conn
- .complete_page_screencast_frame_capture(auxiliary_capture.wait().await)
+ .complete_page_screencast_frame_capture(attached_capture.wait().await)
else {
- panic!("auxiliary first capture must emit a frame");
+ panic!("attached first capture must emit a frame");
};
assert_eq!(
primary_event.into_parts().0["sessionId"],
json!("SID-screencast-primary")
);
assert_eq!(
- auxiliary_event.into_parts().0["sessionId"],
- json!("SID-screencast-aux")
+ attached_event.into_parts().0["sessionId"],
+ json!("SID-screencast-attached")
);
assert_eq!(
ctx.conn
@@ -3946,8 +3956,8 @@ async fn screencast_visual_state_is_independent_for_two_sessions_on_one_page() {
assert_eq!(
ctx.conn
.acknowledge_page_screencast_frame_for_session_owner(
- Some("SID-screencast-aux"),
- auxiliary.generation(),
+ Some("SID-screencast-attached"),
+ attached.generation(),
),
Some(true)
);
@@ -3983,34 +3993,34 @@ async fn screencast_visual_state_is_independent_for_two_sessions_on_one_page() {
Some(true)
);
- let PageScreencastCaptureStart::Pending(auxiliary_refresh) = ctx
+ let PageScreencastCaptureStart::Pending(attached_refresh) = ctx
.conn
- .start_page_screencast_frame_capture(&auxiliary, Some(auxiliary_state))
+ .start_page_screencast_frame_capture(&attached, Some(attached_state))
else {
- panic!("auxiliary session must retain its own pre-mutation state");
+ panic!("attached session must retain its own pre-mutation state");
};
let PageScreencastCaptureCompletion::Frame { event, .. } = ctx
.conn
- .complete_page_screencast_frame_capture(auxiliary_refresh.wait().await)
+ .complete_page_screencast_frame_capture(attached_refresh.wait().await)
else {
- panic!("auxiliary session must receive the mutation after the primary session did");
+ panic!("attached session must receive the mutation after the primary session did");
};
assert_eq!(
event.into_parts().0["sessionId"],
- json!("SID-screencast-aux")
+ json!("SID-screencast-attached")
);
assert_eq!(
ctx.conn
.acknowledge_page_screencast_frame_for_session_owner(
- Some("SID-screencast-aux"),
- auxiliary.generation(),
+ Some("SID-screencast-attached"),
+ attached.generation(),
),
Some(true)
);
}
#[tokio::test(flavor = "multi_thread")]
-async fn start_screencast_is_session_local_for_active_auxiliary_session() {
+async fn start_screencast_is_session_local_for_active_attached_session() {
let mut ctx = TestContext::new();
load_bc_with_session(
&mut ctx,
@@ -4020,20 +4030,22 @@ async fn start_screencast_is_session_local_for_active_auxiliary_session() {
"about:blank",
);
let browser_context = ctx.conn.browser_context.as_mut().unwrap();
- assert!(browser_context.assign_auxiliary_session_to_target("TID-active", "SID-aux".to_owned()));
+ assert!(
+ browser_context.assign_attached_session_to_target("TID-active", "SID-attached".to_owned())
+ );
ctx.process_async(json!({
"id": 56,
"method": "Page.startScreencast",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": {}
}))
.await;
- let visibility = ctx.take_first_matching("active auxiliary screencast visibility", |message| {
+ let visibility = ctx.take_first_matching("active attached screencast visibility", |message| {
message["method"] == json!("Page.screencastVisibilityChanged")
});
- assert_eq!(visibility["sessionId"], "SID-aux");
- ctx.expect_result(56, json!({}), Some("SID-aux"));
+ assert_eq!(visibility["sessionId"], "SID-attached");
+ ctx.expect_result(56, json!({}), Some("SID-attached"));
let browser_context = ctx.conn.browser_context.as_ref().unwrap();
assert!(
@@ -4044,16 +4056,16 @@ async fn start_screencast_is_session_local_for_active_auxiliary_session() {
.is_active(),
"primary page session should stay stopped"
);
- let auxiliary = ctx
+ let attached = ctx
.conn
- .target_page_session_state_for_session(Some("SID-aux"))
- .expect("active auxiliary page session state");
- assert!(auxiliary.page_screencast.is_active());
- assert_eq!(auxiliary.page_screencast.generation(), 1);
+ .target_page_session_state_for_session(Some("SID-attached"))
+ .expect("active attached page session state");
+ assert!(attached.page_screencast.is_active());
+ assert_eq!(attached.page_screencast.generation(), 1);
}
#[tokio::test(flavor = "multi_thread")]
-async fn start_screencast_is_session_local_for_background_auxiliary_session() {
+async fn start_screencast_is_session_local_for_background_attached_session() {
let mut ctx = TestContext::new();
let background = PageTargetHost::with_url(
"TID-background".to_owned(),
@@ -4065,43 +4077,45 @@ async fn start_screencast_is_session_local_for_background_auxiliary_session() {
browser_context.attach_active_session("SID-active".to_owned());
browser_context.insert_page_target_host(background);
assert!(
- browser_context
- .assign_auxiliary_session_to_target("TID-background", "SID-background-aux".to_owned())
+ browser_context.assign_attached_session_to_target(
+ "TID-background",
+ "SID-background-attached".to_owned()
+ )
);
ctx.conn.browser_context = Some(browser_context);
ctx.process_async(json!({
"id": 57,
"method": "Page.startScreencast",
- "sessionId": "SID-background-aux",
+ "sessionId": "SID-background-attached",
"params": {}
}))
.await;
let visibility = ctx
- .take_first_matching("background auxiliary screencast visibility", |message| {
+ .take_first_matching("background attached screencast visibility", |message| {
message["method"] == json!("Page.screencastVisibilityChanged")
});
- assert_eq!(visibility["sessionId"], "SID-background-aux");
- ctx.expect_result(57, json!({}), Some("SID-background-aux"));
+ assert_eq!(visibility["sessionId"], "SID-background-attached");
+ ctx.expect_result(57, json!({}), Some("SID-background-attached"));
let browser_context = ctx.conn.browser_context.as_ref().unwrap();
- let parked = browser_context
+ let background = browser_context
.background_target("TID-background")
.filter(|target| target.has_non_default_session_state())
- .expect("background target should retain parked page session state");
+ .expect("background target should retain background page session state");
assert!(
- !parked.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
+ !background.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
.page_session_state
.page_screencast
.is_active(),
"background primary page session should stay stopped"
);
- let auxiliary = ctx
+ let attached = ctx
.conn
- .target_page_session_state_for_session(Some("SID-background-aux"))
- .expect("background auxiliary page session state");
- assert!(auxiliary.page_screencast.is_active());
- assert_eq!(auxiliary.page_screencast.generation(), 1);
+ .target_page_session_state_for_session(Some("SID-background-attached"))
+ .expect("background attached page session state");
+ assert!(attached.page_screencast.is_active());
+ assert_eq!(attached.page_screencast.generation(), 1);
}
#[tokio::test(flavor = "multi_thread")]
diff --git a/moli-protocol/src/domains/page/tests/mod.rs b/moli-protocol/src/domains/page/tests/mod.rs
index 02c971620..4ff868ce8 100644
--- a/moli-protocol/src/domains/page/tests/mod.rs
+++ b/moli-protocol/src/domains/page/tests/mod.rs
@@ -200,9 +200,17 @@ fn load_bc_with_service_worker_target(ctx: &mut TestContext) {
ctx.conn.browser_context = Some(bc);
}
async fn ensure_initial_document_for_session(ctx: &mut TestContext, session_id: Option<&str>) {
+ let owner = match session_id {
+ Some(session_id) => crate::conn::CommandOwnerScope::for_route(
+ ctx.conn
+ .bound_session_route_for_test(session_id, None)
+ .expect("test session must own a concrete target route"),
+ ),
+ None => crate::conn::CommandOwnerScope::capture(&ctx.conn, None),
+ };
let pending = ctx
.conn
- .start_initial_document_page_ensure_for_session_owner(session_id)
+ .start_initial_document_page_ensure_for_owner(&owner)
.expect("target lifecycle initial document ensure should start")
.expect("metadata-only initial target should need an initial document page build");
let completed = pending
diff --git a/moli-protocol/src/domains/page/tests/navigation.rs b/moli-protocol/src/domains/page/tests/navigation.rs
index fe426a87b..ffc0600eb 100644
--- a/moli-protocol/src/domains/page/tests/navigation.rs
+++ b/moli-protocol/src/domains/page/tests/navigation.rs
@@ -1198,7 +1198,7 @@ async fn reset_navigation_history_prunes_browser_and_renderer_history() {
}
#[tokio::test(flavor = "multi_thread")]
-async fn navigation_history_is_preserved_per_parked_target() {
+async fn navigation_history_is_preserved_per_background_target() {
let mut ctx = TestContext::new();
load_bc_with_session(&mut ctx, "BID-1", "TID-A", "SID-A", "about:blank");
let a1_url = "data:text/html,<title>A1</title><main>a1</main>";
@@ -1291,7 +1291,7 @@ async fn navigation_history_is_preserved_per_parked_target() {
);
}
#[tokio::test(flavor = "multi_thread")]
-async fn get_navigation_history_targets_loaded_background_owner_without_promotion() {
+async fn get_navigation_history_targets_loaded_background_owner_without_activation() {
let mut ctx = TestContext::new();
let background_url = "data:text/html,<title>Background History</title><main>background</main>";
let background = PageTargetHost::with_url(
@@ -1330,12 +1330,12 @@ async fn get_navigation_history_targets_loaded_background_owner_without_promotio
.as_ref()
.and_then(|browser_context| browser_context.active_target_id()),
Some("TID-active"),
- "background Page.getNavigationHistory should not promote the target"
+ "background Page.getNavigationHistory should not activate the target"
);
}
#[tokio::test(flavor = "multi_thread")]
-async fn reset_navigation_history_targets_loaded_background_owner_without_promotion() {
+async fn reset_navigation_history_targets_loaded_background_owner_without_activation() {
let mut ctx = TestContext::new();
let background_url =
"data:text/html,<title>Background Reset History</title><main>background</main>";
@@ -1371,7 +1371,7 @@ async fn reset_navigation_history_targets_loaded_background_owner_without_promot
.as_ref()
.and_then(|browser_context| browser_context.active_target_id()),
Some("TID-active"),
- "background Page.resetNavigationHistory should not promote the target"
+ "background Page.resetNavigationHistory should not activate the target"
);
ctx.process_async(json!({
@@ -1393,7 +1393,7 @@ async fn reset_navigation_history_targets_loaded_background_owner_without_promot
}
#[tokio::test(flavor = "multi_thread")]
-async fn navigate_to_history_entry_targets_background_owner_without_promotion() {
+async fn navigate_to_history_entry_targets_background_owner_without_activation() {
let mut ctx = TestContext::new();
let mut bc = BrowserContext::new("BID-1".to_owned());
bc.set_active_target_id("TID-active".to_owned());
@@ -1447,11 +1447,11 @@ async fn navigate_to_history_entry_targets_background_owner_without_promotion()
assert_eq!(
browser_context.active_target_id(),
Some("TID-active"),
- "background Page.navigateToHistoryEntry should not promote the target"
+ "background Page.navigateToHistoryEntry should not activate the target"
);
let background = browser_context
.background_target("TID-background")
- .expect("background target should remain parked");
+ .expect("background target should remain background");
assert_eq!(background.target_url(), first_url);
ctx.sent.clear();
@@ -1578,7 +1578,7 @@ async fn navigation_history_marks_reload_as_reload_transition() {
);
}
#[tokio::test(flavor = "multi_thread")]
-async fn navigate_targets_background_owner_without_promotion() {
+async fn navigate_targets_background_owner_without_activation() {
let mut ctx = TestContext::new();
let mut bc = BrowserContext::new("BID-1".to_owned());
bc.set_active_target_id("TID-active".to_owned());
@@ -1607,7 +1607,7 @@ async fn navigate_targets_background_owner_without_promotion() {
assert_eq!(
browser_context.active_target_id(),
Some("TID-active"),
- "background Page.navigate should not promote the target"
+ "background Page.navigate should not activate the target"
);
assert_eq!(
browser_context.target_url(),
@@ -1616,7 +1616,7 @@ async fn navigate_targets_background_owner_without_promotion() {
);
let background = browser_context
.background_target("TID-background")
- .expect("background target should remain parked");
+ .expect("background target should remain background");
assert!(background.has_loaded_page());
assert_eq!(background.target_url(), background_url);
}
@@ -1649,7 +1649,7 @@ async fn navigate_targets_inactive_owner_without_activation() {
.inactive_browser_contexts
.iter()
.find(|browser_context| browser_context.id == "BID-inactive")
- .expect("inactive browser context should stay parked");
+ .expect("inactive browser context should stay background");
assert!(inactive.has_loaded_page());
assert_eq!(inactive.target_url(), inactive_url);
}
@@ -3400,7 +3400,7 @@ async fn navigate_after_real_runtime_enable_resets_before_creating_default_conte
}
#[tokio::test(flavor = "multi_thread")]
-async fn navigate_after_real_runtime_enable_fans_out_context_reset_to_auxiliary_session() {
+async fn navigate_after_real_runtime_enable_fans_out_context_reset_to_attached_session() {
let mut ctx = TestContext::new();
load_bc_with_session(&mut ctx, "BID-1", "TID-1", "SID-1", "about:blank");
ensure_initial_document_for_session(&mut ctx, Some("SID-1")).await;
@@ -3409,10 +3409,10 @@ async fn navigate_after_real_runtime_enable_fans_out_context_reset_to_auxiliary_
.browser_context
.as_mut()
.unwrap()
- .assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned())
+ .assign_attached_session_to_target("TID-1", "SID-attached".to_owned())
);
- for (id, session_id) in [(21, "SID-1"), (22, "SID-aux")] {
+ for (id, session_id) in [(21, "SID-1"), (22, "SID-attached")] {
ctx.process_async(json!({
"id": id,
"method": "Runtime.enable",
@@ -3439,13 +3439,13 @@ async fn navigate_after_real_runtime_enable_fans_out_context_reset_to_auxiliary_
.await;
let sent = ctx.take_all();
- for session_id in ["SID-1", "SID-aux"] {
+ for session_id in ["SID-1", "SID-attached"] {
assert_runtime_navigation_context_reset(&sent, session_id, "TID-1");
}
}
#[tokio::test(flavor = "multi_thread")]
-async fn navigate_from_auxiliary_session_keeps_primary_and_auxiliary_runtime_events_separate() {
+async fn navigate_from_attached_session_keeps_primary_and_attached_runtime_events_separate() {
let mut ctx = TestContext::new();
load_bc_with_session(&mut ctx, "BID-1", "TID-1", "SID-1", "about:blank");
ensure_initial_document_for_session(&mut ctx, Some("SID-1")).await;
@@ -3454,10 +3454,10 @@ async fn navigate_from_auxiliary_session_keeps_primary_and_auxiliary_runtime_eve
.browser_context
.as_mut()
.unwrap()
- .assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned())
+ .assign_attached_session_to_target("TID-1", "SID-attached".to_owned())
);
- for (id, session_id) in [(21, "SID-1"), (22, "SID-aux")] {
+ for (id, session_id) in [(21, "SID-1"), (22, "SID-attached")] {
ctx.process_async(json!({
"id": id,
"method": "Runtime.enable",
@@ -3470,19 +3470,19 @@ async fn navigate_from_auxiliary_session_keeps_primary_and_auxiliary_runtime_eve
ctx.process_async(json!({
"id": 23,
"method": "Page.navigate",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": { "url": "data:text/html,<body>aux-session-nav</body>" }
}))
.await;
let sent = ctx.take_all();
- for session_id in ["SID-1", "SID-aux"] {
+ for session_id in ["SID-1", "SID-attached"] {
assert_runtime_navigation_context_reset(&sent, session_id, "TID-1");
}
}
#[tokio::test(flavor = "multi_thread")]
-async fn navigate_after_auxiliary_runtime_disable_keeps_primary_runtime_enabled() {
+async fn navigate_after_attached_runtime_disable_keeps_primary_runtime_enabled() {
let mut ctx = TestContext::new();
load_bc_with_session(&mut ctx, "BID-1", "TID-1", "SID-1", "about:blank");
ensure_initial_document_for_session(&mut ctx, Some("SID-1")).await;
@@ -3491,10 +3491,10 @@ async fn navigate_after_auxiliary_runtime_disable_keeps_primary_runtime_enabled(
.browser_context
.as_mut()
.unwrap()
- .assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned())
+ .assign_attached_session_to_target("TID-1", "SID-attached".to_owned())
);
- for (id, session_id) in [(21, "SID-1"), (22, "SID-aux")] {
+ for (id, session_id) in [(21, "SID-1"), (22, "SID-attached")] {
ctx.process_async(json!({
"id": id,
"method": "Runtime.enable",
@@ -3506,20 +3506,20 @@ async fn navigate_after_auxiliary_runtime_disable_keeps_primary_runtime_enabled(
ctx.process_async(json!({
"id": 23,
"method": "Runtime.disable",
- "sessionId": "SID-aux"
+ "sessionId": "SID-attached"
}))
.await;
assert_eq!(
take_response_by_id(&mut ctx, 23)["result"],
json!({}),
- "auxiliary Runtime.disable should succeed through its own V8 session"
+ "attached Runtime.disable should succeed through its own V8 session"
);
ctx.sent.clear();
ctx.process_async(json!({
"id": 24,
"method": "Page.navigate",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": { "url": "data:text/html,<body>aux-runtime-disabled</body>" }
}))
.await;
@@ -3528,20 +3528,19 @@ async fn navigate_after_auxiliary_runtime_disable_keeps_primary_runtime_enabled(
assert_runtime_navigation_context_reset(&sent, "SID-1", "TID-1");
assert!(
sent.iter().all(|message| {
- message["sessionId"] != json!("SID-aux")
+ message["sessionId"] != json!("SID-attached")
|| !matches!(
message["method"].as_str(),
Some("Runtime.executionContextsCleared")
| Some("Runtime.executionContextCreated")
)
}),
- "Runtime-disabled auxiliary session must stay off context lifecycle surfaces after navigation: {sent:?}"
+ "Runtime-disabled attached session must stay off context lifecycle surfaces after navigation: {sent:?}"
);
}
#[tokio::test(flavor = "multi_thread")]
-async fn navigate_with_staged_auxiliary_runtime_enable_emits_context_created_for_auxiliary_session()
-{
+async fn navigate_with_staged_attached_runtime_enable_emits_context_created_for_attached_session() {
let mut ctx = TestContext::new();
load_bc_with_session(&mut ctx, "BID-1", "TID-1", "SID-1", "about:blank");
assert!(
@@ -3549,14 +3548,14 @@ async fn navigate_with_staged_auxiliary_runtime_enable_emits_context_created_for
.browser_context
.as_mut()
.unwrap()
- .assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned())
+ .assign_attached_session_to_target("TID-1", "SID-attached".to_owned())
);
ctx.conn
.with_target_devtools_session_state_for_session_mut(Some("SID-1"), |state| {
state.runtime_session_state.runtime_frontend_enabled = true;
});
ctx.conn
- .with_target_devtools_session_state_for_session_mut(Some("SID-aux"), |state| {
+ .with_target_devtools_session_state_for_session_mut(Some("SID-attached"), |state| {
state.runtime_session_state.runtime_frontend_enabled = true;
});
@@ -3569,7 +3568,7 @@ async fn navigate_with_staged_auxiliary_runtime_enable_emits_context_created_for
.await;
let sent = ctx.take_all();
- for session_id in ["SID-1", "SID-aux"] {
+ for session_id in ["SID-1", "SID-attached"] {
assert!(
sent.iter().any(|message| {
message["method"] == json!("Runtime.executionContextCreated")
@@ -3701,7 +3700,7 @@ async fn navigate_with_console_enabled_emits_initial_console_without_runtime_ena
}
#[tokio::test(flavor = "multi_thread")]
-async fn auxiliary_console_enable_survives_navigation_without_enabling_primary_or_runtime() {
+async fn attached_console_enable_survives_navigation_without_enabling_primary_or_runtime() {
let mut ctx = TestContext::new();
load_bc_with_session(&mut ctx, "BID-1", "TID-1", "SID-1", "about:blank");
ensure_initial_document_for_session(&mut ctx, Some("SID-1")).await;
@@ -3710,16 +3709,16 @@ async fn auxiliary_console_enable_survives_navigation_without_enabling_primary_o
.browser_context
.as_mut()
.unwrap()
- .assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned())
+ .assign_attached_session_to_target("TID-1", "SID-attached".to_owned())
);
ctx.process_async(json!({
"id": 28,
"method": "Console.enable",
- "sessionId": "SID-aux"
+ "sessionId": "SID-attached"
}))
.await;
- ctx.expect_result(28, json!({}), Some("SID-aux"));
+ ctx.expect_result(28, json!({}), Some("SID-attached"));
ctx.process_async(json!({
"id": 29,
@@ -3747,7 +3746,7 @@ async fn auxiliary_console_enable_survives_navigation_without_enabling_primary_o
ctx.process_async(json!({
"id": 30,
"method": "Runtime.evaluate",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": {
"expression": "console.warn('aux console after navigation')"
}
@@ -3757,17 +3756,17 @@ async fn auxiliary_console_enable_survives_navigation_without_enabling_primary_o
assert!(
sent.iter().any(|message| {
message["method"] == json!("Console.messageAdded")
- && message["sessionId"] == json!("SID-aux")
+ && message["sessionId"] == json!("SID-attached")
&& message["params"]["message"]["text"] == json!("aux console after navigation")
}),
- "Console-enabled auxiliary session should retain its own V8 Console subscription after navigation: {sent:?}"
+ "Console-enabled attached session should retain its own V8 Console subscription after navigation: {sent:?}"
);
assert!(
sent.iter().all(|message| {
message["sessionId"] != json!("SID-1")
|| message["method"] != json!("Console.messageAdded")
}),
- "Console-disabled primary session must not receive the auxiliary subscription's events: {sent:?}"
+ "Console-disabled primary session must not receive the attached subscription's events: {sent:?}"
);
assert!(
sent.iter()
@@ -4027,10 +4026,10 @@ async fn navigate_emits_each_child_default_context_identity_once_per_runtime_ses
.browser_context
.as_mut()
.expect("browser context")
- .assign_auxiliary_session_to_target("TID-1", "SID-auxiliary".to_owned())
+ .assign_attached_session_to_target("TID-1", "SID-attached".to_owned())
);
- for (command_id, session_id) in [(25_301, "SID-primary"), (25_302, "SID-auxiliary")] {
+ for (command_id, session_id) in [(25_301, "SID-primary"), (25_302, "SID-attached")] {
ctx.process_async(json!({
"id": command_id,
"method": "Runtime.enable",
@@ -4078,9 +4077,9 @@ async fn navigate_emits_each_child_default_context_identity_once_per_runtime_ses
wait_until_messages(
&mut ctx,
"SID-primary",
- "child default Runtime context fan-out to primary and auxiliary sessions",
+ "child default Runtime context fan-out to primary and attached sessions",
move |messages| {
- ["SID-primary", "SID-auxiliary"]
+ ["SID-primary", "SID-attached"]
.into_iter()
.all(|session_id| {
messages.iter().any(|message| {
@@ -4113,9 +4112,9 @@ async fn navigate_emits_each_child_default_context_identity_once_per_runtime_ses
.collect::<Vec<_>>()
};
let primary_identities = child_context_identities("SID-primary");
- let auxiliary_identities = child_context_identities("SID-auxiliary");
+ let attached_identities = child_context_identities("SID-attached");
assert!(
- !primary_identities.is_empty() && !auxiliary_identities.is_empty(),
+ !primary_identities.is_empty() && !attached_identities.is_empty(),
"both Runtime frontends must observe a child default context: {:?}",
ctx.sent
);
@@ -4132,17 +4131,17 @@ async fn navigate_emits_each_child_default_context_identity_once_per_runtime_ses
"the primary Runtime frontend must receive each child context once: {:?}",
ctx.sent
);
- let mut unique_auxiliary_identities = auxiliary_identities.clone();
- unique_auxiliary_identities.sort();
- unique_auxiliary_identities.dedup();
+ let mut unique_attached_identities = attached_identities.clone();
+ unique_attached_identities.sort();
+ unique_attached_identities.dedup();
assert_eq!(
- auxiliary_identities.len(),
- unique_auxiliary_identities.len(),
- "the auxiliary Runtime frontend must receive each child context once: {:?}",
+ attached_identities.len(),
+ unique_attached_identities.len(),
+ "the attached Runtime frontend must receive each child context once: {:?}",
ctx.sent
);
assert_eq!(
- unique_primary_identities, unique_auxiliary_identities,
+ unique_primary_identities, unique_attached_identities,
"both Runtime frontends should observe the same child context identities"
);
}
@@ -4337,10 +4336,10 @@ async fn navigate_child_runtime_contexts_fan_out_to_each_runtime_enabled_session
.browser_context
.as_mut()
.expect("browser context")
- .assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned())
+ .assign_attached_session_to_target("TID-1", "SID-attached".to_owned())
);
- for (id, session_id) in [(90_240, "SID-1"), (90_241, "SID-aux")] {
+ for (id, session_id) in [(90_240, "SID-1"), (90_241, "SID-attached")] {
ctx.process_async(json!({
"id": id,
"method": "Runtime.enable",
@@ -4403,7 +4402,7 @@ async fn navigate_child_runtime_contexts_fan_out_to_each_runtime_enabled_session
"SID-1",
"default and named child contexts for both Runtime sessions",
move |messages| {
- ["SID-1", "SID-aux"].into_iter().all(|session_id| {
+ ["SID-1", "SID-attached"].into_iter().all(|session_id| {
let has_default = messages.iter().any(|message| {
message["method"] == json!("Runtime.executionContextCreated")
&& message["sessionId"] == json!(session_id)
@@ -4425,7 +4424,7 @@ async fn navigate_child_runtime_contexts_fan_out_to_each_runtime_enabled_session
.await;
for (is_default, name) in [(true, None), (false, Some("fanout-child-world"))] {
- let contexts = ["SID-1", "SID-aux"]
+ let contexts = ["SID-1", "SID-attached"]
.into_iter()
.map(|session_id| {
ctx.sent
@@ -4452,7 +4451,7 @@ async fn navigate_child_runtime_contexts_fan_out_to_each_runtime_enabled_session
assert_eq!(
contexts[1].len(),
1,
- "auxiliary context should emit once: {contexts:?}"
+ "attached context should emit once: {contexts:?}"
);
assert_eq!(
contexts[0][0]["params"]["context"]["id"], contexts[1][0]["params"]["context"]["id"],
@@ -6013,7 +6012,7 @@ allowedScript.nonce = "changed-after-connection";
}
#[tokio::test(flavor = "multi_thread")]
-async fn reload_targets_background_owner_without_promotion() {
+async fn reload_targets_background_owner_without_activation() {
use std::sync::{
Arc,
atomic::{AtomicUsize, Ordering},
@@ -6093,11 +6092,11 @@ async fn reload_targets_background_owner_without_promotion() {
assert_eq!(
browser_context.active_target_id(),
Some("TID-active"),
- "background Page.reload should not promote the target"
+ "background Page.reload should not activate the target"
);
let background = browser_context
.background_target_mut("TID-background")
- .expect("background target should remain parked");
+ .expect("background target should remain background");
let reloaded_html = background
.loaded_page_mut()
.expect("loaded background page after reload")
diff --git a/moli-protocol/src/domains/page/tests/runtime.rs b/moli-protocol/src/domains/page/tests/runtime.rs
index 88c12213d..ab651a209 100644
--- a/moli-protocol/src/domains/page/tests/runtime.rs
+++ b/moli-protocol/src/domains/page/tests/runtime.rs
@@ -275,7 +275,7 @@ async fn repeated_runtime_enable_does_not_replay_child_default_context_twice() {
);
}
#[tokio::test(flavor = "multi_thread")]
-async fn runtime_enable_replays_child_default_context_per_auxiliary_session() {
+async fn runtime_enable_replays_child_default_context_per_attached_session() {
let mut ctx = TestContext::new();
load_bc_with_session(&mut ctx, "BID-1", "TID-1", "SID-1", "about:blank");
ctx.enable_page_events_for_test(Some("SID-1"));
@@ -289,7 +289,7 @@ async fn runtime_enable_replays_child_default_context_per_auxiliary_session() {
.browser_context
.as_mut()
.expect("browser context")
- .assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned())
+ .assign_attached_session_to_target("TID-1", "SID-attached".to_owned())
);
let child_frame_id = child_frame_id_for_single_iframe(&mut ctx, 40715).await;
@@ -323,24 +323,24 @@ async fn runtime_enable_replays_child_default_context_per_auxiliary_session() {
ctx.process_async(json!({
"id": 40717,
"method": "Runtime.enable",
- "sessionId": "SID-aux"
+ "sessionId": "SID-attached"
}))
.await;
- let auxiliary_response = take_response_by_id(&mut ctx, 40717);
- assert_eq!(auxiliary_response["result"], json!({}));
- let auxiliary_child_default_count = ctx
+ let attached_response = take_response_by_id(&mut ctx, 40717);
+ assert_eq!(attached_response["result"], json!({}));
+ let attached_child_default_count = ctx
.sent
.iter()
.filter(|message| {
message["method"] == json!("Runtime.executionContextCreated")
- && message["sessionId"] == json!("SID-aux")
+ && message["sessionId"] == json!("SID-attached")
&& message["params"]["context"]["auxData"]["isDefault"] == json!(true)
&& message["params"]["context"]["auxData"]["frameId"] == json!(child_frame_id)
})
.count();
assert_eq!(
- auxiliary_child_default_count, 1,
- "auxiliary Runtime.enable should have its own child default replay cursor"
+ attached_child_default_count, 1,
+ "attached Runtime.enable should have its own child default replay cursor"
);
ctx.sent.clear();
@@ -357,24 +357,24 @@ async fn runtime_enable_replays_child_default_context_per_auxiliary_session() {
ctx.process_async(json!({
"id": 40719,
"method": "Runtime.enable",
- "sessionId": "SID-aux"
+ "sessionId": "SID-attached"
}))
.await;
- let auxiliary_enable_again = take_response_by_id(&mut ctx, 40719);
- assert_eq!(auxiliary_enable_again["result"], json!({}));
- let repeated_auxiliary_child_default_count = ctx
+ let attached_enable_again = take_response_by_id(&mut ctx, 40719);
+ assert_eq!(attached_enable_again["result"], json!({}));
+ let repeated_attached_child_default_count = ctx
.sent
.iter()
.filter(|message| {
message["method"] == json!("Runtime.executionContextCreated")
- && message["sessionId"] == json!("SID-aux")
+ && message["sessionId"] == json!("SID-attached")
&& message["params"]["context"]["auxData"]["isDefault"] == json!(true)
&& message["params"]["context"]["auxData"]["frameId"] == json!(child_frame_id)
})
.count();
assert_eq!(
- repeated_auxiliary_child_default_count, 0,
- "disabling primary Runtime must not clear auxiliary child default replay cursor"
+ repeated_attached_child_default_count, 0,
+ "disabling primary Runtime must not clear attached child default replay cursor"
);
}
#[tokio::test(flavor = "multi_thread")]
diff --git a/moli-protocol/src/domains/page/tests/scripts.rs b/moli-protocol/src/domains/page/tests/scripts.rs
index 66a1cceb4..00a8c3a57 100644
--- a/moli-protocol/src/domains/page/tests/scripts.rs
+++ b/moli-protocol/src/domains/page/tests/scripts.rs
@@ -1593,7 +1593,7 @@ async fn create_isolated_world_returns_unique_context_ids_and_emits_runtime_even
);
}
#[tokio::test(flavor = "multi_thread")]
-async fn create_isolated_world_targets_loaded_background_owner_without_promotion() {
+async fn create_isolated_world_targets_loaded_background_owner_without_activation() {
let mut ctx = TestContext::new();
let background = PageTargetHost::with_url(
"TID-background".to_owned(),
@@ -1663,7 +1663,7 @@ async fn create_isolated_world_targets_loaded_background_owner_without_promotion
.as_ref()
.and_then(|browser_context| browser_context.active_target_id()),
Some("TID-active"),
- "background Page.createIsolatedWorld should not promote the target"
+ "background Page.createIsolatedWorld should not activate the target"
);
ctx.sent.clear();
ctx.process_async(json!({
diff --git a/moli-protocol/src/domains/performance.rs b/moli-protocol/src/domains/performance.rs
index db827dd48..b9faad18c 100644
--- a/moli-protocol/src/domains/performance.rs
+++ b/moli-protocol/src/domains/performance.rs
@@ -41,7 +41,7 @@ pub(crate) struct CompletedPerformanceCommandDispatch {
enum PendingPerformanceRendererCommand {
Main(PendingPageCommand),
- IoCommandReply {
+ IoAdapterReply {
pending: PendingDevToolsIoCommandDispatch,
snapshot: RendererPerformanceMetricSnapshot,
},
@@ -53,7 +53,7 @@ enum PendingPerformanceRendererCommand {
enum CompletedPerformanceRendererCommand {
Main(CompletedPageCommand),
- IoCommandReply(RendererPerformanceMetricSnapshot),
+ IoAdapterReply(RendererPerformanceMetricSnapshot),
IoSessionOutput {
completed: Result<CompletedDevToolsIoCommandDispatch, String>,
correlation: RendererCommandCorrelation,
@@ -72,13 +72,13 @@ impl PendingPerformanceCommandDispatch {
.wait()
.await
.map(CompletedPerformanceRendererCommand::Main),
- PendingPerformanceRendererCommand::IoCommandReply { pending, snapshot } => {
+ PendingPerformanceRendererCommand::IoAdapterReply { pending, snapshot } => {
match pending.wait().await {
Ok(CompletedDevToolsIoCommandDispatch::Dispatched) => Ok(
- CompletedPerformanceRendererCommand::IoCommandReply(snapshot),
+ CompletedPerformanceRendererCommand::IoAdapterReply(snapshot),
),
Ok(CompletedDevToolsIoCommandDispatch::SessionResponse { .. }) => Err(
- anyhow::anyhow!("command-reply Performance dispatch used session output"),
+ anyhow::anyhow!("adapter-reply Performance dispatch used session output"),
),
Err(error) => Err(error),
}
@@ -250,11 +250,9 @@ pub(crate) fn try_start_performance_command_dispatch(
page.cached_performance_metric_snapshot(),
)
};
- let response_delivery = cmd.terminal_response_delivery(
- moli_page_types::RendererInspectorResponseDelivery::DevToolsSession,
- );
+ let response_delivery = cmd.terminal_response_delivery();
if cmd.id.is_none()
- || response_delivery == moli_page_types::RendererInspectorResponseDelivery::CommandReply
+ || response_delivery == moli_page_types::RendererInspectorResponseDelivery::AdapterReply
{
let page = loaded_page_mut_for_renderer_access(conn, renderer_access, &owner_scope)
.expect("the captured Performance Page must remain loaded synchronously");
@@ -264,7 +262,7 @@ pub(crate) fn try_start_performance_command_dispatch(
owner_scope,
renderer_access,
renderer_page,
- pending: Box::new(PendingPerformanceRendererCommand::IoCommandReply {
+ pending: Box::new(PendingPerformanceRendererCommand::IoAdapterReply {
pending,
snapshot,
}),
@@ -300,7 +298,7 @@ pub(crate) fn try_start_performance_command_dispatch(
let (correlation, response, response_rx) = prepared.into_parts();
debug_assert!(
response_rx.is_none(),
- "Performance session output must not allocate a command-reply receiver",
+ "Performance session output must not allocate an adapter-reply receiver",
);
let pending = loaded_page_mut_for_renderer_access(conn, renderer_access, &owner_scope)
.ok()
@@ -402,7 +400,7 @@ pub(crate) async fn complete_pending_performance_command(
.and_then(|page| page.finish_performance_metric_snapshot(completed_page).ok())
.unwrap_or_default()
}
- Ok(CompletedPerformanceRendererCommand::IoCommandReply(snapshot)) => {
+ Ok(CompletedPerformanceRendererCommand::IoAdapterReply(snapshot)) => {
let remains_current =
loaded_page_mut_for_renderer_access(conn, renderer_access, &owner_scope)
.ok()
@@ -813,12 +811,17 @@ mod tests {
.browser_context
.as_mut()
.expect("browser context")
- .assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned())
+ .assign_attached_session_to_target("TID-1", "SID-attached".to_owned())
+ );
+ let owner = crate::conn::CommandOwnerScope::for_route(
+ ctx.conn
+ .bound_session_route_for_test("SID-attached", Some("TID-1"))
+ .expect("attached test session must own its Page route"),
);
ctx.conn
- .apply_runtime_binding_state_for_session_owner_async(Some("SID-aux"))
+ .apply_runtime_binding_state_for_owner_async(&owner)
.await
- .expect("target attachment should establish the auxiliary renderer session");
+ .expect("target attachment should establish the attached renderer session");
ctx.process_async(json!({
"id": 4_100,
@@ -830,7 +833,7 @@ mod tests {
ctx.process_async(json!({
"id": 4_101,
"method": "Performance.getMetrics",
- "sessionId": "SID-aux"
+ "sessionId": "SID-attached"
}))
.await;
assert!(metric_map(&ctx.take_response_by_id(4_101)).is_empty());
@@ -838,11 +841,11 @@ mod tests {
ctx.process_async(json!({
"id": 4_102,
"method": "Performance.enable",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": { "timeDomain": "threadTicks" }
}))
.await;
- ctx.expect_result(4_102, json!({}), Some("SID-aux"));
+ ctx.expect_result(4_102, json!({}), Some("SID-attached"));
ctx.process_async(json!({
"id": 4_103,
@@ -854,7 +857,7 @@ mod tests {
ctx.process_async(json!({
"id": 4_104,
"method": "Performance.getMetrics",
- "sessionId": "SID-aux"
+ "sessionId": "SID-attached"
}))
.await;
assert!(!metric_map(&ctx.take_response_by_id(4_104)).is_empty());
@@ -867,15 +870,15 @@ mod tests {
.performance
.enabled()
);
- let auxiliary = browser_context
+ let attached = browser_context
.active_page_target()
.devtools_sessions
- .attached("SID-aux")
- .expect("auxiliary session state")
+ .attached("SID-attached")
+ .expect("attached session state")
.page_session_state
.performance;
- assert!(auxiliary.enabled());
- assert_eq!(auxiliary.time_domain(), PerformanceTimeDomain::ThreadTicks);
+ assert!(attached.enabled());
+ assert_eq!(attached.time_domain(), PerformanceTimeDomain::ThreadTicks);
}
#[tokio::test(flavor = "multi_thread")]
@@ -1022,7 +1025,7 @@ mod tests {
}
#[tokio::test(flavor = "multi_thread")]
- async fn performance_get_metrics_targets_loaded_background_owner_without_promotion() {
+ async fn performance_get_metrics_targets_loaded_background_owner_without_activation() {
let mut ctx = TestContext::new();
let background_url = "data:text/html,<!doctype html><body><main><section></section><section></section></main></body>";
let mut bc = BrowserContext::new("BID-1".into());
@@ -1065,12 +1068,12 @@ mod tests {
browser_context
.background_target("TID-background")
.is_some_and(|target| target.has_loaded_page()),
- "Performance.getMetrics should not promote the loaded background owner"
+ "Performance.getMetrics should not activate the loaded background owner"
);
}
#[tokio::test]
- async fn performance_get_metrics_on_unloaded_background_owner_does_not_promote() {
+ async fn performance_get_metrics_on_unloaded_background_owner_does_not_activate() {
let mut ctx = TestContext::new();
let mut bc = BrowserContext::new("BID-1".into());
bc.set_active_target_id("TID-active".to_owned());
@@ -1116,7 +1119,7 @@ mod tests {
browser_context
.background_target("TID-background")
.is_some_and(|target| !target.has_loaded_page()),
- "unloaded Performance owner fallback should not promote the background target"
+ "unloaded Performance owner fallback should not activate the background target"
);
}
diff --git a/moli-protocol/src/domains/profiler.rs b/moli-protocol/src/domains/profiler.rs
index 8974807db..df6fcff87 100644
--- a/moli-protocol/src/domains/profiler.rs
+++ b/moli-protocol/src/domains/profiler.rs
@@ -113,7 +113,7 @@ mod tests {
msg: serde_json::Value,
id: u64,
) -> serde_json::Value {
- ctx.process_async(msg).await;
+ ctx.process_and_wait_for_response_async(msg).await;
let pos = ctx
.sent
.iter()
@@ -565,12 +565,10 @@ mod tests {
{
let browser_context = ctx.conn.browser_context.as_mut().expect("browser context");
browser_context.attach_active_session("SID-profiler-primary");
- assert!(
- browser_context.assign_auxiliary_session_to_target(
- "TID-profiler",
- "SID-profiler-aux".to_owned()
- )
- );
+ assert!(browser_context.assign_attached_session_to_target(
+ "TID-profiler",
+ "SID-profiler-attached".to_owned()
+ ));
}
let primary_enable = process_and_take_response(
@@ -593,7 +591,7 @@ mod tests {
&mut ctx,
json!({
"id": 38,
- "sessionId": "SID-profiler-aux",
+ "sessionId": "SID-profiler-attached",
"method": "Profiler.start"
}),
38,
@@ -604,14 +602,14 @@ mod tests {
aux_start_without_enable["error"]["message"]
.as_str()
.is_some_and(|message| message.contains("Profiler is not enabled")),
- "auxiliary session should not see primary enable state: {aux_start_without_enable:?}"
+ "attached session should not see primary enable state: {aux_start_without_enable:?}"
);
let aux_enable = process_and_take_response(
&mut ctx,
json!({
"id": 39,
- "sessionId": "SID-profiler-aux",
+ "sessionId": "SID-profiler-attached",
"method": "Profiler.enable"
}),
39,
@@ -622,7 +620,7 @@ mod tests {
&mut ctx,
json!({
"id": 40,
- "sessionId": "SID-profiler-aux",
+ "sessionId": "SID-profiler-attached",
"method": "Profiler.start"
}),
40,
@@ -648,14 +646,14 @@ mod tests {
primary_stop_without_recording["error"]["message"]
.as_str()
.is_some_and(|message| message.contains("No recording profiles found")),
- "primary stop should not stop auxiliary profile: {primary_stop_without_recording:?}"
+ "primary stop should not stop attached profile: {primary_stop_without_recording:?}"
);
let aux_stop = process_and_take_response(
&mut ctx,
json!({
"id": 49,
- "sessionId": "SID-profiler-aux",
+ "sessionId": "SID-profiler-attached",
"method": "Profiler.stop"
}),
49,
@@ -665,7 +663,7 @@ mod tests {
aux_stop["result"]["profile"]["nodes"]
.as_array()
.is_some_and(|nodes| !nodes.is_empty()),
- "auxiliary session should return its own CPU profile: {aux_stop:?}"
+ "attached session should return its own CPU profile: {aux_stop:?}"
);
}
@@ -676,12 +674,10 @@ mod tests {
{
let browser_context = ctx.conn.browser_context.as_mut().expect("browser context");
browser_context.attach_active_session("SID-profiler-primary");
- assert!(
- browser_context.assign_auxiliary_session_to_target(
- "TID-profiler",
- "SID-profiler-aux".to_owned()
- )
- );
+ assert!(browser_context.assign_attached_session_to_target(
+ "TID-profiler",
+ "SID-profiler-attached".to_owned()
+ ));
}
let primary_enable = process_and_take_response(
@@ -731,7 +727,7 @@ mod tests {
&mut ctx,
json!({
"id": 133,
- "sessionId": "SID-profiler-aux",
+ "sessionId": "SID-profiler-attached",
"method": "Profiler.enable"
}),
133,
@@ -742,7 +738,7 @@ mod tests {
&mut ctx,
json!({
"id": 134,
- "sessionId": "SID-profiler-aux",
+ "sessionId": "SID-profiler-attached",
"method": "Profiler.setSamplingInterval",
"params": {"interval": 111}
}),
@@ -754,7 +750,7 @@ mod tests {
&mut ctx,
json!({
"id": 135,
- "sessionId": "SID-profiler-aux",
+ "sessionId": "SID-profiler-attached",
"method": "Profiler.startPreciseCoverage",
"params": {
"callCount": false,
@@ -767,14 +763,14 @@ mod tests {
.await;
assert!(
aux_coverage["result"]["timestamp"].is_number(),
- "auxiliary startPreciseCoverage should return timestamp: {aux_coverage:?}"
+ "attached startPreciseCoverage should return timestamp: {aux_coverage:?}"
);
let aux_stop_coverage = process_and_take_response(
&mut ctx,
json!({
"id": 136,
- "sessionId": "SID-profiler-aux",
+ "sessionId": "SID-profiler-attached",
"method": "Profiler.stopPreciseCoverage"
}),
136,
@@ -793,7 +789,7 @@ mod tests {
.await;
assert!(
primary_take_after_aux_stop["result"]["timestamp"].is_number(),
- "stopping auxiliary coverage must not clear primary coverage: {primary_take_after_aux_stop:?}"
+ "stopping attached coverage must not clear primary coverage: {primary_take_after_aux_stop:?}"
);
let primary_stop_coverage = process_and_take_response(
@@ -816,9 +812,9 @@ mod tests {
{
let browser_context = ctx.conn.browser_context.as_mut().expect("browser context");
browser_context.attach_active_session("SID-profiler-old");
- assert!(browser_context.assign_auxiliary_session_to_target(
+ assert!(browser_context.assign_attached_session_to_target(
"TID-profiler",
- "SID-profiler-aux-old".to_owned()
+ "SID-profiler-attached-old".to_owned()
));
}
@@ -849,7 +845,7 @@ mod tests {
&mut ctx,
json!({
"id": 52,
- "sessionId": "SID-profiler-aux-old",
+ "sessionId": "SID-profiler-attached-old",
"method": "Profiler.enable"
}),
52,
@@ -879,9 +875,9 @@ mod tests {
browser_context
.active_page_target()
.devtools_sessions
- .attached("SID-profiler-aux-old")
+ .attached("SID-profiler-attached-old")
.is_some(),
- "detaching the primary target session must preserve independent auxiliary sessions"
+ "detaching the primary target session must preserve independent attached sessions"
);
}
@@ -1663,18 +1659,16 @@ mod tests {
}
#[tokio::test(flavor = "multi_thread")]
- async fn auxiliary_profiler_recording_survives_page_navigation() {
+ async fn attached_profiler_recording_survives_page_navigation() {
let mut ctx = TestContext::new();
with_loaded_document_async(&mut ctx, "<!doctype html><body>before</body>").await;
{
let browser_context = ctx.conn.browser_context.as_mut().expect("browser context");
browser_context.attach_active_session("SID-profiler-primary");
- assert!(
- browser_context.assign_auxiliary_session_to_target(
- "TID-profiler",
- "SID-profiler-aux".to_owned()
- )
- );
+ assert!(browser_context.assign_attached_session_to_target(
+ "TID-profiler",
+ "SID-profiler-attached".to_owned()
+ ));
}
assert_eq!(
@@ -1682,7 +1676,7 @@ mod tests {
&mut ctx,
json!({
"id": 220,
- "sessionId": "SID-profiler-aux",
+ "sessionId": "SID-profiler-attached",
"method": "Profiler.enable"
}),
220
@@ -1695,7 +1689,7 @@ mod tests {
&mut ctx,
json!({
"id": 221,
- "sessionId": "SID-profiler-aux",
+ "sessionId": "SID-profiler-attached",
"method": "Profiler.setSamplingInterval",
"params": {"interval": 100}
}),
@@ -1709,7 +1703,7 @@ mod tests {
&mut ctx,
json!({
"id": 222,
- "sessionId": "SID-profiler-aux",
+ "sessionId": "SID-profiler-attached",
"method": "Profiler.start"
}),
222
@@ -1722,7 +1716,7 @@ mod tests {
&mut ctx,
json!({
"id": 223,
- "sessionId": "SID-profiler-aux",
+ "sessionId": "SID-profiler-attached",
"method": "Runtime.evaluate",
"params": {
"expression": "(() => { function moliAuxProfilerBeforeNavigation() { let x = 0; for (let i = 0; i < 500000; ++i) x += Math.sqrt(i); return x > 0; } return moliAuxProfilerBeforeNavigation(); })()\n//# sourceURL=moli-aux-profiler-before-navigation.js",
@@ -1738,7 +1732,7 @@ mod tests {
&mut ctx,
json!({
"id": 224,
- "sessionId": "SID-profiler-aux",
+ "sessionId": "SID-profiler-attached",
"method": "Page.navigate",
"params": {
"url": "data:text/html,<!doctype html><body>after</body>"
@@ -1749,14 +1743,14 @@ mod tests {
.await;
assert!(
navigate["result"]["frameId"].is_string(),
- "auxiliary Page.navigate should commit before Profiler.stop: {navigate:?}"
+ "attached Page.navigate should commit before Profiler.stop: {navigate:?}"
);
let after = process_and_take_response(
&mut ctx,
json!({
"id": 225,
- "sessionId": "SID-profiler-aux",
+ "sessionId": "SID-profiler-attached",
"method": "Runtime.evaluate",
"params": {
"expression": "(() => { if (!document.body.textContent.includes('after')) return false; function moliAuxProfilerAfterNavigation() { let x = 0; for (let i = 0; i < 500000; ++i) x += Math.sqrt(i + 1); return x > 0; } return moliAuxProfilerAfterNavigation(); })()\n//# sourceURL=moli-aux-profiler-after-navigation.js",
@@ -1771,7 +1765,7 @@ mod tests {
&mut ctx,
json!({
"id": 226,
- "sessionId": "SID-profiler-aux",
+ "sessionId": "SID-profiler-attached",
"method": "Profiler.stop"
}),
226,
@@ -1779,21 +1773,21 @@ mod tests {
.await;
assert!(
stop.get("error").is_none(),
- "auxiliary Profiler.stop after navigation should not fail: {stop:?}"
+ "attached Profiler.stop after navigation should not fail: {stop:?}"
);
let profile = &stop["result"]["profile"];
assert!(
!profile_contains_script_url(profile, "moli-aux-profiler-before-navigation.js"),
- "auxiliary restore should not migrate old-isolate samples: {stop:?}"
+ "attached restore should not migrate old-isolate samples: {stop:?}"
);
assert!(
profile_contains_script_url(profile, "moli-aux-profiler-after-navigation.js"),
- "auxiliary profile should include work from the replacement Profiler agent: {stop:?}"
+ "attached profile should include work from the replacement Profiler agent: {stop:?}"
);
}
#[tokio::test(flavor = "multi_thread")]
- async fn inactive_context_auxiliary_profiler_recording_survives_page_navigation() {
+ async fn inactive_context_attached_profiler_recording_survives_page_navigation() {
let mut ctx = TestContext::new();
let default_context = process_and_take_response(
@@ -1936,7 +1930,7 @@ mod tests {
.await;
assert!(
navigate["result"]["frameId"].is_string(),
- "inactive auxiliary Page.navigate should commit before Profiler.stop: {navigate:?}"
+ "inactive attached Page.navigate should commit before Profiler.stop: {navigate:?}"
);
let after = process_and_take_response(
@@ -1967,7 +1961,7 @@ mod tests {
.await;
assert!(
stop.get("error").is_none(),
- "inactive auxiliary Profiler.stop after navigation should not fail: {stop:?}"
+ "inactive attached Profiler.stop after navigation should not fail: {stop:?}"
);
let profile = &stop["result"]["profile"];
assert!(
@@ -1975,11 +1969,11 @@ mod tests {
profile,
"moli-inactive-aux-profiler-before-navigation.js"
),
- "inactive auxiliary restore should not migrate old-isolate samples: {stop:?}"
+ "inactive attached restore should not migrate old-isolate samples: {stop:?}"
);
assert!(
profile_contains_script_url(profile, "moli-inactive-aux-profiler-after-navigation.js"),
- "inactive auxiliary profile should include work from the replacement Profiler agent: {stop:?}"
+ "inactive attached profile should include work from the replacement Profiler agent: {stop:?}"
);
}
@@ -2516,16 +2510,16 @@ mod tests {
{
let browser_context = ctx.conn.browser_context.as_mut().expect("browser context");
browser_context.attach_active_session("SID-page-console-profile-primary");
- assert!(browser_context.assign_auxiliary_session_to_target(
+ assert!(browser_context.assign_attached_session_to_target(
"TID-page-console-profile-fanout",
- "SID-page-console-profile-aux".to_owned(),
+ "SID-page-console-profile-attached".to_owned(),
));
}
ctx.sent.clear();
for (command_id, session_id) in [
(91_101, "SID-page-console-profile-primary"),
- (91_102, "SID-page-console-profile-aux"),
+ (91_102, "SID-page-console-profile-attached"),
] {
let enable = process_and_take_response(
&mut ctx,
@@ -2589,11 +2583,11 @@ mod tests {
"Profiler.consoleProfileFinished",
),
(
- "SID-page-console-profile-aux",
+ "SID-page-console-profile-attached",
"Profiler.consoleProfileStarted",
),
(
- "SID-page-console-profile-aux",
+ "SID-page-console-profile-attached",
"Profiler.consoleProfileFinished",
),
]
@@ -2610,7 +2604,7 @@ mod tests {
for session_id in [
"SID-page-console-profile-primary",
- "SID-page-console-profile-aux",
+ "SID-page-console-profile-attached",
] {
let started =
ctx.take_first_matching("page Profiler.consoleProfileStarted event", |message| {
@@ -2661,16 +2655,16 @@ mod tests {
{
let browser_context = ctx.conn.browser_context.as_mut().expect("browser context");
browser_context.attach_active_session("SID-page-console-profile-detach-primary");
- assert!(browser_context.assign_auxiliary_session_to_target(
+ assert!(browser_context.assign_attached_session_to_target(
"TID-page-console-profile-detach",
- "SID-page-console-profile-detach-aux".to_owned(),
+ "SID-page-console-profile-detach-attached".to_owned(),
));
}
ctx.sent.clear();
for (command_id, session_id) in [
(91_201, "SID-page-console-profile-detach-primary"),
- (91_202, "SID-page-console-profile-detach-aux"),
+ (91_202, "SID-page-console-profile-detach-attached"),
] {
let enable = process_and_take_response(
&mut ctx,
@@ -2719,7 +2713,7 @@ mod tests {
|messages| {
[
"SID-page-console-profile-detach-primary",
- "SID-page-console-profile-detach-aux",
+ "SID-page-console-profile-detach-attached",
]
.into_iter()
.all(|session_id| {
@@ -2737,13 +2731,11 @@ mod tests {
message["sessionId"] == json!("SID-page-console-profile-detach-primary")
&& message["method"] == json!("Profiler.consoleProfileStarted")
});
- let aux_started = ctx.take_first_matching(
- "auxiliary Profiler.consoleProfileStarted event",
- |message| {
- message["sessionId"] == json!("SID-page-console-profile-detach-aux")
+ let aux_started =
+ ctx.take_first_matching("attached Profiler.consoleProfileStarted event", |message| {
+ message["sessionId"] == json!("SID-page-console-profile-detach-attached")
&& message["method"] == json!("Profiler.consoleProfileStarted")
- },
- );
+ });
assert_eq!(
primary_started["params"]["title"],
json!("page-console-profile-detach")
@@ -2759,7 +2751,7 @@ mod tests {
"method": "Target.detachFromTarget",
"params": {
"targetId": "TID-page-console-profile-detach",
- "sessionId": "SID-page-console-profile-detach-aux"
+ "sessionId": "SID-page-console-profile-detach-attached"
}
}))
.await;
@@ -2768,7 +2760,7 @@ mod tests {
"Target.detachedFromTarget",
Some(&json!({
"targetId": "TID-page-console-profile-detach",
- "sessionId": "SID-page-console-profile-detach-aux"
+ "sessionId": "SID-page-console-profile-detach-attached"
})),
);
ctx.sent.clear();
@@ -2807,7 +2799,7 @@ mod tests {
wait_until_messages(
&mut ctx,
Some("SID-page-console-profile-detach-primary"),
- "primary page console profile finish after auxiliary detach",
+ "primary page console profile finish after attached detach",
|messages| {
messages.iter().any(|message| {
message["sessionId"] == json!("SID-page-console-profile-detach-primary")
@@ -2835,11 +2827,11 @@ mod tests {
&primary_finished["params"]["profile"],
"moliDetachedPageConsoleProfileWork",
),
- "remaining attached session should keep sampling after auxiliary detach: {primary_finished:?}"
+ "remaining attached session should keep sampling after attached detach: {primary_finished:?}"
);
assert!(
ctx.sent.iter().all(|message| {
- !(message["sessionId"] == json!("SID-page-console-profile-detach-aux")
+ !(message["sessionId"] == json!("SID-page-console-profile-detach-attached")
&& message["method"] == json!("Profiler.consoleProfileFinished"))
}),
"detached session must not receive a stale consoleProfileFinished event: {:?}",
diff --git a/moli-protocol/src/domains/runtime.rs b/moli-protocol/src/domains/runtime.rs
index dfcbf8f93..401960ced 100644
--- a/moli-protocol/src/domains/runtime.rs
+++ b/moli-protocol/src/domains/runtime.rs
@@ -7,6 +7,136 @@ mod evaluate;
#[cfg(test)]
mod test_support;
+use crate::conn::{
+ BackgroundProtocolEvent, CdpConnection, SessionDisposalPlan, SessionDisposalTarget,
+};
+
+/// Settles protocol work that still belongs to a session before another
+/// domain starts tearing down renderer-owned resources.
+pub(in crate::domains) fn fail_pending_session_calls(
+ conn: &mut CdpConnection,
+ background_events: &mut Vec<BackgroundProtocolEvent>,
+ protocol_events: &mut Vec<BackgroundProtocolEvent>,
+ session_id: &str,
+) {
+ conn.fail_pending_inspector_awaits_for_session_owner_background_events_into(
+ background_events,
+ protocol_events,
+ Some(session_id),
+ "Target detached",
+ );
+}
+
+/// Detaches the Page's renderer Inspector endpoint after Page-owned cleanup
+/// commands have completed.
+pub(in crate::domains) async fn detach_page_session_inspector_async(
+ conn: &mut CdpConnection,
+ session_id: &str,
+) {
+ if let Err(error) = conn
+ .detach_runtime_inspector_session_for_session_owner_async(Some(session_id))
+ .await
+ {
+ tracing::debug!(
+ session_id,
+ %error,
+ "renderer Inspector session was already unavailable during disposal"
+ );
+ }
+}
+
+/// Releases Runtime state and the renderer Inspector endpoint owned by one
+/// Worker session. The binding described by `plan` remains authoritative for
+/// the whole operation.
+pub(in crate::domains) async fn dispose_worker_session_async(
+ conn: &mut CdpConnection,
+ background_events: &mut Vec<BackgroundProtocolEvent>,
+ protocol_events: &mut Vec<BackgroundProtocolEvent>,
+ plan: &SessionDisposalPlan,
+) -> anyhow::Result<()> {
+ let session_id = plan.session_id();
+ conn.release_worker_runtime_remote_objects_for_session_best_effort_async(session_id)
+ .await;
+ fail_pending_session_calls(conn, background_events, protocol_events, session_id);
+
+ match plan.target() {
+ SessionDisposalTarget::SharedWorkerTarget {
+ browser_context_id,
+ target_id,
+ } => {
+ let renderer_detach =
+ conn.browser_context_by_id(browser_context_id)
+ .and_then(|browser_context| {
+ browser_context
+ .shared_worker_target(target_id)
+ .map(|target| {
+ (
+ browser_context.renderer_runtime(),
+ target.renderer_instance_id,
+ )
+ })
+ });
+ if let Some((renderer_runtime, instance_id)) = renderer_detach {
+ renderer_runtime.detach_shared_worker_runtime_inspector_session(
+ instance_id,
+ Some(session_id.to_owned()),
+ );
+ }
+ }
+ SessionDisposalTarget::DedicatedWorkerTarget {
+ browser_context_id,
+ target_id,
+ } => {
+ let renderer_detach =
+ conn.browser_context_by_id(browser_context_id)
+ .and_then(|browser_context| {
+ browser_context
+ .dedicated_worker_target(target_id)
+ .map(|target| {
+ (
+ browser_context.renderer_runtime(),
+ target.renderer_instance_id,
+ )
+ })
+ });
+ if let Some((renderer_runtime, instance_id)) = renderer_detach {
+ renderer_runtime.detach_dedicated_worker_runtime_inspector_session(
+ instance_id,
+ Some(session_id.to_owned()),
+ );
+ }
+ }
+ SessionDisposalTarget::ServiceWorkerTarget {
+ browser_context_id,
+ target_id,
+ } => {
+ let renderer_detach =
+ conn.browser_context_by_id(browser_context_id)
+ .and_then(|browser_context| {
+ browser_context
+ .service_worker_target(target_id)
+ .map(|target| {
+ (
+ browser_context.renderer_runtime(),
+ target.renderer_version_id,
+ )
+ })
+ });
+ super::target::set_service_worker_pause_on_start_owner(conn, Some(session_id), false);
+ if let Some((renderer_runtime, version_id)) = renderer_detach {
+ renderer_runtime.detach_service_worker_runtime_inspector_session(
+ version_id,
+ Some(session_id.to_owned()),
+ );
+ }
+ }
+ SessionDisposalTarget::Browser
+ | SessionDisposalTarget::PageTarget { .. }
+ | SessionDisposalTarget::TabTarget { .. } => anyhow::bail!("InvalidSessionId"),
+ }
+ Ok(())
+}
+
pub(in crate::domains) use activity::{
RuntimePreparedOutputSlot, RuntimePreparedOutputs, project_runtime_binding_calls_async,
project_runtime_inspector_messages_async,
diff --git a/moli-protocol/src/domains/runtime/activity.rs b/moli-protocol/src/domains/runtime/activity.rs
index 22186d8d6..1feffb418 100644
--- a/moli-protocol/src/domains/runtime/activity.rs
+++ b/moli-protocol/src/domains/runtime/activity.rs
@@ -807,7 +807,7 @@ mod tests {
crate::conn::RendererCommandDescriptor::from_frontend_policy(
frontend.json().to_owned(),
frontend.renderer_policy(),
- RendererInspectorResponseDelivery::DevToolsSession,
+ RendererInspectorResponseDelivery::SessionSink,
),
)
.expect("retired renderer call correlation");
@@ -1121,12 +1121,12 @@ mod tests {
.browser_context
.as_mut()
.expect("browser context")
- .assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned())
+ .assign_attached_session_to_target("TID-1", "SID-attached".to_owned())
);
let outputs = renderer_inspector_outputs(
&mut ctx.conn,
Some("SID-1"),
- Some("SID-aux"),
+ Some("SID-attached"),
vec![json!({
"method": "Debugger.scriptParsed",
"params": { "scriptId": "attached-session" }
@@ -1142,7 +1142,7 @@ mod tests {
assert_eq!(events[0]["method"], json!("Debugger.scriptParsed"));
assert_eq!(
events[0]["sessionId"],
- json!("SID-aux"),
+ json!("SID-attached"),
"an attached renderer inspector batch must retain its own session instead of following the source or drain session"
);
}
diff --git a/moli-protocol/src/domains/runtime/dispatcher.rs b/moli-protocol/src/domains/runtime/dispatcher.rs
index 59e0db7c9..4eede3fc4 100644
--- a/moli-protocol/src/domains/runtime/dispatcher.rs
+++ b/moli-protocol/src/domains/runtime/dispatcher.rs
@@ -1029,7 +1029,7 @@ fn start_main_runtime_inspector_command_for_owner(
cmd,
&owner_scope,
inspector_json,
- cmd.terminal_response_delivery(RendererInspectorResponseDelivery::DevToolsSession),
+ cmd.terminal_response_delivery(),
) {
Ok(pending) => pending,
Err(message) => {
@@ -1089,7 +1089,7 @@ pub(crate) fn start_profiler_inspector_command_dispatch(
cmd,
&owner_scope,
dispatch.into_inspector_json(),
- cmd.terminal_response_delivery(RendererInspectorResponseDelivery::DevToolsSession),
+ cmd.terminal_response_delivery(),
) {
Ok(pending) => pending,
Err(message) => {
@@ -1178,7 +1178,7 @@ pub(crate) fn start_heap_profiler_inspector_command_dispatch(
cmd,
&owner_scope,
cmd.json.to_owned(),
- cmd.terminal_response_delivery(RendererInspectorResponseDelivery::DevToolsSession),
+ cmd.terminal_response_delivery(),
) {
Ok(pending) => pending,
Err(message) => {
@@ -1232,7 +1232,7 @@ pub(crate) fn start_debugger_inspector_command_dispatch(
cmd,
&owner_scope,
inspector_json,
- cmd.terminal_response_delivery(RendererInspectorResponseDelivery::DevToolsSession),
+ cmd.terminal_response_delivery(),
)
}
CdpRendererCommandAccess::Io => start_pending_runtime_io_inspector_dispatch(
@@ -1240,7 +1240,7 @@ pub(crate) fn start_debugger_inspector_command_dispatch(
cmd,
&owner_scope,
inspector_json,
- cmd.terminal_response_delivery(RendererInspectorResponseDelivery::DevToolsSession),
+ cmd.terminal_response_delivery(),
),
CdpRendererCommandAccess::OwnerIndependent => Err(
"an owner-independent command cannot enter the Debugger Inspector dispatcher"
@@ -1298,7 +1298,7 @@ fn start_heap_profiler_inspector_shared_worker_command_dispatch(
conn,
cmd,
cmd.json.to_owned(),
- cmd.terminal_response_delivery(RendererInspectorResponseDelivery::DevToolsSession),
+ cmd.terminal_response_delivery(),
) {
Ok(pending) => pending,
Err(message)
@@ -1396,7 +1396,7 @@ fn start_profiler_inspector_shared_worker_command_dispatch(
conn,
cmd,
dispatch.into_inspector_json(),
- cmd.terminal_response_delivery(RendererInspectorResponseDelivery::DevToolsSession),
+ cmd.terminal_response_delivery(),
) {
Ok(pending) => pending,
Err(message) => {
@@ -1454,7 +1454,7 @@ pub(crate) fn start_console_inspector_command_dispatch(
cmd,
&owner_scope,
cmd.json.to_owned(),
- cmd.terminal_response_delivery(RendererInspectorResponseDelivery::DevToolsSession),
+ cmd.terminal_response_delivery(),
) {
Ok(pending) => pending,
Err(message) => {
@@ -1523,7 +1523,7 @@ fn start_console_inspector_shared_worker_command_dispatch(
conn,
cmd,
cmd.json.to_owned(),
- cmd.terminal_response_delivery(RendererInspectorResponseDelivery::DevToolsSession),
+ cmd.terminal_response_delivery(),
) {
Ok(pending) => pending,
Err(message) if worker_runtime_is_unavailable(&message) => {
@@ -1586,7 +1586,7 @@ fn start_console_inspector_service_worker_command_dispatch(
conn,
cmd,
cmd.json.to_owned(),
- cmd.terminal_response_delivery(RendererInspectorResponseDelivery::DevToolsSession),
+ cmd.terminal_response_delivery(),
) {
Ok(pending) => pending,
Err(message) if message == "ServiceWorkerRuntimeUnavailable" => {
@@ -1793,8 +1793,7 @@ fn try_start_pending_runtime_binding_command(
execution_context_id,
inspector_json: Some(cmd.json.to_owned()),
command_response: None,
- response_delivery: cmd
- .terminal_response_delivery(RendererInspectorResponseDelivery::DevToolsSession),
+ response_delivery: cmd.terminal_response_delivery(),
session_response_predecessor: None,
session_response_succeeded: None,
should_persist,
@@ -2069,7 +2068,7 @@ fn start_cdp_devtools_script_runtime_command(
command,
inspector_json,
await_promise,
- cmd.terminal_response_delivery(RendererInspectorResponseDelivery::DevToolsSession),
+ cmd.terminal_response_delivery(),
)
}
@@ -4637,7 +4636,7 @@ async fn start_protocol_neutral_runtime_command(
command,
inspector_json,
runtime_command_awaits_promise(&cmd, RuntimeAction::Evaluate),
- RendererInspectorResponseDelivery::CommandReply,
+ RendererInspectorResponseDelivery::AdapterReply,
owner.clone(),
),
Err(message) => {
@@ -4694,7 +4693,7 @@ async fn start_protocol_neutral_runtime_command(
command,
inspector_json,
runtime_command_awaits_promise(&cmd, RuntimeAction::CallFunctionOn),
- RendererInspectorResponseDelivery::CommandReply,
+ RendererInspectorResponseDelivery::AdapterReply,
owner.clone(),
),
Err(message) => RuntimeCommandTaskStep::Complete(
@@ -4724,7 +4723,10 @@ async fn start_protocol_neutral_runtime_command(
}
};
let cmd = Cmd::from_parsed(&parsed)
- .expect("synthesized Runtime command must contain a domain separator");
+ .expect("synthesized Runtime command must contain a domain separator")
+ .with_terminal_response_delivery_override(Some(
+ RendererInspectorResponseDelivery::AdapterReply,
+ ));
let MainRuntimeCommand::Inspector(command) =
MainRuntimeCommand::classify(RuntimeAction::TerminateExecution)
else {
@@ -8296,13 +8298,13 @@ async fn complete_pending_runtime_inspector_command(
renderer_response_rx.take();
saw_current_response = true;
}
- if response_delivery == RendererInspectorResponseDelivery::DevToolsSession {
+ if response_delivery == RendererInspectorResponseDelivery::SessionSink {
// The attachment-scoped renderer session stream owns the terminal
// response. The typed Page completion remains internal state only and
// must not join or await the legacy per-command receiver.
renderer_response_rx.take();
}
- if response_delivery == RendererInspectorResponseDelivery::CommandReply
+ if response_delivery == RendererInspectorResponseDelivery::AdapterReply
&& !completed.wait_for_deferred_reply
&& let Some(renderer_response_rx) = renderer_response_rx.take()
{
@@ -8324,7 +8326,7 @@ async fn complete_pending_runtime_inspector_command(
saw_current_response,
);
}
- if response_delivery == RendererInspectorResponseDelivery::CommandReply
+ if response_delivery == RendererInspectorResponseDelivery::AdapterReply
&& completed.wait_for_deferred_reply
&& (renderer_response_rx.is_some() || !saw_current_response)
&& completed.command_id.is_some()
@@ -8721,10 +8723,10 @@ async fn complete_pending_runtime_binding_inspector_command(
if saw_current_response {
renderer_response_rx.take();
}
- if response_delivery == RendererInspectorResponseDelivery::DevToolsSession {
+ if response_delivery == RendererInspectorResponseDelivery::SessionSink {
renderer_response_rx.take();
}
- if response_delivery == RendererInspectorResponseDelivery::CommandReply
+ if response_delivery == RendererInspectorResponseDelivery::AdapterReply
&& let Some(renderer_response_rx) = renderer_response_rx
{
route_registered_runtime_response_receiver_into(
@@ -8736,7 +8738,7 @@ async fn complete_pending_runtime_binding_inspector_command(
)
.await;
}
- if response_delivery == RendererInspectorResponseDelivery::CommandReply {
+ if response_delivery == RendererInspectorResponseDelivery::AdapterReply {
record_runtime_binding_command_response_from_routed_events(
&mut task,
routed_output.events(),
@@ -9236,8 +9238,7 @@ fn start_pending_shared_worker_runtime_inspector_command(
action.label(),
)
.map_err(|error| error.to_string())?;
- let response_delivery =
- cmd.terminal_response_delivery(RendererInspectorResponseDelivery::DevToolsSession);
+ let response_delivery = cmd.terminal_response_delivery();
let pending = match start_shared_worker_frontend_inspector_dispatch(
conn,
cmd,
@@ -9305,8 +9306,7 @@ fn start_pending_service_worker_runtime_inspector_command(
action.label(),
)
.map_err(|error| error.to_string())?;
- let response_delivery =
- cmd.terminal_response_delivery(RendererInspectorResponseDelivery::DevToolsSession);
+ let response_delivery = cmd.terminal_response_delivery();
let pending = match start_service_worker_frontend_inspector_dispatch(
conn,
cmd,
@@ -9474,7 +9474,7 @@ async fn complete_pending_shared_worker_runtime_inspector_command(
) = match completed_inspector {
Ok(mut completed_protocol) => {
let response_delivery = completed_protocol.response_delivery();
- if response_delivery == RendererInspectorResponseDelivery::DevToolsSession
+ if response_delivery == RendererInspectorResponseDelivery::SessionSink
&& !completed.await_promise
&& let Err(message) = completed_protocol.wait_for_session_response().await
{
@@ -9530,10 +9530,10 @@ async fn complete_pending_shared_worker_runtime_inspector_command(
if saw_current_response {
renderer_response_rx.take();
}
- if response_delivery == RendererInspectorResponseDelivery::DevToolsSession {
+ if response_delivery == RendererInspectorResponseDelivery::SessionSink {
renderer_response_rx.take();
}
- if response_delivery == RendererInspectorResponseDelivery::CommandReply
+ if response_delivery == RendererInspectorResponseDelivery::AdapterReply
&& !completed.wait_for_deferred_reply
&& let Some(renderer_response_rx) = renderer_response_rx.take()
{
@@ -9546,7 +9546,7 @@ async fn complete_pending_shared_worker_runtime_inspector_command(
)
.await;
}
- if response_delivery == RendererInspectorResponseDelivery::CommandReply
+ if response_delivery == RendererInspectorResponseDelivery::AdapterReply
&& completed.wait_for_deferred_reply
&& (renderer_response_rx.is_some() || !saw_current_response)
&& completed.command_id.is_some()
@@ -9558,7 +9558,7 @@ async fn complete_pending_shared_worker_runtime_inspector_command(
renderer_response_rx,
);
}
- if response_delivery == RendererInspectorResponseDelivery::DevToolsSession
+ if response_delivery == RendererInspectorResponseDelivery::SessionSink
&& completed.await_promise
&& session_response_succeeded.is_none()
{
@@ -9663,7 +9663,7 @@ async fn complete_pending_service_worker_runtime_inspector_command(
) = match completed_inspector {
Ok(mut completed_protocol) => {
let response_delivery = completed_protocol.response_delivery();
- if response_delivery == RendererInspectorResponseDelivery::DevToolsSession
+ if response_delivery == RendererInspectorResponseDelivery::SessionSink
&& !completed.await_promise
&& let Err(message) = completed_protocol.wait_for_session_response().await
{
@@ -9719,10 +9719,10 @@ async fn complete_pending_service_worker_runtime_inspector_command(
if saw_current_response {
renderer_response_rx.take();
}
- if response_delivery == RendererInspectorResponseDelivery::DevToolsSession {
+ if response_delivery == RendererInspectorResponseDelivery::SessionSink {
renderer_response_rx.take();
}
- if response_delivery == RendererInspectorResponseDelivery::CommandReply
+ if response_delivery == RendererInspectorResponseDelivery::AdapterReply
&& !completed.wait_for_deferred_reply
&& let Some(renderer_response_rx) = renderer_response_rx.take()
{
@@ -9735,7 +9735,7 @@ async fn complete_pending_service_worker_runtime_inspector_command(
)
.await;
}
- if response_delivery == RendererInspectorResponseDelivery::CommandReply
+ if response_delivery == RendererInspectorResponseDelivery::AdapterReply
&& completed.wait_for_deferred_reply
&& (renderer_response_rx.is_some() || !saw_current_response)
&& completed.command_id.is_some()
@@ -9747,7 +9747,7 @@ async fn complete_pending_service_worker_runtime_inspector_command(
renderer_response_rx,
);
}
- if response_delivery == RendererInspectorResponseDelivery::DevToolsSession
+ if response_delivery == RendererInspectorResponseDelivery::SessionSink
&& completed.await_promise
&& session_response_succeeded.is_none()
{
@@ -10375,8 +10375,7 @@ fn start_pending_runtime_disable_command(
cmd: &Cmd<'_>,
) -> RuntimeCommandTaskStep {
let owner_scope = CommandOwnerScope::capture(conn, cmd.session_id);
- let response_delivery =
- cmd.terminal_response_delivery(RendererInspectorResponseDelivery::DevToolsSession);
+ let response_delivery = cmd.terminal_response_delivery();
start_runtime_disable_command_for_owner(conn, cmd, owner_scope, response_delivery)
}
@@ -10439,7 +10438,7 @@ pub(crate) async fn execute_runtime_listener_command_for_owner(
conn,
&cmd,
owner,
- RendererInspectorResponseDelivery::CommandReply,
+ RendererInspectorResponseDelivery::AdapterReply,
)
};
loop {
@@ -10469,7 +10468,7 @@ fn start_runtime_run_if_waiting_for_debugger_command(
cmd,
&owner_scope,
cmd.json.to_owned(),
- cmd.terminal_response_delivery(RendererInspectorResponseDelivery::DevToolsSession),
+ cmd.terminal_response_delivery(),
) {
Ok(pending) => pending,
Err(message) if message == "NoDocumentLoaded" => {
@@ -10531,7 +10530,7 @@ fn start_runtime_discard_console_entries_command(
cmd,
&owner_scope,
cmd.json.to_owned(),
- cmd.terminal_response_delivery(RendererInspectorResponseDelivery::DevToolsSession),
+ cmd.terminal_response_delivery(),
) {
Ok(pending) => pending,
Err(message) => {
@@ -11525,7 +11524,7 @@ mod protocol_neutral_tests {
DevToolsCommand::EvaluateScript(command),
cmd.json.to_owned(),
false,
- RendererInspectorResponseDelivery::CommandReply,
+ RendererInspectorResponseDelivery::AdapterReply,
);
let RuntimeCommandTaskStep::Complete(plan) = step else {
@@ -11569,7 +11568,7 @@ mod protocol_neutral_tests {
DevToolsCommand::EvaluateScript(command),
cmd.json.to_owned(),
true,
- RendererInspectorResponseDelivery::CommandReply,
+ RendererInspectorResponseDelivery::AdapterReply,
);
let RuntimeCommandTaskStep::Complete(plan) = step else {
diff --git a/moli-protocol/src/domains/runtime/tests/console.rs b/moli-protocol/src/domains/runtime/tests/console.rs
index cb61d2046..8898c8498 100644
--- a/moli-protocol/src/domains/runtime/tests/console.rs
+++ b/moli-protocol/src/domains/runtime/tests/console.rs
@@ -92,7 +92,7 @@ async fn runtime_discard_console_entries_is_page_target_local() {
.expect("browser context should exist")
.active_target_id(),
Some("TID-active"),
- "background Runtime.discardConsoleEntries must not promote the target"
+ "background Runtime.discardConsoleEntries must not activate the target"
);
ctx.sent.clear();
@@ -1408,7 +1408,7 @@ async fn runtime_exception_thrown_emits_timer_callback_warning() {
.await;
}
#[tokio::test]
-async fn runtime_discard_console_entries_advances_background_owner_without_promotion() {
+async fn runtime_discard_console_entries_advances_background_owner_without_activation() {
let mut ctx = TestContext::new();
with_loaded_runtime_frontend_enabled_background_target_async(
&mut ctx,
@@ -1460,7 +1460,7 @@ async fn runtime_discard_console_entries_advances_background_owner_without_promo
assert_eq!(
browser_context.active_target_id(),
Some("TID-active"),
- "background Runtime.discardConsoleEntries should not promote the target"
+ "background Runtime.discardConsoleEntries should not activate the target"
);
assert_eq!(
browser_context
@@ -1474,7 +1474,7 @@ async fn runtime_discard_console_entries_advances_background_owner_without_promo
);
}
#[tokio::test(flavor = "multi_thread")]
-async fn background_runtime_get_heap_usage_reads_owner_page_without_promotion() {
+async fn background_runtime_get_heap_usage_reads_owner_page_without_activation() {
let mut ctx = TestContext::new();
with_loaded_runtime_frontend_enabled_background_target_async(
&mut ctx,
@@ -1515,6 +1515,6 @@ async fn background_runtime_get_heap_usage_reads_owner_page_without_promotion()
.as_ref()
.and_then(|browser_context| browser_context.active_target_id()),
Some("TID-active"),
- "background Runtime.getHeapUsage should not promote the target"
+ "background Runtime.getHeapUsage should not activate the target"
);
}
diff --git a/moli-protocol/src/domains/runtime/tests/evaluate.rs b/moli-protocol/src/domains/runtime/tests/evaluate.rs
index 58b44fc1c..451152c56 100644
--- a/moli-protocol/src/domains/runtime/tests/evaluate.rs
+++ b/moli-protocol/src/domains/runtime/tests/evaluate.rs
@@ -1849,7 +1849,7 @@ async fn evaluate_started_before_pending_navigation_can_complete() {
}
#[tokio::test]
-async fn evaluate_rejects_auxiliary_session_while_main_document_navigation_is_pending() {
+async fn evaluate_rejects_attached_session_while_main_document_navigation_is_pending() {
let mut ctx = TestContext::new();
with_loaded_document_async(
&mut ctx,
@@ -1864,8 +1864,8 @@ async fn evaluate_rejects_auxiliary_session_while_main_document_navigation_is_pe
browser_context.set_active_target_id("TID-1");
browser_context.attach_active_session("SID-1");
assert!(
- browser_context.assign_auxiliary_session_to_target("TID-1", "SID-aux".to_owned()),
- "auxiliary session should attach to the active target"
+ browser_context.assign_attached_session_to_target("TID-1", "SID-attached".to_owned()),
+ "attached session should attach to the active target"
);
browser_context.set_target_url("data:text/html,previous".to_owned());
browser_context
@@ -1873,15 +1873,15 @@ async fn evaluate_rejects_auxiliary_session_while_main_document_navigation_is_pe
.expect("active navigation should start");
assert!(
ctx.conn
- .has_pending_document_navigation_for_session_owner(Some("SID-aux")),
- "auxiliary session should inherit the active target document gate"
+ .has_pending_document_navigation_for_session_owner(Some("SID-attached")),
+ "attached session should inherit the active target document gate"
);
ctx.sent.clear();
ctx.process_async(json!({
"id": 4,
"method": "Runtime.evaluate",
- "sessionId": "SID-aux",
+ "sessionId": "SID-attached",
"params": {
"expression": "document.title",
"returnByValue": true
@@ -2878,7 +2878,7 @@ async fn runtime_await_promise_releases_dispatch_before_session_response() {
let CdpCommandTaskStep::Complete(outcome) =
ctx.conn.complete_pending_command_dispatch(completed).await
else {
- panic!("a Page session response must not enter the CommandReply deferred-reply lane");
+ panic!("a Page session response must not enter the AdapterReply deferred-reply lane");
};
drop(outcome);
assert!(
@@ -2899,7 +2899,7 @@ async fn runtime_await_promise_releases_dispatch_before_session_response() {
assert!(
!ctx.conn
.has_claimed_pending_inspector_awaits_for_session_owner(None),
- "the CommandReply claimed-await index must remain unused"
+ "the AdapterReply claimed-await index must remain unused"
);
ctx.process_async(json!({
@@ -7230,7 +7230,7 @@ async fn release_object_group_drops_inherited_get_properties_and_call_function_h
);
}
#[tokio::test]
-async fn background_runtime_evaluate_emits_runtime_observable_from_background_owner_without_promotion()
+async fn background_runtime_evaluate_emits_runtime_observable_from_background_owner_without_activation()
{
let mut ctx = TestContext::new();
with_loaded_runtime_frontend_enabled_background_target_async(
@@ -7285,12 +7285,12 @@ async fn background_runtime_evaluate_emits_runtime_observable_from_background_ow
.as_ref()
.and_then(|browser_context| browser_context.active_target_id()),
Some("TID-active"),
- "background Runtime.evaluate observable drain should not promote the target"
+ "background Runtime.evaluate observable drain should not activate the target"
);
}
#[tokio::test]
-async fn call_function_on_loaded_background_owner_without_promotion() {
+async fn call_function_on_loaded_background_owner_without_activation() {
let mut ctx = TestContext::new();
with_loaded_runtime_frontend_enabled_background_target_async(
&mut ctx,
@@ -7351,7 +7351,7 @@ async fn call_function_on_loaded_background_owner_without_promotion() {
.as_ref()
.and_then(|browser_context| browser_context.active_target_id()),
Some("TID-active"),
- "background Runtime.callFunctionOn should not promote the target"
+ "background Runtime.callFunctionOn should not activate the target"
);
ctx.process_async(json!({
@@ -8117,7 +8117,7 @@ fn replay_policy_command_rotates_lease_and_completes_on_replacement_attachment()
.expect("register replay command");
let (old_correlation, old_sender, response_receiver) = prepared.into_parts();
let response_receiver = response_receiver
- .expect("a synthesized CommandReply call must allocate a response receiver");
+ .expect("a synthesized AdapterReply call must allocate a response receiver");
ctx.process_async(json!({
"id": 9_022,
diff --git a/moli-protocol/src/domains/runtime/tests/objects.rs b/moli-protocol/src/domains/runtime/tests/objects.rs
index 76716de20..e5aaafe21 100644
--- a/moli-protocol/src/domains/runtime/tests/objects.rs
+++ b/moli-protocol/src/domains/runtime/tests/objects.rs
@@ -79,7 +79,7 @@ async fn release_object_rejects_cross_owner_and_drops_owner_registry_on_success(
.as_ref()
.and_then(|browser_context| browser_context.active_target_id()),
Some("TID-active"),
- "background Runtime.evaluate should not promote the target"
+ "background Runtime.evaluate should not activate the target"
);
assert!(
ctx.conn
@@ -124,7 +124,7 @@ async fn release_object_rejects_cross_owner_and_drops_owner_registry_on_success(
.as_ref()
.and_then(|browser_context| browser_context.active_target_id()),
Some("TID-active"),
- "background Runtime.releaseObject should not promote the target"
+ "background Runtime.releaseObject should not activate the target"
);
assert!(
ctx.conn
@@ -201,7 +201,7 @@ async fn release_object_group_drops_owner_registry_on_success() {
.as_ref()
.and_then(|browser_context| browser_context.active_target_id()),
Some("TID-active"),
- "background Runtime.releaseObjectGroup should not promote the target"
+ "background Runtime.releaseObjectGroup should not activate the target"
);
assert!(
ctx.conn
@@ -300,7 +300,7 @@ async fn release_object_group_drops_await_promise_inherited_result_handle() {
);
}
#[tokio::test]
-async fn await_promise_routes_to_loaded_background_owner_without_promotion() {
+async fn await_promise_routes_to_loaded_background_owner_without_activation() {
let mut ctx = TestContext::new();
with_loaded_runtime_frontend_enabled_background_target_async(
&mut ctx,
@@ -359,7 +359,7 @@ async fn await_promise_routes_to_loaded_background_owner_without_promotion() {
.as_ref()
.and_then(|browser_context| browser_context.active_target_id()),
Some("TID-active"),
- "background Runtime.awaitPromise should not promote the target"
+ "background Runtime.awaitPromise should not activate the target"
);
assert!(
ctx.conn
@@ -426,7 +426,7 @@ async fn await_promise_rejects_promise_object_id_known_to_different_target_owner
);
}
#[tokio::test]
-async fn loaded_background_runtime_binding_routes_to_owner_without_promotion() {
+async fn loaded_background_runtime_binding_routes_to_owner_without_activation() {
let mut ctx = TestContext::new();
with_loaded_runtime_frontend_enabled_background_target_async(
&mut ctx,
@@ -463,7 +463,7 @@ async fn loaded_background_runtime_binding_routes_to_owner_without_promotion() {
.as_ref()
.and_then(|browser_context| browser_context.active_target_id()),
Some("TID-active"),
- "background Runtime.addBinding should not promote the target"
+ "background Runtime.addBinding should not activate the target"
);
assert!(
ctx.conn
@@ -517,7 +517,7 @@ async fn loaded_background_runtime_binding_routes_to_owner_without_promotion() {
.as_ref()
.and_then(|browser_context| browser_context.active_target_id()),
Some("TID-active"),
- "background Runtime.removeBinding should not promote the target"
+ "background Runtime.removeBinding should not activate the target"
);
assert!(
ctx.conn
@@ -551,7 +551,7 @@ async fn loaded_background_runtime_binding_routes_to_owner_without_promotion() {
);
}
#[tokio::test]
-async fn runtime_disable_advances_background_owner_observable_cursor_without_promotion() {
+async fn runtime_disable_advances_background_owner_observable_cursor_without_activation() {
let mut ctx = TestContext::new();
with_loaded_runtime_frontend_enabled_background_target_async(
&mut ctx,
@@ -603,7 +603,7 @@ async fn runtime_disable_advances_background_owner_observable_cursor_without_pro
assert_eq!(
browser_context.active_target_id(),
Some("TID-active"),
- "background Runtime.disable should not promote the target"
+ "background Runtime.disable should not activate the target"
);
assert_eq!(
browser_context
@@ -617,8 +617,8 @@ async fn runtime_disable_advances_background_owner_observable_cursor_without_pro
);
}
#[tokio::test]
-async fn runtime_disable_clears_background_child_default_context_emission_cursor_without_promotion()
-{
+async fn runtime_disable_clears_background_child_default_context_emission_cursor_without_activation()
+ {
let mut ctx = TestContext::new();
let html = "<iframe srcdoc=\"<body>background child</body>\"></iframe>";
let background_target = crate::conn::PageTargetHost::with_url(
@@ -726,6 +726,6 @@ async fn runtime_disable_clears_background_child_default_context_emission_cursor
.expect("browser context")
.active_target_id(),
Some("TID-active"),
- "background Runtime.disable/enable must not promote the target"
+ "background Runtime.disable/enable must not activate the target"
);
}
diff --git a/moli-protocol/src/domains/runtime/tests/shared_worker.rs b/moli-protocol/src/domains/runtime/tests/shared_worker.rs
index 2caf9555f..b3a1df65e 100644
--- a/moli-protocol/src/domains/runtime/tests/shared_worker.rs
+++ b/moli-protocol/src/domains/runtime/tests/shared_worker.rs
@@ -3435,7 +3435,7 @@ onconnect = event => {
let CdpCommandTaskStep::Complete(outcome) =
ctx.conn.complete_pending_command_dispatch(completed).await
else {
- panic!("a Worker session response must not enter the CommandReply deferred-reply lane");
+ panic!("a Worker session response must not enter the AdapterReply deferred-reply lane");
};
assert!(
outcome.into_parts().0.is_empty(),
diff --git a/moli-protocol/src/domains/storage/tests.rs b/moli-protocol/src/domains/storage/tests.rs
index aa6ad278c..3e02e9ebb 100644
--- a/moli-protocol/src/domains/storage/tests.rs
+++ b/moli-protocol/src/domains/storage/tests.rs
@@ -766,7 +766,7 @@ async fn storage_get_storage_key_for_frame_rejects_unknown_frame() {
}
#[tokio::test(flavor = "multi_thread")]
-async fn storage_key_targets_loaded_background_owner_without_promotion() {
+async fn storage_key_targets_loaded_background_owner_without_activation() {
let mut ctx = TestContext::new();
let (page_url, server) =
spawn_static_html_server(r#"<iframe srcdoc="<p>child</p>"></iframe>"#).await;
@@ -955,24 +955,26 @@ async fn storage_key_targets_inactive_owner_without_activation() {
}
#[tokio::test(flavor = "multi_thread")]
-async fn storage_get_cookies_accepts_auxiliary_page_session_route() {
+async fn storage_get_cookies_accepts_attached_page_session_route() {
let mut ctx = TestContext::new();
- let mut browser_context = BrowserContext::new("BID-aux-storage".into());
- browser_context.set_active_target_id("TID-aux-storage".to_owned());
- assert!(
- browser_context
- .assign_auxiliary_session_to_target("TID-aux-storage", "SID-aux-storage".to_owned())
- );
+ let mut browser_context = BrowserContext::new("BID-attached-storage".into());
+ browser_context.set_active_target_id("TID-attached-storage".to_owned());
+ assert!(browser_context.assign_attached_session_to_target(
+ "TID-attached-storage",
+ "SID-attached-storage".to_owned()
+ ));
ctx.conn.browser_context = Some(browser_context);
+ ctx.conn
+ .register_bound_session_for_test("SID-attached-storage");
ctx.process_async(json!({
"id": 8,
"method": "Storage.getCookies",
- "sessionId": "SID-aux-storage"
+ "sessionId": "SID-attached-storage"
}))
.await;
- ctx.expect_result(8, json!({ "cookies": [] }), Some("SID-aux-storage"));
+ ctx.expect_result(8, json!({ "cookies": [] }), Some("SID-attached-storage"));
}
#[tokio::test(flavor = "multi_thread")]
@@ -988,6 +990,8 @@ async fn storage_get_cookies_accepts_background_page_session_route() {
None,
);
ctx.conn.browser_context = Some(browser_context);
+ ctx.conn
+ .register_bound_session_for_test("SID-background-storage");
ctx.process_async(json!({
"id": 9,
diff --git a/moli-protocol/src/domains/target.rs b/moli-protocol/src/domains/target.rs
index 08ebe7ce0..36d440243 100644
--- a/moli-protocol/src/domains/target.rs
+++ b/moli-protocol/src/domains/target.rs
@@ -2,7 +2,7 @@ use serde::Deserialize;
use crate::conn::{
BackgroundProtocolEvent, BrowserContext, CdpConnection, Cmd, CommandOwnerScope,
- TargetHandlerAccessMode,
+ TargetAttachSessionCommit, TargetHandlerAccessMode,
};
use crate::devtools_runtime::{
DevToolsActivateTargetCommand, DevToolsCloseTargetCommand, DevToolsCommand,
@@ -27,6 +27,9 @@ mod popup;
#[cfg(test)]
mod protocol_neutral_tests;
mod session_disposal;
+pub(crate) use session_disposal::{
+ dispose_closed_session_domains_async, dispose_uncommitted_session_async,
+};
#[cfg(test)]
mod tests;
mod worker_target;
@@ -179,91 +182,6 @@ pub(in crate::domains) fn set_dedicated_worker_pause_on_start_owner(
sync_dedicated_worker_pause_on_start_for_devtools(conn);
}
-pub(in crate::domains::target) async fn clear_detached_target_fetch_state_background_events_async(
- conn: &mut CdpConnection,
- out: &mut Vec<BackgroundProtocolEvent>,
- session_id: &str,
-) -> Option<moli_core::RendererOutputFence> {
- clear_detached_target_owner_fetch_state_background_events_async(conn, out, Some(session_id))
- .await
-}
-
-async fn clear_detached_target_owner_fetch_state_background_events_async(
- conn: &mut CdpConnection,
- out: &mut Vec<BackgroundProtocolEvent>,
- session_id: Option<&str>,
-) -> Option<moli_core::RendererOutputFence> {
- let (pending_fetch_state, pending_page_command) =
- (match conn.start_disable_fetch_for_session_owner(session_id) {
- Ok(disable_state) => disable_state,
- Err(error) => {
- tracing::warn!(
- ?session_id,
- error,
- "failed to disable Fetch interception while detaching target owner"
- );
- return None;
- }
- })?;
-
- if let Some(pending_page_command) = pending_page_command {
- match pending_page_command.wait().await {
- Ok(completion) => match conn.loaded_page_mut_for_protocol_access(session_id) {
- Ok(page) => {
- if let Err(error) = page.finish_set_fetch_subresource_interception(completion) {
- tracing::warn!(
- ?session_id,
- %error,
- "failed to finish Fetch interception disable while detaching target owner"
- );
- }
- }
- Err(message) if message == "NoDocumentLoaded" => {}
- Err(message) => {
- tracing::warn!(
- ?session_id,
- message,
- "failed to find page while detaching target owner Fetch state"
- );
- }
- },
- Err(error) => {
- tracing::warn!(
- ?session_id,
- %error,
- "renderer failed Fetch interception disable while detaching target owner"
- );
- }
- }
- }
-
- let (
- pending_navigations,
- pending_auth_navigations,
- pending_response_navigations,
- pending_subresource_fetches,
- pending_subresource_auths,
- pending_subresource_responses,
- ) = pending_fetch_state;
- // Target-owner teardown has no command response to fence. The concrete
- // renderer publication remains ordered on its own stream and will reach
- // protocol ingress independently.
- page::fail_pending_fetch_state_background_events_async(
- conn,
- out,
- session_id,
- "Target detached",
- "Target detached",
- pending_navigations,
- pending_auth_navigations,
- pending_response_navigations,
- pending_subresource_fetches,
- pending_subresource_auths,
- pending_subresource_responses,
- )
- .await
-}
-
impl CdpConnection {
/// Releases root-owned Target control state after its transport frontend
/// disconnects, while preserving sessions owned by direct page frontends.
@@ -278,12 +196,12 @@ impl CdpConnection {
None,
"Inspector detached",
);
- let _ = clear_detached_target_owner_fetch_state_background_events_async(
- self,
- side_effects.background_events_mut(),
- None,
- )
- .await;
+ if let Err(error) =
+ super::fetch::dispose_owner_async(self, side_effects.background_events_mut(), None)
+ .await
+ {
+ tracing::warn!(%error, "failed to dispose root Fetch handler");
+ }
let _ = self
.detach_runtime_inspector_session_for_session_owner_async(None)
.await;
@@ -306,7 +224,7 @@ impl CdpConnection {
enum PendingTargetCommandKind {
AttachToTarget {
- attached_session_id: String,
+ prepared_session: TargetAttachSessionCommit,
target_info: DevToolsTargetInfo,
initial_document: Option<Box<crate::conn::PendingInitialDocumentPageBuild>>,
},
@@ -316,7 +234,6 @@ enum PendingTargetCommandKind {
SetAutoAttach {
auto_attach: bool,
owner_session_id: Option<String>,
- legacy_disable_all: bool,
},
CreateTarget {
response_plan: CommandOutputPlan,
@@ -341,7 +258,7 @@ enum PendingTargetCommandKind {
enum CompletedTargetCommandKind {
AttachToTarget {
- attached_session_id: String,
+ prepared_session: TargetAttachSessionCommit,
target_info: DevToolsTargetInfo,
initial_document: Option<
Result<
@@ -356,7 +273,6 @@ enum CompletedTargetCommandKind {
SetAutoAttach {
auto_attach: bool,
owner_session_id: Option<String>,
- legacy_disable_all: bool,
},
CreateTarget {
response_plan: CommandOutputPlan,
@@ -388,11 +304,11 @@ impl PendingTargetCommandDispatch {
pub(crate) async fn wait(self) -> CompletedTargetCommandDispatch {
let kind = match *self.kind {
PendingTargetCommandKind::AttachToTarget {
- attached_session_id,
+ prepared_session,
target_info,
initial_document,
} => CompletedTargetCommandKind::AttachToTarget {
- attached_session_id,
+ prepared_session,
target_info,
initial_document: match initial_document {
Some(pending) => Some(pending.wait().await.map(Box::new)),
@@ -405,11 +321,9 @@ impl PendingTargetCommandDispatch {
PendingTargetCommandKind::SetAutoAttach {
auto_attach,
owner_session_id,
- legacy_disable_all,
} => CompletedTargetCommandKind::SetAutoAttach {
auto_attach,
owner_session_id,
- legacy_disable_all,
},
PendingTargetCommandKind::CreateTarget {
response_plan,
@@ -764,15 +678,14 @@ pub(crate) async fn complete_pending_target_command(
) -> TargetCommandTaskStep {
match completed.kind {
CompletedTargetCommandKind::AttachToTarget {
- attached_session_id,
+ prepared_session,
target_info,
initial_document,
} => {
return TargetCommandTaskStep::Complete(
attachment::complete_attach_to_target_command_async(
conn,
- completed.session_id.as_deref(),
- attached_session_id,
+ prepared_session,
target_info,
initial_document,
)
@@ -787,14 +700,12 @@ pub(crate) async fn complete_pending_target_command(
CompletedTargetCommandKind::SetAutoAttach {
auto_attach,
owner_session_id,
- legacy_disable_all,
} => {
return TargetCommandTaskStep::Complete(
auto_attach::complete_set_auto_attach_command_async(
conn,
auto_attach,
owner_session_id.as_deref(),
- legacy_disable_all,
command_context,
)
.await,
@@ -915,7 +826,6 @@ fn pending_set_auto_attach_command(
session_id: Option<&str>,
auto_attach: bool,
owner_session_id: Option<&str>,
- legacy_disable_all: bool,
) -> TargetCommandTaskStep {
TargetCommandTaskStep::Pending(PendingTargetCommandDispatch {
command_id,
@@ -923,7 +833,6 @@ fn pending_set_auto_attach_command(
kind: Box::new(PendingTargetCommandKind::SetAutoAttach {
auto_attach,
owner_session_id: owner_session_id.map(str::to_owned),
- legacy_disable_all,
}),
})
}
@@ -1204,8 +1113,16 @@ mod devtools_runtime_entry_tests {
let mut conn = CdpConnection::new();
let plan = attachment::complete_attach_to_target_command_async(
&mut conn,
- Some("SID-parent"),
- "SID-child".to_owned(),
+ TargetAttachSessionCommit::direct(
+ "SID-child",
+ Some("SID-parent".to_owned()),
+ crate::conn::CdpSessionRoute::PageTarget {
+ browser_context_id: "BID-child".to_owned(),
+ target_id: "TID-child".to_owned(),
+ session_key: moli_page_types::DevToolsSessionKey::Primary,
+ },
+ false,
+ ),
DevToolsTargetInfo {
target_id: Some(DevToolsTargetId::from("TID-child")),
kind: DevToolsTargetKind::Page,
@@ -1248,14 +1165,14 @@ mod devtools_runtime_entry_tests {
}
#[tokio::test]
- async fn devtools_target_legacy_close_drains_runtime_ready_events_without_serializing_them() {
+ async fn devtools_target_close_drains_runtime_ready_events_without_serializing_them() {
let mut conn = CdpConnection::new();
let mut browser_context = BrowserContext::new("BID-runtime-ready-close".to_owned());
browser_context.set_active_target_id("TID-runtime-ready-close");
browser_context.attach_active_session("SID-runtime-ready-close");
- assert!(browser_context.assign_auxiliary_session_to_target(
+ assert!(browser_context.assign_attached_session_to_target(
"TID-runtime-ready-close",
- "SID-runtime-ready-close-aux".to_owned(),
+ "SID-runtime-ready-close-attached".to_owned(),
));
conn.browser_context = Some(browser_context);
let page = conn
@@ -1277,10 +1194,10 @@ mod devtools_runtime_entry_tests {
.is_some(),
"test must cover scheduler-deferred Runtime await owner cleanup"
);
- conn.register_pending_inspector_await(7102, Some("SID-runtime-ready-close-aux"));
- let auxiliary_dispatch = conn
+ conn.register_pending_inspector_await(7102, Some("SID-runtime-ready-close-attached"));
+ let attached_dispatch = conn
.try_register_renderer_call_for_session_owner(
- Some("SID-runtime-ready-close-aux"),
+ Some("SID-runtime-ready-close-attached"),
7102,
None,
RendererCommandDescriptor::from_synthesized_payload(
@@ -1293,14 +1210,14 @@ mod devtools_runtime_entry_tests {
)
.expect("test Runtime command should parse"),
)
- .expect("auxiliary renderer command should register");
+ .expect("attached renderer command should register");
assert!(
conn.claim_pending_inspector_await_for_scheduler_deferred_reply(
7102,
- &crate::conn::CommandOwnerScope::for_session("SID-runtime-ready-close-aux",),
+ &crate::conn::CommandOwnerScope::for_session("SID-runtime-ready-close-attached",),
)
.is_some(),
- "test must cover an auxiliary scheduler-deferred Runtime await"
+ "test must cover an attached scheduler-deferred Runtime await"
);
let (result, protocol_events) = execute_devtools_target_command_async_with_protocol_events(
@@ -1338,9 +1255,9 @@ mod devtools_runtime_entry_tests {
.is_some_and(|response| response.command_id() == 7102
&& response.error() == Some("Target closed")
&& response.has_bound_renderer_call_id())),
- "an auxiliary claimed await must settle through its correlated typed response before the Page route retires"
+ "an attached claimed await must settle through its correlated typed response before the Page route retires"
);
- drop(auxiliary_dispatch);
+ drop(attached_dispatch);
assert!(
protocol_events.iter().all(|event| {
event.protocol_message().is_none_or(|message| {
@@ -1348,7 +1265,7 @@ mod devtools_runtime_entry_tests {
!= Some("InternalRuntimeInspectorResponseReadyNotRouted")
})
}),
- "legacy Target executor must not serialize runtime-ready events as internal errors"
+ "Target executor must not serialize runtime-ready events as internal errors"
);
}
diff --git a/moli-protocol/src/domains/target/attachment.rs b/moli-protocol/src/domains/target/attachment.rs
index 083230c5a..40fdad5fd 100644
--- a/moli-protocol/src/domains/target/attachment.rs
+++ b/moli-protocol/src/domains/target/attachment.rs
@@ -195,11 +195,12 @@ fn do_attach(conn: &mut CdpConnection, cmd: &Cmd<'_>, target_id: &str) -> Target
}
return target_command_error_without_session(-31998, "UnknownTargetId");
};
+ let browser_context_id = bc.id.clone();
let session_id = conn.gen_session_id();
let bc = conn.browser_context.as_mut().unwrap();
let assigned = if attach_from_browser_session || target_has_primary_session {
- bc.assign_auxiliary_session_to_target(target_id, session_id.clone())
+ bc.assign_attached_session_to_target(target_id, session_id.clone())
} else {
bc.assign_session_to_target(target_id, session_id.clone())
};
@@ -209,20 +210,35 @@ fn do_attach(conn: &mut CdpConnection, cmd: &Cmd<'_>, target_id: &str) -> Target
}
return target_command_error_without_session(-31998, "UnknownTargetId");
}
+ let session_key = if attach_from_browser_session || target_has_primary_session {
+ moli_page_types::DevToolsSessionKey::Attached(session_id.clone())
+ } else {
+ moli_page_types::DevToolsSessionKey::Primary
+ };
+ let prepared_session = crate::conn::TargetAttachSessionCommit::direct(
+ session_id.clone(),
+ cmd.session_id.map(str::to_owned),
+ crate::conn::CdpSessionRoute::PageTarget {
+ browser_context_id,
+ target_id: target_id.to_owned(),
+ session_key,
+ },
+ false,
+ );
+ let owner = crate::conn::CommandOwnerScope::for_route(prepared_session.route().clone());
- let initial_document =
- match conn.start_initial_document_page_ensure_for_session_owner(Some(&session_id)) {
- Ok(pending) => pending.map(Box::new),
- Err(message) => {
- if let Some(restore_browser_context_id) = restore_browser_context_id.as_ref() {
- restore_previously_active_browser_context(
- conn,
- restore_browser_context_id.as_deref(),
- );
- }
- return target_command_error_without_session(-32000, message);
+ let initial_document = match conn.start_initial_document_page_ensure_for_owner(&owner) {
+ Ok(pending) => pending.map(Box::new),
+ Err(message) => {
+ if let Some(restore_browser_context_id) = restore_browser_context_id.as_ref() {
+ restore_previously_active_browser_context(
+ conn,
+ restore_browser_context_id.as_deref(),
+ );
}
- };
+ return target_command_error_without_session(-32000, message);
+ }
+ };
let bc = conn.browser_context.as_ref().unwrap();
let target_info = bc
.devtools_target_info(target_id)
@@ -234,7 +250,7 @@ fn do_attach(conn: &mut CdpConnection, cmd: &Cmd<'_>, target_id: &str) -> Target
command_id: cmd.id,
session_id: cmd.session_id.map(str::to_owned),
kind: Box::new(PendingTargetCommandKind::AttachToTarget {
- attached_session_id: session_id,
+ prepared_session,
target_info,
initial_document,
}),
@@ -247,7 +263,7 @@ fn do_attach_tab_target(
tab_target_id: &str,
attach_from_browser_session: bool,
) -> TargetCommandTaskStep {
- let attach_as_auxiliary = attach_from_browser_session
+ let is_attached_session = attach_from_browser_session
|| conn
.primary_session_id_for_tab_target_id(tab_target_id)
.is_some();
@@ -256,7 +272,7 @@ fn do_attach_tab_target(
session_id.clone(),
command_session_id,
tab_target_id,
- attach_as_auxiliary,
+ is_attached_session,
) {
Ok(event_plan) => event_plan,
Err(message) => return target_command_error_without_session(-31998, message),
@@ -266,8 +282,7 @@ fn do_attach_tab_target(
pub(super) async fn complete_attach_to_target_command_async(
conn: &mut CdpConnection,
- command_session_id: Option<&str>,
- attached_session_id: String,
+ prepared_session: crate::conn::TargetAttachSessionCommit,
target_info: DevToolsTargetInfo,
initial_document: Option<
Result<
@@ -276,11 +291,7 @@ pub(super) async fn complete_attach_to_target_command_async(
>,
>,
) -> CommandOutputPlan {
- let prepared_session = conn.prepare_direct_attach_session_commit(
- attached_session_id.clone(),
- command_session_id.map(str::to_owned),
- false,
- );
+ let attached_session_id = prepared_session.session_id().to_owned();
match initial_document {
Some(Ok(completed_initial_document)) => {
let completed_initial_document = *completed_initial_document;
@@ -302,7 +313,9 @@ pub(super) async fn complete_attach_to_target_command_async(
None => {}
}
if let Err(message) = conn
- .apply_runtime_binding_state_for_session_owner_async(Some(&attached_session_id))
+ .apply_runtime_binding_state_for_owner_async(&crate::conn::CommandOwnerScope::for_route(
+ prepared_session.route().clone(),
+ ))
.await
&& message != "NoDocumentLoaded"
{
@@ -457,8 +470,11 @@ async fn send_message_to_target_inner_async(
return;
}
+ // Non-flat Target transport is an adapter boundary: the nested terminal
+ // response is consumed here and re-emitted as receivedMessageFromTarget.
+ // It must never escape as a direct Page/Worker frontend response.
let nested_outcome =
- Box::pin(conn.process_message_with_command_reply_turn_outcome_async(&params.message)).await;
+ Box::pin(conn.process_nested_target_message_adapter_async(&params.message)).await;
let (
nested_events,
post_renderer_output_events,
@@ -557,12 +573,6 @@ async fn detach_from_target_inner_async(
out.push_error(-31998, "InvalidSessionId");
return;
};
- if let Some(browser_context_id) = route.browser_context_id()
- && !conn.activate_browser_context_by_id(browser_context_id)
- {
- out.push_error(-31998, "InvalidSessionId");
- return;
- }
if let Some(requested_target_id) = params.target_id.as_deref()
&& detach_session_route_target_id(&route)
.is_some_and(|target_id| target_id != requested_target_id)
@@ -591,12 +601,16 @@ async fn detach_from_target_inner_async(
if let Some(session_id) = params.session_id.as_deref()
&& conn.is_browser_session_id(Some(session_id))
{
- conn.cancel_tracing_for_session_owner_async(Some(session_id))
- .await;
- let detached = conn.detach_browser_session_owner_event_plan(session_id);
- debug_assert!(detached.is_some());
- if let Some(detached) = detached {
- out.target_events_mut().extend_background_events(detached);
+ match super::session_disposal::dispose_browser_session_event_plan_async(conn, session_id)
+ .await
+ {
+ Ok(detached) => {
+ out.target_events_mut().extend_background_events(detached);
+ }
+ Err(error) => {
+ out.push_error(-31998, error.to_string());
+ return;
+ }
}
out.push_success();
return;
diff --git a/moli-protocol/src/domains/target/auto_attach.rs b/moli-protocol/src/domains/target/auto_attach.rs
index 3ce9a815c..6af8b054a 100644
--- a/moli-protocol/src/domains/target/auto_attach.rs
+++ b/moli-protocol/src/domains/target/auto_attach.rs
@@ -1,6 +1,9 @@
use serde::Deserialize;
-use crate::conn::{CdpTargetFilter, CdpTargetFilterEntry, PreparedTargetAttach};
+use crate::conn::{
+ CdpSessionRoute, CdpTargetFilter, CdpTargetFilterEntry, CommandOwnerScope,
+ PreparedTargetAttach, TargetAttachSessionCommit,
+};
use super::*;
@@ -84,9 +87,13 @@ pub(super) fn auto_attach_related(conn: &mut CdpConnection, cmd: &Cmd<'_>) -> Co
let event_plan = conn.commit_prepared_attach_event_plan(PreparedTargetAttach::new(
&target.target_id,
target_info,
- [conn.prepare_auto_attach_session_commit(
+ [TargetAttachSessionCommit::auto_attached(
session_id,
cmd.session_id.map(str::to_owned),
+ CdpSessionRoute::ServiceWorkerTarget {
+ browser_context_id: target.browser_context_id.clone(),
+ target_id: target.target_id.clone(),
+ },
false,
)],
));
@@ -318,11 +325,6 @@ pub(super) fn start_set_auto_attach_command(
"Filter should not simultaneously allow \"tab\" and \"page\", page targets are attached via tab targets",
);
}
- let owner_was_enabled = conn.has_auto_attach_owner(cmd.session_id);
- let legacy_disable_all = !params.auto_attach
- && !owner_was_enabled
- && conn.auto_attach_owner_count() == 0
- && conn.auto_attach;
if params.auto_attach {
conn.install_default_browser_target_for_auto_attach_if_enabled();
}
@@ -348,20 +350,13 @@ pub(super) fn start_set_auto_attach_command(
cmd.session_id,
pause_dedicated_workers_on_start,
);
- pending_set_auto_attach_command(
- cmd.id,
- cmd.session_id,
- params.auto_attach,
- cmd.session_id,
- legacy_disable_all,
- )
+ pending_set_auto_attach_command(cmd.id, cmd.session_id, params.auto_attach, cmd.session_id)
}
pub(super) async fn complete_set_auto_attach_command_async(
conn: &mut CdpConnection,
auto_attach: bool,
owner_session_id: Option<&str>,
- legacy_disable_all: bool,
command_context: &mut crate::conn::CommandDispatchContext,
) -> CommandOutputPlan {
let mut side_effects = events::TargetProtocolSideEffects::default();
@@ -371,7 +366,6 @@ pub(super) async fn complete_set_auto_attach_command_async(
&mut side_effects,
auto_attach,
owner_session_id,
- legacy_disable_all,
command_context,
)
.await;
@@ -390,10 +384,9 @@ async fn set_auto_attach_inner_async(
out: &mut events::TargetProtocolSideEffects,
auto_attach: bool,
owner_session_id: Option<&str>,
- legacy_disable_all: bool,
command_context: &mut crate::conn::CommandDispatchContext,
) {
- if !auto_attach && !legacy_disable_all {
+ if !auto_attach {
detach_auto_attached_sessions_for_owner_async(conn, out, owner_session_id, command_context)
.await;
return;
@@ -605,51 +598,72 @@ async fn set_auto_attach_inner_async(
})
}
};
- {
- for (target_id, session_id) in &attached_targets {
- let assigned = conn
- .prepare_auto_attached_page_session_binding(target_id, session_id.clone());
- debug_assert!(assigned, "attached target must remain addressable");
- }
- for (target_id, session_id) in &attached_shared_worker_targets {
- let assigned = conn.prepare_auto_attached_shared_worker_session_binding(
- target_id,
+ let attached_targets = attached_targets
+ .into_iter()
+ .filter_map(|(target_id, session_id)| {
+ let route = conn
+ .prepare_auto_attached_page_session_binding(&target_id, session_id.clone());
+ debug_assert!(route.is_some(), "attached target must remain addressable");
+ route.map(|route| (target_id, session_id, route))
+ })
+ .collect::<Vec<_>>();
+ let attached_shared_worker_targets = attached_shared_worker_targets
+ .into_iter()
+ .filter_map(|(target_id, session_id)| {
+ let route = conn.prepare_auto_attached_shared_worker_session_binding(
+ &target_id,
session_id.clone(),
);
debug_assert!(
- assigned,
+ route.is_some(),
"attached shared worker target must remain addressable"
);
- }
- for (target_id, session_id) in &attached_dedicated_worker_targets {
- let assigned = conn.prepare_auto_attached_dedicated_worker_session_binding(
- target_id,
+ route.map(|route| (target_id, session_id, route))
+ })
+ .collect::<Vec<_>>();
+ let attached_dedicated_worker_targets = attached_dedicated_worker_targets
+ .into_iter()
+ .filter_map(|(target_id, session_id)| {
+ let route = conn.prepare_auto_attached_dedicated_worker_session_binding(
+ &target_id,
session_id.clone(),
);
debug_assert!(
- assigned,
+ route.is_some(),
"attached dedicated worker target must remain addressable"
);
- }
- for (target_id, session_id) in &attached_service_worker_targets {
- let assigned = conn.prepare_auto_attached_service_worker_session_binding(
- target_id,
+ route.map(|route| (target_id, session_id, route))
+ })
+ .collect::<Vec<_>>();
+ let attached_service_worker_targets = attached_service_worker_targets
+ .into_iter()
+ .filter_map(|(target_id, session_id)| {
+ let route = conn.prepare_auto_attached_service_worker_session_binding(
+ &target_id,
session_id.clone(),
);
debug_assert!(
- assigned,
+ route.is_some(),
"attached service worker target must remain addressable"
);
- }
- }
- for (target_id, session_id) in &attached_tab_targets {
- let assigned = conn.prepare_auto_attached_tab_session_binding(
- target_id,
- session_id.clone(),
- owner_session_id,
- );
- debug_assert!(assigned, "attached tab target must remain addressable");
- }
+ route.map(|route| (target_id, session_id, route))
+ })
+ .collect::<Vec<_>>();
+ let attached_tab_targets = attached_tab_targets
+ .into_iter()
+ .filter_map(|(target_id, session_id)| {
+ let route = conn.prepare_auto_attached_tab_session_binding(
+ &target_id,
+ session_id.clone(),
+ owner_session_id,
+ );
+ debug_assert!(
+ route.is_some(),
+ "attached tab target must remain addressable"
+ );
+ route.map(|route| (target_id, session_id, route))
+ })
+ .collect::<Vec<_>>();
if let Some(foreground_target_id) = foreground_target_id {
match conn
.select_page_target_for_connection_async(&foreground_target_id)
@@ -667,9 +681,11 @@ async fn set_auto_attach_inner_async(
}
}
ensure_initial_document_for_attached_page_targets_async(conn, &attached_targets).await;
- for (target_id, session_id) in &attached_targets {
+ for (target_id, session_id, route) in &attached_targets {
if let Err(message) = conn
- .apply_runtime_binding_state_for_session_owner_async(Some(session_id))
+ .apply_runtime_binding_state_for_owner_async(&CommandOwnerScope::for_route(
+ route.clone(),
+ ))
.await
&& message != "NoDocumentLoaded"
{
@@ -681,22 +697,23 @@ async fn set_auto_attach_inner_async(
);
}
}
- for (target_id, session_id) in attached_tab_targets {
+ for (target_id, session_id, route) in attached_tab_targets {
let ti = conn
.tab_target_info(&target_id)
.expect("attached tab target must remain addressable");
let event_plan = conn.commit_prepared_attach_event_plan(PreparedTargetAttach::new(
&target_id,
ti,
- [conn.prepare_auto_attach_session_commit(
+ [TargetAttachSessionCommit::auto_attached(
session_id,
owner_session_id.map(str::to_owned),
+ route,
waiting_for_debugger,
)],
));
out.extend_background_events(event_plan);
}
- for (target_id, session_id) in attached_targets {
+ for (target_id, session_id, route) in attached_targets {
let ti = {
let bc = conn
.browser_context
@@ -717,15 +734,16 @@ async fn set_auto_attach_inner_async(
let event_plan = conn.commit_prepared_attach_event_plan(PreparedTargetAttach::new(
&target_id,
ti,
- [conn.prepare_auto_attach_session_commit(
+ [TargetAttachSessionCommit::auto_attached(
session_id,
owner_session_id.map(str::to_owned),
+ route,
waiting_for_debugger,
)],
));
out.extend_background_events(event_plan);
}
- for (target_id, session_id) in attached_shared_worker_targets {
+ for (target_id, session_id, route) in attached_shared_worker_targets {
let ti = {
let bc = conn
.browser_context
@@ -737,15 +755,16 @@ async fn set_auto_attach_inner_async(
let event_plan = conn.commit_prepared_attach_event_plan(PreparedTargetAttach::new(
&target_id,
ti,
- [conn.prepare_auto_attach_session_commit(
+ [TargetAttachSessionCommit::auto_attached(
session_id,
owner_session_id.map(str::to_owned),
+ route,
waiting_for_debugger,
)],
));
out.extend_background_events(event_plan);
}
- for (target_id, session_id) in attached_dedicated_worker_targets {
+ for (target_id, session_id, route) in attached_dedicated_worker_targets {
let ti = {
let bc = conn
.browser_context
@@ -757,15 +776,16 @@ async fn set_auto_attach_inner_async(
let event_plan = conn.commit_prepared_attach_event_plan(PreparedTargetAttach::new(
&target_id,
ti,
- [conn.prepare_auto_attach_session_commit(
+ [TargetAttachSessionCommit::auto_attached(
session_id,
owner_session_id.map(str::to_owned),
+ route,
waiting_for_debugger,
)],
));
out.extend_background_events(event_plan);
}
- for (target_id, session_id) in attached_service_worker_targets {
+ for (target_id, session_id, route) in attached_service_worker_targets {
let ti = {
let bc = conn
.browser_context
@@ -777,9 +797,10 @@ async fn set_auto_attach_inner_async(
let event_plan = conn.commit_prepared_attach_event_plan(PreparedTargetAttach::new(
&target_id,
ti,
- [conn.prepare_auto_attach_session_commit(
+ [TargetAttachSessionCommit::auto_attached(
session_id,
owner_session_id.map(str::to_owned),
+ route,
waiting_for_debugger,
)],
));
@@ -838,14 +859,25 @@ async fn set_auto_attach_inner_async(
out.background_events_mut(),
command_context.protocol_events_mut(),
crate::conn::TargetSessionDetachCleanupPlan::new(
- target_id,
+ &target_id,
&session_id,
None,
None,
),
)
- .await
- .expect("target session cleanup during auto-attach reset should succeed");
+ .await;
+ let outcome = match outcome {
+ Ok(outcome) => outcome,
+ Err(error) => {
+ tracing::warn!(
+ target_id,
+ session_id,
+ %error,
+ "failed to dispose target session during auto-attach reset"
+ );
+ continue;
+ }
+ };
let (event_plan, predecessor) = outcome.into_parts();
if let Some(predecessor) = predecessor {
command_context.set_renderer_output_predecessor(predecessor);
@@ -899,18 +931,18 @@ async fn auto_attach_child_page_for_tab_session_async(
return;
}
let session_id = conn.gen_session_id();
- let assigned =
- conn.prepare_auto_attached_page_session_binding(&page_target_id, session_id.clone());
- if !assigned {
+ let Some(route) =
+ conn.prepare_auto_attached_page_session_binding(&page_target_id, session_id.clone())
+ else {
return;
- }
+ };
ensure_initial_document_for_attached_page_targets_async(
conn,
- &[(page_target_id.clone(), session_id.clone())],
+ &[(page_target_id.clone(), session_id.clone(), route.clone())],
)
.await;
if let Err(message) = conn
- .apply_runtime_binding_state_for_session_owner_async(Some(&session_id))
+ .apply_runtime_binding_state_for_owner_async(&CommandOwnerScope::for_route(route.clone()))
.await
&& message != "NoDocumentLoaded"
{
@@ -921,9 +953,10 @@ async fn auto_attach_child_page_for_tab_session_async(
"failed to apply renderer binding state during tab child page auto-attach"
);
}
- let prepared_session = conn.prepare_auto_attach_session_commit(
+ let prepared_session = TargetAttachSessionCommit::auto_attached(
session_id.clone(),
Some(tab_session_id.to_owned()),
+ route,
false,
);
let Some(target_info) = conn
@@ -989,8 +1022,8 @@ pub(super) async fn release_attached_sessions_for_root_frontend_async(
for session_id in session_ids {
let detach_plan = conn.auto_attached_session_detach_plan(&session_id);
let preserves_other_frontends = matches!(
- detach_plan.cleanup_plan().map(|plan| plan.action()),
- Some(crate::conn::TargetBindingCleanupAction::PageTarget {
+ detach_plan.cleanup_plan().map(|plan| plan.target()),
+ Some(crate::conn::SessionDisposalTarget::PageTarget {
session_key: moli_page_types::DevToolsSessionKey::Primary,
..
})
@@ -1000,41 +1033,28 @@ pub(super) async fn release_attached_sessions_for_root_frontend_async(
continue;
}
- let Some(browser_context_id) = detach_plan.browser_context_id().map(str::to_owned) else {
- conn.rollback_auto_attached_session_detach_plan_without_event(&detach_plan);
- continue;
- };
- if !conn
- .activate_browser_context_by_id_async(&browser_context_id)
+ let predecessor =
+ match super::session_disposal::dispose_primary_page_session_preserving_frontend_async(
+ conn,
+ out.background_events_mut(),
+ command_context.protocol_events_mut(),
+ &session_id,
+ )
.await
- {
- conn.rollback_auto_attached_session_detach_plan_without_event(&detach_plan);
- continue;
- }
- let predecessor = match super::session_disposal::dispose_page_session_runtime_state_async(
- conn,
- out.background_events_mut(),
- command_context.protocol_events_mut(),
- &session_id,
- )
- .await
- {
- Ok(predecessor) => predecessor,
- Err(error) => {
- tracing::warn!(
- session_id,
- %error,
- "failed to dispose root-owned page session runtime state"
- );
- continue;
- }
- };
+ {
+ Ok(predecessor) => predecessor,
+ Err(error) => {
+ tracing::warn!(
+ session_id,
+ %error,
+ "failed to dispose root-owned page session runtime state"
+ );
+ continue;
+ }
+ };
if let Some(predecessor) = predecessor {
command_context.set_renderer_output_predecessor(predecessor);
}
- if !conn.release_primary_target_session_binding_without_event(&session_id) {
- conn.rollback_auto_attached_session_detach_plan_without_event(&detach_plan);
- }
}
}
@@ -1045,43 +1065,27 @@ async fn detach_attached_session_for_owner_async(
command_context: &mut crate::conn::CommandDispatchContext,
) {
if conn.is_browser_session_id(Some(session_id)) {
- conn.cancel_tracing_for_session_owner_async(Some(session_id))
- .await;
- let detached = conn.detach_browser_session_owner_without_event(session_id);
- debug_assert!(detached.is_some());
+ if let Err(error) =
+ super::session_disposal::dispose_browser_session_without_event_async(conn, session_id)
+ .await
+ {
+ tracing::warn!(
+ session_id,
+ %error,
+ "failed to dispose auto-attached browser session"
+ );
+ }
return;
}
let detach_plan = conn.auto_attached_session_detach_plan(session_id);
- let Some(browser_context_id) = detach_plan.browser_context_id().map(str::to_owned) else {
+ let Some(cleanup_plan) = detach_plan.cleanup_plan() else {
conn.rollback_auto_attached_session_detach_plan_without_event(&detach_plan);
return;
};
- if !conn
- .activate_browser_context_by_id_async(&browser_context_id)
- .await
- {
+ let Some(target_id) = cleanup_plan.target_id().map(str::to_owned) else {
+ debug_assert!(false, "browser sessions use the browser disposal path");
conn.rollback_auto_attached_session_detach_plan_without_event(&detach_plan);
return;
- }
-
- let Some(cleanup_plan) = detach_plan.cleanup_plan() else {
- conn.rollback_auto_attached_session_detach_plan_without_event(&detach_plan);
- return;
- };
- let target_id = match cleanup_plan.action() {
- crate::conn::TargetBindingCleanupAction::PageTarget { target_id, .. }
- | crate::conn::TargetBindingCleanupAction::SharedWorkerTarget { target_id }
- | crate::conn::TargetBindingCleanupAction::DedicatedWorkerTarget { target_id }
- | crate::conn::TargetBindingCleanupAction::ServiceWorkerTarget { target_id } => {
- target_id.clone()
- }
- crate::conn::TargetBindingCleanupAction::TabTarget { tab_target_id } => {
- tab_target_id.clone()
- }
- crate::conn::TargetBindingCleanupAction::None => {
- conn.rollback_auto_attached_session_detach_plan_without_event(&detach_plan);
- return;
- }
};
match super::session_disposal::dispose_target_session_async(
conn,
@@ -1110,18 +1114,15 @@ async fn detach_attached_session_for_owner_async(
async fn ensure_initial_document_for_attached_page_targets_async(
conn: &mut CdpConnection,
- attached_targets: &[(String, String)],
+ attached_targets: &[(String, String, CdpSessionRoute)],
) {
- for (target_id, _session_id) in attached_targets {
+ for (target_id, _session_id, route) in attached_targets {
if !conn.browser_contexts().any(|browser_context| {
browser_context.target_has_pending_initial_document_page_build(target_id)
}) {
continue;
}
- let Some(route) = conn.target_session_route_for_target_id(target_id) else {
- continue;
- };
- let owner = crate::conn::CommandOwnerScope::for_route(route);
+ let owner = CommandOwnerScope::for_route(route.clone());
let pending = match conn.start_initial_document_page_ensure_for_owner(&owner) {
Ok(pending) => pending,
Err(message) => {
diff --git a/moli-protocol/src/domains/target/browser_context_disposal.rs b/moli-protocol/src/domains/target/browser_context_disposal.rs
index 147f37352..de1366324 100644
--- a/moli-protocol/src/domains/target/browser_context_disposal.rs
+++ b/moli-protocol/src/domains/target/browser_context_disposal.rs
@@ -282,14 +282,22 @@ async fn close_page_target(
out.extend_background_events(
conn.prepared_target_host_deltas_event_plan(target_detached_info_deltas),
);
- out.extend_background_events(conn.detach_target_closure_cleanup_event_plan(
- closed.into_detach_cleanup_plan(Some(INSPECTOR_DETACHED_REASON)),
- None,
- ));
- out.extend_background_events(conn.detach_closed_top_level_target_sessions_event_plan(
+ out.extend_background_events(
+ conn.dispose_target_closure_sessions_event_plan_async(
+ closed.into_detach_cleanup_plan(Some(INSPECTOR_DETACHED_REASON)),
+ None,
+ )
+ .await,
+ );
+ if let Some(tab_cleanup) = conn.take_closed_top_level_target_sessions_cleanup_plan(
&target_id,
Some(INSPECTOR_DETACHED_REASON),
- ));
+ ) {
+ out.extend_background_events(
+ conn.dispose_target_closure_sessions_event_plan_async(tab_cleanup, None)
+ .await,
+ );
+ }
out.extend_background_events(
conn.prepared_target_host_deltas_event_plan(target_destroyed_deltas),
);
diff --git a/moli-protocol/src/domains/target/closing.rs b/moli-protocol/src/domains/target/closing.rs
index 545e680a3..cdc911548 100644
--- a/moli-protocol/src/domains/target/closing.rs
+++ b/moli-protocol/src/domains/target/closing.rs
@@ -85,7 +85,7 @@ pub(super) async fn execute_devtools_close_target_command_async(
crate::DEFAULT_CDP_PAGE_TARGET_ID | crate::DEFAULT_CDP_TAB_TARGET_ID
);
let target_id = command.target_id.into_string();
- if let Some(plan) = conn.close_default_target_placeholder(&target_id) {
+ if let Some(plan) = conn.close_default_target_placeholder(&target_id).await {
out.extend_background_events(plan.into_background_events());
return Ok(DevToolsCloseTargetResult { success: true });
}
diff --git a/moli-protocol/src/domains/target/creation.rs b/moli-protocol/src/domains/target/creation.rs
index 0675eefcc..3efa8a0d8 100644
--- a/moli-protocol/src/domains/target/creation.rs
+++ b/moli-protocol/src/domains/target/creation.rs
@@ -1,6 +1,8 @@
use serde::Deserialize;
-use crate::conn::{PreparedTargetAttach, TargetActivationTransition, TargetAttachSessionCommit};
+use crate::conn::{
+ CdpSessionRoute, PreparedTargetAttach, TargetActivationTransition, TargetAttachSessionCommit,
+};
use crate::devtools_runtime::{
DevToolsBrowserContextId, DevToolsCreateTargetResult, DevToolsTargetId,
};
@@ -279,6 +281,12 @@ pub(super) fn execute_devtools_create_target_command(
return Err(error);
}
conn.ensure_browser_context_for_implicit_target_creation();
+ let browser_context_id = conn
+ .browser_context
+ .as_ref()
+ .expect("browser context must exist before target creation")
+ .id
+ .clone();
let target_id = conn.gen_target_id();
let default_target_id = conn.default_target_id();
@@ -367,15 +375,16 @@ pub(super) fn execute_devtools_create_target_command(
for (owner_session_id, session_id) in &auto_attached_tab_sessions {
let waiting_for_debugger =
conn.auto_attach_owner_waits_for_debugger_on_start(owner_session_id.as_deref());
- let assigned = conn.prepare_auto_attached_tab_session_binding(
+ let route = conn.prepare_auto_attached_tab_session_binding(
&tab_target_id,
session_id.clone(),
owner_session_id.as_deref(),
);
- debug_assert!(assigned, "created tab target must remain addressable");
- attached_tab_sessions.push(conn.prepare_auto_attach_session_commit(
+ let route = route.expect("created tab target must remain addressable");
+ attached_tab_sessions.push(TargetAttachSessionCommit::auto_attached(
session_id.clone(),
owner_session_id.clone(),
+ route,
waiting_for_debugger,
));
}
@@ -384,25 +393,22 @@ pub(super) fn execute_devtools_create_target_command(
for (index, (owner_session_id, session_id)) in auto_attached_page_sessions.iter().enumerate() {
let waiting_for_debugger =
conn.auto_attach_owner_waits_for_debugger_on_start(owner_session_id.as_deref());
- if creating_background_target && index == 0 {
- attached_sessions.push(conn.prepare_auto_attach_session_commit(
- session_id.clone(),
- owner_session_id.clone(),
- waiting_for_debugger,
- ));
+ let route = if creating_background_target && index == 0 {
+ CdpSessionRoute::PageTarget {
+ browser_context_id: browser_context_id.clone(),
+ target_id: target_id.clone(),
+ session_key: moli_page_types::DevToolsSessionKey::Primary,
+ }
} else {
- let assigned =
- conn.prepare_auto_attached_page_session_binding(&target_id, session_id.clone());
- debug_assert!(
- assigned,
- "newly created target must remain addressable for auto attach"
- );
- attached_sessions.push(conn.prepare_auto_attach_session_commit(
- session_id.clone(),
- owner_session_id.clone(),
- waiting_for_debugger,
- ));
- }
+ conn.prepare_auto_attached_page_session_binding(&target_id, session_id.clone())
+ .expect("newly created target must remain addressable for auto attach")
+ };
+ attached_sessions.push(TargetAttachSessionCommit::auto_attached(
+ session_id.clone(),
+ owner_session_id.clone(),
+ route,
+ waiting_for_debugger,
+ ));
}
if activating_created_target {
conn.apply_active_engine_fetch_overrides();
diff --git a/moli-protocol/src/domains/target/popup.rs b/moli-protocol/src/domains/target/popup.rs
index 78341e171..d13082961 100644
--- a/moli-protocol/src/domains/target/popup.rs
+++ b/moli-protocol/src/domains/target/popup.rs
@@ -1,6 +1,6 @@
use crate::conn::{
- CommandOwnerScope, PopupTargetActivationAction, PopupTargetNavigationKind,
- PopupTargetNavigationOwnerAction, PreparedTargetAttach,
+ CdpSessionRoute, CommandOwnerScope, PopupTargetActivationAction, PopupTargetNavigationKind,
+ PopupTargetNavigationOwnerAction, PreparedTargetAttach, TargetAttachSessionCommit,
};
use super::creation::{
@@ -148,7 +148,7 @@ pub(crate) async fn create_popup_target_from_renderer_output_background_events_a
// The renderer has already accepted an auxiliary-context action. Even when
// noopener blocks script access, Chromium preserves the creator target and
- // frame as DevTools attribution for the new auxiliary target.
+ // frame as DevTools attribution for the new popup Page target.
let opener = opener.filter(|opener| {
conn.browser_context_by_id(&browser_context_id)
.and_then(|browser_context| browser_context.devtools_target_info(&opener.target_id))
@@ -205,27 +205,39 @@ pub(crate) async fn create_popup_target_from_renderer_output_background_events_a
}
let tab_target_id = conn.register_top_level_page_target(&target_id);
- for (owner_session_id, session_id) in &auto_attached_tab_sessions {
- let assigned = conn.prepare_auto_attached_tab_session_binding(
- &tab_target_id,
- session_id.clone(),
- owner_session_id.as_deref(),
- );
- assert!(assigned, "created popup tab target must remain addressable");
- }
- for (index, (_, session_id)) in auto_attached_page_sessions.iter().enumerate() {
- if index != 0 || auto_attached_background_session_id.is_none() {
- let assigned = conn.prepare_auto_attached_page_session_binding_in_browser_context(
- &browser_context_id,
- &target_id,
+ let auto_attached_tab_sessions = auto_attached_tab_sessions
+ .into_iter()
+ .map(|(owner_session_id, session_id)| {
+ let route = conn.prepare_auto_attached_tab_session_binding(
+ &tab_target_id,
session_id.clone(),
+ owner_session_id.as_deref(),
);
- assert!(
- assigned,
- "newly created popup target must remain addressable"
- );
- }
- }
+ let route = route.expect("created popup tab target must remain addressable");
+ (owner_session_id, session_id, route)
+ })
+ .collect::<Vec<_>>();
+ let auto_attached_page_sessions = auto_attached_page_sessions
+ .into_iter()
+ .enumerate()
+ .map(|(index, (owner_session_id, session_id))| {
+ let route = if index == 0 && auto_attached_background_session_id.is_some() {
+ CdpSessionRoute::PageTarget {
+ browser_context_id: browser_context_id.clone(),
+ target_id: target_id.clone(),
+ session_key: moli_page_types::DevToolsSessionKey::Primary,
+ }
+ } else {
+ conn.prepare_auto_attached_page_session_binding_in_browser_context(
+ &browser_context_id,
+ &target_id,
+ session_id.clone(),
+ )
+ .expect("newly created popup target must remain addressable")
+ };
+ (owner_session_id, session_id, route)
+ })
+ .collect::<Vec<_>>();
if !ensure_popup_initial_document_page_async(conn, &target_id).await {
rollback_incomplete_popup_target_async(conn, Some(&browser_context_id), &target_id).await;
@@ -358,16 +370,17 @@ async fn ensure_popup_initial_document_page_async(
fn push_committed_auto_attached_session_events(
conn: &mut CdpConnection,
out: &mut impl events::CdpTargetAutomationEventSink,
- sessions: &[(Option<String>, String)],
+ sessions: &[(Option<String>, String, CdpSessionRoute)],
target_id: &str,
target_info: DevToolsTargetInfo,
) {
let sessions = sessions
.iter()
- .map(|(owner_session_id, session_id)| {
- conn.prepare_auto_attach_session_commit(
+ .map(|(owner_session_id, session_id, route)| {
+ TargetAttachSessionCommit::auto_attached(
session_id.clone(),
owner_session_id.clone(),
+ route.clone(),
conn.auto_attach_owner_waits_for_debugger_on_start(owner_session_id.as_deref()),
)
})
diff --git a/moli-protocol/src/domains/target/session_disposal.rs b/moli-protocol/src/domains/target/session_disposal.rs
index 557938284..28c45e179 100644
--- a/moli-protocol/src/domains/target/session_disposal.rs
+++ b/moli-protocol/src/domains/target/session_disposal.rs
@@ -1,8 +1,41 @@
use crate::conn::{
- BackgroundProtocolEvent, CdpConnection, TargetBindingCleanupAction, TargetBindingCleanupPlan,
- TargetEventPlan, TargetSessionDetachCleanupPlan,
+ BackgroundProtocolEvent, CdpConnection, CdpSessionRoute, CommandOwnerScope,
+ SessionDisposalPlan, SessionDisposalTarget, TargetEventPlan, TargetSessionDetachCleanupPlan,
};
+fn prepare_session_disposal(
+ conn: &CdpConnection,
+ detachment: TargetSessionDetachCleanupPlan,
+) -> anyhow::Result<(SessionDisposalPlan, TargetSessionDetachCleanupPlan)> {
+ let session_id = detachment.session_id();
+ let route = conn
+ .session_route(Some(session_id))
+ .ok_or_else(|| anyhow::anyhow!("InvalidSessionId"))?;
+ let plan = SessionDisposalPlan::for_session_route(session_id, &route)
+ .ok_or_else(|| anyhow::anyhow!("InvalidSessionId"))?;
+ anyhow::ensure!(
+ plan.target_id() == Some(detachment.target_id()),
+ "UnknownTargetId"
+ );
+ Ok((plan, detachment))
+}
+
+fn prepare_browser_session_disposal(
+ conn: &CdpConnection,
+ session_id: &str,
+) -> anyhow::Result<SessionDisposalPlan> {
+ let route = conn
+ .session_route(Some(session_id))
+ .ok_or_else(|| anyhow::anyhow!("InvalidSessionId"))?;
+ let plan = SessionDisposalPlan::for_session_route(session_id, &route)
+ .ok_or_else(|| anyhow::anyhow!("InvalidSessionId"))?;
+ anyhow::ensure!(
+ matches!(plan.target(), SessionDisposalTarget::Browser),
+ "InvalidSessionId"
+ );
+ Ok(plan)
+}
+
pub(super) struct TargetSessionDisposalOutcome {
event_plan: TargetEventPlan,
renderer_output_predecessor: Option<moli_core::RendererOutputFence>,
@@ -14,164 +47,390 @@ impl TargetSessionDisposalOutcome {
}
}
-pub(super) async fn dispose_target_session_async(
+/// Runs every domain handler's disposal while `plan` still resolves to a live
+/// session. All handlers get a cleanup opportunity even if one fails. A Page
+/// whose renderer remains alive after such a failure is failed closed before
+/// the binding can be removed, because otherwise renderer-owned scripts or
+/// policy could outlive their DevTools session.
+async fn dispose_live_session_domains_async(
conn: &mut CdpConnection,
background_events: &mut Vec<BackgroundProtocolEvent>,
protocol_events: &mut Vec<BackgroundProtocolEvent>,
- cleanup_plan: TargetSessionDetachCleanupPlan,
-) -> anyhow::Result<TargetSessionDisposalOutcome> {
- let session_id = cleanup_plan.session_id().to_owned();
- let route = conn
- .session_route(Some(&session_id))
- .ok_or_else(|| anyhow::anyhow!("InvalidSessionId"))?;
- let binding_plan = TargetBindingCleanupPlan::from_route(&session_id, &route);
- let expected_target_id = cleanup_plan.target_id();
- let action_target_id = match binding_plan.action() {
- TargetBindingCleanupAction::None => None,
- TargetBindingCleanupAction::PageTarget { target_id, .. }
- | TargetBindingCleanupAction::SharedWorkerTarget { target_id }
- | TargetBindingCleanupAction::DedicatedWorkerTarget { target_id }
- | TargetBindingCleanupAction::ServiceWorkerTarget { target_id } => Some(target_id.as_str()),
- TargetBindingCleanupAction::TabTarget { tab_target_id } => Some(tab_target_id.as_str()),
- };
- if action_target_id.is_some_and(|target_id| target_id != expected_target_id) {
- anyhow::bail!("UnknownTargetId");
- }
+ plan: &SessionDisposalPlan,
+) -> anyhow::Result<Option<moli_core::RendererOutputFence>> {
+ let session_id = plan.session_id();
+ dispose_connection_session_domains_async(conn, session_id).await;
- let mut renderer_output_predecessor = None;
- match binding_plan.action() {
- TargetBindingCleanupAction::PageTarget { .. } => {
- renderer_output_predecessor = dispose_page_session_runtime_state_async(
+ match plan.target() {
+ SessionDisposalTarget::PageTarget { .. } => {
+ let mut first_error = None;
+ let predecessor = match Box::pin(crate::domains::fetch::dispose_session_async(
conn,
background_events,
- protocol_events,
- &session_id,
- )
- .await?;
- }
- TargetBindingCleanupAction::SharedWorkerTarget { target_id } => {
- let renderer_detach = conn.browser_context.as_ref().and_then(|browser_context| {
- browser_context
- .shared_worker_target(target_id)
- .map(|target| {
- (
- browser_context.renderer_runtime(),
- target.renderer_instance_id,
- )
- })
- });
- conn.release_shared_worker_runtime_remote_objects_for_session_best_effort_async(
- &session_id,
- )
- .await;
- conn.fail_pending_inspector_awaits_for_session_owner_background_events_into(
+ session_id,
+ ))
+ .await
+ {
+ Ok(predecessor) => predecessor,
+ Err(error) => {
+ record_session_cleanup_error(&mut first_error, session_id, "Fetch", error);
+ None
+ }
+ };
+ crate::domains::runtime::fail_pending_session_calls(
+ conn,
background_events,
protocol_events,
- Some(&session_id),
- "Target detached",
+ session_id,
);
- if let Some((renderer_runtime, instance_id)) = renderer_detach {
- renderer_runtime.detach_shared_worker_runtime_inspector_session(
- instance_id,
- Some(session_id.clone()),
- );
- }
- }
- TargetBindingCleanupAction::DedicatedWorkerTarget { target_id } => {
- let renderer_detach = conn.browser_context.as_ref().and_then(|browser_context| {
- browser_context
- .dedicated_worker_target(target_id)
- .map(|target| {
- (
- browser_context.renderer_runtime(),
- target.renderer_instance_id,
- )
- })
- });
- conn.release_shared_worker_runtime_remote_objects_for_session_best_effort_async(
- &session_id,
- )
- .await;
- conn.fail_pending_inspector_awaits_for_session_owner_background_events_into(
- background_events,
- protocol_events,
- Some(&session_id),
- "Target detached",
+
+ // Document-start scripts are renderer-owned resources. Remove
+ // them before detaching the Inspector endpoint that carries the
+ // cleanup commands.
+ record_session_cleanup_result(
+ &mut first_error,
+ session_id,
+ "Page",
+ crate::domains::page::dispose_session_async(conn, session_id).await,
+ );
+ record_session_cleanup_result(
+ &mut first_error,
+ session_id,
+ "Emulation",
+ crate::domains::emulation::dispose_page_session_async(conn, session_id).await,
);
- if let Some((renderer_runtime, instance_id)) = renderer_detach {
- renderer_runtime.detach_dedicated_worker_runtime_inspector_session(
- instance_id,
- Some(session_id.clone()),
+ record_session_cleanup_result(
+ &mut first_error,
+ session_id,
+ "Network",
+ crate::domains::network::dispose_session_policy_async(conn, session_id).await,
+ );
+ if let SessionDisposalTarget::PageTarget {
+ browser_context_id,
+ target_id,
+ session_key: moli_page_types::DevToolsSessionKey::Primary,
+ } = plan.target()
+ {
+ let reset_result = match conn.browser_context_by_id_mut(browser_context_id) {
+ Some(browser_context) => {
+ browser_context
+ .reset_primary_page_session_target_state_async(target_id, session_id)
+ .await
+ }
+ None => Ok(false),
+ };
+ record_session_cleanup_result(
+ &mut first_error,
+ session_id,
+ "primary Page target",
+ reset_result.and_then(|found| {
+ anyhow::ensure!(
+ found,
+ "primary Page target disappeared during session disposal"
+ );
+ Ok(())
+ }),
);
}
+ if let Some(error) = first_error {
+ recover_failed_page_session_disposal_async(conn, background_events, plan, &error)
+ .await?;
+ }
+ crate::domains::runtime::detach_page_session_inspector_async(conn, session_id).await;
+ Ok(predecessor)
}
- TargetBindingCleanupAction::ServiceWorkerTarget { .. } => {
- conn.fail_pending_inspector_awaits_for_session_owner_background_events_into(
+ SessionDisposalTarget::SharedWorkerTarget { .. }
+ | SessionDisposalTarget::DedicatedWorkerTarget { .. }
+ | SessionDisposalTarget::ServiceWorkerTarget { .. } => {
+ crate::domains::runtime::dispose_worker_session_async(
+ conn,
background_events,
protocol_events,
- Some(&session_id),
- "Target detached",
- );
- super::set_service_worker_pause_on_start_owner(conn, Some(&session_id), false);
+ plan,
+ )
+ .await?;
+ Ok(None)
}
- TargetBindingCleanupAction::TabTarget { .. } => {}
- TargetBindingCleanupAction::None => anyhow::bail!("InvalidSessionId"),
+ SessionDisposalTarget::Browser | SessionDisposalTarget::TabTarget { .. } => Ok(None),
+ }
+}
+
+fn record_session_cleanup_result(
+ first_error: &mut Option<anyhow::Error>,
+ session_id: &str,
+ domain: &'static str,
+ result: anyhow::Result<()>,
+) {
+ if let Err(error) = result {
+ record_session_cleanup_error(first_error, session_id, domain, error);
}
+}
+
+fn record_session_cleanup_error(
+ first_error: &mut Option<anyhow::Error>,
+ session_id: &str,
+ domain: &'static str,
+ error: anyhow::Error,
+) {
+ tracing::warn!(
+ session_id,
+ domain,
+ %error,
+ "failed to dispose DevTools session domain"
+ );
+ first_error
+ .get_or_insert_with(|| anyhow::anyhow!("failed to dispose {domain} domain: {error:#}"));
+}
+
+async fn recover_failed_page_session_disposal_async(
+ conn: &mut CdpConnection,
+ background_events: &mut Vec<BackgroundProtocolEvent>,
+ plan: &SessionDisposalPlan,
+ cleanup_error: &anyhow::Error,
+) -> anyhow::Result<()> {
+ let SessionDisposalTarget::PageTarget {
+ browser_context_id,
+ target_id,
+ session_key,
+ } = plan.target()
+ else {
+ anyhow::bail!("Page cleanup recovery requires a Page target");
+ };
+ let owner = CommandOwnerScope::for_route(CdpSessionRoute::PageTarget {
+ browser_context_id: browser_context_id.clone(),
+ target_id: target_id.clone(),
+ session_key: session_key.clone(),
+ });
+ let has_live_page = conn
+ .runtime_session_owner_slot_for_owner(&owner)
+ .ok()
+ .is_some_and(|slot| slot.loaded_page().is_some());
+
+ if has_live_page {
+ let inspector_session_ids = conn.page_event_session_ids_for_owner(&owner);
+ for inspector_session_id in &inspector_session_ids {
+ let inspector_owner = inspector_session_id
+ .as_deref()
+ .map(CommandOwnerScope::for_session)
+ .unwrap_or_else(|| owner.clone());
+ let _ =
+ conn.with_target_devtools_session_state_for_owner_mut(&inspector_owner, |state| {
+ state
+ .runtime_session_state
+ .record_inspector_target_crashed()
+ });
+ }
+ anyhow::ensure!(
+ conn.mark_target_crashed_for_owner_async(&owner)
+ .await
+ .is_some(),
+ "failed to close Page after session cleanup failure: {cleanup_error:#}"
+ );
+ background_events.extend(inspector_session_ids.into_iter().map(|session_id| {
+ BackgroundProtocolEvent::inspector_target_crashed(session_id.as_deref())
+ }));
+ background_events
+ .extend(conn.target_crashed_events_for_all_discovery_owners(target_id, "crashed", 1));
+ }
+
+ // Once no renderer Page remains, protocol-side ownership records can be
+ // discarded without leaving executable renderer state behind.
+ crate::domains::page::dispose_session_async(conn, plan.session_id())
+ .await
+ .map_err(|error| {
+ anyhow::anyhow!(
+ "failed to finalize Page cleanup after renderer retirement: {error:#}; original cleanup failure: {cleanup_error:#}"
+ )
+ })?;
+ tracing::warn!(
+ session_id = plan.session_id(),
+ target_id,
+ %cleanup_error,
+ "retired Page renderer after DevTools session cleanup failure"
+ );
+ Ok(())
+}
+
+async fn dispose_connection_session_domains_async(conn: &mut CdpConnection, session_id: &str) {
+ // Tracing may own isolate tasks that must finish before another session
+ // can start a trace.
+ conn.cancel_tracing_for_session_owner_async(Some(session_id))
+ .await;
+ dispose_connection_session_domains_sync(conn, session_id);
+}
+
+fn dispose_connection_session_domains_sync(conn: &mut CdpConnection, session_id: &str) {
+ conn.cancel_tracing_for_session_owner(Some(session_id));
+ conn.download_behavior
+ .set_browser_events_enabled_for_session(Some(session_id), false);
+ conn.clear_auto_attach_owner(Some(session_id));
+ conn.clear_target_discovery_for_owner(Some(session_id));
+ super::set_service_worker_pause_on_start_owner(conn, Some(session_id), false);
+ super::set_dedicated_worker_pause_on_start_owner(conn, Some(session_id), false);
+}
+
+pub(super) async fn dispose_browser_session_without_event_async(
+ conn: &mut CdpConnection,
+ session_id: &str,
+) -> anyhow::Result<TargetEventPlan> {
+ let plan = prepare_browser_session_disposal(conn, session_id)?;
+ let mut discarded_background_events = Vec::new();
+ let mut discarded_protocol_events = Vec::new();
+ dispose_live_session_domains_async(
+ conn,
+ &mut discarded_background_events,
+ &mut discarded_protocol_events,
+ &plan,
+ )
+ .await?;
+ conn.commit_browser_session_disposal_without_event(&plan)
+}
+
+pub(super) async fn dispose_browser_session_event_plan_async(
+ conn: &mut CdpConnection,
+ session_id: &str,
+) -> anyhow::Result<TargetEventPlan> {
+ let plan = prepare_browser_session_disposal(conn, session_id)?;
+ let mut discarded_background_events = Vec::new();
+ let mut discarded_protocol_events = Vec::new();
+ dispose_live_session_domains_async(
+ conn,
+ &mut discarded_background_events,
+ &mut discarded_protocol_events,
+ &plan,
+ )
+ .await?;
+ conn.commit_browser_session_disposal_event_plan(&plan)
+}
+
+/// Runs the connection-owned portion of domain disposal after a target has
+/// already destroyed its renderer-owned state but before its session binding
+/// is removed from the control plane.
+pub(crate) async fn dispose_closed_session_domains_async(
+ conn: &mut CdpConnection,
+ plan: &SessionDisposalPlan,
+) {
+ dispose_connection_session_domains_async(conn, plan.session_id()).await;
+}
+
+/// Rolls back a prepared attachment after it has become capable of owning
+/// renderer/domain state but before its attached event is published. No
+/// protocol event is emitted because the frontend never observed the session.
+pub(crate) async fn dispose_uncommitted_session_async(
+ conn: &mut CdpConnection,
+ plan: &SessionDisposalPlan,
+) -> anyhow::Result<()> {
+ let mut discarded_background_events = Vec::new();
+ let mut discarded_protocol_events = Vec::new();
+ dispose_live_session_domains_async(
+ conn,
+ &mut discarded_background_events,
+ &mut discarded_protocol_events,
+ plan,
+ )
+ .await?;
+ conn.commit_session_disposal(plan)
+}
+
+pub(super) async fn dispose_target_session_async(
+ conn: &mut CdpConnection,
+ background_events: &mut Vec<BackgroundProtocolEvent>,
+ protocol_events: &mut Vec<BackgroundProtocolEvent>,
+ cleanup_plan: TargetSessionDetachCleanupPlan,
+) -> anyhow::Result<TargetSessionDisposalOutcome> {
+ let (plan, detachment) = prepare_session_disposal(conn, cleanup_plan)?;
+ let renderer_output_predecessor =
+ dispose_live_session_domains_async(conn, background_events, protocol_events, &plan).await?;
- let event_plan = conn
- .detach_session_with_binding_cleanup_event_plan_async(cleanup_plan)
- .await?;
+ conn.commit_session_disposal(&plan)?;
+ let event_plan = conn.commit_target_session_detachment_event_plan(detachment);
Ok(TargetSessionDisposalOutcome {
event_plan,
renderer_output_predecessor,
})
}
-pub(super) async fn dispose_page_session_runtime_state_async(
+pub(super) async fn dispose_primary_page_session_preserving_frontend_async(
conn: &mut CdpConnection,
background_events: &mut Vec<BackgroundProtocolEvent>,
protocol_events: &mut Vec<BackgroundProtocolEvent>,
session_id: &str,
) -> anyhow::Result<Option<moli_core::RendererOutputFence>> {
- let renderer_output_predecessor =
- super::clear_detached_target_fetch_state_background_events_async(
- conn,
- background_events,
- session_id,
- )
- .await;
- conn.fail_pending_inspector_awaits_for_session_owner_background_events_into(
- background_events,
- protocol_events,
- Some(session_id),
- "Target detached",
- );
+ let route = conn
+ .session_route(Some(session_id))
+ .ok_or_else(|| anyhow::anyhow!("InvalidSessionId"))?;
+ let plan = SessionDisposalPlan::for_session_route(session_id, &route)
+ .ok_or_else(|| anyhow::anyhow!("InvalidSessionId"))?;
+ if !matches!(
+ plan.target(),
+ SessionDisposalTarget::PageTarget {
+ session_key: moli_page_types::DevToolsSessionKey::Primary,
+ ..
+ }
+ ) {
+ anyhow::bail!("InvalidSessionId");
+ }
- // Document-start scripts are renderer-owned resources. Remove them before
- // detaching the Inspector session that carries the cleanup commands.
- conn.remove_document_start_scripts_for_detached_session_async(session_id)
- .await?;
- clear_page_session_target_state_async(conn, session_id).await?;
- if let Err(error) = conn
- .detach_runtime_inspector_session_for_session_owner_async(Some(session_id))
- .await
- {
- tracing::debug!(
- session_id,
- %error,
- "renderer Inspector session was already unavailable during disposal"
- );
+ let predecessor =
+ dispose_live_session_domains_async(conn, background_events, protocol_events, &plan).await?;
+ if !conn.release_primary_target_session_binding_without_event(session_id) {
+ anyhow::bail!("InvalidSessionId");
}
- Ok(renderer_output_predecessor)
+ Ok(predecessor)
}
-async fn clear_page_session_target_state_async(
+pub(super) async fn dispose_dedicated_worker_session_after_prepared_state_delta_async(
conn: &mut CdpConnection,
- session_id: &str,
-) -> anyhow::Result<()> {
- crate::domains::emulation::clear_emulated_media_for_detached_session_async(conn, session_id)
- .await?;
- conn.clear_target_session_overrides_async(session_id)
- .await?;
- Ok(())
+ background_events: &mut Vec<BackgroundProtocolEvent>,
+ protocol_events: &mut Vec<BackgroundProtocolEvent>,
+ cleanup_plan: TargetSessionDetachCleanupPlan,
+) -> anyhow::Result<TargetSessionDisposalOutcome> {
+ let (plan, detachment) = prepare_session_disposal(conn, cleanup_plan)?;
+ if !matches!(
+ plan.target(),
+ SessionDisposalTarget::DedicatedWorkerTarget { .. }
+ ) {
+ anyhow::bail!("InvalidSessionId");
+ }
+
+ dispose_live_session_domains_async(conn, background_events, protocol_events, &plan).await?;
+ conn.commit_session_disposal(&plan)?;
+ let event_plan =
+ conn.commit_target_session_detachment_after_prepared_state_delta_event_plan(detachment);
+ Ok(TargetSessionDisposalOutcome {
+ event_plan,
+ renderer_output_predecessor: None,
+ })
+}
+
+/// Completes disposal after a worker target has transferred and dropped its
+/// per-session state. Renderer-owned resources have already gone away with
+/// the target, but connection-owned handlers still retire before the control
+/// plane binding is removed.
+pub(super) async fn dispose_removed_worker_session_async(
+ conn: &mut CdpConnection,
+ cleanup_plan: TargetSessionDetachCleanupPlan,
+) -> anyhow::Result<TargetEventPlan> {
+ let (plan, detachment) = prepare_session_disposal(conn, cleanup_plan)?;
+ if !matches!(
+ plan.target(),
+ SessionDisposalTarget::SharedWorkerTarget { .. }
+ | SessionDisposalTarget::DedicatedWorkerTarget { .. }
+ | SessionDisposalTarget::ServiceWorkerTarget { .. }
+ ) {
+ anyhow::bail!("InvalidSessionId");
+ }
+ dispose_closed_session_domains_async(conn, &plan).await;
+ Ok(conn.commit_target_session_detachment_event_plan(detachment))
+}
+
+/// Emergency completion for a DedicatedWorker retirement whose renderer
+/// output failed after the target state was already removed. The renderer is
+/// unavailable, so only connection and control-plane ownership remain.
+pub(super) fn dispose_removed_dedicated_worker_session_after_failed_retirement(
+ conn: &mut CdpConnection,
+ cleanup_plan: TargetSessionDetachCleanupPlan,
+) -> TargetEventPlan {
+ dispose_connection_session_domains_sync(conn, cleanup_plan.session_id());
+ conn.commit_target_session_detachment_after_prepared_state_delta_event_plan(cleanup_plan)
}
diff --git a/moli-protocol/src/domains/target/tests/test_support.rs b/moli-protocol/src/domains/target/tests/test_support.rs
index fd51048b7..c6a22378e 100644
--- a/moli-protocol/src/domains/target/tests/test_support.rs
+++ b/moli-protocol/src/domains/target/tests/test_support.rs
@@ -27,21 +27,26 @@ pub(super) fn push_background_target(
url: &str,
session_id: Option<&str>,
) {
- let bc = ctx
- .conn
- .browser_context
- .as_mut()
- .expect("browser context must exist before adding background target");
- bc.insert_page_target_host(crate::conn::PageTargetHost::new(
- target_id.to_owned(),
- session_id.map(str::to_owned),
- crate::conn::TargetIdentityState::new(
- url.to_owned(),
- crate::conn::URL_BASE.into(),
- "Secure".into(),
- ),
- crate::conn::TargetPageSlot::empty_for_test_fixture(),
- ));
+ {
+ let bc = ctx
+ .conn
+ .browser_context
+ .as_mut()
+ .expect("browser context must exist before adding background target");
+ bc.insert_page_target_host(crate::conn::PageTargetHost::new(
+ target_id.to_owned(),
+ session_id.map(str::to_owned),
+ crate::conn::TargetIdentityState::new(
+ url.to_owned(),
+ crate::conn::URL_BASE.into(),
+ "Secure".into(),
+ ),
+ crate::conn::TargetPageSlot::empty_for_test_fixture(),
+ ));
+ }
+ if let Some(session_id) = session_id {
+ ctx.conn.register_bound_session_for_test(session_id);
+ }
}
pub(super) fn loaded_page_for_target<'a>(
@@ -65,23 +70,28 @@ pub(super) fn push_shared_worker_target(
name: &str,
session_id: Option<&str>,
) {
- let bc = ctx
- .conn
- .browser_context
- .as_mut()
- .expect("browser context must exist before adding shared worker target");
- let mut target = crate::conn::SharedWorkerTargetState::new(
- moli_core::RendererOwnerLocalHostId::new_for_testing(1),
- renderer_instance_id,
- target_id.to_owned(),
- None,
- url.to_owned(),
- name.to_owned(),
- );
+ {
+ let bc = ctx
+ .conn
+ .browser_context
+ .as_mut()
+ .expect("browser context must exist before adding shared worker target");
+ let mut target = crate::conn::SharedWorkerTargetState::new(
+ moli_core::RendererOwnerLocalHostId::new_for_testing(1),
+ renderer_instance_id,
+ target_id.to_owned(),
+ None,
+ url.to_owned(),
+ name.to_owned(),
+ );
+ if let Some(session_id) = session_id {
+ target.attach_session(session_id.to_owned());
+ }
+ bc.insert_shared_worker_target(target);
+ }
if let Some(session_id) = session_id {
- target.attach_session(session_id.to_owned());
+ ctx.conn.register_bound_session_for_test(session_id);
}
- bc.insert_shared_worker_target(target);
}
pub(super) fn push_service_worker_target(
@@ -92,23 +102,28 @@ pub(super) fn push_service_worker_target(
scope_url: &str,
session_id: Option<&str>,
) {
- let bc = ctx
- .conn
- .browser_context
- .as_mut()
- .expect("browser context must exist before adding service worker target");
- let target = crate::conn::ServiceWorkerTargetState::new(
- 1,
- renderer_version_id,
- target_id.to_owned(),
- script_url.to_owned(),
- scope_url.to_owned(),
- RendererServiceWorkerVersionStatus::Activated,
- None,
- );
- bc.insert_service_worker_target(target);
+ {
+ let bc = ctx
+ .conn
+ .browser_context
+ .as_mut()
+ .expect("browser context must exist before adding service worker target");
+ let target = crate::conn::ServiceWorkerTargetState::new(
+ 1,
+ renderer_version_id,
+ target_id.to_owned(),
+ script_url.to_owned(),
+ scope_url.to_owned(),
+ RendererServiceWorkerVersionStatus::Activated,
+ None,
+ );
+ bc.insert_service_worker_target(target);
+ if let Some(session_id) = session_id {
+ assert!(bc.assign_session_to_service_worker_target(target_id, session_id.to_owned()));
+ }
+ }
if let Some(session_id) = session_id {
- assert!(bc.assign_session_to_service_worker_target(target_id, session_id.to_owned()));
+ ctx.conn.register_bound_session_for_test(session_id);
}
}
diff --git a/moli-protocol/src/domains/target/tests/tests_background_auto_attach.rs b/moli-protocol/src/domains/target/tests/tests_background_auto_attach.rs
index 0f8b77217..7340bf973 100644
--- a/moli-protocol/src/domains/target/tests/tests_background_auto_attach.rs
+++ b/moli-protocol/src/domains/target/tests/tests_background_auto_attach.rs
@@ -148,7 +148,7 @@ async fn set_auto_attach_true_still_reports_transient_no_page_target_like_chromi
}
#[tokio::test(flavor = "multi_thread")]
-async fn runtime_add_binding_on_auto_attached_background_target_session_routes_without_promotion_when_active_target_has_no_loaded_page()
+async fn runtime_add_binding_on_auto_attached_background_target_session_routes_without_activation_when_active_target_has_no_loaded_page()
{
let mut ctx = TestContext::new();
load_bc_with_target(&mut ctx, "BID-9", "TID-000000000A");
@@ -157,7 +157,12 @@ async fn runtime_add_binding_on_auto_attached_background_target_session_routes_w
.as_mut()
.unwrap()
.attach_active_session("SID-active");
- ctx.conn.auto_attach = true;
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
ctx.process_async(json!({
"id": 1034,
@@ -208,7 +213,7 @@ async fn runtime_add_binding_on_auto_attached_background_target_session_routes_w
.runtime_bindings
.iter()
.any(|binding| binding.name == "patchedBinding"),
- "binding definition should persist on the background DevTools session without promotion"
+ "binding definition should persist on the background DevTools session without activation"
);
}
@@ -222,7 +227,12 @@ async fn runtime_add_binding_then_navigation_on_auto_attached_background_target_
.as_mut()
.unwrap()
.attach_active_session("SID-active");
- ctx.conn.auto_attach = true;
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
ctx.process_async(json!({
"id": 10351,
@@ -311,7 +321,12 @@ async fn runtime_add_binding_and_preload_on_auto_attached_background_target_sess
.as_mut()
.unwrap()
.attach_active_session("SID-active");
- ctx.conn.auto_attach = true;
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
ctx.process_async(json!({
"id": 10355,
@@ -423,7 +438,12 @@ async fn runtime_add_binding_and_utility_preload_on_auto_attached_background_tar
.as_mut()
.unwrap()
.attach_active_session("SID-active");
- ctx.conn.auto_attach = true;
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
ctx.process_async(json!({
"id": 10369,
@@ -572,7 +592,12 @@ async fn runtime_add_binding_and_utility_preload_then_remove_on_auto_attached_ba
.as_mut()
.unwrap()
.attach_active_session("SID-active");
- ctx.conn.auto_attach = true;
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
ctx.process_async(json!({
"id": 10375,
diff --git a/moli-protocol/src/domains/target/tests/tests_background_staging.rs b/moli-protocol/src/domains/target/tests/tests_background_staging.rs
index f1d08a3a2..2b43818c5 100644
--- a/moli-protocol/src/domains/target/tests/tests_background_staging.rs
+++ b/moli-protocol/src/domains/target/tests/tests_background_staging.rs
@@ -80,7 +80,7 @@ async fn loaded_page_html_for_test(ctx: &mut TestContext) -> String {
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_stage_its_own_pre_document_state_before_promotion() {
+async fn same_context_background_session_can_stage_its_own_pre_document_state_before_activation() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -237,7 +237,7 @@ async fn same_context_background_session_can_stage_its_own_pre_document_state_be
"method": "Page.navigate",
"sessionId": second_session_id,
"params": {
- "url": "data:text/html,<title>promoted</title><div id='ok'>promoted target</div>"
+ "url": "data:text/html,<title>activated</title><div id='ok'>activated target</div>"
}
}))
.await;
@@ -268,19 +268,19 @@ async fn same_context_background_session_can_stage_its_own_pre_document_state_be
"expression": "JSON.stringify({ binding: typeof globalThis.targetBPreDocumentBinding, preload: globalThis.targetBPreload, text: document.getElementById('ok').textContent })"
}
})).await;
- let promoted_eval = take_response_by_id(&mut ctx, 104193);
- let promoted_payload = promoted_eval["result"]["result"]["value"]
+ let activated_eval = take_response_by_id(&mut ctx, 104193);
+ let activated_payload = activated_eval["result"]["result"]["value"]
.as_str()
- .expect("promoted payload should be string");
- let promoted_payload: serde_json::Value =
- serde_json::from_str(promoted_payload).expect("promoted payload should be valid json");
- assert_eq!(promoted_payload["binding"], json!("function"));
- assert_eq!(promoted_payload["preload"], json!("from-target-b"));
- assert_eq!(promoted_payload["text"], json!("promoted target"));
+ .expect("activated payload should be string");
+ let activated_payload: serde_json::Value =
+ serde_json::from_str(activated_payload).expect("activated payload should be valid json");
+ assert_eq!(activated_payload["binding"], json!("function"));
+ assert_eq!(activated_payload["preload"], json!("from-target-b"));
+ assert_eq!(activated_payload["text"], json!("activated target"));
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_stage_its_own_utility_pre_document_state_before_promotion()
+async fn same_context_background_session_can_stage_its_own_utility_pre_document_state_before_activation()
{
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
@@ -467,7 +467,7 @@ async fn same_context_background_session_can_stage_its_own_utility_pre_document_
"method": "Page.navigate",
"sessionId": second_session_id,
"params": {
- "url": "data:text/html,<title>promoted</title><div id='ok'>promoted utility target</div>"
+ "url": "data:text/html,<title>activated</title><div id='ok'>activated utility target</div>"
}
})).await;
consume_main_document_navigation_start(&mut ctx);
@@ -506,7 +506,7 @@ async fn same_context_background_session_can_stage_its_own_utility_pre_document_
})
.cloned()
})
- .expect("promoted target utility world should materialize its staged binding/preload");
+ .expect("activated target utility world should materialize its staged binding/preload");
assert_eq!(
binding_called["params"]["executionContextId"],
json!(utility_context)
@@ -526,19 +526,19 @@ async fn same_context_background_session_can_stage_its_own_utility_pre_document_
"expression": "JSON.stringify({ binding: typeof globalThis.targetBUtilityPreDocumentBinding, preload: globalThis.targetBUtilityPreload, text: document.getElementById('ok').textContent })"
}
})).await;
- let promoted_eval = take_response_by_id(&mut ctx, 104194129);
- let promoted_payload = promoted_eval["result"]["result"]["value"]
+ let activated_eval = take_response_by_id(&mut ctx, 104194129);
+ let activated_payload = activated_eval["result"]["result"]["value"]
.as_str()
- .expect("promoted payload should be string");
- let promoted_payload: serde_json::Value =
- serde_json::from_str(promoted_payload).expect("promoted payload should be valid json");
- assert_eq!(promoted_payload["binding"], json!("function"));
- assert_eq!(promoted_payload["preload"], json!("from-target-b-utility"));
- assert_eq!(promoted_payload["text"], json!("promoted utility target"));
+ .expect("activated payload should be string");
+ let activated_payload: serde_json::Value =
+ serde_json::from_str(activated_payload).expect("activated payload should be valid json");
+ assert_eq!(activated_payload["binding"], json!("function"));
+ assert_eq!(activated_payload["preload"], json!("from-target-b-utility"));
+ assert_eq!(activated_payload["text"], json!("activated utility target"));
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_remove_its_own_binding_before_promotion() {
+async fn same_context_background_session_can_remove_its_own_binding_before_activation() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -633,7 +633,7 @@ async fn same_context_background_session_can_remove_its_own_binding_before_promo
});
assert!(
staged_bindings_empty,
- "removed binding should be cleared from parked DevTools session"
+ "removed binding should be cleared from background DevTools session"
);
assert_eq!(
active
@@ -669,7 +669,7 @@ async fn same_context_background_session_can_remove_its_own_binding_before_promo
"method": "Page.navigate",
"sessionId": second_session_id,
"params": {
- "url": "data:text/html,<title>promoted</title><div id='ok'>promoted target</div>"
+ "url": "data:text/html,<title>activated</title><div id='ok'>activated target</div>"
}
}))
.await;
@@ -681,7 +681,7 @@ async fn same_context_background_session_can_remove_its_own_binding_before_promo
!ctx.sent
.iter()
.any(|message| message["method"] == json!("Runtime.bindingCalled")),
- "removed binding should not replay into first promoted navigation: {:?}",
+ "removed binding should not replay into first activated navigation: {:?}",
ctx.sent
);
@@ -693,19 +693,19 @@ async fn same_context_background_session_can_remove_its_own_binding_before_promo
"expression": "JSON.stringify({ binding: typeof globalThis.targetBRemovedBinding, preload: globalThis.targetBRemovedBindingPreload, text: document.getElementById('ok').textContent })"
}
})).await;
- let promoted_eval = take_response_by_id(&mut ctx, 104194107);
- let promoted_payload = promoted_eval["result"]["result"]["value"]
+ let activated_eval = take_response_by_id(&mut ctx, 104194107);
+ let activated_payload = activated_eval["result"]["result"]["value"]
.as_str()
- .expect("promoted payload should be string");
- let promoted_payload: serde_json::Value =
- serde_json::from_str(promoted_payload).expect("promoted payload should be valid json");
- assert_eq!(promoted_payload["binding"], json!("undefined"));
- assert_eq!(promoted_payload["preload"], json!("undefined"));
- assert_eq!(promoted_payload["text"], json!("promoted target"));
+ .expect("activated payload should be string");
+ let activated_payload: serde_json::Value =
+ serde_json::from_str(activated_payload).expect("activated payload should be valid json");
+ assert_eq!(activated_payload["binding"], json!("undefined"));
+ assert_eq!(activated_payload["preload"], json!("undefined"));
+ assert_eq!(activated_payload["text"], json!("activated target"));
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_remove_its_own_preload_before_promotion() {
+async fn same_context_background_session_can_remove_its_own_preload_before_activation() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -821,7 +821,7 @@ async fn same_context_background_session_can_remove_its_own_preload_before_promo
"method": "Page.navigate",
"sessionId": second_session_id,
"params": {
- "url": "data:text/html,<title>promoted</title><div id='ok'>promoted target</div>"
+ "url": "data:text/html,<title>activated</title><div id='ok'>activated target</div>"
}
}))
.await;
@@ -833,7 +833,7 @@ async fn same_context_background_session_can_remove_its_own_preload_before_promo
!ctx.sent
.iter()
.any(|message| message["method"] == json!("Runtime.bindingCalled")),
- "removed preload should not trigger binding call during first promoted navigation: {:?}",
+ "removed preload should not trigger binding call during first activated navigation: {:?}",
ctx.sent
);
@@ -845,19 +845,19 @@ async fn same_context_background_session_can_remove_its_own_preload_before_promo
"expression": "JSON.stringify({ binding: typeof globalThis.targetBRemainingBinding, preload: globalThis.targetBRemovedPreload ?? 'absent', text: document.getElementById('ok').textContent })"
}
})).await;
- let promoted_eval = take_response_by_id(&mut ctx, 104194117);
- let promoted_payload = promoted_eval["result"]["result"]["value"]
+ let activated_eval = take_response_by_id(&mut ctx, 104194117);
+ let activated_payload = activated_eval["result"]["result"]["value"]
.as_str()
- .expect("promoted payload should be string");
- let promoted_payload: serde_json::Value =
- serde_json::from_str(promoted_payload).expect("promoted payload should be valid json");
- assert_eq!(promoted_payload["binding"], json!("function"));
- assert_eq!(promoted_payload["preload"], json!("absent"));
- assert_eq!(promoted_payload["text"], json!("promoted target"));
+ .expect("activated payload should be string");
+ let activated_payload: serde_json::Value =
+ serde_json::from_str(activated_payload).expect("activated payload should be valid json");
+ assert_eq!(activated_payload["binding"], json!("function"));
+ assert_eq!(activated_payload["preload"], json!("absent"));
+ assert_eq!(activated_payload["text"], json!("activated target"));
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_remove_its_own_utility_binding_before_promotion() {
+async fn same_context_background_session_can_remove_its_own_utility_binding_before_activation() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -955,7 +955,7 @@ async fn same_context_background_session_can_remove_its_own_utility_binding_befo
});
assert!(
staged_bindings_empty,
- "removed utility binding should be cleared from parked DevTools session"
+ "removed utility binding should be cleared from background DevTools session"
);
assert_eq!(
active
@@ -991,7 +991,7 @@ async fn same_context_background_session_can_remove_its_own_utility_binding_befo
"method": "Page.navigate",
"sessionId": second_session_id,
"params": {
- "url": "data:text/html,<title>promoted</title><div id='ok'>promoted utility target</div>"
+ "url": "data:text/html,<title>activated</title><div id='ok'>activated utility target</div>"
}
})).await;
consume_main_document_navigation_start(&mut ctx);
@@ -1001,7 +1001,7 @@ async fn same_context_background_session_can_remove_its_own_utility_binding_befo
!ctx.sent
.iter()
.any(|message| message["method"] == json!("Runtime.bindingCalled")),
- "removed utility binding should not replay into first promoted utility world: {:?}",
+ "removed utility binding should not replay into first activated utility world: {:?}",
ctx.sent
);
ctx.take_all();
@@ -1037,19 +1037,19 @@ async fn same_context_background_session_can_remove_its_own_utility_binding_befo
"expression": "JSON.stringify({ binding: typeof globalThis.targetBRemovedUtilityBinding, preload: globalThis.targetBRemovedUtilityBindingType, text: document.getElementById('ok').textContent })"
}
})).await;
- let promoted_eval = take_response_by_id(&mut ctx, 104194138);
- let promoted_payload = promoted_eval["result"]["result"]["value"]
+ let activated_eval = take_response_by_id(&mut ctx, 104194138);
+ let activated_payload = activated_eval["result"]["result"]["value"]
.as_str()
- .expect("promoted payload should be string");
- let promoted_payload: serde_json::Value =
- serde_json::from_str(promoted_payload).expect("promoted payload should be valid json");
- assert_eq!(promoted_payload["binding"], json!("undefined"));
- assert_eq!(promoted_payload["preload"], json!("undefined"));
- assert_eq!(promoted_payload["text"], json!("promoted utility target"));
+ .expect("activated payload should be string");
+ let activated_payload: serde_json::Value =
+ serde_json::from_str(activated_payload).expect("activated payload should be valid json");
+ assert_eq!(activated_payload["binding"], json!("undefined"));
+ assert_eq!(activated_payload["preload"], json!("undefined"));
+ assert_eq!(activated_payload["text"], json!("activated utility target"));
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_remove_its_own_utility_preload_before_promotion() {
+async fn same_context_background_session_can_remove_its_own_utility_preload_before_activation() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -1172,7 +1172,7 @@ async fn same_context_background_session_can_remove_its_own_utility_preload_befo
"method": "Page.navigate",
"sessionId": second_session_id,
"params": {
- "url": "data:text/html,<title>promoted</title><div id='ok'>promoted utility target</div>"
+ "url": "data:text/html,<title>activated</title><div id='ok'>activated utility target</div>"
}
})).await;
consume_main_document_navigation_start(&mut ctx);
@@ -1182,7 +1182,7 @@ async fn same_context_background_session_can_remove_its_own_utility_preload_befo
!ctx.sent
.iter()
.any(|message| message["method"] == json!("Runtime.bindingCalled")),
- "removed utility preload should not trigger binding call during first promoted navigation: {:?}",
+ "removed utility preload should not trigger binding call during first activated navigation: {:?}",
ctx.sent
);
ctx.take_all();
@@ -1218,19 +1218,19 @@ async fn same_context_background_session_can_remove_its_own_utility_preload_befo
"expression": "JSON.stringify({ binding: typeof globalThis.targetBRemainingUtilityBinding, preload: globalThis.targetBRemovedUtilityPreload ?? 'absent', text: document.getElementById('ok').textContent })"
}
})).await;
- let promoted_eval = take_response_by_id(&mut ctx, 104194148);
- let promoted_payload = promoted_eval["result"]["result"]["value"]
+ let activated_eval = take_response_by_id(&mut ctx, 104194148);
+ let activated_payload = activated_eval["result"]["result"]["value"]
.as_str()
- .expect("promoted payload should be string");
- let promoted_payload: serde_json::Value =
- serde_json::from_str(promoted_payload).expect("promoted payload should be valid json");
- assert_eq!(promoted_payload["binding"], json!("function"));
- assert_eq!(promoted_payload["preload"], json!("absent"));
- assert_eq!(promoted_payload["text"], json!("promoted utility target"));
+ .expect("activated payload should be string");
+ let activated_payload: serde_json::Value =
+ serde_json::from_str(activated_payload).expect("activated payload should be valid json");
+ assert_eq!(activated_payload["binding"], json!("function"));
+ assert_eq!(activated_payload["preload"], json!("absent"));
+ assert_eq!(activated_payload["text"], json!("activated utility target"));
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_stage_its_own_emulated_media_before_promotion() {
+async fn same_context_background_session_can_stage_its_own_emulated_media_before_activation() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -1329,7 +1329,7 @@ async fn same_context_background_session_can_stage_its_own_emulated_media_before
let staged = active
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
- .expect("second target should have staged parked page session state");
+ .expect("second target should have staged background page session state");
assert_eq!(staged.emulated_media.color_scheme.as_deref(), Some("light"));
}
@@ -1369,7 +1369,7 @@ async fn same_context_background_session_can_stage_its_own_emulated_media_before
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_clear_its_own_emulated_media_before_promotion() {
+async fn same_context_background_session_can_clear_its_own_emulated_media_before_activation() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -1470,7 +1470,7 @@ async fn same_context_background_session_can_clear_its_own_emulated_media_before
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
.is_none(),
- "clearing staged emulated media back to default should fold away the parked state entry",
+ "clearing staged emulated media back to default should fold away the background state entry",
);
}
@@ -1494,30 +1494,30 @@ async fn same_context_background_session_can_clear_its_own_emulated_media_before
ctx.take_all();
let html = loaded_page_html_for_test(&mut ctx).await;
- let promoted_surface = html
+ let activated_surface = html
.split("<body>")
.nth(1)
.and_then(|tail| tail.split("</body>").next())
- .expect("promoted payload should be embedded in body");
- let promoted_surface = serde_json::json!(
- promoted_surface
+ .expect("activated payload should be embedded in body");
+ let activated_surface = serde_json::json!(
+ activated_surface
.split('|')
.map(str::to_owned)
.collect::<Vec<_>>()
);
assert_eq!(
- promoted_surface, default_surface,
- "promoted target should observe default emulated media after clearing its staged override; got {html}"
+ activated_surface, default_surface,
+ "activated target should observe default emulated media after clearing its staged override; got {html}"
);
assert_ne!(
- promoted_surface,
+ activated_surface,
serde_json::json!(["true", "false"]),
- "promoted target should not retain the staged dark override"
+ "activated target should not retain the staged dark override"
);
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_stage_its_own_network_conditions_before_promotion() {
+async fn same_context_background_session_can_stage_its_own_network_conditions_before_activation() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -1608,7 +1608,7 @@ async fn same_context_background_session_can_stage_its_own_network_conditions_be
let staged = active
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
- .expect("second target should have staged parked page session state");
+ .expect("second target should have staged background page session state");
assert!(staged.network_policy.network_offline());
assert_eq!(staged.network_policy.emulated_network_latency(), 25.0);
assert_eq!(staged.network_policy.emulated_download_throughput(), 1024.0);
@@ -1645,45 +1645,48 @@ async fn same_context_background_session_can_stage_its_own_network_conditions_be
ctx.take_all();
{
- let promoted = ctx
+ let activated = ctx
.conn
.browser_context
.as_ref()
- .expect("promoted browser context");
- assert_eq!(promoted.active_target_id(), Some(second_target_id.as_str()));
+ .expect("activated browser context");
assert_eq!(
- promoted.active_session_id(),
+ activated.active_target_id(),
+ Some(second_target_id.as_str())
+ );
+ assert_eq!(
+ activated.active_session_id(),
Some(second_session_id.as_str())
);
assert!(
- promoted
+ activated
.active_page_target()
.network_policy
.network_offline()
);
assert_eq!(
- promoted
+ activated
.active_page_target()
.network_policy
.emulated_network_latency(),
25.0
);
assert_eq!(
- promoted
+ activated
.active_page_target()
.network_policy
.emulated_download_throughput(),
1024.0
);
assert_eq!(
- promoted
+ activated
.active_page_target()
.network_policy
.emulated_upload_throughput(),
256.0
);
assert_eq!(
- promoted
+ activated
.active_page_target()
.network_policy
.emulated_connection_type(),
@@ -1695,19 +1698,19 @@ async fn same_context_background_session_can_stage_its_own_network_conditions_be
"id": 10419456,
"method": "Page.navigate",
"sessionId": second_session_id,
- "params": { "url": "http://example.test/offline-promoted" }
+ "params": { "url": "http://example.test/offline-activated" }
}))
.await;
consume_main_document_navigation_start(&mut ctx);
- let promoted_navigation = take_response_by_id(&mut ctx, 10419456);
+ let activated_navigation = take_response_by_id(&mut ctx, 10419456);
assert_eq!(
- promoted_navigation["error"]["message"],
+ activated_navigation["error"]["message"],
json!("Network emulation offline")
);
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_stage_its_own_blocked_urls_before_promotion() {
+async fn same_context_background_session_can_stage_its_own_blocked_urls_before_activation() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -1776,7 +1779,7 @@ async fn same_context_background_session_can_stage_its_own_blocked_urls_before_p
let staged = active
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
- .expect("second target should have staged parked page session state");
+ .expect("second target should have staged background page session state");
assert!(
staged.effective_policy().blocked_url_patterns().is_empty(),
"a disabled Network handler must not contribute to effective target policy"
@@ -1802,19 +1805,22 @@ async fn same_context_background_session_can_stage_its_own_blocked_urls_before_p
ctx.take_all();
{
- let promoted = ctx
+ let activated = ctx
.conn
.browser_context
.as_ref()
- .expect("promoted browser context");
- assert_eq!(promoted.active_target_id(), Some(second_target_id.as_str()));
+ .expect("activated browser context");
+ assert_eq!(
+ activated.active_target_id(),
+ Some(second_target_id.as_str())
+ );
assert!(
- promoted
+ activated
.active_page_target()
.effective_policy()
.blocked_url_patterns()
.is_empty(),
- "promotion must not activate a disabled Network handler"
+ "activation must not activate a disabled Network handler"
);
}
@@ -1829,7 +1835,7 @@ async fn same_context_background_session_can_stage_its_own_blocked_urls_before_p
ctx.conn
.browser_context
.as_ref()
- .expect("promoted browser context")
+ .expect("activated browser context")
.active_page_target()
.effective_policy()
.blocked_url_patterns(),
@@ -1849,15 +1855,15 @@ async fn same_context_background_session_can_stage_its_own_blocked_urls_before_p
let failed = ctx.take_one();
assert_eq!(failed["method"], "Network.loadingFailed");
assert_eq!(failed["params"]["errorText"], "net::ERR_BLOCKED_BY_CLIENT");
- let promoted_navigation = take_response_by_id(&mut ctx, 10419462);
+ let activated_navigation = take_response_by_id(&mut ctx, 10419462);
assert_eq!(
- promoted_navigation["error"]["message"],
+ activated_navigation["error"]["message"],
json!("net::ERR_BLOCKED_BY_CLIENT")
);
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_reset_its_own_network_conditions_before_promotion() {
+async fn same_context_background_session_can_reset_its_own_network_conditions_before_activation() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -1944,7 +1950,7 @@ async fn same_context_background_session_can_reset_its_own_network_conditions_be
let staged = active
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
- .expect("second target should have staged parked page session state");
+ .expect("second target should have staged background page session state");
assert!(!staged.network_policy.network_offline());
assert_eq!(staged.network_policy.emulated_network_latency(), 0.0);
assert_eq!(staged.network_policy.emulated_download_throughput(), -1.0);
@@ -1968,54 +1974,57 @@ async fn same_context_background_session_can_reset_its_own_network_conditions_be
"id": 104194506,
"method": "Page.navigate",
"sessionId": second_session_id,
- "params": { "url": "data:text/html,<title>promoted-online</title><div id='ok'>promoted online</div>" }
+ "params": { "url": "data:text/html,<title>activated-online</title><div id='ok'>activated online</div>" }
})).await;
- let promoted_navigation = take_response_by_id(&mut ctx, 104194506);
+ let activated_navigation = take_response_by_id(&mut ctx, 104194506);
assert_eq!(
- promoted_navigation["result"]["frameId"],
+ activated_navigation["result"]["frameId"],
json!(second_target_id)
);
assert!(
ctx.sent
.iter()
.all(|message| message.get("error").is_none()),
- "unexpected protocol error during promoted navigation: {:?}",
+ "unexpected protocol error during activated navigation: {:?}",
ctx.sent
);
ctx.take_all();
{
- let promoted = ctx.conn.browser_context.as_ref().expect("browser context");
- assert_eq!(promoted.active_target_id(), Some(second_target_id.as_str()));
+ let activated = ctx.conn.browser_context.as_ref().expect("browser context");
+ assert_eq!(
+ activated.active_target_id(),
+ Some(second_target_id.as_str())
+ );
assert!(
- !promoted
+ !activated
.active_page_target()
.network_policy
.network_offline()
);
assert_eq!(
- promoted
+ activated
.active_page_target()
.network_policy
.emulated_network_latency(),
0.0
);
assert_eq!(
- promoted
+ activated
.active_page_target()
.network_policy
.emulated_download_throughput(),
-1.0
);
assert_eq!(
- promoted
+ activated
.active_page_target()
.network_policy
.emulated_upload_throughput(),
-1.0
);
assert_eq!(
- promoted
+ activated
.active_page_target()
.network_policy
.emulated_connection_type(),
@@ -2025,7 +2034,7 @@ async fn same_context_background_session_can_reset_its_own_network_conditions_be
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_stage_its_own_extra_headers_before_promotion() {
+async fn same_context_background_session_can_stage_its_own_extra_headers_before_activation() {
async fn handler(
State(seen): State<Arc<Mutex<Vec<(String, Option<String>)>>>>,
headers: HeaderMap,
@@ -2161,7 +2170,7 @@ async fn same_context_background_session_can_stage_its_own_extra_headers_before_
let staged = active
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
- .expect("second target should have staged parked page session state");
+ .expect("second target should have staged background page session state");
assert_eq!(
staged.effective_policy().extra_headers(),
vec![("X-Target".into(), "B".into())]
@@ -2208,7 +2217,7 @@ async fn same_context_background_session_can_stage_its_own_extra_headers_before_
ctx.sent
.iter()
.all(|message| message.get("error").is_none()),
- "unexpected protocol error during promoted navigation: {:?}",
+ "unexpected protocol error during activated navigation: {:?}",
ctx.sent
);
@@ -2225,7 +2234,7 @@ async fn same_context_background_session_can_stage_its_own_extra_headers_before_
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_clear_its_own_extra_headers_before_promotion() {
+async fn same_context_background_session_can_clear_its_own_extra_headers_before_activation() {
async fn handler(
State(seen): State<Arc<Mutex<Vec<(String, Option<String>)>>>>,
headers: HeaderMap,
@@ -2414,7 +2423,7 @@ async fn same_context_background_session_can_clear_its_own_extra_headers_before_
ctx.sent
.iter()
.all(|message| message.get("error").is_none()),
- "unexpected protocol error during promoted navigation: {:?}",
+ "unexpected protocol error during activated navigation: {:?}",
ctx.sent
);
@@ -2431,7 +2440,7 @@ async fn same_context_background_session_can_clear_its_own_extra_headers_before_
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_stage_its_own_user_agent_before_promotion() {
+async fn same_context_background_session_can_stage_its_own_user_agent_before_activation() {
async fn handler(
State(seen): State<Arc<Mutex<Vec<(String, Option<String>)>>>>,
headers: HeaderMap,
@@ -2544,7 +2553,7 @@ async fn same_context_background_session_can_stage_its_own_user_agent_before_pro
let staged = active
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
- .expect("second target should have staged parked page session state");
+ .expect("second target should have staged background page session state");
assert_eq!(
staged
.effective_policy()
@@ -2594,7 +2603,7 @@ async fn same_context_background_session_can_stage_its_own_user_agent_before_pro
ctx.sent
.iter()
.all(|message| message.get("error").is_none()),
- "unexpected protocol error during promoted navigation: {:?}",
+ "unexpected protocol error during activated navigation: {:?}",
ctx.sent
);
@@ -2605,9 +2614,9 @@ async fn same_context_background_session_can_stage_its_own_user_agent_before_pro
"params": { "expression": "navigator.userAgent" }
}))
.await;
- let promoted_eval = take_response_by_id(&mut ctx, 10419477);
+ let activated_eval = take_response_by_id(&mut ctx, 10419477);
assert_eq!(
- promoted_eval["result"]["result"]["value"],
+ activated_eval["result"]["result"]["value"],
json!("Moli/Stage-B")
);
@@ -2624,7 +2633,7 @@ async fn same_context_background_session_can_stage_its_own_user_agent_before_pro
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_clear_its_own_user_agent_before_promotion() {
+async fn same_context_background_session_can_clear_its_own_user_agent_before_activation() {
async fn handler(
State(seen): State<Arc<Mutex<Vec<(String, Option<String>)>>>>,
headers: HeaderMap,
@@ -2755,7 +2764,7 @@ async fn same_context_background_session_can_clear_its_own_user_agent_before_pro
let staged = active
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
- .expect("second target should have staged parked page session state");
+ .expect("second target should have staged background page session state");
assert_eq!(
staged
.effective_policy()
@@ -2787,7 +2796,7 @@ async fn same_context_background_session_can_clear_its_own_user_agent_before_pro
ctx.sent
.iter()
.all(|message| message.get("error").is_none()),
- "unexpected protocol error during promoted navigation: {:?}",
+ "unexpected protocol error during activated navigation: {:?}",
ctx.sent
);
@@ -2800,7 +2809,7 @@ async fn same_context_background_session_can_clear_its_own_user_agent_before_pro
assert_ne!(
seen[1].1.as_deref(),
Some("Moli/Staged-B"),
- "promoted target should not retain the staged user agent override",
+ "activated target should not retain the staged user agent override",
);
server.abort();
@@ -2944,7 +2953,7 @@ async fn same_context_background_session_stages_locale_without_changing_request_
let staged = active
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
- .expect("second target should have staged parked page session state");
+ .expect("second target should have staged background page session state");
assert_eq!(staged.effective_policy().locale_override(), Some("fr-FR"));
assert_eq!(
staged.effective_policy().timezone_override(),
@@ -3011,7 +3020,7 @@ async fn same_context_background_session_stages_locale_without_changing_request_
ctx.sent
.iter()
.all(|message| message.get("error").is_none()),
- "unexpected protocol error during promoted navigation: {:?}",
+ "unexpected protocol error during activated navigation: {:?}",
ctx.sent
);
@@ -3024,15 +3033,15 @@ async fn same_context_background_session_stages_locale_without_changing_request_
}
}))
.await;
- let promoted_eval = take_response_by_id(&mut ctx, 10419490);
- let promoted_payload = promoted_eval["result"]["result"]["value"]
+ let activated_eval = take_response_by_id(&mut ctx, 10419490);
+ let activated_payload = activated_eval["result"]["result"]["value"]
.as_str()
- .expect("promoted payload should be string");
- let promoted_payload: serde_json::Value =
- serde_json::from_str(promoted_payload).expect("promoted payload should be valid json");
- assert_eq!(promoted_payload["lang"], json!("en-US"));
- assert_eq!(promoted_payload["locale"], json!("fr-FR"));
- assert_eq!(promoted_payload["tz"], json!("Asia/Shanghai"));
+ .expect("activated payload should be string");
+ let activated_payload: serde_json::Value =
+ serde_json::from_str(activated_payload).expect("activated payload should be valid json");
+ assert_eq!(activated_payload["lang"], json!("en-US"));
+ assert_eq!(activated_payload["locale"], json!("fr-FR"));
+ assert_eq!(activated_payload["tz"], json!("Asia/Shanghai"));
let seen = seen.lock().clone();
assert_eq!(
@@ -3047,7 +3056,7 @@ async fn same_context_background_session_stages_locale_without_changing_request_
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_clear_its_own_locale_before_promotion() {
+async fn same_context_background_session_can_clear_its_own_locale_before_activation() {
async fn handler(headers: HeaderMap) -> impl IntoResponse {
let accept_language = headers
.get(axum::http::header::ACCEPT_LANGUAGE)
@@ -3151,7 +3160,7 @@ async fn same_context_background_session_can_clear_its_own_locale_before_promoti
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
.is_none(),
- "clearing staged locale back to default should fold away the parked state entry",
+ "clearing staged locale back to default should fold away the background state entry",
);
}
@@ -3199,25 +3208,25 @@ async fn same_context_background_session_can_clear_its_own_locale_before_promoti
let _ = take_response_by_id(&mut ctx, 104194807);
ctx.take_all();
- let promoted_html = loaded_page_html_for_test(&mut ctx).await;
- let promoted_surface = promoted_html
+ let activated_html = loaded_page_html_for_test(&mut ctx).await;
+ let activated_surface = activated_html
.split("<body")
.nth(1)
.and_then(|tail| tail.split('>').nth(1))
.and_then(|tail| tail.split("</body>").next())
- .expect("promoted payload should be embedded in body")
+ .expect("activated payload should be embedded in body")
.to_owned();
assert_eq!(
- promoted_surface, active_surface,
- "promoted target should observe default locale surface after clearing its staged override"
+ activated_surface, active_surface,
+ "activated target should observe default locale surface after clearing its staged override"
);
server.abort();
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_clear_its_own_timezone_before_promotion() {
+async fn same_context_background_session_can_clear_its_own_timezone_before_activation() {
async fn handler() -> impl IntoResponse {
"<!doctype html><html><body><script>document.body.textContent = Intl.DateTimeFormat().resolvedOptions().timeZone;</script></body></html>"
}
@@ -3315,7 +3324,7 @@ async fn same_context_background_session_can_clear_its_own_timezone_before_promo
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
.is_none(),
- "clearing staged timezone back to default should fold away the parked state entry",
+ "clearing staged timezone back to default should fold away the background state entry",
);
}
@@ -3360,29 +3369,29 @@ async fn same_context_background_session_can_clear_its_own_timezone_before_promo
let _ = take_response_by_id(&mut ctx, 104194814);
ctx.take_all();
- let promoted_html = loaded_page_html_for_test(&mut ctx).await;
- let promoted_surface = promoted_html
+ let activated_html = loaded_page_html_for_test(&mut ctx).await;
+ let activated_surface = activated_html
.split("<body")
.nth(1)
.and_then(|tail| tail.split('>').nth(1))
.and_then(|tail| tail.split("</body>").next())
- .expect("promoted payload should be embedded in body")
+ .expect("activated payload should be embedded in body")
.to_owned();
assert_eq!(
- promoted_surface, active_surface,
- "promoted target should observe default timezone surface after clearing its staged override"
+ activated_surface, active_surface,
+ "activated target should observe default timezone surface after clearing its staged override"
);
assert_ne!(
- promoted_surface, "Asia/Shanghai",
- "promoted target should not retain the staged timezone override"
+ activated_surface, "Asia/Shanghai",
+ "activated target should not retain the staged timezone override"
);
server.abort();
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_stage_its_own_emulation_overrides_before_promotion() {
+async fn same_context_background_session_can_stage_its_own_emulation_overrides_before_activation() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -3520,7 +3529,7 @@ async fn same_context_background_session_can_stage_its_own_emulation_overrides_b
let staged = active
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
- .expect("second target should have staged parked page session state");
+ .expect("second target should have staged background page session state");
assert_eq!(
staged.emulated_device_metrics.as_ref().map(|metrics| (
metrics.width,
@@ -3601,7 +3610,7 @@ async fn same_context_background_session_can_stage_its_own_emulation_overrides_b
ctx.sent
.iter()
.all(|message| message.get("error").is_none()),
- "unexpected protocol error during promoted navigation: {:?}",
+ "unexpected protocol error during activated navigation: {:?}",
ctx.sent
);
ctx.take_all();
@@ -3614,25 +3623,25 @@ async fn same_context_background_session_can_stage_its_own_emulation_overrides_b
"expression": "JSON.stringify({ innerWidth: window.innerWidth, innerHeight: window.innerHeight, dpr: window.devicePixelRatio, screenWidth: screen.width, screenHeight: screen.height, maxTouchPoints: navigator.maxTouchPoints, hasFocus: document.hasFocus(), hidden: document.hidden, visibilityState: document.visibilityState })"
}
})).await;
- let promoted_eval = take_response_by_id(&mut ctx, 104194913);
- let promoted_payload = promoted_eval["result"]["result"]["value"]
+ let activated_eval = take_response_by_id(&mut ctx, 104194913);
+ let activated_payload = activated_eval["result"]["result"]["value"]
.as_str()
- .expect("promoted payload should be string");
- let promoted_payload: serde_json::Value =
- serde_json::from_str(promoted_payload).expect("promoted payload should be valid json");
- assert_eq!(promoted_payload["innerWidth"], json!(640));
- assert_eq!(promoted_payload["innerHeight"], json!(360));
- assert_eq!(promoted_payload["dpr"], json!(1));
- assert_eq!(promoted_payload["screenWidth"], json!(800));
- assert_eq!(promoted_payload["screenHeight"], json!(600));
- assert_eq!(promoted_payload["maxTouchPoints"], json!(0));
- assert_eq!(promoted_payload["hasFocus"], json!(true));
- assert_eq!(promoted_payload["hidden"], json!(false));
- assert_eq!(promoted_payload["visibilityState"], json!("visible"));
+ .expect("activated payload should be string");
+ let activated_payload: serde_json::Value =
+ serde_json::from_str(activated_payload).expect("activated payload should be valid json");
+ assert_eq!(activated_payload["innerWidth"], json!(640));
+ assert_eq!(activated_payload["innerHeight"], json!(360));
+ assert_eq!(activated_payload["dpr"], json!(1));
+ assert_eq!(activated_payload["screenWidth"], json!(800));
+ assert_eq!(activated_payload["screenHeight"], json!(600));
+ assert_eq!(activated_payload["maxTouchPoints"], json!(0));
+ assert_eq!(activated_payload["hasFocus"], json!(true));
+ assert_eq!(activated_payload["hidden"], json!(false));
+ assert_eq!(activated_payload["visibilityState"], json!("visible"));
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_stage_its_own_page_settings_before_promotion() {
+async fn same_context_background_session_can_stage_its_own_page_settings_before_activation() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -3754,7 +3763,7 @@ async fn same_context_background_session_can_stage_its_own_page_settings_before_
.conn
.browser_context
.as_ref()
- .expect("promoted browser context");
+ .expect("activated browser context");
assert_eq!(active.active_target_id(), Some(second_target_id.as_str()));
assert!(
active.active_page_target().devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
@@ -3783,7 +3792,7 @@ async fn same_context_background_session_can_stage_its_own_page_settings_before_
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_clear_its_own_device_metrics_before_promotion() {
+async fn same_context_background_session_can_clear_its_own_device_metrics_before_activation() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -3869,7 +3878,7 @@ async fn same_context_background_session_can_clear_its_own_device_metrics_before
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
.is_none(),
- "clearing staged device metrics back to default should fold away the parked state entry",
+ "clearing staged device metrics back to default should fold away the background state entry",
);
}
@@ -3929,25 +3938,25 @@ async fn same_context_background_session_can_clear_its_own_device_metrics_before
"expression": "JSON.stringify({ innerWidth: window.innerWidth, innerHeight: window.innerHeight, dpr: window.devicePixelRatio, screenWidth: screen.width, screenHeight: screen.height })"
}
})).await;
- let promoted_eval = take_response_by_id(&mut ctx, 1041949139);
- let promoted_payload = promoted_eval["result"]["result"]["value"]
+ let activated_eval = take_response_by_id(&mut ctx, 1041949139);
+ let activated_payload = activated_eval["result"]["result"]["value"]
.as_str()
- .expect("promoted payload should be string");
- let promoted_payload: serde_json::Value =
- serde_json::from_str(promoted_payload).expect("promoted payload should be valid json");
+ .expect("activated payload should be string");
+ let activated_payload: serde_json::Value =
+ serde_json::from_str(activated_payload).expect("activated payload should be valid json");
assert_eq!(
- promoted_payload, active_payload,
- "promoted target should observe default metrics after clearing its staged override"
+ activated_payload, active_payload,
+ "activated target should observe default metrics after clearing its staged override"
);
- assert_ne!(promoted_payload["innerWidth"], json!(640));
- assert_ne!(promoted_payload["innerHeight"], json!(360));
- assert_ne!(promoted_payload["screenWidth"], json!(800));
- assert_ne!(promoted_payload["screenHeight"], json!(600));
+ assert_ne!(activated_payload["innerWidth"], json!(640));
+ assert_ne!(activated_payload["innerHeight"], json!(360));
+ assert_ne!(activated_payload["screenWidth"], json!(800));
+ assert_ne!(activated_payload["screenHeight"], json!(600));
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_clear_its_own_touch_and_focus_before_promotion() {
+async fn same_context_background_session_can_clear_its_own_touch_and_focus_before_activation() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -4046,7 +4055,7 @@ async fn same_context_background_session_can_clear_its_own_touch_and_focus_befor
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
.is_none(),
- "clearing staged touch/focus back to defaults should fold away the parked state entry",
+ "clearing staged touch/focus back to defaults should fold away the background state entry",
);
}
@@ -4106,18 +4115,18 @@ async fn same_context_background_session_can_clear_its_own_touch_and_focus_befor
"expression": "JSON.stringify({ maxTouchPoints: navigator.maxTouchPoints, hasFocusType: typeof document.hasFocus, hasFocusValue: typeof document.hasFocus === 'function' ? document.hasFocus() : null, hidden: document.hidden, visibilityState: document.visibilityState })"
}
})).await;
- let promoted_eval = take_response_by_id(&mut ctx, 1041949151);
- let promoted_payload = promoted_eval["result"]["result"]["value"]
+ let activated_eval = take_response_by_id(&mut ctx, 1041949151);
+ let activated_payload = activated_eval["result"]["result"]["value"]
.as_str()
- .expect("promoted payload should be string");
- let promoted_payload: serde_json::Value =
- serde_json::from_str(promoted_payload).expect("promoted payload should be valid json");
+ .expect("activated payload should be string");
+ let activated_payload: serde_json::Value =
+ serde_json::from_str(activated_payload).expect("activated payload should be valid json");
assert_eq!(
- promoted_payload, active_payload,
- "promoted target should observe default touch/focus surfaces after clearing staged overrides"
+ activated_payload, active_payload,
+ "activated target should observe default touch/focus surfaces after clearing staged overrides"
);
- assert_ne!(promoted_payload["maxTouchPoints"], json!(1));
+ assert_ne!(activated_payload["maxTouchPoints"], json!(1));
assert_eq!(active_payload["hasFocusType"], json!("function"));
assert_eq!(active_payload["hasFocusValue"], json!(true));
assert_eq!(active_payload["hidden"], json!(false));
@@ -4125,7 +4134,7 @@ async fn same_context_background_session_can_clear_its_own_touch_and_focus_befor
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_stage_its_own_script_execution_disabled_before_promotion()
+async fn same_context_background_session_can_stage_its_own_script_execution_disabled_before_activation()
{
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
@@ -4189,7 +4198,7 @@ async fn same_context_background_session_can_stage_its_own_script_execution_disa
let staged = active
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
- .expect("second target should have staged parked page session state");
+ .expect("second target should have staged background page session state");
assert!(staged.script_execution_disabled);
}
@@ -4242,7 +4251,7 @@ async fn same_context_background_session_can_stage_its_own_script_execution_disa
"method": "Page.navigate",
"sessionId": second_session_id,
"params": {
- "url": "data:text/html,<body><script>document.body.dataset.inlineRan='yes'; globalThis.__inlineRan = true;</script>promoted</body>"
+ "url": "data:text/html,<body><script>document.body.dataset.inlineRan='yes'; globalThis.__inlineRan = true;</script>activated</body>"
}
})).await;
let _ = take_response_by_id(&mut ctx, 104194926);
@@ -4250,18 +4259,18 @@ async fn same_context_background_session_can_stage_its_own_script_execution_disa
ctx.sent
.iter()
.all(|message| message.get("error").is_none()),
- "unexpected protocol error during promoted navigation: {:?}",
+ "unexpected protocol error during activated navigation: {:?}",
ctx.sent
);
ctx.take_all();
{
- let promoted = ctx
+ let activated = ctx
.conn
.browser_context
.as_ref()
- .expect("promoted browser context");
- assert!(promoted.active_page_target().script_execution_disabled);
+ .expect("activated browser context");
+ assert!(activated.active_page_target().script_execution_disabled);
}
ctx.process_async(json!({
@@ -4272,19 +4281,19 @@ async fn same_context_background_session_can_stage_its_own_script_execution_disa
"expression": "JSON.stringify({ inlineRan: !!globalThis.__inlineRan, dataset: document.body.dataset.inlineRan || null, runtimeEvalStillWorks: 1 + 1 })"
}
})).await;
- let promoted_eval = take_response_by_id(&mut ctx, 104194927);
- let promoted_payload = promoted_eval["result"]["result"]["value"]
+ let activated_eval = take_response_by_id(&mut ctx, 104194927);
+ let activated_payload = activated_eval["result"]["result"]["value"]
.as_str()
- .expect("promoted payload should be string");
- let promoted_payload: serde_json::Value =
- serde_json::from_str(promoted_payload).expect("promoted payload should be valid json");
- assert_eq!(promoted_payload["inlineRan"], json!(false));
- assert_eq!(promoted_payload["dataset"], serde_json::Value::Null);
- assert_eq!(promoted_payload["runtimeEvalStillWorks"], json!(2));
+ .expect("activated payload should be string");
+ let activated_payload: serde_json::Value =
+ serde_json::from_str(activated_payload).expect("activated payload should be valid json");
+ assert_eq!(activated_payload["inlineRan"], json!(false));
+ assert_eq!(activated_payload["dataset"], serde_json::Value::Null);
+ assert_eq!(activated_payload["runtimeEvalStillWorks"], json!(2));
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_reenable_its_own_script_execution_before_promotion() {
+async fn same_context_background_session_can_reenable_its_own_script_execution_before_activation() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -4354,14 +4363,14 @@ async fn same_context_background_session_can_reenable_its_own_script_execution_b
.expect("active browser context");
assert!(!active.active_page_target().script_execution_disabled);
// A completed renderer call may retain its monotonic correlation
- // allocator in the parked session; only the effective setting must
+ // allocator in the background session; only the effective setting must
// collapse back to the default.
assert!(
active
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
.is_none_or(|state| !state.script_execution_disabled),
- "script execution re-enable should clear the staged parked setting: {:#?}",
+ "script execution re-enable should clear the staged background setting: {:#?}",
active
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
@@ -4417,7 +4426,7 @@ async fn same_context_background_session_can_reenable_its_own_script_execution_b
"method": "Page.navigate",
"sessionId": second_session_id,
"params": {
- "url": "data:text/html,<body><script>document.body.dataset.inlineRan='yes'; globalThis.__inlineRan = true;</script>promoted</body>"
+ "url": "data:text/html,<body><script>document.body.dataset.inlineRan='yes'; globalThis.__inlineRan = true;</script>activated</body>"
}
})).await;
let _ = take_response_by_id(&mut ctx, 1041949277);
@@ -4425,18 +4434,18 @@ async fn same_context_background_session_can_reenable_its_own_script_execution_b
ctx.sent
.iter()
.all(|message| message.get("error").is_none()),
- "unexpected protocol error during promoted navigation: {:?}",
+ "unexpected protocol error during activated navigation: {:?}",
ctx.sent
);
ctx.take_all();
{
- let promoted = ctx
+ let activated = ctx
.conn
.browser_context
.as_ref()
- .expect("promoted browser context");
- assert!(!promoted.active_page_target().script_execution_disabled);
+ .expect("activated browser context");
+ assert!(!activated.active_page_target().script_execution_disabled);
}
ctx.process_async(json!({
@@ -4447,19 +4456,19 @@ async fn same_context_background_session_can_reenable_its_own_script_execution_b
"expression": "JSON.stringify({ inlineRan: !!globalThis.__inlineRan, dataset: document.body.dataset.inlineRan || null, runtimeEvalStillWorks: 1 + 1 })"
}
})).await;
- let promoted_eval = take_response_by_id(&mut ctx, 1041949278);
- let promoted_payload = promoted_eval["result"]["result"]["value"]
+ let activated_eval = take_response_by_id(&mut ctx, 1041949278);
+ let activated_payload = activated_eval["result"]["result"]["value"]
.as_str()
- .expect("promoted payload should be string");
- let promoted_payload: serde_json::Value =
- serde_json::from_str(promoted_payload).expect("promoted payload should be valid json");
- assert_eq!(promoted_payload["inlineRan"], json!(true));
- assert_eq!(promoted_payload["dataset"], json!("yes"));
- assert_eq!(promoted_payload["runtimeEvalStillWorks"], json!(2));
+ .expect("activated payload should be string");
+ let activated_payload: serde_json::Value =
+ serde_json::from_str(activated_payload).expect("activated payload should be valid json");
+ assert_eq!(activated_payload["inlineRan"], json!(true));
+ assert_eq!(activated_payload["dataset"], json!("yes"));
+ assert_eq!(activated_payload["runtimeEvalStillWorks"], json!(2));
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_stage_its_own_lifecycle_events_before_promotion() {
+async fn same_context_background_session_can_stage_its_own_lifecycle_events_before_activation() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -4535,7 +4544,7 @@ async fn same_context_background_session_can_stage_its_own_lifecycle_events_befo
let staged = active
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
- .expect("second target should have staged parked page session state");
+ .expect("second target should have staged background page session state");
assert!(
staged.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
.page_session_state
@@ -4565,7 +4574,7 @@ async fn same_context_background_session_can_stage_its_own_lifecycle_events_befo
.iter()
.any(|message| message["method"] == json!("Page.lifecycleEvent")
&& message["sessionId"] == json!("SID-active")),
- "active target should not emit lifecycle events before promotion: {:?}",
+ "active target should not emit lifecycle events before activation: {:?}",
ctx.sent
);
ctx.take_all();
@@ -4591,7 +4600,7 @@ async fn same_context_background_session_can_stage_its_own_lifecycle_events_befo
let _ = take_response_by_id(&mut ctx, 104194936);
crate::testing::wait_until_scheduler_message(
&mut ctx,
- "promoted target networkIdle lifecycle event",
+ "activated target networkIdle lifecycle event",
|message| {
message["method"] == json!("Page.lifecycleEvent")
&& message["sessionId"] == json!(second_session_id)
@@ -4604,7 +4613,7 @@ async fn same_context_background_session_can_stage_its_own_lifecycle_events_befo
ctx.sent
.iter()
.all(|message| message.get("error").is_none()),
- "unexpected protocol error during promoted navigation: {:?}",
+ "unexpected protocol error during activated navigation: {:?}",
ctx.sent
);
@@ -4636,7 +4645,7 @@ async fn same_context_background_session_can_stage_its_own_lifecycle_events_befo
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_disable_its_own_lifecycle_events_before_promotion() {
+async fn same_context_background_session_can_disable_its_own_lifecycle_events_before_activation() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -4715,7 +4724,7 @@ async fn same_context_background_session_can_disable_its_own_lifecycle_events_be
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
.is_none(),
- "lifecycle disable should collapse staged parked state back to default"
+ "lifecycle disable should collapse staged background state back to default"
);
}
@@ -4741,7 +4750,7 @@ async fn same_context_background_session_can_disable_its_own_lifecycle_events_be
.iter()
.any(|message| message["method"] == json!("Page.lifecycleEvent")
&& message["sessionId"] == json!("SID-active")),
- "active target should not emit lifecycle events before promotion: {:?}",
+ "active target should not emit lifecycle events before activation: {:?}",
ctx.sent
);
ctx.take_all();
@@ -4769,7 +4778,7 @@ async fn same_context_background_session_can_disable_its_own_lifecycle_events_be
ctx.sent
.iter()
.all(|message| message.get("error").is_none()),
- "unexpected protocol error during promoted navigation: {:?}",
+ "unexpected protocol error during activated navigation: {:?}",
ctx.sent
);
assert!(
@@ -4778,13 +4787,13 @@ async fn same_context_background_session_can_disable_its_own_lifecycle_events_be
&& message["sessionId"] == json!(second_session_id)
&& message["params"]["frameId"] == json!(second_target_id)
}),
- "disabled lifecycle events should not emit on first promoted navigation: {:?}",
+ "disabled lifecycle events should not emit on first activated navigation: {:?}",
ctx.sent
);
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_stage_its_own_runtime_enable_before_promotion() {
+async fn same_context_background_session_can_stage_its_own_runtime_enable_before_activation() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -4852,7 +4861,7 @@ async fn same_context_background_session_can_stage_its_own_runtime_enable_before
let staged = active
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
- .expect("second target should have staged parked page session state");
+ .expect("second target should have staged background page session state");
assert!(
staged.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
.runtime_session_state
@@ -4881,7 +4890,7 @@ async fn same_context_background_session_can_stage_its_own_runtime_enable_before
!ctx.sent.iter().any(|message| {
message["sessionId"] == json!("SID-active") && is_runtime_context_event(message)
}),
- "active target should not emit runtime context events before promotion: {:?}",
+ "active target should not emit runtime context events before activation: {:?}",
ctx.sent
);
ctx.take_all();
@@ -4909,17 +4918,17 @@ async fn same_context_background_session_can_stage_its_own_runtime_enable_before
ctx.sent
.iter()
.all(|message| message.get("error").is_none()),
- "unexpected protocol error during promoted navigation: {:?}",
+ "unexpected protocol error during activated navigation: {:?}",
ctx.sent
);
let runtime_events = vec![
- ctx.wait_for_scheduler_message("promoted Runtime context reset", |message| {
+ ctx.wait_for_scheduler_message("activated Runtime context reset", |message| {
message["sessionId"] == json!(second_session_id)
&& message["method"] == json!("Runtime.executionContextsCleared")
})
.await,
- ctx.wait_for_scheduler_message("promoted Runtime default context", |message| {
+ ctx.wait_for_scheduler_message("activated Runtime default context", |message| {
message["sessionId"] == json!(second_session_id)
&& message["method"] == json!("Runtime.executionContextCreated")
})
@@ -4928,7 +4937,7 @@ async fn same_context_background_session_can_stage_its_own_runtime_enable_before
assert_eq!(
runtime_events.len(),
2,
- "staged Runtime.enable should use the owner-safe native path after promotion: {runtime_events:?}"
+ "staged Runtime.enable should use the owner-safe native path after activation: {runtime_events:?}"
);
assert_eq!(
runtime_events[0]["method"],
@@ -4949,7 +4958,8 @@ async fn same_context_background_session_can_stage_its_own_runtime_enable_before
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_loaded_background_session_runtime_enable_replays_context_without_promotion() {
+async fn same_context_loaded_background_session_runtime_enable_replays_context_without_activation()
+{
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -5028,7 +5038,7 @@ async fn same_context_loaded_background_session_runtime_enable_replays_context_w
assert!(
bc.background_target(&second_target_id)
.is_some_and(|target| target.has_loaded_page()),
- "second target should be parked with a loaded page before Runtime.enable"
+ "second target should be background with a loaded page before Runtime.enable"
);
}
@@ -5069,7 +5079,7 @@ async fn same_context_loaded_background_session_runtime_enable_replays_context_w
assert_eq!(
bc.active_target_id(),
Some("TID-000000000RDA"),
- "direct Runtime.enable should not promote the loaded background target"
+ "direct Runtime.enable should not activate the loaded background target"
);
assert!(
bc.background_target(&second_target_id)
@@ -5083,7 +5093,7 @@ async fn same_context_loaded_background_session_runtime_enable_replays_context_w
assert!(
bc.background_target(&second_target_id)
.is_some_and(|target| target.has_loaded_page()),
- "direct Runtime.enable should leave the loaded page parked"
+ "direct Runtime.enable should leave the loaded page background"
);
}
}
@@ -5184,7 +5194,7 @@ async fn load_same_context_loaded_background_runtime_owner_async(
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_loaded_background_session_runtime_evaluate_reads_owner_page_without_promotion()
+async fn same_context_loaded_background_session_runtime_evaluate_reads_owner_page_without_activation()
{
let mut ctx = TestContext::new();
let owner = load_same_context_loaded_background_runtime_owner_async(
@@ -5228,17 +5238,17 @@ async fn same_context_loaded_background_session_runtime_evaluate_reads_owner_pag
assert_eq!(
bc.active_target_id(),
Some("TID-000000000REA"),
- "direct Runtime.evaluate should not promote the loaded background target"
+ "direct Runtime.evaluate should not activate the loaded background target"
);
assert!(
bc.background_target(&owner.target_id)
.is_some_and(|target| target.has_loaded_page()),
- "direct Runtime.evaluate should leave the owner page parked"
+ "direct Runtime.evaluate should leave the owner page background"
);
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_loaded_background_window_open_self_navigates_owner_without_promotion() {
+async fn same_context_loaded_background_window_open_self_navigates_owner_without_activation() {
let mut ctx = TestContext::new();
let owner = load_same_context_loaded_background_runtime_owner_async(
&mut ctx,
@@ -5288,11 +5298,11 @@ async fn same_context_loaded_background_window_open_self_navigates_owner_without
assert_eq!(
browser_context.active_target_id(),
Some("TID-000000000PSA"),
- "background _self navigation must not promote the background target"
+ "background _self navigation must not activate the background target"
);
let background_target = browser_context
.background_target(&owner.target_id)
- .expect("background target should remain parked");
+ .expect("background target should remain background");
assert_eq!(
background_target.target_url(),
"data:text/html,<title>self</title><main>self target</main>"
@@ -5317,7 +5327,7 @@ async fn same_context_loaded_background_window_open_self_navigates_owner_without
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_named_popup_reuse_navigates_and_promotes_loaded_owner() {
+async fn same_context_named_popup_reuse_navigates_and_activates_loaded_owner() {
let mut ctx = TestContext::new();
tokio::task::LocalSet::new()
.run_until(async {
@@ -5396,7 +5406,7 @@ async fn same_context_named_popup_reuse_navigates_and_promotes_loaded_owner() {
assert_eq!(
browser_context.active_target_id(),
Some(owner.target_id.as_str()),
- "ordinary window.open should promote its reused named target"
+ "ordinary window.open should activate its reused named target"
);
assert_eq!(
browser_context.target_url(),
@@ -5410,7 +5420,7 @@ async fn same_context_named_popup_reuse_navigates_and_promotes_loaded_owner() {
browser_context
.background_target("TID-000000000NPA")
.is_some(),
- "foreground named-target reuse should demote the previous active target"
+ "foreground named-target reuse should deactivate the previous active target"
);
}
@@ -5430,7 +5440,7 @@ async fn same_context_named_popup_reuse_navigates_and_promotes_loaded_owner() {
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_loaded_background_session_runtime_call_function_on_uses_owner_object_without_promotion()
+async fn same_context_loaded_background_session_runtime_call_function_on_uses_owner_object_without_activation()
{
let mut ctx = TestContext::new();
let owner = load_same_context_loaded_background_runtime_owner_async(
@@ -5480,18 +5490,18 @@ async fn same_context_loaded_background_session_runtime_call_function_on_uses_ow
assert_eq!(
bc.active_target_id(),
Some("TID-000000000RCA"),
- "direct Runtime.callFunctionOn should not promote the loaded background target"
+ "direct Runtime.callFunctionOn should not activate the loaded background target"
);
assert!(
bc.background_target(&owner.target_id)
.is_some_and(|target| target.has_loaded_page()),
- "direct Runtime.callFunctionOn should leave the owner page parked"
+ "direct Runtime.callFunctionOn should leave the owner page background"
);
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_loaded_background_session_runtime_await_promise_uses_owner_without_promotion()
-{
+async fn same_context_loaded_background_session_runtime_await_promise_uses_owner_without_activation()
+ {
let mut ctx = TestContext::new();
let owner = load_same_context_loaded_background_runtime_owner_async(
&mut ctx,
@@ -5556,12 +5566,12 @@ async fn same_context_loaded_background_session_runtime_await_promise_uses_owner
assert_eq!(
bc.active_target_id(),
Some("TID-000000000RWA"),
- "direct Runtime awaitPromise should not promote the loaded background target"
+ "direct Runtime awaitPromise should not activate the loaded background target"
);
assert!(
bc.background_target(&owner.target_id)
.is_some_and(|target| target.has_loaded_page()),
- "direct Runtime awaitPromise should leave the owner page parked"
+ "direct Runtime awaitPromise should leave the owner page background"
);
}
@@ -5695,17 +5705,17 @@ async fn same_context_background_pending_await_survives_active_target_switch() {
assert_eq!(
bc.active_target_id(),
Some("TID-000000000RAS"),
- "pending background awaitPromise completion must not promote the owner target"
+ "pending background awaitPromise completion must not activate the owner target"
);
assert!(
bc.background_target(&owner.target_id)
.is_some_and(|target| target.has_loaded_page()),
- "pending background awaitPromise completion should leave the owner page parked"
+ "pending background awaitPromise completion should leave the owner page background"
);
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_disable_its_own_runtime_before_promotion() {
+async fn same_context_background_session_can_disable_its_own_runtime_before_activation() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -5801,7 +5811,7 @@ async fn same_context_background_session_can_disable_its_own_runtime_before_prom
!ctx.sent.iter().any(|message| {
message["sessionId"] == json!("SID-active") && is_runtime_context_event(message)
}),
- "active target should not emit runtime context events before promotion: {:?}",
+ "active target should not emit runtime context events before activation: {:?}",
ctx.sent
);
ctx.take_all();
@@ -5829,7 +5839,7 @@ async fn same_context_background_session_can_disable_its_own_runtime_before_prom
ctx.sent
.iter()
.all(|message| message.get("error").is_none()),
- "unexpected protocol error during promoted navigation: {:?}",
+ "unexpected protocol error during activated navigation: {:?}",
ctx.sent
);
assert!(
@@ -5841,13 +5851,13 @@ async fn same_context_background_session_can_disable_its_own_runtime_before_prom
| Some("Runtime.executionContextCreated")
)
}),
- "disabled runtime should not emit execution context events on first promoted navigation: {:?}",
+ "disabled runtime should not emit execution context events on first activated navigation: {:?}",
ctx.sent
);
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_stage_its_own_inspector_enable_before_promotion() {
+async fn same_context_background_session_can_stage_its_own_inspector_enable_before_activation() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -5929,7 +5939,7 @@ async fn same_context_background_session_can_stage_its_own_inspector_enable_befo
let staged = active
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
- .expect("second target should have staged parked page session state");
+ .expect("second target should have staged background page session state");
assert!(
staged.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
.runtime_session_state
@@ -5982,7 +5992,7 @@ async fn same_context_background_session_can_stage_its_own_inspector_enable_befo
message["method"] == json!("Inspector.targetReloadedAfterCrash")
&& message["sessionId"] == json!(second_session_id)
}),
- "promoted target should emit crash-reload event when staged inspector is enabled"
+ "activated target should emit crash-reload event when staged inspector is enabled"
);
assert!(
!ctx.conn
@@ -5997,7 +6007,7 @@ async fn same_context_background_session_can_stage_its_own_inspector_enable_befo
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_disable_its_own_inspector_before_promotion() {
+async fn same_context_background_session_can_disable_its_own_inspector_before_activation() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -6074,7 +6084,7 @@ async fn same_context_background_session_can_disable_its_own_inspector_before_pr
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
.is_none(),
- "inspector disable should collapse staged parked state back to default"
+ "inspector disable should collapse staged background state back to default"
);
}
@@ -6113,7 +6123,7 @@ async fn same_context_background_session_can_disable_its_own_inspector_before_pr
Some("Inspector.targetReloadedAfterCrash") | Some("Inspector.targetCrashed")
) && message["sessionId"] == json!(second_session_id)
}),
- "disabled inspector should not emit crash-related events on first promoted navigation"
+ "disabled inspector should not emit crash-related events on first activated navigation"
);
assert!(
!ctx.conn
@@ -6129,7 +6139,7 @@ async fn same_context_background_session_can_disable_its_own_inspector_before_pr
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_stage_its_own_css_enable_before_promotion() {
+async fn same_context_background_session_can_stage_its_own_css_enable_before_activation() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -6191,7 +6201,7 @@ async fn same_context_background_session_can_stage_its_own_css_enable_before_pro
let staged = active
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
- .expect("second target should have staged parked page session state");
+ .expect("second target should have staged background page session state");
assert!(staged.css_enabled);
}
@@ -6208,7 +6218,7 @@ async fn same_context_background_session_can_stage_its_own_css_enable_before_pro
.conn
.browser_context
.as_ref()
- .expect("promoted browser context");
+ .expect("activated browser context");
assert_eq!(active.active_target_id(), Some(second_target_id.as_str()));
assert!(active.active_page_target().css_enabled);
}
@@ -6226,7 +6236,7 @@ async fn same_context_background_session_can_stage_its_own_css_enable_before_pro
ctx.sent
.iter()
.all(|message| message.get("error").is_none()),
- "unexpected protocol error during promoted navigation: {:?}",
+ "unexpected protocol error during activated navigation: {:?}",
ctx.sent
);
assert!(
@@ -6240,7 +6250,7 @@ async fn same_context_background_session_can_stage_its_own_css_enable_before_pro
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_disable_its_own_css_before_promotion() {
+async fn same_context_background_session_can_disable_its_own_css_before_activation() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -6312,7 +6322,7 @@ async fn same_context_background_session_can_disable_its_own_css_before_promotio
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
.is_none(),
- "css disable should collapse staged parked state back to default"
+ "css disable should collapse staged background state back to default"
);
}
@@ -6329,7 +6339,7 @@ async fn same_context_background_session_can_disable_its_own_css_before_promotio
.conn
.browser_context
.as_ref()
- .expect("promoted browser context");
+ .expect("activated browser context");
assert_eq!(active.active_target_id(), Some(second_target_id.as_str()));
assert!(!active.active_page_target().css_enabled);
}
@@ -6347,7 +6357,7 @@ async fn same_context_background_session_can_disable_its_own_css_before_promotio
ctx.sent
.iter()
.all(|message| message.get("error").is_none()),
- "unexpected protocol error during promoted navigation: {:?}",
+ "unexpected protocol error during activated navigation: {:?}",
ctx.sent
);
assert!(
@@ -6361,7 +6371,7 @@ async fn same_context_background_session_can_disable_its_own_css_before_promotio
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_stage_its_own_fetch_enable_before_promotion() {
+async fn same_context_background_session_can_stage_its_own_fetch_enable_before_activation() {
async fn page() -> impl axum::response::IntoResponse {
(
[(axum::http::header::CONTENT_TYPE.as_str(), "text/html")],
@@ -6458,7 +6468,7 @@ async fn same_context_background_session_can_stage_its_own_fetch_enable_before_p
let staged = active
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
- .expect("second target should have staged parked page session state");
+ .expect("second target should have staged background page session state");
assert!(staged.fetch_owner.config_snapshot().is_enabled());
assert_eq!(staged.fetch_owner.config_snapshot().patterns().len(), 1);
assert_eq!(
@@ -6537,7 +6547,7 @@ async fn same_context_background_session_can_stage_its_own_fetch_enable_before_p
ctx.sent
.iter()
.all(|message| message.get("error").is_none()),
- "unexpected protocol error during promoted navigation: {:?}",
+ "unexpected protocol error during activated navigation: {:?}",
ctx.sent
);
@@ -6545,11 +6555,11 @@ async fn same_context_background_session_can_stage_its_own_fetch_enable_before_p
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_fetch_continue_request_keeps_target_parked() {
+async fn same_context_background_fetch_continue_request_keeps_target_background() {
async fn page() -> impl axum::response::IntoResponse {
(
[(axum::http::header::CONTENT_TYPE.as_str(), "text/html")],
- "<!doctype html><html><body>fetch-continue-parked</body></html>",
+ "<!doctype html><html><body>fetch-continue-background</body></html>",
)
}
@@ -6653,7 +6663,7 @@ async fn same_context_background_fetch_continue_request_keeps_target_parked() {
.fetch_owner
.pending_state()
.has_pending_fetch_navigation(),
- "background fetch pause should stay parked before continueRequest"
+ "background fetch pause should stay background before continueRequest"
);
}
@@ -6681,7 +6691,7 @@ async fn same_context_background_fetch_continue_request_keeps_target_parked() {
active
.background_target(&second_target_id)
.is_some_and(|target| target.has_loaded_page()),
- "continued background navigation should commit to parked owner"
+ "continued background navigation should commit to background owner"
);
}
@@ -6689,7 +6699,7 @@ async fn same_context_background_fetch_continue_request_keeps_target_parked() {
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_stage_its_own_fetch_auth_handling_before_promotion() {
+async fn same_context_background_session_can_stage_its_own_fetch_auth_handling_before_activation() {
async fn page() -> impl axum::response::IntoResponse {
(
[(axum::http::header::CONTENT_TYPE.as_str(), "text/html")],
@@ -6796,7 +6806,7 @@ async fn same_context_background_session_can_stage_its_own_fetch_auth_handling_b
let staged = active
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
- .expect("second target should have staged parked page session state");
+ .expect("second target should have staged background page session state");
assert!(staged.fetch_owner.config_snapshot().is_enabled());
assert!(staged.fetch_owner.config_snapshot().handle_auth_requests());
}
@@ -6888,7 +6898,7 @@ async fn same_context_background_session_can_stage_its_own_fetch_auth_handling_b
ctx.sent
.iter()
.all(|message| message.get("error").is_none()),
- "unexpected protocol error during promoted auth navigation: {:?}",
+ "unexpected protocol error during activated auth navigation: {:?}",
ctx.sent
);
@@ -6896,7 +6906,7 @@ async fn same_context_background_session_can_stage_its_own_fetch_auth_handling_b
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_disable_its_own_fetch_before_promotion() {
+async fn same_context_background_session_can_disable_its_own_fetch_before_activation() {
async fn page() -> impl axum::response::IntoResponse {
(
[(axum::http::header::CONTENT_TYPE.as_str(), "text/html")],
@@ -7003,7 +7013,7 @@ async fn same_context_background_session_can_disable_its_own_fetch_before_promot
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
.is_none(),
- "fetch disable should collapse staged parked state back to default"
+ "fetch disable should collapse staged background state back to default"
);
}
@@ -7052,14 +7062,14 @@ async fn same_context_background_session_can_disable_its_own_fetch_before_promot
ctx.sent
.iter()
.all(|message| message.get("error").is_none()),
- "unexpected protocol error during promoted navigation: {:?}",
+ "unexpected protocol error during activated navigation: {:?}",
ctx.sent
);
assert!(
!ctx.sent
.iter()
.any(|message| message["method"] == json!("Fetch.requestPaused")),
- "disabled fetch should not pause first promoted navigation: {:?}",
+ "disabled fetch should not pause first activated navigation: {:?}",
ctx.sent
);
@@ -7067,7 +7077,7 @@ async fn same_context_background_session_can_disable_its_own_fetch_before_promot
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_stage_its_own_network_enable_before_promotion() {
+async fn same_context_background_session_can_stage_its_own_network_enable_before_activation() {
async fn page() -> impl axum::response::IntoResponse {
(
[(axum::http::header::CONTENT_TYPE.as_str(), "text/html")],
@@ -7153,7 +7163,7 @@ async fn same_context_background_session_can_stage_its_own_network_enable_before
let staged = active
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
- .expect("second target should have staged parked page session state");
+ .expect("second target should have staged background page session state");
assert!(staged.runtime_slot.primary_network_events_enabled());
}
@@ -7176,7 +7186,7 @@ async fn same_context_background_session_can_stage_its_own_network_enable_before
!ctx.sent
.iter()
.any(|message| message["method"] == json!("Network.requestWillBeSent")),
- "active target should not emit network events before promotion: {:?}",
+ "active target should not emit network events before activation: {:?}",
ctx.sent
);
ctx.take_all();
@@ -7204,7 +7214,7 @@ async fn same_context_background_session_can_stage_its_own_network_enable_before
ctx.sent
.iter()
.all(|message| message.get("error").is_none()),
- "unexpected protocol error during promoted navigation: {:?}",
+ "unexpected protocol error during activated navigation: {:?}",
ctx.sent
);
@@ -7212,7 +7222,7 @@ async fn same_context_background_session_can_stage_its_own_network_enable_before
&mut ctx,
&second_session_id,
&page_url,
- "promoted session main-document network completion",
+ "activated session main-document network completion",
)
.await;
let emitted = ctx.take_all();
@@ -7224,7 +7234,7 @@ async fn same_context_background_session_can_stage_its_own_network_enable_before
&& message["params"]["request"]["url"] == json!(page_url)
})
.cloned()
- .expect("promoted target should emit requestWillBeSent");
+ .expect("activated target should emit requestWillBeSent");
let request_id = request["params"]["requestId"]
.as_str()
.expect("request id")
@@ -7239,7 +7249,7 @@ async fn same_context_background_session_can_stage_its_own_network_enable_before
&& message["params"]["requestId"] == json!(request_id)
})
.cloned()
- .expect("promoted target should emit responseReceived");
+ .expect("activated target should emit responseReceived");
assert_eq!(response["params"]["response"]["url"], json!(page_url));
assert_eq!(response["params"]["response"]["status"], json!(200));
@@ -7253,7 +7263,7 @@ async fn same_context_background_session_can_stage_its_own_network_enable_before
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_disable_its_own_network_before_promotion() {
+async fn same_context_background_session_can_disable_its_own_network_before_activation() {
async fn page() -> impl axum::response::IntoResponse {
(
[(axum::http::header::CONTENT_TYPE.as_str(), "text/html")],
@@ -7349,7 +7359,7 @@ async fn same_context_background_session_can_disable_its_own_network_before_prom
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
.is_none(),
- "network disable should collapse staged parked state back to default"
+ "network disable should collapse staged background state back to default"
);
assert!(
active
@@ -7357,7 +7367,7 @@ async fn same_context_background_session_can_disable_its_own_network_before_prom
.expect("background target")
.runtime_slot
.network_artifacts_are_default_for_test(),
- "network disable should clear staged parked network artifacts"
+ "network disable should clear staged background network artifacts"
);
}
@@ -7385,7 +7395,7 @@ async fn same_context_background_session_can_disable_its_own_network_before_prom
| Some("Network.loadingFinished")
)
}),
- "active target should not emit network events before promotion: {:?}",
+ "active target should not emit network events before activation: {:?}",
ctx.sent
);
ctx.take_all();
@@ -7411,7 +7421,7 @@ async fn same_context_background_session_can_disable_its_own_network_before_prom
ctx.sent
.iter()
.all(|message| message.get("error").is_none()),
- "unexpected protocol error during promoted navigation: {:?}",
+ "unexpected protocol error during activated navigation: {:?}",
ctx.sent
);
assert!(
@@ -7424,7 +7434,7 @@ async fn same_context_background_session_can_disable_its_own_network_before_prom
| Some("Network.loadingFinished")
)
}),
- "disabled network should not emit first-navigation network events after promotion: {:?}",
+ "disabled network should not emit first-navigation network events after activation: {:?}",
ctx.sent
);
@@ -7432,7 +7442,7 @@ async fn same_context_background_session_can_disable_its_own_network_before_prom
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_stage_its_own_cache_and_service_worker_policy_before_promotion()
+async fn same_context_background_session_can_stage_its_own_cache_and_service_worker_policy_before_activation()
{
async fn page() -> impl axum::response::IntoResponse {
(
@@ -7556,7 +7566,7 @@ async fn same_context_background_session_can_stage_its_own_cache_and_service_wor
let staged = active
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
- .expect("second target should have staged parked page session state");
+ .expect("second target should have staged background page session state");
assert!(staged.runtime_slot.primary_network_events_enabled());
assert!(staged.effective_policy().cache_disabled());
assert!(staged.effective_policy().bypass_service_worker());
@@ -7581,7 +7591,7 @@ async fn same_context_background_session_can_stage_its_own_cache_and_service_wor
!ctx.sent
.iter()
.any(|message| message["method"] == json!("Network.requestWillBeSent")),
- "active target should not emit network events before promotion: {:?}",
+ "active target should not emit network events before activation: {:?}",
ctx.sent
);
ctx.take_all();
@@ -7600,7 +7610,7 @@ async fn same_context_background_session_can_stage_its_own_cache_and_service_wor
.conn
.browser_context
.as_ref()
- .expect("promoted browser context");
+ .expect("activated browser context");
assert_eq!(bc.active_target_id(), Some(second_target_id.as_str()));
assert!(
bc.active_page_target()
@@ -7629,7 +7639,7 @@ async fn same_context_background_session_can_stage_its_own_cache_and_service_wor
ctx.sent
.iter()
.all(|message| message.get("error").is_none()),
- "unexpected protocol error during promoted navigation: {:?}",
+ "unexpected protocol error during activated navigation: {:?}",
ctx.sent
);
@@ -7637,7 +7647,7 @@ async fn same_context_background_session_can_stage_its_own_cache_and_service_wor
&mut ctx,
&second_session_id,
&page_url,
- "promoted session main-document completion with staged network policy",
+ "activated session main-document completion with staged network policy",
)
.await;
let emitted = ctx.take_all();
@@ -7649,7 +7659,7 @@ async fn same_context_background_session_can_stage_its_own_cache_and_service_wor
&& message["params"]["request"]["url"] == json!(page_url)
})
.cloned()
- .expect("promoted target should emit requestWillBeSent");
+ .expect("activated target should emit requestWillBeSent");
let request_id = request["params"]["requestId"]
.as_str()
.expect("request id")
@@ -7670,7 +7680,7 @@ async fn same_context_background_session_can_stage_its_own_cache_and_service_wor
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_background_session_can_disable_its_own_cache_and_service_worker_policy_before_promotion()
+async fn same_context_background_session_can_disable_its_own_cache_and_service_worker_policy_before_activation()
{
async fn page() -> impl axum::response::IntoResponse {
(
@@ -7812,7 +7822,7 @@ async fn same_context_background_session_can_disable_its_own_cache_and_service_w
let staged = active
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
- .expect("second target should have staged parked page session state");
+ .expect("second target should have staged background page session state");
assert!(staged.runtime_slot.primary_network_events_enabled());
assert!(!staged.effective_policy().cache_disabled());
assert!(!staged.effective_policy().bypass_service_worker());
@@ -7837,7 +7847,7 @@ async fn same_context_background_session_can_disable_its_own_cache_and_service_w
!ctx.sent
.iter()
.any(|message| message["method"] == json!("Network.requestWillBeSent")),
- "active target should not emit network events before promotion: {:?}",
+ "active target should not emit network events before activation: {:?}",
ctx.sent
);
ctx.take_all();
@@ -7856,7 +7866,7 @@ async fn same_context_background_session_can_disable_its_own_cache_and_service_w
.conn
.browser_context
.as_ref()
- .expect("promoted browser context");
+ .expect("activated browser context");
assert_eq!(bc.active_target_id(), Some(second_target_id.as_str()));
assert!(
bc.active_page_target()
@@ -7885,7 +7895,7 @@ async fn same_context_background_session_can_disable_its_own_cache_and_service_w
ctx.sent
.iter()
.all(|message| message.get("error").is_none()),
- "unexpected protocol error during promoted navigation: {:?}",
+ "unexpected protocol error during activated navigation: {:?}",
ctx.sent
);
@@ -7893,7 +7903,7 @@ async fn same_context_background_session_can_disable_its_own_cache_and_service_w
&mut ctx,
&second_session_id,
&page_url,
- "promoted session main-document completion after staged policy reset",
+ "activated session main-document completion after staged policy reset",
)
.await;
let emitted = ctx.take_all();
@@ -7905,7 +7915,7 @@ async fn same_context_background_session_can_disable_its_own_cache_and_service_w
&& message["params"]["request"]["url"] == json!(page_url)
})
.cloned()
- .expect("promoted target should still emit requestWillBeSent");
+ .expect("activated target should still emit requestWillBeSent");
let request_id = request["params"]["requestId"]
.as_str()
.expect("request id")
diff --git a/moli-protocol/src/domains/target/tests/tests_cdp_chromium_imports/p1_target_contexts.rs b/moli-protocol/src/domains/target/tests/tests_cdp_chromium_imports/p1_target_contexts.rs
index 00dac7332..44a970f11 100644
--- a/moli-protocol/src/domains/target/tests/tests_cdp_chromium_imports/p1_target_contexts.rs
+++ b/moli-protocol/src/domains/target/tests/tests_cdp_chromium_imports/p1_target_contexts.rs
@@ -259,7 +259,7 @@ async fn rust_cdp_chromium_target_dispose_inactive_context_preserves_active_cont
// Chromium source:
// third_party/blink/web_tests/http/tests/inspector-protocol/target/target-browser-context.js
#[tokio::test(flavor = "multi_thread")]
-async fn rust_cdp_chromium_target_dispose_active_context_promotes_remaining_context() {
+async fn rust_cdp_chromium_target_dispose_active_context_activates_remaining_context() {
let mut ctx = TestContext::new_with_target_discovery(false);
let first_id = create_browser_context(&mut ctx, 261_013).await;
let second_id = create_browser_context(&mut ctx, 261_014).await;
@@ -542,7 +542,7 @@ async fn rust_cdp_chromium_target_get_targets_lists_context_ids_for_multiple_con
#[tokio::test(flavor = "multi_thread")]
async fn rust_cdp_chromium_target_popup_target_keeps_opener_browser_context_id() {
let mut ctx = TestContext::new_with_target_discovery(false);
- // Chromium creates the auxiliary browsing context and returns from the
+ // Chromium creates the attached browsing context and returns from the
// causing Runtime command before the popup's requested URL finishes
// loading. Use the production scheduler boundary here: leaving this test
// on TestContext's legacy inline-navigation mode makes an unrelated
diff --git a/moli-protocol/src/domains/target/tests/tests_cdp_chromium_imports/p1_target_multipage.rs b/moli-protocol/src/domains/target/tests/tests_cdp_chromium_imports/p1_target_multipage.rs
index 370633906..2ac869d7a 100644
--- a/moli-protocol/src/domains/target/tests/tests_cdp_chromium_imports/p1_target_multipage.rs
+++ b/moli-protocol/src/domains/target/tests/tests_cdp_chromium_imports/p1_target_multipage.rs
@@ -154,7 +154,7 @@ async fn rust_cdp_chromium_target_set_auto_attach_true_records_global_policy() {
set_auto_attach(&mut ctx, 260_003, true).await;
- assert!(ctx.conn.auto_attach);
+ assert!(ctx.conn.auto_attach_enabled());
}
// Chromium source:
@@ -162,11 +162,16 @@ async fn rust_cdp_chromium_target_set_auto_attach_true_records_global_policy() {
#[tokio::test(flavor = "multi_thread")]
async fn rust_cdp_chromium_target_set_auto_attach_false_records_global_policy() {
let mut ctx = TestContext::new_with_target_discovery(false);
- ctx.conn.auto_attach = true;
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
set_auto_attach(&mut ctx, 260_004, false).await;
- assert!(!ctx.conn.auto_attach);
+ assert!(!ctx.conn.auto_attach_enabled());
}
// Chromium source:
@@ -1381,7 +1386,14 @@ async fn rust_cdp_chromium_target_auto_attach_false_detaches_active_session() {
.as_mut()
.unwrap()
.attach_active_session("SID-active");
- ctx.conn.auto_attach = true;
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
+ ctx.conn
+ .register_auto_attached_session("SID-active".to_owned(), None);
set_auto_attach(&mut ctx, 260_035, false).await;
let detached = ctx.take_one();
@@ -1398,7 +1410,14 @@ async fn rust_cdp_chromium_target_auto_attach_false_detaches_background_session(
let mut ctx = TestContext::new_with_target_discovery(false);
load_bc_with_target(&mut ctx, "BID-detach-bg", "TID-active");
push_background_target(&mut ctx, "TID-background", "about:blank#bg", Some("SID-bg"));
- ctx.conn.auto_attach = true;
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
+ ctx.conn
+ .register_auto_attached_session("SID-bg".to_owned(), None);
set_auto_attach(&mut ctx, 260_036, false).await;
let detached = ctx.take_one();
@@ -1435,8 +1454,7 @@ async fn rust_cdp_chromium_target_attach_to_browser_target_emits_browser_target(
// Chromium source:
// third_party/blink/web_tests/http/tests/inspector-protocol/target/browser-auto-attach-tab.js
#[tokio::test(flavor = "multi_thread")]
-async fn rust_cdp_chromium_target_attach_to_target_from_browser_session_creates_auxiliary_session()
-{
+async fn rust_cdp_chromium_target_attach_to_target_from_browser_session_creates_attached_session() {
let mut ctx = TestContext::new_with_target_discovery(false);
let browser_context_id = create_browser_context(&mut ctx, 260_038).await;
let target_id =
@@ -1607,7 +1625,7 @@ async fn rust_cdp_chromium_target_close_background_target_detaches_sessions() {
.browser_context
.as_mut()
.unwrap()
- .assign_auxiliary_session_to_target("TID-background", "SID-aux".into())
+ .assign_attached_session_to_target("TID-background", "SID-attached".into())
);
ctx.process_async(json!({
@@ -1643,7 +1661,7 @@ async fn rust_cdp_chromium_target_close_background_target_detaches_sessions() {
// Chromium source:
// third_party/blink/web_tests/http/tests/inspector-protocol/target/tab-target.js
#[tokio::test(flavor = "multi_thread")]
-async fn rust_cdp_chromium_target_activate_background_target_promotes_it() {
+async fn rust_cdp_chromium_target_activate_background_target_activates_it() {
let mut ctx = TestContext::new_with_target_discovery(false);
load_bc_with_target(&mut ctx, "BID-activate", "TID-active");
push_background_target(
diff --git a/moli-protocol/src/domains/target/tests/tests_cdp_smoke_playwright.rs b/moli-protocol/src/domains/target/tests/tests_cdp_smoke_playwright.rs
index cac82b1bd..52ff988a0 100644
--- a/moli-protocol/src/domains/target/tests/tests_cdp_smoke_playwright.rs
+++ b/moli-protocol/src/domains/target/tests/tests_cdp_smoke_playwright.rs
@@ -525,7 +525,7 @@ async fn rust_cdp_playwright_cdp_session_runtime_error_and_detach_contracts() {
}
#[tokio::test(flavor = "multi_thread")]
-async fn rust_cdp_playwright_auxiliary_session_network_event_contract() {
+async fn rust_cdp_playwright_attached_session_network_event_contract() {
let fixture = SmokeFixtureServer::start().await;
let mut ctx = TestContext::new();
let attached = attached_smoke_session(&mut ctx, 86_000).await;
@@ -554,7 +554,7 @@ async fn rust_cdp_playwright_auxiliary_session_network_event_contract() {
.await;
let aux_session_id = take_response_by_id(&mut ctx, 86_006)["result"]["sessionId"]
.as_str()
- .expect("auxiliary session")
+ .expect("attached session")
.to_owned();
assert_ne!(aux_session_id, attached.session_id);
ctx.expect_event("Target.attachedToTarget", None);
@@ -583,7 +583,7 @@ async fn rust_cdp_playwright_auxiliary_session_network_event_contract() {
.as_str()
.is_some_and(|url| url.ends_with("/plain?playwright-cdp-event"))
}),
- "auxiliary session should receive Network.requestWillBeSent: {:?}",
+ "attached session should receive Network.requestWillBeSent: {:?}",
ctx.sent
);
}
@@ -878,13 +878,14 @@ async fn queued_popup_navigation_rechecks_a_late_debugger_barrier() {
);
let late_session_id = "SID-late-debugger".to_owned();
- assert!(
- ctx.conn
- .prepare_auto_attached_page_session_binding(&popup_target_id, late_session_id.clone(),)
- );
- let prepared = ctx.conn.prepare_auto_attach_session_commit(
+ let route = ctx
+ .conn
+ .prepare_auto_attached_page_session_binding(&popup_target_id, late_session_id.clone())
+ .expect("popup target must remain addressable");
+ let prepared = crate::conn::TargetAttachSessionCommit::auto_attached(
late_session_id,
Some(opener.session_id.clone()),
+ route,
true,
);
let target_info = ctx
diff --git a/moli-protocol/src/domains/target/tests/tests_control_plane.rs b/moli-protocol/src/domains/target/tests/tests_control_plane.rs
index 6e03aa3fa..b9e862cf2 100644
--- a/moli-protocol/src/domains/target/tests/tests_control_plane.rs
+++ b/moli-protocol/src/domains/target/tests/tests_control_plane.rs
@@ -19,7 +19,7 @@ fn take_created_target_id(ctx: &mut TestContext, command_id: u64, description: &
}
#[tokio::test(flavor = "multi_thread")]
-async fn activate_target_promotes_background_target_when_active_target_has_no_loaded_page() {
+async fn activate_target_activates_background_target_when_active_target_has_no_loaded_page() {
let mut ctx = TestContext::new();
load_bc_with_target(&mut ctx, "BID-9", "TID-000000000A");
ctx.conn
@@ -111,7 +111,7 @@ async fn activate_target_handoffs_loaded_page_runtime_and_restores_it_when_switc
bc.background_target("TID-000000000A")
.and_then(|target| target.loaded_page())
.is_some(),
- "the previously active target should keep its loaded page runtime while backgrounded"
+ "the previously active target should keep its loaded page runtime in the background"
);
ctx.process_async(json!({
@@ -147,7 +147,7 @@ async fn activate_target_handoffs_loaded_page_runtime_and_restores_it_when_switc
bc.background_target(&second_target_id)
.and_then(|target| target.loaded_page())
.is_some(),
- "the demoted second target should now keep its loaded page runtime while backgrounded"
+ "the deactivated second target should now keep its loaded page runtime in the background"
);
ctx.process_async(json!({
@@ -479,13 +479,13 @@ async fn activate_target_chain_restores_multiple_loaded_page_runtimes_without_re
bc.background_target("TID-000000000A")
.and_then(|target| target.loaded_page())
.is_some(),
- "first target runtime should stay parked in the background",
+ "first target runtime should stay background in the background",
);
assert!(
bc.background_target(&second_target_id)
.and_then(|target| target.loaded_page())
.is_some(),
- "second target runtime should stay parked in the background",
+ "second target runtime should stay background in the background",
);
ctx.process_async(json!({
@@ -565,7 +565,7 @@ async fn activate_target_chain_restores_multiple_loaded_page_runtimes_without_re
}
#[tokio::test(flavor = "multi_thread")]
-async fn activate_target_then_attach_can_navigate_on_promoted_target_without_loaded_page() {
+async fn activate_target_then_attach_can_navigate_on_activated_target_without_loaded_page() {
let mut ctx = TestContext::new();
load_bc_with_target(&mut ctx, "BID-9", "TID-000000000A");
ctx.conn
@@ -597,7 +597,7 @@ async fn activate_target_then_attach_can_navigate_on_promoted_target_without_loa
.await;
let session_id = take_response_by_id(&mut ctx, 1807)["result"]["sessionId"]
.as_str()
- .expect("promoted target session id")
+ .expect("activated target session id")
.to_owned();
ctx.expect_event("Target.attachedToTarget", None);
@@ -725,6 +725,50 @@ async fn detach_from_target_error_restores_previously_active_context() {
);
}
+#[tokio::test(flavor = "multi_thread")]
+async fn detach_from_inactive_context_cleans_exact_session_without_activating_context() {
+ let mut ctx = TestContext::new();
+ load_bc_with_target(&mut ctx, "BID-A", "TID-A");
+ let mut inactive = BrowserContext::new_with_page_for_test("BID-B", "TID-B");
+ inactive.attach_active_session("SID-B");
+ ctx.conn.inactive_browser_contexts.push(inactive);
+ ctx.conn
+ .register_auto_attached_session_for_target("SID-B".to_owned(), None, Some("TID-B"));
+ ctx.conn
+ .set_service_worker_pause_on_start_owner(Some("SID-B"), true);
+ ctx.conn
+ .set_dedicated_worker_pause_on_start_owner(Some("SID-B"), true);
+
+ ctx.process_async(json!({
+ "id": 1503,
+ "method": "Target.detachFromTarget",
+ "params": { "sessionId": "SID-B" }
+ }))
+ .await;
+
+ ctx.expect_result(1503, json!({}), None);
+ ctx.expect_event(
+ "Target.detachedFromTarget",
+ Some(&json!({
+ "sessionId": "SID-B",
+ "targetId": "TID-B",
+ })),
+ );
+ assert_eq!(
+ ctx.conn.browser_context.as_ref().map(|bc| bc.id.as_str()),
+ Some("BID-A"),
+ "disposing another context's session must not change the active context"
+ );
+ assert!(
+ ctx.conn
+ .browser_context_by_id("BID-B")
+ .is_some_and(|context| !context.has_active_session()),
+ "the exact inactive-context binding must be disposed"
+ );
+ assert!(!ctx.conn.service_worker_pause_on_start_for_devtools());
+ assert!(!ctx.conn.dedicated_worker_pause_on_start_for_devtools());
+}
+
#[tokio::test(flavor = "multi_thread")]
async fn detach_from_target_aborts_paused_request_stage_navigation() {
async fn page() -> impl axum::response::IntoResponse {
@@ -925,16 +969,16 @@ async fn same_context_targets_keep_paused_fetch_state_target_local_after_switchi
!bc.active_page_target()
.fetch_owner
.has_pending_fetch_state_for_test(),
- "promoted target should not see another target's pending fetch ids",
+ "activated target should not see another target's pending fetch ids",
);
- let parked = bc
+ let background = bc
.background_target(&first_target_id)
.expect("background target must exist")
.fetch_owner
.pending_state();
assert!(
- parked.has_pending_fetch_request_id_for_test(&request_id),
- "first target pending fetch id should move with parked target state",
+ background.has_pending_fetch_request_id_for_test(&request_id),
+ "first target pending fetch id should move with background target state",
);
}
@@ -1141,8 +1185,8 @@ async fn set_auto_attach_true_attaches_existing_background_targets() {
}
#[tokio::test(flavor = "multi_thread")]
-async fn set_auto_attach_promotes_existing_background_target_when_active_target_has_no_loaded_page()
-{
+async fn set_auto_attach_activates_existing_background_target_when_active_target_has_no_loaded_page()
+ {
let mut ctx = TestContext::new();
load_bc_with_target(&mut ctx, "BID-9", "TID-000000000E");
ctx.conn
@@ -1191,7 +1235,7 @@ async fn set_auto_attach_promotes_existing_background_target_when_active_target_
bc.background_target("TID-000000000E")
.and_then(|target| target.session_id()),
Some("SID-1"),
- "the old active target should be demoted into the background with its newly attached session",
+ "the old active target should be deactivated into the background with its newly attached session",
);
ctx.process_async(json!({
@@ -1199,7 +1243,7 @@ async fn set_auto_attach_promotes_existing_background_target_when_active_target_
"method": "Page.navigate",
"sessionId": session_id,
"params": {
- "url": "data:text/html,<title>autoattach-sweep-promoted</title><div id='ok'>setAutoAttach sweep promoted target</div>"
+ "url": "data:text/html,<title>autoattach-sweep-activated</title><div id='ok'>setAutoAttach sweep activated target</div>"
}
})).await;
consume_main_document_navigation_start(&mut ctx);
@@ -1221,15 +1265,15 @@ async fn set_auto_attach_promotes_existing_background_target_when_active_target_
.expect("evaluation payload should be a string");
let payload: serde_json::Value =
serde_json::from_str(payload).expect("evaluation payload should be valid json");
- assert_eq!(payload["title"], json!("autoattach-sweep-promoted"));
+ assert_eq!(payload["title"], json!("autoattach-sweep-activated"));
assert_eq!(
payload["text"],
- json!("setAutoAttach sweep promoted target")
+ json!("setAutoAttach sweep activated target")
);
}
#[tokio::test(flavor = "multi_thread")]
-async fn set_auto_attach_sweep_chain_promotes_multiple_existing_background_targets_into_runtime() {
+async fn set_auto_attach_sweep_chain_activates_multiple_existing_background_targets_into_runtime() {
let mut ctx = TestContext::new();
load_bc_with_target(&mut ctx, "BID-9", "TID-000000000E");
let bc = ctx.conn.browser_context.as_mut().unwrap();
@@ -1298,7 +1342,7 @@ async fn set_auto_attach_sweep_chain_promotes_multiple_existing_background_targe
"method": "Page.navigate",
"sessionId": second_session_id,
"params": {
- "url": "data:text/html,<title>sweep-second-promoted</title><div id='ok'>second sweep promoted target</div>"
+ "url": "data:text/html,<title>sweep-second-activated</title><div id='ok'>second sweep activated target</div>"
}
})).await;
consume_main_document_navigation_start(&mut ctx);
@@ -1330,7 +1374,7 @@ async fn set_auto_attach_sweep_chain_promotes_multiple_existing_background_targe
"method": "Page.navigate",
"sessionId": third_session_id,
"params": {
- "url": "data:text/html,<title>sweep-third-promoted</title><div id='ok'>third sweep promoted target</div>"
+ "url": "data:text/html,<title>sweep-third-activated</title><div id='ok'>third sweep activated target</div>"
}
})).await;
consume_main_document_navigation_start(&mut ctx);
@@ -1355,12 +1399,12 @@ async fn set_auto_attach_sweep_chain_promotes_multiple_existing_background_targe
.expect("evaluation payload should be a string");
let payload: serde_json::Value =
serde_json::from_str(payload).expect("evaluation payload should be valid json");
- assert_eq!(payload["title"], json!("sweep-third-promoted"));
- assert_eq!(payload["text"], json!("third sweep promoted target"));
+ assert_eq!(payload["title"], json!("sweep-third-activated"));
+ assert_eq!(payload["text"], json!("third sweep activated target"));
}
#[tokio::test(flavor = "multi_thread")]
-async fn set_auto_attach_prefers_existing_background_target_with_parked_loaded_runtime() {
+async fn set_auto_attach_prefers_existing_background_target_with_background_loaded_runtime() {
let mut ctx = TestContext::new();
load_bc_with_target(&mut ctx, "BID-9", "TID-000000000E");
{
@@ -1378,12 +1422,12 @@ async fn set_auto_attach_prefers_existing_background_target_with_parked_loaded_r
bc.stage_foreground_target(
"TID-0000000010".into(),
None,
- "about:blank#parked".into(),
+ "about:blank#background".into(),
Some("about:blank".into()),
);
}
ctx.install_navigation_fixture_for_session_owner(
- "data:text/html,<title>parked</title><div id='ok'>parked runtime</div>",
+ "data:text/html,<title>background</title><div id='ok'>background runtime</div>",
None,
)
.await;
@@ -1395,7 +1439,7 @@ async fn set_auto_attach_prefers_existing_background_target_with_parked_loaded_r
.select_page_target_async("TID-000000000E")
.await
.expect("restoring the original active target should succeed"),
- "the original active target should remain parked during fixture setup"
+ "the original active target should remain background during fixture setup"
);
ctx.process_async(json!({
@@ -1421,21 +1465,21 @@ async fn set_auto_attach_prefers_existing_background_target_with_parked_loaded_r
.as_str()
.expect("metadata-only background session id")
.to_owned();
- let parked_attached = events
+ let background_attached = events
.iter()
.find(|event| {
event["method"] == json!("Target.attachedToTarget")
&& event["params"]["targetInfo"]["targetId"] == json!("TID-0000000010")
})
- .expect("background attached event for parked target");
- let parked_session_id = parked_attached["params"]["sessionId"]
+ .expect("background attached event for background target");
+ let background_session_id = background_attached["params"]["sessionId"]
.as_str()
- .expect("parked background session id")
+ .expect("background target session id")
.to_owned();
let bc = ctx.conn.browser_context.as_ref().unwrap();
assert_eq!(bc.active_target_id(), Some("TID-0000000010"));
- assert_eq!(bc.active_session_id(), Some(parked_session_id.as_str()));
+ assert_eq!(bc.active_session_id(), Some(background_session_id.as_str()));
assert_eq!(
bc.background_target("TID-000000000F")
.and_then(|target| target.session_id()),
@@ -1450,7 +1494,7 @@ async fn set_auto_attach_prefers_existing_background_target_with_parked_loaded_r
ctx.process_async(json!({
"id": 17024,
"method": "Runtime.evaluate",
- "sessionId": parked_session_id,
+ "sessionId": background_session_id,
"params": {
"expression": "JSON.stringify({ title: document.title, text: document.getElementById('ok').textContent })"
}
@@ -1461,12 +1505,12 @@ async fn set_auto_attach_prefers_existing_background_target_with_parked_loaded_r
.expect("evaluation payload should be a string");
let payload: serde_json::Value =
serde_json::from_str(payload).expect("evaluation payload should be valid json");
- assert_eq!(payload["title"], json!("parked"));
- assert_eq!(payload["text"], json!("parked runtime"));
+ assert_eq!(payload["title"], json!("background"));
+ assert_eq!(payload["text"], json!("background runtime"));
}
#[tokio::test(flavor = "multi_thread")]
-async fn activate_target_promotes_set_auto_attach_background_session_into_page_runtime() {
+async fn activate_target_activates_set_auto_attach_background_session_into_page_runtime() {
let mut ctx = TestContext::new();
load_bc_with_target(&mut ctx, "BID-9", "TID-000000000E");
ctx.conn
@@ -1521,7 +1565,7 @@ async fn activate_target_promotes_set_auto_attach_background_session_into_page_r
"method": "Page.navigate",
"sessionId": session_id,
"params": {
- "url": "data:text/html,<title>autoattach-activated</title><div id='ok'>setAutoAttach promoted target</div>"
+ "url": "data:text/html,<title>autoattach-activated</title><div id='ok'>setAutoAttach activated target</div>"
}
})).await;
consume_main_document_navigation_start(&mut ctx);
@@ -1544,7 +1588,7 @@ async fn activate_target_promotes_set_auto_attach_background_session_into_page_r
let payload: serde_json::Value =
serde_json::from_str(payload).expect("evaluation payload should be valid json");
assert_eq!(payload["title"], json!("autoattach-activated"));
- assert_eq!(payload["text"], json!("setAutoAttach promoted target"));
+ assert_eq!(payload["text"], json!("setAutoAttach activated target"));
}
#[tokio::test(flavor = "multi_thread")]
@@ -1614,7 +1658,7 @@ async fn activate_target_chain_switches_between_multiple_attached_background_tar
"method": "Page.navigate",
"sessionId": "SID-third",
"params": {
- "url": "data:text/html,<title>activate-chain-promoted</title><div id='ok'>activate chain promoted target</div>"
+ "url": "data:text/html,<title>activate-chain-activated</title><div id='ok'>activate chain activated target</div>"
}
})).await;
consume_main_document_navigation_start(&mut ctx);
@@ -1636,8 +1680,8 @@ async fn activate_target_chain_switches_between_multiple_attached_background_tar
.expect("evaluation payload should be a string");
let payload: serde_json::Value =
serde_json::from_str(payload).expect("evaluation payload should be valid json");
- assert_eq!(payload["title"], json!("activate-chain-promoted"));
- assert_eq!(payload["text"], json!("activate chain promoted target"));
+ assert_eq!(payload["title"], json!("activate-chain-activated"));
+ assert_eq!(payload["text"], json!("activate chain activated target"));
}
#[tokio::test(flavor = "multi_thread")]
@@ -1663,7 +1707,16 @@ async fn set_auto_attach_false_detaches_existing_background_targets() {
),
crate::conn::TargetPageSlot::empty_for_test_fixture(),
));
- ctx.conn.auto_attach = true;
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
+ ctx.conn
+ .register_auto_attached_session("SID-1".to_owned(), None);
+ ctx.conn
+ .register_auto_attached_session("SID-bg".to_owned(), None);
ctx.process_async(json!({
"id": 1702,
diff --git a/moli-protocol/src/domains/target/tests/tests_playwright_cdp.rs b/moli-protocol/src/domains/target/tests/tests_playwright_cdp.rs
index 1697f6ac7..97f063ee2 100644
--- a/moli-protocol/src/domains/target/tests/tests_playwright_cdp.rs
+++ b/moli-protocol/src/domains/target/tests/tests_playwright_cdp.rs
@@ -1183,7 +1183,7 @@ async fn playwright_connect_over_cdp_auto_attach_child_frame_utility_script_uses
}
#[tokio::test(flavor = "multi_thread")]
-async fn playwright_connect_over_cdp_second_page_window_query_keeps_background_target_parked() {
+async fn playwright_connect_over_cdp_second_page_window_query_keeps_background_target_background() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -1257,7 +1257,7 @@ async fn playwright_connect_over_cdp_second_page_window_query_keeps_background_t
assert_eq!(bc.active_session_id(), Some("SID-first"));
assert!(
bc.background_target(&second_target_id).is_some(),
- "second page should remain parked after Browser.getWindowForTarget"
+ "second page should remain background after Browser.getWindowForTarget"
);
assert!(
bc.background_target("TID-PW-FIRST").is_none(),
diff --git a/moli-protocol/src/domains/target/tests/tests_same_context_bindings.rs b/moli-protocol/src/domains/target/tests/tests_same_context_bindings.rs
index 87937b659..7f7507423 100644
--- a/moli-protocol/src/domains/target/tests/tests_same_context_bindings.rs
+++ b/moli-protocol/src/domains/target/tests/tests_same_context_bindings.rs
@@ -190,9 +190,9 @@ async fn same_context_targets_allocate_document_start_script_identifiers_target_
"params": { "expression": "document.title" }
}))
.await;
- let promoted_second = take_response_by_id(&mut ctx, 1041947);
+ let activated_second = take_response_by_id(&mut ctx, 1041947);
assert_eq!(
- promoted_second["result"]["result"]["value"],
+ activated_second["result"]["result"]["value"],
json!("second")
);
@@ -336,9 +336,9 @@ async fn same_context_targets_allocate_utility_pre_document_script_identifiers_t
"params": { "expression": "document.title" }
}))
.await;
- let promoted_second = take_response_by_id(&mut ctx, 1041957);
+ let activated_second = take_response_by_id(&mut ctx, 1041957);
assert_eq!(
- promoted_second["result"]["result"]["value"],
+ activated_second["result"]["result"]["value"],
json!("second")
);
@@ -1359,7 +1359,12 @@ async fn same_context_targets_replay_only_their_own_pre_document_binding_and_pre
.as_mut()
.unwrap()
.attach_active_session("SID-active");
- ctx.conn.auto_attach = true;
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
ctx.process_async(json!({
"id": 10416,
@@ -1514,17 +1519,17 @@ async fn same_context_targets_replay_only_their_own_pre_document_binding_and_pre
"expression": "JSON.stringify({ title: document.title, marker: globalThis.__lm_target_marker, hasA: typeof globalThis.targetABinding, hasB: typeof globalThis.targetBBinding, text: document.getElementById('ok').textContent })"
}
})).await;
- let parked_eval = take_response_by_id(&mut ctx, 10425);
- let parked_payload = parked_eval["result"]["result"]["value"]
+ let background_eval = take_response_by_id(&mut ctx, 10425);
+ let background_payload = background_eval["result"]["result"]["value"]
.as_str()
- .expect("parked target payload should be string");
- let parked_payload: serde_json::Value =
- serde_json::from_str(parked_payload).expect("parked target payload should be valid json");
- assert_eq!(parked_payload["title"], json!("target-b-initial"));
- assert_eq!(parked_payload["marker"], json!("B"));
- assert_eq!(parked_payload["hasA"], json!("undefined"));
- assert_eq!(parked_payload["hasB"], json!("function"));
- assert_eq!(parked_payload["text"], json!("B initial page"));
+ .expect("background target payload should be string");
+ let background_payload: serde_json::Value = serde_json::from_str(background_payload)
+ .expect("background target payload should be valid json");
+ assert_eq!(background_payload["title"], json!("target-b-initial"));
+ assert_eq!(background_payload["marker"], json!("B"));
+ assert_eq!(background_payload["hasA"], json!("undefined"));
+ assert_eq!(background_payload["hasB"], json!("function"));
+ assert_eq!(background_payload["text"], json!("B initial page"));
ctx.take_all();
ctx.process_async(json!({
@@ -1532,13 +1537,13 @@ async fn same_context_targets_replay_only_their_own_pre_document_binding_and_pre
"method": "Page.navigate",
"sessionId": second_session_id,
"params": {
- "url": "data:text/html,<title>target-b-promoted</title><div id='ok'>B promoted page</div>"
+ "url": "data:text/html,<title>target-b-activated</title><div id='ok'>B activated page</div>"
}
})).await;
consume_main_document_navigation_start(&mut ctx);
- let promoted_navigation = take_response_by_id(&mut ctx, 10426);
+ let activated_navigation = take_response_by_id(&mut ctx, 10426);
assert_eq!(
- promoted_navigation["result"]["frameId"],
+ activated_navigation["result"]["frameId"],
json!(second_target_id)
);
assert!(
@@ -1547,7 +1552,7 @@ async fn same_context_targets_replay_only_their_own_pre_document_binding_and_pre
&& message["params"]["name"] == json!("targetBBinding")
&& message["params"]["payload"] == json!("payload-B")
}),
- "session-scoped promotion should replay target B binding: {:?}",
+ "session-scoped activation should replay target B binding: {:?}",
ctx.sent
);
assert!(
@@ -1555,7 +1560,7 @@ async fn same_context_targets_replay_only_their_own_pre_document_binding_and_pre
message["method"] == json!("Runtime.bindingCalled")
&& message["params"]["name"] == json!("targetABinding")
}),
- "session-scoped promotion should not leak target A binding into target B: {:?}",
+ "session-scoped activation should not leak target A binding into target B: {:?}",
ctx.sent
);
ctx.take_all();
@@ -1568,21 +1573,21 @@ async fn same_context_targets_replay_only_their_own_pre_document_binding_and_pre
"expression": "JSON.stringify({ title: document.title, marker: globalThis.__lm_target_marker, hasA: typeof globalThis.targetABinding, hasB: typeof globalThis.targetBBinding, text: document.getElementById('ok').textContent })"
}
})).await;
- let promoted_eval = take_response_by_id(&mut ctx, 10427);
- let promoted_payload = promoted_eval["result"]["result"]["value"]
+ let activated_eval = take_response_by_id(&mut ctx, 10427);
+ let activated_payload = activated_eval["result"]["result"]["value"]
.as_str()
- .expect("promoted target payload should be string");
- let promoted_payload: serde_json::Value = serde_json::from_str(promoted_payload)
- .expect("promoted target payload should be valid json");
- assert_eq!(promoted_payload["title"], json!("target-b-promoted"));
- assert_eq!(promoted_payload["marker"], json!("B"));
- assert_eq!(promoted_payload["hasA"], json!("undefined"));
- assert_eq!(promoted_payload["hasB"], json!("function"));
- assert_eq!(promoted_payload["text"], json!("B promoted page"));
+ .expect("activated target payload should be string");
+ let activated_payload: serde_json::Value = serde_json::from_str(activated_payload)
+ .expect("activated target payload should be valid json");
+ assert_eq!(activated_payload["title"], json!("target-b-activated"));
+ assert_eq!(activated_payload["marker"], json!("B"));
+ assert_eq!(activated_payload["hasA"], json!("undefined"));
+ assert_eq!(activated_payload["hasB"], json!("function"));
+ assert_eq!(activated_payload["text"], json!("B activated page"));
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_targets_replay_only_their_own_pre_document_binding_and_preload_after_close_target_promotion()
+async fn same_context_targets_replay_only_their_own_pre_document_binding_and_preload_after_close_target_activation()
{
let mut ctx = TestContext::new();
load_bc_with_target(&mut ctx, "BID-9", "TID-000000000A");
@@ -1591,7 +1596,12 @@ async fn same_context_targets_replay_only_their_own_pre_document_binding_and_pre
.as_mut()
.unwrap()
.attach_active_session("SID-active");
- ctx.conn.auto_attach = true;
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
ctx.process_async(json!({
"id": 10470,
@@ -1751,13 +1761,13 @@ async fn same_context_targets_replay_only_their_own_pre_document_binding_and_pre
"method": "Page.navigate",
"sessionId": second_session_id,
"params": {
- "url": "data:text/html,<title>target-b-promoted</title><div id='ok'>B promoted close page</div>"
+ "url": "data:text/html,<title>target-b-activated</title><div id='ok'>B activated close page</div>"
}
})).await;
consume_main_document_navigation_start(&mut ctx);
- let promoted_navigation = take_response_by_id(&mut ctx, 10480);
+ let activated_navigation = take_response_by_id(&mut ctx, 10480);
assert_eq!(
- promoted_navigation["result"]["frameId"],
+ activated_navigation["result"]["frameId"],
json!(second_target_id)
);
assert!(
@@ -1766,7 +1776,7 @@ async fn same_context_targets_replay_only_their_own_pre_document_binding_and_pre
&& message["params"]["name"] == json!("targetBBinding")
&& message["params"]["payload"] == json!("payload-B")
}),
- "closeTarget promotion should replay target B binding: {:?}",
+ "closeTarget activation should replay target B binding: {:?}",
ctx.sent
);
assert!(
@@ -1774,7 +1784,7 @@ async fn same_context_targets_replay_only_their_own_pre_document_binding_and_pre
message["method"] == json!("Runtime.bindingCalled")
&& message["params"]["name"] == json!("targetABinding")
}),
- "closeTarget promotion should not leak target A binding into target B: {:?}",
+ "closeTarget activation should not leak target A binding into target B: {:?}",
ctx.sent
);
ctx.take_all();
@@ -1787,21 +1797,21 @@ async fn same_context_targets_replay_only_their_own_pre_document_binding_and_pre
"expression": "JSON.stringify({ title: document.title, marker: globalThis.__lm_target_marker, hasA: typeof globalThis.targetABinding, hasB: typeof globalThis.targetBBinding, text: document.getElementById('ok').textContent })"
}
})).await;
- let promoted_eval = take_response_by_id(&mut ctx, 10481);
- let promoted_payload = promoted_eval["result"]["result"]["value"]
+ let activated_eval = take_response_by_id(&mut ctx, 10481);
+ let activated_payload = activated_eval["result"]["result"]["value"]
.as_str()
- .expect("promoted target payload should be string");
- let promoted_payload: serde_json::Value = serde_json::from_str(promoted_payload)
- .expect("promoted target payload should be valid json");
- assert_eq!(promoted_payload["title"], json!("target-b-promoted"));
- assert_eq!(promoted_payload["marker"], json!("B"));
- assert_eq!(promoted_payload["hasA"], json!("undefined"));
- assert_eq!(promoted_payload["hasB"], json!("function"));
- assert_eq!(promoted_payload["text"], json!("B promoted close page"));
+ .expect("activated target payload should be string");
+ let activated_payload: serde_json::Value = serde_json::from_str(activated_payload)
+ .expect("activated target payload should be valid json");
+ assert_eq!(activated_payload["title"], json!("target-b-activated"));
+ assert_eq!(activated_payload["marker"], json!("B"));
+ assert_eq!(activated_payload["hasA"], json!("undefined"));
+ assert_eq!(activated_payload["hasB"], json!("function"));
+ assert_eq!(activated_payload["text"], json!("B activated close page"));
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_targets_materialize_only_their_own_utility_pre_document_binding_and_preload_after_close_target_promotion()
+async fn same_context_targets_materialize_only_their_own_utility_pre_document_binding_and_preload_after_close_target_activation()
{
let mut ctx = TestContext::new();
load_bc_with_target(&mut ctx, "BID-9", "TID-000000000A");
@@ -1810,7 +1820,12 @@ async fn same_context_targets_materialize_only_their_own_utility_pre_document_bi
.as_mut()
.unwrap()
.attach_active_session("SID-active");
- ctx.conn.auto_attach = true;
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
ctx.process_async(json!({
"id": 10428,
@@ -2059,16 +2074,16 @@ async fn same_context_targets_materialize_only_their_own_utility_pre_document_bi
"method": "Page.navigate",
"sessionId": second_session_id,
"params": {
- "url": "data:text/html,<title>target-b-utility-promoted</title><div id='ok'>B utility promoted page</div>"
+ "url": "data:text/html,<title>target-b-utility-activated</title><div id='ok'>B utility activated page</div>"
}
})).await;
consume_main_document_navigation_start(&mut ctx);
- let promoted_navigation = take_response_by_id(&mut ctx, 10440);
+ let activated_navigation = take_response_by_id(&mut ctx, 10440);
assert_eq!(
- promoted_navigation["result"]["frameId"],
+ activated_navigation["result"]["frameId"],
json!(second_target_id)
);
- let promoted_binding_called_b_during_navigation = ctx
+ let activated_binding_called_b_during_navigation = ctx
.sent
.iter()
.find(|message| {
@@ -2081,7 +2096,7 @@ async fn same_context_targets_materialize_only_their_own_utility_pre_document_bi
message["method"] == json!("Runtime.bindingCalled")
&& message["params"]["name"] == json!("targetAUtilityBinding")
}),
- "target A utility binding should not leak into target B promoted navigation/materialization: {:?}",
+ "target A utility binding should not leak into target B activated navigation/materialization: {:?}",
ctx.sent
);
ctx.take_all();
@@ -2096,11 +2111,11 @@ async fn same_context_targets_materialize_only_their_own_utility_pre_document_bi
}
}))
.await;
- let utility_context_b_promoted =
+ let utility_context_b_activated =
take_response_by_id(&mut ctx, 10441)["result"]["executionContextId"]
.as_i64()
- .expect("promoted target B utility context id");
- let promoted_binding_called_b = promoted_binding_called_b_during_navigation
+ .expect("activated target B utility context id");
+ let activated_binding_called_b = activated_binding_called_b_during_navigation
.or_else(|| {
ctx.sent
.iter()
@@ -2110,21 +2125,21 @@ async fn same_context_targets_materialize_only_their_own_utility_pre_document_bi
})
.cloned()
})
- .expect("target B utility binding should replay after closeTarget promotion");
+ .expect("target B utility binding should replay after closeTarget activation");
assert_eq!(
- promoted_binding_called_b["params"]["payload"],
+ activated_binding_called_b["params"]["payload"],
json!("payload-B-utility")
);
assert_eq!(
- promoted_binding_called_b["params"]["executionContextId"],
- json!(utility_context_b_promoted)
+ activated_binding_called_b["params"]["executionContextId"],
+ json!(utility_context_b_activated)
);
assert!(
!ctx.sent.iter().any(|message| {
message["method"] == json!("Runtime.bindingCalled")
&& message["params"]["name"] == json!("targetAUtilityBinding")
}),
- "target A utility binding should not leak after closeTarget promotion: {:?}",
+ "target A utility binding should not leak after closeTarget activation: {:?}",
ctx.sent
);
ctx.sent.clear();
@@ -2134,7 +2149,7 @@ async fn same_context_targets_materialize_only_their_own_utility_pre_document_bi
"method": "Runtime.evaluate",
"sessionId": second_session_id,
"params": {
- "contextId": utility_context_b_promoted,
+ "contextId": utility_context_b_activated,
"expression": "JSON.stringify({ marker: globalThis.__lm_target_utility_marker, hasA: typeof globalThis.targetAUtilityBinding, hasB: typeof globalThis.targetBUtilityBinding, title: document.title, text: document.getElementById('ok').textContent })"
}
})).await;
@@ -2147,8 +2162,8 @@ async fn same_context_targets_materialize_only_their_own_utility_pre_document_bi
assert_eq!(payload_b["marker"], json!("B"));
assert_eq!(payload_b["hasA"], json!("undefined"));
assert_eq!(payload_b["hasB"], json!("function"));
- assert_eq!(payload_b["title"], json!("target-b-utility-promoted"));
- assert_eq!(payload_b["text"], json!("B utility promoted page"));
+ assert_eq!(payload_b["title"], json!("target-b-utility-activated"));
+ assert_eq!(payload_b["text"], json!("B utility activated page"));
}
#[tokio::test(flavor = "multi_thread")]
@@ -2161,7 +2176,12 @@ async fn same_context_targets_materialize_only_their_own_utility_pre_document_bi
.as_mut()
.unwrap()
.attach_active_session("SID-active");
- ctx.conn.auto_attach = true;
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
ctx.process_async(json!({
"id": 10482,
@@ -2245,7 +2265,7 @@ async fn same_context_targets_materialize_only_their_own_utility_pre_document_bi
"method": "Page.navigate",
"sessionId": second_session_id,
"params": {
- "url": "data:text/html,<title>target-b-utility-initial</title><div id='ok'>B utility parked page</div>"
+ "url": "data:text/html,<title>target-b-utility-initial</title><div id='ok'>B utility background page</div>"
}
})).await;
consume_main_document_navigation_start(&mut ctx);
@@ -2316,7 +2336,7 @@ async fn same_context_targets_materialize_only_their_own_utility_pre_document_bi
"method": "Page.navigate",
"sessionId": "SID-active",
"params": {
- "url": "data:text/html,<title>target-a-utility-initial</title><div id='ok'>A utility parked page</div>"
+ "url": "data:text/html,<title>target-a-utility-initial</title><div id='ok'>A utility background page</div>"
}
})).await;
consume_main_document_navigation_start(&mut ctx);
@@ -2380,9 +2400,9 @@ async fn same_context_targets_materialize_only_their_own_utility_pre_document_bi
"params": { "expression": "document.title" }
}))
.await;
- let parked_eval = take_response_by_id(&mut ctx, 10493);
+ let background_eval = take_response_by_id(&mut ctx, 10493);
assert_eq!(
- parked_eval["result"]["result"]["value"],
+ background_eval["result"]["result"]["value"],
json!("target-b-utility-initial")
);
ctx.take_all();
@@ -2392,12 +2412,12 @@ async fn same_context_targets_materialize_only_their_own_utility_pre_document_bi
"method": "Page.navigate",
"sessionId": second_session_id,
"params": {
- "url": "data:text/html,<title>target-b-utility-promoted</title><div id='ok'>B utility promoted page</div>"
+ "url": "data:text/html,<title>target-b-utility-activated</title><div id='ok'>B utility activated page</div>"
}
})).await;
consume_main_document_navigation_start(&mut ctx);
take_response_by_id(&mut ctx, 10494);
- let promoted_binding_called_b_during_navigation = ctx
+ let activated_binding_called_b_during_navigation = ctx
.sent
.iter()
.find(|message| {
@@ -2410,7 +2430,7 @@ async fn same_context_targets_materialize_only_their_own_utility_pre_document_bi
message["method"] == json!("Runtime.bindingCalled")
&& message["params"]["name"] == json!("targetAUtilityBinding")
}),
- "session-scoped promotion should not leak target A utility binding into target B: {:?}",
+ "session-scoped activation should not leak target A utility binding into target B: {:?}",
ctx.sent
);
ctx.take_all();
@@ -2425,11 +2445,11 @@ async fn same_context_targets_materialize_only_their_own_utility_pre_document_bi
}
}))
.await;
- let utility_context_b_promoted =
+ let utility_context_b_activated =
take_response_by_id(&mut ctx, 10495)["result"]["executionContextId"]
.as_i64()
- .expect("promoted target B utility context id");
- let promoted_binding_called_b = promoted_binding_called_b_during_navigation
+ .expect("activated target B utility context id");
+ let activated_binding_called_b = activated_binding_called_b_during_navigation
.or_else(|| {
ctx.sent
.iter()
@@ -2439,21 +2459,21 @@ async fn same_context_targets_materialize_only_their_own_utility_pre_document_bi
})
.cloned()
})
- .expect("target B utility binding should replay after session-scoped promotion");
+ .expect("target B utility binding should replay after session-scoped activation");
assert_eq!(
- promoted_binding_called_b["params"]["payload"],
+ activated_binding_called_b["params"]["payload"],
json!("payload-B-utility")
);
assert_eq!(
- promoted_binding_called_b["params"]["executionContextId"],
- json!(utility_context_b_promoted)
+ activated_binding_called_b["params"]["executionContextId"],
+ json!(utility_context_b_activated)
);
assert!(
!ctx.sent.iter().any(|message| {
message["method"] == json!("Runtime.bindingCalled")
&& message["params"]["name"] == json!("targetAUtilityBinding")
}),
- "target A utility binding should not leak after session-scoped promotion: {:?}",
+ "target A utility binding should not leak after session-scoped activation: {:?}",
ctx.sent
);
ctx.sent.clear();
@@ -2463,7 +2483,7 @@ async fn same_context_targets_materialize_only_their_own_utility_pre_document_bi
"method": "Runtime.evaluate",
"sessionId": second_session_id,
"params": {
- "contextId": utility_context_b_promoted,
+ "contextId": utility_context_b_activated,
"expression": "JSON.stringify({ marker: globalThis.__lm_target_utility_marker, hasA: typeof globalThis.targetAUtilityBinding, hasB: typeof globalThis.targetBUtilityBinding, title: document.title, text: document.getElementById('ok').textContent })"
}
})).await;
@@ -2476,8 +2496,8 @@ async fn same_context_targets_materialize_only_their_own_utility_pre_document_bi
assert_eq!(payload_b["marker"], json!("B"));
assert_eq!(payload_b["hasA"], json!("undefined"));
assert_eq!(payload_b["hasB"], json!("function"));
- assert_eq!(payload_b["title"], json!("target-b-utility-promoted"));
- assert_eq!(payload_b["text"], json!("B utility promoted page"));
+ assert_eq!(payload_b["title"], json!("target-b-utility-activated"));
+ assert_eq!(payload_b["text"], json!("B utility activated page"));
}
#[tokio::test(flavor = "multi_thread")]
diff --git a/moli-protocol/src/domains/target/tests/tests_same_context_overrides.rs b/moli-protocol/src/domains/target/tests/tests_same_context_overrides.rs
index 635821288..0e7ba1b0b 100644
--- a/moli-protocol/src/domains/target/tests/tests_same_context_overrides.rs
+++ b/moli-protocol/src/domains/target/tests/tests_same_context_overrides.rs
@@ -361,16 +361,22 @@ async fn same_context_targets_restore_their_own_network_conditions_after_session
.as_ref()
.expect("active browser context after direct background navigation");
assert_eq!(active.active_target_id(), Some("TID-000000000NA"));
- let parked = active
+ let background = active
.background_target(&second_target_id)
.filter(|target| target.has_non_default_session_state())
- .expect("second target should keep parked network state");
- assert!(parked.network_policy.network_offline());
- assert_eq!(parked.network_policy.emulated_network_latency(), 25.0);
- assert_eq!(parked.network_policy.emulated_download_throughput(), 2048.0);
- assert_eq!(parked.network_policy.emulated_upload_throughput(), 256.0);
+ .expect("second target should keep background network state");
+ assert!(background.network_policy.network_offline());
+ assert_eq!(background.network_policy.emulated_network_latency(), 25.0);
assert_eq!(
- parked.network_policy.emulated_connection_type(),
+ background.network_policy.emulated_download_throughput(),
+ 2048.0
+ );
+ assert_eq!(
+ background.network_policy.emulated_upload_throughput(),
+ 256.0
+ );
+ assert_eq!(
+ background.network_policy.emulated_connection_type(),
Some("wifi")
);
}
@@ -636,7 +642,7 @@ async fn same_context_targets_restore_their_own_cookie_manager_surface_after_swi
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_targets_restore_their_own_cookie_manager_surface_after_close_target_promotion()
+async fn same_context_targets_restore_their_own_cookie_manager_surface_after_close_target_activation()
{
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
@@ -769,7 +775,7 @@ async fn same_context_targets_restore_their_own_cookie_manager_surface_after_clo
.conn
.browser_context
.as_ref()
- .expect("active browser context after close promotion");
+ .expect("active browser context after close activation");
assert_eq!(active.active_target_id(), Some("TID-000000000CKC"));
}
@@ -1145,7 +1151,7 @@ async fn same_context_targets_restore_their_own_proxy_loader_overrides_after_swi
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_targets_restore_their_own_loader_overrides_after_close_target_promotion() {
+async fn same_context_targets_restore_their_own_loader_overrides_after_close_target_activation() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -1270,13 +1276,13 @@ async fn same_context_targets_restore_their_own_loader_overrides_after_close_tar
}
ctx.conn
.ensure_resource_request_client()
- .expect("restored loader after close promotion");
+ .expect("restored loader after close activation");
assert_eq!(ctx.conn.user_agent(), "Moli/Close-A");
assert!(!ctx.conn.tls_verify_host());
}
#[tokio::test(flavor = "multi_thread")]
-async fn same_context_targets_restore_their_own_proxy_loader_overrides_after_close_target_promotion()
+async fn same_context_targets_restore_their_own_proxy_loader_overrides_after_close_target_activation()
{
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
@@ -1413,7 +1419,7 @@ async fn same_context_targets_restore_their_own_proxy_loader_overrides_after_clo
}
ctx.conn
.ensure_resource_request_client()
- .expect("restored loader after close promotion");
+ .expect("restored loader after close activation");
assert_eq!(
ctx.conn.http_proxy(),
Some("http://proxy-close-a.test:8080")
diff --git a/moli-protocol/src/domains/target/tests/tests_same_context_state.rs b/moli-protocol/src/domains/target/tests/tests_same_context_state.rs
index 229b0d4fe..d87b915bf 100644
--- a/moli-protocol/src/domains/target/tests/tests_same_context_state.rs
+++ b/moli-protocol/src/domains/target/tests/tests_same_context_state.rs
@@ -1392,7 +1392,7 @@ async fn same_context_targets_restore_their_own_crash_state_after_session_scoped
"method": "Page.navigate",
"sessionId": second_session_id,
"params": {
- "url": "data:text/html,<title>second-after-session-promotion</title><div id='ok'>second target</div>"
+ "url": "data:text/html,<title>second-after-session-activation</title><div id='ok'>second target</div>"
}
})).await;
let _ = take_response_by_id(&mut ctx, 1042027);
@@ -1598,7 +1598,7 @@ async fn same_context_targets_restore_their_own_domain_enablement_after_session_
.conn
.browser_context
.as_ref()
- .expect("active browser context after session-scoped promotion");
+ .expect("active browser context after session-scoped activation");
assert_eq!(bc.active_target_id(), Some(second_target_id.as_str()));
assert!(!bc.active_page_target().devtools_sessions[moli_page_types::DevToolsSessionKey::Primary].page_session_state.page_lifecycle_events);
assert!(bc.active_page_target().devtools_sessions[moli_page_types::DevToolsSessionKey::Primary].runtime_session_state.runtime_frontend_enabled);
diff --git a/moli-protocol/src/domains/target/tests/tests_same_context_target_local.rs b/moli-protocol/src/domains/target/tests/tests_same_context_target_local.rs
index 37f4383b8..55efd87bd 100644
--- a/moli-protocol/src/domains/target/tests/tests_same_context_target_local.rs
+++ b/moli-protocol/src/domains/target/tests/tests_same_context_target_local.rs
@@ -1,7 +1,7 @@
use super::*;
#[tokio::test(flavor = "multi_thread")]
-async fn activate_target_promotes_auto_attached_background_session_into_page_runtime() {
+async fn activate_target_activates_auto_attached_background_session_into_page_runtime() {
let mut ctx = TestContext::new();
load_bc_with_target(&mut ctx, "BID-9", "TID-000000000A");
ctx.conn
@@ -9,7 +9,12 @@ async fn activate_target_promotes_auto_attached_background_session_into_page_run
.as_mut()
.unwrap()
.attach_active_session("SID-active");
- ctx.conn.auto_attach = true;
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
ctx.process_async(json!({
"id": 103,
@@ -173,7 +178,12 @@ async fn get_target_info_reports_background_target_in_same_browser_context() {
#[tokio::test(flavor = "multi_thread")]
async fn popup_target_diagnostics_report_distinct_page_vm_document_isolates() {
let mut ctx = TestContext::new();
- ctx.conn.auto_attach = true;
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
let browser_context = ctx
.conn
.new_browser_context("BID-popup-diagnostics".to_owned());
@@ -307,7 +317,8 @@ async fn popup_target_diagnostics_report_distinct_page_vm_document_isolates() {
}
#[tokio::test(flavor = "multi_thread")]
-async fn attach_to_target_keeps_background_target_parked_when_active_target_has_no_loaded_page() {
+async fn attach_to_target_keeps_background_target_background_when_active_target_has_no_loaded_page()
+{
let mut ctx = TestContext::new();
load_bc_with_target(&mut ctx, "BID-9", "TID-000000000A");
ctx.conn
@@ -370,8 +381,8 @@ async fn attach_to_target_keeps_background_target_parked_when_active_target_has_
}
#[tokio::test(flavor = "multi_thread")]
-async fn background_target_session_can_navigate_enable_and_evaluate_after_attach_without_promotion()
-{
+async fn background_target_session_can_navigate_enable_and_evaluate_after_attach_without_activation()
+ {
let mut ctx = TestContext::new();
load_bc_with_target(&mut ctx, "BID-9", "TID-000000000A");
ctx.conn
@@ -426,7 +437,7 @@ async fn background_target_session_can_navigate_enable_and_evaluate_after_attach
.as_ref()
.and_then(|bc| bc.active_target_id()),
Some("TID-000000000A"),
- "session-scoped navigation must keep the attached target parked"
+ "session-scoped navigation must keep the attached target background"
);
ctx.take_all();
@@ -443,7 +454,7 @@ async fn background_target_session_can_navigate_enable_and_evaluate_after_attach
.as_ref()
.and_then(|bc| bc.active_target_id()),
Some("TID-000000000A"),
- "session-scoped Runtime.enable must keep the attached target parked"
+ "session-scoped Runtime.enable must keep the attached target background"
);
ctx.take_all();
@@ -477,7 +488,7 @@ async fn background_target_session_can_navigate_enable_and_evaluate_after_attach
.as_ref()
.and_then(|bc| bc.active_target_id()),
Some("TID-000000000A"),
- "session-scoped runtime evaluation must keep the attached target parked"
+ "session-scoped runtime evaluation must keep the attached target background"
);
}
@@ -512,7 +523,7 @@ async fn close_target_removes_background_target_without_disturbing_active_target
}
#[tokio::test(flavor = "multi_thread")]
-async fn close_active_target_promotes_background_target_to_active_slot() {
+async fn close_active_target_activates_background_target_to_active_slot() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -575,7 +586,7 @@ async fn close_active_target_promotes_background_target_to_active_slot() {
}
#[tokio::test(flavor = "multi_thread")]
-async fn close_active_target_exposes_promoted_target_screencast() {
+async fn close_active_target_exposes_activated_target_screencast() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(&mut ctx, "BID-9", "TID-active", "<title>active</title>").await;
ctx.conn
@@ -588,36 +599,36 @@ async fn close_active_target_exposes_promoted_target_screencast() {
"id": 20,
"method": "Target.createTarget",
"params": {
- "background": true, "browserContextId": "BID-9", "url": "about:blank#parked"}
+ "background": true, "browserContextId": "BID-9", "url": "about:blank#background"}
}))
.await;
- let parked_target_id = take_created_target_id(&mut ctx, 20);
+ let background_target_id = take_created_target_id(&mut ctx, 20);
ctx.process_async(json!({
"id": 21,
"method": "Target.attachToTarget",
- "params": {"targetId": parked_target_id}
+ "params": {"targetId": background_target_id}
}))
.await;
- let parked_session_id = take_response_by_id(&mut ctx, 21)["result"]["sessionId"]
+ let background_session_id = take_response_by_id(&mut ctx, 21)["result"]["sessionId"]
.as_str()
- .expect("parked target session")
+ .expect("background target session")
.to_owned();
ctx.expect_event("Target.attachedToTarget", None);
ctx.process_async(json!({
"id": 22,
"method": "Page.startScreencast",
- "sessionId": parked_session_id,
+ "sessionId": background_session_id,
"params": {}
}))
.await;
- let hidden = ctx.take_first_matching("parked screencast starts hidden", |message| {
+ let hidden = ctx.take_first_matching("background screencast starts hidden", |message| {
message["method"] == json!("Page.screencastVisibilityChanged")
});
- assert_eq!(hidden["sessionId"], json!(parked_session_id));
+ assert_eq!(hidden["sessionId"], json!(background_session_id));
assert_eq!(hidden["params"]["visible"], json!(false));
- ctx.expect_result(22, json!({}), Some(&parked_session_id));
+ ctx.expect_result(22, json!({}), Some(&background_session_id));
ctx.process_async(json!({
"id": 23,
@@ -626,9 +637,9 @@ async fn close_active_target_exposes_promoted_target_screencast() {
}))
.await;
ctx.expect_result(23, json!({ "success": true }), None);
- let visible = ctx.take_first_matching("promoted screencast becomes visible", |message| {
+ let visible = ctx.take_first_matching("activated screencast becomes visible", |message| {
message["method"] == json!("Page.screencastVisibilityChanged")
- && message["sessionId"] == json!(parked_session_id)
+ && message["sessionId"] == json!(background_session_id)
});
assert_eq!(visible["params"]["visible"], json!(true));
@@ -637,12 +648,12 @@ async fn close_active_target_exposes_promoted_target_screencast() {
.browser_context
.as_ref()
.and_then(BrowserContext::active_target_id),
- Some(parked_target_id.as_str())
+ Some(background_target_id.as_str())
);
}
#[tokio::test(flavor = "multi_thread")]
-async fn create_foreground_target_hides_demoted_target_screencast() {
+async fn create_foreground_target_hides_deactivated_target_screencast() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(&mut ctx, "BID-9", "TID-active", "<title>active</title>").await;
ctx.conn
@@ -671,7 +682,7 @@ async fn create_foreground_target_hides_demoted_target_screencast() {
"params": { "browserContextId": "BID-9", "url": "about:blank#foreground" }
}))
.await;
- let hidden = ctx.take_first_matching("demoted screencast becomes hidden", |message| {
+ let hidden = ctx.take_first_matching("deactivated screencast becomes hidden", |message| {
message["method"] == json!("Page.screencastVisibilityChanged")
&& message["sessionId"] == json!("SID-active")
});
@@ -690,7 +701,7 @@ async fn create_foreground_target_hides_demoted_target_screencast() {
}
#[tokio::test(flavor = "multi_thread")]
-async fn close_active_target_promoted_background_session_can_navigate_and_evaluate() {
+async fn close_active_target_activated_background_session_can_navigate_and_evaluate() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -719,7 +730,7 @@ async fn close_active_target_promoted_background_session_can_navigate_and_evalua
"params": {"targetId": second_target_id}
}))
.await;
- let promoted_session_id = take_response_by_id(&mut ctx, 13)["result"]["sessionId"]
+ let activated_session_id = take_response_by_id(&mut ctx, 13)["result"]["sessionId"]
.as_str()
.expect("background target session id")
.to_owned();
@@ -732,12 +743,12 @@ async fn close_active_target_promoted_background_session_can_navigate_and_evalua
}))
.await;
ctx.expect_result(14, json!({ "success": true }), None);
- expect_inspector_detached(&mut ctx, &promoted_session_id);
+ expect_inspector_detached(&mut ctx, &activated_session_id);
ctx.expect_event(
"Target.detachedFromTarget",
Some(&json!({
"targetId": second_target_id,
- "sessionId": promoted_session_id,
+ "sessionId": activated_session_id,
})),
);
ctx.expect_event(
@@ -752,7 +763,7 @@ async fn close_active_target_promoted_background_session_can_navigate_and_evalua
"method": "Page.navigate",
"sessionId": "SID-active",
"params": {
- "url": "data:text/html,<title>promoted</title><div id='ok'>promoted target</div>"
+ "url": "data:text/html,<title>activated</title><div id='ok'>activated target</div>"
}
}))
.await;
@@ -776,8 +787,8 @@ async fn close_active_target_promoted_background_session_can_navigate_and_evalua
.expect("evaluation payload should be a string");
let payload: serde_json::Value =
serde_json::from_str(payload).expect("evaluation payload should be valid json");
- assert_eq!(payload["title"], json!("promoted"));
- assert_eq!(payload["text"], json!("promoted target"));
+ assert_eq!(payload["title"], json!("activated"));
+ assert_eq!(payload["text"], json!("activated target"));
}
#[tokio::test(flavor = "multi_thread")]
@@ -882,7 +893,7 @@ async fn close_active_target_restores_background_loaded_page_runtime_without_ren
}
#[tokio::test(flavor = "multi_thread")]
-async fn close_active_target_promotes_auto_attached_background_session_into_page_runtime() {
+async fn close_active_target_activates_auto_attached_background_session_into_page_runtime() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -896,7 +907,13 @@ async fn close_active_target_promotes_auto_attached_background_session_into_page
.as_mut()
.unwrap()
.attach_active_session("SID-active");
- ctx.conn.auto_attach = true;
+ ctx.conn.register_bound_session_for_test("SID-active");
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
ctx.process_async(json!({
"id": 17,
@@ -913,7 +930,7 @@ async fn close_active_target_promotes_auto_attached_background_session_into_page
.to_owned();
let attached = ctx.take_one();
assert_eq!(attached["method"], "Target.attachedToTarget");
- let promoted_session_id = attached["params"]["sessionId"]
+ let activated_session_id = attached["params"]["sessionId"]
.as_str()
.expect("background target session id")
.to_owned();
@@ -938,9 +955,9 @@ async fn close_active_target_promotes_auto_attached_background_session_into_page
ctx.process_async(json!({
"id": 19,
"method": "Page.navigate",
- "sessionId": promoted_session_id,
+ "sessionId": activated_session_id,
"params": {
- "url": "data:text/html,<title>autoattach-promoted</title><div id='ok'>auto attached promoted target</div>"
+ "url": "data:text/html,<title>autoattach-activated</title><div id='ok'>auto attached activated target</div>"
}
}))
.await;
@@ -952,7 +969,7 @@ async fn close_active_target_promotes_auto_attached_background_session_into_page
ctx.process_async(json!({
"id": 20,
"method": "Runtime.evaluate",
- "sessionId": promoted_session_id,
+ "sessionId": activated_session_id,
"params": {
"expression": "JSON.stringify({ title: document.title, text: document.getElementById('ok').textContent })"
}
@@ -964,12 +981,12 @@ async fn close_active_target_promotes_auto_attached_background_session_into_page
.expect("evaluation payload should be a string");
let payload: serde_json::Value =
serde_json::from_str(payload).expect("evaluation payload should be valid json");
- assert_eq!(payload["title"], json!("autoattach-promoted"));
- assert_eq!(payload["text"], json!("auto attached promoted target"));
+ assert_eq!(payload["title"], json!("autoattach-activated"));
+ assert_eq!(payload["text"], json!("auto attached activated target"));
}
#[tokio::test(flavor = "multi_thread")]
-async fn close_targets_chain_promotes_multiple_auto_attached_background_sessions_into_runtime() {
+async fn close_targets_chain_activates_multiple_auto_attached_background_sessions_into_runtime() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -983,7 +1000,13 @@ async fn close_targets_chain_promotes_multiple_auto_attached_background_sessions
.as_mut()
.unwrap()
.attach_active_session("SID-active");
- ctx.conn.auto_attach = true;
+ ctx.conn.register_bound_session_for_test("SID-active");
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
ctx.process_async(json!({
"id": 1801,
@@ -1050,7 +1073,7 @@ async fn close_targets_chain_promotes_multiple_auto_attached_background_sessions
"method": "Page.navigate",
"sessionId": second_session_id,
"params": {
- "url": "data:text/html,<title>second-promoted</title><div id='ok'>second promoted target</div>"
+ "url": "data:text/html,<title>second-activated</title><div id='ok'>second activated target</div>"
}
}))
.await;
@@ -1077,8 +1100,8 @@ async fn close_targets_chain_promotes_multiple_auto_attached_background_sessions
.expect("evaluation payload should be a string");
let second_payload: serde_json::Value =
serde_json::from_str(second_payload).expect("evaluation payload should be valid json");
- assert_eq!(second_payload["title"], json!("second-promoted"));
- assert_eq!(second_payload["text"], json!("second promoted target"));
+ assert_eq!(second_payload["title"], json!("second-activated"));
+ assert_eq!(second_payload["text"], json!("second activated target"));
ctx.process_async(json!({
"id": 1806,
@@ -1107,7 +1130,7 @@ async fn close_targets_chain_promotes_multiple_auto_attached_background_sessions
"method": "Page.navigate",
"sessionId": third_session_id,
"params": {
- "url": "data:text/html,<title>third-promoted</title><div id='ok'>third promoted target</div>"
+ "url": "data:text/html,<title>third-activated</title><div id='ok'>third activated target</div>"
}
}))
.await;
@@ -1134,8 +1157,8 @@ async fn close_targets_chain_promotes_multiple_auto_attached_background_sessions
.expect("evaluation payload should be a string");
let third_payload: serde_json::Value =
serde_json::from_str(third_payload).expect("evaluation payload should be valid json");
- assert_eq!(third_payload["title"], json!("third-promoted"));
- assert_eq!(third_payload["text"], json!("third promoted target"));
+ assert_eq!(third_payload["title"], json!("third-activated"));
+ assert_eq!(third_payload["text"], json!("third activated target"));
}
#[tokio::test(flavor = "multi_thread")]
@@ -1154,7 +1177,13 @@ async fn activate_target_chain_restores_multiple_auto_attached_loaded_page_runti
.as_mut()
.unwrap()
.attach_active_session("SID-active");
- ctx.conn.auto_attach = true;
+ ctx.conn.register_bound_session_for_test("SID-active");
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
ctx.process_async(json!({
"id": 1822,
@@ -1190,14 +1219,14 @@ async fn activate_target_chain_restores_multiple_auto_attached_loaded_page_runti
"method": "Page.navigate",
"sessionId": second_session_id,
"params": {
- "url": "data:text/html,<title>second-promoted</title><div id='ok'>second promoted target</div>"
+ "url": "data:text/html,<title>second-activated</title><div id='ok'>second activated target</div>"
}
}))
.await;
consume_main_document_navigation_start(&mut ctx);
- let promoted_second_navigation = take_response_by_id(&mut ctx, 1824);
+ let activated_second_navigation = take_response_by_id(&mut ctx, 1824);
assert_eq!(
- promoted_second_navigation["result"]["frameId"],
+ activated_second_navigation["result"]["frameId"],
json!(second_target_id)
);
ctx.take_all();
@@ -1236,14 +1265,14 @@ async fn activate_target_chain_restores_multiple_auto_attached_loaded_page_runti
"method": "Page.navigate",
"sessionId": third_session_id,
"params": {
- "url": "data:text/html,<title>third-promoted</title><div id='ok'>third promoted target</div>"
+ "url": "data:text/html,<title>third-activated</title><div id='ok'>third activated target</div>"
}
}))
.await;
consume_main_document_navigation_start(&mut ctx);
- let promoted_third_navigation = take_response_by_id(&mut ctx, 1827);
+ let activated_third_navigation = take_response_by_id(&mut ctx, 1827);
assert_eq!(
- promoted_third_navigation["result"]["frameId"],
+ activated_third_navigation["result"]["frameId"],
json!(third_target_id)
);
ctx.take_all();
@@ -1297,8 +1326,8 @@ async fn activate_target_chain_restores_multiple_auto_attached_loaded_page_runti
.expect("second evaluation payload should be a string");
let second_payload: serde_json::Value = serde_json::from_str(second_payload)
.expect("second evaluation payload should be valid json");
- assert_eq!(second_payload["title"], json!("second-promoted"));
- assert_eq!(second_payload["text"], json!("second promoted target"));
+ assert_eq!(second_payload["title"], json!("second-activated"));
+ assert_eq!(second_payload["text"], json!("second activated target"));
ctx.process_async(json!({
"id": 1832,
@@ -1323,8 +1352,8 @@ async fn activate_target_chain_restores_multiple_auto_attached_loaded_page_runti
.expect("third evaluation payload should be a string");
let third_payload_again: serde_json::Value = serde_json::from_str(third_payload_again)
.expect("third evaluation payload should be valid json");
- assert_eq!(third_payload_again["title"], json!("third-promoted"));
- assert_eq!(third_payload_again["text"], json!("third promoted target"));
+ assert_eq!(third_payload_again["title"], json!("third-activated"));
+ assert_eq!(third_payload_again["text"], json!("third activated target"));
}
#[tokio::test(flavor = "multi_thread")]
@@ -1343,6 +1372,7 @@ async fn activate_target_chain_restores_multiple_set_auto_attach_background_load
.as_mut()
.unwrap()
.attach_active_session("SID-active");
+ ctx.conn.register_bound_session_for_test("SID-active");
{
let bc = ctx.conn.browser_context.as_mut().unwrap();
bc.insert_page_target_host(crate::conn::PageTargetHost::new(
@@ -1542,6 +1572,7 @@ async fn close_target_restores_loaded_runtime_to_previous_set_auto_attach_target
.as_mut()
.unwrap()
.attach_active_session("SID-active");
+ ctx.conn.register_bound_session_for_test("SID-active");
{
let bc = ctx.conn.browser_context.as_mut().unwrap();
bc.insert_page_target_host(crate::conn::PageTargetHost::new(
@@ -1769,7 +1800,7 @@ async fn detach_from_target_clears_background_target_session() {
assert!(
bc.background_target(&second_target_id)
.is_some_and(|target| target.session_id().is_none()),
- "detaching a parked target session should clear the parked session binding without promoting it",
+ "detaching a background target session should clear the background session binding without activating it",
);
assert!(
bc.background_target(&second_target_id).is_some(),
@@ -1777,12 +1808,13 @@ async fn detach_from_target_clears_background_target_session() {
);
assert!(
bc.loaded_page().is_some(),
- "detaching a parked target session should keep the active loaded page active"
+ "detaching a background target session should keep the active loaded page active"
);
}
#[tokio::test(flavor = "multi_thread")]
-async fn page_command_on_background_target_session_routes_without_promoting_loaded_active_target() {
+async fn page_command_on_background_target_session_routes_without_activating_loaded_active_target()
+{
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -1810,6 +1842,8 @@ async fn page_command_on_background_target_session_routes_without_promoting_load
),
crate::conn::TargetPageSlot::empty_for_test_fixture(),
));
+ ctx.conn.register_bound_session_for_test("SID-active");
+ ctx.conn.register_bound_session_for_test("SID-bg");
ctx.process_async(json!({
"id": 12,
@@ -1840,7 +1874,7 @@ async fn page_command_on_background_target_session_routes_without_promoting_load
assert!(
bc.background_target("TID-000000000F")
.is_some_and(|target| target.has_loaded_page()),
- "background Page.navigate should load the parked target without promoting it"
+ "background Page.navigate should load the background target without activating it"
);
ctx.process_async(json!({
diff --git a/moli-protocol/src/domains/target/tests/tests_target_attachment.rs b/moli-protocol/src/domains/target/tests/tests_target_attachment.rs
index a6058706b..ca3199a14 100644
--- a/moli-protocol/src/domains/target/tests/tests_target_attachment.rs
+++ b/moli-protocol/src/domains/target/tests/tests_target_attachment.rs
@@ -688,7 +688,7 @@ async fn attach_to_target_ensures_pending_background_initial_document_before_att
}
#[tokio::test(flavor = "multi_thread")]
-async fn attach_to_target_existing_session_creates_distinct_auxiliary_session() {
+async fn attach_to_target_existing_session_creates_distinct_attached_session() {
// Chromium TargetHandler::AttachToTarget calls Session::Attach on every
// invocation, even when the host already has another attached session.
let mut ctx = TestContext::new();
@@ -698,27 +698,28 @@ async fn attach_to_target_existing_session_creates_distinct_auxiliary_session()
.as_mut()
.unwrap()
.attach_active_session("SID-primary");
+ ctx.conn.register_bound_session_for_test("SID-primary");
ctx.process_async(json!({"id": 12, "method": "Target.attachToTarget",
"params": {"targetId": "TID-000000000B"}}))
.await;
let response = take_response_by_id(&mut ctx, 12);
- let auxiliary_session_id = response["result"]["sessionId"]
+ let attached_session_id = response["result"]["sessionId"]
.as_str()
- .expect("auxiliary session id")
+ .expect("attached session id")
.to_owned();
- assert_ne!(auxiliary_session_id, "SID-primary");
+ assert_ne!(attached_session_id, "SID-primary");
let attached = ctx.take_one();
assert_eq!(attached["method"], "Target.attachedToTarget");
assert_eq!(
attached["params"]["sessionId"],
- json!(auxiliary_session_id.as_str())
+ json!(attached_session_id.as_str())
);
let bc = ctx.conn.browser_context.as_ref().unwrap();
assert_eq!(bc.active_session_id(), Some("SID-primary"));
assert_eq!(
- bc.auxiliary_target_id_for_session(&auxiliary_session_id),
+ bc.attached_target_id_for_session(&attached_session_id),
Some("TID-000000000B")
);
@@ -738,7 +739,7 @@ async fn attach_to_target_existing_session_creates_distinct_auxiliary_session()
ctx.process_async(json!({
"id": 121,
"method": "Runtime.evaluate",
- "sessionId": auxiliary_session_id,
+ "sessionId": attached_session_id,
"params": {
"expression": "21 + 21",
"returnByValue": true
@@ -750,7 +751,7 @@ async fn attach_to_target_existing_session_creates_distinct_auxiliary_session()
}
#[tokio::test(flavor = "multi_thread")]
-async fn attach_to_target_keeps_background_target_parked() {
+async fn attach_to_target_keeps_background_target_background() {
let mut ctx = TestContext::new();
load_bc_with_target(&mut ctx, "BID-9", "TID-000000000A");
push_background_target(&mut ctx, "TID-000000000B", "about:blank", None);
@@ -1044,9 +1045,9 @@ async fn detach_browser_target_session_cascades_owned_target_sessions() {
}
#[tokio::test(flavor = "multi_thread")]
-async fn detach_auxiliary_page_session_cascades_owned_target_sessions() {
+async fn detach_attached_page_session_cascades_owned_target_sessions() {
let mut ctx = TestContext::new();
- load_bc_with_target(&mut ctx, "BID-aux-cascade", "TID-page");
+ load_bc_with_target(&mut ctx, "BID-attached-cascade", "TID-page");
ctx.process_async(json!({"id": 151, "method": "Target.attachToBrowserTarget"}))
.await;
@@ -1069,7 +1070,7 @@ async fn detach_auxiliary_page_session_cascades_owned_target_sessions() {
.await;
let page_session_id = ctx.take_response_by_id(152)["result"]["sessionId"]
.as_str()
- .expect("auxiliary page session id")
+ .expect("attached page session id")
.to_owned();
ctx.expect_event("Target.attachedToTarget", None);
@@ -1101,7 +1102,7 @@ async fn detach_auxiliary_page_session_cascades_owned_target_sessions() {
assert_eq!(
ctx.conn.session_route(Some(&child_session_id)),
None,
- "detaching a direct page frontend's auxiliary session must release its child sessions"
+ "detaching a direct page frontend's attached session must release its child sessions"
);
let detached_child = ctx.take_first_matching("child detachedFromTarget", |message| {
message["method"] == json!("Target.detachedFromTarget")
@@ -1182,7 +1183,7 @@ async fn root_frontend_release_preserves_private_browser_owned_page_session() {
let browser_context = ctx.conn.browser_context.as_ref().expect("browser context");
assert_eq!(browser_context.active_session_id(), None);
assert_eq!(
- browser_context.auxiliary_target_id_for_session(&private_page_session_id),
+ browser_context.attached_target_id_for_session(&private_page_session_id),
Some("TID-root-release")
);
}
@@ -1239,7 +1240,7 @@ async fn browser_target_session_survives_browser_context_disposal() {
assert_eq!(attach_response["sessionId"], browser_session_id);
assert!(
attach_response["result"]["sessionId"].is_string(),
- "attach response should include an auxiliary target session"
+ "attach response should include an attached target session"
);
let attached_event = ctx.take_one();
assert_eq!(attached_event["method"], "Target.attachedToTarget");
@@ -1247,17 +1248,17 @@ async fn browser_target_session_survives_browser_context_disposal() {
}
#[tokio::test(flavor = "multi_thread")]
-async fn session_route_finds_browser_active_auxiliary_background_and_inactive_sessions() {
+async fn session_route_finds_committed_browser_page_and_worker_sessions() {
let mut ctx = TestContext::new();
load_bc_with_target(&mut ctx, "BID-A", "TID-000000000A");
ctx.conn.register_browser_session("SID-browser".to_owned());
{
let bc = ctx.conn.browser_context.as_mut().unwrap();
bc.attach_active_session("SID-active");
- assert!(
- bc.assign_auxiliary_session_to_target("TID-000000000A", "SID-auxiliary".to_owned())
- );
+ assert!(bc.assign_attached_session_to_target("TID-000000000A", "SID-attached".to_owned()));
}
+ ctx.conn.register_bound_session_for_test("SID-active");
+ ctx.conn.register_bound_session_for_test("SID-attached");
push_background_target(
&mut ctx,
"TID-000000000B",
@@ -1282,9 +1283,9 @@ async fn session_route_finds_browser_active_auxiliary_background_and_inactive_se
crate::conn::TargetIdentityState::about_blank(),
crate::conn::TargetPageSlot::empty_for_test_fixture(),
));
- assert!(inactive.assign_auxiliary_session_to_target(
+ assert!(inactive.assign_attached_session_to_target(
"TID-000000000D",
- "SID-inactive-aux-background".to_owned()
+ "SID-inactive-attached-background".to_owned()
));
let mut inactive_shared_worker = crate::conn::SharedWorkerTargetState::new(
moli_core::RendererOwnerLocalHostId::new_for_testing(1),
@@ -1297,6 +1298,14 @@ async fn session_route_finds_browser_active_auxiliary_background_and_inactive_se
inactive_shared_worker.attach_session("SID-shared-inactive".to_owned());
inactive.insert_shared_worker_target(inactive_shared_worker);
ctx.conn.inactive_browser_contexts.push(inactive);
+ for session_id in [
+ "SID-inactive",
+ "SID-inactive-background",
+ "SID-inactive-attached-background",
+ "SID-shared-inactive",
+ ] {
+ ctx.conn.register_bound_session_for_test(session_id);
+ }
assert_eq!(
ctx.conn.session_route(Some("SID-browser")),
@@ -1311,11 +1320,11 @@ async fn session_route_finds_browser_active_auxiliary_background_and_inactive_se
})
);
assert_eq!(
- ctx.conn.session_route(Some("SID-auxiliary")),
+ ctx.conn.session_route(Some("SID-attached")),
Some(CdpSessionRoute::PageTarget {
browser_context_id: "BID-A".to_owned(),
target_id: "TID-000000000A".to_owned(),
- session_key: moli_page_types::DevToolsSessionKey::Attached("SID-auxiliary".to_owned(),),
+ session_key: moli_page_types::DevToolsSessionKey::Attached("SID-attached".to_owned(),),
})
);
assert_eq!(
@@ -1351,12 +1360,13 @@ async fn session_route_finds_browser_active_auxiliary_background_and_inactive_se
})
);
assert_eq!(
- ctx.conn.session_route(Some("SID-inactive-aux-background")),
+ ctx.conn
+ .session_route(Some("SID-inactive-attached-background")),
Some(CdpSessionRoute::PageTarget {
browser_context_id: "BID-B".to_owned(),
target_id: "TID-000000000D".to_owned(),
session_key: moli_page_types::DevToolsSessionKey::Attached(
- "SID-inactive-aux-background".to_owned(),
+ "SID-inactive-attached-background".to_owned(),
),
})
);
@@ -1378,7 +1388,7 @@ async fn session_route_finds_browser_active_auxiliary_background_and_inactive_se
assert_eq!(
ctx.conn.browser_context.as_ref().map(|bc| bc.id.as_str()),
Some("BID-A"),
- "direct background route helpers must not promote inactive browser contexts"
+ "direct background route helpers must not activate inactive browser contexts"
);
assert!(
ctx.conn
@@ -1403,7 +1413,7 @@ async fn session_route_finds_browser_active_auxiliary_background_and_inactive_se
}
#[tokio::test(flavor = "multi_thread")]
-async fn attach_to_target_from_browser_session_creates_distinct_auxiliary_session() {
+async fn attach_to_target_from_browser_session_creates_distinct_attached_session() {
let mut ctx = TestContext::new();
load_bc_with_target(&mut ctx, "BID-9", "TID-000000000B");
ctx.conn
@@ -1449,7 +1459,7 @@ async fn attach_to_target_from_browser_session_creates_distinct_auxiliary_sessio
let bc = ctx.conn.browser_context.as_ref().unwrap();
assert_eq!(bc.active_session_id(), Some("SID-page"));
assert_eq!(
- bc.auxiliary_target_id_for_session(target_session_id),
+ bc.attached_target_id_for_session(target_session_id),
Some("TID-000000000B")
);
@@ -1465,7 +1475,7 @@ async fn attach_to_target_from_browser_session_creates_distinct_auxiliary_sessio
assert!(
bc.active_page_target()
.runtime_slot
- .has_auxiliary_network_events_for_session(target_session_id)
+ .has_attached_network_events_for_session(target_session_id)
);
}
@@ -1552,8 +1562,10 @@ async fn detach_from_target() {
},
);
bc.active_page_target_mut().css_enabled = true;
+ bc.active_page_target_mut().input_intercept_drags_enabled = true;
+ bc.active_page_target_mut().input_drag_intercepted = true;
bc.active_page_target_mut().fetch_owner.configure(
- None,
+ Some(sid.clone()),
true,
vec![crate::conn::FetchInterceptionPattern {
url_pattern: "*".into(),
@@ -1595,6 +1607,8 @@ async fn detach_from_target() {
.bypass_service_worker()
);
assert!(!bc.active_page_target().css_enabled);
+ assert!(!bc.active_page_target().input_intercept_drags_enabled);
+ assert!(!bc.active_page_target().input_drag_intercepted);
assert!(!bc.active_page_target().fetch_owner.is_enabled());
assert!(!bc.active_page_target().fetch_owner.handle_auth_requests());
assert!(
@@ -1638,15 +1652,19 @@ async fn detach_from_target_drops_only_selected_page_renderer_inspector_session(
{
let bc = ctx.conn.browser_context.as_mut().unwrap();
bc.attach_active_session("SID-detach-primary");
- assert!(bc.assign_auxiliary_session_to_target(
+ assert!(bc.assign_attached_session_to_target(
"TID-detach-inspector",
- "SID-detach-aux".to_owned()
+ "SID-detach-attached".to_owned()
));
}
+ ctx.conn
+ .register_bound_session_for_test("SID-detach-primary");
+ ctx.conn
+ .register_bound_session_for_test("SID-detach-attached");
ctx.sent.clear();
let baseline_session_count =
- page_renderer_inspector_session_count(&mut ctx, "before Runtime.enable").await;
+ page_renderer_inspector_session_count(&mut ctx, None, "before Runtime.enable").await;
ctx.process_async(json!({
"id": 120_001,
"sessionId": "SID-detach-primary",
@@ -1656,17 +1674,17 @@ async fn detach_from_target_drops_only_selected_page_renderer_inspector_session(
ctx.expect_result(120_001, json!({}), Some("SID-detach-primary"));
ctx.process_async(json!({
"id": 120_002,
- "sessionId": "SID-detach-aux",
+ "sessionId": "SID-detach-attached",
"method": "Runtime.enable"
}))
.await;
- ctx.expect_result(120_002, json!({}), Some("SID-detach-aux"));
+ ctx.expect_result(120_002, json!({}), Some("SID-detach-attached"));
ctx.sent.clear();
assert_eq!(
- page_renderer_inspector_session_count(&mut ctx, "after both sessions enabled").await,
+ page_renderer_inspector_session_count(&mut ctx, None, "after both sessions enabled").await,
baseline_session_count + 1,
- "primary Runtime.enable must reuse the target default Inspector session while auxiliary Runtime.enable adds one session"
+ "primary Runtime.enable must reuse the target default Inspector session while attached Runtime.enable adds one session"
);
ctx.process_async(json!({
@@ -1674,7 +1692,7 @@ async fn detach_from_target_drops_only_selected_page_renderer_inspector_session(
"method": "Target.detachFromTarget",
"params": {
"targetId": "TID-detach-inspector",
- "sessionId": "SID-detach-aux"
+ "sessionId": "SID-detach-attached"
}
}))
.await;
@@ -1683,19 +1701,19 @@ async fn detach_from_target_drops_only_selected_page_renderer_inspector_session(
"Target.detachedFromTarget",
Some(&json!({
"targetId": "TID-detach-inspector",
- "sessionId": "SID-detach-aux"
+ "sessionId": "SID-detach-attached"
})),
);
assert!(
ctx.sent
.iter()
.all(|message| message["method"] != json!("Target.detachedFromTarget")),
- "auxiliary detach must publish exactly one target detach event"
+ "attached detach must publish exactly one target detach event"
);
assert_eq!(
- page_renderer_inspector_session_count(&mut ctx, "after auxiliary detach").await,
+ page_renderer_inspector_session_count(&mut ctx, None, "after attached detach").await,
baseline_session_count,
- "auxiliary detach should drop only that renderer V8 inspector session"
+ "attached detach should drop only that renderer V8 inspector session"
);
ctx.process_async(json!({
"id": 120_005,
@@ -1712,38 +1730,41 @@ async fn detach_from_target_drops_only_selected_page_renderer_inspector_session(
{
let bc = ctx.conn.browser_context.as_mut().unwrap();
- assert!(bc.assign_auxiliary_session_to_target(
+ assert!(bc.assign_attached_session_to_target(
"TID-detach-inspector",
- "SID-detach-aux-replacement".to_owned()
+ "SID-detach-attached-replacement".to_owned()
));
}
+ ctx.conn
+ .register_bound_session_for_test("SID-detach-attached-replacement");
ctx.process_async(json!({
"id": 120_006,
- "sessionId": "SID-detach-aux-replacement",
+ "sessionId": "SID-detach-attached-replacement",
"method": "Runtime.enable"
}))
.await;
- ctx.expect_result(120_006, json!({}), Some("SID-detach-aux-replacement"));
+ ctx.expect_result(120_006, json!({}), Some("SID-detach-attached-replacement"));
ctx.sent.clear();
assert_eq!(
- page_renderer_inspector_session_count(&mut ctx, "after replacement auxiliary enable").await,
+ page_renderer_inspector_session_count(&mut ctx, None, "after replacement attached enable",)
+ .await,
baseline_session_count + 1
);
ctx.process_async(json!({
"id": 120_007,
- "sessionId": "SID-detach-aux-replacement",
+ "sessionId": "SID-detach-attached-replacement",
"method": "Network.enable"
}))
.await;
- ctx.expect_result(120_007, json!({}), Some("SID-detach-aux-replacement"));
+ ctx.expect_result(120_007, json!({}), Some("SID-detach-attached-replacement"));
ctx.process_async(json!({
"id": 120_008,
- "sessionId": "SID-detach-aux-replacement",
+ "sessionId": "SID-detach-attached-replacement",
"method": "Network.setCacheDisabled",
"params": { "cacheDisabled": true }
}))
.await;
- ctx.expect_result(120_008, json!({}), Some("SID-detach-aux-replacement"));
+ ctx.expect_result(120_008, json!({}), Some("SID-detach-attached-replacement"));
ctx.process_async(json!({
"id": 120_009,
@@ -1769,7 +1790,12 @@ async fn detach_from_target_drops_only_selected_page_renderer_inspector_session(
"primary detach must publish exactly one target detach event"
);
assert_eq!(
- page_renderer_inspector_session_count(&mut ctx, "after primary detach").await,
+ page_renderer_inspector_session_count(
+ &mut ctx,
+ Some("SID-detach-attached-replacement"),
+ "after primary detach",
+ )
+ .await,
baseline_session_count,
"primary detach must release the default Inspector session while preserving the attached replacement session"
);
@@ -1787,7 +1813,7 @@ async fn detach_from_target_drops_only_selected_page_renderer_inspector_session(
let bc = ctx.conn.browser_context.as_ref().unwrap();
assert_eq!(
- bc.auxiliary_target_id_for_session("SID-detach-aux-replacement"),
+ bc.attached_target_id_for_session("SID-detach-attached-replacement"),
Some("TID-detach-inspector"),
"detaching primary must preserve the attached session binding"
);
@@ -1798,7 +1824,7 @@ async fn detach_from_target_drops_only_selected_page_renderer_inspector_session(
ctx.process_async(json!({
"id": 120_011,
- "sessionId": "SID-detach-aux-replacement",
+ "sessionId": "SID-detach-attached-replacement",
"method": "Runtime.evaluate",
"params": {
"expression": "21 + 21",
@@ -1814,7 +1840,7 @@ async fn detach_from_target_drops_only_selected_page_renderer_inspector_session(
"method": "Target.detachFromTarget",
"params": {
"targetId": "TID-detach-inspector",
- "sessionId": "SID-detach-aux-replacement"
+ "sessionId": "SID-detach-attached-replacement"
}
}))
.await;
@@ -1823,12 +1849,12 @@ async fn detach_from_target_drops_only_selected_page_renderer_inspector_session(
"Target.detachedFromTarget",
Some(&json!({
"targetId": "TID-detach-inspector",
- "sessionId": "SID-detach-aux-replacement"
+ "sessionId": "SID-detach-attached-replacement"
})),
);
ctx.process_async(json!({
"id": 120_013,
- "sessionId": "SID-detach-aux-replacement",
+ "sessionId": "SID-detach-attached-replacement",
"method": "Runtime.evaluate",
"params": {
"expression": "21 + 21",
@@ -1843,6 +1869,8 @@ async fn detach_from_target_drops_only_selected_page_renderer_inspector_session(
.as_mut()
.expect("browser context")
.attach_active_session("SID-detach-diagnostic");
+ ctx.conn
+ .register_bound_session_for_test("SID-detach-diagnostic");
ctx.process_async(json!({
"id": 120_014,
"sessionId": "SID-detach-diagnostic",
@@ -1851,9 +1879,9 @@ async fn detach_from_target_drops_only_selected_page_renderer_inspector_session(
.await;
ctx.expect_result(120_014, json!({}), Some("SID-detach-diagnostic"));
assert_eq!(
- page_renderer_inspector_session_count(&mut ctx, "after fresh primary attach").await,
+ page_renderer_inspector_session_count(&mut ctx, None, "after fresh primary attach").await,
baseline_session_count,
- "a fresh primary session must not observe a leaked auxiliary renderer session"
+ "a fresh primary session must not observe a leaked attached renderer session"
);
}
@@ -1870,11 +1898,15 @@ async fn detach_from_target_removes_only_selected_session_document_start_scripts
{
let browser_context = ctx.conn.browser_context.as_mut().unwrap();
browser_context.attach_active_session("SID-preload-primary");
- assert!(browser_context.assign_auxiliary_session_to_target(
+ assert!(browser_context.assign_attached_session_to_target(
"TID-detach-preload",
- "SID-preload-aux".to_owned(),
+ "SID-preload-attached".to_owned(),
));
}
+ ctx.conn
+ .register_bound_session_for_test("SID-preload-primary");
+ ctx.conn
+ .register_bound_session_for_test("SID-preload-attached");
ctx.sent.clear();
for (id, session_id, source) in [
@@ -1885,8 +1917,8 @@ async fn detach_from_target_removes_only_selected_session_document_start_scripts
),
(
120_102,
- "SID-preload-aux",
- "globalThis.__auxPreload = 'auxiliary';",
+ "SID-preload-attached",
+ "globalThis.__auxPreload = 'attached';",
),
] {
ctx.process_async(json!({
@@ -1905,28 +1937,28 @@ async fn detach_from_target_removes_only_selected_session_document_start_scripts
ctx.process_async(json!({
"id": 120_107,
- "sessionId": "SID-preload-aux",
+ "sessionId": "SID-preload-attached",
"method": "Page.addScriptToEvaluateOnNewDocument",
- "params": { "source": "globalThis.__auxSecondPreload = 'auxiliary-2';" }
+ "params": { "source": "globalThis.__auxSecondPreload = 'attached-2';" }
}))
.await;
ctx.expect_result(
120_107,
json!({ "identifier": "2" }),
- Some("SID-preload-aux"),
+ Some("SID-preload-attached"),
);
ctx.process_async(json!({
"id": 120_108,
- "sessionId": "SID-preload-aux",
+ "sessionId": "SID-preload-attached",
"method": "Page.removeScriptToEvaluateOnNewDocument",
"params": { "identifier": "1" }
}))
.await;
- ctx.expect_result(120_108, json!({}), Some("SID-preload-aux"));
+ ctx.expect_result(120_108, json!({}), Some("SID-preload-attached"));
ctx.process_async(json!({
"id": 120_109,
- "sessionId": "SID-preload-aux",
+ "sessionId": "SID-preload-attached",
"method": "Page.removeScriptToEvaluateOnNewDocument",
"params": { "identifier": "1" }
}))
@@ -1959,7 +1991,7 @@ async fn detach_from_target_removes_only_selected_session_document_start_scripts
identifier == "2"
&& script.devtools_session
== Some(moli_page_types::DevToolsSessionKey::Attached(
- "SID-preload-aux".to_owned(),
+ "SID-preload-attached".to_owned(),
))
})
);
@@ -1970,7 +2002,7 @@ async fn detach_from_target_removes_only_selected_session_document_start_scripts
"method": "Target.detachFromTarget",
"params": {
"targetId": "TID-detach-preload",
- "sessionId": "SID-preload-aux"
+ "sessionId": "SID-preload-attached"
}
}))
.await;
@@ -1979,7 +2011,7 @@ async fn detach_from_target_removes_only_selected_session_document_start_scripts
"Target.detachedFromTarget",
Some(&json!({
"targetId": "TID-detach-preload",
- "sessionId": "SID-preload-aux"
+ "sessionId": "SID-preload-attached"
})),
);
@@ -2019,7 +2051,7 @@ async fn detach_from_target_removes_only_selected_session_document_start_scripts
"sessionId": "SID-preload-primary",
"method": "Runtime.evaluate",
"params": {
- "expression": "JSON.stringify({ primary: globalThis.__primaryPreload ?? null, auxiliary: globalThis.__auxPreload ?? null })",
+ "expression": "JSON.stringify({ primary: globalThis.__primaryPreload ?? null, attached: globalThis.__auxPreload ?? null })",
"returnByValue": true
}
}))
@@ -2027,23 +2059,230 @@ async fn detach_from_target_removes_only_selected_session_document_start_scripts
let replacement = take_response_by_id(&mut ctx, 120_106);
assert_eq!(
replacement["result"]["result"]["value"],
- json!(r#"{"primary":"primary","auxiliary":null}"#),
+ json!(r#"{"primary":"primary","attached":null}"#),
"only the surviving session script must replay into the replacement Document"
);
}
-async fn page_renderer_inspector_session_count(ctx: &mut TestContext, stage: &str) -> u64 {
+#[tokio::test(flavor = "multi_thread")]
+async fn detach_fail_closes_page_before_retiring_unremovable_session_scripts() {
+ let mut ctx = TestContext::new();
+ load_bc_with_titled_page_async(
+ &mut ctx,
+ "BID-detach-cleanup-failure",
+ "TID-detach-cleanup-failure",
+ "<!doctype html><body>detach cleanup failure</body>",
+ )
+ .await;
+ {
+ let browser_context = ctx.conn.browser_context.as_mut().unwrap();
+ browser_context.attach_active_session("SID-cleanup-primary");
+ assert!(browser_context.assign_attached_session_to_target(
+ "TID-detach-cleanup-failure",
+ "SID-cleanup-attached".to_owned(),
+ ));
+ }
+ ctx.conn
+ .register_bound_session_for_test("SID-cleanup-primary");
+ ctx.conn
+ .register_bound_session_for_test("SID-cleanup-attached");
+ ctx.sent.clear();
+
+ ctx.process_async(json!({
+ "id": 120_110,
+ "sessionId": "SID-cleanup-attached",
+ "method": "Page.addScriptToEvaluateOnNewDocument",
+ "params": { "source": "globalThis.__mustNotOutliveSession = true;" }
+ }))
+ .await;
+ ctx.expect_result(
+ 120_110,
+ json!({ "identifier": "1" }),
+ Some("SID-cleanup-attached"),
+ );
+
+ ctx.conn
+ .browser_context
+ .as_ref()
+ .and_then(|browser_context| browser_context.active_page_target().loaded_page())
+ .expect("fixture should retain a loaded Page")
+ .crash_devtools_target_from_io();
+ let cleanup_error = ctx
+ .conn
+ .remove_document_start_scripts_for_detached_session_async("SID-cleanup-attached")
+ .await
+ .expect_err("a closed renderer ingress must reject script cleanup");
+ assert!(
+ cleanup_error
+ .to_string()
+ .contains("document-start script cleanup"),
+ "unexpected cleanup failure: {cleanup_error:#}"
+ );
+ assert!(
+ ctx.conn
+ .browser_context
+ .as_ref()
+ .unwrap()
+ .active_page_target()
+ .owner_state
+ .document_start_scripts
+ .iter()
+ .any(|(_, script)| {
+ script.devtools_session
+ == Some(moli_page_types::DevToolsSessionKey::Attached(
+ "SID-cleanup-attached".to_owned(),
+ ))
+ }),
+ "failed renderer cleanup must retain protocol-side retry authority"
+ );
+
+ ctx.process_async(json!({
+ "id": 120_111,
+ "method": "Target.detachFromTarget",
+ "params": {
+ "targetId": "TID-detach-cleanup-failure",
+ "sessionId": "SID-cleanup-attached"
+ }
+ }))
+ .await;
+ ctx.expect_result(120_111, json!({}), None);
+
+ let target = ctx
+ .conn
+ .browser_context
+ .as_ref()
+ .unwrap()
+ .active_page_target();
+ assert!(target.owner_state.target_crash_state.is_crashed());
+ assert!(target.loaded_page().is_none());
+ assert!(
+ target
+ .owner_state
+ .document_start_scripts
+ .iter()
+ .all(|(_, script)| {
+ script.devtools_session
+ != Some(moli_page_types::DevToolsSessionKey::Attached(
+ "SID-cleanup-attached".to_owned(),
+ ))
+ }),
+ "session records may retire after the failed renderer has been closed"
+ );
+ assert_eq!(
+ ctx.conn.session_route(Some("SID-cleanup-attached")),
+ None,
+ "the binding should commit only after renderer ownership is gone"
+ );
+ assert!(
+ ctx.sent
+ .iter()
+ .any(|message| message["method"] == json!("Inspector.targetCrashed")),
+ "cleanup fail-close should be observable to attached Inspector clients: {:?}",
+ ctx.sent
+ );
+}
+
+#[tokio::test(flavor = "multi_thread")]
+async fn detach_fail_closes_page_when_fetch_disable_cannot_reach_renderer() {
+ let mut ctx = TestContext::new();
+ load_bc_with_titled_page_async(
+ &mut ctx,
+ "BID-detach-fetch-cleanup-failure",
+ "TID-detach-fetch-cleanup-failure",
+ "<!doctype html><body>detach fetch cleanup failure</body>",
+ )
+ .await;
+ {
+ let browser_context = ctx.conn.browser_context.as_mut().unwrap();
+ browser_context.attach_active_session("SID-fetch-cleanup-primary");
+ assert!(browser_context.assign_attached_session_to_target(
+ "TID-detach-fetch-cleanup-failure",
+ "SID-fetch-cleanup-attached".to_owned(),
+ ));
+ }
+ ctx.conn
+ .register_bound_session_for_test("SID-fetch-cleanup-primary");
+ ctx.conn
+ .register_bound_session_for_test("SID-fetch-cleanup-attached");
+ ctx.sent.clear();
+
+ ctx.process_async(json!({
+ "id": 120_112,
+ "sessionId": "SID-fetch-cleanup-attached",
+ "method": "Fetch.enable"
+ }))
+ .await;
+ ctx.expect_result(120_112, json!({}), Some("SID-fetch-cleanup-attached"));
+ assert!(
+ ctx.conn
+ .browser_context
+ .as_ref()
+ .unwrap()
+ .active_page_target()
+ .fetch_owner
+ .is_enabled(),
+ "the attached session must own renderer Fetch interception before detach"
+ );
+
+ ctx.conn
+ .browser_context
+ .as_ref()
+ .and_then(|browser_context| browser_context.active_page_target().loaded_page())
+ .expect("fixture should retain a loaded Page")
+ .crash_devtools_target_from_io();
+
+ ctx.process_async(json!({
+ "id": 120_113,
+ "method": "Target.detachFromTarget",
+ "params": {
+ "targetId": "TID-detach-fetch-cleanup-failure",
+ "sessionId": "SID-fetch-cleanup-attached"
+ }
+ }))
+ .await;
+ ctx.expect_result(120_113, json!({}), None);
+
+ let target = ctx
+ .conn
+ .browser_context
+ .as_ref()
+ .unwrap()
+ .active_page_target();
+ assert!(
+ target.owner_state.target_crash_state.is_crashed(),
+ "a failed renderer Fetch cleanup must fail the Page closed"
+ );
+ assert!(target.loaded_page().is_none());
+ assert!(!target.fetch_owner.is_enabled());
+ assert_eq!(
+ ctx.conn.session_route(Some("SID-fetch-cleanup-attached")),
+ None,
+ "the binding should commit only after renderer ownership is gone"
+ );
+ assert!(
+ ctx.sent
+ .iter()
+ .any(|message| message["method"] == json!("Inspector.targetCrashed")),
+ "Fetch cleanup fail-close should be observable to Inspector clients: {:?}",
+ ctx.sent
+ );
+}
+
+async fn page_renderer_inspector_session_count(
+ ctx: &mut TestContext,
+ inspector_session_id: Option<&str>,
+ stage: &str,
+) -> u64 {
let page = ctx
.conn
.browser_context
.as_mut()
.and_then(|bc| bc.active_page_target_mut().runtime_slot.loaded_page_mut())
.expect("active target should still have a loaded page");
- // This diagnostic deliberately runs on the primary Inspector route. It
- // bypasses CdpConnection's session-aware Page accessor, so bind that route
- // explicitly instead of inheriting whichever auxiliary session the prior
- // command happened to stamp on the Page facade.
- page.set_renderer_devtools_command_session_id(None);
+ // This diagnostic bypasses CdpConnection's session-aware Page accessor, so
+ // bind the exact surviving Inspector route instead of inheriting whichever
+ // session the prior command happened to stamp on the Page facade.
+ page.set_renderer_devtools_command_session_id(inspector_session_id.map(str::to_owned));
let response = page
.runtime_heap_usage_async()
.await
@@ -2063,6 +2302,7 @@ async fn detach_from_target_emits_detached_event() {
.as_mut()
.unwrap()
.attach_active_session("SID-1");
+ ctx.conn.register_bound_session_for_test("SID-1");
ctx.process_async(json!({
"id": 14,
@@ -2130,6 +2370,82 @@ async fn detach_from_shared_worker_target_clears_session_and_emits_detached_even
);
}
+#[tokio::test(flavor = "multi_thread")]
+async fn detach_from_service_worker_target_disposes_session_runtime_state() {
+ let mut ctx = TestContext::new();
+ load_bc(&mut ctx, "BID-9");
+ push_service_worker_target(
+ &mut ctx,
+ 91,
+ "TID-service-worker",
+ "https://example.test/service-worker.js",
+ "https://example.test/",
+ Some("SID-service-worker"),
+ );
+ {
+ let target = ctx
+ .conn
+ .service_worker_target_for_session_mut(Some("SID-service-worker"))
+ .expect("service worker target should be attached");
+ target.register_pending_inspector_await(
+ "SID-service-worker",
+ 14_001,
+ Some("SID-service-worker"),
+ None,
+ );
+ target.register_runtime_remote_object_ids_for_session(
+ "SID-service-worker",
+ ["service-worker-object".to_owned()],
+ );
+ }
+ ctx.conn
+ .set_service_worker_pause_on_start_owner(Some("SID-service-worker"), true);
+
+ ctx.process_async(json!({
+ "id": 14,
+ "method": "Target.detachFromTarget",
+ "params": {
+ "targetId": "TID-service-worker",
+ "sessionId": "SID-service-worker"
+ }
+ }))
+ .await;
+
+ ctx.expect_result(14, json!({}), None);
+ let failed_await = ctx.take_one();
+ assert_eq!(failed_await["id"], json!(14_001));
+ assert_eq!(failed_await["sessionId"], json!("SID-service-worker"));
+ assert_eq!(failed_await["error"]["message"], json!("Target detached"));
+ ctx.expect_event(
+ "Target.detachedFromTarget",
+ Some(&json!({
+ "targetId": "TID-service-worker",
+ "sessionId": "SID-service-worker",
+ })),
+ );
+
+ assert_eq!(ctx.conn.session_route(Some("SID-service-worker")), None);
+ assert!(!ctx.conn.has_pending_inspector_awaits());
+ assert!(
+ ctx.conn
+ .validate_runtime_remote_object_ids_for_session_owner(
+ None,
+ &["service-worker-object".to_owned()],
+ )
+ .is_ok(),
+ "service worker remote-object ownership must be retired with its session"
+ );
+ assert!(!ctx.conn.service_worker_pause_on_start_for_devtools());
+ let target = ctx
+ .conn
+ .browser_context
+ .as_ref()
+ .unwrap()
+ .service_worker_target("TID-service-worker")
+ .expect("service worker target remains live after detach");
+ assert!(!target.has_session());
+}
+
#[tokio::test(flavor = "multi_thread")]
async fn detach_from_target_invalid_session_errors() {
let mut ctx = TestContext::new();
@@ -2182,6 +2498,7 @@ async fn detach_from_target_aborts_paused_request_stage_navigation() {
.runtime_slot
.enable_primary_network_events();
ctx.conn.browser_context = Some(bc);
+ ctx.conn.register_bound_session_for_test("SID-1");
ctx.process_async(json!({
"id": 40,
@@ -2275,7 +2592,7 @@ async fn set_auto_attach_false_detaches_existing_target() {
);
bc.active_page_target_mut().css_enabled = true;
bc.active_page_target_mut().fetch_owner.configure(
- None,
+ Some("SID-1".to_owned()),
true,
vec![crate::conn::FetchInterceptionPattern {
url_pattern: "*".into(),
@@ -2283,7 +2600,14 @@ async fn set_auto_attach_false_detaches_existing_target() {
request_stage: crate::conn::FetchRequestStage::Request,
}],
);
- ctx.conn.auto_attach = true;
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
+ ctx.conn
+ .register_auto_attached_session("SID-1".to_owned(), None);
ctx.process_async(json!({
"id": 16,
@@ -2364,7 +2688,7 @@ async fn set_auto_attach_false_detaches_existing_target() {
.extra_headers()
.is_empty()
);
- assert!(!ctx.conn.auto_attach);
+ assert!(!ctx.conn.auto_attach_enabled());
}
#[tokio::test(flavor = "multi_thread")]
@@ -2379,7 +2703,14 @@ async fn set_auto_attach_false_detaches_existing_shared_worker_target() {
"shared",
Some("SID-shared-worker"),
);
- ctx.conn.auto_attach = true;
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
+ ctx.conn
+ .register_auto_attached_session("SID-shared-worker".to_owned(), None);
ctx.process_async(json!({
"id": 16,
@@ -2406,7 +2737,7 @@ async fn set_auto_attach_false_detaches_existing_shared_worker_target() {
.and_then(|target| target.session_id()),
None
);
- assert!(!ctx.conn.auto_attach);
+ assert!(!ctx.conn.auto_attach_enabled());
}
#[tokio::test(flavor = "multi_thread")]
@@ -2421,7 +2752,14 @@ async fn set_auto_attach_false_cleans_shared_worker_runtime_state_before_detache
"shared",
Some("SID-shared-worker"),
);
- ctx.conn.auto_attach = true;
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
+ ctx.conn
+ .register_auto_attached_session("SID-shared-worker".to_owned(), None);
{
let target = ctx
.conn
@@ -2486,7 +2824,7 @@ async fn set_auto_attach_false_cleans_shared_worker_runtime_state_before_detache
.shared_worker_target("TID-shared-worker")
.expect("shared worker target remains live after auto-attach reset");
assert_eq!(target.session_id(), None);
- assert!(!ctx.conn.auto_attach);
+ assert!(!ctx.conn.auto_attach_enabled());
}
#[tokio::test(flavor = "multi_thread")]
@@ -2625,7 +2963,7 @@ async fn set_auto_attach_false_detaches_only_matching_browser_service_worker_own
);
assert!(ctx.sent.is_empty());
assert!(
- ctx.conn.auto_attach,
+ ctx.conn.auto_attach_enabled(),
"root autoAttach owner should remain active"
);
assert!(matches!(
@@ -2677,7 +3015,7 @@ async fn auto_attach_related_attaches_current_service_worker_target() {
.to_owned();
assert_eq!(ctx.take_one(), json!({ "id": 22, "result": {} }));
assert!(ctx.sent.is_empty());
- assert!(!ctx.conn.auto_attach);
+ assert!(!ctx.conn.auto_attach_enabled());
assert!(matches!(
ctx.conn.session_route(Some(&session_id)),
Some(CdpSessionRoute::ServiceWorkerTarget {
@@ -2753,7 +3091,7 @@ async fn set_auto_attach_from_background_session_uses_direct_session_route() {
"Target.setAutoAttach must not be blocked by DirectSessionRouteRequired: {:?}",
ctx.sent
);
- assert!(ctx.conn.auto_attach);
+ assert!(ctx.conn.auto_attach_enabled());
}
#[tokio::test(flavor = "multi_thread")]
@@ -2780,7 +3118,7 @@ async fn set_auto_attach_true_attaches_existing_unattached_target() {
assert_eq!(ctx.take_one(), json!({ "id": 17, "result": {} }));
let bc = ctx.conn.browser_context.as_ref().unwrap();
assert!(bc.has_active_session());
- assert!(ctx.conn.auto_attach);
+ assert!(ctx.conn.auto_attach_enabled());
}
#[tokio::test(flavor = "multi_thread")]
@@ -2806,7 +3144,7 @@ async fn set_auto_attach_wait_for_debugger_does_not_mark_existing_page_as_waitin
);
assert_eq!(event["params"]["waitingForDebugger"], json!(false));
assert_eq!(ctx.take_one(), json!({ "id": 1700, "result": {} }));
- assert!(ctx.conn.auto_attach);
+ assert!(ctx.conn.auto_attach_enabled());
}
#[tokio::test(flavor = "multi_thread")]
@@ -2959,7 +3297,7 @@ async fn set_auto_attach_true_attaches_existing_page_target_for_each_owner() {
.active_session_id(),
Some(root_session_id.as_str())
);
- assert!(ctx.conn.auto_attach);
+ assert!(ctx.conn.auto_attach_enabled());
}
#[tokio::test(flavor = "multi_thread")]
@@ -3001,7 +3339,7 @@ async fn set_auto_attach_true_attaches_existing_unattached_shared_worker_target(
ctx.conn.session_route(Some(session_id)),
Some(CdpSessionRoute::SharedWorkerTarget { .. })
));
- assert!(ctx.conn.auto_attach);
+ assert!(ctx.conn.auto_attach_enabled());
}
#[tokio::test(flavor = "multi_thread")]
@@ -3011,7 +3349,9 @@ async fn non_browser_auto_attach_owners_do_not_replay_existing_shared_worker_tar
assert!(
ctx.conn
.prepare_auto_attached_page_session_binding("TID-page", "SID-page".to_owned())
+ .is_some()
);
+ ctx.conn.register_bound_session_for_test("SID-page");
ctx.conn
.runtime_session_owner_slot_mut(Some("SID-page"))
.expect("page owner runtime slot")
@@ -3027,7 +3367,10 @@ async fn non_browser_auto_attach_owners_do_not_replay_existing_shared_worker_tar
"TID-dedicated-worker",
"SID-dedicated-worker".to_owned(),
)
+ .is_some()
);
+ ctx.conn
+ .register_bound_session_for_test("SID-dedicated-worker");
push_shared_worker_target(
&mut ctx,
SharedWorkerInstanceId::from_u64(2402),
@@ -3220,7 +3563,7 @@ async fn set_auto_attach_filter_excludes_existing_page_target() {
assert!(ctx.sent.is_empty());
let bc = ctx.conn.browser_context.as_ref().unwrap();
assert!(!bc.has_active_session());
- assert!(ctx.conn.auto_attach);
+ assert!(ctx.conn.auto_attach_enabled());
}
#[tokio::test(flavor = "multi_thread")]
@@ -3353,7 +3696,7 @@ async fn set_auto_attach_filter_page_exclude_catchall_auto_attaches_existing_tab
.has_active_session(),
"tab auto-attach must not directly attach the page"
);
- assert!(ctx.conn.auto_attach);
+ assert!(ctx.conn.auto_attach_enabled());
}
#[tokio::test(flavor = "multi_thread")]
@@ -3402,7 +3745,7 @@ async fn set_auto_attach_filter_allows_only_existing_service_worker_target() {
ctx.conn.session_route(Some(session_id)),
Some(CdpSessionRoute::ServiceWorkerTarget { .. })
));
- assert!(ctx.conn.auto_attach);
+ assert!(ctx.conn.auto_attach_enabled());
}
#[tokio::test(flavor = "multi_thread")]
@@ -3505,7 +3848,7 @@ async fn set_auto_attach_filter_excludes_existing_service_worker_target() {
.and_then(|bc| bc.service_worker_target("TID-service-worker"))
.expect("service worker target remains registered");
assert!(!target.has_session());
- assert!(ctx.conn.auto_attach);
+ assert!(ctx.conn.auto_attach_enabled());
}
#[tokio::test(flavor = "multi_thread")]
@@ -3579,5 +3922,5 @@ async fn set_auto_attach_true_does_not_reattach_existing_session() {
assert!(ctx.sent.is_empty());
let bc = ctx.conn.browser_context.as_ref().unwrap();
assert_eq!(bc.active_session_id(), Some("SID-keep"));
- assert!(ctx.conn.auto_attach);
+ assert!(ctx.conn.auto_attach_enabled());
}
diff --git a/moli-protocol/src/domains/target/tests/tests_target_basics.rs b/moli-protocol/src/domains/target/tests/tests_target_basics.rs
index 23bcde915..1694b2dd2 100644
--- a/moli-protocol/src/domains/target/tests/tests_target_basics.rs
+++ b/moli-protocol/src/domains/target/tests/tests_target_basics.rs
@@ -42,12 +42,10 @@ async fn close_active_target_fails_only_active_owner_pending_awaits() {
let mut bc = BrowserContext::new("BID-await-owner".into());
bc.set_active_target_id("TID-active-await".to_owned());
bc.attach_active_session("SID-active-await".to_owned());
- assert!(
- bc.assign_auxiliary_session_to_target(
- "TID-active-await",
- "SID-active-aux-await".to_owned(),
- )
- );
+ assert!(bc.assign_attached_session_to_target(
+ "TID-active-await",
+ "SID-active-attached-await".to_owned(),
+ ));
bc.insert_page_target_host(PageTargetHost::with_url(
"TID-bg-await".to_owned(),
Some("SID-bg-await".to_owned()),
@@ -57,7 +55,7 @@ async fn close_active_target_fails_only_active_owner_pending_awaits() {
ctx.conn
.register_pending_inspector_await(1041201, Some("SID-active-await"));
ctx.conn
- .register_pending_inspector_await(1041203, Some("SID-active-aux-await"));
+ .register_pending_inspector_await(1041203, Some("SID-active-attached-await"));
ctx.conn
.register_pending_inspector_await(1041202, Some("SID-bg-await"));
@@ -73,9 +71,12 @@ async fn close_active_target_fails_only_active_owner_pending_awaits() {
let active_failed = take_response_by_id(&mut ctx, 1041201);
assert_eq!(active_failed["sessionId"], json!("SID-active-await"));
assert_eq!(active_failed["error"]["message"], json!("Target closed"));
- let auxiliary_failed = take_response_by_id(&mut ctx, 1041203);
- assert_eq!(auxiliary_failed["sessionId"], json!("SID-active-aux-await"));
- assert_eq!(auxiliary_failed["error"]["message"], json!("Target closed"));
+ let attached_failed = take_response_by_id(&mut ctx, 1041203);
+ assert_eq!(
+ attached_failed["sessionId"],
+ json!("SID-active-attached-await")
+ );
+ assert_eq!(attached_failed["error"]["message"], json!("Target closed"));
assert!(
ctx.take_all().into_iter().all(|message| {
message["id"] != json!(1041201)
@@ -193,7 +194,7 @@ async fn attach_to_target_selects_inactive_browser_context() {
}
#[tokio::test(flavor = "multi_thread")]
-async fn attach_to_target_creates_auxiliary_session_and_keeps_target_context_active() {
+async fn attach_to_target_creates_attached_session_and_keeps_target_context_active() {
let mut ctx = TestContext::new();
load_bc_with_target(&mut ctx, "BID-A", "TID-A");
let mut inactive = BrowserContext::new("BID-B".into());
@@ -229,7 +230,7 @@ async fn attach_to_target_creates_auxiliary_session_and_keeps_target_context_act
ctx.conn
.browser_context
.as_ref()
- .and_then(|bc| bc.auxiliary_target_id_for_session(&attached_session_id)),
+ .and_then(|bc| bc.attached_target_id_for_session(&attached_session_id)),
Some("TID-B")
);
assert!(
@@ -481,7 +482,12 @@ async fn create_target_for_inactive_browser_context_keeps_previously_active_cont
async fn create_target_with_auto_attach_attaches_second_target_in_same_browser_context() {
let mut ctx = TestContext::new();
load_bc_with_target(&mut ctx, "BID-9", "TID-000000000A");
- ctx.conn.auto_attach = true;
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
ctx.process_async(json!({"id": 10, "method": "Target.createTarget",
"params": {
@@ -516,7 +522,7 @@ async fn create_target_with_auto_attach_attaches_second_target_in_same_browser_c
}
#[tokio::test(flavor = "multi_thread")]
-async fn page_command_on_auto_attached_background_target_session_routes_without_promoting_loaded_active_target()
+async fn page_command_on_auto_attached_background_target_session_routes_without_activating_loaded_active_target()
{
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
@@ -531,7 +537,12 @@ async fn page_command_on_auto_attached_background_target_session_routes_without_
.as_mut()
.unwrap()
.attach_active_session("SID-active");
- ctx.conn.auto_attach = true;
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
ctx.process_async(json!({
"id": 101,
@@ -583,7 +594,7 @@ async fn page_command_on_auto_attached_background_target_session_routes_without_
assert!(
bc.background_target(&second_target_id)
.is_some_and(|target| target.has_loaded_page()),
- "background Page.navigate should load the parked target without promoting it"
+ "background Page.navigate should load the background target without activating it"
);
ctx.process_async(json!({
@@ -606,7 +617,7 @@ async fn page_command_on_auto_attached_background_target_session_routes_without_
}
#[tokio::test(flavor = "multi_thread")]
-async fn page_bring_to_front_promotes_background_session_explicitly() {
+async fn page_bring_to_front_activates_background_session_explicitly() {
let mut ctx = TestContext::new();
load_bc_with_target(&mut ctx, "BID-9", "TID-000000000A");
ctx.conn
@@ -614,7 +625,12 @@ async fn page_bring_to_front_promotes_background_session_explicitly() {
.as_mut()
.unwrap()
.attach_active_session("SID-active");
- ctx.conn.auto_attach = true;
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
ctx.process_async(json!({
"id": 1021,
@@ -692,13 +708,13 @@ async fn page_bring_to_front_on_inactive_context_restores_previous_context() {
.inactive_browser_contexts
.iter()
.find(|bc| bc.id == "BID-B")
- .expect("inactive context should remain parked");
+ .expect("inactive context should remain background");
assert_eq!(inactive.active_target_id(), Some("TID-active-b"));
assert_eq!(inactive.active_session_id(), Some("SID-active-b"));
}
#[tokio::test(flavor = "multi_thread")]
-async fn page_navigate_on_auto_attached_background_target_session_routes_without_promotion() {
+async fn page_navigate_on_auto_attached_background_target_session_routes_without_activation() {
let mut ctx = TestContext::new();
load_bc_with_target(&mut ctx, "BID-9", "TID-000000000A");
ctx.conn
@@ -706,7 +722,12 @@ async fn page_navigate_on_auto_attached_background_target_session_routes_without
.as_mut()
.unwrap()
.attach_active_session("SID-active");
- ctx.conn.auto_attach = true;
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
ctx.process_async(json!({
"id": 1031,
@@ -758,7 +779,7 @@ async fn page_navigate_on_auto_attached_background_target_session_routes_without
assert!(
bc.background_target(&second_target_id)
.is_some_and(|target| target.has_loaded_page()),
- "background Page.navigate should load the parked target without promoting it"
+ "background Page.navigate should load the background target without activating it"
);
ctx.process_async(json!({
@@ -781,7 +802,7 @@ async fn page_navigate_on_auto_attached_background_target_session_routes_without
}
#[tokio::test(flavor = "multi_thread")]
-async fn page_stop_loading_aborts_background_pending_fetch_without_promotion() {
+async fn page_stop_loading_aborts_background_pending_fetch_without_activation() {
let mut ctx = TestContext::new();
load_bc_with_titled_page_async(
&mut ctx,
@@ -795,7 +816,12 @@ async fn page_stop_loading_aborts_background_pending_fetch_without_promotion() {
.as_mut()
.unwrap()
.attach_active_session("SID-active");
- ctx.conn.auto_attach = true;
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
ctx.process_async(json!({
"id": 1034,
@@ -881,7 +907,7 @@ async fn page_stop_loading_aborts_background_pending_fetch_without_promotion() {
assert_eq!(bc.active_target_id(), Some("TID-000000000A"));
let background = bc
.background_target(&second_target_id)
- .expect("background target should remain parked");
+ .expect("background target should remain background");
assert_eq!(background.session_id(), Some(session_id.as_str()));
assert!(
bc.background_target(&second_target_id)
@@ -894,7 +920,7 @@ async fn page_stop_loading_aborts_background_pending_fetch_without_promotion() {
}
#[tokio::test(flavor = "multi_thread")]
-async fn runtime_add_binding_and_preload_then_remove_on_auto_attached_background_target_session_prevent_first_navigation_replay_after_empty_slot_promotion()
+async fn runtime_add_binding_and_preload_then_remove_on_auto_attached_background_target_session_prevent_first_navigation_replay_after_empty_slot_activation()
{
let mut ctx = TestContext::new();
load_bc_with_target(&mut ctx, "BID-9", "TID-000000000A");
@@ -903,7 +929,12 @@ async fn runtime_add_binding_and_preload_then_remove_on_auto_attached_background
.as_mut()
.unwrap()
.attach_active_session("SID-active");
- ctx.conn.auto_attach = true;
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
ctx.process_async(json!({
"id": 10360,
@@ -1032,7 +1063,7 @@ async fn runtime_add_binding_and_preload_then_remove_on_auto_attached_background
}
#[tokio::test(flavor = "multi_thread")]
-async fn runtime_remove_binding_on_background_target_session_routes_without_promotion_when_active_target_has_no_loaded_page()
+async fn runtime_remove_binding_on_background_target_session_routes_without_activation_when_active_target_has_no_loaded_page()
{
let mut ctx = TestContext::new();
load_bc_with_target(&mut ctx, "BID-9", "TID-000000000A");
@@ -1041,7 +1072,12 @@ async fn runtime_remove_binding_on_background_target_session_routes_without_prom
.as_mut()
.unwrap()
.attach_active_session("SID-active");
- ctx.conn.auto_attach = true;
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
ctx.process_async(json!({
"id": 1036,
@@ -1109,7 +1145,7 @@ async fn runtime_remove_binding_on_background_target_session_routes_without_prom
.runtime_bindings
.iter()
.all(|binding| binding.name != "patchedBinding")),
- "binding definition should be removed from the background DevTools session without promotion"
+ "binding definition should be removed from the background DevTools session without activation"
);
}
@@ -1123,7 +1159,12 @@ async fn same_context_targets_replay_only_their_own_pre_document_binding_and_pre
.as_mut()
.unwrap()
.attach_active_session("SID-active");
- ctx.conn.auto_attach = true;
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
ctx.process_async(json!({
"id": 10390,
@@ -1335,7 +1376,12 @@ async fn same_context_targets_materialize_only_their_own_utility_pre_document_bi
.as_mut()
.unwrap()
.attach_active_session("SID-active");
- ctx.conn.auto_attach = true;
+ ctx.conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
ctx.process_async(json!({
"id": 10402,
@@ -1725,9 +1771,9 @@ async fn same_context_targets_do_not_replay_bare_isolated_worlds_after_switching
"params": { "expression": "document.title" }
}))
.await;
- let second_promote = take_response_by_id(&mut ctx, 10415041);
+ let second_activate = take_response_by_id(&mut ctx, 10415041);
assert_eq!(
- second_promote["result"]["result"]["value"],
+ second_activate["result"]["result"]["value"],
json!("second-target")
);
ctx.conn
diff --git a/moli-protocol/src/domains/target/tests/tests_target_creation.rs b/moli-protocol/src/domains/target/tests/tests_target_creation.rs
index 6765fda0d..2ac5cb5a3 100644
--- a/moli-protocol/src/domains/target/tests/tests_target_creation.rs
+++ b/moli-protocol/src/domains/target/tests/tests_target_creation.rs
@@ -627,6 +627,19 @@ async fn detached_browser_target_session_stops_receiving_discovery_events() {
}))
.await;
ctx.expect_result(10059, json!({}), Some(&browser_session_id));
+ ctx.conn.set_auto_attach_owner(
+ Some(&browser_session_id),
+ true,
+ true,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
+ ctx.conn
+ .download_behavior
+ .set_browser_events_enabled_for_session(Some(&browser_session_id), true);
+ ctx.conn
+ .set_service_worker_pause_on_start_owner(Some(&browser_session_id), true);
+ ctx.conn
+ .set_dedicated_worker_pause_on_start_owner(Some(&browser_session_id), true);
ctx.sent.clear();
ctx.process_async(json!({
@@ -636,6 +649,20 @@ async fn detached_browser_target_session_stops_receiving_discovery_events() {
}))
.await;
ctx.expect_result(10060, json!({}), None);
+ assert_eq!(ctx.conn.session_route(Some(&browser_session_id)), None);
+ assert!(
+ !ctx.conn
+ .auto_attach_owner_sessions_for_target_type("page")
+ .contains(&Some(browser_session_id.clone()))
+ );
+ assert!(
+ !ctx.conn
+ .download_behavior
+ .browser_event_session_ids()
+ .contains(&Some(browser_session_id.clone()))
+ );
+ assert!(!ctx.conn.service_worker_pause_on_start_for_devtools());
+ assert!(!ctx.conn.dedicated_worker_pause_on_start_for_devtools());
ctx.sent.clear();
ctx.process_async(json!({
@@ -1020,7 +1047,7 @@ async fn window_open_hands_off_session_storage_snapshot_and_initial_storage_key(
// The opener's lightweight WindowProxy facade starts its mirrored
// load before the concrete popup action can reach protocol. Let that
// renderer-local request finish; gate the second request, which is the
- // real auxiliary target navigation whose lifetime this test covers.
+ // real attached target navigation whose lifetime this test covers.
let request_index = request_count.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
if request_index == 0 {
return opener().await;
@@ -2077,7 +2104,7 @@ fn popup_target_id_for_url(messages: &[serde_json::Value], url: &str) -> String
}
#[tokio::test(flavor = "multi_thread")]
-async fn anchor_left_click_promotes_blank_target_to_foreground() {
+async fn anchor_left_click_activates_blank_target_to_foreground() {
const POPUP_HREF: &str = "data:text/html,%3Cmain%3Eforeground-popup%3C/main%3E";
const POPUP_URL: &str = "data:text/html,<main>foreground-popup</main>";
let mut ctx = TestContext::new();
@@ -2111,7 +2138,7 @@ async fn anchor_left_click_promotes_blank_target_to_foreground() {
browser_context
.background_target("TID-anchor-foreground-opener")
.is_some(),
- "foreground popup should demote its opener"
+ "foreground popup should deactivate its opener"
);
})
.await;
@@ -3051,7 +3078,7 @@ async fn incomplete_popup_rollback_clears_tab_page_sessions_and_target_graph() {
);
assert!(browser_context.assign_auto_attached_session_to_target(
page_target_id,
- "SID-popup-page-aux".to_owned()
+ "SID-popup-page-attached".to_owned()
));
browser_context.remember_target_window_name("popupName", page_target_id);
browser_context.remember_target_popup_id(Some(42), page_target_id);
@@ -3066,7 +3093,7 @@ async fn incomplete_popup_rollback_clears_tab_page_sessions_and_target_graph() {
ctx.conn
.register_auto_attached_session("SID-popup-page-primary".to_owned(), None);
ctx.conn
- .register_auto_attached_session("SID-popup-page-aux".to_owned(), None);
+ .register_auto_attached_session("SID-popup-page-attached".to_owned(), None);
assert!(ctx.conn.session_route(Some("SID-popup-tab")).is_some());
assert!(
@@ -3074,7 +3101,11 @@ async fn incomplete_popup_rollback_clears_tab_page_sessions_and_target_graph() {
.session_route(Some("SID-popup-page-primary"))
.is_some()
);
- assert!(ctx.conn.session_route(Some("SID-popup-page-aux")).is_some());
+ assert!(
+ ctx.conn
+ .session_route(Some("SID-popup-page-attached"))
+ .is_some()
+ );
assert_eq!(ctx.conn.tab_target_count(), 1);
popup::rollback_incomplete_popup_target_async(
@@ -3086,7 +3117,10 @@ async fn incomplete_popup_rollback_clears_tab_page_sessions_and_target_graph() {
assert_eq!(ctx.conn.session_route(Some("SID-popup-tab")), None);
assert_eq!(ctx.conn.session_route(Some("SID-popup-page-primary")), None);
- assert_eq!(ctx.conn.session_route(Some("SID-popup-page-aux")), None);
+ assert_eq!(
+ ctx.conn.session_route(Some("SID-popup-page-attached")),
+ None
+ );
assert!(ctx.conn.auto_attached_sessions_for_owner(None).is_empty());
assert_eq!(ctx.conn.tab_target_count(), 0);
assert!(
@@ -3119,7 +3153,7 @@ async fn incomplete_active_popup_rollback_clears_active_slot_sessions_and_target
browser_context.attach_active_session("SID-active-popup-page-primary");
assert!(browser_context.assign_auto_attached_session_to_target(
page_target_id,
- "SID-active-popup-page-aux".to_owned()
+ "SID-active-popup-page-attached".to_owned()
));
}
assert!(ctx.conn.assign_session_to_tab_target(
@@ -3132,7 +3166,7 @@ async fn incomplete_active_popup_rollback_clears_active_slot_sessions_and_target
ctx.conn
.register_auto_attached_session("SID-active-popup-page-primary".to_owned(), None);
ctx.conn
- .register_auto_attached_session("SID-active-popup-page-aux".to_owned(), None);
+ .register_auto_attached_session("SID-active-popup-page-attached".to_owned(), None);
assert!(
ctx.conn
@@ -3146,7 +3180,7 @@ async fn incomplete_active_popup_rollback_clears_active_slot_sessions_and_target
);
assert!(
ctx.conn
- .session_route(Some("SID-active-popup-page-aux"))
+ .session_route(Some("SID-active-popup-page-attached"))
.is_some()
);
assert_eq!(ctx.conn.tab_target_count(), 1);
@@ -3165,7 +3199,8 @@ async fn incomplete_active_popup_rollback_clears_active_slot_sessions_and_target
None
);
assert_eq!(
- ctx.conn.session_route(Some("SID-active-popup-page-aux")),
+ ctx.conn
+ .session_route(Some("SID-active-popup-page-attached")),
None
);
assert!(ctx.conn.auto_attached_sessions_for_owner(None).is_empty());
@@ -3208,9 +3243,14 @@ async fn unannounced_page_session_cleanup_clears_route_and_auto_attached_owner_i
vec!["SID-page-cleanup".to_owned()]
);
- let prepared = ctx.conn.prepare_auto_attach_session_commit(
+ let prepared = crate::conn::TargetAttachSessionCommit::auto_attached(
"SID-page-cleanup",
Some("SID-tab-owner".to_owned()),
+ crate::conn::CdpSessionRoute::PageTarget {
+ browser_context_id: "BID-page-session-cleanup".to_owned(),
+ target_id: "TID-page-cleanup".to_owned(),
+ session_key: moli_page_types::DevToolsSessionKey::Primary,
+ },
false,
);
let rollback_plan = ctx
diff --git a/moli-protocol/src/domains/target/tests/tests_target_management.rs b/moli-protocol/src/domains/target/tests/tests_target_management.rs
index 3452ff124..f7d9edd60 100644
--- a/moli-protocol/src/domains/target/tests/tests_target_management.rs
+++ b/moli-protocol/src/domains/target/tests/tests_target_management.rs
@@ -301,7 +301,7 @@ async fn close_target_emits_detached_events() {
let session_id = "SID-000000000A".to_owned();
let bc = ctx.conn.browser_context.as_mut().unwrap();
bc.attach_active_session(session_id.clone());
- assert!(bc.assign_auxiliary_session_to_target("TID-000000000A", "SID-aux".into()));
+ assert!(bc.assign_attached_session_to_target("TID-000000000A", "SID-attached".into()));
bc.active_page_target_mut().devtools_sessions[moli_page_types::DevToolsSessionKey::Primary]
.runtime_session_state
.inspector_enabled = true;
@@ -318,11 +318,11 @@ async fn close_target_emits_detached_events() {
primary_inspector["params"]["reason"],
"Render process gone."
);
- let auxiliary_inspector = ctx.take_one();
- assert_eq!(auxiliary_inspector["method"], "Inspector.detached");
- assert_eq!(auxiliary_inspector["sessionId"], "SID-aux");
+ let attached_inspector = ctx.take_one();
+ assert_eq!(attached_inspector["method"], "Inspector.detached");
+ assert_eq!(attached_inspector["sessionId"], "SID-attached");
assert_eq!(
- auxiliary_inspector["params"]["reason"],
+ attached_inspector["params"]["reason"],
"Render process gone."
);
ctx.expect_event(
@@ -336,11 +336,11 @@ async fn close_target_emits_detached_events() {
"Target.detachedFromTarget",
Some(&json!({
"targetId": "TID-000000000A",
- "sessionId": "SID-aux"
+ "sessionId": "SID-attached"
})),
);
let bc = ctx.conn.browser_context.as_ref().unwrap();
- assert!(bc.auxiliary_target_id_for_session("SID-aux").is_none());
+ assert!(bc.attached_target_id_for_session("SID-attached").is_none());
}
#[tokio::test(flavor = "multi_thread")]
@@ -521,7 +521,7 @@ async fn close_background_target_emits_detached_events_and_clears_attached_sessi
Some("SID-bg"),
);
let bc = ctx.conn.browser_context.as_mut().unwrap();
- assert!(bc.assign_auxiliary_session_to_target("TID-000000000B", "SID-aux".into()));
+ assert!(bc.assign_attached_session_to_target("TID-000000000B", "SID-attached".into()));
bc.background_target_mut("TID-000000000B")
.expect("background target must exist")
.devtools_sessions[moli_page_types::DevToolsSessionKey::Primary] =
@@ -556,13 +556,13 @@ async fn close_background_target_emits_detached_events_and_clears_attached_sessi
"Target.detachedFromTarget",
Some(&json!({
"targetId": "TID-000000000B",
- "sessionId": "SID-aux"
+ "sessionId": "SID-attached"
})),
);
let bc = ctx.conn.browser_context.as_ref().unwrap();
assert!(bc.background_target("TID-000000000B").is_none());
- assert!(bc.auxiliary_target_id_for_session("SID-aux").is_none());
+ assert!(bc.attached_target_id_for_session("SID-attached").is_none());
assert!(
bc.background_target("TID-000000000B")
.filter(|target| target.has_non_default_session_state())
@@ -1167,7 +1167,7 @@ async fn activate_target_returns_empty_result_for_known_target() {
}
#[tokio::test(flavor = "multi_thread")]
-async fn activate_target_promotes_background_target_into_active_slot() {
+async fn activate_target_selects_background_target_as_active() {
let mut ctx = TestContext::new();
load_bc_with_target(&mut ctx, "BID-9", "TID-000000000A");
push_background_target(&mut ctx, "TID-000000000B", "about:blank", None);
diff --git a/moli-protocol/src/domains/target/worker_target.rs b/moli-protocol/src/domains/target/worker_target.rs
index ffa219559..db598502a 100644
--- a/moli-protocol/src/domains/target/worker_target.rs
+++ b/moli-protocol/src/domains/target/worker_target.rs
@@ -31,10 +31,11 @@ use crate::devtools_runtime::{
};
use crate::{
conn::{
- BackgroundProtocolEvent, CdpConnection, CommandOwnerScope, PreparedTargetAttach,
- PreparedTargetHostDelta, RendererPageResidenceIdentity,
+ BackgroundProtocolEvent, CdpConnection, CdpSessionRoute, CommandOwnerScope,
+ PreparedTargetAttach, PreparedTargetHostDelta, RendererPageResidenceIdentity,
ServiceWorkerRuntimeExceptionSnapshot, ServiceWorkerTargetState, SharedWorkerTargetState,
- TargetPageResidenceIdentity, TargetServiceWorkerProtocolAttachmentIdentity,
+ TargetAttachSessionCommit, TargetPageResidenceIdentity,
+ TargetServiceWorkerProtocolAttachmentIdentity,
TargetServiceWorkerProtocolAttachmentRetirement, TargetServiceWorkerRunIdentity,
TargetServiceWorkerRunRetirement, TargetServiceWorkerRuntimeAttachmentIdentity,
TargetServiceWorkerVersionIdentity, TargetServiceWorkerVersionRetirement,
@@ -847,9 +848,13 @@ fn record_dedicated_worker_main_script(
else {
continue;
};
- let prepared_session = conn.prepare_auto_attach_session_commit(
+ let prepared_session = TargetAttachSessionCommit::auto_attached(
session_id.clone(),
owner_session_id,
+ CdpSessionRoute::DedicatedWorkerTarget {
+ browser_context_id: browser_context_id.to_owned(),
+ target_id: target_id.clone(),
+ },
waiting_for_debugger,
);
if waiting_for_debugger
@@ -1241,13 +1246,22 @@ async fn commit_dedicated_worker_retirement_output_async(
conn.prepared_target_info_changed_event_plan_for_discovery_owners(target_delta),
);
}
- events.extend(
- conn.detach_dedicated_worker_session_with_binding_cleanup_event_plan_async(
- cleanup_plan,
- )
- .await
- .expect("retired dedicated-worker session cleanup should succeed"),
+ let mut response_events = Vec::new();
+ let outcome = super::session_disposal::dispose_dedicated_worker_session_after_prepared_state_delta_async(
+ conn,
+ &mut events,
+ &mut response_events,
+ cleanup_plan,
+ )
+ .await
+ .expect("retired dedicated-worker session cleanup should succeed");
+ let (event_plan, predecessor) = outcome.into_parts();
+ debug_assert!(
+ predecessor.is_none(),
+ "DedicatedWorker disposal cannot publish a Page renderer fence"
);
+ events.extend(response_events);
+ events.extend(event_plan);
}
WorkerTargetLifecycleOutput::DedicatedWorkerDestroyed {
browser_context_id,
@@ -1332,7 +1346,8 @@ fn commit_failed_dedicated_worker_retirement_sync(
);
}
events.extend(
- conn.detach_dedicated_worker_session_after_target_removal_event_plan(
+ super::session_disposal::dispose_removed_dedicated_worker_session_after_failed_retirement(
+ conn,
cleanup_plan,
),
);
@@ -1560,20 +1575,28 @@ fn register_shared_worker_target(
)
{
let attachment = conn
- .shared_worker_protocol_attachment_identity_for_session(Some(&session_id))
+ .browser_context_by_id(browser_context_id)
+ .and_then(|context| context.shared_worker_target(&target_id))
+ .and_then(|target| {
+ target.protocol_attachment_identity(browser_context_id, &session_id)
+ })
.expect("new shared-worker session must expose its exact attachment identity");
- let prepared_session = conn.prepare_auto_attach_session_commit(
+ let prepared_session = TargetAttachSessionCommit::auto_attached(
session_id,
owner_session_id,
+ CdpSessionRoute::SharedWorkerTarget {
+ browser_context_id: browser_context_id.to_owned(),
+ target_id: target_id.clone(),
+ },
waiting_for_debugger,
);
assert!(
matches!(
prepared_session.route(),
- Some(crate::conn::CdpSessionRoute::SharedWorkerTarget {
+ CdpSessionRoute::SharedWorkerTarget {
browser_context_id: route_browser_context_id,
target_id: route_target_id,
- }) if route_browser_context_id == browser_context_id
+ } if route_browser_context_id == browser_context_id
&& route_target_id == &target_id
),
"shared-worker auto-attach must freeze its exact target route at capture"
@@ -1687,9 +1710,13 @@ fn register_service_worker_target_with_active_run(
session_id.clone(),
)
{
- let prepared_session = conn.prepare_auto_attach_session_commit(
+ let prepared_session = TargetAttachSessionCommit::auto_attached(
session_id.clone(),
owner_session_id,
+ CdpSessionRoute::ServiceWorkerTarget {
+ browser_context_id: browser_context_id.to_owned(),
+ target_id: target_id.clone(),
+ },
waiting_for_debugger,
);
let prepared_attach =
@@ -2953,10 +2980,12 @@ async fn emit_target_lifecycle_events(
retirement.identity().session_id(),
"shared-worker detach plan must retain its exact attachment"
);
- let event_plan = conn
- .detach_session_with_binding_cleanup_event_plan_async(cleanup_plan)
- .await
- .expect("retired shared-worker session cleanup should succeed");
+ let event_plan = super::session_disposal::dispose_removed_worker_session_async(
+ conn,
+ cleanup_plan,
+ )
+ .await
+ .expect("retired shared-worker session cleanup should succeed");
side_effects.extend_background_events(event_plan);
retirement.retire();
}
@@ -2977,10 +3006,12 @@ async fn emit_target_lifecycle_events(
retirement.identity().session_id(),
"service-worker detach plan must retain its exact attachment"
);
- let event_plan = conn
- .detach_session_with_binding_cleanup_event_plan_async(cleanup_plan)
- .await
- .expect("retired service-worker session cleanup should succeed");
+ let event_plan = super::session_disposal::dispose_removed_worker_session_async(
+ conn,
+ cleanup_plan,
+ )
+ .await
+ .expect("retired service-worker session cleanup should succeed");
side_effects.extend_background_events(event_plan);
retirement.retire();
}
@@ -3732,7 +3763,8 @@ mod tests {
assert!(conn.prepare_auto_attached_page_session_binding(
"TID-page",
"SID-page-base".to_owned(),
- ));
+ ).is_some());
+ conn.register_bound_session_for_test("SID-page-base");
conn.set_auto_attach_owner(
Some("SID-page-base"),
true,
@@ -3980,7 +4012,7 @@ mod tests {
assert!(conn.prepare_auto_attached_page_session_binding(
"TID-page",
"SID-page-base".to_owned(),
- ));
+ ).is_some());
conn.browser_context
.as_mut()
.unwrap()
@@ -3989,6 +4021,8 @@ mod tests {
Some("SID-other-page".to_owned()),
"about:blank".to_owned(),
));
+ conn.register_bound_session_for_test("SID-page-base");
+ conn.register_bound_session_for_test("SID-other-page");
for owner in [None, Some("SID-page-base"), Some("SID-other-page")] {
conn.set_auto_attach_owner(owner, true, false, CdpTargetFilter::default_auto_attach());
}
@@ -4417,7 +4451,8 @@ mod tests {
assert!(conn.prepare_auto_attached_page_session_binding(
"TID-page",
"SID-page-base".to_owned(),
- ));
+ ).is_some());
+ conn.register_bound_session_for_test("SID-page-base");
conn.set_target_discovery_for_owner(
Some("SID-page-base"),
CdpTargetFilter::default_target_discovery(),
@@ -4890,6 +4925,7 @@ mod tests {
#[test]
fn service_worker_target_registration_auto_attaches_when_enabled() {
let mut conn = CdpConnection::default();
+ conn.require_committed_session_routes_for_test();
conn.set_root_target_discovery_enabled(true);
conn.set_auto_attach_owner(None, true, true, CdpTargetFilter::default_auto_attach());
conn.browser_context = Some(BrowserContext::new("BID-1".to_owned()));
@@ -4914,12 +4950,13 @@ mod tests {
.is_some_and(crate::conn::TargetAttachSessionCommit::waiting_for_debugger),
"service worker autoAttach output should preserve waitForDebuggerOnStart"
);
+ assert_eq!(conn.session_route(Some(session_id)), None);
assert_eq!(
- conn.session_route(Some(session_id)),
- Some(crate::conn::CdpSessionRoute::ServiceWorkerTarget {
+ prepared_attach.sessions()[0].route(),
+ &crate::conn::CdpSessionRoute::ServiceWorkerTarget {
browser_context_id: "BID-1".to_owned(),
target_id: target_id.clone(),
- })
+ }
);
}
@@ -5080,6 +5117,7 @@ mod tests {
#[test]
fn service_worker_target_registration_auto_attaches_related_newer_version() {
let mut conn = CdpConnection::default();
+ conn.require_committed_session_routes_for_test();
conn.browser_context = Some(BrowserContext::new("BID-1".to_owned()));
assert!(
register_service_worker_target(&mut conn, "BID-1", service_worker_info(7)).is_empty()
@@ -5123,12 +5161,13 @@ mod tests {
.is_some_and(crate::conn::TargetAttachSessionCommit::waiting_for_debugger),
"related autoAttach output should preserve waitForDebuggerOnStart"
);
+ assert_eq!(conn.session_route(Some(session_id)), None);
assert!(matches!(
- conn.session_route(Some(session_id)),
- Some(crate::conn::CdpSessionRoute::ServiceWorkerTarget {
+ prepared_attach.sessions()[0].route(),
+ crate::conn::CdpSessionRoute::ServiceWorkerTarget {
browser_context_id,
target_id: attached_target_id,
- }) if browser_context_id == "BID-1" && attached_target_id == target_id
+ } if browser_context_id == "BID-1" && attached_target_id == &target_id
));
}
@@ -5412,7 +5451,12 @@ mod tests {
#[test]
fn service_worker_target_destruction_detaches_session_before_destroyed() {
let mut conn = CdpConnection::default();
- conn.auto_attach = true;
+ conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
conn.set_root_target_discovery_enabled(true);
conn.browser_context = Some(BrowserContext::new("BID-1".to_owned()));
@@ -5459,7 +5503,12 @@ mod tests {
#[test]
fn service_worker_target_stopped_retains_target_and_clears_runtime_sessions() {
let mut conn = CdpConnection::default();
- conn.auto_attach = true;
+ conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
conn.set_root_target_discovery_enabled(true);
conn.browser_context = Some(BrowserContext::new("BID-1".to_owned()));
@@ -5556,7 +5605,12 @@ mod tests {
#[test]
fn service_worker_target_started_reloads_after_crash_once() {
let mut conn = CdpConnection::default();
- conn.auto_attach = true;
+ conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
conn.set_root_target_discovery_enabled(true);
conn.browser_context = Some(BrowserContext::new("BID-1".to_owned()));
@@ -5604,7 +5658,12 @@ mod tests {
#[tokio::test]
async fn service_worker_restart_emits_reload_before_new_runtime_context() {
let mut conn = CdpConnection::default();
- conn.auto_attach = true;
+ conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
conn.set_root_target_discovery_enabled(true);
conn.browser_context = Some(BrowserContext::new("BID-1".to_owned()));
@@ -5949,7 +6008,13 @@ mod tests {
#[test]
fn shared_worker_target_registration_auto_attaches_when_enabled() {
let mut conn = CdpConnection::default();
- conn.auto_attach = true;
+ conn.require_committed_session_routes_for_test();
+ conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
conn.browser_context = Some(BrowserContext::new("BID-1".to_owned()));
let outputs =
@@ -5963,9 +6028,10 @@ mod tests {
attachment.target_id(),
target_info_id(prepared_attach.target_info())
);
+ assert_eq!(conn.session_route(Some(attachment.session_id())), None);
assert!(matches!(
- conn.session_route(Some(attachment.session_id())),
- Some(crate::conn::CdpSessionRoute::SharedWorkerTarget { .. })
+ prepared_attach.sessions()[0].route(),
+ crate::conn::CdpSessionRoute::SharedWorkerTarget { .. }
));
assert!(attachment.is_current());
}
@@ -5975,7 +6041,9 @@ mod tests {
let (mut conn, owner_page, owner_renderer_page) = dedicated_worker_fixture();
assert!(
conn.prepare_auto_attached_page_session_binding("TID-page", "SID-page".to_owned(),)
+ .is_some()
);
+ conn.register_bound_session_for_test("SID-page");
conn.register_browser_session("SID-browser-1".to_owned());
conn.register_browser_session("SID-browser-2".to_owned());
@@ -5990,10 +6058,14 @@ mod tests {
"https://example.test/worker.js".to_owned(),
Vec::new(),
));
- assert!(conn.prepare_auto_attached_dedicated_worker_session_binding(
- "TID-dedicated-worker",
- "SID-dedicated-worker".to_owned(),
- ));
+ assert!(
+ conn.prepare_auto_attached_dedicated_worker_session_binding(
+ "TID-dedicated-worker",
+ "SID-dedicated-worker".to_owned(),
+ )
+ .is_some()
+ );
+ conn.register_bound_session_for_test("SID-dedicated-worker");
let mut owner_shared_worker = SharedWorkerTargetState::new(
moli_core::RendererOwnerLocalHostId::new_for_testing(2),
@@ -6008,6 +6080,7 @@ mod tests {
.as_mut()
.expect("browser context")
.insert_shared_worker_target(owner_shared_worker);
+ conn.register_bound_session_for_test("SID-shared-worker");
for (owner, wait_for_debugger_on_start) in [
(None, false),
@@ -6621,7 +6694,12 @@ mod tests {
#[test]
fn shared_worker_target_destruction_detaches_session_before_destroyed() {
let mut conn = CdpConnection::default();
- conn.auto_attach = true;
+ conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
conn.set_root_target_discovery_enabled(true);
conn.browser_context = Some(BrowserContext::new("BID-1".to_owned()));
@@ -6666,7 +6744,12 @@ mod tests {
#[tokio::test]
async fn shared_worker_target_destruction_terminates_all_renderer_calls() {
let mut conn = CdpConnection::default();
- conn.auto_attach = true;
+ conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
conn.set_root_target_discovery_enabled(true);
conn.browser_context = Some(BrowserContext::new("BID-1".to_owned()));
@@ -6712,7 +6795,7 @@ mod tests {
.expect("non-await renderer call should register");
let (correlation, old_sender, terminal_receiver) = prepared.into_parts();
let terminal_receiver = terminal_receiver
- .expect("a synthesized CommandReply call must allocate a response receiver");
+ .expect("a synthesized AdapterReply call must allocate a response receiver");
let outputs =
remove_shared_worker_target(&mut conn, "BID-1", SharedWorkerInstanceId::from_u64(15))
@@ -6783,7 +6866,12 @@ mod tests {
#[test]
fn late_shared_worker_messages_after_destroy_are_dropped_without_page_fallback() {
let mut conn = CdpConnection::default();
- conn.auto_attach = true;
+ conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
conn.set_root_target_discovery_enabled(true);
let mut browser_context = BrowserContext::new("BID-1".to_owned());
browser_context.set_active_target_id("TID-page");
diff --git a/moli-protocol/src/domains/target/worker_target_attachment_tests.rs b/moli-protocol/src/domains/target/worker_target_attachment_tests.rs
index 88d76da30..ac28d3c48 100644
--- a/moli-protocol/src/domains/target/worker_target_attachment_tests.rs
+++ b/moli-protocol/src/domains/target/worker_target_attachment_tests.rs
@@ -45,6 +45,7 @@ fn install_collision_target(conn: &mut CdpConnection) {
.as_mut()
.expect("test browser context")
.insert_shared_worker_target(target);
+ conn.register_bound_session_for_test(SESSION_ID);
}
fn runtime_inspector_messages(value: &str) -> Vec<RendererRuntimeInspectorMessage> {
@@ -164,7 +165,12 @@ async fn short_lived_shared_worker_preserves_exact_lifecycle_order() {
#[tokio::test]
async fn detached_session_cannot_be_resurrected_by_held_auto_attach_output() {
let mut conn = CdpConnection::default();
- conn.auto_attach = true;
+ conn.set_auto_attach_owner(
+ None,
+ true,
+ false,
+ crate::conn::CdpTargetFilter::default_auto_attach(),
+ );
conn.browser_context = Some(BrowserContext::new(BROWSER_CONTEXT_ID.to_owned()));
let outputs =
diff --git a/moli-protocol/src/domains/tracing/tests.rs b/moli-protocol/src/domains/tracing/tests.rs
index 5242f24da..f4dc50f16 100644
--- a/moli-protocol/src/domains/tracing/tests.rs
+++ b/moli-protocol/src/domains/tracing/tests.rs
@@ -12,7 +12,7 @@ fn context_with_page_sessions() -> TestContext {
browser_context.set_target_url("https://example.test/page#fragment".to_owned());
browser_context.attach_active_session("SID-owner".to_owned());
assert!(
- browser_context.assign_auxiliary_session_to_target("TID-tracing", "SID-peer".to_owned(),)
+ browser_context.assign_attached_session_to_target("TID-tracing", "SID-peer".to_owned(),)
);
ctx.conn.browser_context = Some(browser_context);
ctx
@@ -282,11 +282,19 @@ async fn owner_cleanup_cancels_trace_without_emitting_completion() {
ctx.expect_result(30, json!({}), Some("SID-peer"));
ctx.sent.clear();
- assert!(
- ctx.conn
- .execute_target_binding_cleanup_for_session_without_event_async("SID-peer")
- .await
- .unwrap()
+ ctx.process_async(json!({
+ "id": 30_001,
+ "method": "Target.detachFromTarget",
+ "params": { "sessionId": "SID-peer" },
+ }))
+ .await;
+ ctx.expect_result(30_001, json!({}), None);
+ ctx.expect_event(
+ "Target.detachedFromTarget",
+ Some(&json!({
+ "sessionId": "SID-peer",
+ "targetId": "TID-tracing",
+ })),
);
assert!(!ctx.conn.tracing_state.is_active());
assert!(
@@ -353,18 +361,38 @@ async fn owner_cleanup_waits_for_cpu_trace_release_before_replacement_start() {
})]
);
- let (cleaned, stop_tasks) = tokio::time::timeout(
+ let detach = ctx.conn.start_command_dispatch(
+ &json!({
+ "id": 32_001,
+ "method": "Target.detachFromTarget",
+ "params": { "sessionId": "SID-peer" },
+ })
+ .to_string(),
+ );
+ let pending_detach = match detach {
+ CdpCommandTaskStep::Pending(pending) => pending,
+ CdpCommandTaskStep::Complete(plan) => {
+ panic!("CPU trace owner detach should wait for isolate cleanup: {plan:?}")
+ }
+ };
+ let completed_detach = pending_detach.wait().await;
+ let (detach_step, stop_tasks) = tokio::time::timeout(
std::time::Duration::from_secs(2),
drive_owner_tasks_until(
&mut owner_task_rx,
- ctx.conn
- .execute_target_binding_cleanup_for_session_without_event_async("SID-peer"),
+ ctx.conn.complete_pending_command_dispatch(completed_detach),
),
)
.await
.expect("owner detach should wait for CPU trace cancellation");
- assert!(cleaned.unwrap());
assert!(stop_tasks > 0);
+ assert!(
+ detach_step
+ .into_parts()
+ .0
+ .iter()
+ .any(|message| { message["id"] == json!(32_001) && message["result"] == json!({}) })
+ );
assert!(!ctx.conn.tracing_state.is_active());
let replacement_start = ctx.conn.start_command_dispatch(
diff --git a/moli-renderer-v8/src/devtools/ingress/io.rs b/moli-renderer-v8/src/devtools/ingress/io.rs
index 61ffc52e1..bc2a5d563 100644
--- a/moli-renderer-v8/src/devtools/ingress/io.rs
+++ b/moli-renderer-v8/src/devtools/ingress/io.rs
@@ -1,5 +1,5 @@
use std::{
- collections::{BTreeSet, VecDeque},
+ collections::{BTreeMap, VecDeque},
ffi::c_void,
sync::{
Arc,
@@ -243,14 +243,25 @@ impl RendererInspectorIoOwnerWake {
struct RendererInspectorIoState {
commands: VecDeque<RendererInspectorIoCommand>,
active_command_id: Option<u64>,
- detached_sessions: BTreeSet<RendererDevToolsSessionLaneKey>,
+ // One count per lane is enough: every detach guard completes at most once,
+ // and commands stay blocked until all outstanding guards have completed.
+ session_detaches: BTreeMap<RendererDevToolsSessionLaneKey, usize>,
closed: bool,
owner_wake_tx: Option<tokio::sync::mpsc::UnboundedSender<RendererInspectorIoOwnerWake>>,
}
impl RendererInspectorIoState {
fn has_ready(&self) -> bool {
- !self.closed && self.active_command_id.is_none() && !self.commands.is_empty()
+ !self.closed
+ && self.active_command_id.is_none()
+ && self.commands.iter().any(|command| {
+ !self
+ .session_detaches
+ .contains_key(&RendererDevToolsSessionLaneKey::new(
+ command.agent_token,
+ command.ticket().session().clone(),
+ ))
+ })
}
fn drain_commands(
@@ -363,7 +374,7 @@ impl RendererInspectorIoIngress {
state: Mutex::new(RendererInspectorIoState {
commands: VecDeque::new(),
active_command_id: None,
- detached_sessions: BTreeSet::new(),
+ session_detaches: BTreeMap::new(),
closed: false,
owner_wake_tx: None,
}),
@@ -425,8 +436,6 @@ impl RendererInspectorIoIngress {
RendererInspectorCommandRoute::Io,
"only IO DevTools commands may enter RendererInspectorIoIngress"
);
- let lane_key =
- RendererDevToolsSessionLaneKey::new(agent_token, envelope.ticket().session().clone());
let mut state = self.shared.state.lock();
let (first_dispatch_tx, first_dispatch_rx) = tokio::sync::oneshot::channel();
let session_response_settlement_rx = envelope.response().and_then(
@@ -443,8 +452,6 @@ impl RendererInspectorIoIngress {
};
let rejected = if state.closed {
Some((command, "Inspector IO target is closed"))
- } else if state.detached_sessions.contains(&lane_key) {
- Some((command, "Inspector IO session was detached"))
} else {
state.commands.push_back(command);
None
@@ -505,10 +512,22 @@ impl RendererInspectorIoIngress {
if !state.has_ready() {
return None;
}
+ let position = state
+ .commands
+ .iter()
+ .position(|command| {
+ !state
+ .session_detaches
+ .contains_key(&RendererDevToolsSessionLaneKey::new(
+ command.agent_token,
+ command.ticket().session().clone(),
+ ))
+ })
+ .expect("a ready Inspector task runner must have an eligible command");
let mut command = state
.commands
- .pop_front()
- .expect("a ready Inspector task runner must have a command");
+ .remove(position)
+ .expect("the located Inspector IO command must remain queued");
state.active_command_id = Some(command.command_id);
command.claimed_by = Some(consumer);
Some(command)
@@ -559,7 +578,7 @@ impl RendererInspectorIoIngress {
}
}
- pub(crate) fn detach_session(
+ pub(crate) fn begin_session_detach(
&self,
agent_token: RendererDevToolsAgentToken,
session: &DevToolsSessionKey,
@@ -567,16 +586,50 @@ impl RendererInspectorIoIngress {
let lane_key = RendererDevToolsSessionLaneKey::new(agent_token, session.clone());
let commands = {
let mut state = self.shared.state.lock();
- state.detached_sessions.insert(lane_key);
- state.drain_commands(|command| {
- command.agent_token == agent_token && command.ticket().session() == session
- })
+ if state.closed {
+ Vec::new()
+ } else {
+ let pending_detaches = state.session_detaches.entry(lane_key).or_default();
+ *pending_detaches = pending_detaches
+ .checked_add(1)
+ .expect("renderer Inspector IO pending-detach count overflow");
+ state.drain_commands(|command| {
+ command.agent_token == agent_token && command.ticket().session() == session
+ })
+ }
};
for command in commands {
fail_io_command(command, "Inspector IO session was detached");
}
}
+ pub(crate) fn finish_session_detach(
+ &self,
+ agent_token: RendererDevToolsAgentToken,
+ session: &DevToolsSessionKey,
+ ) {
+ let lane_key = RendererDevToolsSessionLaneKey::new(agent_token, session.clone());
+ let mut state = self.shared.state.lock();
+ let finished_last_detach = match state.session_detaches.get_mut(&lane_key) {
+ Some(pending_detaches) => {
+ *pending_detaches -= 1;
+ *pending_detaches == 0
+ }
+ None => {
+ debug_assert!(
+ state.closed,
+ "only a closed target may finish an unarmed IO detach"
+ );
+ false
+ }
+ };
+ if finished_last_detach {
+ state.session_detaches.remove(&lane_key);
+ }
+ drop(state);
+ self.notify_execution_opportunities();
+ }
+
pub(crate) fn close(&self, message: &str) {
let commands = {
let mut state = self.shared.state.lock();
@@ -897,7 +950,7 @@ mod tests {
let attachment = moli_page_types::RendererAgentAttachmentId::allocate();
let session = DevToolsSessionKey::Attached("session-output".to_owned());
let (channel, response_rx) = RendererRuntimeInspectorResponseChannel::new_for_delivery(
- moli_page_types::RendererInspectorResponseDelivery::DevToolsSession,
+ moli_page_types::RendererInspectorResponseDelivery::SessionSink,
);
assert!(response_rx.is_none());
let stream = RendererOutputStreamIdentity::new_page_for_protocol_test(
@@ -953,7 +1006,7 @@ mod tests {
let attachment = moli_page_types::RendererAgentAttachmentId::allocate();
let session = DevToolsSessionKey::Attached("session-replayed-output".to_owned());
let (channel, response_rx) = RendererRuntimeInspectorResponseChannel::new_for_delivery(
- moli_page_types::RendererInspectorResponseDelivery::DevToolsSession,
+ moli_page_types::RendererInspectorResponseDelivery::SessionSink,
);
assert!(response_rx.is_none());
let original_response = channel.activate_sender(32, Some(attachment));
@@ -1006,7 +1059,7 @@ mod tests {
let agent = RendererDevToolsAgentToken::allocate();
let attachment = moli_page_types::RendererAgentAttachmentId::allocate();
let (channel, response_rx) = RendererRuntimeInspectorResponseChannel::new_for_delivery(
- moli_page_types::RendererInspectorResponseDelivery::DevToolsSession,
+ moli_page_types::RendererInspectorResponseDelivery::SessionSink,
);
assert!(response_rx.is_none());
let route = ingress.enqueue_command(
@@ -1141,11 +1194,11 @@ mod tests {
}
#[tokio::test]
- async fn detach_cancels_all_queued_commands_while_active_first_dispatch_retires_safely() {
+ async fn overlapping_primary_detaches_hold_io_ingress_until_all_complete() {
let ingress = ingress();
let agent = RendererDevToolsAgentToken::allocate();
let mut routes = (0..64)
- .map(|index| enqueue(&ingress, agent, Some("session-a"), &format!("a-{index}")))
+ .map(|index| enqueue(&ingress, agent, None, &format!("a-{index}")))
.collect::<Vec<_>>();
let first_route = routes.remove(0);
@@ -1159,7 +1212,7 @@ mod tests {
Ok(RendererRuntimeInspectorIoCommandClaim::Dispatched)
);
- ingress.detach_session(agent, &DevToolsSessionKey::Attached("session-a".to_owned()));
+ ingress.begin_session_detach(agent, &DevToolsSessionKey::Primary);
for (index, route) in routes.into_iter().enumerate() {
assert!(
matches!(
@@ -1181,6 +1234,37 @@ mod tests {
},
"the detached session's tasks must retire"
);
+
+ let replacement = enqueue(&ingress, agent, None, "replacement");
+ ingress.begin_session_detach(agent, &DevToolsSessionKey::Primary);
+ assert!(matches!(
+ replacement.wait_for_first_dispatch().await,
+ Ok(RendererRuntimeInspectorIoCommandClaim::Canceled(_))
+ ));
+
+ let post_detach = enqueue(&ingress, agent, None, "post-detach");
+ let peer = enqueue(&ingress, agent, Some("session-b"), "peer");
+ let mut peer_command = ingress
+ .claim_for_owner()
+ .expect("an unrelated session must bypass the suspended session");
+ assert_eq!(peer_command.command_id(), peer.command_id);
+ ingress.first_dispatch_guard(&mut peer_command).release();
+ assert!(
+ ingress.claim_for_owner().is_none(),
+ "replacement IO work must remain behind owner-side cleanup"
+ );
+
+ ingress.finish_session_detach(agent, &DevToolsSessionKey::Primary);
+ assert!(
+ ingress.claim_for_owner().is_none(),
+ "the first cleanup must not bypass the second IO detach barrier"
+ );
+
+ ingress.finish_session_detach(agent, &DevToolsSessionKey::Primary);
+ let replacement_command = ingress
+ .claim_for_owner()
+ .expect("replacement IO work should run after owner cleanup");
+ assert_eq!(replacement_command.command_id(), post_detach.command_id);
}
#[tokio::test]
diff --git a/moli-renderer-v8/src/devtools/ingress/lane.rs b/moli-renderer-v8/src/devtools/ingress/lane.rs
index 61b7c2fc6..458f8c3ba 100644
--- a/moli-renderer-v8/src/devtools/ingress/lane.rs
+++ b/moli-renderer-v8/src/devtools/ingress/lane.rs
@@ -24,16 +24,14 @@ impl RendererDevToolsSessionLaneKey {
}
}
-pub(crate) enum RendererDevToolsLaneEnqueueError<C> {
- TargetClosed(C),
- SessionDetached(C),
-}
-
struct RendererDevToolsSessionLane<C> {
active_command_id: Option<u64>,
queued: VecDeque<C>,
ready: bool,
- detached: bool,
+ // Distinct frontend owners may share the Primary lane and detach while an
+ // earlier owner cleanup is still queued. Each one-shot guard contributes
+ // one arm, so a count is sufficient regardless of completion order.
+ pending_detaches: usize,
}
impl<C> Default for RendererDevToolsSessionLane<C> {
@@ -42,7 +40,7 @@ impl<C> Default for RendererDevToolsSessionLane<C> {
active_command_id: None,
queued: VecDeque::new(),
ready: false,
- detached: false,
+ pending_detaches: 0,
}
}
}
@@ -74,16 +72,13 @@ impl<C: RendererDevToolsIngressCommand> RendererDevToolsSessionLanes<C> {
&mut self,
lane_key: RendererDevToolsSessionLaneKey,
command: C,
- ) -> Result<(), RendererDevToolsLaneEnqueueError<C>> {
+ ) -> Result<(), C> {
if self.closed {
- return Err(RendererDevToolsLaneEnqueueError::TargetClosed(command));
+ return Err(command);
}
let lane = self.sessions.entry(lane_key.clone()).or_default();
- if lane.detached {
- return Err(RendererDevToolsLaneEnqueueError::SessionDetached(command));
- }
lane.queued.push_back(command);
- if lane.active_command_id.is_none() && !lane.ready {
+ if lane.pending_detaches == 0 && lane.active_command_id.is_none() && !lane.ready {
lane.ready = true;
self.ready_sessions.push_back(lane_key);
}
@@ -155,11 +150,16 @@ impl<C: RendererDevToolsIngressCommand> RendererDevToolsSessionLanes<C> {
.get_mut(&lane_key)
.expect("an active DevTools session lane must still exist");
assert_eq!(lane.active_command_id.take(), Some(command_id), "{message}");
- let make_ready = !lane.detached && !lane.queued.is_empty() && !lane.ready;
+ let make_ready = lane.pending_detaches == 0 && !lane.queued.is_empty() && !lane.ready;
if make_ready {
lane.ready = true;
}
- (make_ready, lane.queued.is_empty())
+ (
+ make_ready,
+ lane.pending_detaches == 0
+ && lane.queued.is_empty()
+ && lane.active_command_id.is_none(),
+ )
};
if make_ready {
self.ready_sessions.push_back(lane_key.clone());
@@ -187,7 +187,8 @@ impl<C: RendererDevToolsIngressCommand> RendererDevToolsSessionLanes<C> {
.position(|command| command.ingress_command_id() == command_id)
.expect("a located DevTools command must remain queued");
let command = lane.queued.remove(position);
- if lane.queued.is_empty() && lane.active_command_id.is_none() {
+ if lane.pending_detaches == 0 && lane.queued.is_empty() && lane.active_command_id.is_none()
+ {
lane.ready = false;
self.ready_sessions.retain(|ready| ready != &lane_key);
self.sessions.remove(&lane_key);
@@ -195,18 +196,53 @@ impl<C: RendererDevToolsIngressCommand> RendererDevToolsSessionLanes<C> {
command
}
- pub(crate) fn detach_session(&mut self, lane_key: &RendererDevToolsSessionLaneKey) -> Vec<C> {
+ pub(crate) fn begin_session_detach(
+ &mut self,
+ lane_key: &RendererDevToolsSessionLaneKey,
+ ) -> Vec<C> {
+ if self.closed {
+ return Vec::new();
+ }
self.ready_sessions.retain(|ready| ready != lane_key);
+ let lane = self.sessions.entry(lane_key.clone()).or_default();
+ lane.ready = false;
+ lane.pending_detaches = lane
+ .pending_detaches
+ .checked_add(1)
+ .expect("renderer DevTools session pending-detach count overflow");
+ lane.queued.drain(..).collect()
+ }
+
+ /// Releases replacement frontend commands only after every detach queued
+ /// ahead of them has destroyed its renderer-side session on the owner
+ /// thread.
+ pub(crate) fn finish_session_detach(
+ &mut self,
+ lane_key: &RendererDevToolsSessionLaneKey,
+ ) -> bool {
let Some(lane) = self.sessions.get_mut(lane_key) else {
- return Vec::new();
+ return self.has_ready();
};
- lane.ready = false;
- lane.detached = true;
- let commands = lane.queued.drain(..).collect();
- if lane.active_command_id.is_none() {
+ if lane.pending_detaches == 0 {
+ debug_assert!(
+ self.closed,
+ "only a closed target may finish an unarmed detach"
+ );
+ return self.has_ready();
+ }
+ lane.pending_detaches -= 1;
+ if lane.pending_detaches != 0 {
+ return self.has_ready();
+ }
+ let make_ready = lane.active_command_id.is_none() && !lane.queued.is_empty() && !lane.ready;
+ if make_ready {
+ lane.ready = true;
+ self.ready_sessions.push_back(lane_key.clone());
+ }
+ if lane.active_command_id.is_none() && lane.queued.is_empty() {
self.sessions.remove(lane_key);
}
- commands
+ self.has_ready()
}
pub(crate) fn close_and_drain(&mut self) -> Vec<C> {
diff --git a/moli-renderer-v8/src/devtools/ingress/main.rs b/moli-renderer-v8/src/devtools/ingress/main.rs
index f37f3410b..d8090dad8 100644
--- a/moli-renderer-v8/src/devtools/ingress/main.rs
+++ b/moli-renderer-v8/src/devtools/ingress/main.rs
@@ -9,8 +9,8 @@ use parking_lot::Mutex;
use crate::{
devtools::{
ingress::lane::{
- RendererDevToolsIngressCommand, RendererDevToolsLaneEnqueueError,
- RendererDevToolsSessionLaneKey, RendererDevToolsSessionLanes,
+ RendererDevToolsIngressCommand, RendererDevToolsSessionLaneKey,
+ RendererDevToolsSessionLanes,
},
pause::RendererInspectorPauseLoopWake,
route::RendererInspectorSessionExecutorRouteId,
@@ -534,16 +534,9 @@ impl RendererInspectorMainIngress {
owner_reply_tx: Some(owner_reply_tx),
claimed_by: None,
};
- if let Err(rejected) = state.lanes.enqueue(lane_key, command) {
+ if let Err(command) = state.lanes.enqueue(lane_key, command) {
drop(state);
- match rejected {
- RendererDevToolsLaneEnqueueError::TargetClosed(command) => {
- fail_main_command(command, "Inspector Main target is closed");
- }
- RendererDevToolsLaneEnqueueError::SessionDetached(command) => {
- fail_main_command(command, "Inspector Main session was detached");
- }
- }
+ fail_main_command(command, "Inspector Main target is closed");
} else {
drop(state);
self.notify_execution_opportunities();
@@ -677,18 +670,40 @@ impl RendererInspectorMainIngress {
}
}
- pub(crate) fn detach_session(
+ pub(crate) fn begin_session_detach(
&self,
agent_token: RendererDevToolsAgentToken,
session: &DevToolsSessionKey,
) {
let lane_key = RendererDevToolsSessionLaneKey::new(agent_token, session.clone());
- let commands = self.shared.state.lock().lanes.detach_session(&lane_key);
+ let commands = self
+ .shared
+ .state
+ .lock()
+ .lanes
+ .begin_session_detach(&lane_key);
for command in commands {
fail_main_command(command, "Inspector Main session was detached");
}
}
+ pub(crate) fn finish_session_detach(
+ &self,
+ agent_token: RendererDevToolsAgentToken,
+ session: &DevToolsSessionKey,
+ ) {
+ let lane_key = RendererDevToolsSessionLaneKey::new(agent_token, session.clone());
+ let has_ready = self
+ .shared
+ .state
+ .lock()
+ .lanes
+ .finish_session_detach(&lane_key);
+ if has_ready {
+ self.notify_execution_opportunities();
+ }
+ }
+
pub(crate) fn close(&self, message: &str) {
let commands = { self.shared.state.lock().lanes.close_and_drain() };
self.shared.pause_wake.notify_all();
@@ -895,19 +910,19 @@ mod tests {
}
#[tokio::test]
- async fn detach_rejects_late_main_work_until_active_first_dispatch_retires() {
+ async fn overlapping_primary_detaches_hold_main_ingress_until_all_complete() {
let ingress = ingress();
let agent = RendererDevToolsAgentToken::allocate();
let _active_route = enqueue(
&ingress,
agent,
- Some("session-detaching"),
+ None,
r#"{"id":1,"method":"Runtime.getProperties","params":{"objectId":"active"}}"#,
);
let queued_route = enqueue(
&ingress,
agent,
- Some("session-detaching"),
+ None,
r#"{"id":2,"method":"Runtime.getProperties","params":{"objectId":"queued"}}"#,
);
let mut active = ingress
@@ -915,42 +930,52 @@ mod tests {
.expect("the session head should become active");
let mut first_dispatch = ingress.first_dispatch_guard(&mut active);
- ingress.detach_session(
- agent,
- &DevToolsSessionKey::Attached("session-detaching".to_owned()),
- );
+ ingress.begin_session_detach(agent, &DevToolsSessionKey::Primary);
assert!(matches!(
queued_route.wait_for_completion().await,
Ok(RendererRuntimeInspectorMainCommandCompletion::Canceled(_))
));
- let late_route = enqueue(
+ let replacement_route = enqueue(
&ingress,
agent,
- Some("session-detaching"),
- r#"{"id":3,"method":"Runtime.getProperties","params":{"objectId":"late"}}"#,
+ None,
+ r#"{"id":3,"method":"Runtime.getProperties","params":{"objectId":"replacement"}}"#,
);
+ ingress.begin_session_detach(agent, &DevToolsSessionKey::Primary);
assert!(matches!(
- late_route.wait_for_completion().await,
+ replacement_route.wait_for_completion().await,
Ok(RendererRuntimeInspectorMainCommandCompletion::Canceled(_))
));
- first_dispatch.release();
+ let post_detach_route = enqueue(
+ &ingress,
+ agent,
+ None,
+ r#"{"id":4,"method":"Runtime.getProperties","params":{"objectId":"post-detach"}}"#,
+ );
assert!(
- ingress.shared.state.lock().lanes.session_count() == 0,
- "the detached lane must retire after its active first dispatch releases"
+ ingress.claim_for_owner().is_none(),
+ "the next generation must wait for its own owner-side cleanup"
);
- let _reattached_route = enqueue(
- &ingress,
- agent,
- Some("session-detaching"),
- r#"{"id":4,"method":"Runtime.getProperties","params":{"objectId":"reattached"}}"#,
+ first_dispatch.release();
+ assert!(
+ ingress.claim_for_owner().is_none(),
+ "releasing an old first dispatch must not bypass the detach barrier"
);
+
+ ingress.finish_session_detach(agent, &DevToolsSessionKey::Primary);
assert!(
- ingress.claim_for_owner().is_some(),
- "a later attachment may create a fresh lane for the same wire session id"
+ ingress.claim_for_owner().is_none(),
+ "the first cleanup must not bypass the second detach barrier"
);
+
+ ingress.finish_session_detach(agent, &DevToolsSessionKey::Primary);
+ let replacement = ingress
+ .claim_for_owner()
+ .expect("replacement work should run after every owner cleanup");
+ assert_eq!(replacement.command_id(), post_detach_route.command_id);
}
#[tokio::test]
@@ -997,7 +1022,7 @@ mod tests {
let attachment = moli_page_types::RendererAgentAttachmentId::allocate();
let session = DevToolsSessionKey::Attached("session-replay".to_owned());
let (channel, response_rx) = RendererRuntimeInspectorResponseChannel::new_for_delivery(
- moli_page_types::RendererInspectorResponseDelivery::DevToolsSession,
+ moli_page_types::RendererInspectorResponseDelivery::SessionSink,
);
assert!(response_rx.is_none());
let old_response = channel.activate_sender(1, Some(attachment));
@@ -1060,7 +1085,7 @@ mod tests {
let attachment = moli_page_types::RendererAgentAttachmentId::allocate();
let session = DevToolsSessionKey::Attached("session-direct-error".to_owned());
let (channel, response_rx) = RendererRuntimeInspectorResponseChannel::new_for_delivery(
- moli_page_types::RendererInspectorResponseDelivery::DevToolsSession,
+ moli_page_types::RendererInspectorResponseDelivery::SessionSink,
);
assert!(response_rx.is_none());
let stream = RendererOutputStreamIdentity::new_page_for_protocol_test(
diff --git a/moli-renderer-v8/src/devtools/pause/mod.rs b/moli-renderer-v8/src/devtools/pause/mod.rs
index 6368b0b1f..5f4075421 100644
--- a/moli-renderer-v8/src/devtools/pause/mod.rs
+++ b/moli-renderer-v8/src/devtools/pause/mod.rs
@@ -598,11 +598,10 @@ impl RendererInspectorSessionOutboundRoute {
);
}
- pub(crate) fn detach_session(&self) {
+ pub(crate) fn deactivate_session(&self) {
self.target
.pause_ref()
.detach_session(self.agent_token, &self.session);
- self.target.detach_session(self.agent_token, &self.session);
}
pub(crate) fn stage_pause_preface(
diff --git a/moli-renderer-v8/src/devtools/pause/tests.rs b/moli-renderer-v8/src/devtools/pause/tests.rs
index c1eac790c..78a23618b 100644
--- a/moli-renderer-v8/src/devtools/pause/tests.rs
+++ b/moli-renderer-v8/src/devtools/pause/tests.rs
@@ -447,7 +447,7 @@ async fn dropping_io_route_cancels_the_unclaimed_command() {
);
assert!(
response_rx.await.is_err(),
- "abandoning the frontend route must close its obsolete command-reply capability"
+ "abandoning the frontend route must close its obsolete adapter-reply capability"
);
}
diff --git a/moli-renderer-v8/src/devtools/target.rs b/moli-renderer-v8/src/devtools/target.rs
index 2954f3068..b6767d6c4 100644
--- a/moli-renderer-v8/src/devtools/target.rs
+++ b/moli-renderer-v8/src/devtools/target.rs
@@ -133,13 +133,22 @@ impl RendererDevToolsTargetHandle {
.outbound_route(self.clone(), agent_token, session)
}
- pub(crate) fn detach_session(
+ pub(crate) fn begin_session_detach(
&self,
agent_token: RendererDevToolsAgentToken,
session: &DevToolsSessionKey,
) {
- self.main.detach_session(agent_token, session);
- self.io.detach_session(agent_token, session);
+ self.main.begin_session_detach(agent_token, session);
+ self.io.begin_session_detach(agent_token, session);
+ }
+
+ pub(crate) fn finish_session_detach(
+ &self,
+ agent_token: RendererDevToolsAgentToken,
+ session: &DevToolsSessionKey,
+ ) {
+ self.main.finish_session_detach(agent_token, session);
+ self.io.finish_session_detach(agent_token, session);
}
pub(crate) fn close(&self, message: &str) -> bool {
diff --git a/moli-renderer-v8/src/native_bridge/element/activation/default_action.rs b/moli-renderer-v8/src/native_bridge/element/activation/default_action.rs
index 04bbf650c..6e0aab663 100644
--- a/moli-renderer-v8/src/native_bridge/element/activation/default_action.rs
+++ b/moli-renderer-v8/src/native_bridge/element/activation/default_action.rs
@@ -2028,7 +2028,7 @@ fn hyperlink_navigation_policy(
InputNavigationPolicy::NewWindow | InputNavigationPolicy::NewForegroundSurface => {
// The renderer target model has no separate window chrome. Preserve
// Chromium's selected-surface behavior by folding a new window into a
- // foreground auxiliary target.
+ // foreground popup Page target.
HyperlinkNavigationPolicy::Auxiliary(RendererPopupDisposition::Foreground)
}
}
diff --git a/moli-renderer-v8/src/runtime/browser_context_runtime/service_worker_runtime.rs b/moli-renderer-v8/src/runtime/browser_context_runtime/service_worker_runtime.rs
index cb747b447..421d01c1e 100644
--- a/moli-renderer-v8/src/runtime/browser_context_runtime/service_worker_runtime.rs
+++ b/moli-renderer-v8/src/runtime/browser_context_runtime/service_worker_runtime.rs
@@ -421,8 +421,10 @@ impl RendererBrowserContextRuntime {
raw_json: String,
response: RendererRuntimeInspectorResponseSender,
) -> Result<crate::runtime::CompletedWorkerRuntimeInspectorCommandDispatch, String> {
- self.inner
- .service_worker_runtime
+ let Some(runtime) = self.service_worker_runtime_for_existing_registration() else {
+ return Err("ServiceWorkerRuntimeUnavailable".to_owned());
+ };
+ runtime
.dispatch_runtime_protocol_message_with_devtools_session_response(
ServiceWorkerVersionId::from_u64_for_binding(version_id),
inspector_session_id,
diff --git a/moli-renderer-v8/src/runtime/browser_context_runtime/shared_workers.rs b/moli-renderer-v8/src/runtime/browser_context_runtime/shared_workers.rs
index f19677784..5a2208ae8 100644
--- a/moli-renderer-v8/src/runtime/browser_context_runtime/shared_workers.rs
+++ b/moli-renderer-v8/src/runtime/browser_context_runtime/shared_workers.rs
@@ -486,8 +486,10 @@ impl RendererBrowserContextRuntime {
raw_json: String,
response: RendererRuntimeInspectorResponseSender,
) -> Result<crate::runtime::CompletedWorkerRuntimeInspectorCommandDispatch, String> {
- self.inner
- .shared_worker_runtime
+ let Some(runtime) = self.shared_worker_runtime_if_initialized() else {
+ return Err("SharedWorkerRuntimeUnavailable".to_owned());
+ };
+ runtime
.dispatch_runtime_protocol_message_with_devtools_session_response(
instance_id,
inspector_session_id,
diff --git a/moli-renderer-v8/src/runtime/owner.rs b/moli-renderer-v8/src/runtime/owner.rs
index 152c64769..c00326f90 100644
--- a/moli-renderer-v8/src/runtime/owner.rs
+++ b/moli-renderer-v8/src/runtime/owner.rs
@@ -250,8 +250,9 @@ pub enum RendererOwnerCommand {
command: RendererPageCommand,
},
/// Renderer-side cleanup after the browser/protocol owner has already
- /// disconnected a DevTools session and closed both of its ingress lanes.
- /// This is lifecycle work, not another frontend Inspector command.
+ /// disconnected a DevTools session and suspended both of its ingress lanes.
+ /// Replacement frontend work remains queued behind this lifecycle task so
+ /// it cannot reuse the V8 session before destruction completes.
FinalizeRuntimeInspectorSessionDetach {
token: RendererPageToken,
inspector_session_id: Option<String>,
@@ -2521,7 +2522,7 @@ impl RendererOwnerHandle {
RendererOwnerCommand::FinalizeRuntimeInspectorSessionDetach {
token,
inspector_session_id,
- pause_guard: _pause_guard,
+ mut pause_guard,
} => {
let mut entry = match checkout_entry_for_owner_turn_on_bound_owner_local_store(
token,
@@ -2530,6 +2531,7 @@ impl RendererOwnerHandle {
Err(
LivePageEntryCheckoutError::Retired | LivePageEntryCheckoutError::Missing,
) => {
+ pause_guard.complete();
return Ok(RendererOwnerReply::RuntimeInspectorSessionDetachFinalized(
false,
))
@@ -2547,6 +2549,7 @@ impl RendererOwnerHandle {
.page_vm_mut()
.detach_runtime_inspector_session(inspector_session_id.as_deref());
restore_entry_after_command_on_bound_owner_local_store(token, entry);
+ pause_guard.complete();
Ok(RendererOwnerReply::RuntimeInspectorSessionDetachFinalized(
detached,
))
diff --git a/moli-renderer-v8/src/runtime/owner_local.rs b/moli-renderer-v8/src/runtime/owner_local.rs
index e24e774b6..15194cbda 100644
--- a/moli-renderer-v8/src/runtime/owner_local.rs
+++ b/moli-renderer-v8/src/runtime/owner_local.rs
@@ -117,19 +117,44 @@ pub struct RendererPageTestingHandle {
#[must_use = "the owner detach command must retain this guard until it drops the V8 session"]
pub struct RendererRuntimeInspectorSessionDetachGuard {
inspector_pause_bridge: Option<crate::devtools::pause::RendererInspectorPauseBridge>,
+ pending_detach: Option<(
+ crate::devtools::target::RendererDevToolsTargetHandle,
+ RendererDevToolsAgentToken,
+ DevToolsSessionKey,
+ )>,
}
impl RendererRuntimeInspectorSessionDetachGuard {
- fn new(inspector_pause_bridge: crate::devtools::pause::RendererInspectorPauseBridge) -> Self {
+ fn new(
+ inspector_pause_bridge: crate::devtools::pause::RendererInspectorPauseBridge,
+ devtools_target: crate::devtools::target::RendererDevToolsTargetHandle,
+ agent_token: RendererDevToolsAgentToken,
+ session: DevToolsSessionKey,
+ ) -> Self {
inspector_pause_bridge.arm_session_detach();
+ devtools_target.begin_session_detach(agent_token, &session);
Self {
inspector_pause_bridge: Some(inspector_pause_bridge),
+ pending_detach: Some((devtools_target, agent_token, session)),
+ }
+ }
+
+ pub(crate) fn complete(&mut self) {
+ if let Some((target, agent_token, session)) = self.pending_detach.take() {
+ target.finish_session_detach(agent_token, &session);
}
}
}
impl Drop for RendererRuntimeInspectorSessionDetachGuard {
fn drop(&mut self) {
+ if let Some((target, _agent_token, _session)) = self.pending_detach.take() {
+ // Reopening the ingress after owner-side V8 cleanup failed would
+ // let a replacement attachment reuse the stale session. Close the
+ // target so queued replacement commands fail instead of hanging or
+ // inheriting the retired frontend's state.
+ target.close("Inspector session detach did not reach the renderer owner");
+ }
if let Some(inspector_pause_bridge) = self.inspector_pause_bridge.take() {
inspector_pause_bridge.disarm_session_detach();
}
@@ -297,12 +322,6 @@ impl RendererPageHandle {
)
}
- pub fn arm_runtime_inspector_session_detach(
- &self,
- ) -> RendererRuntimeInspectorSessionDetachGuard {
- RendererRuntimeInspectorSessionDetachGuard::new(self.devtools_target.pause())
- }
-
/// Disconnects one frontend Inspector route without waiting for the Page
/// owner to return from JavaScript.
///
@@ -311,8 +330,8 @@ impl RendererPageHandle {
/// V8InspectorSession is a subsequent Main-thread task. Mirror that
/// boundary here: cancel both ingress lanes synchronously, then enqueue an
/// owner-only cleanup whose reply is deliberately detached. The retained
- /// pause guard also releases a nested debugger loop so the cleanup can
- /// eventually reach the owner.
+ /// guard also releases a nested debugger loop and holds any replacement
+ /// attachment's commands until cleanup reaches the owner.
pub fn detach_runtime_inspector_session(
&self,
inspector_session_id: Option<String>,
@@ -322,10 +341,12 @@ impl RendererPageHandle {
.as_deref()
.filter(|session_id| !session_id.is_empty()),
);
- self.devtools_target
- .detach_session(self.devtools_agent_token, &session);
-
- let pause_guard = self.arm_runtime_inspector_session_detach();
+ let pause_guard = RendererRuntimeInspectorSessionDetachGuard::new(
+ self.devtools_target.pause(),
+ self.devtools_target.clone(),
+ self.devtools_agent_token,
+ session,
+ );
let reply_rx = self.render_runtime.enqueue(
RendererOwnerCommand::FinalizeRuntimeInspectorSessionDetach {
token: self.token(),
diff --git a/moli-renderer-v8/src/runtime/page_dom.rs b/moli-renderer-v8/src/runtime/page_dom.rs
index 147223654..d4c4842a2 100644
--- a/moli-renderer-v8/src/runtime/page_dom.rs
+++ b/moli-renderer-v8/src/runtime/page_dom.rs
@@ -786,7 +786,7 @@ impl PageVm {
let call_id = deferred_response.call_id();
if let Some(message) = messages.into_iter().next() {
if deferred_response.response_delivery()
- == moli_page_types::RendererInspectorResponseDelivery::DevToolsSession
+ == moli_page_types::RendererInspectorResponseDelivery::SessionSink
{
let deferred_response = self.vm().route_frontend_runtime_inspector_response(
inspector_session_id,
@@ -3909,7 +3909,7 @@ impl PageVm {
// Target attachment applies binding state before exposing the session
// to frontend commands. Even an empty state must establish the
// concrete renderer DevTools session/output capability: otherwise an
- // auxiliary session whose first command is a non-V8 IO agent has no
+ // attached session whose first command is a non-V8 IO agent has no
// session host through which to publish its terminal response.
self.vm_mut()
.ensure_runtime_inspector_session(inspector_session_id);
diff --git a/moli-renderer-v8/src/runtime/page_surface.rs b/moli-renderer-v8/src/runtime/page_surface.rs
index 1778f4608..0b67916b3 100644
--- a/moli-renderer-v8/src/runtime/page_surface.rs
+++ b/moli-renderer-v8/src/runtime/page_surface.rs
@@ -2866,7 +2866,7 @@ pub(crate) struct RendererRuntimeCommandOutputSettlement {
}
impl RendererRuntimeCommandOutputSettlement {
- fn command_reply(output: RendererRuntimeCommandOutput) -> Self {
+ fn adapter_reply(output: RendererRuntimeCommandOutput) -> Self {
Self {
output,
session_response: None,
@@ -2898,10 +2898,10 @@ impl RendererRuntimeCommandOutputSettlement {
self.output.set_v8_state_update(state);
}
- fn into_command_reply_output(self) -> RendererRuntimeCommandOutput {
+ fn into_adapter_reply_output(self) -> RendererRuntimeCommandOutput {
assert!(
self.session_response.is_none(),
- "a DevTools session response cannot become a typed command reply"
+ "a session-sink response cannot become a typed adapter reply"
);
self.output
}
@@ -2999,7 +2999,7 @@ impl RendererRuntimeCommandOutputRecorder {
pub(crate) fn finish(self) -> RendererRuntimeCommandOutput {
self.finish_settlement_with_response_override(None)
- .into_command_reply_output()
+ .into_adapter_reply_output()
}
pub(crate) fn finish_for_page(self) -> RendererRuntimeCommandOutputSettlement {
@@ -3022,7 +3022,7 @@ impl RendererRuntimeCommandOutputRecorder {
let response = state.response.take();
drop(state);
let Some((sender, message)) = response else {
- return RendererRuntimeCommandOutputSettlement::command_reply(output);
+ return RendererRuntimeCommandOutputSettlement::adapter_reply(output);
};
let message = error_message.map_or(message, |message| {
json!({
@@ -3081,7 +3081,7 @@ impl RendererRuntimeInspectorResponseChannel {
let (tx, rx) = oneshot::channel();
(
Self {
- delivery: moli_page_types::RendererInspectorResponseDelivery::CommandReply,
+ delivery: moli_page_types::RendererInspectorResponseDelivery::AdapterReply,
state: Arc::new(Mutex::new(RendererRuntimeInspectorResponseChannelState {
next_lease_id: 1,
active_lease_id: None,
@@ -3101,11 +3101,11 @@ impl RendererRuntimeInspectorResponseChannel {
Option<oneshot::Receiver<RendererRuntimeInspectorAsyncCompletion>>,
) {
match delivery {
- moli_page_types::RendererInspectorResponseDelivery::CommandReply => {
+ moli_page_types::RendererInspectorResponseDelivery::AdapterReply => {
let (channel, receiver) = Self::new();
(channel, Some(receiver))
}
- moli_page_types::RendererInspectorResponseDelivery::DevToolsSession => (
+ moli_page_types::RendererInspectorResponseDelivery::SessionSink => (
Self {
delivery,
state: Arc::new(Mutex::new(RendererRuntimeInspectorResponseChannelState {
@@ -3149,10 +3149,10 @@ impl RendererRuntimeInspectorResponseChannel {
};
let lease = RendererRuntimeInspectorResponseLease::new(lease_id, self.clone());
let destination = match self.delivery {
- moli_page_types::RendererInspectorResponseDelivery::CommandReply => {
- RendererRuntimeInspectorResponseDestination::CommandReply(lease)
+ moli_page_types::RendererInspectorResponseDelivery::AdapterReply => {
+ RendererRuntimeInspectorResponseDestination::AdapterReply(lease)
}
- moli_page_types::RendererInspectorResponseDelivery::DevToolsSession => {
+ moli_page_types::RendererInspectorResponseDelivery::SessionSink => {
RendererRuntimeInspectorResponseDestination::DevToolsSessionPending(lease)
}
};
@@ -3273,7 +3273,7 @@ impl RendererRuntimeInspectorResponseLease {
}
}
- fn send_command_reply(
+ fn send_adapter_reply(
self,
completion: RendererRuntimeInspectorAsyncCompletion,
) -> Result<(), RendererRuntimeInspectorAsyncCompletion> {
@@ -3382,7 +3382,7 @@ impl RendererDevToolsSessionOutputHost {
#[derive(Clone, Debug)]
enum RendererRuntimeInspectorResponseDestination {
- CommandReply(RendererRuntimeInspectorResponseLease),
+ AdapterReply(RendererRuntimeInspectorResponseLease),
DevToolsSessionPending(RendererRuntimeInspectorResponseLease),
DevToolsSession {
lease: RendererRuntimeInspectorResponseLease,
@@ -3399,7 +3399,7 @@ impl RendererRuntimeInspectorResponseDestination {
RendererRuntimeInspectorAsyncCompletion,
> {
match self {
- Self::CommandReply(lease) => lease.send_command_reply(completion).map(|()| None),
+ Self::AdapterReply(lease) => lease.send_adapter_reply(completion).map(|()| None),
Self::DevToolsSessionPending(_) => Err(completion),
Self::DevToolsSession { lease, host } => {
let settlement_tx = match lease.claim_session() {
@@ -3445,7 +3445,7 @@ impl RendererRuntimeInspectorResponseDestination {
&self,
) -> Option<oneshot::Receiver<RendererRuntimeInspectorSessionResponseSettlement>> {
match self {
- Self::CommandReply(_) => None,
+ Self::AdapterReply(_) => None,
Self::DevToolsSessionPending(lease) | Self::DevToolsSession { lease, .. } => {
lease.take_session_response_settlement_receiver()
}
@@ -3479,7 +3479,7 @@ impl std::fmt::Debug for RendererRuntimeInspectorResponseSender {
impl RendererRuntimeInspectorResponseSender {
pub fn new(call_id: i32, tx: oneshot::Sender<RendererRuntimeInspectorAsyncCompletion>) -> Self {
let channel = RendererRuntimeInspectorResponseChannel {
- delivery: moli_page_types::RendererInspectorResponseDelivery::CommandReply,
+ delivery: moli_page_types::RendererInspectorResponseDelivery::AdapterReply,
state: Arc::new(Mutex::new(RendererRuntimeInspectorResponseChannelState {
next_lease_id: 2,
active_lease_id: Some(1),
@@ -3491,7 +3491,7 @@ impl RendererRuntimeInspectorResponseSender {
Self {
call_id,
attachment_id: None,
- destination: RendererRuntimeInspectorResponseDestination::CommandReply(
+ destination: RendererRuntimeInspectorResponseDestination::AdapterReply(
RendererRuntimeInspectorResponseLease::new(1, channel),
),
publication_boundary: RendererRuntimeInspectorResponsePublicationBoundary::Immediate,
@@ -3504,12 +3504,12 @@ impl RendererRuntimeInspectorResponseSender {
pub(crate) fn response_delivery(&self) -> moli_page_types::RendererInspectorResponseDelivery {
match self.destination {
- RendererRuntimeInspectorResponseDestination::CommandReply(_) => {
- moli_page_types::RendererInspectorResponseDelivery::CommandReply
+ RendererRuntimeInspectorResponseDestination::AdapterReply(_) => {
+ moli_page_types::RendererInspectorResponseDelivery::AdapterReply
}
RendererRuntimeInspectorResponseDestination::DevToolsSessionPending(_)
| RendererRuntimeInspectorResponseDestination::DevToolsSession { .. } => {
- moli_page_types::RendererInspectorResponseDelivery::DevToolsSession
+ moli_page_types::RendererInspectorResponseDelivery::SessionSink
}
}
}
@@ -3567,8 +3567,8 @@ impl RendererRuntimeInspectorResponseSender {
RendererRuntimeInspectorResponseDestination::DevToolsSession { lease, host: _ } => {
RendererRuntimeInspectorResponseDestination::DevToolsSession { lease, host }
}
- RendererRuntimeInspectorResponseDestination::CommandReply(_) => {
- panic!("a command-reply response cannot be rebound to DevTools session output")
+ RendererRuntimeInspectorResponseDestination::AdapterReply(_) => {
+ panic!("an adapter reply cannot be rebound to session output")
}
};
self
@@ -3649,8 +3649,8 @@ impl RendererRuntimeInspectorResponseSender {
publication_boundary: _,
} = self;
match destination {
- RendererRuntimeInspectorResponseDestination::CommandReply(_) => {
- RendererRuntimeCommandOutputSettlement::command_reply(output)
+ RendererRuntimeInspectorResponseDestination::AdapterReply(_) => {
+ RendererRuntimeCommandOutputSettlement::adapter_reply(output)
}
RendererRuntimeInspectorResponseDestination::DevToolsSessionPending(_) => panic!(
"a DevTools session response must bind its concrete output host before settlement"
@@ -3771,7 +3771,7 @@ mod renderer_runtime_inspector_response_channel_tests {
async fn revoking_session_lease_leaves_terminal_settlement_to_protocol_owner() {
let attachment = RendererAgentAttachmentId::allocate();
let (channel, receiver) = RendererRuntimeInspectorResponseChannel::new_for_delivery(
- moli_page_types::RendererInspectorResponseDelivery::DevToolsSession,
+ moli_page_types::RendererInspectorResponseDelivery::SessionSink,
);
assert!(receiver.is_none());
let sender = channel.activate_sender(1, Some(attachment));
@@ -3937,11 +3937,11 @@ mod renderer_runtime_inspector_response_channel_tests {
let (owner_wake_tx, mut owner_wake_rx) = tokio::sync::mpsc::unbounded_channel();
let owner_wake = RendererOwnerWakeSender::new(owner_wake_tx, token);
let (channel, response_rx) = RendererRuntimeInspectorResponseChannel::new_for_delivery(
- moli_page_types::RendererInspectorResponseDelivery::DevToolsSession,
+ moli_page_types::RendererInspectorResponseDelivery::SessionSink,
);
assert!(
response_rx.is_none(),
- "session delivery must not allocate a legacy command-reply receiver"
+ "session delivery must not allocate an adapter-reply receiver"
);
channel
@@ -4031,7 +4031,7 @@ mod renderer_runtime_inspector_response_channel_tests {
let attachment = RendererAgentAttachmentId::allocate();
let (channel, receiver) = RendererRuntimeInspectorResponseChannel::new_for_delivery(
- moli_page_types::RendererInspectorResponseDelivery::DevToolsSession,
+ moli_page_types::RendererInspectorResponseDelivery::SessionSink,
);
assert!(receiver.is_none());
let sender = channel
@@ -4113,7 +4113,7 @@ mod renderer_runtime_inspector_response_channel_tests {
let journal = RendererTurnOutputJournal::new_with_transport(stream, transport.clone());
let attachment = RendererAgentAttachmentId::allocate();
let (channel, receiver) = RendererRuntimeInspectorResponseChannel::new_for_delivery(
- moli_page_types::RendererInspectorResponseDelivery::DevToolsSession,
+ moli_page_types::RendererInspectorResponseDelivery::SessionSink,
);
assert!(receiver.is_none());
let sender = channel
@@ -4154,7 +4154,7 @@ mod renderer_runtime_inspector_response_channel_tests {
let journal = RendererTurnOutputJournal::new(stream);
let attachment = RendererAgentAttachmentId::allocate();
let (channel, receiver) = RendererRuntimeInspectorResponseChannel::new_for_delivery(
- moli_page_types::RendererInspectorResponseDelivery::DevToolsSession,
+ moli_page_types::RendererInspectorResponseDelivery::SessionSink,
);
assert!(receiver.is_none());
let sender = channel
@@ -4206,7 +4206,7 @@ mod renderer_runtime_inspector_response_channel_tests {
let old_attachment = RendererAgentAttachmentId::allocate();
let new_attachment = RendererAgentAttachmentId::allocate();
let (channel, receiver) = RendererRuntimeInspectorResponseChannel::new_for_delivery(
- moli_page_types::RendererInspectorResponseDelivery::DevToolsSession,
+ moli_page_types::RendererInspectorResponseDelivery::SessionSink,
);
assert!(receiver.is_none());
let old_sender = channel
@@ -4280,7 +4280,7 @@ mod renderer_runtime_inspector_response_channel_tests {
));
let attachment = RendererAgentAttachmentId::allocate();
let (channel, receiver) = RendererRuntimeInspectorResponseChannel::new_for_delivery(
- moli_page_types::RendererInspectorResponseDelivery::DevToolsSession,
+ moli_page_types::RendererInspectorResponseDelivery::SessionSink,
);
assert!(receiver.is_none());
let sender = channel
@@ -4352,7 +4352,7 @@ mod renderer_runtime_inspector_response_channel_tests {
));
let attachment = RendererAgentAttachmentId::allocate();
let (channel, receiver) = RendererRuntimeInspectorResponseChannel::new_for_delivery(
- moli_page_types::RendererInspectorResponseDelivery::DevToolsSession,
+ moli_page_types::RendererInspectorResponseDelivery::SessionSink,
);
assert!(receiver.is_none());
let sender = channel
@@ -4373,7 +4373,7 @@ mod renderer_runtime_inspector_response_channel_tests {
);
let mut accumulated = RendererRuntimeCommandOutputSettlement::default();
accumulated.append(session_response);
- accumulated.append(RendererRuntimeCommandOutputSettlement::command_reply(
+ accumulated.append(RendererRuntimeCommandOutputSettlement::adapter_reply(
nonresponse_output,
));
assert!(accumulated.has_session_response());
@@ -4413,7 +4413,7 @@ mod renderer_runtime_inspector_response_channel_tests {
let (transport, _transport_rx) = crate::runtime::renderer_output_transport_channel();
let attachment = RendererAgentAttachmentId::allocate();
let (channel, receiver) = RendererRuntimeInspectorResponseChannel::new_for_delivery(
- moli_page_types::RendererInspectorResponseDelivery::DevToolsSession,
+ moli_page_types::RendererInspectorResponseDelivery::SessionSink,
);
assert!(receiver.is_none());
channel
diff --git a/moli-renderer-v8/src/runtime/page_vm/tests/lifecycle.rs b/moli-renderer-v8/src/runtime/page_vm/tests/lifecycle.rs
index 26b6b0593..7d1ffb255 100644
--- a/moli-renderer-v8/src/runtime/page_vm/tests/lifecycle.rs
+++ b/moli-renderer-v8/src/runtime/page_vm/tests/lifecycle.rs
@@ -2779,7 +2779,7 @@ async fn runtime_document_close_response_does_not_wait_for_replacement_lifecycle
let (output, session_response) = page_vm.take_runtime_command_settlement();
assert!(
session_response.is_none(),
- "CommandReply delivery must not park a DevTools session response"
+ "AdapterReply delivery must not park a DevTools session response"
);
assert_eq!(
output
diff --git a/moli-renderer-v8/src/runtime/protocol_output/turn_journal.rs b/moli-renderer-v8/src/runtime/protocol_output/turn_journal.rs
index 8e34fd5a1..8285d03f4 100644
--- a/moli-renderer-v8/src/runtime/protocol_output/turn_journal.rs
+++ b/moli-renderer-v8/src/runtime/protocol_output/turn_journal.rs
@@ -226,7 +226,7 @@ impl RendererTurnOutputJournal {
return None;
}
// A terminal response cannot settle against a deferred publication:
- // the DevTools session has no command-reply fallback if later
+ // the DevTools session has no adapter-reply fallback if later
// transport admission fails.
let transport = state.transport.clone()?;
state.records.extend(records);
diff --git a/moli-renderer-v8/src/runtime/tests.rs b/moli-renderer-v8/src/runtime/tests.rs
index 690a47bc7..fffefa8a1 100644
--- a/moli-renderer-v8/src/runtime/tests.rs
+++ b/moli-renderer-v8/src/runtime/tests.rs
@@ -12142,7 +12142,7 @@ async fn webcrypto_checkpoint_reconciles_document_replacement_before_restoring_p
let document_open_session = "SID-document-open-agent";
runtime_enable_events_for_inspector_session_for_test(&page, Some(document_open_session))
.await
- .expect("auxiliary Runtime session should attach before document.open");
+ .expect("attached Runtime session should attach before document.open");
let inspector_before = runtime_heap_usage_for_test(&page).await;
let inspector_before = &inspector_before["moli"]["runtime"];
let context_group_before = inspector_before["inspectorContextGroupId"].clone();
@@ -12228,7 +12228,7 @@ async fn webcrypto_checkpoint_reconciles_document_replacement_before_restoring_p
);
runtime_enable_events_for_inspector_session_for_test(&page, Some(document_open_session))
.await
- .expect("the existing auxiliary Runtime session should remain dispatchable");
+ .expect("the existing attached Runtime session should remain dispatchable");
page.close_async()
.await
diff --git a/moli-renderer-v8/src/script_vm/inspector/mod.rs b/moli-renderer-v8/src/script_vm/inspector/mod.rs
index 31a7bca9e..330066246 100644
--- a/moli-renderer-v8/src/script_vm/inspector/mod.rs
+++ b/moli-renderer-v8/src/script_vm/inspector/mod.rs
@@ -150,7 +150,7 @@ impl DocumentInspectorBinding {
inspector_session_id: Option<&str>,
response: RendererRuntimeInspectorResponseSender,
) -> Result<RendererRuntimeInspectorResponseSender> {
- if response.response_delivery() == RendererInspectorResponseDelivery::CommandReply {
+ if response.response_delivery() == RendererInspectorResponseDelivery::AdapterReply {
return Ok(response);
}
let session_key = inspector_session_key(inspector_session_id);
diff --git a/moli-renderer-v8/src/script_vm/inspector/outbound.rs b/moli-renderer-v8/src/script_vm/inspector/outbound.rs
index 696964f86..28cef9383 100644
--- a/moli-renderer-v8/src/script_vm/inspector/outbound.rs
+++ b/moli-renderer-v8/src/script_vm/inspector/outbound.rs
@@ -146,7 +146,7 @@ impl InspectorOutbound {
let mut messages = self.messages.borrow_mut();
messages.messages.clear();
if let Some(route) = self.session_route.borrow_mut().take() {
- route.detach_session();
+ route.deactivate_session();
}
}
@@ -412,7 +412,7 @@ impl InspectorOutbound {
/// Registers a real frontend command with its explicit terminal response
/// destination. Internal Classic/BiDi adapter calls intentionally keep
/// using `register_response_callback`, which always preserves their
- /// private command reply capability.
+ /// private adapter-reply capability.
pub(in crate::script_vm) fn register_frontend_response_callback(
&self,
callback: RendererRuntimeInspectorResponseSender,
@@ -437,8 +437,8 @@ impl InspectorOutbound {
callback: RendererRuntimeInspectorResponseSender,
) -> RendererRuntimeInspectorResponseSender {
match callback.response_delivery() {
- RendererInspectorResponseDelivery::CommandReply => callback,
- RendererInspectorResponseDelivery::DevToolsSession => {
+ RendererInspectorResponseDelivery::AdapterReply => callback,
+ RendererInspectorResponseDelivery::SessionSink => {
let host = self
.session
.clone()
diff --git a/moli-renderer-v8/src/worker/thread/runtime_inspector.rs b/moli-renderer-v8/src/worker/thread/runtime_inspector.rs
index 2c61d4701..b53cbcbba 100644
--- a/moli-renderer-v8/src/worker/thread/runtime_inspector.rs
+++ b/moli-renderer-v8/src/worker/thread/runtime_inspector.rs
@@ -529,7 +529,7 @@ impl WorkerRuntimeInspector {
let deferred_response = deferred_response.map(|response| {
if self.shared_worker
|| response.response_delivery()
- == moli_page_types::RendererInspectorResponseDelivery::DevToolsSession
+ == moli_page_types::RendererInspectorResponseDelivery::SessionSink
{
response.defer_publication_to_worker_parent(self.parent_tx.clone())
} else {