Commit Graph
44 Commits
Author SHA1 Message Date
ldm0 e72a279388 refactor(inspector): borrow pause notification observers 2026-11-12 03:32:12 +08:00
ldm0 82f159c708 Preserve raw Inspector payloads through renderer and CDP routing 2026-11-12 02:01:08 +08:00
guojinghua afd5b8fae3 feat(ace): expose typed page tasks and browser runtime hooks
Add opt-in ace-protocol support with AcePageTask and PageExtensionHost
for renderer-owner-thread inspection, native input, and screenshots.
Expose BrowserRuntimeHandle through a runtime-ready callback so embedders
can discover targets and submit tasks without CDP request/response envelopes.

Reuse supervised page workflows for output ordering, input effects, and
target/document lifetime checks. Recover lost waiters without replaying
admitted tasks, and revoke runtime access on browser shutdown.
2026-11-10 20:26:30 +08:00
ldm0 0551e4afb7 fix(renderer): use shared dialog waiting mode for every Page
A VM created while dialog waiting was enabled cached that value locally. The
cached true value survived disabling or detaching the final Page observer,
so later dialogs could still wait after the shared context flag was false.

Read the BrowserContext shared switch for every dialog. Remove the VM-local
Boolean, its constructor snapshot, the ScriptVm/JsContextHost setters, and the
obsolete Page setter and renderer command. Page domain commands now rely on
the existing shared subscription aggregation.

Cover enabled-at-construction VMs and interleaved disable/detach across two
Pages and different sessions. Verify that confirm returns without a modal wait
while a native handler remains available to handle the prompt. Keep standalone
headless dialog fallback coverage through the shared switch.
2026-11-07 01:22:11 +08:00
ldm0 3bb459f524 feat(cdp): intercept native drags with complete input lifecycle 2026-10-30 03:27:19 +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 83e7091c5a fix(cdp): enforce DOM node publication across commands
Separate backend identity, session frontend bindings, and publication. Publish missing Inspector paths before returning usable node IDs, validate CDP frontend inputs, and retain explicit internal automation bindings.

Preserve expanded and associated subtrees during refresh and mutation resync, including shallow template fragments. Cover cross-command behavior and message ordering with a raw CDP client mirror, Chromium comparisons, and real chromedp queries.
2026-10-29 00:01:33 +08:00
ldm0 9ee1fdf27f refactor(renderer): remove legacy print screenshot entry point 2026-10-16 17:48:09 +08:00
ldm0 53d16780d5 feat(pdf): render searchable PDFs with Krilla
Route CDP Page.printToPDF and CLI PDF dumps through an owned snapshot PDF
backend with embedded subset fonts and logical text cluster mappings.

Preserve print layout isolation, page selection, and bounded local raster
fallbacks. Pin Krilla to upstream Git and share its font parsing dependencies
with the existing rendering stack where version constraints allow.

Add PDF extraction, pagination, graphics, and print lifecycle regressions,
fixed font fixtures, and reader and CDP smoke checks.

Refs #279.
2026-10-12 21:33:26 +08:00
ldm0 1404fa344b perf(accessibility): avoid JSON intermediates in semantic dumps
Large semantic dumps retain a JSON object graph with allocated field names
and string node references for every AX node before formatting the output.

Build compact typed nodes with numeric references and pass them directly
from the renderer to the CLI. Keep one AX traversal for both typed nodes
and CDP payloads, converting protocol nodes individually as they are built.
Preserve omitted/empty fields, field insertion order, list markers, and
frame-root attachment order. Render text iteratively and trim in place.

Add compatibility coverage and a standalone benchmark that stages both
executables on the same filesystem, alternates runs, records peak RSS and
wall time, and rejects changes to dump output bytes.

Against main at 5f5e1fff3 on a generated 40,000-row list (three interleaved
runs, medians):
- semantic_tree_text: 718.42 -> 390.96 MiB; 2.919 -> 2.204 s.
- semantic_tree: 815.71 -> 483.81 MiB; 2.484 -> 2.369 s.
- markdown control: 95.52 -> 95.59 MiB; 0.895 -> 0.913 s.

A generated 200,000-row list also completes with identical bytes (one run):
- semantic_tree_text: 3473.02 -> 1775.07 MiB; 13.245 -> 10.015 s.
- semantic_tree: 3803.45 -> 2137.26 MiB; 12.626 -> 10.397 s.

