Skip to content

Browser.setWindowBounds is accepted but never resizes, moves or hides the page #2777

Open

Description

@lanyue-llk

Environment

  • moli v1.1.23 (aarch64-apple-darwin), moli serve --layout; the code path is unchanged on current main (cbf4d0149f)
  • Reference: Google Chrome 157.0.8103.52 --headless=new

Steps to reproduce

On any page:

  1. Evaluate [innerWidth, innerHeight, outerWidth, outerHeight, screenX, screenY].
  2. Browser.getWindowForTarget {targetId}.
  3. Browser.setWindowBounds {windowId, bounds: {left:10, top:20, width:800, height:600}}.
  4. Evaluate the same metrics and matchMedia('(max-width: 900px)').matches.
  5. Browser.setWindowBounds {windowId, bounds: {windowState:'minimized'}}, then read document.visibilityState.

Expected (Chromium)

  • Step 2 returns a full rectangle, e.g. {left:22, top:22, width:756, height:556, windowState:'normal'}.
  • After step 3 the metrics are 800,513,800,600,10,20 and the media query matches.
  • After minimizing, visibilityState is hidden.

Actual

  • Step 2 returns {windowState:'normal'} with no rectangle.
  • The metrics stay 1920,1080,1920,1080,0,0, and the media query is false.
  • visibilityState stays visible.

Root cause

moli-protocol/src/domains/browser.rs:214-259 seeds bounds from BrowserWindowBounds::default() (conn.rs:1669). set_window_bounds only writes conn.browser_window_bounds, and nothing reads that map to resize the page's window, move it, or hide it.

Impact

Clients that size the window instead of using device-metrics emulation see no layout change, and pages never see visibilitychange when the window is minimized. Related: #2767 (omitted fields are erased).

Activity

  1. lanyue-llk commented on Nov 12, 2026

    @lanyue-llk
    ContributorAuthor

    Related validation gap, found while reviewing #2772 (same on main). Chrome rejects Browser.setWindowBounds when it combines a non-normal windowState with left/top/width/height. It also rejects a bounds-only resize while the window is minimized, maximized or fullscreen ("restore it to normal state first"). moli accepts both and stores them. When this issue makes bounds actually apply to the page, these validation rules should come with it.

  2. lanyue-llk commented on Nov 12, 2026

    @lanyue-llk
    ContributorAuthor

    Closing as not planned after a scope review. Chromium behaving differently is not enough reason on its own; the question is whether moli, a headless browser for agent workloads, needs this. moli is headless: clients size the viewport through Emulation.setDeviceMetricsOverride, which works. Applying window bounds to the page only matters for headful window management. The field-merge and getWindowBounds part is handled by #2772.

  3. lanyue-llk commented on Nov 12, 2026

    @lanyue-llk
    ContributorAuthor

    Reopening to keep this on record. It is a reproduced problem that one of the earlier PRs targeted. It is low priority and not scheduled for a fix now; a PR will follow only once the scope (whether moli should support it) and the fix approach are clear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions