Skip to content

fix(pages): report actual page size after resize_page - #3442

Closed
kuLm1Fs wants to merge 1 commit into
ChromeDevTools:mainfrom
kuLm1Fs:fix/resize-page-actual-size-2998
Closed

kuLm1Fs wants to merge 1 commit into
ChromeDevTools:mainfrom
kuLm1Fs:fix/resize-page-actual-size-2998

Conversation

@kuLm1Fs

@kuLm1Fs kuLm1Fs commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Fixes #2998

Problem

resize_page reported success even when Chrome clamped the requested size (e.g. a 100x100 request ends up 500x100 because of Chrome's minimum window width), so agents assumed the page was at the requested size.

A previous attempt (#3132) was reverted in #3308 because Page.getLayoutMetrics on a background tab returned the old size (#3306).

Changes

  • Add McpPage.resize(): normalizes window state, brings the target page to the front, resizes, then reads cssLayoutViewport from Page.getLayoutMetrics. Metrics are skipped if bringing to front fails or a dialog is open.
  • resize_page now appends Requested WxH, page is WxH when the actual size differs from the request; the tool description is updated accordingly (docs regenerated with npm run gen).

Notes

Bringing the page to front on every resize_page avoids the stale background-tab size from #3306, but it is a behavior change for callers that resize a background tab. Happy to switch to skipping the size check (or reporting it as unknown) when the page is not frontmost if that's preferred.

Testing

  • npm run test tests/McpPage.test.ts tests/tools/pages.test.ts (new cases: clamped size reported, matching size, unknown size, open dialog, bringToFront failure)
  • npm run check-format

…#2998)

After resize_page, read Page.getLayoutMetrics and, when Chrome clamps
the window, append "Requested WxH, page is WxH". Bring the target page
to the front first so background tabs do not report a stale size
(ChromeDevTools#3306).
@google-cla

google-cla Bot commented Nov 10, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@OrKoN OrKoN 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.

Using layout metrics does not work for backgrounded pages.

@OrKoN OrKoN closed this Nov 10, 2026
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.

resize_page reports success when the page does not end up at the requested size

2 participants