Skip to content

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

Merged
OrKoN merged 2 commits into
ChromeDevTools:mainfrom
thomasbachem:feat/evaluate-script-wait-for-stable-dom
Aug 10, 2026
Merged

OrKoN merged 2 commits 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.

@OrKoN
OrKoN requested a review from Lightning00Blade July 13, 2026 09:16

@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 Resolved
Comment thread src/tools/script.ts Resolved
@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
@Lightning00Blade
Lightning00Blade requested a review from OrKoN July 29, 2026 09:09
@OrKoN
OrKoN added this pull request to the merge queue Jul 29, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 29, 2026
@thomasbachem
thomasbachem force-pushed the feat/evaluate-script-wait-for-stable-dom branch from 5397c2f to bb10172 Compare July 29, 2026 15:31
@thomasbachem

Copy link
Copy Markdown
Contributor Author

Sorry, that dequeue was mine. The branch still called response.handle('test', context), and #2392 dropped the leading toolName parameter after this PR last ran CI, so the merge commit failed to compile.

I've rebased onto main and updated the call to response.handle(context) – still a single commit, and the only change from what you reviewed is that one line. npm run build, npm run test tests/tools/script.test.ts and npm run format all pass locally against current main.

The workflow runs need approval whenever one of you gets a moment, then it should be good for the queue.

@OrKoN
OrKoN added this pull request to the merge queue Aug 10, 2026
Merged via the queue into ChromeDevTools:main with commit 781e2fb Aug 10, 2026
19 checks passed
@thomasbachem
thomasbachem deleted the feat/evaluate-script-wait-for-stable-dom branch November 24, 2026 15:23
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

4 participants