Commit Graph
373 Commits
Author SHA1 Message Date
ldm0 b2a45e6129 fix(webdriver): unify Classic and BiDi node references 2026-11-03 11:04:27 +08:00
ldm0 ea1076e2db fix(cdp): preserve per-page output fences during Fetch teardown
Fix MOL-554 by keeping renderer output fences for different Pages as
independent predecessors of the existing protocol output work item.
Preserve command correlation when publishing cleanup and detach events
after every original renderer prefix has crossed protocol ingress.

Cover continued and outstanding Fetch requests across two Pages, and prove
that projecting one Page's cursor cannot release another Page's output.

Validation: cargo fmt --all; workspace all-target/all-feature Clippy;
Nextest 21,987 passed, 19 skipped; Playwright reproduction passes 3/3.
2026-11-03 10:48:27 +08:00
ldm0 24ad52ddd2 fix(webdriver): preserve node scope across Classic and BiDi 2026-11-03 09:09:03 +08:00
ldm0 b593f7e617 fix(webdriver): restore Classic opt-out and BiDi client workflows 2026-11-03 07:23:02 +08:00
ldm0 191e5fc166 refactor(protocol): make context preload IDs authoritative
Store DevToolsPreloadScriptId in BrowserContext preload registrations and keep registry_key unset there. Preserve typed IDs through registration, routing, removal and response projection.

Derive renderer keys through a shared descriptor projection for navigation and live updates, and derive removal keys from the same protocol ID. Extend the regression to verify that a previous renderer key cannot become a second stored identity.

Validation: cargo fmt --all; cargo clippy --workspace --all-targets --all-features -- -D warnings; cargo nextest run --no-fail-fast (22,197 passed, 20 skipped).
2026-11-03 07:13:38 +08:00
ldm0 e5c74d4643 refactor(protocol): clarify context preload naming
Name mutable BrowserContext registrations context_preload_scripts and name the startup-plus-protocol projection context_document_start_script_descriptors. Update registration, removal, channel lookup and pending command names to match their ownership.

Keep startup scripts separate and preserve script IDs, renderer registry keys, diagnostic fields and execution order.

Validation: cargo fmt --all; cargo clippy --workspace --all-targets --all-features -- -D warnings; cargo nextest run --no-fail-fast (22,197 passed, 20 skipped).
2026-11-03 07:13:38 +08:00
ldm0 de4cc98f47 fix(serve): preserve startup scripts across protocol lifecycles
Capture startup scripts before creating navigation engines and install them when each BrowserContext is created. Keep CLI scripts outside mutable protocol preload registries so engine resets and protocol removals preserve startup policy.

Pass complete runtime configuration through BiDi and Classic entry points. Add six regression tests covering protocol navigation, iframes, late contexts, new windows, preload removal and engine reset.

Validation: cargo fmt --all; cargo clippy --workspace --all-targets --all-features -- -D warnings; cargo nextest run --no-fail-fast (22,197 passed, 20 skipped).
2026-11-03 07:13:38 +08:00
Neo 孫 686d9d6c57 fix(serve): honor --document-start-script in protocol-server pages
`moli fetch` reads configured document-start scripts straight from
BrowserConfig, but `moli serve` builds its pages from
NavigationRuntimeConfig, which never carried them, so the flag was a
silent no-op in serve mode.

- NavigationRuntimeConfig gains `document_start_scripts`, populated in
  From<&BrowserConfig>; the two exhaustive destructurings mark it as not
  engine state.
- BrowserContextState::bind_page_navigation_engines seeds each configured
  script into the context's default document-start registry (the same
  registry BiDi addPreloadScript uses), once per context.

Verified: unit test for the config hop; end to end, a script that
increments a counter reads 1 after each of two navigations (upstream
binary: script never runs).
2026-11-03 07:13:38 +08:00
Neo 孫 7ab8319998 fix(system-info): accept the frontend's browser session (SystemInfo always rejected over real connections)
The frontend router dispatches every command with a session: the client's
sessionId, or the frontend's own browser session when the client sent none.
SystemInfo.getInfo / getProcessInfo rejected any command with a session, so
over a real browser-endpoint connection they always answered "only supported
on the browser target" (unit tests passed because TestContext sends no
session). Measured: a fresh, never-attached browser-endpoint connection got
the error too.

