e2e: a popup moved to the far right stops where retail's does, the capture's numbers per case

The phase ran moveBy(10, 10) and moveTo(99999, 0) in one popup and expected availLeft + availWidth - outerWidth, which is not retail's clamp:
Mozilla's CheckSecurityLeftAndTop uses the outer width rounded by its edges (CSSIntRect::Round), then the device rounding and the read-back.
The phase now runs the sequence of the retail capture (popup_move_resize, retail-window-geometry, Firefox 159.0) and expects the screenX and screenY
retail read after each call, per case, with the derivation for scale 1.25 written next to the table.
This commit is contained in:
feder-cr committed 2026-11-29 03:50:11 +01:00
1 parent 0b23228eb8
commit b916990a33
1 file changed
+34 -10
@@ -10,9 +10,10 @@ the window tests), each in a popup of its own opened by a real click, ``window.o
measures nothing here: the call is a no-op in its window). The page is watched for 1.5 s after the call, so a change that arrives late is seen.
2. ``moveBy(10, 10)``: ``screenX`` and ``screenY`` grow by exactly 10 CSS pixels, from the position the popup read before. If the parent took the real position of
the window as the base, the declared and the real positions would differ by what the host's window manager decided, and the popup would jump.
3. ``moveTo(99999, 0)``: ``screenX`` is ``screen.availLeft + screen.availWidth - outerWidth``, the three read by the page. The clamp is the page's
(``nsGlobalWindowOuter::CheckSecurityLeftAndTop``: it keeps the window inside the available rectangle of the screen the page reads, with the outer size the page
reads), so the page can learn the real outer width of the window from where the popup stops if the clamp reads any of them from the host.
3. ``moveBy(10, 10)`` and then ``moveTo(99999, 0)``, the sequence the retail capture ran: ``screenX`` and ``screenY`` after each call are the numbers RETAIL read
(``RETAIL``, below, with the capture and the derivation). The clamp is the page's (``nsGlobalWindowOuter::CheckSecurityLeftAndTop``: it keeps the window inside
the available rectangle of the screen the page reads, with the outer width in CSS pixels that Mozilla rounds by its edges), so the page can learn the real
frame of the window from where the popup stops if the clamp reads any of it from the host.
Why a page reads it: a script that moves a window by ten and sees it move by another number, or that throws a window to the far right and reads where it stops,
is reading the host's window manager and its frame.
@@ -30,6 +31,22 @@ from _window_origin import CASES, DEADLINE_S, launch_case, observe, settled, wai
pytestmark = pytest.mark.e2e
#: What RETAIL read, per case, in the round ``popup_move_resize`` of the capture ``retail-window-geometry`` (workflow of oss-invisible/core, run 46215774874, commit
#: 29f3e82, Firefox 159.0; the two machines a and b agree): a popup opened with ``width=500,height=400``, then ``moveBy(10, 10)``, then ``moveTo(99999, 0)``.
#: case -> (moved (screenX, screenY), moved_to (screenX, screenY), outerWidth). The numbers are the capture's, never computed here.
#:
#: Why ``moveTo(99999, 0)`` stops at 1022 at scale 1.25: Mozilla's ``CheckSecurityLeftAndTop`` (dom/base/nsGlobalWindowOuter.cpp) clamps
#: ``x_css = availLeft + availWidth - W``, where ``W`` is the outer width ROUNDED BY ITS EDGES, ``CSSIntRect::Round(deviceRect / scale).width``
#: (gfx/2d/BaseRect.h: ``W = round(x_dev / s + w_dev / s) - round(x_dev / s)``), not the ``outerWidth`` the page reads. At 1.25 the window is at x_dev 16 and
#: w_dev 643: ``W = round(12.8 + 514.4) - round(12.8) = 527 - 13 = 514``, so ``x_css = 1536 - 514 = 1022`` (availLeft + availWidth is 1920 / 1.25 = 1536).
#: The parent then moves to ``devPos = RoundedToInt(1022 * 1.25) = 1278`` (1277.5 rounds up), and the page reads back ``screenX = RoundedToInt(1278 / 1.25) =
#: round(1022.4) = 1022``. The stop is a result of the clamp, the device rounding and the read-back, so it is the capture's number and not a formula of the page.
RETAIL: Dict[str, Tuple[Tuple[int, int], Tuple[int, int], int]] = {
"1920x1080-dpr1.0": ((14, 14), (1404, 0), 516),
"1920x1080-dpr1.25": ((13, 13), (1022, 0), 514),
"1920x1080-dpr1.5": ((13, 13), (764, 0), 515),
"1600x1200-dpr2.0": ((12, 12), (287, 0), 513),
}
#: The button that opens the popup: ``position:fixed`` at (20, 20), 160x40 CSS pixels; its centre is the point of the real click.
OPEN = (100, 40)
FEATURES = "width=500,height=400"
@@ -96,17 +113,24 @@ def _phase_move_by(page, sites, case: str) -> None:
def _phase_move_to_the_far_right(page, sites, case: str) -> None:
"""The retail capture's sequence: the popup, ``moveBy(10, 10)``, ``moveTo(99999, 0)``; where the popup is after each call is what retail read."""
moved, moved_to, outer_width = RETAIL[case]
popup = _open(page, sites)
try:
before = _settled_popup(popup)
popup.evaluate("() => { window.moveBy(10, 10); }")
wait_for(popup, lambda: tuple(popup.evaluate(POSITION)) == moved, DEADLINE_S)
after_by = _settled_popup(popup)
assert (after_by["sx"], after_by["sy"]) == moved, (
"%s: after moveBy(10, 10) the popup is at (screenX, screenY) = (%r, %r); retail read %r (the popup was %r before the call)"
% (case, after_by["sx"], after_by["sy"], moved, before))
popup.evaluate("() => { window.moveTo(99999, 0); }")
# the clamp's own inputs, read by the page after the call: the declared avail rectangle and the declared outer width
wait_for(popup, lambda: popup.evaluate("() => screenX") == popup.evaluate("() => screen.availLeft + screen.availWidth - outerWidth"), DEADLINE_S)
after = settled(popup, lambda: popup.evaluate(READ))
expected = after["availL"] + after["availW"] - after["ow"]
assert after["sx"] == expected, (
"%s: after moveTo(99999, 0) screenX is %r; the declared avail right (availLeft %r + availWidth %r) less outerWidth %r is %r (popup was %r before the call)"
% (case, after["sx"], after["availL"], after["availW"], after["ow"], expected, before))
wait_for(popup, lambda: tuple(popup.evaluate(POSITION)) == moved_to, DEADLINE_S)
after = _settled_popup(popup)
assert (after["sx"], after["sy"]) == moved_to, (
"%s: after moveTo(99999, 0) the popup is at (screenX, screenY) = (%r, %r); retail read %r (availLeft %r, availWidth %r, outerWidth %r; "
"the popup was at %r after moveBy)" % (case, after["sx"], after["sy"], moved_to, after["availL"], after["availW"], after["ow"], (after_by["sx"], after_by["sy"])))
assert after["ow"] == outer_width, "%s: outerWidth is %r after the moves; retail read %r" % (case, after["ow"], outer_width)
finally:
popup.close()