JSON/text comparisons also match the baseline on a mixed fixture containing
hidden/ignored nodes, form values, list markers, shadow DOM, and child frames.
These generated fixtures are independent of the external MOL-269 evidence.

Validation:
- cargo fmt --all
- cargo clippy --workspace --all-targets --all-features -- -D warnings
- cargo nextest run --no-fail-fast (19,885 passed, 17 skipped)
- cargo build --release -p moli

Refs: MOL-269
2026-10-11 17:37:40 +08:00
ldm0 20b9a7a33c fix(runtime): allow removing bindings while debugger is paused 2026-10-10 17:51:54 +08:00
ldm0 0b11db6cd2 fix(runtime): order binding mutations with subscription delivery
A delayed addBinding adapter could repersist and reapply bindings after a
later Runtime.disable had cleared them. Commit persistent add/remove
mutations in the renderer turn and project their frozen state with the
NativeTerminal, alongside enable/disable. Adapter completion no longer
writes a stale binding snapshot back to either owner.

Unregister V8 bindings during disable as well as clearing restore metadata,
so re-enabling cannot reactivate a removed binding. Include the retained
binding output and metadata in transport memory accounting.

Cover delayed addBinding, unpolled and reversed binding completions, and
binding calls after re-enabling. Document and test the existing committed
SessionSink disable success policy after owner retirement, including
ordered delivery and no duplicate terminal on late adapter completion.
2026-10-10 17:51:54 +08:00
ldm0 8d58d0fd59 fix(runtime): unify turn output and Runtime subscription delivery
Append ready command records directly to the Page journal and publish them
at the common owner-turn settlement boundary. Replace continuation-owned
record batches with exact cursors for internal completion dependencies.

Publish loaded-page frontend Runtime.enable/disable, frozen Inspector output,
and session updates through NativeTerminal. Apply subscriptions and replay
at ordered ingress so delayed adapters cannot reverse newer enable/disable
state. Complete disable binding updates in the originating renderer turn.
Retain exact predecessors for internal/collector completion success and
projection errors, and charge replay/V8 state to the transport memory budget.

Cover unpolled and reversed completions, cancellation after publication,
owner retirement, unresolved Promise output and concurrent ready replies,
and navigation handoff with controlled regression tests.
2026-10-10 17:51:54 +08:00
ldm0 041846069a fix(core): preserve newer Page state when commands settle out of order
Stamp every successful Page VM state capture with its VM creation identity
and capture sequence, including nested captures. Reject older revisions at
the shared Page cache installation point while preserving each query reply.

A real same-document regression holds two DOM snapshots and consumes them in
reverse order. Both return their captured titles, while the cached title
must remain the newer value.
2026-10-06 01:01:03 +08:00
ldm0 91aec378a4 refactor(cdp): search resource content on the renderer owner
Native CDP replies can expose resources before the protocol adapter consumes
its Page snapshot. Resolve, decode, and search sources in one renderer command
instead of refreshing a snapshot and selecting cached content in the adapter.

Pass the immutable main response body by committed loader and preserve frame
matching, decoding, byte limits, and the attachment check before settlement.
Require a single renderer turn in the held-native-publication regression.
2026-10-06 01:01:03 +08:00
ldm0 70b4b1eb15 fix(cdp): refresh resource sources before searching
Native Page replies can reach the frontend before the adapter updates the cached resource report. Capture a current renderer snapshot before selecting root frame subresources and reject completions from replaced renderer attachments.

Add regressions for resource searches before native adapter settlement and for navigation before consuming a resource snapshot.
2026-10-06 01:01:03 +08:00
ldm0 30e36e64a3 fix(cdp): preserve auxiliary Page ownership through document navigation
Create script auxiliary Pages synchronously and let their CDP targets adopt
those exact Pages. Preserve Page and WindowProxy identity through document
navigation, sharing browsing-context names, opener references, message endpoints
and close state with related windows.

Commit browser responses into the existing Page with exact document admission,
cancellation and failure disposition. Capture accepted navigation origin, base,
policy, storage and referrer, preserve auxiliary history and restore related
browsing-context groups without issuing duplicate popup requests.

