Skip to content

Publish Browser.Get|SetWindowBounds and Page.WindowId (#14494)#3131

Merged
kblok merged 6 commits intomasterfrom
implement-upstream-change-14494
Feb 16, 2026
Merged

Publish Browser.Get|SetWindowBounds and Page.WindowId (#14494)#3131
kblok merged 6 commits intomasterfrom
implement-upstream-change-14494

Conversation

@kblok
Copy link
Member

@kblok kblok commented Feb 13, 2026

Summary

  • Implements upstream Puppeteer PR #14494 which adds Browser.getWindowBounds/setWindowBounds and Page.windowId APIs
  • Adds WindowBounds class and WindowState enum to represent browser window dimensions and state
  • Implements both CDP and BiDi protocol paths:
    • CDP: Uses Browser.getWindowBounds, Browser.setWindowBounds, and Browser.getWindowForTarget commands
    • BiDi: Uses browser.getClientWindows and browser.setClientWindowState commands with state mapping
  • Refactors CdpPage.ResizeAsync to reuse the new WindowIdAsync() method
  • Adds WindowBoundsTests with the upstream test for get/set window bounds

Changes

File Description
WindowState.cs New enum: Normal, Minimized, Maximized, Fullscreen
WindowBounds.cs New class with Left, Top, Width, Height, WindowState properties
IBrowser.cs / Browser.cs Added GetWindowBoundsAsync and SetWindowBoundsAsync abstract methods
IPage.cs / Page.cs Added WindowIdAsync abstract method
CdpBrowser.cs CDP implementation using Browser.getWindowBounds/setWindowBounds
CdpPage.cs CDP implementation of WindowIdAsync using Browser.getWindowForTarget; refactored ResizeAsync
BidiBrowser.cs BiDi implementation using browser.getClientWindows/setClientWindowState
BidiPage.cs BiDi implementation returning BrowsingContext.WindowId
BrowsingContext.cs Added WindowId property populated from clientWindow field
UserContext.cs Passes ClientWindowId through to BrowsingContext creation
CDP Messaging classes New request/response classes for the CDP commands
WindowBoundsTests.cs Test for get and set browser window bounds
TestExpectations.upstream.json Added expectations matching upstream for Firefox and headful Windows

Test plan

  • WindowBoundsTests.ShouldGetAndSetBrowserWindowBounds passes on Chrome+CDP
  • ResizeTests continue to pass (refactored to use new WindowIdAsync)
  • Full BrowserTests suite passes without regressions

🤖 Generated with Claude Code

kblok and others added 6 commits February 13, 2026 16:28
…IdAsync (#14494)

Port upstream Puppeteer PR #14494 which adds browser window management
methods. These allow users to get and set browser window position,
size, and state (normal/minimized/maximized/fullscreen).

- Add WindowBounds class and WindowState enum
- Add GetWindowBoundsAsync/SetWindowBoundsAsync to IBrowser/Browser
- Add WindowIdAsync to IPage/Page
- Implement CDP protocol: Browser.getWindowBounds, Browser.setWindowBounds
- Implement BiDi protocol: browser.getClientWindows, browser.setClientWindowState
- Refactor CdpPage.ResizeAsync to use WindowIdAsync
- Add BrowsingContext.WindowId for BiDi protocol
- Add test and upstream test expectations

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… #14494 tests

- Add CreatePageOptions and CreatePageType for window/tab page creation
- Add NewPageAsync(CreatePageOptions) to IBrowserContext/BrowserContext
- Implement in CdpBrowserContext and BidiBrowserContext
- Extend TargetCreateTargetRequest with window bounds and background params
- Update WindowBoundsTests to use CreatePageOptions matching upstream
- Add ShouldSetAndGetBrowserWindowMaximizedState test
- Add NewPageTests (window, position, maximized state, background page)
- Merge with master's screen management (ScreensAsync, AddScreenAsync, RemoveScreenAsync)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…#14547)

- Merge master's background page creation support (BiDi UserContext.CreateBrowserContextAsync with background param)
- Use CreatePageType enum for Type property instead of raw string
- Single NewPageAsync(CreatePageOptions options = null) method signature
- Add [JsonIgnore(WhenWritingNull)] to TargetCreateTargetRequest nullable properties
- Background page test now uses PuppeteerPageBaseTest and Context directly
- Remove local test expectation for background page (now works with master's impl)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant