Commit Graph
229 Commits
Author SHA1 Message Date
ldm0 8597efb12f fix(stylesheets): bind parser imports before releasing scripts 2026-11-03 07:53:58 +08:00
ldm0 86ede9afdb fix(stylesheets): reject child integrity failures before CSSOM
Reject integrity-failed parser stylesheet responses in child Documents before preparing or installing an owner CSSStyleSheet. Complete the failed load and release its blocker through the existing terminal path.

Add eight end-to-end URL iframe/srcdoc cases covering initial and cached integrity rejection, matching hashes, CSSOM and computed style, dependent import suppression, and parser/DCL/iframe-load progress.

The regression reproduced the empty-sheet bug at the previous PR head. Validation at 32 build jobs, test threads and Tokio workers: cargo fmt --all; cargo clippy --workspace --all-targets --all-features -- -D warnings; cargo nextest run --no-fail-fast.
Summary [ 146.212s] 22163 tests run: 22163 passed (9 slow), 20 skipped
2026-11-03 07:16:23 +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
ldm0 d9290e87ad feat(modules): support native text module imports
Support type: text through the shared module map, Window, child Documents and workers. Export UTF-8 decoded strings without executing their contents, preserve typed-module identity, and carry text request metadata through network, preload and Service Worker loaders. Regressions cover static/dynamic import sharing, BOM and invalid UTF-8, CORS, integrity, worker environments and unsupported-type rejection.

Extracted from development commit a6de018613.
Base: main (62e527cd34).

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 [ 146.817s] 22203 tests run: 22203 passed (9 slow), 20 skipped
2026-11-03 06:30:06 +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 cba18451c8 test(scripts): gate parser stylesheet after runtime load mutation
Release the parser-owned blocking stylesheet only after the runtime stylesheet load handler has applied its DOM marker. Use the existing fixture event gate and a dedicated signal route to establish the renderer/parser snapshot ordering explicitly, preserving the marker and event-order assertions without relying on two relative network delays.

Extracted from development commit f51d7c2c5e141b0926e262a35c3d21ff6cb79450.
Base: main (b30f39c580).

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 [ 147.438s] 22169 tests run: 22169 passed (9 slow), 20 skipped
2026-11-02 22:28:59 +08:00
ldm0 460096594e test(core): prove fetch deadlines interrupt an entered navigation grace
Warm the renderer before starting the short deadline and assert the lifecycle decider actually enters its successor-navigation grace path. Preserve the original 100 ms request timeout, 10-second grace and owner-recovery bounds.

Extracted from development commit 739748a5d14a9cfd0c5aff913146a238d97030c9.
Base: main (b30f39c580).

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 [ 147.288s] 22169 tests run: 22169 passed (9 slow), 20 skipped
2026-11-02 22:28:44 +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 244192dccb refactor(storage): remove unused cross-partition usage APIs 2026-11-01 05:19:55 +08:00
ldm0 a598b45216 refactor(storage): remove unused persistence APIs 2026-11-01 04:03:38 +08:00
ldm0 843ddcc3f2 refactor(storage): retire protocol cookie profiles and close partitions once 2026-11-01 04:03:38 +08:00
ldm0 59743d9466 refactor(storage): remove the legacy JSON Web Storage backend
Keep SQLite for persisted localStorage and memory for sessionStorage. Remove
the unused JSON backend, serialization types, constructors, reexports, and
dependencies. Explicit external data imports still target SQLite; older JSON
profile files remain untouched without automatic migration.
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 6584ff274f refactor(storage): keep SQLite databases directly in partition directory 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 b5cf04a307 refactor(storage): switch SQLite namespaces without JSON migration 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 6708ecf8ac feat(profile): stage and recover atomic SQLite cookie and localStorage migration 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 ef1f983b4b refactor(storage): share the partition SQLite runtime with IndexedDB 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 5a9837461c test(indexeddb): split live cursor coverage into bounded probes
Run independent source and direction matrices in separate Runtime commands while preserving all 660 checks per realm and the existing 30-second command limit. Report the failing realm and matrix in timeout errors.
2026-11-01 03:55:30 +08:00
ldm0 59b0aa9754 fix(worker): send typed Fetch Metadata for worker main scripts
Set SameOrigin mode and native Worker/SharedWorker destinations on dedicated, nested and shared worker main-script requests. Retain CORS mode for module imports and honor nested worker script-kind credentials.

Validation (32 build jobs / test threads, zero retries):

- `cargo fmt --all`
- `cargo clippy --workspace --all-targets --all-features -- -D warnings`
- `cargo nextest run --no-fail-fast`: Summary [ 133.978s] 22032 tests run: 22032 passed (9 slow), 19 skipped
2026-10-31 21:23:14 +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 3c826bd1e8 fix(referrer): use delivered Document policies for Fetch and XHR
Read effective policies from native Document delivery state and preserve them in Fetch and both XHR transport paths. Remove obsolete subtree rescanning and response-only owner lookups.

