A popup window opened with a fixed outer size (for example
width=1160,height=900) shrinks on every page reload when the popup
calls window.moveTo(0, 0) during load. The position update is
correct, but the outer size silently decreases on each F5.
repro.html in Chrome stable / canary.1160x900 popup
opens at (0, 0).outerWidth / outerHeight in the popup.F5 in the popup.moveTo() should only change position.// popup.html
(function() {
window.moveTo(0, 0); // runs during page load, not on click
})();
The bug does NOT reproduce when moveTo(0,0) is fired from a
user click without reload. It only triggers on the load-then-reload sequence.
The renderer-side window.moveTo() implementation in
third_party/blink/renderer/core/frame/local_dom_window.cc reads the
current outer window rect, replaces just the origin, and sends the
whole rect back to the browser:
void LocalDOMWindow::moveTo(int x, int y) const {
...
gfx::Rect window_rect =
page->GetChromeClient().RootWindowRect(*frame); // outer rect
window_rect.set_origin(gfx::Point(x, y)); // position only
page->GetChromeClient().SetWindowRect(window_rect, *frame);
}
On the browser side, for non-app popups,
BrowserView::GetSavedWindowPlacement /
SavedBoundsAreContentBounds path treats the rect as
content (inner) bounds, not outer. So each round trip:
(W, H)(W, H) to browser(W, H) as inner client size and re-derives
a smaller outer because the chrome (toolbar / titlebar) is double-countedThis is exactly the inner-vs-outer mismatch flagged in the long-standing
TODO(crbug.com/40092782) already living in both
web_contents_impl.cc and chrome_client_impl.cc.