Use the same rule as Target's browser-only operations: no session, or a
session whose route is the browser (`is_browser_session_id`). Page / frame
target sessions are still rejected (the existing two tests are unchanged).

Test: system_info_accepts_the_frontend_browser_session. Reverting the check
fails it. fmt / clippy -D warnings clean.
2026-11-03 06:13:21 +08:00
ldm0andneosun100 08e83bffc0 fix(cdp): randomize browser endpoints and page target identities
Generate a fresh browser WebSocket UUID per server and random 128-bit page
and tab target IDs for network CDP owners. Keep discovery URLs and protocol
target IDs consistent, and make clients discover endpoints instead of
relying on fixed paths.

Cover endpoint rotation, guessed and foreign ID rejection, and target
lifecycle behavior.

Co-authored-by: neosun100 <neosun100@users.noreply.github.com>
2026-11-03 05:53:28 +08:00
ldm0 de15d018dd fix(cookies): enforce native SameSite contexts for script and network access
Apply per-cookie SameSite restrictions to script reads while preserving HttpOnly and privileged CDP access. Carry relationship and navigation shape into canonical insertion checks before mutation, including overwrite and expiry deletion. Keep Secure SameSite=None, top-level response allowances and precise rejection reports; remove the blanket cross-site document-cookie denial.

Extracted from development commit 1b521cee146.
Base: wpt/20261030-cookie-age-aware-samesite (a170fb14b8).

Validation (32 build jobs and test threads): cargo fmt --all; cargo clippy --workspace --all-targets --all-features -- -D warnings; cargo nextest run --no-fail-fast.
     Summary [ 150.549s] 22175 tests run: 22175 passed (9 slow), 20 skipped
2026-11-02 11:12:00 +08:00
ldm0 8f6648c1f9 fix(cookies): preserve unknown ages and streamline SameSite checks 2026-11-02 11:09:13 +08:00
ldm0 2e4fa728e8 refactor(cookies): store creation times as Unix microseconds 2026-11-02 11:09:13 +08:00
ldm0 66aec1d3b5 fix(cookies): report the canonical SameSite mode after overwrite 2026-11-02 11:09:13 +08:00
ldm0 8b0701deeb fix(cookies): apply age-aware Lax-by-default request policy
Record and preserve cookie creation time across updates, browser imports and cache persistence. Apply modern Lax-by-default request inclusion, including the age-bounded unsafe top-level navigation allowance; keep explicit Lax and Strict semantics, raw cookie visibility and diagnostic exclusion reasons. Cover age boundaries, updates, imports, persistence and navigation contexts.
2026-11-02 11:09:13 +08:00
ldm0 768ba6e400 test(storage): cover first-party quota isolation and implicit OPFS 2026-11-01 05:19:55 +08:00
ldm0 244192dccb refactor(storage): remove unused cross-partition usage APIs 2026-11-01 05:19:55 +08:00
ldm0 f11c7cbf32 fix(storage): scope CDP quota usage to first-party StorageKey 2026-11-01 05:19:55 +08:00
ldm0 843ddcc3f2 refactor(storage): retire protocol cookie profiles and close partitions once 2026-11-01 04:03:38 +08:00
ldm0 43feec65be fix(storage): exclude Web Storage from quota-managed usage
Align StorageManager.estimate and CDP Storage.getUsageAndQuota with Chromium's
quota clients. Report IndexedDB, Cache Storage, and OPFS by backend, including
named and implicit-default bucket data, without touching local/sessionStorage.
Keep Web Storage's independent per-area quota unchanged.

Cover Web Storage exclusion, an unopened or closed SQLite localStorage backend,
default and named OPFS data, bucket attribution, and command-session isolation.
2026-11-01 04:03:38 +08:00
ldm0 5e6482996e feat(storage): open Cookie and localStorage databases on first use 2026-11-01 04:03:38 +08:00
ldm0 4649cb1256 feat(storage): use partition SQLite cookies and localStorage by default 2026-11-01 04:03:38 +08:00
ldm0 03e09d240c feat(storage): add asynchronous SQLite Web Storage areas and flush barriers 2026-11-01 04:03:38 +08:00
ldm0 b092492b97 test(navigation): await traversal and background target load
Wait for the destination traversal state and the background session load notification before inspecting document contents. A best-effort stability result or navigation acknowledgement does not establish either completion boundary.
2026-11-01 03:55:30 +08:00
ldm0 2dd72ca458 fix(performance): distinguish cached and validated resource transfers
The existing from_cache flag collapses fresh local responses and revalidated 304 responses into the same state, producing incorrect Resource Timing transferSize.

