Repository navigation
Conversation
…#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).
|
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
requested changes
Nov 10, 2026
OrKoN
left a comment
Collaborator
There was a problem hiding this comment.
Using layout metrics does not work for backgrounded pages.
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.
Fixes #2998
Problem
resize_pagereported success even when Chrome clamped the requested size (e.g. a100x100request ends up500x100because 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.getLayoutMetricson a background tab returned the old size (#3306).Changes
McpPage.resize(): normalizes window state, brings the target page to the front, resizes, then readscssLayoutViewportfromPage.getLayoutMetrics. Metrics are skipped if bringing to front fails or a dialog is open.resize_pagenow appendsRequested WxH, page is WxHwhen the actual size differs from the request; the tool description is updated accordingly (docs regenerated withnpm run gen).Notes
Bringing the page to front on every
resize_pageavoids 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