Validation (32 build jobs / test threads, zero retries):

- `cargo fmt --all`
- `cargo clippy --workspace --all-targets --all-features -- -D warnings`
- `cargo nextest run --no-fail-fast`: Summary [ 141.923s] 21998 tests run: 21998 passed (9 slow), 19 skipped
2026-10-31 18:55:48 +08:00
ldm0 77c7f1fdc2 fix(indexeddb): preserve native request attributes and factory result state
Expose IDBRequest attributes through branded readonly prototype getters backed by native lifecycle state and traced values. Pending result/error throw InvalidStateError; cursor reuse and upgrade completion update internal state without writing author properties. Preserve the SQLite factory and owner-completion paths and their versionchange/delete event metadata. Cover pending, success, error, abort, shadowed properties and borrowed cross-realm getters.
2026-10-30 20:58:07 +08:00
ldm0 416e0607aa fix(indexeddb): reserve open results before upgrade completion callbacks
After a successful SQLite COMMIT receipt, reserve the upgrade open-result task before transaction complete listeners can enqueue regular request results. Retain openRequest.transaction through complete dispatch and clear it after dispatch; result delivery still checks for a closed connection. Correct IDBDatabase.transaction.length to 1. Retain the Window, iframe and Worker conversion, upgrade-boundary, ordering, close and reopen regressions.
2026-10-30 20:58:07 +08:00
ldm0 a587a5ecee perf(indexeddb): load Blob bodies on demand across consumers
Return immutable stored Blob/File sources without eagerly reading their bodies. Keep metadata, clone and slice lazy; route consumption through the owner, stream in chunks, and preserve handed-out data before destructive changes or retirement.

Adapt FileReader, Clipboard, WebSocket and OPFS together with the source representation. Share Fetch/XHR object-body extraction and propagate Blob and multipart read failures instead of string coercion. Preserve cancellation, ordering, backpressure, quota, permission/error semantics and realm cleanup across consumers.
2026-10-30 20:27:08 +08:00
ldm0 cf802a0acd fix(indexeddb): expose native readonly schema attributes
Expose IDBObjectStore and IDBIndex readonly attributes through generated branded prototype getters. Keep immutable flags, cached keyPath values and parent references in V8-traced private slots on ordinary and failed schema handles; indexNames reads the current SQLite metadata mirror. Remove obsolete public-property rewrites so author shadows and cached arrays survive schema edits and rollback. Preserve collectible wrappers and native Proxy/cross-realm behavior. Use the shared lossless SQLite schema-name model, independently of mutable rename; mutable name behavior remains a separate topic. Retain all readonly/identity/rollback assertions from the original fixture and save its full rename integration matrix for the SQLite rename work.
2026-10-30 17:50:36 +08:00
ldm0 b52ca510ea fix(indexeddb): preserve UTF-16 schema names through SQLite
Carry store and index names as IndexedDbName code units through WebIDL DOMString16 conversion, transaction scopes/admission, metadata, queued operations, cursors and DOMStringList. Store labels as ordered UTF-16BE BLOBs in SQLite schema v3; migrate known v1/v2 tables transactionally while preserving stable ids, records, indexes, generators and logical usage. Reuse the database-name codec and existing SQL command FIFO. Add exact surrogate/replacement/NUL/astral name operations in Window, iframe and Worker, plus native disk restart and malformed-label migration rollback/retry tests. This prerequisite supplies the lossless name model needed by the separate index/store rename setters.
2026-10-30 17:50:36 +08:00
ldm0 8564d0a23f fix(indexeddb): preserve UTF-16 database name identity
Preserve database DOMString names as IndexedDbName code units across derived WebIDL conversion, native connection FIFO, SQL service identity, IDBDatabase.name and databases() results. Store database names as UTF-16BE BLOBs in SQLite schema v2. Migrate v1 TEXT metadata inside one SQL transaction after owner/name/generation validation, keeping records, stable ids, generators and logical quota accounting. Extend the existing generation-path hash with canonical WTF-8 so legacy Unicode directory paths remain unchanged. Retain the complete original Window/iframe/Worker conversion, independent-record/version, abort, deletion and cross-agent matrix. Add real disk-profile restart plus legacy migration/failure, exact queue identity, path compatibility and quota-rollback regressions. This database-name topic is independent of object-store/index rename and readonly schema attributes.
2026-10-30 17:50:36 +08:00
ldm0 045041566f fix(storage): use temporary disk backing without a profile 2026-10-30 15:53:29 +08:00
ldm0 e97641f7a9 test(indexeddb): retain live cursor mutation coverage on SQLite
Carry the complete live cursor mutation matrix from superseded #1341 onto SQLite, without its snapshot rescanning implementation. Cover writes during iteration, pending cursor values, forward/reverse and unique directions in Window, iframe and Worker contexts.
2026-10-30 11:09:24 +08:00
ldm0 e3911cf75b feat(indexeddb): extend native geometry snapshots with shared codecs 2026-10-30 04:17:00 +08:00
ldm0 273ce0519d refactor(indexeddb): remove shared in-flight memory budgets 2026-10-30 03:31:32 +08:00
ldm0 d8755b9ff9 refactor(indexeddb): replace task tickets with one data byte budget 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 620ce7735f feat(indexeddb): enable SQLite for browser partitions 2026-10-30 03:31:32 +08:00
ldm0 3aceb8a3e2 fix(indexeddb): close partition SQL before releasing profile locks 2026-10-30 03:31:32 +08:00
ldm0 3bb459f524 feat(cdp): intercept native drags with complete input lifecycle 2026-10-30 03:27:19 +08:00
ldm0 dcae77e5aa feat(indexeddb): store native DOMRect snapshots with shared codecs 2026-10-29 17:43:13 +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 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 39e6d90ab1 refactor(runtime): run automation commands as owned async workflows
Move all six neutral Runtime commands, including target/realm lookup,
node materialization, channels and locateNodes, into one ordinary async
workflow using finite state access and the existing command supervisor.
Remove the duplicated preparation/completion and server deferred-reply loops.

