Repository navigation
fix(serve): honor --document-start-script in protocol-server pages - #2292
Merged
Merged
Conversation
Contributor
Author
|
FYI: the only failing check, Python harness tests, failed inside |
neosun100
force-pushed
the
pr/k3-serve-document-start-script
branch
from
November 2, 2026 14:14
ca82b01 to
e13f173
Compare
`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
force-pushed
the
pr/k3-serve-document-start-script
branch
from
November 2, 2026 22:45
1d1ddaf to
3388267
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
moli fetchreads configured document-start scripts straight fromBrowserConfig, but
moli servebuilds its pages fromNavigationRuntimeConfig, which never carried them, so the flag was a
silent no-op in serve mode.
document_start_scripts, populated inFrom<&BrowserConfig>; the two exhaustive destructurings mark it as not
engine state.
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
mainat 2870135 (macOS arm64):cargo fmt --all -- --check: cleancargo clippy --workspace --all-targets --all-features -- -D warnings: cleancargo nextest run --profile ci -p moli-core -p moli-protocol: 6163 passed, 8 skippedBefore rebasing, the whole workspace
cargo nextest run --profile ciwith this change (together with my other fixes, on the oldermainat898ba89d) passed on Linux amd64: 21997 passed.