Skip to content

fix(serve): honor --document-start-script in protocol-server pages - #2292

Merged
ldm0 merged 4 commits into
lexmount:mainfrom
neosun100:pr/k3-serve-document-start-script
Nov 2, 2026
Merged

ldm0 merged 4 commits into
lexmount:mainfrom
neosun100:pr/k3-serve-document-start-script

Conversation

@neosun100

@neosun100 neosun100 commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

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).

Verification

Rebased on main at 2870135 (macOS arm64):

  • cargo fmt --all -- --check: clean
  • cargo clippy --workspace --all-targets --all-features -- -D warnings: clean
  • cargo nextest run --profile ci -p moli-core -p moli-protocol: 6163 passed, 8 skipped

Before rebasing, the whole workspace cargo nextest run --profile ci with this change (together with my other fixes, on the older main at 898ba89d) passed on Linux amd64: 21997 passed.

@neosun100

Copy link
Copy Markdown
Contributor Author

FYI: the only failing check, Python harness tests, failed inside setup-uv while fetching the uv version manifest (##[error]fetch failed), before any test ran. It looks like a transient network error; a re-run should clear it. All other checks pass.

neosun100 and others added 4 commits November 3, 2026 06:33
`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).
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).
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).
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).
@ldm0
ldm0 force-pushed the pr/k3-serve-document-start-script branch from 1d1ddaf to 3388267 Compare November 2, 2026 22:45
@ldm0
ldm0 merged commit 191e5fc into lexmount:main Nov 2, 2026
18 of 21 checks passed
@neosun100
neosun100 deleted the pr/k3-serve-document-start-script branch November 3, 2026 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants