e2e: a popup's position is Firefox's own rule (retail round 5: 4, 4 at scale 1.0), no popup_position pref is set; the second popup's stagger waits for capture round 8

This commit is contained in:
feder-cr committed 2026-11-28 21:35:33 +01:00
1 parent 652c911514
commit cb67c18332
2 files changed
+60 -63

No files matched your search

+6 -5
View File
@@ -20,11 +20,12 @@ from _waits import wait_until
#: position 4 (device pixels, and CSS pixels at 1.0). The screen is the one the other surface tests pin.
PIN = {"screen.width": 1920, "screen.height": 1080, "screen.dpr": 1.0}
#: A second declared window frame that no runner has: a border of 6, a popup UI of 53 above the content, a default position of 9. The declared frame at scale 1.0
#: (8, 72, 4) is the frame of a retail Windows window, so a Windows runner's own popup has it too (outer - inner = 16 x 80) and a launch with the engine off
#: cannot tell the declaration from the host there; a launch declared with ANOTHER frame can (the prefs are applied last, over the core's declaration).
OTHER_FRAME = {"zoom.stealth.screen.frame_border": 6, "zoom.stealth.screen.popup_ui": 53, "zoom.stealth.screen.popup_position": 9}
OTHER_BORDER, OTHER_POPUP_UI, OTHER_POSITION = 6, 53, 9
#: A second declared window frame that no runner has: a border of 6 and a popup UI of 53 above the content. The declared frame at scale 1.0 (8, 72) is the frame
#: of a retail Windows window, so a Windows runner's own popup has it too (outer - inner = 16 x 80) and a launch with the engine off cannot tell the declaration from
#: the host there; a launch declared with ANOTHER frame can (the prefs are applied last, over the core's declaration). The position of an unpositioned popup is not
#: declared: it is Firefox's own rule (browser.xhtml screenX/screenY = 4, the stagger, the clamp), the same under every frame.
OTHER_FRAME = {"zoom.stealth.screen.frame_border": 6, "zoom.stealth.screen.popup_ui": 53}
OTHER_BORDER, OTHER_POPUP_UI = 6, 53
READ = """() => ({iw: innerWidth, ih: innerHeight, ow: outerWidth, oh: outerHeight,
sx: screenX, sy: screenY, mx: mozInnerScreenX, my: mozInnerScreenY})"""
@@ -1,29 +1,30 @@
"""A popup reads the window frame the core declares, not the one of the host.
"""A popup reads the window frame the core declares and the position Firefox gives it, not the ones of the host.
What it fixes: the geometry of a window a page opens with `window.open(url, 'p', 'width=500,height=400')`, read from
inside the popup. A popup is its real inner size plus the declared frame (retail Windows Firefox, measured by the core at
scale 1.0: a border of 8 on the left, right and bottom, the popup UI of 72 above the content, and a default position of
4,4 when the page names no left/top):
inside the popup, at scale 1.0. The expected values are retail Windows Firefox 159.0's, round 5 of the window-geometry capture (GitHub run
oss-invisible/core 45952171443, RetailCaptures `captures/WINDOW_GEOMETRY_POPUP_FRAME.csv`, step `popup`, copied by a script into `RETAIL_POPUPS` of
`test_the_maximized_window_frames_and_popups_read_retail_e2e.py`, which this file reads): inner 500x400, outer 516x480 (a border of 8 on the left, right and bottom,
the popup UI of 72 above the content), `screenX` and `screenY` 4, `mozInnerScreenX/Y` 12 and 76.
* `outerWidth == innerWidth + 2 * border`
* `outerHeight == innerHeight + popup_ui + border`
* `screenX == screenY ==` the declared default position (the page named none)
* an unpositioned popup sits where Firefox's own rule puts it, not where a pref says: browser.xhtml's `screenX="4" screenY="4"` (device pixels; CSS pixels at 1.0), applied by
`AppWindow::LoadPositionFromXUL`. The position is no declared value: there is no pref for it, and the same rule gives the same place under any declared frame.
* `mozInnerScreenX == screenX + border`, `mozInnerScreenY == screenY + popup_ui`
Engine hook: `fingerprint/screen-window/geometry` of the engine series (`nsGlobalWindowOuter::GetOuterSize`,
`GetScreenXY`, `GetMozInnerScreenX/Y`, with the content origin shift of `StealthScreenCoords`) and
`fingerprint/screen-window/popup-position` (`nsWindowWatcher`, the default position of a popup).
The second popup of a page (the stagger of round(22 * scale) when another browser window sits within round(4 * scale)) is not read here: capture round 8 has not measured it.
Negative control, in the same test: the same page in a launch declared with a SECOND frame that no runner has (border 6,
popup UI 53, default position 9). The popup reads that one (outer - inner = 12 x 59, screen 9, mozInnerScreen 15 x 62) and
none of the first declaration's numbers, and the two readings DIFFER. The engine off is not the control: the declared frame
is the one of a retail Windows window at scale 1.0, so on a Windows runner the host's own popup has the very same frame
(measured: 16 x 80 with the engine off) and the test could not tell a hook that answers from one that does not.
Engine hook: `fingerprint/screen-window/geometry` of the engine series (the declared window rect and client offset the parent sends the content process) and
`fingerprint/screen-window/popup-position` (`nsWindowWatcher`, the position of a popup).
A popup that names ONLY `left` (`window.open(url, 'p', 'width=500,height=400,left=137')`, `test_a_popup_naming_only_left_..`): the
hook (`StealthPlacePopupAtDefault`, `fingerprint/screen-window/popup-position`) fills in only the coordinate the page did not give, so
`screenX` is the 137 the page asked for (the opener's CSS-to-desktop scale is 1.0 here, no second conversion) and `screenY` is the
declared default position, 4 (9 under the second frame); the frame relations are the same as for a popup with no position at all.
Negative control, in the same test: the same page in a launch declared with a SECOND frame that no runner has (border 6, popup UI 53). The popup reads that one
(outer - inner = 12 x 59, mozInnerScreen the position plus 6 and 53) and none of the first declaration's numbers; the two readings DIFFER in the frame and are EQUAL in the
position. The engine off is not the control: the declared frame is the one of a retail Windows window at scale 1.0, so on a Windows runner the host's own popup has the very
same frame (measured: 16 x 80 with the engine off) and the test could not tell a hook that answers from one that does not.
A popup that names ONLY `left` (`window.open(url, 'p', 'width=500,height=400,left=137')`, `test_a_popup_naming_only_left_..`): `screenX` is the 137 the page asked for (the
opener's CSS-to-desktop scale is 1.0 here, no second conversion) and `screenY` is the unpositioned popup's, 4; the frame relations are the same as for a popup with no position
at all.
Why a page reads it: `outerWidth - innerWidth`, `screenX` and `mozInnerScreenX/Y` are one line each, and a popup whose
frame is not a Windows frame is a browser that does not run on Windows. Linux and Windows run the same assertions: the
@@ -32,35 +33,36 @@ declaration, not the host, is what is read.
from __future__ import annotations
import pytest
from _popup_geometry import (OTHER_BORDER, OTHER_FRAME, OTHER_POPUP_UI, OTHER_POSITION, frame_extra, frame_of_the_declaration,
read_popup)
from _popup_geometry import OTHER_BORDER, OTHER_FRAME, OTHER_POPUP_UI, frame_extra, read_popup
from test_the_maximized_window_frames_and_popups_read_retail_e2e import RETAIL_POPUPS
pytestmark = pytest.mark.e2e
#: Retail's unpositioned popup at scale 1.0 (round 5): the case this file pins (``_popup_geometry.PIN``).
RETAIL = RETAIL_POPUPS["1920x1080-dpr1.0"]["popup"]
FRAME = (RETAIL["ow"] - RETAIL["iw"], RETAIL["oh"] - RETAIL["ih"])
BORDER = FRAME[0] // 2
POPUP_UI = FRAME[1] - BORDER
POSITION = RETAIL["sx"]
def test_a_popup_is_its_inner_size_plus_the_declared_frame(firefox_binary):
frame = frame_of_the_declaration()
declared = (2 * frame.border, frame.popup_ui + frame.border)
def has_the_frame(reading):
p = reading["popup"]
return (p["ow"] - p["iw"], p["oh"] - p["ih"]) == declared
return (p["ow"] - p["iw"], p["oh"] - p["ih"]) == FRAME
on = read_popup(firefox_binary, ready=has_the_frame)["popup"]
assert (on["ow"] - on["iw"], on["oh"] - on["ih"]) == declared, (
"the popup reads outer %dx%d for inner %dx%d: the frame is %r, the declaration is %r"
% (on["ow"], on["oh"], on["iw"], on["ih"], (on["ow"] - on["iw"], on["oh"] - on["ih"]), declared))
assert (on["sx"], on["sy"]) == (frame.popup_position, frame.popup_position), (
"a popup that names no position reads screen %r, the declared default is %d" % ((on["sx"], on["sy"]),
frame.popup_position))
assert on["mx"] == pytest.approx(on["sx"] + frame.border, abs=0.01), (
"mozInnerScreenX %r is not screenX %r plus the border %d" % (on["mx"], on["sx"], frame.border))
assert on["my"] == pytest.approx(on["sy"] + frame.popup_ui, abs=0.01), (
"mozInnerScreenY %r is not screenY %r plus the popup UI %d" % (on["my"], on["sy"], frame.popup_ui))
assert (on["ow"] - on["iw"], on["oh"] - on["ih"]) == FRAME, (
"the popup reads outer %dx%d for inner %dx%d: the frame is %r, retail reads %r"
% (on["ow"], on["oh"], on["iw"], on["ih"], (on["ow"] - on["iw"], on["oh"] - on["ih"]), FRAME))
assert (on["sx"], on["sy"]) == (RETAIL["sx"], RETAIL["sy"]), (
"a popup that names no position reads screen %r, retail reads %r" % ((on["sx"], on["sy"]), (RETAIL["sx"], RETAIL["sy"])))
assert (on["mx"], on["my"]) == (RETAIL["mx"], RETAIL["my"]), (
"the popup reads mozInnerScreen %r, retail reads %r" % ((on["mx"], on["my"]), (RETAIL["mx"], RETAIL["my"])))
# The control: a launch declared with another frame reads that one, and none of the first declaration's relations.
# The control: a launch declared with another frame reads that one, and none of the first declaration's relations; the position is the same.
other_declared = frame_extra(OTHER_BORDER, OTHER_POPUP_UI)
assert other_declared != declared
assert other_declared != FRAME
def has_the_other_frame(reading):
p = reading["popup"]
@@ -70,39 +72,36 @@ def test_a_popup_is_its_inner_size_plus_the_declared_frame(firefox_binary):
assert (other["ow"] - other["iw"], other["oh"] - other["ih"]) == other_declared, (
"declared with another frame the popup reads outer %dx%d for inner %dx%d: the frame is %r, the second declaration is %r"
% (other["ow"], other["oh"], other["iw"], other["ih"], (other["ow"] - other["iw"], other["oh"] - other["ih"]), other_declared))
assert (other["sx"], other["sy"]) == (OTHER_POSITION, OTHER_POSITION), (
"declared with another default position the popup reads screen %r, the second declaration is %d" % ((other["sx"], other["sy"]), OTHER_POSITION))
assert other["mx"] == pytest.approx(other["sx"] + OTHER_BORDER, abs=0.01)
assert other["my"] == pytest.approx(other["sy"] + OTHER_POPUP_UI, abs=0.01)
assert (other["sx"], other["sy"]) == (POSITION, POSITION), (
"declared with another frame the popup reads screen %r: the position of an unpositioned popup is Firefox's own, %d, under any frame"
% ((other["sx"], other["sy"]), POSITION))
assert other["mx"] == pytest.approx(POSITION + OTHER_BORDER, abs=0.01)
assert other["my"] == pytest.approx(POSITION + OTHER_POPUP_UI, abs=0.01)
assert (other["ow"] - other["iw"], other["oh"] - other["ih"]) != (on["ow"] - on["iw"], on["oh"] - on["ih"]), (
"the two declared frames read the same frame: the declaration decides nothing")
assert (other["sx"], other["sy"]) != (on["sx"], on["sy"]) and other["my"] - other["sy"] != on["my"] - on["sy"], (
"the two declared frames read the same position or content origin: %r vs %r" % (other, on))
assert other["my"] - other["sy"] != on["my"] - on["sy"], "the two declared frames read the same content origin: %r vs %r" % (other, on)
LEFT = 137
def test_a_popup_naming_only_left_reads_that_x_and_the_declared_default_y(firefox_binary):
frame = frame_of_the_declaration()
def test_a_popup_naming_only_left_reads_that_x_and_the_unpositioned_y(firefox_binary):
features = "width=500,height=400,left=%d" % LEFT
declared = (2 * frame.border, frame.popup_ui + frame.border)
def has_the_frame(reading):
p = reading["popup"]
return (p["ow"] - p["iw"], p["oh"] - p["ih"]) == declared
return (p["ow"] - p["iw"], p["oh"] - p["ih"]) == FRAME
on = read_popup(firefox_binary, ready=has_the_frame, features=features)["popup"]
assert (on["ow"] - on["iw"], on["oh"] - on["ih"]) == declared, (
"the popup reads outer %dx%d for inner %dx%d: the frame is %r, the declaration is %r"
% (on["ow"], on["oh"], on["iw"], on["ih"], (on["ow"] - on["iw"], on["oh"] - on["ih"]), declared))
assert (on["ow"] - on["iw"], on["oh"] - on["ih"]) == FRAME, (
"the popup reads outer %dx%d for inner %dx%d: the frame is %r, retail reads %r"
% (on["ow"], on["oh"], on["iw"], on["ih"], (on["ow"] - on["iw"], on["oh"] - on["ih"]), FRAME))
assert on["sx"] == LEFT, "a popup that names left=%d reads screenX %r: the page's own x is lost" % (LEFT, on["sx"])
assert on["sy"] == frame.popup_position, (
"a popup that names no top reads screenY %r, the declared default is %d" % (on["sy"], frame.popup_position))
assert on["mx"] == pytest.approx(on["sx"] + frame.border, abs=0.01)
assert on["my"] == pytest.approx(on["sy"] + frame.popup_ui, abs=0.01)
assert on["sy"] == POSITION, "a popup that names no top reads screenY %r, an unpositioned popup reads %d" % (on["sy"], POSITION)
assert on["mx"] == pytest.approx(on["sx"] + BORDER, abs=0.01)
assert on["my"] == pytest.approx(on["sy"] + POPUP_UI, abs=0.01)
# The control: a launch declared with a second frame keeps the page's x and reads the second default for y.
# The control: a launch declared with a second frame keeps the page's x and the same y.
other_declared = frame_extra(OTHER_BORDER, OTHER_POPUP_UI)
def has_the_other_frame(reading):
@@ -112,9 +111,6 @@ def test_a_popup_naming_only_left_reads_that_x_and_the_declared_default_y(firefo
other = read_popup(firefox_binary, extra_prefs=OTHER_FRAME, ready=has_the_other_frame, features=features)["popup"]
assert (other["ow"] - other["iw"], other["oh"] - other["ih"]) == other_declared
assert other["sx"] == LEFT, "declared with another frame the popup reads screenX %r, the page asked for %d" % (other["sx"], LEFT)
assert other["sy"] == OTHER_POSITION, (
"declared with another default position the popup reads screenY %r, the second declaration is %d" % (other["sy"], OTHER_POSITION))
assert other["sy"] == POSITION, "declared with another frame the popup reads screenY %r, Firefox's own is %d" % (other["sy"], POSITION)
assert other["mx"] == pytest.approx(LEFT + OTHER_BORDER, abs=0.01)
assert other["my"] == pytest.approx(OTHER_POSITION + OTHER_POPUP_UI, abs=0.01)
assert other["sy"] != on["sy"] and other["sx"] == on["sx"], (
"the declaration decides y alone when the page names x: %r vs %r" % (other, on))
assert other["my"] == pytest.approx(POSITION + OTHER_POPUP_UI, abs=0.01)