Skip to content

feat: allow evaluate_script to skip the stable DOM wait#2346

Open
thomasbachem wants to merge 1 commit into
ChromeDevTools:mainfrom
thomasbachem:feat/evaluate-script-wait-for-stable-dom
Open

feat: allow evaluate_script to skip the stable DOM wait#2346
thomasbachem wants to merge 1 commit into
ChromeDevTools:mainfrom
thomasbachem:feat/evaluate-script-wait-for-stable-dom

Conversation

@thomasbachem

@thomasbachem thomasbachem commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Closes #2338

Adds a waitForStableDom parameter to evaluate_script (default true). Passing false skips just the stable DOM wait in waitForEventsAfterAction() – the navigation probe and dialog handling stay, so a script that unexpectedly navigates is still awaited (and the navigation reported), and an alert() is still auto-handled. The page path passes the flag through, and service worker evals now always skip the stable DOM wait (workers can't interact with the DOM – thanks @Lightning00Blade).

Read-only evals drop from ~205ms to ~103ms on quiet pages, and from ~3.1s to ~103ms on pages that never go quiet – numbers and repro in #2338.

This is the branch the issue promised – I see #2344 beat me to posting, so take whichever is easier to review. Differences here: complete npm run gen artifacts (tool_call_metrics.json + chrome-devtools-cli-options.ts, so check-docs passes), a skip test that spies WaitForHelper.prototype.waitForStableDom (fails if the helper ignores the flag, not only if the option isn't passed through), and a test pinning the safety property – a script that navigates with the flag off still gets its navigation awaited and reported.

@Lightning00Blade Lightning00Blade left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, I left some small comments.

Comment thread src/tools/script.ts Outdated
Comment thread src/tools/script.ts Outdated
@thomasbachem
thomasbachem force-pushed the feat/evaluate-script-wait-for-stable-dom branch from 68e7034 to c9dab9d Compare July 13, 2026 15:56
@Lightning00Blade
Lightning00Blade force-pushed the feat/evaluate-script-wait-for-stable-dom branch from c9dab9d to 5397c2f Compare July 14, 2026 09:02
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.

Allow read-only evaluate_script calls to skip the stable DOM wait

3 participants