Carry explicit cache state through buffered and streamed fetches, navigation, subresource snapshots and response interception. Resource Timing reports zero transfer for local hits, validation overhead for merged 304 responses, and body bytes plus header overhead for network responses. Cover disk and memory cache state in the HTTP timing fixture and native response tests.
2026-10-31 20:06:00 +08:00
ldm0 f802862181 refactor(indexeddb): use Tokio database owners and timed connection cleanup
Replace fixed worker shards and Lane locks with one async worker and one FIFO owner per database. Move synchronous SQL, connection work and catalog operations to the blocking pool. Drain accepted work and await final owner receipts before retirement or runtime teardown.

Use a single maintenance task with a short idle grace and at most one pending check per database, so slow owners cannot stall later rounds. Retry transient open failures in the same prepared generation while preserving terminal missing-file checks. Cover lifecycle races, low-FD creation and recovery, and single-worker host shutdown without new shared resource budgets.
2026-10-30 20:27:08 +08:00
ldm0 045041566f fix(storage): use temporary disk backing without a profile 2026-10-30 15:53:29 +08:00
ldm0 907a27de0c fix(cdp): preserve prepared documents when enabling Page
Page.enable must acknowledge a native Document that is already running while protocol Page adoption waits for resources. Reuse the prepared-document lifecycle state instead of starting another lazy initial navigation, which can revoke the existing work and deadlock behind Fetch interception. The regression holds a script response, enables Page before adoption, verifies the original paused Fetch remains valid, and checks the final URL for both normal and crashed targets.
2026-10-30 04:14:12 +08:00
ldm0 273ce0519d refactor(indexeddb): remove shared in-flight memory budgets 2026-10-30 03:31:32 +08:00
ldm0 26a50c0116 refactor(indexeddb): remove JSON backend and whole-database working copies
Keep IndexedDbManager as the owner of a required SQLite service, with committed usage and shutdown access. Remove the synchronous storage API, legacy persistence and transaction data copies.

Delete bucket IDB owner-key imports while preserving durable bucket identities, pending deletion and CacheStorage recovery. Port storage fixtures and the native benchmark to actual SQL connections and commands; retain generic key/direction tests and port cold-reopen and invalid-key transaction contracts to SQLite.

Validation: cargo fmt --all; workspace Clippy with all targets/features and -D warnings; nextest 21,815 passed,19 skipped;229 native/storage tests passed all20 stress iterations;memory/disk benchmark smoke passed.
2026-10-30 03:31:32 +08:00
ldm0 068941f411 refactor(indexeddb): use SQLite across renderer storage entry points
Route the public manager constructor through the SQLite service, including protocol ephemeral browser contexts. Match injected bucket owners and run existing storage fixtures through native completions and the Page task dispatcher.
2026-10-30 03:31:32 +08:00
ldm0 ffdbbd098b test(target): wait for background document load before DOM assertions 2026-10-30 03:31:32 +08:00
ldm0 4bd588d9ee fix(input): complete native drag events and rich payloads 2026-10-30 03:27:19 +08:00
ldm0 e7c610b355 fix(input): revalidate drop editors and release finished drag views
Recheck the original Document, connectivity and current editing host after
beforeinput. Use the current host for insertion mode and input dispatch,
including inherited plaintext-only editors.

Use the shared UTF-16 range helpers for contenteditable replacement and
caret offsets in drop and Input.insertText.

Disconnect disabled DataTransfer views and detached item wrappers from the
backing store and raw records without invalidating active drag storage,
read-only InputEvent snapshots or explicitly captured files and entries.
Add weak-reference GC regressions and shared Chromium/Moli drop cases.

Validation: cargo fmt --all; full workspace Clippy with warnings denied;
21,288 Nextest tests passed, 19 skipped; Moli build; 164 Python tests;
seven actual Moli drag scenarios and 20 editing cases / 121 assertions;
the same 20 editing cases pass Chromium 145.
2026-10-30 03:27:19 +08:00
ldm0 3bb459f524 feat(cdp): intercept native drags with complete input lifecycle 2026-10-30 03:27:19 +08:00
ldm0 4f5778d7db perf(runtime): trim workflow query forwarding and clones 2026-10-29 19:59:31 +08:00
ldm0 78ebc22b77 refactor(runtime): use synchronous workflow state access 2026-10-29 17:39:23 +08:00
ldm0 9c71de3c9c fix(protocol): keep history stable across document.open
Use Page residence and the stable Document token to deduplicate native
history registration and Page adoption. Keep lifecycle epochs in native
execution and cancellation identities. Adopt a restarted epoch's reply
title instead of retaining a title published by its predecessor epoch.

Cover asynchronous document.open/write/close before DCL on reused and
crash-recovery Pages, checking history length/index and replacement
content/title without requiring unchanged entry ids.
2026-10-29 17:39:23 +08:00
ldm0 922419d5b2 fix(protocol): complete prepared Document policy and retirement
Dispatch late Fetch configuration and blocked URLs to the exact running native
Document before Page adoption. Apply admitted title facts to the published
history entry before later pushState operations can create another entry. The adoption path
retains the reply's exact Document identity even before native commit projection,
so journal and reply arrival order cannot register the same history entry twice.

Retire failed debugger-paused Worker targets and sessions when their prepared
owner is superseded, even after native destruction has already been deferred.
A new native commit also ends that deferral; stale Page destruction cannot
start it again. Reuse the existing retirement and session disposal paths.

Cover reused and crash-recovery Pages with four WebSocket regressions. Hold
response headers to enforce policy/title phases and require Worker retirement
before the replacement Document can commit.
2026-10-29 17:39:23 +08:00
ldm0 8087e48649 refactor(protocol): simplify Fetch dispatch and workflow state
Carry matching completion data in each Fetch operation instead of storing a
parallel dispatch kind. Restrict navigation termination to document work and
require native completion results directly, removing impossible fallbacks.

Move one owned workflow payload through execution, cancellation and recovery.
Derive renderer commit observation from its captured native Document.

Wait for the recovered session/frame/loader load in the cancellation integration
test before querying the new realm; a navigation ACK can precede Page adoption.
2026-10-29 17:39:23 +08:00
ldm0 804bf1e357 fix(protocol): preserve native Document work before Page adoption
Capture weak command capabilities for the exact native Document behind early
Fetch pauses. Use them for request, response, authentication and cleanup work,
and restore pause records when dispatch is rejected.

Carry publication Page sources through owner-action projection. Register and
attach workers during handoff, revoke abandoned Page workers, and preserve
source identity for dialogs, choosers, popups and script navigation.

Record native navigation history once, retain observed URLs and titles at
adoption, and publish error-Document failure before its frozen frame commit.
Add controlled WebSocket regressions for handoff, cancellation and recovery.
2026-10-29 17:39:23 +08:00
ldm0 34bd52d306 fix(cdp): share nested target session routing policy 2026-10-29 17:39:23 +08:00
ldm0 2e5bcc6fc8 fix(cdp): preserve non-flat target session output routing 2026-10-29 17:39:23 +08:00
ldm0 7192c36264 refactor(protocol): simplify state access and dispatch 2026-10-29 17:39:23 +08:00
ldm0 06fcf9d91e refactor(protocol): finish synchronous owner migration
Run CDP, BiDi, Classic and test workflows through finite synchronous state
access and revocable weak handles. Remove the mailbox, Inline driver,
exclusive completion branches and unused Fetch/Runtime connection APIs.

Keep original document, attachment and call identities through owned waits.
Preserve terminal responses for retired documents, settle empty renderer
boundaries and retain Fetch request announcements until terminal delivery.
Keep body/resource I/O outside shared state and preserve typed error causes.

Validation: cargo fmt --all; full workspace/all-targets/all-features Clippy;
21,456 Nextest tests (19 existing skips); five ownership doctests; same-source
CLI with Playwright, Puppeteer and CDP/BiDi/Classic workflow checks;
1,024 complete navigations; 128 cancelled waits and 4,096 peer commands.
2026-10-29 17:39:23 +08:00
ldm0 acdbc9587e refactor(protocol): unify automation admission and own preload workflows
Admit finite commands synchronously and route every asynchronous automation
command through the existing controller. Remove the server's duplicated
owned-command selector and exclusive-connection fallback. Restrict the old
automation and Runtime/Page inline entry points to the test harness.