Reuse the initial same-origin Window while replacing its Document, and centralize
Document owner transitions, descendant retirement and Inspector publication.
Give related Pages independent Inspector routes and shared per-Page startup
pause state, route isolate foreground work through surviving Pages, and cache
cross-origin Window functions in each accessing realm with receiver-aware access.

Cover actual popup state, navigation and parser rebinding, accepted environments,
history, cross-origin access, multiple frontends, cancellation and task retirement.

Validation: cargo fmt --all; cargo clippy --workspace --all-targets --all-features -- -D warnings; cargo nextest run --no-fail-fast.
2026-10-06 01:01:03 +08:00
ldm0 f1c5bf6618 fix(cdp): separate browser window selection from document activity
Track each window's selected tab and browser focus independently of protocol
page routing. Keep window bounds, adjacent-tab close selection, discovery and
target metadata consistent with their owning windows and documents.

Queue renderer activity updates outside the CDP actor, preserve their output
fences and remember admitted activity so focus reversals survive a busy page.
Cover window selection, focus-event state and busy-context activation.

Validation: cargo fmt --all; cargo clippy --workspace --all-targets --all-features -- -D warnings; cargo nextest run --no-fail-fast.
2026-10-06 01:01:03 +08:00
ldm0 c345a594f4 feat(webmcp): implement document tools and CDP integration
Expose secure Document.modelContext APIs with document-owned registrations,
callback realm and input validation, task-based result delivery, and independent
caller cancellation and target completion. Preserve cancellation reasons and
emit lifecycle events only for live owners.

Register native declarative forms in light and shadow trees through indexed
mutation candidates. Track schema changes to valid forms even before a
registration succeeds, including controls associated through a form attribute.
Use changed containers only for ancestor and form-owner checks; inspect added
and removed subtrees for discovery. Retire registrations at actual removal and
owner transitions while preserving submit handling and captured pending responses. Apply validated
fill intents to current options and checkable values in control event order.

Compute tools delegation from committed security origins, ancestor header
allowlists, container declarations, redirects, and combined sandbox policies.
Carry invocation identity, original origin, and resolved target through form
navigation; accept same-origin JSON-LD results and reject cross-origin commits.

Connect typed renderer observations to CDP discovery, invocation, cancellation,
and Runtime result projection. Include renderer and protocol regression coverage
for document lifetime, reentrancy, permissions, dynamic controls, and cancellation.

Validation on this commit tree: cargo fmt --all;
cargo clippy --workspace --all-targets --all-features -- -D warnings;
cargo nextest run --no-fail-fast.
Summary [ 100.619s] 19320 tests run: 19320 passed, 16 skipped
2026-10-05 15:25:06 +08:00
ldm0 a789da8a0d feat(cdp): support Emulation.setScrollbarsHidden
Apply scrollbar hiding to the live Page before acknowledging the command, preserve the startup flag, and replay the target setting before navigation scripts. Validate the required boolean and layout mode, track per-session state, and clear overrides on detach.

Refs #1081
2026-10-04 05:20:17 +08:00
ldm0 9cbdd35da5 refactor(emulation): apply navigator and activity policy together 2026-10-03 03:30:39 +08:00
ldm0 828658d9d4 refactor(renderer): resolve scoped nodes within owner-only DOM operations 2026-10-03 03:30:39 +08:00
ldm0 330b8c6381 refactor(renderer): resolve scoped nodes within read operations 2026-10-03 03:30:39 +08:00
ldm0 5c19ed1006 refactor(dom): resolve attribute references in the renderer handler 2026-10-01 16:51:46 +08:00
ldm0 429847e98a refactor(renderer): use one document serialization command 2026-10-01 16:51:46 +08:00
ldm0 a18314640a refactor(cdp): publish native terminals through the renderer journal
Share terminal authority with Inspector and publish ready native replies
after their renderer facts, independently of adapter polling. Keep typed
internal completions separate and settle caches against the exact residence.

Define exhaustive backend entry requirements for nested Main dispatch and
release Main and IO admission at backend entry. Bind native continuations
and preserve their owner lifecycle before terminal projection.

Migrate Page and DOMSnapshot through the generic operation boundary,
including live tree URLs, initial DocumentLoader identity, document capture
and isolated worlds. Cover cancellation, retirement and pause ordering,
and release held popup fixture routes before awaiting initialization.
2026-10-01 03:33:13 +08:00
ldm0 c4d0cac89a refactor(renderer): own document replacement debugger lifecycle
Move old-document debugger termination into renderer preparation scopes instead of tracking protocol navigation IDs in DevTools. Reject superseded response jobs using exact navigation tokens and cancellation authority, and retire their renderer-channel suspension independently.

Cover response interception and supersession while paused, repeated pauses, and prepare commit/cancellation/drop cleanup. Verified cargo fmt --all, workspace all-targets all-features clippy with warnings denied, 18444 nextest tests, and 20 stress iterations of 127 focused tests.
2026-09-28 20:11:15 +08:00
ldm0 79ea1406fa fix(devtools): unblock navigation while the debugger is paused
Track provisional loads by navigation ID on the existing renderer target and explicitly finish debugger policy on commit or cancellation. Return the pause-loop exit reason and terminate paused old-document execution through V8 Inspector.

Defer intercepted-response document creation until continuation, removing the eager prepared-document paths. Preserve committed documents for aborted navigations and cover repeated pauses, multiple sessions, interception and supersession.

Validated cargo fmt --all, strict workspace clippy, and cargo nextest run --no-fail-fast: 18,429 passed, 13 skipped. New regressions also passed 20 stress iterations and three confirmed debugger-paused ippure navigation probes.
2026-09-28 20:11:15 +08:00
ldm0 1933cec74f refactor(input): centralize editing and native element clicks 2026-09-23 23:06:17 +08:00
ldm0 73f2e785ea fix(emulation): reject unavailable throttling modes 2026-09-15 14:46:31 +08:00
ldm0 3a5cf7f123 refactor(emulation): clarify environment invalidation contracts
Name coalesced work by the native caches it invalidates, and document that the Worker armed bit tracks the outstanding fallback message rather than mailbox contents.

Consolidate Date/Intl options regressions into named cases and fold time-first legacy dates into the shared parsing matrix, retaining their inputs and native-semantic assertions.
2026-09-13 05:55:27 +08:00
ldm0 2d249b069c refactor(emulation): coalesce process environment notifications
Publish typed invalidation flags under the environment lock and wake isolate owners only after releasing it. Bound page and worker notification work while preserving command FIFO, teardown safety, and observation ordering.

Remove stale wrapper-era dependencies and terminology, and add mailbox race and CDP burst regressions.
2026-09-13 05:55:27 +08:00
ldm0 19e5667fe3 refactor(emulation): notify isolate owners without environment generations 2026-09-13 01:07:35 +08:00
ldm0 49ea8a3e1c refactor(cdp): centralize session disposal 2026-09-04 04:39:43 +08:00
ldm0 d73651aea6 fix(renderer): terminate inspector targets on owner shutdown 2026-09-04 04:39:43 +08:00
ldm0 4d0b78f1f8 fix(cdp): unify renderer session response authority 2026-08-25 17:15:54 +08:00
ldm0 461f9bcac4 feat(fetch): enrich JSON dump metadata 2026-08-24 20:04:55 +08:00
ldm0 2fe9e2ad9a fix(devtools): preserve nested Main response order 2026-08-21 20:10:15 +08:00
ldm0 2c186e3c4a fix(devtools): preserve nested Main response order 2026-08-20 14:12:15 +08:00
ldm0 a74431d226 fix(devtools): unify synchronous Page IO responses 2026-08-20 14:12:15 +08:00
ldm0 d28c20ef87 refactor(devtools): align inspector session routing with Chromium 2026-08-19 19:58:31 +08:00
ldm0 f63a5640ab fix(devtools): make Page crash terminal IO control 2026-08-19 19:58:31 +08:00
ldm0 f90729edf3 fix(devtools): unify Page IO agent ingress 2026-08-19 19:58:31 +08:00
ldm0 2692c5ce76 refactor(devtools): separate renderer control plane
Move renderer DevTools command metadata, route-local ingress, and pause coordination out of script_vm. Share the per-session lane algorithm without merging Main and IO state, centralize target lifecycle wiring, and keep first-dispatch permits explicit at the owner boundary.
2026-08-17 00:40:39 +08:00