Skip to content

fix: use page.setViewport instead of page.resize#650

Closed
yasirusman85 wants to merge 1 commit intoChromeDevTools:mainfrom
yasirusman85:fix/resize-page-protocol-error
Closed

fix: use page.setViewport instead of page.resize#650
yasirusman85 wants to merge 1 commit intoChromeDevTools:mainfrom
yasirusman85:fix/resize-page-protocol-error

Conversation

@yasirusman85
Copy link
Copy Markdown

Description

Fixes #645.

The resize_page tool was failing with a Protocol error (Browser.setContentsSize): 'Browser.setContentsSize' wasn't found when running against certain Chrome environments (e.g., remote debugging). This was because it relied on an internal page.resize method that uses Browser.setContentsSize, which is not universally supported.

This PR replaces the internal page.resize call with the standard Puppeteer page.setViewport method. This uses Emulation.setDeviceMetricsOverride under the hood, which is the standard and supported way to resize the viewport for testing and emulation.

Changes

  • Replaced page.resize with page.setViewport in src/tools/pages.ts.

Verification

  • Verified that resize_page now correctly calls page.setViewport with the provided dimensions.

@OrKoN
Copy link
Copy Markdown
Collaborator

OrKoN commented Dec 8, 2025

Thanks for the PR. We are not using set viewport because of the issues with visual rendering that can arise when the window size does not match the viewport. We will keep using the resize for now.

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 fails with Protocol error: Browser.setContentsSize wasn't found

2 participants