Prepare desired preload registries before waiting and retain each original
host and Document for ordered Native updates. Reuse target preload/channel
execution and completion-owned recovery without adding task registries.

Pass actual ingress receivers into BiDi realm, layout and frame inventories.
Keep their accepted output prefixes in the original command's event sources;
perform context and target descriptor inventories synchronously.

Preserve original pending navigation replies from admission queries and realm
replay before projecting subscription events. Give the header-only network
baseline fixture its own URL so late baseline events cannot select the
collector request. Keep the original body and success assertions.

Validation: cargo fmt --all; default CLI Clippy; workspace all-targets
all-features Clippy with -D warnings; cargo nextest run --no-fail-fast
(21,413 passed, 19 existing skips); five protocol doctests.
2026-10-29 17:39:23 +08:00
ldm0 5021e7c5df refactor(protocol): own automation navigation workflows
Route navigation, reload and history traversal through the shared automation
owner and Page workflows. Retain the original typed result, navigation
identity and source response across auth handoff and lost ready results.

Reuse the Page completion body for exclusive compatibility and preserve
private task replies across independent renderer output boundaries. Remove
the duplicated protocol-neutral navigation dispatcher and completion loop.

Validate Direct state without a mailbox through the actual renderer
transport, accepted ready-result recovery and Inline compatibility.

Validation: root fmt, workspace Clippy, Nextest (21,393 passed, 19
existing skips), five borrow-boundary doctests, and source-matched
CDP/BiDi/Classic, Playwright, Puppeteer and navigation smoke checks.
2026-10-29 17:39:23 +08:00
ldm0 4dc4a48c73 refactor(protocol): own automation DOM and Page query workflows
Route DOM commands and Page frame inventories, layout metrics and screenshots
through the existing supervised automation workflow. Freeze the original
Page scope for child-frame queries and object registration, preserve typed
errors and exact Native cursors, and remove connection-borrowing dispatch
loops and query helpers. Independent Page inventories keep separate streams.

Exercise direct state access without a mailbox, child-frame projection and
unknown-node errors, recreated hosts with reused literal ids, and distinct
Native frame inventories. Existing DOM fixtures consume complete output
ownership while preserving their semantic assertions.
2026-10-29 17:39:23 +08:00
ldm0 3f87195084 refactor(target): own automation creation and lifecycle workflows
Run target creation, activation, closing and browser-context removal through
the existing automation workflow controller. Creation owns its admitted blank
document build and preload channel setup; activation reuses the finite surface
and visibility flow. Close and removal reuse the original Target retirement,
disposal, output and recovery owners through the common protocol adapter.

Keep creation and activation completion-owned after their finite admission so
waiter cancellation cannot abandon the original browser transition. Freeze
the actual target host for output projection and creation publication; retain
initial realm/listener and best-effort activation behavior. Delete the old
async automation wrappers and the resulting unused connection helpers.

Validation: root fmt, full workspace Clippy and unfiltered Nextest with default
parallelism; protocol doctests; source-built CLI CDP/Playwright/Puppeteer/BiDi
checks including user-context removal while an author promise is held. Direct
state regressions cover all four lifecycle commands, cancellation before the
first poll and discarded ready creation results.
2026-10-29 17:39:23 +08:00
ldm0 fd994c2299 refactor(protocol): own automation input and Fetch workflows
Route six Input and seven Fetch automation commands through the shared owned
workflow controller. Reuse the existing finite domain admission, native waits,
recovery contexts and typed result owner; remove the old async wrapper loops.

Freeze the original page host for input settlement, downloads, file choosers
and output projection. Keep typed admission causes and canonical document
errors until the protocol boundary. Preserve Fetch metadata before its
independent navigation output boundary and consume only the internal reply.

Supervise Fetch handler revocation during the owned wait and before adopting
a queued ready receipt. Explicit revocation and owner teardown wake weak
lifetime observers without extending the original owner lifetime.

Validation: root fmt, full workspace Clippy and unfiltered Nextest with the
default parallelism; protocol doctests; source-built CLI with CDP, Playwright,
Puppeteer and BiDi, including real keyboard input and request/response-stage
interception with independent progress while blocked.
2026-10-29 17:39:23 +08:00