Keep the original Page/host/binding authority, typed result, accepted output
and cancellation with their command owner. Recover failed Native output
before adoption, hand channel listeners over at script admission, and release
temporary locateNodes object groups on cancellation. Classic and BiDi use
the same owned wait and move-only completion receipt.

Validate direct-owner before-poll and held-Promise cancellation, ready loss,
recreated hosts, channel progress, context close and actual Native proxy
release. Run root fmt, full workspace Clippy and Nextest, doctests and the
same-source CLI, Playwright, BiDi and Puppeteer suites before committing.
2026-10-29 17:39:23 +08:00
ldm0 835d08b590 refactor(page): own command waits and finite completion
Run Page composite commands in the existing supervised command workflow.
Prepare preload, stop, crash and close ownership at admission; keep native
waits outside state access and complete finite commands synchronously.

Share owned navigation commit, streaming response and retirement logic with
Fetch. Preserve current, nested and background navigation reply ownership,
including accepted terminals during later waits, cancellation and ready loss.
Keep stop cleanup scoped to its original request and retain crashed Pages
before awaiting shutdown.

Remove the child-navigation Owned/Inline split, redundant world phases and
old exclusive Page completion/activation wrappers. Carry typed native errors
and use finite state operations for output, attachment and listener updates.

Keep original Native child facts routable through the unbound Document
handoff without granting business access. Preserve their exact Document tree
through adoption and use the captured owner for events and response bodies
when foreground selection changes.

Validate controlled renderer-held peer progress and recovery, successor
navigation ownership, stale world attachments, full workspace checks, source
CLI compatibility, Playwright, Puppeteer and parallel targeted stress. Replace an old stylesheet fixture clock check with
a script-released CSS gate while preserving the parser/DOM ordering checks.
2026-10-29 17:39:23 +08:00
ldm0 6b308b10bd refactor(runtime): move worker Inspector completion into owned workflows 2026-10-29 17:39:23 +08:00
ldm0 326045091d refactor(protocol): own BiDi channel waits and renderer output
Run preload proxy/listener admission and object-group release as ordinary
async workflows outside protocol state. Supervise initial dispatch in the
existing owner-work task, hand long promises to the original response lane,
and retain exact binding, host, native attachment and group ownership.

Keep materialized events and their renderer cursor in the existing protocol
queue until typed projection completes. Preserve navigation response/commit
boundaries, cancellation cleanup and original output after Page retirement;
reject rebound-session replies before they can consume a successor journal.

Validation: root fmt, complete workspace/all-targets/all-features Clippy,
root Nextest (20,996 passed; 19 skipped), five lifecycle doctests, and
3,973 focused protocol/scheduler tests. Real CLI CDP, captured/auth, child
navigation, Playwright and debugger-held peer progress checks passed, as
did 18 sequential BiDi messages across two realms with 16 peer requests.
2026-10-29 17:39:23 +08:00
ldm0 96ffdbfdfa refactor(protocol): own runtime helpers and popup activation waits
Run internal Inspector helpers and realm inventory through finite state
operations, preserving native error causes and the original session, host,
Page and renderer-call identities through completion and cancellation.
Separate navigation Page installation from retirement of the previous Page.

Route popup activation through the existing supervised owner-work path. An
activation waiting on a pending Document commit now leaves the actor free to
consume that commit and discovery control requests. Reuse the same native
wait and terminal output after cancellation or ready-result loss.

Make CLI readiness regressions wait for the initialized successor DOM and
exercise a shared deadline with stages that each fit a fresh budget, including
a direct-load success control and exact timeout-phase/output assertions.
2026-10-29 17:39:23 +08:00