Compare commits
82
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d469820b8e | ||
|
|
1c2fdca4ce | ||
|
|
219b6f6cd0 | ||
|
|
54efe947e1 | ||
|
|
427e56ac90 | ||
|
|
5abb307e56 | ||
|
|
7568572532 | ||
|
|
246c6f1544 | ||
|
|
6998d0bef6 | ||
|
|
dc70c3374b | ||
|
|
be516fe595 | ||
|
|
39698aedc6 | ||
|
|
d4cb981523 | ||
|
|
ac24330d0a | ||
|
|
24d71ac096 | ||
|
|
040d5cc15a | ||
|
|
d9a7d86968 | ||
|
|
44e8a7a376 | ||
|
|
6ea6cb9f3e | ||
|
|
bde0dc8b84 | ||
|
|
45e2548933 | ||
|
|
c2fa042d3f | ||
|
|
bb7c69b9e7 | ||
|
|
87daa6ef25 | ||
|
|
3985a88a4d | ||
|
|
f62efa2e8a | ||
|
|
a48ab8e837 | ||
|
|
b84bcde68b | ||
|
|
bef8bf7a92 | ||
|
|
dfa9aff5f6 | ||
|
|
e28069e712 | ||
|
|
40841aa857 | ||
|
|
a7f57ac4f0 | ||
|
|
27f0501cea | ||
|
|
585acedecc | ||
|
|
22e89ddbf3 | ||
|
|
2e9cdafbaa | ||
|
|
ebfaf30552 | ||
|
|
5663ca7ec1 | ||
|
|
3cc83a9820 | ||
|
|
06cb753d9c | ||
|
|
05149cb8c8 | ||
|
|
95bcd4d1c3 | ||
|
|
4afd02e305 | ||
|
|
570d9997ad | ||
|
|
0eff758320 | ||
|
|
cbb4a9982e | ||
|
|
55131f98b0 | ||
|
|
584c43cd35 | ||
|
|
6bb7df2ba3 | ||
|
|
71ddb27003 | ||
|
|
1509415d7a | ||
|
|
0072328944 | ||
|
|
197a3e4f49 | ||
|
|
f0b83b089c | ||
|
|
b165ac7e90 | ||
|
|
c1c0a84214 | ||
|
|
674ba82359 | ||
|
|
7ee01460c3 | ||
|
|
476da7c8d0 | ||
|
|
eb052e7439 | ||
|
|
c8b3b086fa | ||
|
|
5e4adfbcfa | ||
|
|
f73432d5ed | ||
|
|
03dde48c06 | ||
|
|
e9d4f95d54 | ||
|
|
728bcbe5d7 | ||
|
|
633b72bbcf | ||
|
|
516edfc15c | ||
|
|
a3e647bf2f | ||
|
|
fee389c299 | ||
|
|
db40654e73 | ||
|
|
1c8c1bcbe7 | ||
|
|
8805cb8978 | ||
|
|
185c386b79 | ||
|
|
bee003ef27 | ||
|
|
4ba9c5e4e4 | ||
|
|
365f7da7e3 | ||
|
|
b60a2a89c5 | ||
|
|
27374a6a8f | ||
|
|
d667c6b55d | ||
|
|
2df8b8f773 |
No files matched your search
@@ -34,3 +34,9 @@ tests/data/known_mozilla_defects/** -text
|
||||
|
||||
# The ready security state is hashed byte for byte against ci/security-state.pin.json.
|
||||
ci/security-state/** -text
|
||||
|
||||
# The page of the password-mask e2e is the same bytes as the page of the retail capture (its sha256 is checked), so no checkout may change its line endings.
|
||||
tests/data/password_mask_page.html -text
|
||||
|
||||
# The A/B verdict of candidate run 47107160488 (Linux) is the input of the host only rows of ci/ab-host-expected.json: its sha256 is in each row's source, so no checkout converts its line endings.
|
||||
tests/data/ab_host_linux/** -text
|
||||
+1753
-1
File diff suppressed because it is too large.
Load diff
@@ -744,6 +744,246 @@
|
||||
"published": 84.66666412353516,
|
||||
"candidate": 72.66666412353516,
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: window.mozInnerScreenY, the screen Y of the content's top in CSS px (the bar above the content)."
|
||||
},
|
||||
{
|
||||
"id": "linux-seed0-relaunch.surface.systemColors.Highlight",
|
||||
"os": "linux",
|
||||
"seed": 0,
|
||||
"dpr": 1.0,
|
||||
"leaf": "relaunch.surface.systemColors.Highlight",
|
||||
"published": "rgb(0, 120, 215)",
|
||||
"candidate": "rgb(0, 120, 212)",
|
||||
"reason": "Windows 11 24H2/25H2 GetSysColor(COLOR_HIGHLIGHT) is #0078D4 (nsLookAndFeel.cpp:188); retail Firefox 159 reads rgb(0, 120, 212) on build 26100 (RetailCaptures captures/firefox-159.0/windows-server-2025/syscolors/2026-12-01, xul.dll fec21f3e…) and on client build 26200 (captures/firefox-159.0/windows-11-arm/syscolors/2026-12-02, run 46828919060, xul.dll 204f37aa…); core #376 declared it; only build 20348 reads 215"
|
||||
},
|
||||
{
|
||||
"id": "linux-seed0-relaunch.surface.systemColors.SelectedItem",
|
||||
"os": "linux",
|
||||
"seed": 0,
|
||||
"dpr": 1.0,
|
||||
"leaf": "relaunch.surface.systemColors.SelectedItem",
|
||||
"published": "rgb(0, 120, 215)",
|
||||
"candidate": "rgb(0, 120, 212)",
|
||||
"reason": "Windows 11 24H2/25H2 GetSysColor(COLOR_HIGHLIGHT) is #0078D4 (nsLookAndFeel.cpp:188); retail Firefox 159 reads rgb(0, 120, 212) on build 26100 (RetailCaptures captures/firefox-159.0/windows-server-2025/syscolors/2026-12-01, xul.dll fec21f3e…) and on client build 26200 (captures/firefox-159.0/windows-11-arm/syscolors/2026-12-02, run 46828919060, xul.dll 204f37aa…); core #376 declared it; only build 20348 reads 215"
|
||||
},
|
||||
{
|
||||
"id": "linux-seed0-surface.systemColors.Highlight",
|
||||
"os": "linux",
|
||||
"seed": 0,
|
||||
"dpr": 1.0,
|
||||
"leaf": "surface.systemColors.Highlight",
|
||||
"published": "rgb(0, 120, 215)",
|
||||
"candidate": "rgb(0, 120, 212)",
|
||||
"reason": "Windows 11 24H2/25H2 GetSysColor(COLOR_HIGHLIGHT) is #0078D4 (nsLookAndFeel.cpp:188); retail Firefox 159 reads rgb(0, 120, 212) on build 26100 (RetailCaptures captures/firefox-159.0/windows-server-2025/syscolors/2026-12-01, xul.dll fec21f3e…) and on client build 26200 (captures/firefox-159.0/windows-11-arm/syscolors/2026-12-02, run 46828919060, xul.dll 204f37aa…); core #376 declared it; only build 20348 reads 215"
|
||||
},
|
||||
{
|
||||
"id": "linux-seed0-surface.systemColors.SelectedItem",
|
||||
"os": "linux",
|
||||
"seed": 0,
|
||||
"dpr": 1.0,
|
||||
"leaf": "surface.systemColors.SelectedItem",
|
||||
"published": "rgb(0, 120, 215)",
|
||||
"candidate": "rgb(0, 120, 212)",
|
||||
"reason": "Windows 11 24H2/25H2 GetSysColor(COLOR_HIGHLIGHT) is #0078D4 (nsLookAndFeel.cpp:188); retail Firefox 159 reads rgb(0, 120, 212) on build 26100 (RetailCaptures captures/firefox-159.0/windows-server-2025/syscolors/2026-12-01, xul.dll fec21f3e…) and on client build 26200 (captures/firefox-159.0/windows-11-arm/syscolors/2026-12-02, run 46828919060, xul.dll 204f37aa…); core #376 declared it; only build 20348 reads 215"
|
||||
},
|
||||
{
|
||||
"id": "linux-seed2-surface.systemColors.Highlight",
|
||||
"os": "linux",
|
||||
"seed": 2,
|
||||
"dpr": 1.0,
|
||||
"leaf": "surface.systemColors.Highlight",
|
||||
"published": "rgb(0, 120, 215)",
|
||||
"candidate": "rgb(0, 120, 212)",
|
||||
"reason": "Windows 11 24H2/25H2 GetSysColor(COLOR_HIGHLIGHT) is #0078D4 (nsLookAndFeel.cpp:188); retail Firefox 159 reads rgb(0, 120, 212) on build 26100 (RetailCaptures captures/firefox-159.0/windows-server-2025/syscolors/2026-12-01, xul.dll fec21f3e…) and on client build 26200 (captures/firefox-159.0/windows-11-arm/syscolors/2026-12-02, run 46828919060, xul.dll 204f37aa…); core #376 declared it; only build 20348 reads 215"
|
||||
},
|
||||
{
|
||||
"id": "linux-seed2-surface.systemColors.SelectedItem",
|
||||
"os": "linux",
|
||||
"seed": 2,
|
||||
"dpr": 1.0,
|
||||
"leaf": "surface.systemColors.SelectedItem",
|
||||
"published": "rgb(0, 120, 215)",
|
||||
"candidate": "rgb(0, 120, 212)",
|
||||
"reason": "Windows 11 24H2/25H2 GetSysColor(COLOR_HIGHLIGHT) is #0078D4 (nsLookAndFeel.cpp:188); retail Firefox 159 reads rgb(0, 120, 212) on build 26100 (RetailCaptures captures/firefox-159.0/windows-server-2025/syscolors/2026-12-01, xul.dll fec21f3e…) and on client build 26200 (captures/firefox-159.0/windows-11-arm/syscolors/2026-12-02, run 46828919060, xul.dll 204f37aa…); core #376 declared it; only build 20348 reads 215"
|
||||
},
|
||||
{
|
||||
"id": "linux-seed4-surface.systemColors.Highlight",
|
||||
"os": "linux",
|
||||
"seed": 4,
|
||||
"dpr": 1.0,
|
||||
"leaf": "surface.systemColors.Highlight",
|
||||
"published": "rgb(0, 120, 215)",
|
||||
"candidate": "rgb(0, 120, 212)",
|
||||
"reason": "Windows 11 24H2/25H2 GetSysColor(COLOR_HIGHLIGHT) is #0078D4 (nsLookAndFeel.cpp:188); retail Firefox 159 reads rgb(0, 120, 212) on build 26100 (RetailCaptures captures/firefox-159.0/windows-server-2025/syscolors/2026-12-01, xul.dll fec21f3e…) and on client build 26200 (captures/firefox-159.0/windows-11-arm/syscolors/2026-12-02, run 46828919060, xul.dll 204f37aa…); core #376 declared it; only build 20348 reads 215"
|
||||
},
|
||||
{
|
||||
"id": "linux-seed4-surface.systemColors.SelectedItem",
|
||||
"os": "linux",
|
||||
"seed": 4,
|
||||
"dpr": 1.0,
|
||||
"leaf": "surface.systemColors.SelectedItem",
|
||||
"published": "rgb(0, 120, 215)",
|
||||
"candidate": "rgb(0, 120, 212)",
|
||||
"reason": "Windows 11 24H2/25H2 GetSysColor(COLOR_HIGHLIGHT) is #0078D4 (nsLookAndFeel.cpp:188); retail Firefox 159 reads rgb(0, 120, 212) on build 26100 (RetailCaptures captures/firefox-159.0/windows-server-2025/syscolors/2026-12-01, xul.dll fec21f3e…) and on client build 26200 (captures/firefox-159.0/windows-11-arm/syscolors/2026-12-02, run 46828919060, xul.dll 204f37aa…); core #376 declared it; only build 20348 reads 215"
|
||||
},
|
||||
{
|
||||
"id": "linux-seed6-surface.systemColors.Highlight",
|
||||
"os": "linux",
|
||||
"seed": 6,
|
||||
"dpr": 1.25,
|
||||
"leaf": "surface.systemColors.Highlight",
|
||||
"published": "rgb(0, 120, 215)",
|
||||
"candidate": "rgb(0, 120, 212)",
|
||||
"reason": "Windows 11 24H2/25H2 GetSysColor(COLOR_HIGHLIGHT) is #0078D4 (nsLookAndFeel.cpp:188); retail Firefox 159 reads rgb(0, 120, 212) on build 26100 (RetailCaptures captures/firefox-159.0/windows-server-2025/syscolors/2026-12-01, xul.dll fec21f3e…) and on client build 26200 (captures/firefox-159.0/windows-11-arm/syscolors/2026-12-02, run 46828919060, xul.dll 204f37aa…); core #376 declared it; only build 20348 reads 215"
|
||||
},
|
||||
{
|
||||
"id": "linux-seed6-surface.systemColors.SelectedItem",
|
||||
"os": "linux",
|
||||
"seed": 6,
|
||||
"dpr": 1.25,
|
||||
"leaf": "surface.systemColors.SelectedItem",
|
||||
"published": "rgb(0, 120, 215)",
|
||||
"candidate": "rgb(0, 120, 212)",
|
||||
"reason": "Windows 11 24H2/25H2 GetSysColor(COLOR_HIGHLIGHT) is #0078D4 (nsLookAndFeel.cpp:188); retail Firefox 159 reads rgb(0, 120, 212) on build 26100 (RetailCaptures captures/firefox-159.0/windows-server-2025/syscolors/2026-12-01, xul.dll fec21f3e…) and on client build 26200 (captures/firefox-159.0/windows-11-arm/syscolors/2026-12-02, run 46828919060, xul.dll 204f37aa…); core #376 declared it; only build 20348 reads 215"
|
||||
},
|
||||
{
|
||||
"id": "linux-seed63-surface.systemColors.Highlight",
|
||||
"os": "linux",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "surface.systemColors.Highlight",
|
||||
"published": "rgb(0, 120, 215)",
|
||||
"candidate": "rgb(0, 120, 212)",
|
||||
"reason": "Windows 11 24H2/25H2 GetSysColor(COLOR_HIGHLIGHT) is #0078D4 (nsLookAndFeel.cpp:188); retail Firefox 159 reads rgb(0, 120, 212) on build 26100 (RetailCaptures captures/firefox-159.0/windows-server-2025/syscolors/2026-12-01, xul.dll fec21f3e…) and on client build 26200 (captures/firefox-159.0/windows-11-arm/syscolors/2026-12-02, run 46828919060, xul.dll 204f37aa…); core #376 declared it; only build 20348 reads 215"
|
||||
},
|
||||
{
|
||||
"id": "linux-seed63-surface.systemColors.SelectedItem",
|
||||
"os": "linux",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "surface.systemColors.SelectedItem",
|
||||
"published": "rgb(0, 120, 215)",
|
||||
"candidate": "rgb(0, 120, 212)",
|
||||
"reason": "Windows 11 24H2/25H2 GetSysColor(COLOR_HIGHLIGHT) is #0078D4 (nsLookAndFeel.cpp:188); retail Firefox 159 reads rgb(0, 120, 212) on build 26100 (RetailCaptures captures/firefox-159.0/windows-server-2025/syscolors/2026-12-01, xul.dll fec21f3e…) and on client build 26200 (captures/firefox-159.0/windows-11-arm/syscolors/2026-12-02, run 46828919060, xul.dll 204f37aa…); core #376 declared it; only build 20348 reads 215"
|
||||
},
|
||||
{
|
||||
"id": "windows-seed0-relaunch.surface.systemColors.Highlight",
|
||||
"os": "windows",
|
||||
"seed": 0,
|
||||
"dpr": 1.0,
|
||||
"leaf": "relaunch.surface.systemColors.Highlight",
|
||||
"published": "rgb(0, 120, 215)",
|
||||
"candidate": "rgb(0, 120, 212)",
|
||||
"reason": "Windows 11 24H2/25H2 GetSysColor(COLOR_HIGHLIGHT) is #0078D4 (nsLookAndFeel.cpp:188); retail Firefox 159 reads rgb(0, 120, 212) on build 26100 (RetailCaptures captures/firefox-159.0/windows-server-2025/syscolors/2026-12-01, xul.dll fec21f3e…) and on client build 26200 (captures/firefox-159.0/windows-11-arm/syscolors/2026-12-02, run 46828919060, xul.dll 204f37aa…); core #376 declared it; only build 20348 reads 215"
|
||||
},
|
||||
{
|
||||
"id": "windows-seed0-relaunch.surface.systemColors.SelectedItem",
|
||||
"os": "windows",
|
||||
"seed": 0,
|
||||
"dpr": 1.0,
|
||||
"leaf": "relaunch.surface.systemColors.SelectedItem",
|
||||
"published": "rgb(0, 120, 215)",
|
||||
"candidate": "rgb(0, 120, 212)",
|
||||
"reason": "Windows 11 24H2/25H2 GetSysColor(COLOR_HIGHLIGHT) is #0078D4 (nsLookAndFeel.cpp:188); retail Firefox 159 reads rgb(0, 120, 212) on build 26100 (RetailCaptures captures/firefox-159.0/windows-server-2025/syscolors/2026-12-01, xul.dll fec21f3e…) and on client build 26200 (captures/firefox-159.0/windows-11-arm/syscolors/2026-12-02, run 46828919060, xul.dll 204f37aa…); core #376 declared it; only build 20348 reads 215"
|
||||
},
|
||||
{
|
||||
"id": "windows-seed0-surface.systemColors.Highlight",
|
||||
"os": "windows",
|
||||
"seed": 0,
|
||||
"dpr": 1.0,
|
||||
"leaf": "surface.systemColors.Highlight",
|
||||
"published": "rgb(0, 120, 215)",
|
||||
"candidate": "rgb(0, 120, 212)",
|
||||
"reason": "Windows 11 24H2/25H2 GetSysColor(COLOR_HIGHLIGHT) is #0078D4 (nsLookAndFeel.cpp:188); retail Firefox 159 reads rgb(0, 120, 212) on build 26100 (RetailCaptures captures/firefox-159.0/windows-server-2025/syscolors/2026-12-01, xul.dll fec21f3e…) and on client build 26200 (captures/firefox-159.0/windows-11-arm/syscolors/2026-12-02, run 46828919060, xul.dll 204f37aa…); core #376 declared it; only build 20348 reads 215"
|
||||
},
|
||||
{
|
||||
"id": "windows-seed0-surface.systemColors.SelectedItem",
|
||||
"os": "windows",
|
||||
"seed": 0,
|
||||
"dpr": 1.0,
|
||||
"leaf": "surface.systemColors.SelectedItem",
|
||||
"published": "rgb(0, 120, 215)",
|
||||
"candidate": "rgb(0, 120, 212)",
|
||||
"reason": "Windows 11 24H2/25H2 GetSysColor(COLOR_HIGHLIGHT) is #0078D4 (nsLookAndFeel.cpp:188); retail Firefox 159 reads rgb(0, 120, 212) on build 26100 (RetailCaptures captures/firefox-159.0/windows-server-2025/syscolors/2026-12-01, xul.dll fec21f3e…) and on client build 26200 (captures/firefox-159.0/windows-11-arm/syscolors/2026-12-02, run 46828919060, xul.dll 204f37aa…); core #376 declared it; only build 20348 reads 215"
|
||||
},
|
||||
{
|
||||
"id": "windows-seed2-surface.systemColors.Highlight",
|
||||
"os": "windows",
|
||||
"seed": 2,
|
||||
"dpr": 1.0,
|
||||
"leaf": "surface.systemColors.Highlight",
|
||||
"published": "rgb(0, 120, 215)",
|
||||
"candidate": "rgb(0, 120, 212)",
|
||||
"reason": "Windows 11 24H2/25H2 GetSysColor(COLOR_HIGHLIGHT) is #0078D4 (nsLookAndFeel.cpp:188); retail Firefox 159 reads rgb(0, 120, 212) on build 26100 (RetailCaptures captures/firefox-159.0/windows-server-2025/syscolors/2026-12-01, xul.dll fec21f3e…) and on client build 26200 (captures/firefox-159.0/windows-11-arm/syscolors/2026-12-02, run 46828919060, xul.dll 204f37aa…); core #376 declared it; only build 20348 reads 215"
|
||||
},
|
||||
{
|
||||
"id": "windows-seed2-surface.systemColors.SelectedItem",
|
||||
"os": "windows",
|
||||
"seed": 2,
|
||||
"dpr": 1.0,
|
||||
"leaf": "surface.systemColors.SelectedItem",
|
||||
"published": "rgb(0, 120, 215)",
|
||||
"candidate": "rgb(0, 120, 212)",
|
||||
"reason": "Windows 11 24H2/25H2 GetSysColor(COLOR_HIGHLIGHT) is #0078D4 (nsLookAndFeel.cpp:188); retail Firefox 159 reads rgb(0, 120, 212) on build 26100 (RetailCaptures captures/firefox-159.0/windows-server-2025/syscolors/2026-12-01, xul.dll fec21f3e…) and on client build 26200 (captures/firefox-159.0/windows-11-arm/syscolors/2026-12-02, run 46828919060, xul.dll 204f37aa…); core #376 declared it; only build 20348 reads 215"
|
||||
},
|
||||
{
|
||||
"id": "windows-seed4-surface.systemColors.Highlight",
|
||||
"os": "windows",
|
||||
"seed": 4,
|
||||
"dpr": 1.0,
|
||||
"leaf": "surface.systemColors.Highlight",
|
||||
"published": "rgb(0, 120, 215)",
|
||||
"candidate": "rgb(0, 120, 212)",
|
||||
"reason": "Windows 11 24H2/25H2 GetSysColor(COLOR_HIGHLIGHT) is #0078D4 (nsLookAndFeel.cpp:188); retail Firefox 159 reads rgb(0, 120, 212) on build 26100 (RetailCaptures captures/firefox-159.0/windows-server-2025/syscolors/2026-12-01, xul.dll fec21f3e…) and on client build 26200 (captures/firefox-159.0/windows-11-arm/syscolors/2026-12-02, run 46828919060, xul.dll 204f37aa…); core #376 declared it; only build 20348 reads 215"
|
||||
},
|
||||
{
|
||||
"id": "windows-seed4-surface.systemColors.SelectedItem",
|
||||
"os": "windows",
|
||||
"seed": 4,
|
||||
"dpr": 1.0,
|
||||
"leaf": "surface.systemColors.SelectedItem",
|
||||
"published": "rgb(0, 120, 215)",
|
||||
"candidate": "rgb(0, 120, 212)",
|
||||
"reason": "Windows 11 24H2/25H2 GetSysColor(COLOR_HIGHLIGHT) is #0078D4 (nsLookAndFeel.cpp:188); retail Firefox 159 reads rgb(0, 120, 212) on build 26100 (RetailCaptures captures/firefox-159.0/windows-server-2025/syscolors/2026-12-01, xul.dll fec21f3e…) and on client build 26200 (captures/firefox-159.0/windows-11-arm/syscolors/2026-12-02, run 46828919060, xul.dll 204f37aa…); core #376 declared it; only build 20348 reads 215"
|
||||
},
|
||||
{
|
||||
"id": "windows-seed6-surface.systemColors.Highlight",
|
||||
"os": "windows",
|
||||
"seed": 6,
|
||||
"dpr": 1.25,
|
||||
"leaf": "surface.systemColors.Highlight",
|
||||
"published": "rgb(0, 120, 215)",
|
||||
"candidate": "rgb(0, 120, 212)",
|
||||
"reason": "Windows 11 24H2/25H2 GetSysColor(COLOR_HIGHLIGHT) is #0078D4 (nsLookAndFeel.cpp:188); retail Firefox 159 reads rgb(0, 120, 212) on build 26100 (RetailCaptures captures/firefox-159.0/windows-server-2025/syscolors/2026-12-01, xul.dll fec21f3e…) and on client build 26200 (captures/firefox-159.0/windows-11-arm/syscolors/2026-12-02, run 46828919060, xul.dll 204f37aa…); core #376 declared it; only build 20348 reads 215"
|
||||
},
|
||||
{
|
||||
"id": "windows-seed6-surface.systemColors.SelectedItem",
|
||||
"os": "windows",
|
||||
"seed": 6,
|
||||
"dpr": 1.25,
|
||||
"leaf": "surface.systemColors.SelectedItem",
|
||||
"published": "rgb(0, 120, 215)",
|
||||
"candidate": "rgb(0, 120, 212)",
|
||||
"reason": "Windows 11 24H2/25H2 GetSysColor(COLOR_HIGHLIGHT) is #0078D4 (nsLookAndFeel.cpp:188); retail Firefox 159 reads rgb(0, 120, 212) on build 26100 (RetailCaptures captures/firefox-159.0/windows-server-2025/syscolors/2026-12-01, xul.dll fec21f3e…) and on client build 26200 (captures/firefox-159.0/windows-11-arm/syscolors/2026-12-02, run 46828919060, xul.dll 204f37aa…); core #376 declared it; only build 20348 reads 215"
|
||||
},
|
||||
{
|
||||
"id": "windows-seed63-surface.systemColors.Highlight",
|
||||
"os": "windows",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "surface.systemColors.Highlight",
|
||||
"published": "rgb(0, 120, 215)",
|
||||
"candidate": "rgb(0, 120, 212)",
|
||||
"reason": "Windows 11 24H2/25H2 GetSysColor(COLOR_HIGHLIGHT) is #0078D4 (nsLookAndFeel.cpp:188); retail Firefox 159 reads rgb(0, 120, 212) on build 26100 (RetailCaptures captures/firefox-159.0/windows-server-2025/syscolors/2026-12-01, xul.dll fec21f3e…) and on client build 26200 (captures/firefox-159.0/windows-11-arm/syscolors/2026-12-02, run 46828919060, xul.dll 204f37aa…); core #376 declared it; only build 20348 reads 215"
|
||||
},
|
||||
{
|
||||
"id": "windows-seed63-surface.systemColors.SelectedItem",
|
||||
"os": "windows",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "surface.systemColors.SelectedItem",
|
||||
"published": "rgb(0, 120, 215)",
|
||||
"candidate": "rgb(0, 120, 212)",
|
||||
"reason": "Windows 11 24H2/25H2 GetSysColor(COLOR_HIGHLIGHT) is #0078D4 (nsLookAndFeel.cpp:188); retail Firefox 159 reads rgb(0, 120, 212) on build 26100 (RetailCaptures captures/firefox-159.0/windows-server-2025/syscolors/2026-12-01, xul.dll fec21f3e…) and on client build 26200 (captures/firefox-159.0/windows-11-arm/syscolors/2026-12-02, run 46828919060, xul.dll 204f37aa…); core #376 declared it; only build 20348 reads 215"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -12,22 +12,22 @@
|
||||
{"id": "wrapper.unit.page", "giro": "G1", "os": ["linux", "windows"], "min_tests": 72, "exact": true, "tests": ["tests/test_a_download_finished_before_it_was_announced_is_finished.py", "tests/test_every_order_of_the_events_of_a_popup_gives_one_page_event.py", "tests/test_ci_drive_gate_goes_through_the_core.py", "tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py", "tests/test_a_new_page_waits_for_the_engine.py", "tests/test_page_number_follows_the_call.py", "tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py", "tests/test_no_event_of_any_family_is_lost_by_the_hand_over.py", "tests/test_the_hand_over_of_a_popup_holds_under_concurrency.py", "tests/test_a_page_closed_before_its_announcement_is_not_announced.py", "tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py"], "marker": "unit", "needs_root": false, "note": "72 = 44 + 3+9+5+1+10 of the popup hand-over (24 counted at the collection before; was 20 = 3+8+1+8 before 6200bc2). The page dispatcher's wait for Page.ready and what it hands over; the drive gate goes through the core (the engine waits for the session's road)."},
|
||||
{"id": "wrapper.e2e.compositing", "giro": "G2", "os": ["linux", "windows"], "min_tests": 9, "exact": true, "tests": ["tests/test_software_compositing_is_declared_e2e.py", "tests/test_a_screenshot_draws_the_text_of_the_bundled_fonts_as_the_content_does_e2e.py"], "marker": "e2e", "needs_root": false, "note": "The engine DECLARES software compositing on every machine (core: the compositing entries of zoom.stealth.gfx.feature_status carry the VM decision, and on Windows gfx.webrender.software=true, gfx.webrender.software.d3d11=false). 3 = (1) the compositor read from a privileged context is 'WebRender (Software)' on Windows and on Linux (windowUtils.layerManagerType of each window: Troubleshoot.snapshot().graphics throws on this engine, `ext is null`, so it is not the route); (2) the GPU process uses under 1.5 s of CPU on the fixed 10-scene loop of one browser (Windows runner: 0.32 s declared, 2.7-4.2 s not, runs 43652292533 and 43642744101; on Linux it is held to the bound if a GPU process exists); (3) the 86 keys of the page-bytes probe plus the canvas 2D scenes (drawImage scaled with smoothing off/low/medium/high, text with linear/radial/conic gradients) equal tests/data/page_bytes_<os>.json, PNGs on decoded pixels. EXPECTED RED on the core 64.71.0 (tests 1 and 2 on Windows). The reference of Windows holds the 75 stable keys and 6 of the 11 PNG keys of run 43652292533; the five other PNG keys and the new canvas keys, and all of Linux, are written from the first run on the engine of the reference (the failure of test 3 prints RECORD-BEGIN ... RECORD-END with the entries to merge): a reference that is not complete is red, never skipped. 9 = those 3 + the 6 families of tests/test_a_screenshot_draws_the_text_of_the_bundled_fonts_as_the_content_does_e2e.py (from firefox-66, engine_at_least): a screenshot draws the text of Arial, Times New Roman, Consolas and Segoe UI, with accents, the typographic apostrophe, the euro sign, Chinese, Arabic and Russian, and of MS PGothic (face 2 of msgothic5_32.ttc: Japanese and Latin) and NSimSun (face 1 of simsun.ttc: Chinese), two faces that are not the first of their collection, with the same bytes as the content process drew them in a canvas (an SVG image with a foreignObject of the same markup), cut from the same page.screenshot, on both systems and with no threshold. EXPECTED RED on every engine that rebuilds the text in the parent with another font than the bundle (Linux: fontconfig answers DejaVu Sans), and skipped, hence red here, on an engine older than firefox-66. It saves the screenshot, the two boxes and a result.json under RUNNER_TEMP/invpw-evidence.", "runner_image": {"windows": "windows-2022"}},
|
||||
{"id": "wrapper.e2e.fakeweb", "giro": "G2", "os": ["linux", "windows"], "min_tests": 7, "exact": true, "tests": ["tests/test_fakeweb_p2_e2e.py", "tests/test_fakeweb_p4_e2e.py"], "marker": "e2e", "needs_root": false, "note": "The fake web, offline: our browser on the hard pages (profile P2: a reused routed page reaches networkidle every time, also under a load of three other browsers; the other site is another process) and on the 17-step journey of a person (profile P4: every step as stock, and every page left only once its noise is done), each judged against what stock Firefox does, as tests/fakeweb/pages.json declares it. 7 = 3 + 4 (the last two: a `load` that takes 20 s is a step that succeeds, and a `load` that never comes ends in an error that names the wait and the page). Stock itself is held to that declaration, and compared with ours step by step, by scripts/run_fakeweb.py in .github/workflows/fakeweb.yml. Needs the candidate binary (STEALTHFOX_E2E_BINARY).", "stock_firefox": true, "extra_steps": ["fakeweb_profiles"]},
|
||||
{"id": "wrapper.e2e.stock_twin.dnd", "giro": "G2", "os": ["linux", "windows"], "min_tests": 4, "exact": true, "tests": ["tests/test_a_drag_from_the_top_into_a_frame_of_another_site_e2e.py"], "marker": "e2e", "needs_root": false, "note": "Split from the row wrapper.e2e.stock_twin, which ran past the 25-minute limit of a leg: one file, one leg. The twin of the real drag from the top into a frame of another site (4 scales): the same steps first on Playwright's own Firefox (stock_firefox), headed, driven by the stock Playwright client, and second on ours; the verdict is 'the same as the reference' (tests/_stock_twin.py). Each record keeps the page's and the chrome's devicePixelRatio and the real scale of the screen. The file is in no whole-suite row: the references are installed only for this row's legs.", "stock_firefox": true},
|
||||
{"id": "wrapper.e2e.stock_twin.dnd", "giro": "G2", "os": ["linux", "windows"], "min_tests": 8, "exact": true, "tests": ["tests/test_a_drag_from_the_top_into_a_frame_of_another_site_e2e.py", "tests/test_a_press_outside_an_open_datalist_list_ends_as_on_stock_e2e.py"], "marker": "e2e", "needs_root": false, "note": "Split from the row wrapper.e2e.stock_twin, which ran past the 25-minute limit of a leg: one leg. The twin of the real drag from the top into a frame of another site (4 scales): the same steps first on Playwright's own Firefox (stock_firefox), headed, driven by the stock Playwright client, and second on ours; the verdict is 'the same as the reference' (tests/_stock_twin.py). Each record keeps the page's and the chrome's devicePixelRatio and the real scale of the screen. The file is in no whole-suite row: the references are installed only for this row's legs. Second file: the twin of a press outside the open list of a datalist (4 scales): the list must be open in chrome on both before the press (else BROKEN CONTROL), and the events the page hears and the state of the list after must be the reference's (the leg took 2 minutes with one file).", "stock_firefox": true},
|
||||
{"id": "wrapper.e2e.stock_twin.select", "giro": "G2", "os": ["linux", "windows"], "min_tests": 4, "exact": true, "tests": ["tests/test_a_select_dropdown_opens_at_its_element_e2e.py"], "marker": "e2e", "needs_root": false, "note": "Split from the row wrapper.e2e.stock_twin, which ran past the 25-minute limit of a leg: one file, one leg. The twin of the select dropdown (4 scales), measured from chrome scope against RETAIL Firefox 159 driven by Marionette alone, headed (the leg sets INVPW_RETAIL_FIREFOX to its firefox.exe), the reference first and ours second; the verdict is 'the same as the reference' (tests/_stock_twin.py, tests/_retail_reference.py). Each record keeps the page's and the chrome's devicePixelRatio and the real scale of the screen. The file is in no whole-suite row: the references are installed only for this row's legs.", "stock_firefox": true},
|
||||
{"id": "wrapper.e2e.stock_twin.tooltip", "giro": "G2", "os": ["linux", "windows"], "min_tests": 4, "exact": true, "tests": ["tests/test_a_tooltip_opens_at_the_pointer_e2e.py"], "marker": "e2e", "needs_root": false, "note": "Split from the row wrapper.e2e.stock_twin, which ran past the 25-minute limit of a leg: one file, one leg. The twin of the tooltip (4 scales), measured from chrome scope against RETAIL Firefox 159 driven by Marionette alone, headed (the leg sets INVPW_RETAIL_FIREFOX to its firefox.exe), the reference first and ours second; the verdict is 'the same as the reference' (tests/_stock_twin.py, tests/_retail_reference.py). Each record keeps the page's and the chrome's devicePixelRatio and the real scale of the screen. The file is in no whole-suite row: the references are installed only for this row's legs.", "stock_firefox": true},
|
||||
{"id": "wrapper.e2e.stock_twin.intersection", "giro": "G2", "os": ["linux", "windows"], "min_tests": 8, "exact": true, "tests": ["tests/test_intersection_and_lazy_loading_in_a_frame_of_another_site_e2e.py"], "marker": "e2e", "needs_root": false, "note": "Split from the row wrapper.e2e.stock_twin, which ran past the 25-minute limit of a leg: one file, one leg. The twin of what the IntersectionObserver of a scrolled frame of another site reads (8 steps, 4 scales) and of when a lazy frame is requested (4 distances, 4 scales): the same steps first on Playwright's own Firefox (stock_firefox), headed, driven by the stock Playwright client, and second on ours; the verdict is 'the same as the reference' (tests/_stock_twin.py). Each record keeps the page's and the chrome's devicePixelRatio and the real scale of the screen. The file is in no whole-suite row: the references are installed only for this row's legs.", "stock_firefox": true},
|
||||
{"id": "wrapper.e2e.fontconfig", "giro": "G2", "os": ["linux"], "min_tests": 2, "exact": true, "tests": ["tests/test_the_parent_reads_the_bundle_from_fontconfig_s_cache_linux_e2e.py"], "marker": "e2e", "needs_root": false, "linux_only": "Fontconfig exists only on Linux: the parent of the engine shows <GRE>/fonts to it (FcConfigAppFontAddDir) to rebuild a font from a path and a face index. On Windows DirectWrite opens the file from its path, with no folder to scan and no cache to read, so this test has no Windows counterpart.", "note": "2 = (1) the stand-in that runs the engine under strace stays in the engine's place, as the core launches it (the leader of a process group of its own): a fake engine with a child, no browser; the process the launcher holds lives as long as the fake engine, and the group killed holds strace and the child (the stand-in that exec'd setsid forked and exited 0 at once: candidate 44161687675); (2) the warm launch of the parent reads the bundle from fontconfig's cache and does not scan it again (from firefox-66, engine_at_least). Two launches under strace with the same XDG_CACHE_HOME of the test, the first cold and the second warm: the cold parent opens every font file of <GRE>/fonts (the folder as the disk lists it) before any page and fontconfig writes its cache; the warm parent does not open every one of them, and it opens a *.cache-* file of fontconfig (a few files are opened to be used, so the verdict asks about the whole folder, as a scan does). Scan and drawing are told apart by position: only what the parent opens before the first page counts (the opens that draw are written as after_startup). Evidence in RUNNER_TEMP/invpw-evidence/fontconfig-cache: the interval and the number of opens of the bundle, the names of the files of the bundle each launch opened before the first page, the size of the cache file, the VmRSS of the parent after about:blank and after a page with every family, and a third launch with gfx.bundled-fonts.activate=0 (the behaviour before), which is evidence only. Needs strace on the runner: without it both are red, not skipped. No threshold."},
|
||||
{"id": "wrapper.e2e.fontconfig", "giro": "G2", "os": ["linux"], "min_tests": 9, "exact": true, "tests": ["tests/test_no_fontconfig_file_of_the_host_is_opened_and_the_screenshot_draws_the_bundle_linux_e2e.py", "tests/test_the_host_fontconfig_rules_do_not_reach_the_text_pixels_linux_e2e.py", "tests/test_the_parent_reads_the_bundle_from_fontconfig_s_cache_linux_e2e.py"], "marker": "e2e", "needs_root": false, "linux_only": "Fontconfig exists only on Linux: the engine runs it on its own empty configuration, and the rules of a user and the files of the host are what these tests try to make reach it. On Windows DirectWrite draws the text from the path of the font, with no rule of a user and no configuration or cache of fonts to read, so these tests have no Windows counterpart.", "note": "7 = (1-3) the fontconfig rules of a user do not reach the pixels of the text a page reads: seven launches of one seed, each with its own system-wide rule file (/etc/fonts/local.conf, written with sudo before the launch and put back after it; not the environment, which the core owns: it strips FONTCONFIG_*, and points XDG_CONFIG_HOME and XDG_CONFIG_DIRS at empty folders): nothing; rgba=none with lcdfilter=lcdnone; rgba=bgr; embeddedbitmap=false; autohint=true; hintstyle=hintfull with antialias=false; a strong prepend rule on system-ui. fc-match, in the same environment, must show each rule in force (a launch that measures nothing is red). Three tests: every rule in force in fc-match on the host; the hashes of the pixels of getImageData (an opaque canvas and the default one, Arial, SimSun, MS Gothic at 9-16 px) equal to those of the launch with nothing; the computed family and the widths of system-ui equal. (4-7) no fontconfig file of the host is opened and the screenshot draws the bundle: the stand-in that runs the engine under strace stays in the engine's place (a fake engine with a child, no browser); the caches $HOME/.fontconfig and $XDG_CACHE_HOME/fontconfig hold a valid cache of the bundle that lacks msgothic5_32.ttc (fc-list proves it); under strace no process opens a path under /etc/fonts, a fonts.conf or a *.cache-* file; the screenshot of Japanese text in MS PGothic equals the content's own drawing. Needs strace, fc-cache, fc-list, fc-match and sudo without a password on the runner: without them the tests are red, not skipped. Evidence in RUNNER_TEMP/invpw-evidence/fontconfig-rules and fontconfig-host-files. Also in the row until the 72 is released: the old file of the warm-cache test (2 tests, same ids), rewritten to assert the 72's behaviour: the stand-in, and two launches with the same XDG_CACHE_HOME and HOME under strace write no fontconfig cache file (*.cache-*, .NEW, .TMP-*) and no process opens one. E1 and E2 replace it; its retirement entry goes to main after the release of the 72."},
|
||||
{"id": "wrapper.unit.compositing", "giro": "G1", "os": ["linux", "windows"], "min_tests": 30, "exact": true, "tests": ["tests/test_the_page_bytes_reference_compares_decoded_pixels.py"], "marker": "unit", "needs_root": false, "note": "The helpers of wrapper.e2e.compositing on known inputs, no browser: the PNG compared on decoded pixels (another deBG chunk and compression are the same, one pixel is not, every scanline filter), the comparison with a reference (changed, missing and extra keys named, the entry to record), the type of an engine process, an engine process known by its executable and not by the name it gives itself (Linux), and the CPU of a window, and the shape of the committed Windows reference, and the box cut out of a screenshot (its pixels, a box outside the picture refused, written as a PNG and read back, two boxes told apart by a pixel that is named, the pixels that are not grey)."},
|
||||
{"id": "wrapper.unit.all.linux", "giro": "G1", "os": ["linux"], "min_tests": 4499, "exact": true, "tests": ["tests/test_a_162_message_is_read_like_a_161_one.py", "tests/test_a_click_makes_one_mousemove_at_its_point.py", "tests/test_a_closed_context_leaves_nothing_in_the_registry.py", "tests/test_a_closed_page_says_nothing.py", "tests/test_a_closed_pipe_is_a_closed_target.py", "tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py", "tests/test_a_context_proxy_carries_its_measured_udp_exit.py", "tests/test_a_context_route_disables_the_cache.py", "tests/test_a_detached_frame_answers_detached.py", "tests/test_a_dialog_is_a_protocol_object.py", "tests/test_a_dialog_is_answered_after_a_pause.py", "tests/test_a_download_finished_before_it_was_announced_is_finished.py", "tests/test_a_failed_expect_carries_its_call_log.py", "tests/test_a_failed_generation_of_the_security_state_keeps_its_evidence.py", "tests/test_a_failed_launch_stops_the_display.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_file_chooser_is_never_dropped_in_silence.py", "tests/test_a_frame_tap_needs_a_context_with_touch.py", "tests/test_a_gil_free_thread_dump_kills_a_busy_process_and_the_stack_watchdog_does_not.py", "tests/test_a_handle_action_walks_like_a_selector_action.py", "tests/test_a_launch_asks_nobody_on_the_internet_where_it_leaves_from.py", "tests/test_a_launch_gives_the_core_its_engine_for_the_security_state.py", "tests/test_a_launch_has_one_deadline.py", "tests/test_a_launch_without_a_session_gets_one.py", "tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py", "tests/test_a_marionette_session_is_asked_after_the_first_window.py", "tests/test_a_module_that_leaves_a_browser_open_fails.py", "tests/test_a_new_page_waits_for_the_engine.py", "tests/test_a_non_finite_number_crosses_the_wire_as_a_tag.py", "tests/test_a_page_closed_before_its_announcement_is_not_announced.py", "tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py", "tests/test_a_path_leaves_as_one_stroke.py", "tests/test_a_popup_under_the_declared_viewport_is_not_pinned.py", "tests/test_a_port_number_is_held_until_it_is_used.py", "tests/test_a_read_whose_probe_ran_out_is_the_callers_timeout.py", "tests/test_a_request_and_a_response_are_light.py", "tests/test_a_request_says_what_it_is.py", "tests/test_a_screenshot_refuses_what_would_touch_the_page.py", "tests/test_a_screenshot_sends_its_scale_to_the_engine.py", "tests/test_a_served_browser_keeps_the_udp_verdicts_of_its_proxies.py", "tests/test_a_session_ends_before_the_next_test_starts.py", "tests/test_a_streamed_upload_is_staged_in_the_session.py", "tests/test_a_stroke_is_judged_by_its_shape_not_its_length.py", "tests/test_a_test_that_is_not_e2e_never_leaves_the_machine.py", "tests/test_a_unit_test_does_not_read_the_seal_of_the_job.py", "tests/test_ab_host.py", "tests/test_ab_host_aa_stable.py", "tests/test_ab_network.py", "tests/test_ab_network_turn_credential.py", "tests/test_ab_network_turn_deallocation.py", "tests/test_ab_network_webrtc_evidence.py", "tests/test_ab_oracle.py", "tests/test_ab_oracle_declared_differences.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_element_handle_serves_every_method_of_the_client.py", "tests/test_an_expect_reads_its_value_once.py", "tests/test_an_expired_popupshown_wait_fails_the_e2e_test_that_launched_the_browser.py", "tests/test_async_api.py", "tests/test_browser_output_is_drained.py", "tests/test_ci_downloads_are_authenticated.py", "tests/test_ci_drive_gate_goes_through_the_core.py", "tests/test_ci_host_gate.py", "tests/test_ci_host_gate_ab.py", "tests/test_ci_lab_geoip.py", "tests/test_ci_lab_geoip_verify.py", "tests/test_ci_lab_intermediates.py", "tests/test_ci_lab_security_state.py", "tests/test_ci_linux_legs_read_no_mirror.py", "tests/test_ci_poison_host.py", "tests/test_ci_published_set.py", "tests/test_ci_real_geoip_check.py", "tests/test_ci_real_geoip_exit_code.py", "tests/test_ci_runs_once_per_commit.py", "tests/test_ci_suite_run.py", "tests/test_ci_verdict.py", "tests/test_ci_windows_temp_is_on_d.py", "tests/test_ci_workflows_build_the_geoip_database.py", "tests/test_ci_workflows_set_the_intermediates_list.py", "tests/test_ci_workflows_set_the_security_state.py", "tests/test_cli.py", "tests/test_click_rhythm.py", "tests/test_connect_does_not_start_threads_on_the_loop.py", "tests/test_context_locale_is_a_list.py", "tests/test_core_pin.py", "tests/test_cpu_by_type_window.py", "tests/test_cross_origin_iframe.py", "tests/test_cursor_dispatch.py", "tests/test_cursor_wiring.py", "tests/test_docs_name_the_mcp_repo_as_it_is.py", "tests/test_doh_session_prefs_unit.py", "tests/test_drag_motion.py", "tests/test_e2e_hermetic.py", "tests/test_element_handle_actions.py", "tests/test_every_action_is_pinned_by_commit_sha.py", "tests/test_every_argument_reaches_the_page_as_playwright_sends_it.py", "tests/test_every_fixture_a_test_pins_is_checked_out_byte_for_byte.py", Line truncated
|
||||
{"id": "wrapper.unit.all.windows", "giro": "G1", "os": ["windows"], "min_tests": 4511, "exact": true, "tests": ["tests/test_a_162_message_is_read_like_a_161_one.py", "tests/test_a_click_makes_one_mousemove_at_its_point.py", "tests/test_a_closed_context_leaves_nothing_in_the_registry.py", "tests/test_a_closed_page_says_nothing.py", "tests/test_a_closed_pipe_is_a_closed_target.py", "tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py", "tests/test_a_context_proxy_carries_its_measured_udp_exit.py", "tests/test_a_context_route_disables_the_cache.py", "tests/test_a_detached_frame_answers_detached.py", "tests/test_a_dialog_is_a_protocol_object.py", "tests/test_a_dialog_is_answered_after_a_pause.py", "tests/test_a_download_finished_before_it_was_announced_is_finished.py", "tests/test_a_failed_expect_carries_its_call_log.py", "tests/test_a_failed_generation_of_the_security_state_keeps_its_evidence.py", "tests/test_a_failed_launch_stops_the_display.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_file_chooser_is_never_dropped_in_silence.py", "tests/test_a_frame_tap_needs_a_context_with_touch.py", "tests/test_a_gil_free_thread_dump_kills_a_busy_process_and_the_stack_watchdog_does_not.py", "tests/test_a_handle_action_walks_like_a_selector_action.py", "tests/test_a_launch_asks_nobody_on_the_internet_where_it_leaves_from.py", "tests/test_a_launch_gives_the_core_its_engine_for_the_security_state.py", "tests/test_a_launch_has_one_deadline.py", "tests/test_a_launch_without_a_session_gets_one.py", "tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py", "tests/test_a_marionette_session_is_asked_after_the_first_window.py", "tests/test_a_module_that_leaves_a_browser_open_fails.py", "tests/test_a_new_page_waits_for_the_engine.py", "tests/test_a_non_finite_number_crosses_the_wire_as_a_tag.py", "tests/test_a_page_closed_before_its_announcement_is_not_announced.py", "tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py", "tests/test_a_path_leaves_as_one_stroke.py", "tests/test_a_popup_under_the_declared_viewport_is_not_pinned.py", "tests/test_a_port_number_is_held_until_it_is_used.py", "tests/test_a_read_whose_probe_ran_out_is_the_callers_timeout.py", "tests/test_a_request_and_a_response_are_light.py", "tests/test_a_request_says_what_it_is.py", "tests/test_a_screenshot_refuses_what_would_touch_the_page.py", "tests/test_a_screenshot_sends_its_scale_to_the_engine.py", "tests/test_a_served_browser_keeps_the_udp_verdicts_of_its_proxies.py", "tests/test_a_session_ends_before_the_next_test_starts.py", "tests/test_a_streamed_upload_is_staged_in_the_session.py", "tests/test_a_stroke_is_judged_by_its_shape_not_its_length.py", "tests/test_a_test_that_is_not_e2e_never_leaves_the_machine.py", "tests/test_a_unit_test_does_not_read_the_seal_of_the_job.py", "tests/test_ab_host.py", "tests/test_ab_host_aa_stable.py", "tests/test_ab_network.py", "tests/test_ab_network_turn_credential.py", "tests/test_ab_network_turn_deallocation.py", "tests/test_ab_network_webrtc_evidence.py", "tests/test_ab_oracle.py", "tests/test_ab_oracle_declared_differences.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_element_handle_serves_every_method_of_the_client.py", "tests/test_an_expect_reads_its_value_once.py", "tests/test_an_expired_popupshown_wait_fails_the_e2e_test_that_launched_the_browser.py", "tests/test_async_api.py", "tests/test_browser_output_is_drained.py", "tests/test_ci_downloads_are_authenticated.py", "tests/test_ci_drive_gate_goes_through_the_core.py", "tests/test_ci_host_gate.py", "tests/test_ci_host_gate_ab.py", "tests/test_ci_lab_geoip.py", "tests/test_ci_lab_geoip_verify.py", "tests/test_ci_lab_intermediates.py", "tests/test_ci_lab_security_state.py", "tests/test_ci_linux_legs_read_no_mirror.py", "tests/test_ci_poison_host.py", "tests/test_ci_published_set.py", "tests/test_ci_real_geoip_check.py", "tests/test_ci_real_geoip_exit_code.py", "tests/test_ci_runs_once_per_commit.py", "tests/test_ci_suite_run.py", "tests/test_ci_verdict.py", "tests/test_ci_windows_temp_is_on_d.py", "tests/test_ci_workflows_build_the_geoip_database.py", "tests/test_ci_workflows_set_the_intermediates_list.py", "tests/test_ci_workflows_set_the_security_state.py", "tests/test_cli.py", "tests/test_click_rhythm.py", "tests/test_connect_does_not_start_threads_on_the_loop.py", "tests/test_context_locale_is_a_list.py", "tests/test_core_pin.py", "tests/test_cpu_by_type_window.py", "tests/test_cross_origin_iframe.py", "tests/test_cursor_dispatch.py", "tests/test_cursor_wiring.py", "tests/test_docs_name_the_mcp_repo_as_it_is.py", "tests/test_doh_session_prefs_unit.py", "tests/test_drag_motion.py", "tests/test_e2e_hermetic.py", "tests/test_element_handle_actions.py", "tests/test_every_action_is_pinned_by_commit_sha.py", "tests/test_every_argument_reaches_the_page_as_playwright_sends_it.py", "tests/test_every_fixture_a_test_pins_is_checked_out_byte_for_byte.pLine truncated
|
||||
{"id": "wrapper.unit.all.linux", "giro": "G1", "os": ["linux"], "min_tests": 4715, "exact": true, "tests": ["tests/test_a_162_message_is_read_like_a_161_one.py", "tests/test_a_click_makes_one_mousemove_at_its_point.py", "tests/test_a_closed_context_leaves_nothing_in_the_registry.py", "tests/test_a_closed_page_says_nothing.py", "tests/test_a_closed_pipe_is_a_closed_target.py", "tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py", "tests/test_a_context_proxy_carries_its_measured_udp_exit.py", "tests/test_a_context_route_disables_the_cache.py", "tests/test_a_detached_frame_answers_detached.py", "tests/test_a_dialog_is_a_protocol_object.py", "tests/test_a_dialog_is_answered_after_a_pause.py", "tests/test_a_download_finished_before_it_was_announced_is_finished.py", "tests/test_a_failed_expect_carries_its_call_log.py", "tests/test_a_failed_generation_of_the_security_state_keeps_its_evidence.py", "tests/test_a_failed_launch_stops_the_display.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_file_chooser_is_never_dropped_in_silence.py", "tests/test_a_frame_tap_needs_a_context_with_touch.py", "tests/test_a_gil_free_thread_dump_kills_a_busy_process_and_the_stack_watchdog_does_not.py", "tests/test_a_handle_action_walks_like_a_selector_action.py", "tests/test_a_launch_asks_nobody_on_the_internet_where_it_leaves_from.py", "tests/test_a_launch_gives_the_core_its_engine_for_the_security_state.py", "tests/test_a_launch_has_one_deadline.py", "tests/test_a_launch_without_a_session_gets_one.py", "tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py", "tests/test_a_marionette_session_is_asked_after_the_first_window.py", "tests/test_a_module_that_leaves_a_browser_open_fails.py", "tests/test_a_new_page_waits_for_the_engine.py", "tests/test_a_non_finite_number_crosses_the_wire_as_a_tag.py", "tests/test_a_page_closed_before_its_announcement_is_not_announced.py", "tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py", "tests/test_a_path_leaves_as_one_stroke.py", "tests/test_a_popup_under_the_declared_viewport_is_not_pinned.py", "tests/test_a_port_number_is_held_until_it_is_used.py", "tests/test_a_read_whose_probe_ran_out_is_the_callers_timeout.py", "tests/test_a_request_and_a_response_are_light.py", "tests/test_a_request_says_what_it_is.py", "tests/test_a_screenshot_refuses_what_would_touch_the_page.py", "tests/test_a_screenshot_sends_its_scale_to_the_engine.py", "tests/test_a_served_browser_keeps_the_udp_verdicts_of_its_proxies.py", "tests/test_a_session_ends_before_the_next_test_starts.py", "tests/test_a_streamed_upload_is_staged_in_the_session.py", "tests/test_a_stroke_is_judged_by_its_shape_not_its_length.py", "tests/test_a_test_that_is_not_e2e_never_leaves_the_machine.py", "tests/test_a_unit_test_does_not_read_the_seal_of_the_job.py", "tests/test_ab_host.py", "tests/test_ab_host_aa_stable.py", "tests/test_ab_network.py", "tests/test_ab_network_turn_credential.py", "tests/test_ab_network_turn_deallocation.py", "tests/test_ab_network_webrtc_evidence.py", "tests/test_ab_oracle.py", "tests/test_ab_oracle_declared_differences.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_element_handle_serves_every_method_of_the_client.py", "tests/test_an_expect_reads_its_value_once.py", "tests/test_an_expired_popupshown_wait_fails_the_e2e_test_that_launched_the_browser.py", "tests/test_async_api.py", "tests/test_browser_output_is_drained.py", "tests/test_ci_downloads_are_authenticated.py", "tests/test_ci_drive_gate_goes_through_the_core.py", "tests/test_ci_host_gate.py", "tests/test_ci_host_gate_ab.py", "tests/test_ci_lab_geoip.py", "tests/test_ci_lab_geoip_verify.py", "tests/test_ci_lab_intermediates.py", "tests/test_ci_lab_security_state.py", "tests/test_ci_linux_legs_read_no_mirror.py", "tests/test_ci_poison_host.py", "tests/test_ci_published_set.py", "tests/test_ci_real_geoip_check.py", "tests/test_ci_real_geoip_exit_code.py", "tests/test_ci_runs_once_per_commit.py", "tests/test_ci_suite_run.py", "tests/test_ci_verdict.py", "tests/test_ci_windows_temp_is_on_d.py", "tests/test_ci_workflows_build_the_geoip_database.py", "tests/test_ci_workflows_set_the_intermediates_list.py", "tests/test_ci_workflows_set_the_security_state.py", "tests/test_cli.py", "tests/test_click_rhythm.py", "tests/test_connect_does_not_start_threads_on_the_loop.py", "tests/test_context_locale_is_a_list.py", "tests/test_core_pin.py", "tests/test_cpu_by_type_window.py", "tests/test_cross_origin_iframe.py", "tests/test_cursor_dispatch.py", "tests/test_cursor_wiring.py", "tests/test_docs_name_the_mcp_repo_as_it_is.py", "tests/test_doh_session_prefs_unit.py", "tests/test_drag_motion.py", "tests/test_e2e_hermetic.py", "tests/test_element_handle_actions.py", "tests/test_every_action_is_pinned_by_commit_sha.py", "tests/test_every_argument_reaches_the_page_as_playwright_sends_it.py", "tests/test_every_fixture_a_test_pins_is_checked_out_byte_for_byte.py", Line truncated
|
||||
{"id": "wrapper.unit.all.windows", "giro": "G1", "os": ["windows"], "min_tests": 4727, "exact": true, "tests": ["tests/test_a_162_message_is_read_like_a_161_one.py", "tests/test_a_click_makes_one_mousemove_at_its_point.py", "tests/test_a_closed_context_leaves_nothing_in_the_registry.py", "tests/test_a_closed_page_says_nothing.py", "tests/test_a_closed_pipe_is_a_closed_target.py", "tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py", "tests/test_a_context_proxy_carries_its_measured_udp_exit.py", "tests/test_a_context_route_disables_the_cache.py", "tests/test_a_detached_frame_answers_detached.py", "tests/test_a_dialog_is_a_protocol_object.py", "tests/test_a_dialog_is_answered_after_a_pause.py", "tests/test_a_download_finished_before_it_was_announced_is_finished.py", "tests/test_a_failed_expect_carries_its_call_log.py", "tests/test_a_failed_generation_of_the_security_state_keeps_its_evidence.py", "tests/test_a_failed_launch_stops_the_display.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_file_chooser_is_never_dropped_in_silence.py", "tests/test_a_frame_tap_needs_a_context_with_touch.py", "tests/test_a_gil_free_thread_dump_kills_a_busy_process_and_the_stack_watchdog_does_not.py", "tests/test_a_handle_action_walks_like_a_selector_action.py", "tests/test_a_launch_asks_nobody_on_the_internet_where_it_leaves_from.py", "tests/test_a_launch_gives_the_core_its_engine_for_the_security_state.py", "tests/test_a_launch_has_one_deadline.py", "tests/test_a_launch_without_a_session_gets_one.py", "tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py", "tests/test_a_marionette_session_is_asked_after_the_first_window.py", "tests/test_a_module_that_leaves_a_browser_open_fails.py", "tests/test_a_new_page_waits_for_the_engine.py", "tests/test_a_non_finite_number_crosses_the_wire_as_a_tag.py", "tests/test_a_page_closed_before_its_announcement_is_not_announced.py", "tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py", "tests/test_a_path_leaves_as_one_stroke.py", "tests/test_a_popup_under_the_declared_viewport_is_not_pinned.py", "tests/test_a_port_number_is_held_until_it_is_used.py", "tests/test_a_read_whose_probe_ran_out_is_the_callers_timeout.py", "tests/test_a_request_and_a_response_are_light.py", "tests/test_a_request_says_what_it_is.py", "tests/test_a_screenshot_refuses_what_would_touch_the_page.py", "tests/test_a_screenshot_sends_its_scale_to_the_engine.py", "tests/test_a_served_browser_keeps_the_udp_verdicts_of_its_proxies.py", "tests/test_a_session_ends_before_the_next_test_starts.py", "tests/test_a_streamed_upload_is_staged_in_the_session.py", "tests/test_a_stroke_is_judged_by_its_shape_not_its_length.py", "tests/test_a_test_that_is_not_e2e_never_leaves_the_machine.py", "tests/test_a_unit_test_does_not_read_the_seal_of_the_job.py", "tests/test_ab_host.py", "tests/test_ab_host_aa_stable.py", "tests/test_ab_network.py", "tests/test_ab_network_turn_credential.py", "tests/test_ab_network_turn_deallocation.py", "tests/test_ab_network_webrtc_evidence.py", "tests/test_ab_oracle.py", "tests/test_ab_oracle_declared_differences.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_element_handle_serves_every_method_of_the_client.py", "tests/test_an_expect_reads_its_value_once.py", "tests/test_an_expired_popupshown_wait_fails_the_e2e_test_that_launched_the_browser.py", "tests/test_async_api.py", "tests/test_browser_output_is_drained.py", "tests/test_ci_downloads_are_authenticated.py", "tests/test_ci_drive_gate_goes_through_the_core.py", "tests/test_ci_host_gate.py", "tests/test_ci_host_gate_ab.py", "tests/test_ci_lab_geoip.py", "tests/test_ci_lab_geoip_verify.py", "tests/test_ci_lab_intermediates.py", "tests/test_ci_lab_security_state.py", "tests/test_ci_linux_legs_read_no_mirror.py", "tests/test_ci_poison_host.py", "tests/test_ci_published_set.py", "tests/test_ci_real_geoip_check.py", "tests/test_ci_real_geoip_exit_code.py", "tests/test_ci_runs_once_per_commit.py", "tests/test_ci_suite_run.py", "tests/test_ci_verdict.py", "tests/test_ci_windows_temp_is_on_d.py", "tests/test_ci_workflows_build_the_geoip_database.py", "tests/test_ci_workflows_set_the_intermediates_list.py", "tests/test_ci_workflows_set_the_security_state.py", "tests/test_cli.py", "tests/test_click_rhythm.py", "tests/test_connect_does_not_start_threads_on_the_loop.py", "tests/test_context_locale_is_a_list.py", "tests/test_core_pin.py", "tests/test_cpu_by_type_window.py", "tests/test_cross_origin_iframe.py", "tests/test_cursor_dispatch.py", "tests/test_cursor_wiring.py", "tests/test_docs_name_the_mcp_repo_as_it_is.py", "tests/test_doh_session_prefs_unit.py", "tests/test_drag_motion.py", "tests/test_e2e_hermetic.py", "tests/test_element_handle_actions.py", "tests/test_every_action_is_pinned_by_commit_sha.py", "tests/test_every_argument_reaches_the_page_as_playwright_sends_it.py", "tests/test_every_fixture_a_test_pins_is_checked_out_byte_for_byte.pLine truncated
|
||||
{"id": "wrapper.e2e.securitystate", "giro": "G2", "os": ["linux", "windows"], "min_tests": 4, "exact": true, "tests": ["tests/test_security_state_engine_e2e.py"], "marker": "e2e", "needs_root": false, "note": "The security state the core declares, against the engine: the engine launched directly in its generate mode makes what it is given (the contract's result, security_state/ with the bytes of the full filter and of the delta, the core's own validation of it); a normal launch declares no pref of the mode and re-imports nothing; a certificate that Mozilla's CRLite test data say is revoked in a delta is refused at the first navigation (SEC_ERROR_REVOKED_CERTIFICATE) while a valid one loads, and the revoked one loads when the ready directory has no data; a ready directory with no or an empty security_state/ starts. Certificates made on the run (a fresh root trusted in cert9.db by the engine's own xpcshell, Mozilla's default test key as the key of CN=int), servers on loopback, no network. Red on firefox-67 (no generate mode).", "core_dumps": "invpw-cores"},
|
||||
{"id": "wrapper.e2e.suite.linux.1", "giro": "G2", "os": ["linux"], "min_tests": 447, "exact": true, "tests": ["tests/test_a_closed_browser_leaves_the_others_alone_e2e.py", "tests/test_a_context_that_ends_leaves_no_process_e2e.py", "tests/test_a_cors_preflight_is_not_a_request_of_the_page_e2e.py", "tests/test_a_declared_webgl_extension_survives_its_use_e2e.py", "tests/test_a_granted_permission_is_the_one_the_page_asks_for_e2e.py", "tests/test_a_held_ice_port_blinds_the_loopback_checks_e2e.py", "tests/test_a_launch_without_a_session_gets_one_e2e.py", "tests/test_a_left_documents_body_is_evicted_e2e.py", "tests/test_a_mouse_click_makes_one_mousemove_on_its_point_e2e.py", "tests/test_a_page_over_ipv6_gathers_on_a_machine_declared_without_it_e2e.py", "tests/test_a_popup_is_reported_when_the_engine_says_it_is_ready_as_playwright_does_e2e.py", "tests/test_a_screenshot_draws_the_text_of_the_bundled_fonts_as_the_content_does_e2e.py", "tests/test_a_screenshot_honours_its_scale_e2e.py", "tests/test_a_screenshot_refuses_what_would_touch_the_page_e2e.py", "tests/test_a_served_browser_answers_a_plain_client_e2e.py", "tests/test_a_tiny_download_on_a_served_browser_is_saved_e2e.py", "tests/test_a_turn_name_over_tcp_goes_through_the_proxy_of_the_context_e2e.py", "tests/test_accept_language_on_the_wire_e2e.py", "tests/test_browser_output_is_drained.py", "tests/test_click_rhythm.py", "tests/test_closing_one_of_four_browsers_does_not_hold_the_loop_e2e.py", "tests/test_control_a_selects_all_in_a_field_e2e.py", "tests/test_cross_origin_iframe.py", "tests/test_declared_host_network_e2e.py", "tests/test_detectors_e2e.py", "tests/test_e2e.py", "tests/test_element_handle_actions.py", "tests/test_element_screenshot_e2e.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_file_chooser.py", "tests/test_fingerprint_surface.py", "tests/test_fission_frames_history_and_processes_e2e.py", "tests/test_fission_frames_workers_storage_and_special_frames_e2e.py", "tests/test_frames_outlive_the_back_forward_cache_e2e.py", "tests/test_goto_networkidle_after_spa_e2e.py", "tests/test_goto_script_redirect_e2e.py", "tests/test_hidden_display_linux.py", "tests/test_ice_names_by_the_context_proxy_e2e.py::test_the_ice_name_of_a_context_goes_by_the_proxy_of_that_context", "tests/test_ignore_https_errors_e2e.py", "tests/test_injected_node_surface.py", "tests/test_juggler_connection.py", "tests/test_juggler_posix_pipe.py", "tests/test_juggler_transport.py", "tests/test_navigation_across_processes_e2e.py", "tests/test_navigation_response.py", "tests/test_networkidle_reaches_the_client_e2e.py", "tests/test_oop_frame_element.py", "tests/test_oop_frame_geometry.py", "tests/test_page_number_follows_the_call.py", "tests/test_persistent_profile_keeps_state.py", "tests/test_pointer_position.py", "tests/test_popups_reach_the_client_e2e.py", "tests/test_preload_newtab_turns_the_privileged_about_process_off_e2e.py", "tests/test_realness_behind_a_declared_exit_e2e.py", "tests/test_resolver_race_e2e.py", "tests/test_route_header_order_e2e.py", "tests/test_same_document_goto_e2e.py", "tests/test_screencast.py", "tests/test_screencast_stop_e2e.py", "tests/test_screenshot_looks_where_you_are.py", "tests/test_security_state_engine_e2e.py", "tests/test_service_worker.py", "tests/test_service_worker_controller_e2e.py", "tests/test_set_offline_e2e.py", "tests/test_shadow_trusted_input.py", "tests/test_strict_and_force.py", "tests/test_the_callers_code_is_not_counted_e2e.py", "tests/test_the_device_enumeration_takes_the_declared_time_e2e.py", "tests/test_the_engine_is_born_in_the_job_e2e.py::test_a_launch_scans_no_process_of_the_machine", "tests/test_the_engine_is_born_in_the_job_e2e.py::test_after_close_no_process_of_the_session_is_left", "tests/test_the_hosts_file_of_the_host_is_never_read_e2e.py", "tests/test_trial_does_not_act.py", "tests/test_turn_over_tcp_is_tried_for_real_e2e.py", "tests/test_ua_widget_not_selectable.py", "tests/test_voices_e2e.py", "tests/test_wait_for_function.py", "tests/test_webgl_draws_on_the_engine_s_own_gl_e2e.py", "tests/test_webgl_noise_active.py", "tests/test_webrtc_realness.py::test_a_gateway_that_is_far_away_still_gives_the_page_a_srflx_born_through_its_relay", "tests/test_webrtc_realness.py::test_a_gather_after_the_page_loaded_through_the_gateway_costs_only_the_road_to_the_server", "tests/test_webrtc_realness.py::test_a_host_with_ipv6_addresses_gathers_through_an_ipv4_relay", "tests/test_webrtc_realness.py::test_a_proxy_that_does_not_relay_udp_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_a_proxy_whose_relay_never_answers_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_a_proxy_whose_udp_leaves_from_another_address_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_not_blocked_behind_tcp_only_socks", "tests/test_webrtc_realness.py::test_the_first_candidate_of_a_gather_does_not_wait_for_a_gateway_that_is_far_away", "tests/test_webrtc_realness.py::test_the_turn_over_tcp_of_a_context_goes_throuLine truncated
|
||||
{"id": "wrapper.e2e.suite.linux.2", "giro": "G2", "os": ["linux"], "min_tests": 453, "exact": true, "tests": ["tests/test_a_click_waits_for_the_navigation_it_plans_e2e.py", "tests/test_a_context_init_script_runs_once_e2e.py", "tests/test_a_drag_keeps_its_buttons_pressed_e2e.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_goto_to_a_response_with_no_document_ends_e2e.py", "tests/test_a_keepalive_request_reaches_the_client_e2e.py", "tests/test_a_latin_letter_on_a_cyrillic_persona_e2e.py", "tests/test_a_page_cannot_probe_the_juggler_e2e.py", "tests/test_a_page_that_moves_on_e2e.py", "tests/test_a_pointer_event_is_handled_before_the_call_returns_e2e.py", "tests/test_a_press_on_an_open_select_follows_windows_rollup_e2e.py", "tests/test_a_request_says_what_it_is_e2e.py", "tests/test_a_select_dropdown_stays_open_after_the_release_e2e.py", "tests/test_a_worker_comes_back_with_its_page_from_the_cache_e2e.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_isolated_page_and_the_next_e2e.py", "tests/test_bypass_csp_e2e.py", "tests/test_caller_world_handles_e2e.py", "tests/test_canvas_reads_as_drawn.py", "tests/test_canvas_render_stealth.py", "tests/test_context_locale_e2e.py", "tests/test_context_proxy_only_resolves_by_doh_e2e.py", "tests/test_doh_through_the_proxy_e2e.py", "tests/test_doh_under_stress_e2e.py", "tests/test_download_is_intercepted_e2e.py", "tests/test_drag_motion.py", "tests/test_expose_binding_e2e.py", "tests/test_fakeweb_p4_e2e.py", "tests/test_fingerprint_consistency.py", "tests/test_fission_frames_dialogs_downloads_popups_e2e.py", "tests/test_fission_frames_route_and_bindings_e2e.py", "tests/test_fission_identity_parity_e2e.py", "tests/test_fission_iframe_crash_e2e.py", "tests/test_fission_strategy1_bench.py", "tests/test_goto_to_the_same_url_e2e.py", "tests/test_http3_through_the_proxy_e2e.py", "tests/test_input_is_born_before_the_page_sees_it_e2e.py", "tests/test_juggler_actions.py", "tests/test_juggler_event_listeners.py", "tests/test_juggler_injected.py::test_a_javascript_that_THROWS_arrives_as_an_error_not_as_None", "tests/test_juggler_injected.py::test_actionability_DISTINGUISHES_instead_of_always_saying_yes", "tests/test_juggler_injected.py::test_reads_that_make_no_sense_are_REJECTED", "tests/test_juggler_injected.py::test_states_DISCRIMINATE_instead_of_always_saying_true", "tests/test_juggler_injected.py::test_the_DOM_READING_group", "tests/test_juggler_injected.py::test_the_selector_engines_respond", "tests/test_juggler_injected.py::test_the_text_reads", "tests/test_juggler_lifecycle_e2e.py", "tests/test_key_delay_reaches_the_keyboard.py", "tests/test_keyboard_rhythm.py", "tests/test_long_session_e2e.py", "tests/test_mouse.py", "tests/test_mouse_events_keep_their_values_e2e.py", "tests/test_new_page_defaults.py", "tests/test_no_popup_is_left_when_a_page_closes_e2e.py", "tests/test_popup_destinations_e2e.py", "tests/test_popup_pages.py", "tests/test_proxy_http_auth_e2e.py", "tests/test_proxy_reaches_the_browser.py", "tests/test_proxy_socks_auth_e2e.py", "tests/test_requestless_navigation.py", "tests/test_route_abort_code.py", "tests/test_route_e2e.py", "tests/test_route_post_data_e2e.py", "tests/test_route_sends_a_navigation_elsewhere_e2e.py", "tests/test_route_superseded_e2e.py", "tests/test_same_document_navigation.py", "tests/test_screenshot_of_text_returns_linux_e2e.py", "tests/test_scroll_into_view.py", "tests/test_scroll_only_if_needed_e2e.py", "tests/test_service_workers_blocked.py", "tests/test_set_input_files_payloads.py", "tests/test_software_compositing_is_declared_e2e.py", "tests/test_the_association_is_ready_when_the_peerconnection_is_born_e2e.py", "tests/test_the_callers_code_runs_once_e2e.py", "tests/test_the_close_returns_when_the_browser_has_exited_e2e.py", "tests/test_the_favicon_stays_out_of_sight_e2e.py", "tests/test_the_font_list_is_the_bundle_e2e.py", "tests/test_the_parent_reads_the_bundle_from_fontconfig_s_cache_linux_e2e.py", "tests/test_the_scheme_is_the_personas_e2e.py", "tests/test_the_whole_udp_chain_by_name_e2e.py::test_a_turn_srflx_by_name_arrives_through_the_relay_when_the_exit_of_the_lab_is_loopback", "tests/test_typing_a_character_without_a_key_e2e.py", "tests/test_wait_for_timeout.py", "tests/test_web_fonts_of_closed_contexts_e2e.py"], "marker": "e2e", "needs_root": false, "windows_twin": "wrapper.e2e.suite.windows.2", "note": "Part 2 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 2 rows of linux are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 564 s of estimated wall time, 4 brLine truncated
|
||||
{"id": "wrapper.e2e.suite.linux.3", "giro": "G2", "os": ["linux"], "min_tests": 375, "exact": true, "tests": ["tests/test_a_click_in_an_iframe_lands_at_the_frames_own_screen_origin_e2e.py", "tests/test_a_context_language_is_the_accept_language_of_every_request_e2e.py", "tests/test_a_file_chooser_reaches_every_client_e2e.py", "tests/test_a_frame_reads_only_declared_origins_while_it_loads_e2e.py", "tests/test_a_goto_to_a_refused_port_ends_with_its_reason_e2e.py", "tests/test_a_handle_action_walks_like_a_selector_action_e2e.py", "tests/test_a_launch_and_a_context_timezone_reach_the_page_e2e.py", "tests/test_a_navigation_that_moved_is_told_by_the_engine_e2e.py", "tests/test_a_popup_moves_and_resizes_as_declared_e2e.py", "tests/test_a_popup_of_a_link_reaches_the_client_e2e.py", "tests/test_a_popup_reads_the_retail_sizes_of_a_maximized_main_window_e2e.py", "tests/test_a_regional_indicator_pair_measures_the_same_first_and_after_other_families_e2e.py", "tests/test_an_element_handle_serves_every_method_of_the_client_e2e.py", "tests/test_audio_context_values_are_declared_e2e.py", "tests/test_audio_noise_e2e.py", "tests/test_audio_sample_rate_is_declared_e2e.py", "tests/test_bundle_font_names_e2e.py", "tests/test_canvas_create_pattern_projection_e2e.py", "tests/test_canvas_measure_text_metrics_e2e.py", "tests/test_css_media_reads_the_declared_screen_and_pointer_e2e.py", "tests/test_dom_iterables_from_evaluate_e2e.py", "tests/test_every_argument_reaches_the_page_e2e.py", "tests/test_every_reader_of_a_webgl_canvas_agrees_e2e.py", "tests/test_exslt_date_time_through_an_imported_stylesheet_is_in_the_declared_zone_e2e.py", "tests/test_fakeweb_p2_e2e.py", "tests/test_fission_frames_tree_input_and_pixels_e2e.py", "tests/test_focus_survives_os_deactivation_e2e.py", "tests/test_fullscreen_without_wm_e2e.py", "tests/test_geolocation_reads_nothing_of_the_host_windows_e2e.py", "tests/test_goto_and_every_way_it_is_stopped_e2e.py", "tests/test_hardware_values_are_declared_e2e.py", "tests/test_input_reaches_the_top_and_a_frame_of_another_site_at_every_scale_e2e.py", "tests/test_ipv6_literal_connect_e2e.py", "tests/test_moz_element_paints_a_webgl_canvas_as_drawn_e2e.py", "tests/test_native_line_endings_are_windows_e2e.py", "tests/test_nested_frame_actions.py", "tests/test_networkidle_through_a_served_browser_with_routes_e2e.py", "tests/test_nothing_leaves_but_the_proxy_e2e.py", "tests/test_nothing_of_a_context_leaves_but_through_its_proxy_e2e.py", "tests/test_page_element_atoms_run_in_a_sandbox_e2e.py", "tests/test_popup_geometry_is_the_declared_frame_e2e.py", "tests/test_script_cache_written_is_adopted_e2e.py", "tests/test_the_branding_a_page_loads_is_the_declared_archive_e2e.py", "tests/test_the_evaluated_code_has_no_debugger_name_e2e.py", "tests/test_the_host_gl_probe_runs_only_on_an_undeclared_engine_linux_e2e.py", "tests/test_the_launch_counter_is_one_plain_get_before_any_page_e2e.py", "tests/test_the_maximized_window_frames_and_popups_read_retail_e2e.py", "tests/test_the_parent_methods_of_the_window_origin_are_not_exposed_to_a_page_e2e.py", "tests/test_the_shutdown_ping_leaves_by_the_background_task_e2e.py", "tests/test_webgl_declared_parameters_e2e.py", "tests/test_webgl_shader_language_e2e.py", "tests/test_webgpu_adapter_is_declared_e2e.py", "tests/test_webgpu_canvas_readback_is_noised_e2e.py", "tests/test_webgpu_external_texture_e2e.py", "tests/test_window_occlusion_e2e.py"], "marker": "e2e", "needs_root": false, "windows_twin": "wrapper.e2e.suite.windows.3", "note": "Part 2 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 2 rows of linux are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 565 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapper.e2e.udp.exit and wrapper.e2e.udp.sandbox (root and user namespaces, their own rows), the files of the round after the publication (tests/_post_publication.py), and the tests that skip on linux (a skip is red in the verdict).", "run": "suite_run"},
|
||||
{"id": "wrapper.e2e.suite.linux.2", "giro": "G2", "os": ["linux"], "min_tests": 463, "exact": true, "tests": ["tests/test_a_click_under_the_login_autocomplete_list_reaches_the_page_e2e.py", "tests/test_a_click_waits_for_the_navigation_it_plans_e2e.py", "tests/test_a_context_init_script_runs_once_e2e.py", "tests/test_a_drag_keeps_its_buttons_pressed_e2e.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_goto_to_a_response_with_no_document_ends_e2e.py", "tests/test_a_keepalive_request_reaches_the_client_e2e.py", "tests/test_a_latin_letter_on_a_cyrillic_persona_e2e.py", "tests/test_a_page_cannot_probe_the_juggler_e2e.py", "tests/test_a_page_that_moves_on_e2e.py", "tests/test_a_pointer_event_is_handled_before_the_call_returns_e2e.py", "tests/test_a_press_on_an_open_select_follows_windows_rollup_e2e.py", "tests/test_a_request_says_what_it_is_e2e.py", "tests/test_a_select_dropdown_stays_open_after_the_release_e2e.py", "tests/test_a_worker_comes_back_with_its_page_from_the_cache_e2e.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_isolated_page_and_the_next_e2e.py", "tests/test_bypass_csp_e2e.py", "tests/test_caller_world_handles_e2e.py", "tests/test_canvas_reads_as_drawn.py", "tests/test_canvas_render_stealth.py", "tests/test_context_locale_e2e.py", "tests/test_context_proxy_only_resolves_by_doh_e2e.py", "tests/test_doh_through_the_proxy_e2e.py", "tests/test_doh_under_stress_e2e.py", "tests/test_download_is_intercepted_e2e.py", "tests/test_drag_motion.py", "tests/test_expose_binding_e2e.py", "tests/test_fakeweb_p4_e2e.py", "tests/test_fingerprint_consistency.py", "tests/test_fission_frames_dialogs_downloads_popups_e2e.py", "tests/test_fission_frames_route_and_bindings_e2e.py", "tests/test_fission_identity_parity_e2e.py", "tests/test_fission_iframe_crash_e2e.py", "tests/test_fission_strategy1_bench.py", "tests/test_goto_to_the_same_url_e2e.py", "tests/test_http3_through_the_proxy_e2e.py", "tests/test_input_is_born_before_the_page_sees_it_e2e.py", "tests/test_juggler_actions.py", "tests/test_juggler_event_listeners.py", "tests/test_juggler_injected.py::test_a_javascript_that_THROWS_arrives_as_an_error_not_as_None", "tests/test_juggler_injected.py::test_actionability_DISTINGUISHES_instead_of_always_saying_yes", "tests/test_juggler_injected.py::test_reads_that_make_no_sense_are_REJECTED", "tests/test_juggler_injected.py::test_states_DISCRIMINATE_instead_of_always_saying_true", "tests/test_juggler_injected.py::test_the_DOM_READING_group", "tests/test_juggler_injected.py::test_the_selector_engines_respond", "tests/test_juggler_injected.py::test_the_text_reads", "tests/test_juggler_lifecycle_e2e.py", "tests/test_key_delay_reaches_the_keyboard.py", "tests/test_keyboard_rhythm.py", "tests/test_long_session_e2e.py", "tests/test_mouse.py", "tests/test_mouse_events_keep_their_values_e2e.py", "tests/test_new_page_defaults.py", "tests/test_no_fontconfig_file_of_the_host_is_opened_and_the_screenshot_draws_the_bundle_linux_e2e.py", "tests/test_no_popup_is_left_when_a_page_closes_e2e.py", "tests/test_popup_destinations_e2e.py", "tests/test_popup_pages.py", "tests/test_proxy_http_auth_e2e.py", "tests/test_proxy_reaches_the_browser.py", "tests/test_proxy_socks_auth_e2e.py", "tests/test_requestless_navigation.py", "tests/test_route_abort_code.py", "tests/test_route_e2e.py", "tests/test_route_post_data_e2e.py", "tests/test_route_sends_a_navigation_elsewhere_e2e.py", "tests/test_route_superseded_e2e.py", "tests/test_same_document_navigation.py", "tests/test_screenshot_of_text_returns_linux_e2e.py", "tests/test_scroll_into_view.py", "tests/test_scroll_only_if_needed_e2e.py", "tests/test_service_workers_blocked.py", "tests/test_set_input_files_payloads.py", "tests/test_software_compositing_is_declared_e2e.py", "tests/test_the_association_is_ready_when_the_peerconnection_is_born_e2e.py", "tests/test_the_callers_code_runs_once_e2e.py", "tests/test_the_close_returns_when_the_browser_has_exited_e2e.py", "tests/test_the_favicon_stays_out_of_sight_e2e.py", "tests/test_the_font_list_is_the_bundle_e2e.py", "tests/test_the_host_fontconfig_rules_do_not_reach_the_text_pixels_linux_e2e.py", "tests/test_the_parent_reads_the_bundle_from_fontconfig_s_cache_linux_e2e.py", "tests/test_the_scheme_is_the_personas_e2e.py", "tests/test_the_whole_udp_chain_by_name_e2e.py::test_a_turn_srflx_by_name_arrives_through_the_relay_when_the_exit_of_the_lab_is_loopback", "tests/test_typing_a_character_without_a_key_e2e.py", "tests/test_wait_for_timeout.py", "tests/test_web_fonts_of_closed_contexts_e2e.py"], "marker": "e2e", "needs_root": false, "windows_twin": "wrapper.e2e.suite.windows.2", "note": "Part 2 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 2 rows of linux are the files of Line truncated
|
||||
{"id": "wrapper.e2e.suite.linux.3", "giro": "G2", "os": ["linux"], "min_tests": 405, "exact": true, "tests": ["tests/test_a_click_in_an_iframe_lands_at_the_frames_own_screen_origin_e2e.py", "tests/test_a_context_language_is_the_accept_language_of_every_request_e2e.py", "tests/test_a_file_chooser_reaches_every_client_e2e.py", "tests/test_a_frame_reads_only_declared_origins_while_it_loads_e2e.py", "tests/test_a_goto_to_a_refused_port_ends_with_its_reason_e2e.py", "tests/test_a_handle_action_walks_like_a_selector_action_e2e.py", "tests/test_a_launch_and_a_context_timezone_reach_the_page_e2e.py", "tests/test_a_navigation_that_moved_is_told_by_the_engine_e2e.py", "tests/test_a_page_function_called_by_the_client_sees_only_page_frames_e2e.py", "tests/test_a_page_sees_no_pointer_event_before_the_first_input_on_the_hidden_display_e2e.py", "tests/test_a_pages_own_hasinstance_is_never_called_while_the_client_listens_to_console_e2e.py", "tests/test_a_password_field_is_as_wide_as_on_retail_windows_e2e.py", "tests/test_a_popup_moves_and_resizes_as_declared_e2e.py", "tests/test_a_popup_of_a_link_reaches_the_client_e2e.py", "tests/test_a_popup_reads_the_retail_sizes_of_a_maximized_main_window_e2e.py", "tests/test_a_regional_indicator_pair_measures_the_same_first_and_after_other_families_e2e.py", "tests/test_an_element_handle_serves_every_method_of_the_client_e2e.py", "tests/test_audio_context_values_are_declared_e2e.py", "tests/test_audio_noise_e2e.py", "tests/test_audio_sample_rate_is_declared_e2e.py", "tests/test_bundle_font_names_e2e.py", "tests/test_canvas_create_pattern_projection_e2e.py", "tests/test_canvas_measure_text_metrics_e2e.py", "tests/test_css_media_reads_the_declared_screen_and_pointer_e2e.py", "tests/test_dom_iterables_from_evaluate_e2e.py", "tests/test_every_argument_reaches_the_page_e2e.py", "tests/test_every_reader_of_a_webgl_canvas_agrees_e2e.py", "tests/test_exslt_date_time_through_an_imported_stylesheet_is_in_the_declared_zone_e2e.py", "tests/test_fakeweb_p2_e2e.py", "tests/test_fission_frames_tree_input_and_pixels_e2e.py", "tests/test_focus_survives_os_deactivation_e2e.py", "tests/test_fullscreen_without_wm_e2e.py", "tests/test_geolocation_reads_nothing_of_the_host_windows_e2e.py", "tests/test_goto_and_every_way_it_is_stopped_e2e.py", "tests/test_hardware_values_are_declared_e2e.py", "tests/test_input_reaches_the_top_and_a_frame_of_another_site_at_every_scale_e2e.py", "tests/test_ipv6_literal_connect_e2e.py", "tests/test_moz_element_paints_a_webgl_canvas_as_drawn_e2e.py", "tests/test_native_line_endings_are_windows_e2e.py", "tests/test_nested_frame_actions.py", "tests/test_networkidle_through_a_served_browser_with_routes_e2e.py", "tests/test_nothing_leaves_but_the_proxy_e2e.py", "tests/test_nothing_of_a_context_leaves_but_through_its_proxy_e2e.py", "tests/test_page_element_atoms_run_in_a_sandbox_e2e.py", "tests/test_popup_geometry_is_the_declared_frame_e2e.py", "tests/test_script_cache_written_is_adopted_e2e.py", "tests/test_the_branding_a_page_loads_is_the_declared_archive_e2e.py", "tests/test_the_declared_frame_of_a_window_follows_the_core_owned_display_linux_e2e.py", "tests/test_the_evaluated_code_has_no_debugger_name_e2e.py", "tests/test_the_host_gl_probe_runs_only_on_an_undeclared_engine_linux_e2e.py", "tests/test_the_launch_counter_is_one_plain_get_before_any_page_e2e.py", "tests/test_the_maximized_window_frames_and_popups_read_retail_e2e.py", "tests/test_the_parent_methods_of_the_window_origin_are_not_exposed_to_a_page_e2e.py", "tests/test_the_shutdown_ping_leaves_by_the_background_task_e2e.py", "tests/test_webgl_declared_parameters_e2e.py", "tests/test_webgl_shader_language_e2e.py", "tests/test_webgpu_adapter_is_declared_e2e.py", "tests/test_webgpu_canvas_readback_is_noised_e2e.py", "tests/test_webgpu_external_texture_e2e.py", "tests/test_window_occlusion_e2e.py"], "marker": "e2e", "needs_root": false, "windows_twin": "wrapper.e2e.suite.windows.3", "note": "Part 2 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 2 rows of linux are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 565 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapper.e2e.udp.exit and wrapper.e2e.udp.sandbox (root and user namespaces, their own rows), the files of the round after the publication (tests/_post_publication.py), and the tests that skip on linux (a skip is red in the verdict).", "run": "suite_run"},
|
||||
{"id": "wrapper.e2e.suite.windows.1", "giro": "G2", "os": ["windows"], "min_tests": 332, "exact": true, "tests": ["tests/test_a_click_waits_for_the_navigation_it_plans_e2e.py", "tests/test_a_closed_browser_leaves_the_others_alone_e2e.py", "tests/test_a_context_init_script_runs_once_e2e.py", "tests/test_a_goto_to_a_refused_port_ends_with_its_reason_e2e.py", "tests/test_a_granted_permission_is_the_one_the_page_asks_for_e2e.py", "tests/test_a_held_ice_port_blinds_the_loopback_checks_e2e.py", "tests/test_a_left_documents_body_is_evicted_e2e.py", "tests/test_a_page_cannot_probe_the_juggler_e2e.py", "tests/test_a_screenshot_honours_its_scale_e2e.py", "tests/test_a_screenshot_refuses_what_would_touch_the_page_e2e.py", "tests/test_a_tiny_download_on_a_served_browser_is_saved_e2e.py", "tests/test_a_worker_comes_back_with_its_page_from_the_cache_e2e.py", "tests/test_browser_output_is_drained.py", "tests/test_canvas_create_pattern_projection_e2e.py", "tests/test_click_rhythm.py", "tests/test_closing_one_of_four_browsers_does_not_hold_the_loop_e2e.py", "tests/test_context_locale_e2e.py", "tests/test_context_proxy_only_resolves_by_doh_e2e.py", "tests/test_detectors_e2e.py", "tests/test_download_is_intercepted_e2e.py", "tests/test_e2e.py", "tests/test_element_handle_actions.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_every_reader_of_a_webgl_canvas_agrees_e2e.py", "tests/test_fission_identity_parity_e2e.py", "tests/test_fission_iframe_crash_e2e.py", "tests/test_focus_survives_os_deactivation_e2e.py", "tests/test_geolocation_reads_nothing_of_the_host_windows_e2e.py", "tests/test_goto_to_the_same_url_e2e.py", "tests/test_ignore_https_errors_e2e.py", "tests/test_juggler_actions.py", "tests/test_juggler_transport.py", "tests/test_keyboard_rhythm.py", "tests/test_moz_element_paints_a_webgl_canvas_as_drawn_e2e.py", "tests/test_nested_frame_actions.py", "tests/test_popups_reach_the_client_e2e.py", "tests/test_preload_newtab_turns_the_privileged_about_process_off_e2e.py", "tests/test_route_superseded_e2e.py", "tests/test_scroll_only_if_needed_e2e.py", "tests/test_security_state_engine_e2e.py", "tests/test_service_worker.py", "tests/test_service_workers_blocked.py", "tests/test_strict_and_force.py", "tests/test_the_engine_is_born_in_the_job_e2e.py", "tests/test_the_hosts_file_of_the_host_is_never_read_e2e.py", "tests/test_the_shutdown_ping_leaves_by_the_background_task_e2e.py", "tests/test_trial_does_not_act.py", "tests/test_ua_widget_not_selectable.py", "tests/test_webgpu_canvas_readback_is_noised_e2e.py"], "marker": "e2e", "needs_root": false, "linux_twin": "wrapper.e2e.suite.linux.1", "note": "Part 1 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 4 rows of windows are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 609 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapper.e2e.udp.exit and wrapper.e2e.udp.sandbox (root and user namespaces, their own rows), the files of the round after the publication (tests/_post_publication.py), and the tests that skip on windows (a skip is red in the verdict).", "runner_image": {"windows": "windows-2022"}, "run": "suite_run"},
|
||||
{"id": "wrapper.e2e.suite.windows.2", "giro": "G2", "os": ["windows"], "min_tests": 324, "exact": true, "tests": ["tests/test_a_file_chooser_reaches_every_client_e2e.py", "tests/test_a_goto_to_a_response_with_no_document_ends_e2e.py", "tests/test_a_latin_letter_on_a_cyrillic_persona_e2e.py", "tests/test_a_navigation_that_moved_is_told_by_the_engine_e2e.py", "tests/test_a_press_on_an_open_select_follows_windows_rollup_e2e.py", "tests/test_a_regional_indicator_pair_measures_the_same_first_and_after_other_families_e2e.py", "tests/test_a_select_dropdown_stays_open_after_the_release_e2e.py", "tests/test_a_turn_name_over_tcp_goes_through_the_proxy_of_the_context_e2e.py", "tests/test_add_script_tag.py", "tests/test_an_element_handle_serves_every_method_of_the_client_e2e.py", "tests/test_an_isolated_page_and_the_next_e2e.py", "tests/test_audio_context_values_are_declared_e2e.py", "tests/test_bundle_font_names_e2e.py", "tests/test_caller_world_handles_e2e.py", "tests/test_canvas_reads_as_drawn.py", "tests/test_canvas_render_stealth.py", "tests/test_css_media_reads_the_declared_screen_and_pointer_e2e.py", "tests/test_declared_host_network_e2e.py", "tests/test_every_argument_reaches_the_page_e2e.py", "tests/test_expose_binding_e2e.py", "tests/test_fission_frames_dialogs_downloads_popups_e2e.py", "tests/test_fullscreen_without_wm_e2e.py", "tests/test_goto_networkidle_after_spa_e2e.py", "tests/test_goto_script_redirect_e2e.py", "tests/test_hidden_desktop.py", "tests/test_ice_names_by_the_context_proxy_e2e.py::test_the_ice_name_of_a_context_goes_by_the_proxy_of_that_context", "tests/test_juggler_lifecycle_e2e.py", "tests/test_key_delay_reaches_the_keyboard.py", "tests/test_long_session_e2e.py", "tests/test_mouse.py", "tests/test_native_line_endings_are_windows_e2e.py", "tests/test_navigation_across_processes_e2e.py", "tests/test_networkidle_reaches_the_client_e2e.py", "tests/test_no_popup_is_left_when_a_page_closes_e2e.py", "tests/test_nothing_leaves_but_the_proxy_e2e.py", "tests/test_nothing_of_a_context_leaves_but_through_its_proxy_e2e.py", "tests/test_oop_frame_geometry.py", "tests/test_proxy_socks_auth_e2e.py", "tests/test_resolver_race_e2e.py", "tests/test_route_e2e.py", "tests/test_screencast_stop_e2e.py", "tests/test_the_branding_a_page_loads_is_the_declared_archive_e2e.py", "tests/test_the_device_enumeration_takes_the_declared_time_e2e.py", "tests/test_the_evaluated_code_has_no_debugger_name_e2e.py", "tests/test_the_favicon_stays_out_of_sight_e2e.py", "tests/test_the_font_list_is_the_bundle_e2e.py", "tests/test_the_scheme_is_the_personas_e2e.py", "tests/test_the_whole_udp_chain_by_name_e2e.py::test_a_turn_srflx_by_name_arrives_through_the_relay_when_the_exit_of_the_lab_is_loopback", "tests/test_turn_over_tcp_is_tried_for_real_e2e.py", "tests/test_voices_e2e.py", "tests/test_wait_for_function.py", "tests/test_wait_for_timeout.py", "tests/test_web_fonts_of_closed_contexts_e2e.py", "tests/test_webrtc_realness.py::test_a_gateway_that_is_far_away_still_gives_the_page_a_srflx_born_through_its_relay", "tests/test_webrtc_realness.py::test_a_gather_after_the_page_loaded_through_the_gateway_costs_only_the_road_to_the_server", "tests/test_webrtc_realness.py::test_a_host_with_ipv6_addresses_gathers_through_an_ipv4_relay", "tests/test_webrtc_realness.py::test_a_proxy_that_does_not_relay_udp_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_a_proxy_whose_relay_never_answers_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_a_proxy_whose_udp_leaves_from_another_address_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_not_blocked_behind_tcp_only_socks", "tests/test_webrtc_realness.py::test_the_first_candidate_of_a_gather_does_not_wait_for_a_gateway_that_is_far_away", "tests/test_webrtc_realness.py::test_the_turn_over_tcp_of_a_context_goes_through_the_proxy_of_that_context", "tests/test_webrtc_realness.py::test_two_contexts_with_two_proxies_each_gets_the_srflx_of_its_own"], "marker": "e2e", "needs_root": false, "linux_twin": "wrapper.e2e.suite.linux.2", "note": "Part 2 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 4 rows of windows are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 610 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapper.e2e.udp.exit and wrapper.e2e.udp.sandbox (root and user namespaces, their own rows), the files of the round after the publication (tests/_post_publication.py), and the teLine truncated
|
||||
{"id": "wrapper.e2e.suite.windows.3", "giro": "G2", "os": ["windows"], "min_tests": 278, "exact": true, "tests": ["tests/test_a_click_in_an_iframe_lands_at_the_frames_own_screen_origin_e2e.py", "tests/test_a_context_that_ends_leaves_no_process_e2e.py", "tests/test_a_cors_preflight_is_not_a_request_of_the_page_e2e.py", "tests/test_a_launch_without_a_session_gets_one_e2e.py", "tests/test_a_mouse_click_makes_one_mousemove_on_its_point_e2e.py", "tests/test_a_page_over_ipv6_gathers_on_a_machine_declared_without_it_e2e.py", "tests/test_a_served_browser_answers_a_plain_client_e2e.py", "tests/test_actions_without_a_point.py", "tests/test_audio_noise_e2e.py", "tests/test_audio_sample_rate_is_declared_e2e.py", "tests/test_bypass_csp_e2e.py", "tests/test_control_a_selects_all_in_a_field_e2e.py", "tests/test_cross_origin_iframe.py", "tests/test_dom_iterables_from_evaluate_e2e.py", "tests/test_drag_motion.py", "tests/test_element_screenshot_e2e.py", "tests/test_fakeweb_p4_e2e.py", "tests/test_fingerprint_consistency.py", "tests/test_first_launch_from_a_new_path.py", "tests/test_fission_frames_history_and_processes_e2e.py", "tests/test_fission_frames_workers_storage_and_special_frames_e2e.py", "tests/test_fission_strategy1_bench.py", "tests/test_goto_and_every_way_it_is_stopped_e2e.py", "tests/test_http3_through_the_proxy_e2e.py", "tests/test_input_is_born_before_the_page_sees_it_e2e.py", "tests/test_ipv6_literal_connect_e2e.py", "tests/test_networkidle_through_a_served_browser_with_routes_e2e.py", "tests/test_page_number_follows_the_call.py", "tests/test_persistent_profile_keeps_state.py", "tests/test_pointer_position.py", "tests/test_popup_destinations_e2e.py", "tests/test_popup_pages.py", "tests/test_proxy_http_auth_e2e.py", "tests/test_requestless_navigation.py", "tests/test_route_abort_code.py", "tests/test_route_post_data_e2e.py", "tests/test_same_document_navigation.py", "tests/test_screencast.py", "tests/test_screenshot_looks_where_you_are.py", "tests/test_service_worker_controller_e2e.py", "tests/test_set_input_files_payloads.py", "tests/test_set_offline_e2e.py", "tests/test_the_callers_code_is_not_counted_e2e.py", "tests/test_the_callers_code_runs_once_e2e.py", "tests/test_the_close_returns_when_the_browser_has_exited_e2e.py", "tests/test_the_launch_counter_is_one_plain_get_before_any_page_e2e.py", "tests/test_webgl_declared_parameters_e2e.py", "tests/test_webgl_shader_language_e2e.py", "tests/test_webgpu_adapter_is_declared_e2e.py", "tests/test_webgpu_external_texture_e2e.py"], "marker": "e2e", "needs_root": false, "linux_twin": "wrapper.e2e.suite.linux.1", "note": "Part 3 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 4 rows of windows are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 610 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapper.e2e.udp.exit and wrapper.e2e.udp.sandbox (root and user namespaces, their own rows), the files of the round after the publication (tests/_post_publication.py), and the tests that skip on windows (a skip is red in the verdict).", "runner_image": {"windows": "windows-2022"}, "run": "suite_run"},
|
||||
{"id": "wrapper.e2e.suite.windows.4", "giro": "G2", "os": ["windows"], "min_tests": 334, "exact": true, "tests": ["tests/test_a_context_language_is_the_accept_language_of_every_request_e2e.py", "tests/test_a_declared_webgl_extension_survives_its_use_e2e.py", "tests/test_a_drag_keeps_its_buttons_pressed_e2e.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_frame_reads_only_declared_origins_while_it_loads_e2e.py", "tests/test_a_handle_action_walks_like_a_selector_action_e2e.py", "tests/test_a_keepalive_request_reaches_the_client_e2e.py", "tests/test_a_launch_and_a_context_timezone_reach_the_page_e2e.py", "tests/test_a_page_that_moves_on_e2e.py", "tests/test_a_pointer_event_is_handled_before_the_call_returns_e2e.py", "tests/test_a_popup_is_reported_when_the_engine_says_it_is_ready_as_playwright_does_e2e.py", "tests/test_a_popup_moves_and_resizes_as_declared_e2e.py", "tests/test_a_popup_of_a_link_reaches_the_client_e2e.py", "tests/test_a_popup_reads_the_retail_sizes_of_a_maximized_main_window_e2e.py", "tests/test_a_request_says_what_it_is_e2e.py", "tests/test_a_screenshot_draws_the_text_of_the_bundled_fonts_as_the_content_does_e2e.py", "tests/test_accept_language_on_the_wire_e2e.py", "tests/test_canvas_measure_text_metrics_e2e.py", "tests/test_doh_through_the_proxy_e2e.py", "tests/test_doh_under_stress_e2e.py", "tests/test_exslt_date_time_through_an_imported_stylesheet_is_in_the_declared_zone_e2e.py", "tests/test_fakeweb_p2_e2e.py", "tests/test_file_chooser.py", "tests/test_fingerprint_surface.py", "tests/test_fission_frames_route_and_bindings_e2e.py", "tests/test_fission_frames_tree_input_and_pixels_e2e.py", "tests/test_frames_outlive_the_back_forward_cache_e2e.py", "tests/test_hardware_values_are_declared_e2e.py", "tests/test_injected_node_surface.py", "tests/test_input_reaches_the_top_and_a_frame_of_another_site_at_every_scale_e2e.py", "tests/test_juggler_connection.py", "tests/test_juggler_event_listeners.py", "tests/test_juggler_injected.py::test_a_javascript_that_THROWS_arrives_as_an_error_not_as_None", "tests/test_juggler_injected.py::test_actionability_DISTINGUISHES_instead_of_always_saying_yes", "tests/test_juggler_injected.py::test_reads_that_make_no_sense_are_REJECTED", "tests/test_juggler_injected.py::test_states_DISCRIMINATE_instead_of_always_saying_true", "tests/test_juggler_injected.py::test_the_DOM_READING_group", "tests/test_juggler_injected.py::test_the_selector_engines_respond", "tests/test_juggler_injected.py::test_the_text_reads", "tests/test_mouse_events_keep_their_values_e2e.py", "tests/test_navigation_response.py", "tests/test_new_page_defaults.py", "tests/test_oop_frame_element.py", "tests/test_page_element_atoms_run_in_a_sandbox_e2e.py", "tests/test_popup_geometry_is_the_declared_frame_e2e.py", "tests/test_proxy_reaches_the_browser.py", "tests/test_realness_behind_a_declared_exit_e2e.py", "tests/test_route_header_order_e2e.py", "tests/test_route_sends_a_navigation_elsewhere_e2e.py", "tests/test_same_document_goto_e2e.py", "tests/test_script_cache_written_is_adopted_e2e.py", "tests/test_scroll_into_view.py", "tests/test_shadow_trusted_input.py", "tests/test_software_compositing_is_declared_e2e.py", "tests/test_the_association_is_ready_when_the_peerconnection_is_born_e2e.py", "tests/test_the_maximized_window_frames_and_popups_read_retail_e2e.py", "tests/test_the_parent_methods_of_the_window_origin_are_not_exposed_to_a_page_e2e.py", "tests/test_typing_a_character_without_a_key_e2e.py", "tests/test_webgl_noise_active.py", "tests/test_window_occlusion_e2e.py"], "marker": "e2e", "needs_root": false, "linux_twin": "wrapper.e2e.suite.linux.2", "note": "Part 4 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 4 rows of windows are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 609 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapper.e2e.udp.exit and wrapper.e2e.udp.sandbox (root and user namespaces, their own rows), the files of the round after the publication (tests/_post_publication.py), and the tests that skip on windows (a skip is red in the verdict).", "runner_image": {"windows": "windows-2022"}, "run": "suite_run"},
|
||||
{"id": "wrapper.e2e.suite.windows.2", "giro": "G2", "os": ["windows"], "min_tests": 327, "exact": true, "tests": ["tests/test_a_click_under_the_login_autocomplete_list_reaches_the_page_e2e.py", "tests/test_a_file_chooser_reaches_every_client_e2e.py", "tests/test_a_goto_to_a_response_with_no_document_ends_e2e.py", "tests/test_a_latin_letter_on_a_cyrillic_persona_e2e.py", "tests/test_a_navigation_that_moved_is_told_by_the_engine_e2e.py", "tests/test_a_press_on_an_open_select_follows_windows_rollup_e2e.py", "tests/test_a_regional_indicator_pair_measures_the_same_first_and_after_other_families_e2e.py", "tests/test_a_select_dropdown_stays_open_after_the_release_e2e.py", "tests/test_a_turn_name_over_tcp_goes_through_the_proxy_of_the_context_e2e.py", "tests/test_add_script_tag.py", "tests/test_an_element_handle_serves_every_method_of_the_client_e2e.py", "tests/test_an_isolated_page_and_the_next_e2e.py", "tests/test_audio_context_values_are_declared_e2e.py", "tests/test_bundle_font_names_e2e.py", "tests/test_caller_world_handles_e2e.py", "tests/test_canvas_reads_as_drawn.py", "tests/test_canvas_render_stealth.py", "tests/test_css_media_reads_the_declared_screen_and_pointer_e2e.py", "tests/test_declared_host_network_e2e.py", "tests/test_every_argument_reaches_the_page_e2e.py", "tests/test_expose_binding_e2e.py", "tests/test_fission_frames_dialogs_downloads_popups_e2e.py", "tests/test_fullscreen_without_wm_e2e.py", "tests/test_goto_networkidle_after_spa_e2e.py", "tests/test_goto_script_redirect_e2e.py", "tests/test_hidden_desktop.py", "tests/test_ice_names_by_the_context_proxy_e2e.py::test_the_ice_name_of_a_context_goes_by_the_proxy_of_that_context", "tests/test_juggler_lifecycle_e2e.py", "tests/test_key_delay_reaches_the_keyboard.py", "tests/test_long_session_e2e.py", "tests/test_mouse.py", "tests/test_native_line_endings_are_windows_e2e.py", "tests/test_navigation_across_processes_e2e.py", "tests/test_networkidle_reaches_the_client_e2e.py", "tests/test_no_popup_is_left_when_a_page_closes_e2e.py", "tests/test_nothing_leaves_but_the_proxy_e2e.py", "tests/test_nothing_of_a_context_leaves_but_through_its_proxy_e2e.py", "tests/test_oop_frame_geometry.py", "tests/test_proxy_socks_auth_e2e.py", "tests/test_resolver_race_e2e.py", "tests/test_route_e2e.py", "tests/test_screencast_stop_e2e.py", "tests/test_the_branding_a_page_loads_is_the_declared_archive_e2e.py", "tests/test_the_device_enumeration_takes_the_declared_time_e2e.py", "tests/test_the_evaluated_code_has_no_debugger_name_e2e.py", "tests/test_the_favicon_stays_out_of_sight_e2e.py", "tests/test_the_font_list_is_the_bundle_e2e.py", "tests/test_the_scheme_is_the_personas_e2e.py", "tests/test_the_whole_udp_chain_by_name_e2e.py::test_a_turn_srflx_by_name_arrives_through_the_relay_when_the_exit_of_the_lab_is_loopback", "tests/test_turn_over_tcp_is_tried_for_real_e2e.py", "tests/test_voices_e2e.py", "tests/test_wait_for_function.py", "tests/test_wait_for_timeout.py", "tests/test_web_fonts_of_closed_contexts_e2e.py", "tests/test_webrtc_realness.py::test_a_gateway_that_is_far_away_still_gives_the_page_a_srflx_born_through_its_relay", "tests/test_webrtc_realness.py::test_a_gather_after_the_page_loaded_through_the_gateway_costs_only_the_road_to_the_server", "tests/test_webrtc_realness.py::test_a_host_with_ipv6_addresses_gathers_through_an_ipv4_relay", "tests/test_webrtc_realness.py::test_a_proxy_that_does_not_relay_udp_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_a_proxy_whose_relay_never_answers_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_a_proxy_whose_udp_leaves_from_another_address_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_not_blocked_behind_tcp_only_socks", "tests/test_webrtc_realness.py::test_the_first_candidate_of_a_gather_does_not_wait_for_a_gateway_that_is_far_away", "tests/test_webrtc_realness.py::test_the_turn_over_tcp_of_a_context_goes_through_the_proxy_of_that_context", "tests/test_webrtc_realness.py::test_two_contexts_with_two_proxies_each_gets_the_srflx_of_its_own"], "marker": "e2e", "needs_root": false, "linux_twin": "wrapper.e2e.suite.linux.2", "note": "Part 2 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 4 rows of windows are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 610 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapper.e2e.udp.exit and wrapper.e2e.udp.sandbox (root and user namespaces, their own rows), the fLine truncated
|
||||
{"id": "wrapper.e2e.suite.windows.3", "giro": "G2", "os": ["windows"], "min_tests": 299, "exact": true, "tests": ["tests/test_a_click_in_an_iframe_lands_at_the_frames_own_screen_origin_e2e.py", "tests/test_a_context_that_ends_leaves_no_process_e2e.py", "tests/test_a_cors_preflight_is_not_a_request_of_the_page_e2e.py", "tests/test_a_launch_without_a_session_gets_one_e2e.py", "tests/test_a_mouse_click_makes_one_mousemove_on_its_point_e2e.py", "tests/test_a_page_function_called_by_the_client_sees_only_page_frames_e2e.py", "tests/test_a_page_over_ipv6_gathers_on_a_machine_declared_without_it_e2e.py", "tests/test_a_page_sees_no_pointer_event_before_the_first_input_on_the_hidden_display_e2e.py", "tests/test_a_pages_own_hasinstance_is_never_called_while_the_client_listens_to_console_e2e.py", "tests/test_a_password_field_is_as_wide_as_on_retail_windows_e2e.py", "tests/test_a_served_browser_answers_a_plain_client_e2e.py", "tests/test_actions_without_a_point.py", "tests/test_audio_noise_e2e.py", "tests/test_audio_sample_rate_is_declared_e2e.py", "tests/test_bypass_csp_e2e.py", "tests/test_control_a_selects_all_in_a_field_e2e.py", "tests/test_cross_origin_iframe.py", "tests/test_dom_iterables_from_evaluate_e2e.py", "tests/test_drag_motion.py", "tests/test_element_screenshot_e2e.py", "tests/test_fakeweb_p4_e2e.py", "tests/test_fingerprint_consistency.py", "tests/test_first_launch_from_a_new_path.py", "tests/test_fission_frames_history_and_processes_e2e.py", "tests/test_fission_frames_workers_storage_and_special_frames_e2e.py", "tests/test_fission_strategy1_bench.py", "tests/test_goto_and_every_way_it_is_stopped_e2e.py", "tests/test_http3_through_the_proxy_e2e.py", "tests/test_input_is_born_before_the_page_sees_it_e2e.py", "tests/test_ipv6_literal_connect_e2e.py", "tests/test_networkidle_through_a_served_browser_with_routes_e2e.py", "tests/test_page_number_follows_the_call.py", "tests/test_persistent_profile_keeps_state.py", "tests/test_pointer_position.py", "tests/test_popup_destinations_e2e.py", "tests/test_popup_pages.py", "tests/test_proxy_http_auth_e2e.py", "tests/test_requestless_navigation.py", "tests/test_route_abort_code.py", "tests/test_route_post_data_e2e.py", "tests/test_same_document_navigation.py", "tests/test_screencast.py", "tests/test_screenshot_looks_where_you_are.py", "tests/test_service_worker_controller_e2e.py", "tests/test_set_input_files_payloads.py", "tests/test_set_offline_e2e.py", "tests/test_the_callers_code_is_not_counted_e2e.py", "tests/test_the_callers_code_runs_once_e2e.py", "tests/test_the_close_returns_when_the_browser_has_exited_e2e.py", "tests/test_the_launch_counter_is_one_plain_get_before_any_page_e2e.py", "tests/test_webgl_declared_parameters_e2e.py", "tests/test_webgl_shader_language_e2e.py", "tests/test_webgpu_adapter_is_declared_e2e.py", "tests/test_webgpu_external_texture_e2e.py"], "marker": "e2e", "needs_root": false, "linux_twin": "wrapper.e2e.suite.linux.1", "note": "Part 3 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 4 rows of windows are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 610 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapper.e2e.udp.exit and wrapper.e2e.udp.sandbox (root and user namespaces, their own rows), the files of the round after the publication (tests/_post_publication.py), and the tests that skip on windows (a skip is red in the verdict).", "runner_image": {"windows": "windows-2022"}, "run": "suite_run"},
|
||||
{"id": "wrapper.e2e.suite.windows.4", "giro": "G2", "os": ["windows"], "min_tests": 340, "exact": true, "tests": ["tests/test_a_context_language_is_the_accept_language_of_every_request_e2e.py", "tests/test_a_declared_webgl_extension_survives_its_use_e2e.py", "tests/test_a_drag_keeps_its_buttons_pressed_e2e.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_frame_reads_only_declared_origins_while_it_loads_e2e.py", "tests/test_a_handle_action_walks_like_a_selector_action_e2e.py", "tests/test_a_keepalive_request_reaches_the_client_e2e.py", "tests/test_a_launch_and_a_context_timezone_reach_the_page_e2e.py", "tests/test_a_page_that_moves_on_e2e.py", "tests/test_a_pointer_event_is_handled_before_the_call_returns_e2e.py", "tests/test_a_popup_is_reported_when_the_engine_says_it_is_ready_as_playwright_does_e2e.py", "tests/test_a_popup_moves_and_resizes_as_declared_e2e.py", "tests/test_a_popup_of_a_link_reaches_the_client_e2e.py", "tests/test_a_popup_reads_the_retail_sizes_of_a_maximized_main_window_e2e.py", "tests/test_a_request_says_what_it_is_e2e.py", "tests/test_a_screenshot_draws_the_text_of_the_bundled_fonts_as_the_content_does_e2e.py", "tests/test_accept_language_on_the_wire_e2e.py", "tests/test_canvas_measure_text_metrics_e2e.py", "tests/test_doh_through_the_proxy_e2e.py", "tests/test_doh_under_stress_e2e.py", "tests/test_exslt_date_time_through_an_imported_stylesheet_is_in_the_declared_zone_e2e.py", "tests/test_fakeweb_p2_e2e.py", "tests/test_file_chooser.py", "tests/test_fingerprint_surface.py", "tests/test_fission_frames_route_and_bindings_e2e.py", "tests/test_fission_frames_tree_input_and_pixels_e2e.py", "tests/test_frames_outlive_the_back_forward_cache_e2e.py", "tests/test_hardware_values_are_declared_e2e.py", "tests/test_injected_node_surface.py", "tests/test_input_reaches_the_top_and_a_frame_of_another_site_at_every_scale_e2e.py", "tests/test_juggler_connection.py", "tests/test_juggler_event_listeners.py", "tests/test_juggler_injected.py::test_a_javascript_that_THROWS_arrives_as_an_error_not_as_None", "tests/test_juggler_injected.py::test_actionability_DISTINGUISHES_instead_of_always_saying_yes", "tests/test_juggler_injected.py::test_reads_that_make_no_sense_are_REJECTED", "tests/test_juggler_injected.py::test_states_DISCRIMINATE_instead_of_always_saying_true", "tests/test_juggler_injected.py::test_the_DOM_READING_group", "tests/test_juggler_injected.py::test_the_selector_engines_respond", "tests/test_juggler_injected.py::test_the_text_reads", "tests/test_mouse_events_keep_their_values_e2e.py", "tests/test_navigation_response.py", "tests/test_new_page_defaults.py", "tests/test_oop_frame_element.py", "tests/test_page_element_atoms_run_in_a_sandbox_e2e.py", "tests/test_popup_geometry_is_the_declared_frame_e2e.py", "tests/test_proxy_reaches_the_browser.py", "tests/test_realness_behind_a_declared_exit_e2e.py", "tests/test_route_header_order_e2e.py", "tests/test_route_sends_a_navigation_elsewhere_e2e.py", "tests/test_same_document_goto_e2e.py", "tests/test_script_cache_written_is_adopted_e2e.py", "tests/test_scroll_into_view.py", "tests/test_shadow_trusted_input.py", "tests/test_software_compositing_is_declared_e2e.py", "tests/test_the_association_is_ready_when_the_peerconnection_is_born_e2e.py", "tests/test_the_maximized_window_frames_and_popups_read_retail_e2e.py", "tests/test_the_parent_methods_of_the_window_origin_are_not_exposed_to_a_page_e2e.py", "tests/test_typing_a_character_without_a_key_e2e.py", "tests/test_webgl_noise_active.py", "tests/test_window_occlusion_e2e.py"], "marker": "e2e", "needs_root": false, "linux_twin": "wrapper.e2e.suite.linux.2", "note": "Part 4 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 4 rows of windows are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 609 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapper.e2e.udp.exit and wrapper.e2e.udp.sandbox (root and user namespaces, their own rows), the files of the round after the publication (tests/_post_publication.py), and the tests that skip on windows (a skip is red in the verdict).", "runner_image": {"windows": "windows-2022"}, "run": "suite_run"},
|
||||
{"id": "wrapper.e2e.suite.windows.control_a", "giro": "G2", "os": ["windows"], "min_tests": 20, "exact": true, "tests": ["tests/test_control_a_selects_all_in_a_field_e2e.py"], "marker": "e2e", "needs_root": false, "linux_twin": "wrapper.e2e.suite.linux.1", "note": "The keyboard shortcut Control+A selects all in a field (5 ways to press it x an input and a textarea, in-process and served to the stock client), alone on its own Windows runner (windows-latest), as e2e.yml runs it on the published engine: the Windows keyboard of a real user is what it needs. The same file is in one of wrapper.e2e.suite.windows.1..4 and in wrapper.e2e.suite.linux.1.", "run": "suite_run"},
|
||||
{"id": "wrapper.e2e.ab_oracle", "giro": "G2", "os": ["linux", "windows"], "min_tests": 1, "exact": true, "tests": ["tests/test_ab_oracle_e2e.py"], "marker": "e2e", "needs_root": false, "note": "Same seed, same bytes: the engine of the published set (the last published engine, with its own core and wrapper) against the candidate (with core_ref and wrapper_ref), on one machine, after the control: the published engine against ITSELF (the A/A; a difference is a broken control, exit 2, and the A/B is not run). On a pull request (no candidate: INVPW_BINARY_PATH is the published engine, no INVISIBLE_SEAL_FILE) the A/A is the whole test, on the first two seeds of the candidate set (all five when the pull request changes a file of this oracle: the step of e2e.yml that runs scripts/ci_ab_pr_seeds.py exports AB_ORACLE_PR_SEEDS), and saves both dumps and the diff under $AB_ORACLE_OUT or $RUNNER_TEMP/invpw-evidence/ab-oracle. scripts/ci_ab_oracle.py runs the host gate's dump (scripts/ci_host_gate.py dump: the persona seeds of ci/persona-seeds.json, each at its own DPR with nothing pinned, the whole page of scripts/host_gate; the `candidate` set of 5 seeds that reach every webgl renderer and every DPR, or with AB_ORACLE_SEED_SET=final and AB_ORACLE_SHARD=i/n the 20 seeds that reach every value of every dimension split over n jobs) twice, once with the published engine (fetched by the published set's own core under its own seal, which checks the archive's sha256, and dumped in that set's venv) and once with the candidate binary of the leg under its own seal, and compares every leaf of every visit: the only differences allowed are the `noise` entries of scripts/host_gate/exceptions.json and the diag. keys; anything else is red with the leaf, the two values and the seed; fewer leaves than the host gate's reference holds (16439 per visit; a DPR the reference does not record is held to the least of those it does) is red. The files (dump-<N>.json, dump-<N>-again.json for the tag of the published set, diff-a-a.json and, with a candidate, dump-candidate.json and diff.json) are the artifact ab-oracle-<os> of the leg. 1 = the one test; the comparator's own cases (51, the A/A's among them) are in tests/test_ab_oracle.py, the persona seeds' (15) in tests/test_persona_cover.py, in the rows of the whole unit suite. Needs the engine's binary (INVPW_BINARY_PATH) and, for the A/B, the candidate's seal (INVISIBLE_SEAL_FILE) and the network (the release assets of the published engine, and INVPW_PUBLISHED_PYTHON). Each engine runs with the core it was built for: a core that declares less than the published engine requires is no longer a red of this suite (it was: engine candidate 5, every A/B a broken control). THE CONTROL IS THE PUBLISHED SET, as a user installs it: the last invisible-playwright on the index, the invisible-core it pins exactly and the engine that core's seal pins, in a venv of their own (ci/py-lock/published.txt, installed by hash from the run's wheelhouse; scripts/ci_published_set.py; INVPW_PUBLISHED_PYTHON is its python). The candidate's side is the candidate engine with core_ref and wrapper_ref. No tag is written in a harness file.", "timeout_minutes": 50, "core_dumps": "cores", "extra_steps": ["keep_oracle_files"], "artifact": "ab-oracle"},
|
||||
{"id": "wrapper.e2e.ab_network", "giro": "G2", "os": ["linux", "windows"], "min_tests": 1, "exact": true, "tests": ["tests/test_ab_network_e2e.py"], "marker": "e2e", "needs_root": false, "note": "Network A/B oracle: the P4 journey, HTTPS h1/h2 (ClientHello, h2 frames, header order), HTTP/3 (transport parameters, H3 SETTINGS), WebRTC through the coherent SOCKS5 lab gateway, DNS through the fake DoH, and an idle launch; transcripts compared leaf by leaf, direct connections red on either side. A/A first (the published engine twice: a difference is a broken control; ci/ab-network-volatile.json holds the leaves the A/A proved volatile, and may only shrink), then the published engine against the candidate. Without a candidate (a PR's e2e) the A/A alone, on the first seed (all five when the pull request changes a file of this oracle: AB_NETWORK_PR_SEEDS), in jobs of its own in e2e.yml on Linux and on Windows (the shared e2e jobs leave this file out). THE CONTROL IS THE PUBLISHED SET, as a user installs it: the last invisible-playwright on the index, the invisible-core it pins exactly and the engine that core's seal pins, in a venv of their own (ci/py-lock/published.txt, installed by hash from the run's wheelhouse; scripts/ci_published_set.py; INVPW_PUBLISHED_PYTHON is its python). The candidate's side is the candidate engine with core_ref and wrapper_ref. No tag is written in a harness file.", "timeout_minutes": 75, "core_dumps": "cores", "extra_steps": ["keep_oracle_files"]},
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"about": "What retail Firefox on Windows reads on a password field in the page tests/data/password_mask_page.html (the width of 40 x 'a' in Arial 16px, which is 40 times the advance of the mask character), extracted by scripts/extract_retail_password_mask.py. Never edited by hand.",
|
||||
"capture": {
|
||||
"folder": "captures/firefox-159.0/windows-server-2025/password-mask/2026-12-02",
|
||||
"retail_captures_commit": "e81da117a01c8d05b00beb62cd544dc057d40f85",
|
||||
"run": "https://github.com/oss-invisible/core/actions/runs/46769343558",
|
||||
"browser": {
|
||||
"firefox_version": "159.0",
|
||||
"build_id": "20261022150525",
|
||||
"installer_sha256": "8776887b79925abbdd407fcdfe257d8382b54e24be52a6466426b95a804d6790",
|
||||
"firefox_exe_sha256": "d8b5ed82fcd9c0f159dc86dc1c4526ceae981c4d9651f21908b6de90d0a56d85",
|
||||
"xul_dll_sha256": "fec21f3e7c281c836ff4fb9658bf321857e101750bc4a6280d1b419996ce7e29"
|
||||
},
|
||||
"host": {
|
||||
"runner_image": "windows-2025",
|
||||
"os_version": "10.0.26100",
|
||||
"os_ubr": "33828"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
{
|
||||
"path": "result.json",
|
||||
"sha256": "980ac7f4ee06ffeef80c3aa3ddb594216b30c4b221b43156b1fa39f92153571a"
|
||||
},
|
||||
{
|
||||
"path": "meta.json",
|
||||
"sha256": "3ecefececdca063d84b48f7bb8905039077356b5c6c46e59e2a7551e1bdaf2ad"
|
||||
}
|
||||
],
|
||||
"page": {
|
||||
"path": "tests/data/password_mask_page.html",
|
||||
"sha256": "4b0c454f723392003e75325036effc576627a71f29c8d82cb01033a963e8de2a"
|
||||
},
|
||||
"n": 40,
|
||||
"cases": {
|
||||
"arial16": {
|
||||
"password_scrollWidth": 387,
|
||||
"mask": "U+25CF",
|
||||
"devicePixelRatio": 1,
|
||||
"platform": "Win32"
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,541 @@
|
||||
{
|
||||
"about": "What retail Firefox reads in a popup opened from a maximized main window, per display case and feature string, extracted by scripts/extract_retail_popup_sizes.py. Never edited by hand.",
|
||||
"capture": {
|
||||
"round": "2026-12-01-window-geometry-r12",
|
||||
"run": "https://github.com/oss-invisible/core/actions/runs/46545487209",
|
||||
"retail_captures_commit": "ef2250dee8704d3023c36661e39ea9525fe41a04",
|
||||
"browser": {
|
||||
"firefox_version": "159.0",
|
||||
"build_id": "20261022150525",
|
||||
"installer_sha256": "8776887b79925abbdd407fcdfe257d8382b54e24be52a6466426b95a804d6790"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
{
|
||||
"path": "dpr1/1920x1080/a/raw.json",
|
||||
"sha256": "1e4413e6e06ff1a8fc49eba8d87cd2c1e3642550bd67242fcd8ebd03777baf6a"
|
||||
},
|
||||
{
|
||||
"path": "dpr1/1920x1080/b/raw.json",
|
||||
"sha256": "ee2d4d2b60dea8e56450fca62446a5c3135e358b6f47ead030b55eea174a35a8"
|
||||
},
|
||||
{
|
||||
"path": "dpr1.25/1920x1080/a/raw.json",
|
||||
"sha256": "440d03adc9782905764e34e983c202f816d79059e81f298316e7a0d9d19f29ab"
|
||||
},
|
||||
{
|
||||
"path": "dpr1.25/1920x1080/b/raw.json",
|
||||
"sha256": "4110bbc9b49f5f5c47b340b4a3e6f91328fe14f10247f888fbb301f9f3ff6f80"
|
||||
},
|
||||
{
|
||||
"path": "dpr1.5/1920x1080/a/raw.json",
|
||||
"sha256": "69ba9333f235aab0cf6ef86ddf14f076d67e23aec22616b5a95dabd67680a19f"
|
||||
},
|
||||
{
|
||||
"path": "dpr1.5/1920x1080/b/raw.json",
|
||||
"sha256": "ac9200c9ed122b35ba448149f08e2a560b868e80e20fa92fc2864a3b3856a1f3"
|
||||
},
|
||||
{
|
||||
"path": "dpr2/1600x1200/a/raw.json",
|
||||
"sha256": "947921aac122dd18dab3227b83b47146a9016ac5591adaa956a6bd11d9c3aa64"
|
||||
},
|
||||
{
|
||||
"path": "dpr2/1600x1200/b/raw.json",
|
||||
"sha256": "7566628ff7822d7de6d9233cb4d2e94e3d129fd79df6920dd39cee3c96c07dac"
|
||||
}
|
||||
],
|
||||
"csv_checked": {
|
||||
"path": "WINDOW_GEOMETRY_POPUP_FRAME.csv",
|
||||
"sha256": "205b2f62aa4d721967a011738fefb505e6a09bfc79e014d2479010756ed2ea77"
|
||||
},
|
||||
"cases": {
|
||||
"1920x1080-dpr1.0": {
|
||||
"width=500,height=400": {
|
||||
"inner": [
|
||||
500,
|
||||
400
|
||||
],
|
||||
"outer": [
|
||||
516,
|
||||
480
|
||||
],
|
||||
"screen": [
|
||||
4,
|
||||
4
|
||||
],
|
||||
"vv_height": 400
|
||||
},
|
||||
"popup": {
|
||||
"inner": [
|
||||
1920,
|
||||
968
|
||||
],
|
||||
"outer": [
|
||||
1936,
|
||||
1048
|
||||
],
|
||||
"screen": [
|
||||
-8,
|
||||
-8
|
||||
],
|
||||
"vv_height": 968
|
||||
},
|
||||
"width=500": {
|
||||
"inner": [
|
||||
500,
|
||||
856
|
||||
],
|
||||
"outer": [
|
||||
516,
|
||||
936
|
||||
],
|
||||
"screen": [
|
||||
4,
|
||||
4
|
||||
],
|
||||
"vv_height": 856
|
||||
},
|
||||
"height=400": {
|
||||
"inner": [
|
||||
1280,
|
||||
400
|
||||
],
|
||||
"outer": [
|
||||
1296,
|
||||
480
|
||||
],
|
||||
"screen": [
|
||||
4,
|
||||
4
|
||||
],
|
||||
"vv_height": 400
|
||||
},
|
||||
"width=300,height=200": {
|
||||
"inner": [
|
||||
300,
|
||||
200
|
||||
],
|
||||
"outer": [
|
||||
316,
|
||||
280
|
||||
],
|
||||
"screen": [
|
||||
4,
|
||||
4
|
||||
],
|
||||
"vv_height": 200
|
||||
},
|
||||
"width=800,height=600": {
|
||||
"inner": [
|
||||
800,
|
||||
600
|
||||
],
|
||||
"outer": [
|
||||
816,
|
||||
680
|
||||
],
|
||||
"screen": [
|
||||
4,
|
||||
4
|
||||
],
|
||||
"vv_height": 600
|
||||
},
|
||||
"left=100,top=100": {
|
||||
"inner": [
|
||||
1280,
|
||||
856
|
||||
],
|
||||
"outer": [
|
||||
1296,
|
||||
936
|
||||
],
|
||||
"screen": [
|
||||
100,
|
||||
96
|
||||
],
|
||||
"vv_height": 856
|
||||
},
|
||||
"left=5000,top=5000": {
|
||||
"inner": [
|
||||
1280,
|
||||
856
|
||||
],
|
||||
"outer": [
|
||||
1296,
|
||||
936
|
||||
],
|
||||
"screen": [
|
||||
624,
|
||||
96
|
||||
],
|
||||
"vv_height": 856
|
||||
}
|
||||
},
|
||||
"1920x1080-dpr1.25": {
|
||||
"width=500,height=400": {
|
||||
"inner": [
|
||||
500,
|
||||
400
|
||||
],
|
||||
"outer": [
|
||||
514,
|
||||
478
|
||||
],
|
||||
"screen": [
|
||||
3,
|
||||
3
|
||||
],
|
||||
"vv_height": 400
|
||||
},
|
||||
"popup": {
|
||||
"inner": [
|
||||
1536,
|
||||
752
|
||||
],
|
||||
"outer": [
|
||||
1550,
|
||||
830
|
||||
],
|
||||
"screen": [
|
||||
-7,
|
||||
-7
|
||||
],
|
||||
"vv_height": 752
|
||||
},
|
||||
"width=500": {
|
||||
"inner": [
|
||||
500,
|
||||
662
|
||||
],
|
||||
"outer": [
|
||||
514,
|
||||
741
|
||||
],
|
||||
"screen": [
|
||||
3,
|
||||
3
|
||||
],
|
||||
"vv_height": 662.4000244140625
|
||||
},
|
||||
"height=400": {
|
||||
"inner": [
|
||||
1280,
|
||||
401
|
||||
],
|
||||
"outer": [
|
||||
1294,
|
||||
479
|
||||
],
|
||||
"screen": [
|
||||
3,
|
||||
3
|
||||
],
|
||||
"vv_height": 400.79998779296875
|
||||
},
|
||||
"width=300,height=200": {
|
||||
"inner": [
|
||||
300,
|
||||
200
|
||||
],
|
||||
"outer": [
|
||||
314,
|
||||
278
|
||||
],
|
||||
"screen": [
|
||||
3,
|
||||
3
|
||||
],
|
||||
"vv_height": 200
|
||||
},
|
||||
"width=800,height=600": {
|
||||
"inner": [
|
||||
800,
|
||||
600
|
||||
],
|
||||
"outer": [
|
||||
814,
|
||||
678
|
||||
],
|
||||
"screen": [
|
||||
3,
|
||||
3
|
||||
],
|
||||
"vv_height": 600
|
||||
},
|
||||
"left=100,top=100": {
|
||||
"inner": [
|
||||
1280,
|
||||
662
|
||||
],
|
||||
"outer": [
|
||||
1294,
|
||||
741
|
||||
],
|
||||
"screen": [
|
||||
100,
|
||||
75
|
||||
],
|
||||
"vv_height": 662.4000244140625
|
||||
},
|
||||
"left=5000,top=5000": {
|
||||
"inner": [
|
||||
1280,
|
||||
662
|
||||
],
|
||||
"outer": [
|
||||
1294,
|
||||
741
|
||||
],
|
||||
"screen": [
|
||||
242,
|
||||
75
|
||||
],
|
||||
"vv_height": 662.4000244140625
|
||||
}
|
||||
},
|
||||
"1920x1080-dpr1.5": {
|
||||
"width=500,height=400": {
|
||||
"inner": [
|
||||
500,
|
||||
400
|
||||
],
|
||||
"outer": [
|
||||
515,
|
||||
478
|
||||
],
|
||||
"screen": [
|
||||
3,
|
||||
3
|
||||
],
|
||||
"vv_height": 400
|
||||
},
|
||||
"popup": {
|
||||
"inner": [
|
||||
1280,
|
||||
609
|
||||
],
|
||||
"outer": [
|
||||
1295,
|
||||
687
|
||||
],
|
||||
"screen": [
|
||||
-7,
|
||||
-7
|
||||
],
|
||||
"vv_height": 608.6666870117188
|
||||
},
|
||||
"width=500": {
|
||||
"inner": [
|
||||
501,
|
||||
533
|
||||
],
|
||||
"outer": [
|
||||
515,
|
||||
611
|
||||
],
|
||||
"screen": [
|
||||
3,
|
||||
3
|
||||
],
|
||||
"vv_height": 533.3333129882812
|
||||
},
|
||||
"height=400": {
|
||||
"inner": [
|
||||
1153,
|
||||
400
|
||||
],
|
||||
"outer": [
|
||||
1168,
|
||||
478
|
||||
],
|
||||
"screen": [
|
||||
3,
|
||||
3
|
||||
],
|
||||
"vv_height": 400
|
||||
},
|
||||
"width=300,height=200": {
|
||||
"inner": [
|
||||
300,
|
||||
200
|
||||
],
|
||||
"outer": [
|
||||
315,
|
||||
278
|
||||
],
|
||||
"screen": [
|
||||
3,
|
||||
3
|
||||
],
|
||||
"vv_height": 200
|
||||
},
|
||||
"width=800,height=600": {
|
||||
"inner": [
|
||||
800,
|
||||
594
|
||||
],
|
||||
"outer": [
|
||||
815,
|
||||
672
|
||||
],
|
||||
"screen": [
|
||||
3,
|
||||
0
|
||||
],
|
||||
"vv_height": 594
|
||||
},
|
||||
"left=100,top=100": {
|
||||
"inner": [
|
||||
1153,
|
||||
533
|
||||
],
|
||||
"outer": [
|
||||
1168,
|
||||
611
|
||||
],
|
||||
"screen": [
|
||||
100,
|
||||
61
|
||||
],
|
||||
"vv_height": 533.3333129882812
|
||||
},
|
||||
"left=5000,top=5000": {
|
||||
"inner": [
|
||||
1153,
|
||||
533
|
||||
],
|
||||
"outer": [
|
||||
1168,
|
||||
611
|
||||
],
|
||||
"screen": [
|
||||
112,
|
||||
61
|
||||
],
|
||||
"vv_height": 533.3333129882812
|
||||
}
|
||||
},
|
||||
"1600x1200-dpr2.0": {
|
||||
"width=500,height=400": {
|
||||
"inner": [
|
||||
500,
|
||||
400
|
||||
],
|
||||
"outer": [
|
||||
513,
|
||||
476
|
||||
],
|
||||
"screen": [
|
||||
2,
|
||||
2
|
||||
],
|
||||
"vv_height": 399.5
|
||||
},
|
||||
"popup": {
|
||||
"inner": [
|
||||
800,
|
||||
489
|
||||
],
|
||||
"outer": [
|
||||
813,
|
||||
565
|
||||
],
|
||||
"screen": [
|
||||
-6,
|
||||
-6
|
||||
],
|
||||
"vv_height": 488.5
|
||||
},
|
||||
"width=500": {
|
||||
"inner": [
|
||||
500,
|
||||
428
|
||||
],
|
||||
"outer": [
|
||||
513,
|
||||
504
|
||||
],
|
||||
"screen": [
|
||||
2,
|
||||
2
|
||||
],
|
||||
"vv_height": 427.5
|
||||
},
|
||||
"height=400": {
|
||||
"inner": [
|
||||
720,
|
||||
400
|
||||
],
|
||||
"outer": [
|
||||
733,
|
||||
476
|
||||
],
|
||||
"screen": [
|
||||
2,
|
||||
2
|
||||
],
|
||||
"vv_height": 399.5
|
||||
},
|
||||
"width=300,height=200": {
|
||||
"inner": [
|
||||
300,
|
||||
200
|
||||
],
|
||||
"outer": [
|
||||
313,
|
||||
276
|
||||
],
|
||||
"screen": [
|
||||
2,
|
||||
2
|
||||
],
|
||||
"vv_height": 199.5
|
||||
},
|
||||
"width=800,height=600": {
|
||||
"inner": [
|
||||
787,
|
||||
476
|
||||
],
|
||||
"outer": [
|
||||
800,
|
||||
552
|
||||
],
|
||||
"screen": [
|
||||
0,
|
||||
0
|
||||
],
|
||||
"vv_height": 475.5
|
||||
},
|
||||
"left=100,top=100": {
|
||||
"inner": [
|
||||
720,
|
||||
428
|
||||
],
|
||||
"outer": [
|
||||
733,
|
||||
504
|
||||
],
|
||||
"screen": [
|
||||
67,
|
||||
48
|
||||
],
|
||||
"vv_height": 427.5
|
||||
},
|
||||
"left=5000,top=5000": {
|
||||
"inner": [
|
||||
720,
|
||||
428
|
||||
],
|
||||
"outer": [
|
||||
733,
|
||||
504
|
||||
],
|
||||
"screen": [
|
||||
67,
|
||||
48
|
||||
],
|
||||
"vv_height": 427.5
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
{
|
||||
"about": "The retail border, chrome and popup frame of the maximized window at scale 1.0 and 1.25, read from the 1920x1080 captures by scripts/extract_retail_window_formula.py; tests/_retail_window_formula.py applies them to any work area. Never edited by hand.",
|
||||
"capture": {
|
||||
"round": "2026-12-01-window-geometry-r12",
|
||||
"run": "https://github.com/oss-invisible/core/actions/runs/46545487209",
|
||||
"retail_captures_commit": "ef2250dee8704d3023c36661e39ea9525fe41a04",
|
||||
"browser": {
|
||||
"firefox_version": "159.0",
|
||||
"build_id": "20261022150525",
|
||||
"installer_sha256": "8776887b79925abbdd407fcdfe257d8382b54e24be52a6466426b95a804d6790"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
{
|
||||
"path": "dpr1/1920x1080/a/raw.json",
|
||||
"sha256": "1e4413e6e06ff1a8fc49eba8d87cd2c1e3642550bd67242fcd8ebd03777baf6a"
|
||||
},
|
||||
{
|
||||
"path": "dpr1/1920x1080/b/raw.json",
|
||||
"sha256": "ee2d4d2b60dea8e56450fca62446a5c3135e358b6f47ead030b55eea174a35a8"
|
||||
},
|
||||
{
|
||||
"path": "dpr1.25/1920x1080/a/raw.json",
|
||||
"sha256": "440d03adc9782905764e34e983c202f816d79059e81f298316e7a0d9d19f29ab"
|
||||
},
|
||||
{
|
||||
"path": "dpr1.25/1920x1080/b/raw.json",
|
||||
"sha256": "4110bbc9b49f5f5c47b340b4a3e6f91328fe14f10247f888fbb301f9f3ff6f80"
|
||||
}
|
||||
],
|
||||
"scales": {
|
||||
"1.0": {
|
||||
"border": 8,
|
||||
"ui": 85,
|
||||
"popup_frame": [
|
||||
16,
|
||||
80
|
||||
],
|
||||
"capture_case": {
|
||||
"panel": "1920x1080",
|
||||
"avail_css": [
|
||||
1920,
|
||||
1032
|
||||
],
|
||||
"observed": {
|
||||
"ow": 1936,
|
||||
"oh": 1048,
|
||||
"iw": 1920,
|
||||
"ih": 947,
|
||||
"sx": -8,
|
||||
"sy": -8,
|
||||
"mx": 0,
|
||||
"my": 85
|
||||
},
|
||||
"popup_observed": {
|
||||
"inner": [
|
||||
1920,
|
||||
968
|
||||
],
|
||||
"outer": [
|
||||
1936,
|
||||
1048
|
||||
],
|
||||
"screen": [
|
||||
-8,
|
||||
-8
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"1.25": {
|
||||
"border": 9,
|
||||
"ui": 106,
|
||||
"popup_frame": [
|
||||
14,
|
||||
78
|
||||
],
|
||||
"capture_case": {
|
||||
"panel": "1920x1080",
|
||||
"avail_css": [
|
||||
1536,
|
||||
816
|
||||
],
|
||||
"observed": {
|
||||
"ow": 1550,
|
||||
"oh": 830,
|
||||
"iw": 1536,
|
||||
"ih": 731,
|
||||
"sx": -7,
|
||||
"sy": -7,
|
||||
"mx": 0,
|
||||
"my": 84.80000305175781
|
||||
},
|
||||
"popup_observed": {
|
||||
"inner": [
|
||||
1536,
|
||||
752
|
||||
],
|
||||
"outer": [
|
||||
1550,
|
||||
830
|
||||
],
|
||||
"screen": [
|
||||
-7,
|
||||
-7
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+103
-19
@@ -97,6 +97,10 @@ there and removed after the run): the browser's processes read the link of every
|
||||
|
||||
Declared differences (ci/ab-host-expected.json) are applied to the A/B only, never to the A/A, by kind, and one that does not show is red as stale. A declared `proc` difference covers the
|
||||
process kind and the file leaves whose only toucher on the published side is that kind (a leaf another process touched too is still a difference).
|
||||
A row declares its direction, `published` and `candidate` (`present` or `absent`; default published present, candidate absent), and a row of the other direction (the published engine
|
||||
does not have it, the candidate does: `proc.gpu` of the real window) covers the process kind alone. A `file` row covers the leaf `file.<path>` of its `name`, the path with the staged
|
||||
engine folder as `<engine>` and the profile folder of the user as `<profile>` (`normalise_leaf`, with the `user_root` the footprint recorded), in that direction and no other. A row of either kind that does not show is stale.
|
||||
The candidate is launched from a venv of its own made like the published set's (`candidate_python`, `ci_published_set.install_candidate`), not from the python of the job.
|
||||
|
||||
Evidence of the tree (Windows): every launch (the warm-up, each seed, the idle launch and the stock control) saves the raw events of the audit that its tree was read from, the 4688 births
|
||||
and the 4689 ends, the excluded ones as well, in `<footprint>.audit/<launch>-<seed>.json` (`audit_listing`: record id, event, pid, creator's pid, image, `ParentProcessName`, time, command
|
||||
@@ -111,7 +115,9 @@ import datetime
|
||||
import collections
|
||||
import ipaddress
|
||||
import json
|
||||
import ntpath
|
||||
import os
|
||||
import posixpath
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
@@ -129,6 +135,7 @@ ROOT = HERE.parent
|
||||
sys.path.insert(0, str(HERE))
|
||||
sys.path.insert(0, str(ROOT / "tests"))
|
||||
import ci_ab_oracle as oracle # noqa: E402 (fetch_published, ENGINE_TAG)
|
||||
import ci_published_set as published_set # noqa: E402 (install_candidate: the candidate's venv)
|
||||
import ci_host_gate as gate # noqa: E402 (SEEDS)
|
||||
import ci_crash_evidence as crash # noqa: E402 (the exit code is red, and what a bad end left is saved)
|
||||
from ci_crash_evidence import CrashWatcher, crash_report_dirs # noqa: E402 (the collectors every launch shares)
|
||||
@@ -1688,20 +1695,64 @@ def load_expected(path: Path = EXPECTED_FILE) -> list:
|
||||
return document["differences"]
|
||||
|
||||
|
||||
def _declared_covers(entry: dict, diff: dict, probe_seeds=()) -> bool:
|
||||
"""A declared difference covers, by kind (a `proc` entry, the name of the process):
|
||||
#: A declared `file` row names a path by what the run does not choose: the folder the engine is staged in is `<engine>` (the parent of its package, `STAGE_ENGINE`: the loader of
|
||||
#: Windows asks for `<engine>\systemresources\<exe>.mun` there), and the profile folder of the user that ran it is `<profile>`.
|
||||
ENGINE_PLACEHOLDER = "<engine>"
|
||||
PROFILE_PLACEHOLDER = "<profile>"
|
||||
_STAGE_ROOT = re.compile(r"^.*?\\ab-host\\engine(?=\\|$)", re.I)
|
||||
|
||||
* the leaf `proc.<name>` that is the published engine having it (count >= 1) and the candidate not having it;
|
||||
* a file leaf of a seed in `probe_seeds` (the seeds where that leaf above differs) that only the published engine has and whose ONLY toucher on that side is that kind:
|
||||
what a process the candidate no longer spawns alone touched goes with it. A leaf another process touched too stays a difference, and so does a leaf the
|
||||
candidate touches or one the candidate alone has."""
|
||||
|
||||
def profile_root_of_this_machine() -> str:
|
||||
r"""The folder that holds the profile folders of the machine this runs on (the parent of the home folder), lower case, as a footprint spells a path: what a recorder puts in its
|
||||
document as `user_root`, read from the environment of the run and typed nowhere. The home folder is split by the rules of the platform its own text is of (`ntpath` for a Windows path, a drive
|
||||
or a UNC root, or a backslash in it; `posixpath` otherwise), never by the rules of the host this runs on: `x:\home-root\someone` has the parent `x:\home-root` on a Linux host too."""
|
||||
home = os.path.expanduser("~")
|
||||
windows = re.match(r"^[A-Za-z]:|^\\\\", home) is not None or "\\" in home
|
||||
return (ntpath if windows else posixpath).dirname(home).replace("/", "\\").rstrip("\\").lower()
|
||||
|
||||
|
||||
def normalise_leaf(path: str, user_root: str | None = None) -> str:
|
||||
r"""`path` (a host path as a footprint spells it, without the `file.` of the leaf) with the staged engine folder replaced by `<engine>` and, given `user_root` (the folder that holds
|
||||
the profile folders, as the recording run said it: the `user_root` of its footprint), the profile folder under it by `<profile>`:
|
||||
`d:\a\_temp\ab-host\engine\systemresources\firefox.exe.mun` is `<engine>\systemresources\firefox.exe.mun`; with the root `x:\home-root`, `x:\home-root\someone\appdata\f` is
|
||||
`<profile>\appdata\f`. Any other path is itself, with `\` for `/`."""
|
||||
text = _STAGE_ROOT.sub(ENGINE_PLACEHOLDER, path.replace("/", "\\"), count=1)
|
||||
root = (user_root or "").replace("/", "\\").rstrip("\\").lower()
|
||||
if root and text.lower().startswith(root + "\\"):
|
||||
_name, sep, tail = text[len(root) + 1:].partition("\\")
|
||||
return PROFILE_PLACEHOLDER + sep + tail
|
||||
return text
|
||||
|
||||
|
||||
def _state(value) -> str:
|
||||
return "absent" if value == MISSING or not value else "present"
|
||||
|
||||
|
||||
def _declared_covers(entry: dict, diff: dict, probe_seeds=(), user_root: str | None = None) -> bool:
|
||||
"""A declared difference covers, by kind. Its direction is `published` and `candidate` (each `present` or `absent`; the default is the first row's, published present and
|
||||
candidate absent).
|
||||
|
||||
`proc` (the name of the process):
|
||||
* published present, candidate absent: the leaf `proc.<name>` that is the published engine having it (count >= 1) and the candidate not having it, and the file leaves of a
|
||||
seed in `probe_seeds` (the seeds where that leaf differs) that only the published engine has and whose ONLY toucher on that side is that kind: what a process the candidate
|
||||
no longer spawns alone touched goes with it. A leaf another process touched too stays a difference, and so does a leaf the candidate touches or one the candidate alone has;
|
||||
* published absent, candidate present: the leaf `proc.<name>` alone (the paths the process touched are rows of their own).
|
||||
|
||||
`file` (`name` is the path, normalised by `normalise_leaf`): the leaf `file.<path>` of any seed whose normalised path is `name` and whose two sides are the row's `published` and
|
||||
`candidate`. Nothing else: not another path, not the same path with the sides the other way round."""
|
||||
direction = (entry.get("published", "present"), entry.get("candidate", "absent"))
|
||||
published, candidate = diff["a"], diff["b"]
|
||||
if entry.get("category") == "file":
|
||||
return (diff["category"] == "file" and diff["leaf"].startswith("file.") and normalise_leaf(diff["leaf"][len("file."):], user_root) == entry.get("name")
|
||||
and published != candidate and (_state(published), _state(candidate)) == direction)
|
||||
if entry.get("category") != "proc":
|
||||
return False
|
||||
published, candidate = diff["a"], diff["b"]
|
||||
if diff["leaf"] == "proc." + entry["name"]:
|
||||
return (published != MISSING and published >= 1) and candidate == MISSING
|
||||
if direction == ("absent", "present"):
|
||||
return published == MISSING and candidate != MISSING and candidate >= 1
|
||||
return direction == ("present", "absent") and (published != MISSING and published >= 1) and candidate == MISSING
|
||||
by = diff.get("by") or {}
|
||||
return (diff["category"] == "file" and diff["seed"] in probe_seeds and published != MISSING and candidate == MISSING
|
||||
return (direction == ("present", "absent") and diff["category"] == "file" and diff["seed"] in probe_seeds and published != MISSING and candidate == MISSING
|
||||
and by.get("A") == [entry["name"]] and not by.get("B"))
|
||||
|
||||
|
||||
@@ -1875,13 +1926,15 @@ def judge(a: dict, b: dict, expected: list | None = None, a_a: bool = False, pla
|
||||
if x != y:
|
||||
problems.append("warm-up: the pingsender destinations differ: A only %s | B only %s" % (sorted(set(x) - set(y))[:5], sorted(set(y) - set(x))[:5]))
|
||||
stale = []
|
||||
user_root = a.get("user_root") or b.get("user_root")
|
||||
if not a_a:
|
||||
for entry in expected or []:
|
||||
if entry.get("os") != os_name:
|
||||
continue
|
||||
probe_seeds = {d["seed"] for d in differences if d["leaf"] == "proc." + entry.get("name", "") and _declared_covers(entry, d)}
|
||||
hit = [d for d in differences if _declared_covers(entry, d, probe_seeds)]
|
||||
if not any(d["leaf"] == "proc." + entry.get("name", "") for d in hit):
|
||||
probe_seeds = {d["seed"] for d in differences if d["leaf"] == "proc." + entry.get("name", "") and _declared_covers(entry, d, (), user_root)}
|
||||
hit = [d for d in differences if _declared_covers(entry, d, probe_seeds, user_root)]
|
||||
shows = bool(hit) if entry.get("category") == "file" else any(d["leaf"] == "proc." + entry.get("name", "") for d in hit)
|
||||
if not shows:
|
||||
stale.append(entry)
|
||||
problems.append("the declared difference %r (%s) does not show in this run: it is stale, remove it"
|
||||
% (entry.get("id", entry.get("name")), entry.get("reason", "")))
|
||||
@@ -1910,7 +1963,7 @@ def judge(a: dict, b: dict, expected: list | None = None, a_a: bool = False, pla
|
||||
"differences": differences, "declared": declared, "ours": OURS, "tab": {"reason": TAB_REASON, "counts": tab},
|
||||
"outside_tree": outside, "warmup": dict(warm, both=both), "idle": {side: _idle_summary(fp.get("idle")) for side, fp in (("A", a), ("B", b))}, "not_judged": not_judged,
|
||||
"shortcuts": {side: _shortcuts_summary(((fp.get("idle") or {}).get("idle") or {}).get("shortcut_changes")) for side, fp in (("A", a), ("B", b))},
|
||||
"stale": [e.get("id") for e in stale], "leaves": counts, "net": net}
|
||||
"stale": [e.get("id") for e in stale], "leaves": counts, "net": net, "user_root": user_root}
|
||||
|
||||
|
||||
def _launch_counts(counts: dict) -> str:
|
||||
@@ -2570,7 +2623,7 @@ def run_engine(binary: str, leg: str, seeds: list, label: str, crash_dir=None, d
|
||||
sys.stdout.flush()
|
||||
finally:
|
||||
shutil.rmtree(work, ignore_errors=True)
|
||||
return {"format": FORMAT, "engine": label, "leg": leg, "platform": sys.platform, "seeds": out_seeds, "warmup": warm, "idle": idle, "problems": problems,
|
||||
return {"format": FORMAT, "engine": label, "leg": leg, "platform": sys.platform, "seeds": out_seeds, "warmup": warm, "idle": idle, "problems": problems, "user_root": profile_root_of_this_machine(),
|
||||
"binary": os.path.basename(os.path.dirname(os.path.realpath(binary)))}
|
||||
|
||||
|
||||
@@ -2719,13 +2772,15 @@ def staged_engine(binary: str, base=None):
|
||||
shutil.rmtree(dest, ignore_errors=True)
|
||||
|
||||
|
||||
def run_subprocess(binary: str, seal: Path | None, leg: str, out: Path, label: str, seeds: list, crash_with: str | None = None, python: str | None = None) -> int:
|
||||
def run_subprocess(binary: str, seal: Path | None, leg: str, out: Path, label: str, seeds: list, crash_with: str | None = None, python: str | None = None,
|
||||
pin_allow: bool = False) -> int:
|
||||
"""`run` in a process of its own, with a cache folder and a temp root of its own: they are the run's, so what the engine does in them is `ours`
|
||||
(the cache of the bundle's fonts, the profile and the temp dirs of the launch) and the rest of the machine is the host's.
|
||||
|
||||
`crash_with` (a signal name) makes the run the recorder's own test: one launch, whose parent is sent that signal (`crash-probe`). `python` is the published set's
|
||||
(scripts/ci_published_set.py): the control side runs in the venv that holds the published core and wrapper, never in the candidate's."""
|
||||
env = oracle.process_env(seal, python)
|
||||
(scripts/ci_published_set.py): the control side runs in the venv that holds the published core and wrapper, never in the candidate's; the candidate runs in a venv of its own,
|
||||
made the same way (`candidate_python`, `pin_allow`)."""
|
||||
env = oracle.process_env(seal, python, pin_allow)
|
||||
cmd = [python or sys.executable, "-u", str(Path(__file__).resolve()), "run", binary, "--leg", leg, "--out", str(out), "--label", label,
|
||||
"--seeds", ",".join(str(s) for s in seeds)]
|
||||
if crash_with:
|
||||
@@ -2847,6 +2902,34 @@ def run_stock_control(leg: str, out: Path) -> dict | None:
|
||||
return stock
|
||||
|
||||
|
||||
WHEELHOUSE_ENV = "INVPW_WHEELHOUSE"
|
||||
#: The folder of the candidate's venv, beside the published set's (`$RUNNER_TEMP/published-set`): directly under the temp root of the job, with a name of its own that does not change from
|
||||
#: run to run. The engine's processes read the ancestors of the install folder of the core they run with, so a venv under a folder with a random name would be a path of one side only.
|
||||
CANDIDATE_VENV = "candidate-set"
|
||||
|
||||
|
||||
def candidate_python(environ=None, install=None) -> str | None:
|
||||
"""The python of a venv of the candidate's own, made like the published set's (`ci_published_set.install_candidate`: the run's wheelhouse, offline, the candidate's two wheels over the
|
||||
gate's lock): the two sides of the A/B are launched from the same kind of python, so a read of the host that comes from the python (its library, the folders it loads from) is on both
|
||||
sides or on neither. The wheelhouse is INVPW_WHEELHOUSE, else `$RUNNER_TEMP/py-deps` (the gate's). None, said on the output, when there is none and no published set is in use
|
||||
(INVPW_PUBLISHED_PYTHON unset: a local run): the candidate then runs from this process's python as before. With a published set (the gate's oracle jobs) a missing wheelhouse is an
|
||||
error: the set was installed from it, so it is there."""
|
||||
environ = os.environ if environ is None else environ
|
||||
install = install or published_set.install_candidate
|
||||
house = environ.get(WHEELHOUSE_ENV) or (str(Path(environ["RUNNER_TEMP"]) / "py-deps") if environ.get("RUNNER_TEMP") else "")
|
||||
if not house or not (Path(house) / "lock.txt").is_file():
|
||||
if environ.get(oracle.PUBLISHED_PYTHON_ENV):
|
||||
raise RuntimeError("the candidate's venv cannot be made: %s names no wheelhouse with a lock.txt (%r); the gate's job has the run's py-deps one" % (WHEELHOUSE_ENV, house))
|
||||
print("the candidate runs from this process's python (%s names no wheelhouse): not a venv of its own like the published set's" % WHEELHOUSE_ENV)
|
||||
return None
|
||||
venv = Path(environ.get("RUNNER_TEMP") or tempfile.gettempdir()) / CANDIDATE_VENV
|
||||
shutil.rmtree(venv, ignore_errors=True)
|
||||
python = str(install(Path(house), venv))
|
||||
print("the candidate's python: %s (a venv of its own from %s, as the published set's)" % (python, house))
|
||||
sys.stdout.flush()
|
||||
return python
|
||||
|
||||
|
||||
def ab(candidate: str | None, candidate_seal: Path | None, leg: str, out: Path, engine_tag: str, seeds: list,
|
||||
published: tuple | None = None, expected_file: Path = EXPECTED_FILE) -> int:
|
||||
"""A/A first (the published engine twice), then, with a candidate, the published engine against it. 0 green, 1 the A/B is red,
|
||||
@@ -2858,14 +2941,15 @@ def ab(candidate: str | None, candidate_seal: Path | None, leg: str, out: Path,
|
||||
runs = [(engine_tag, "footprint-%s.json" % engine_tag.rsplit("-", 1)[-1], binary, seal, python),
|
||||
(engine_tag + " again", "footprint-%s-again.json" % engine_tag.rsplit("-", 1)[-1], binary, seal, python)]
|
||||
if candidate:
|
||||
runs.append((oracle.CANDIDATE, "footprint-candidate.json", candidate, candidate_seal, None))
|
||||
runs.append((oracle.CANDIDATE, "footprint-candidate.json", candidate, candidate_seal, candidate_python()))
|
||||
failed = []
|
||||
for label, name, exe, seal_file, side_python in runs:
|
||||
print("=== footprint with %s: %s (run from %s)" % (label, exe, stage_dir()))
|
||||
sys.stdout.flush()
|
||||
try:
|
||||
with staged_engine(exe) as staged:
|
||||
rc = run_subprocess(staged, Path(seal_file) if seal_file else None, leg, out / name, label, seeds, **({"python": side_python} if side_python else {}))
|
||||
rc = run_subprocess(staged, Path(seal_file) if seal_file else None, leg, out / name, label, seeds,
|
||||
**({"python": side_python, **({"pin_allow": True} if label == oracle.CANDIDATE else {})} if side_python else {}))
|
||||
except OSError as e:
|
||||
print("the engine of %s could not be staged: %s" % (label, e))
|
||||
rc = 125
|
||||
|
||||
@@ -465,12 +465,13 @@ def fetch_published(tag: str | None, work: Path) -> tuple:
|
||||
return fetched["binary"], None, python
|
||||
|
||||
|
||||
def process_env(seal, python: str | None = None) -> dict:
|
||||
def process_env(seal, python: str | None = None, pin_allow: bool = False) -> dict:
|
||||
"""The environment of a process that runs ONE engine: no autofix, no browser logging, and the seal of that engine. With `python` (the published set's venv) the process is the
|
||||
set's: nothing of the candidate's job that could make it import another core or run another seal reaches it, and the core's pin check stays ON (a set whose wrapper and
|
||||
core do not agree is refused, as it is on a user's machine). Without it (the candidate, or a pull request's published engine) it is as it always was."""
|
||||
core do not agree is refused, as it is on a user's machine). Without it (a pull request's published engine, or a candidate with no wheelhouse) it is as it always was.
|
||||
The candidate's own venv (`published_set.install_candidate`) is a `python` too, with `pin_allow`: its core is core_ref's, which the wrapper of wrapper_ref may not pin."""
|
||||
if python:
|
||||
env = published_set.clean_env({"INVISIBLE_CORE_AUTOFIX": "off"})
|
||||
env = published_set.clean_env(dict({"INVISIBLE_CORE_AUTOFIX": "off"}, **({"INVISIBLE_CORE_PIN": "allow"} if pin_allow else {})))
|
||||
else:
|
||||
env = dict(os.environ, INVISIBLE_CORE_AUTOFIX="off", INVISIBLE_CORE_PIN="allow")
|
||||
if seal: # None: the engine runs under the seal of the core it is launched with (the published set's, a pull request's published engine)
|
||||
|
||||
@@ -0,0 +1,464 @@
|
||||
#!/usr/bin/env python3
|
||||
"""The footprint of an official RETAIL Firefox with a real window, and the declared rows of the host oracle that it explains.
|
||||
|
||||
python scripts/ci_ab_host.py retail <firefox.exe> --leg windows-x86_64 --out footprint-retail.json [--build build.json] [--launches 3]
|
||||
python scripts/ci_ab_retail.py derive --diff diff.json --retail footprint-retail.json --capture <path of the capture> [--expected ci/ab-host-expected.json] [--write]
|
||||
python scripts/ci_ab_retail.py host-only --diff diff.json --run-id <id of the candidate run> [--expected ci/ab-host-expected.json] [--write]
|
||||
|
||||
`retail` (Windows) is the host oracle's own recorder (`ci_ab_host`: the same process-creation audit and the same Kernel-File trace, the same staged folder, the same classification of
|
||||
the paths and the same footprint document) run on a browser nobody drives: a retail Firefox, started with a fresh profile and one page of the oracle's lab, windowed (no `-headless`,
|
||||
no Juggler), closed the way a user closes it (WM_CLOSE to its window). A discarded warm-up launch first, then `--launches` measured ones. Retail has no seed: the launches are
|
||||
numbered from 0.
|
||||
|
||||
`derive` (`--hidden-desktop` for the capture made on the core's hidden desktop, whose rows carry the reason "hidden desktop") reads the A/B verdict of a candidate run (`diff.json`) and that capture, and writes one declared row for each difference that retail windowed ALSO shows, the sides the other
|
||||
way round included: a difference is explained when the candidate has the path (or the kind of process) exactly when retail windowed has it. A difference that retail windowed
|
||||
does not show stays undeclared and is listed. Each row carries its source: the path of the capture, the run that made it and the sha256 of the xul.dll of the retail build.
|
||||
|
||||
`host-only` writes the rows of the differences of a Linux A/B (`diff.json` of a candidate run) that nothing in a page can read: the host's own files that the published engine opens and the candidate does not, or the
|
||||
other way round. Each row has the reason "host only" and a `note` naming the cause; the cause comes from the rule table HOST_ONLY_RULES (a pattern of the normalised leaf, the direction it is
|
||||
declared in, the note), never from a hand-typed row. A leaf that no rule names, or that a rule names in the other direction, or that is not the same in every seed of the run, refuses the whole run: no row is
|
||||
written and the leaves are listed. The source of a row is the candidate run and the sha256 of the diff.json it was derived from.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
HERE = Path(__file__).resolve().parent
|
||||
sys.path.insert(0, str(HERE))
|
||||
sys.path.insert(0, str(HERE.parent / "tests"))
|
||||
import ci_ab_host as host # noqa: E402
|
||||
|
||||
REASON = "real window, decided 01/12"
|
||||
#: The reason of a row whose source is the retail capture made on the HIDDEN DESKTOP the core creates (`--hidden-desktop`): the difference is the desktop's, not the window's.
|
||||
REASON_HIDDEN = "hidden desktop"
|
||||
#: The capture of retail on the core's hidden desktop says so in its `mode` (the recorder of RetailCaptures); a capture made without it is the real window's.
|
||||
HIDDEN_MODE = "hidden desktop"
|
||||
RETAIL_LABEL = "retail"
|
||||
#: What a fresh profile of a retail Firefox does that a user's does not repeat and that is no trace of a window: the welcome page and the default-browser question. They are written in the
|
||||
#: profile's user.js, and the footprint carries them (`prefs`).
|
||||
RETAIL_PREFS = {
|
||||
"browser.aboutwelcome.enabled": False,
|
||||
"browser.shell.checkDefaultBrowser": False,
|
||||
"browser.startup.homepage_override.mstone": "ignore",
|
||||
"datareporting.policy.firstRunURL": "",
|
||||
}
|
||||
#: Seconds a launch may take to show its browser parent, to load the last stage of the lab page, and to end after the close; the hold after the page has loaded.
|
||||
PARENT_LIMIT_S = 60
|
||||
PAGE_LIMIT_S = 60
|
||||
CLOSE_LIMIT_S = 60
|
||||
HOLD_AFTER_PAGE_S = 5
|
||||
LAST_STAGE = "kind=css&id=ld3"
|
||||
|
||||
|
||||
def user_js(prefs=None) -> str:
|
||||
return "".join("user_pref(%s, %s);\n" % (json.dumps(k), json.dumps(v)) for k, v in sorted((RETAIL_PREFS if prefs is None else prefs).items()))
|
||||
|
||||
|
||||
def sha256_file(path) -> str:
|
||||
h = hashlib.sha256()
|
||||
with open(path, "rb") as f:
|
||||
for block in iter(lambda: f.read(1 << 20), b""):
|
||||
h.update(block)
|
||||
return h.hexdigest()
|
||||
|
||||
|
||||
# -
|
||||
# The launch.
|
||||
|
||||
def browser_parents_of(profile: Path, processes=None) -> list:
|
||||
"""The pids, oldest first, of the browser parents that were started with `-profile <profile>`: a `firefox.exe` without `-contentproc` whose command line names the profile. On
|
||||
Windows there are two: the launcher process the command started, and the browser it starts and waits for (run 46880238752: the oldest one has no window). Empty when none (yet)."""
|
||||
if processes is None:
|
||||
import psutil
|
||||
|
||||
processes = psutil.process_iter()
|
||||
found = []
|
||||
for p in processes:
|
||||
try:
|
||||
if p.name().lower() != "firefox.exe":
|
||||
continue
|
||||
cmd = [str(a) for a in p.cmdline()]
|
||||
if "-contentproc" not in cmd and str(profile) in cmd:
|
||||
found.append((p.create_time(), p.pid))
|
||||
except Exception: # noqa: BLE001 - a process that is gone
|
||||
continue
|
||||
return [pid for _born, pid in sorted(found)]
|
||||
|
||||
|
||||
def browser_parent_of(profile: Path, processes=None) -> int | None:
|
||||
"""The oldest of `browser_parents_of`, None when there is none (yet)."""
|
||||
found = browser_parents_of(profile, processes)
|
||||
return found[0] if found else None
|
||||
|
||||
|
||||
def close_windows_of(pid: int) -> int:
|
||||
"""WM_CLOSE to every visible top-level window of the process `pid`, the close of a user's click on the X; returns how many were asked (Windows only)."""
|
||||
import ctypes
|
||||
from ctypes import wintypes
|
||||
|
||||
user32 = ctypes.windll.user32
|
||||
asked = []
|
||||
proc_type = ctypes.WINFUNCTYPE(wintypes.BOOL, wintypes.HWND, wintypes.LPARAM)
|
||||
|
||||
def each(hwnd, _lparam):
|
||||
owner = wintypes.DWORD()
|
||||
user32.GetWindowThreadProcessId(hwnd, ctypes.byref(owner))
|
||||
if owner.value == pid and user32.IsWindowVisible(hwnd):
|
||||
user32.PostMessageW(hwnd, 0x0010, 0, 0)
|
||||
asked.append(hwnd)
|
||||
return True
|
||||
|
||||
user32.EnumWindows(proc_type(each), 0)
|
||||
return len(asked)
|
||||
|
||||
|
||||
def wait_for(condition, limit_s: float, period: float = 0.25, sleep=time.sleep, now=time.monotonic):
|
||||
"""The value of `condition()` as soon as it is truthy, else None after `limit_s`."""
|
||||
deadline = now() + limit_s
|
||||
while True:
|
||||
value = condition()
|
||||
if value:
|
||||
return value
|
||||
if now() >= deadline:
|
||||
return None
|
||||
sleep(period)
|
||||
|
||||
|
||||
def last_stage_served(state) -> bool:
|
||||
"""Whether the lab site has answered the request of the last stage of its page (the stylesheet ld3): what a window has when its page is done."""
|
||||
return any(r.get("ev") == "request" and LAST_STAGE in r.get("path", "") for r in list(state.records))
|
||||
|
||||
|
||||
def run_retail_seed(binary: str, index: int, work: Path, name: str, audit_dir=None) -> dict:
|
||||
"""One launch of the retail Firefox at `binary`, windowed: a fresh profile, the lab's home page, the close of a user. Returns the footprint of the launch (`ci_ab_host._seed_result`),
|
||||
its `seed` being the number of the launch; a launch that did not start, did not show its page or did not end by itself has it in its `problems`."""
|
||||
import psutil
|
||||
from fakeweb import journey_site
|
||||
|
||||
seed_work = work / name
|
||||
profile = seed_work / "profile"
|
||||
profile.mkdir(parents=True)
|
||||
(profile / "user.js").write_text(user_js(), encoding="utf-8")
|
||||
trace = host.WindowsTrace(seed_work)
|
||||
try:
|
||||
trace.start()
|
||||
except host.TraceError as e:
|
||||
trace.cleanup()
|
||||
return {"seed": index, "steps": [], "kinds": {}, "files": [], "ours": {}, "trace": {"source": "etw+audit", "exited": False}, "problems": [host.trace_not_started(e)]}
|
||||
origin_a, _origin_o, stop_site = journey_site.start((0, 0))
|
||||
problems, process, parent, close = [], None, None, None
|
||||
try:
|
||||
print(host.crash.launch_line(index, name, RETAIL_LABEL))
|
||||
sys.stdout.flush()
|
||||
process = subprocess.Popen([binary, "-no-remote", "-profile", str(profile), origin_a + "/"], cwd=str(seed_work), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
parent = wait_for(lambda: browser_parent_of(profile), PARENT_LIMIT_S)
|
||||
if parent is None:
|
||||
problems.append("no browser parent (firefox.exe without -contentproc, -profile %s) in %d s of the start" % (profile, PARENT_LIMIT_S))
|
||||
elif not wait_for(lambda: last_stage_served(journey_site.STATE), PAGE_LIMIT_S):
|
||||
problems.append("the lab page's last stage (%s) was not requested in %d s: the window did not show the page" % (LAST_STAGE, PAGE_LIMIT_S))
|
||||
else:
|
||||
time.sleep(HOLD_AFTER_PAGE_S)
|
||||
started = time.monotonic()
|
||||
parents = browser_parents_of(profile)
|
||||
asked = sum(close_windows_of(pid) for pid in parents)
|
||||
if parent is not None and not asked:
|
||||
problems.append("no browser parent of %s (%s) had a visible window to close" % (profile, ", ".join(str(p) for p in parents) or "none"))
|
||||
ended = wait_for(lambda: not any(psutil.pid_exists(pid) for pid in parents), CLOSE_LIMIT_S) if parent is not None else True
|
||||
if not ended:
|
||||
problems.append("the browser did not end %d s after WM_CLOSE: it was ended by the oracle" % CLOSE_LIMIT_S)
|
||||
close = {"windows_asked": asked, "close_s": round(time.monotonic() - started, 2), "ended_by_itself": bool(ended)}
|
||||
for pid in (parent, process.pid):
|
||||
if pid is not None:
|
||||
kill_tree(pid)
|
||||
result = host._seed_result(binary, index, seed_work, [], seed_work / "none.log", trace, process.pid, True, close,
|
||||
lambda audit: host.save_audit(audit_dir, name, index, audit))
|
||||
except host.TraceError as e:
|
||||
result = {"seed": index, "steps": [], "kinds": {}, "files": [], "ours": {}, "trace": {"exited": False}, "problems": ["the trace of the run could not be taken: %s" % e]}
|
||||
finally:
|
||||
stop_site()
|
||||
for pid in (parent, process.pid if process is not None else None):
|
||||
if pid is not None:
|
||||
kill_tree(pid)
|
||||
trace.cleanup()
|
||||
result["problems"] = result.get("problems", []) + problems
|
||||
return result
|
||||
|
||||
|
||||
def kill_tree(pid: int) -> None:
|
||||
"""The process `pid` and what is left of its descendants ended (nothing is left of a browser that closed by itself)."""
|
||||
import psutil
|
||||
|
||||
try:
|
||||
parent = psutil.Process(pid)
|
||||
victims = parent.children(recursive=True) + [parent]
|
||||
except psutil.Error:
|
||||
return
|
||||
for p in victims:
|
||||
try:
|
||||
p.kill()
|
||||
except psutil.Error:
|
||||
pass
|
||||
|
||||
|
||||
def run_retail(binary: str, leg: str, launches: int, label: str, audit_dir=None) -> dict:
|
||||
"""The footprint document of the retail browser at `binary` (a staged copy: `host.staged_engine`): a warm-up and `launches` measured launches, one browser at a time."""
|
||||
work = Path(tempfile.mkdtemp(prefix="ab-host-"))
|
||||
problems, seeds = [], []
|
||||
try:
|
||||
warm = run_retail_seed(binary, 0, work, "warmup", audit_dir)
|
||||
problems += ["warm-up: %s" % p for p in warm.get("problems", [])]
|
||||
print("warm-up (discarded): %s; %d host paths" % (json.dumps(warm["kinds"], sort_keys=True), len(warm["files"])))
|
||||
sys.stdout.flush()
|
||||
for index in range(launches):
|
||||
fp = run_retail_seed(binary, index, work, "measured%d" % index, audit_dir)
|
||||
seeds.append(fp)
|
||||
problems += ["launch %d: %s" % (index, p) for p in fp.get("problems", [])]
|
||||
print("launch %d: %s; %d host paths" % (index, json.dumps(fp["kinds"], sort_keys=True), len(fp["files"])))
|
||||
sys.stdout.flush()
|
||||
finally:
|
||||
shutil.rmtree(work, ignore_errors=True)
|
||||
return {"format": host.FORMAT, "engine": label, "leg": leg, "platform": sys.platform, "seeds": seeds, "warmup": warm, "problems": problems,
|
||||
"binary": os.path.basename(os.path.dirname(os.path.realpath(binary))), "prefs": RETAIL_PREFS,
|
||||
"user_root": host.profile_root_of_this_machine()}
|
||||
|
||||
|
||||
def capture(args) -> int:
|
||||
"""`retail`: stage the build, run it, write the document with what names the build (`build.json` of the fetch: the installer's sha256 and the BuildID; the sha256 of its xul.dll) and the
|
||||
run that made it (GITHUB_RUN_ID, GITHUB_SHA). 0 when the document was written and holds no problem, 1 when it holds one (it is written all the same), 2 when nothing could run."""
|
||||
if sys.platform != "win32":
|
||||
print("the retail capture is for Windows")
|
||||
return 3
|
||||
binary = Path(args.binary)
|
||||
if not binary.is_file():
|
||||
print("FAIL %s does not exist" % binary)
|
||||
return 2
|
||||
build = json.loads(Path(args.build).read_text(encoding="utf-8")) if args.build else {}
|
||||
xul = binary.parent / "xul.dll"
|
||||
args.out.parent.mkdir(parents=True, exist_ok=True)
|
||||
with host.staged_engine(str(binary)) as staged:
|
||||
document = run_retail(staged, args.leg, args.launches, args.label, args.out.parent / (args.out.stem + ".audit"))
|
||||
document.update({"build": build, "xul_sha256": sha256_file(xul) if xul.is_file() else None,
|
||||
"run": {"id": os.environ.get("GITHUB_RUN_ID"), "sha": os.environ.get("GITHUB_SHA"), "repository": os.environ.get("GITHUB_REPOSITORY")}})
|
||||
host.write_json(args.out, document)
|
||||
for line in document["problems"]:
|
||||
print("FAIL " + line)
|
||||
print("RETAIL CAPTURE %s: %d measured launches, %d problems" % ("FAILED" if document["problems"] else "OK", len(document["seeds"]), len(document["problems"])))
|
||||
return 1 if document["problems"] else 0
|
||||
|
||||
|
||||
# -
|
||||
# The rows.
|
||||
|
||||
def retail_state(document: dict) -> dict:
|
||||
"""{"files": {normalised path: n launches}, "kinds": {kind: n launches}, "launches": n}: how many of the measured launches of the retail capture have each host path (normalised
|
||||
as the rows' names, `host.normalise_leaf`) and each kind of process."""
|
||||
files: dict = {}
|
||||
kinds: dict = {}
|
||||
seeds = document.get("seeds", [])
|
||||
for seed in seeds:
|
||||
for path in {host.normalise_leaf(p, document.get("user_root")) for p in seed.get("files", [])}:
|
||||
files[path] = files.get(path, 0) + 1
|
||||
for kind in host.judged_kinds(seed):
|
||||
kinds[kind] = kinds.get(kind, 0) + 1
|
||||
return {"files": files, "kinds": kinds, "launches": len(seeds)}
|
||||
|
||||
|
||||
def _slug(text: str) -> str:
|
||||
return re.sub(r"[^a-z0-9]+", "-", text.lower()).strip("-")
|
||||
|
||||
|
||||
def source_of(document: dict, capture_path: str) -> dict:
|
||||
build = document.get("build") or {}
|
||||
return {"capture": capture_path, "run_id": (document.get("run") or {}).get("id"), "xul_sha256": document.get("xul_sha256"),
|
||||
"installer_sha256": build.get("sha256") or build.get("installer_sha256"), "build_id": build.get("build_id") or build.get("buildid")}
|
||||
|
||||
|
||||
def derive(diff: dict, document: dict, capture_path: str, os_name: str = "windows", user_root: str | None = None, hidden_desktop: bool = False) -> tuple:
|
||||
"""`(rows, undeclared)`: one row for each leaf of `diff["differences"]` (the A/B verdict of a candidate) whose two sides are the same in every seed it differs in and that retail
|
||||
windowed explains (the candidate has the path or the kind exactly when retail has it in every measured launch); the others, with what retail does, are `undeclared`.
|
||||
`hidden_desktop` says the capture is retail on the core's hidden desktop: its rows carry REASON_HIDDEN, and a capture is refused when its `mode` and this flag disagree."""
|
||||
if hidden_desktop != str(document.get("mode") or "").startswith(HIDDEN_MODE):
|
||||
raise ValueError("the capture %s a hidden-desktop capture: the reason of its rows cannot be %r" % ("is not" if hidden_desktop else "is", REASON_HIDDEN if hidden_desktop else REASON))
|
||||
reason = REASON_HIDDEN if hidden_desktop else REASON
|
||||
retail = retail_state(document)
|
||||
full = retail["launches"]
|
||||
if not full:
|
||||
raise ValueError("the retail capture has no measured launch")
|
||||
grouped: dict = {}
|
||||
for d in diff["differences"]:
|
||||
grouped.setdefault(d["leaf"], []).append(d)
|
||||
rows, undeclared = [], []
|
||||
for leaf, items in sorted(grouped.items()):
|
||||
category = items[0]["category"]
|
||||
sides = {(host._state(d["a"]), host._state(d["b"])) for d in items}
|
||||
name = host.normalise_leaf(leaf[len("file."):], user_root or diff.get("user_root")) if category == "file" else leaf[len("proc."):]
|
||||
seen = retail["files" if category == "file" else "kinds"].get(name, 0)
|
||||
retail_has = seen == full
|
||||
entry = {"leaf": leaf, "name": name, "category": category, "seeds": sorted(d["seed"] for d in items), "sides": sorted(sides),
|
||||
"retail_launches_with_it": "%d/%d" % (seen, full)}
|
||||
if category not in ("file", "proc") or len(sides) != 1:
|
||||
undeclared.append(dict(entry, why="the difference is not the same in every seed it shows in" if len(sides) != 1 else "not a path nor a process kind"))
|
||||
continue
|
||||
(published, candidate), = sides
|
||||
if (candidate == "present") != retail_has or (seen not in (0, full)):
|
||||
undeclared.append(dict(entry, why="retail windowed %s it, the candidate %s it" % ("has" if retail_has else "does not have", "has" if candidate == "present" else "does not have")
|
||||
if seen in (0, full) else "retail windowed has it in %d of %d launches" % (seen, full)))
|
||||
continue
|
||||
rows.append({"id": "%s-%s" % (category, _slug(name)), "os": os_name, "category": category, "name": name, "published": published, "candidate": candidate,
|
||||
"reason": reason, "source": source_of(document, capture_path)})
|
||||
return rows, undeclared
|
||||
|
||||
|
||||
def derive_command(args) -> int:
|
||||
diff = json.loads(args.diff.read_text(encoding="utf-8"))
|
||||
document = json.loads(args.retail.read_text(encoding="utf-8"))
|
||||
rows, undeclared = derive(diff, document, args.capture, user_root=args.user_root, hidden_desktop=args.hidden_desktop)
|
||||
print("%d rows derived, %d differences retail windowed does not show (left undeclared)" % (len(rows), len(undeclared)))
|
||||
for row in rows:
|
||||
print("ROW %s: published %s, candidate %s" % (row["id"], row["published"], row["candidate"]))
|
||||
for entry in undeclared:
|
||||
print("UNDECLARED %s (seeds %s): %s; retail launches with it %s" % (entry["leaf"], entry["seeds"], entry["why"], entry["retail_launches_with_it"]))
|
||||
if args.write:
|
||||
current = json.loads(args.expected.read_text(encoding="utf-8"))
|
||||
kept = [r for r in current["differences"] if r["id"] not in {x["id"] for x in rows}]
|
||||
current["differences"] = kept + rows
|
||||
args.expected.write_text(json.dumps(current, indent=2, sort_keys=False) + "\n", encoding="utf-8", newline="\n")
|
||||
print("wrote %d rows in %s" % (len(current["differences"]), args.expected))
|
||||
return 0
|
||||
|
||||
|
||||
# -
|
||||
# The rows of the host only differences of a Linux A/B (`host-only`).
|
||||
|
||||
REASON_HOST_ONLY = "host only"
|
||||
NOTE_GTK_SETTINGS = "a real window initialises GtkSettings; every page-visible key is the core's pref (nsXPLookAndFeel.cpp:1024/:1035/:1087)"
|
||||
NOTE_FONTCONFIG = "the published engine reads the host's fontconfig tree and the candidate never does: cause commit bddc7de757 (engine, the empty fontconfig)"
|
||||
NOTE_XDG = "cause core #384 (the GTK environment)"
|
||||
NOTE_NOT_TRACED = "not traced"
|
||||
#: (pattern of the normalised name of the leaf (`host.normalise_leaf`: a backslash for each `/`, `<profile>` for the home folder of the run), (published, candidate) the row is declared in, the note naming the cause).
|
||||
#: The first rule that matches names the leaf; a leaf that none matches is refused.
|
||||
HOST_ONLY_RULES = (
|
||||
(re.compile(r"^\\(etc|usr\\share)\\gtk-3\.0\\settings\.ini$"), ("absent", "present"), NOTE_GTK_SETTINGS),
|
||||
(re.compile(r"^\\etc\\fonts(\\.*)?$"), ("present", "absent"), NOTE_FONTCONFIG),
|
||||
(re.compile(r"^\\usr\\share\\fontconfig(\\.*)?$"), ("present", "absent"), NOTE_FONTCONFIG),
|
||||
(re.compile(r"^<profile>\\\.config\\fontconfig(\\.*)?$"), ("present", "absent"), NOTE_FONTCONFIG),
|
||||
(re.compile(r"^<profile>\\\.fonts\.conf\.d(\\.*)?$"), ("present", "absent"), NOTE_FONTCONFIG),
|
||||
(re.compile(r"^<profile>\\\.config$"), ("present", "absent"), NOTE_FONTCONFIG),
|
||||
(re.compile(r"^\\etc\\xdg$"), ("present", "absent"), NOTE_XDG),
|
||||
(re.compile(r"^<profile>\\\.config\\mozilla\\firefox\\(Crash Reports|Pending Pings)(\\.*)?$"), ("present", "absent"), NOTE_NOT_TRACED),
|
||||
(re.compile(r"^<profile>\\\.config\\mozilla\\firefox\\profiles\.ini$"), ("present", "absent"), NOTE_NOT_TRACED),
|
||||
(re.compile(r"^\\proc(\\(N|self))?$"), ("absent", "present"), NOTE_NOT_TRACED),
|
||||
)
|
||||
|
||||
|
||||
def host_only_rule_for(name: str, published: str, candidate: str) -> tuple:
|
||||
"""`(note, why)`: the note of the first rule whose pattern matches `name` and whose direction is `(published, candidate)`; `note` is None, and `why` says it, for a leaf no rule names or one named in the other direction."""
|
||||
named = [(direction, note) for pattern, direction, note in HOST_ONLY_RULES if pattern.match(name)]
|
||||
if not named:
|
||||
return None, "no rule names it"
|
||||
for direction, note in named:
|
||||
if direction == (published, candidate):
|
||||
return note, ""
|
||||
return None, "a rule names it as published %s, candidate %s, not as published %s, candidate %s" % (*named[0][0], published, candidate)
|
||||
|
||||
|
||||
def derive_host_only(diff: dict, run_id: str, diff_sha256: str, os_name: str = "linux", diff_name: str = "diff.json") -> tuple:
|
||||
"""`(rows, refused)`: one row for each leaf of `diff["differences"]` (the A/B verdict of the candidate run `run_id`) that a rule of HOST_ONLY_RULES names, in the direction the rule says, with the same two sides in
|
||||
every seed of the run; the others are `refused`, each with its leaf, seeds and why. The row is per normalised leaf (`host.normalise_leaf` with the `user_root` of the diff) and its `os` is `os_name`."""
|
||||
if diff.get("mode") != "a-b":
|
||||
raise ValueError("the diff is not an A/B verdict (mode %r): the host only rows are declared on an A/B" % diff.get("mode"))
|
||||
seeds = sorted({d["seed"] for d in diff["differences"]})
|
||||
grouped: dict = {}
|
||||
for d in diff["differences"]:
|
||||
grouped.setdefault(d["leaf"], []).append(d)
|
||||
rows, refused = [], []
|
||||
for leaf, items in sorted(grouped.items()):
|
||||
category = items[0]["category"]
|
||||
sides = {(host._state(d["a"]), host._state(d["b"])) for d in items}
|
||||
found = sorted(d["seed"] for d in items)
|
||||
entry = {"leaf": leaf, "seeds": found}
|
||||
if category != "file":
|
||||
refused.append(dict(entry, why="not a path: no rule names a %s" % category))
|
||||
continue
|
||||
if len(sides) != 1 or found != seeds:
|
||||
refused.append(dict(entry, why="the difference is not the same in every seed of the run (seeds of the run %s)" % seeds))
|
||||
continue
|
||||
name = host.normalise_leaf(leaf[len("file."):], diff.get("user_root"))
|
||||
(published, candidate), = sides
|
||||
note, why = host_only_rule_for(name, published, candidate)
|
||||
if note is None:
|
||||
refused.append(dict(entry, why=why, name=name))
|
||||
continue
|
||||
rows.append({"id": "%s-file-%s" % (os_name, _slug(name)), "os": os_name, "category": "file", "name": name, "published": published, "candidate": candidate,
|
||||
"reason": REASON_HOST_ONLY, "note": note, "source": {"run_id": str(run_id), "diff": diff_name, "diff_sha256": diff_sha256}})
|
||||
ids = [r["id"] for r in rows]
|
||||
if len(ids) != len(set(ids)):
|
||||
raise ValueError("two leaves give the same row id: %s" % sorted({i for i in ids if ids.count(i) > 1}))
|
||||
return rows, refused
|
||||
|
||||
|
||||
def host_only_command(args) -> int:
|
||||
raw = args.diff.read_bytes()
|
||||
rows, refused = derive_host_only(json.loads(raw.decode("utf-8")), args.run_id, hashlib.sha256(raw).hexdigest(), os_name=args.os)
|
||||
causes: dict = {}
|
||||
for row in rows:
|
||||
causes[row["note"]] = causes.get(row["note"], 0) + 1
|
||||
print("%d host only rows derived, %d leaves refused" % (len(rows), len(refused)))
|
||||
for note, n in sorted(causes.items()):
|
||||
print("CAUSE %d rows: %s" % (n, note))
|
||||
for entry in refused:
|
||||
print("REFUSED %s (seeds %s): %s" % (entry["leaf"], entry["seeds"], entry["why"]))
|
||||
if refused:
|
||||
print("nothing written: a leaf no rule of HOST_ONLY_RULES names is not declared")
|
||||
return 2
|
||||
if args.write:
|
||||
current = json.loads(args.expected.read_text(encoding="utf-8"))
|
||||
kept = [r for r in current["differences"] if r["id"] not in {x["id"] for x in rows}]
|
||||
current["differences"] = kept + rows
|
||||
args.expected.write_text(json.dumps(current, indent=2, sort_keys=False) + "\n", encoding="utf-8", newline="\n")
|
||||
print("wrote %d rows in %s" % (len(current["differences"]), args.expected))
|
||||
return 0
|
||||
|
||||
|
||||
def main(argv=None) -> int:
|
||||
ap = argparse.ArgumentParser(description=__doc__.split("\n")[0])
|
||||
sub = ap.add_subparsers(dest="cmd", required=True)
|
||||
r = sub.add_parser("retail")
|
||||
r.add_argument("binary")
|
||||
r.add_argument("--leg", required=True)
|
||||
r.add_argument("--out", type=Path, required=True)
|
||||
r.add_argument("--build", type=Path, default=None, help="build.json of core's scripts/retail/firefox_build.py fetch")
|
||||
r.add_argument("--launches", type=int, default=3)
|
||||
r.add_argument("--label", default="retail windowed")
|
||||
d = sub.add_parser("derive")
|
||||
d.add_argument("--diff", type=Path, required=True)
|
||||
d.add_argument("--retail", type=Path, required=True)
|
||||
d.add_argument("--capture", required=True, help="the path of the capture in RetailCaptures")
|
||||
d.add_argument("--expected", type=Path, default=host.EXPECTED_FILE)
|
||||
d.add_argument("--user-root", default=None, help="the folder that holds the profile folders on the machine of the A/B run, when its diff.json does not say (user_root)")
|
||||
d.add_argument("--hidden-desktop", action="store_true", help="the capture is retail on the core's hidden desktop (its mode says so): the rows carry the reason %r" % REASON_HIDDEN)
|
||||
d.add_argument("--write", action="store_true")
|
||||
h = sub.add_parser("host-only")
|
||||
h.add_argument("--diff", type=Path, required=True, help="the diff.json of the A/B of a candidate run")
|
||||
h.add_argument("--run-id", required=True, help="the id of the candidate run that made the diff.json")
|
||||
h.add_argument("--expected", type=Path, default=host.EXPECTED_FILE)
|
||||
h.add_argument("--os", default="linux", help="the os of the rows: the platform of the A/B (the matcher applies a row to the A/B of its own os)")
|
||||
h.add_argument("--write", action="store_true")
|
||||
args = ap.parse_args(argv)
|
||||
if args.cmd == "retail":
|
||||
return capture(args)
|
||||
return host_only_command(args) if args.cmd == "host-only" else derive_command(args)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -54,8 +54,37 @@ TAB_PREFIX = "crash.tab."
|
||||
TAB_LOST = ("cannot find session", "target closed", "targetclosederror", "session closed", "has been closed", "pipe is closed", "pipe closed", "page crashed", "tab crashed")
|
||||
STRACE_TAIL_LINES = 100
|
||||
SIGNAL_LINES = 20
|
||||
#: The gdb commands: every thread's stack, the reason MOZ_CRASH wrote, the libraries the core mapped.
|
||||
GDB_COMMANDS = ("thread apply all bt", "x/s *(char**)&gMozCrashReason", "info sharedlibrary")
|
||||
#: What gdb runs inside the core to print the whole argv of the crashed process, one `INVPW-ARGV <n> <json string>` line per argument (`argv_of`). The core's `Core was generated by` line
|
||||
#: (the kernel's `psargs`) keeps 80 bytes of the arguments and so cuts a long engine path before its flags; the strings themselves are in the core, in the stack the kernel built at exec:
|
||||
#: from the end of AT_PLATFORM (above AT_RANDOM) the argument strings, then the environment strings, then the string AT_EXECFN names. The arguments end where the first `NAME=value` begins.
|
||||
ARGV_SCRIPT = r"""
|
||||
import json, re
|
||||
try:
|
||||
aux = {}
|
||||
for line in gdb.execute("info auxv", to_string=True).splitlines():
|
||||
found = re.match(r"^\s*\d+\s+(AT_\w+)\s.*?(0x[0-9a-fA-F]+)", line)
|
||||
if found:
|
||||
aux[found.group(1)] = int(found.group(2), 16)
|
||||
memory = gdb.selected_inferior()
|
||||
start, end = aux["AT_RANDOM"] + 16, aux["AT_EXECFN"]
|
||||
for name in ("AT_BASE_PLATFORM", "AT_PLATFORM"):
|
||||
if start <= aux.get(name, 0) < end:
|
||||
start = aux[name] + bytes(memory.read_memory(aux[name], 64)).index(b"\0") + 1
|
||||
if not 0 < end - start <= 4 * 1024 * 1024:
|
||||
raise ValueError("the strings of the stack are not between %#x and %#x" % (start, end))
|
||||
argv = []
|
||||
for raw in bytes(memory.read_memory(start, end - start)).lstrip(b"\0").rstrip(b"\0").split(b"\0"):
|
||||
text = raw.decode("utf-8", "replace")
|
||||
if argv and re.match(r"^[A-Za-z_][A-Za-z0-9_]*=", text):
|
||||
break
|
||||
argv.append(text)
|
||||
for index, text in enumerate(argv):
|
||||
print("INVPW-ARGV %d %s" % (index, json.dumps(text)))
|
||||
except Exception as exc:
|
||||
print("INVPW-ARGV-ERROR %s: %s" % (type(exc).__name__, exc))
|
||||
"""
|
||||
#: The gdb commands: every thread's stack, the reason MOZ_CRASH wrote, the libraries the core mapped, the whole argv of the process.
|
||||
GDB_COMMANDS = ("thread apply all bt", "x/s *(char**)&gMozCrashReason", "info sharedlibrary", "python exec(%r)" % ARGV_SCRIPT)
|
||||
GDB_LIMIT = 400_000
|
||||
CORE_LIMIT = 3
|
||||
#: The exit code of Linux processes that a signal ended is the negative of its number (Python's `Popen`).
|
||||
@@ -199,6 +228,7 @@ CUT_LINE = 79
|
||||
#: The shortest prefix of a flag that names it: `back` is the start of `backgroundtask`, the one Firefox flag that begins with it.
|
||||
FLAG_PREFIX_MIN = 4
|
||||
_HEADER = re.compile(r"Core was generated by `([^']*)'")
|
||||
_ARGV_LINE = re.compile(r"^INVPW-ARGV (\d+) (\".*\")\s*$", re.M)
|
||||
_THREAD_HEADER = re.compile(r"^Thread (\d+) \((.*)\):\s*$")
|
||||
_CURRENT_THREAD = re.compile(r"\[Current thread is (\d+) ")
|
||||
_FRAME = re.compile(r"^#\d+\s+(.*)$")
|
||||
@@ -208,18 +238,36 @@ _SHA = re.compile(r"^[0-9a-f]{40}$")
|
||||
_FETCHED: dict = {}
|
||||
|
||||
|
||||
def process_type(text: str) -> str | None:
|
||||
"""The process type of the crashed process, from gdb's `Core was generated by` line; None when the line cannot say.
|
||||
|
||||
`-backgroundtask` (one or two dashes) gives `backgroundtask`. `-contentproc` gives its last token when that is a whole child type (`tab`, `gpu`, ...) and the line is not cut.
|
||||
A line with neither flag and not cut is the `parent`. A cut line (the kernel keeps 80 bytes of the arguments with the NUL, so 79 visible characters or more) whose last token,
|
||||
without its leading dashes, is a prefix of `backgroundtask` of at least 4 characters gives `backgroundtask` (no other Firefox flag begins with `back`); anything else cut gives None."""
|
||||
found = _HEADER.search(text or "")
|
||||
if not found:
|
||||
def argv_of(text: str) -> list | None:
|
||||
"""The whole argv of the crashed process, from the `INVPW-ARGV <n> <json string>` lines `ARGV_SCRIPT` made gdb print (n counts from 0 without a gap); None when gdb did not print them
|
||||
(no python in gdb, no auxv in the core, memory the core did not keep): the arguments are then not known."""
|
||||
found = _ARGV_LINE.findall(text or "")
|
||||
try:
|
||||
argv = [json.loads(value) for _n, value in found]
|
||||
except ValueError:
|
||||
return None
|
||||
line = found.group(1)
|
||||
tokens = line.split()[1:]
|
||||
cut = len(line) >= CUT_LINE
|
||||
return argv if argv and [int(n) for n, _v in found] == list(range(len(found))) else None
|
||||
|
||||
|
||||
def process_type(text: str) -> str | None:
|
||||
"""The process type of the crashed process; None when it cannot be said (`crash_record` then names it `unknown`).
|
||||
|
||||
The whole argv (`argv_of`) decides when gdb printed it: `-backgroundtask` (one or two dashes) gives `backgroundtask`, `-contentproc` its last argument when that is a whole child type
|
||||
(`tab`, `gpu`, ...), and an argv with neither flag is the `parent`.
|
||||
Without it only gdb's `Core was generated by` line is left, and the kernel keeps 80 bytes of the arguments with the NUL (79 visible characters, and gdb drops a trailing space, so a line of
|
||||
78 may be a cut one): a line of 78 characters or more is cut, and a line that is not cut is the whole command line, so it names `parent` when neither flag is in it. A cut line says
|
||||
`backgroundtask` when its last token, without its leading dashes, is a prefix of `backgroundtask` of at least 4 characters (no other Firefox flag begins with `back`) or a whole
|
||||
`-backgroundtask` is in it; a cut `-contentproc` line, and any other cut line, gives None: the arguments past the cut are not known and `parent` is never inferred from them."""
|
||||
argv = argv_of(text)
|
||||
if argv is not None:
|
||||
tokens, cut = argv[1:], False
|
||||
else:
|
||||
found = _HEADER.search(text or "")
|
||||
if not found:
|
||||
return None
|
||||
line = found.group(1)
|
||||
tokens = line.split()[1:]
|
||||
cut = len(line) >= CUT_LINE - 1
|
||||
if any(t in ("-backgroundtask", "--backgroundtask") for t in tokens):
|
||||
return "backgroundtask"
|
||||
if any(t in ("-contentproc", "--contentproc") for t in tokens):
|
||||
@@ -306,7 +354,8 @@ def crash_record(text: str, core_name: str, mtime: float | None = None, closing_
|
||||
"""The record the matcher takes for one core: {process, phase, thread, frames, reason}; a field the evidence cannot give is left out, so a row that names it cannot match.
|
||||
`text` is gdb's text of the core (`gdb_report`), `core_name` the core's file name, `mtime` its modification time, `closing_at` the moment the launch began to close."""
|
||||
frames = crashing_thread(text)[1]
|
||||
out = {"process": process_type(text), "phase": phase_of(core_name, mtime, closing_at), "thread": thread_name(text, core_name), "frames": frames, "reason": reason_of(text)}
|
||||
has_header = argv_of(text) is not None or _HEADER.search(text or "") is not None
|
||||
out = {"process": process_type(text) or ("unknown" if has_header else None), "phase": phase_of(core_name, mtime, closing_at), "thread": thread_name(text, core_name), "frames": frames, "reason": reason_of(text)}
|
||||
return {key: value for key, value in out.items() if value is not None}
|
||||
|
||||
|
||||
|
||||
@@ -14,6 +14,9 @@ side is a SET, and nothing in it is chosen by hand: the last published `invisibl
|
||||
(`--no-deps`, from DIR/published: the wheelhouse of the run, whose job downloaded the files this lock names there). Prints the venv's python.
|
||||
DIR itself holds the candidate's wheels of the same two packages (built from core_ref and wrapper_ref, and at an equal version with the SAME
|
||||
file names): the set never takes a file of invisible-core or invisible-playwright from DIR, only from DIR/published.
|
||||
python scripts/ci_published_set.py install-candidate --house DIR --venv DIR
|
||||
the same for the CANDIDATE's side: the gate's third-party lock, then the candidate's two wheels (the ones in DIR, never DIR/published), offline, in a venv
|
||||
of its own. The host oracle launches the candidate's engine from it as it launches the control's from the set's venv. Prints the venv's python.
|
||||
python scripts/ci_published_set.py verify --python PY what that python imports is the lock's set, from its own venv and from nowhere else
|
||||
python scripts/ci_published_set.py fetch --work DIR (run BY the set's python) fetches the engine the way a user's core does: its own seal
|
||||
python scripts/ci_published_set.py tag (run BY the set's python) the tag its seal names
|
||||
@@ -269,6 +272,39 @@ def install(house: Path, venv: Path, lock: Path = LOCK_PATH, run=subprocess.run)
|
||||
return venv_python(venv)
|
||||
|
||||
|
||||
def candidate_wheel(house: Path, name: str) -> tuple:
|
||||
"""(path, sha256) of THE wheel of `name` in the wheelhouse's own folder (not `published/`): the candidate's, built from core_ref or wrapper_ref. FileNotFoundError when there is
|
||||
none or more than one: which wheel is the candidate's is never a choice made here."""
|
||||
stem = name.replace("-", "_").lower() + "-"
|
||||
found = sorted(path for path in house.glob("*.whl") if path.name.lower().startswith(stem))
|
||||
if len(found) != 1:
|
||||
raise FileNotFoundError("%s: the wheelhouse %s must hold exactly one wheel of the candidate (built from its ref), it holds %d: %s"
|
||||
% (name, house, len(found), ", ".join(p.name for p in found) or "none"))
|
||||
return found[0], hashlib.sha256(found[0].read_bytes()).hexdigest()
|
||||
|
||||
|
||||
def install_candidate(house: Path, venv: Path, run=subprocess.run) -> Path:
|
||||
"""A venv for the CANDIDATE of the same kind as the set's (`install`): the gate's third-party lock from the wheelhouse (`house/lock.txt`), then the candidate's own two wheels
|
||||
(the ones in `house`, built from core_ref and wrapper_ref; never `published/`), `--no-deps`, offline, over a clean environment, then `pip check`. The candidate's engine is
|
||||
launched from this venv as the control's is launched from its own: the python that runs a side is the same kind of thing on both, so that what a side reads of the host is
|
||||
the engine's and not the difference between a venv and the job's python. What was installed is recorded as in the set's venv (`RECORD_FILE`). Returns the python."""
|
||||
house_lock = house / "lock.txt"
|
||||
if not house_lock.is_file():
|
||||
raise FileNotFoundError("the wheelhouse %s has no lock.txt (the gate's lock): it is not a py-deps wheelhouse" % house)
|
||||
chosen = {name: candidate_wheel(house, name) for name in (CORE, WRAPPER)}
|
||||
run([sys.executable, "-m", "venv", str(venv)], check=True)
|
||||
python = str(venv_python(venv))
|
||||
base = [python, "-m", "pip", "install", "--quiet", "--no-index"]
|
||||
run(base + ["--require-hashes", "--find-links", str(house), "-r", str(house_lock)], check=True, env=clean_env())
|
||||
run(base + ["--no-deps"] + [str(path) for path, _sha in chosen.values()], check=True, env=clean_env())
|
||||
checked = run([python, "-m", "pip", "check"], capture_output=True, text=True, env=clean_env())
|
||||
if checked.returncode != 0:
|
||||
raise RuntimeError("pip check of the candidate's venv %s is red (the requirements of the candidate's wheels are not met by the wheelhouse's dependencies): %s"
|
||||
% (venv, (checked.stdout + checked.stderr).strip()[-1500:]))
|
||||
write_record(venv, chosen)
|
||||
return venv_python(venv)
|
||||
|
||||
|
||||
def file_digest(data: bytes) -> str:
|
||||
"""The digest of a file as a wheel's RECORD writes it: `sha256=<urlsafe base64, no padding>`."""
|
||||
return "sha256=" + base64.urlsafe_b64encode(hashlib.sha256(data).digest()).rstrip(b"=").decode()
|
||||
@@ -390,6 +426,9 @@ def main(argv=None) -> int:
|
||||
i.add_argument("--house", type=Path, required=True)
|
||||
i.add_argument("--venv", type=Path, required=True)
|
||||
i.add_argument("--lock", type=Path, default=LOCK_PATH)
|
||||
c = sub.add_parser("install-candidate")
|
||||
c.add_argument("--house", type=Path, required=True)
|
||||
c.add_argument("--venv", type=Path, required=True)
|
||||
v = sub.add_parser("verify")
|
||||
v.add_argument("--python", required=True)
|
||||
v.add_argument("--lock", type=Path, default=LOCK_PATH)
|
||||
@@ -420,6 +459,9 @@ def main(argv=None) -> int:
|
||||
return 1
|
||||
print(python)
|
||||
return 0
|
||||
if args.cmd == "install-candidate":
|
||||
print(install_candidate(args.house, args.venv))
|
||||
return 0
|
||||
if args.cmd == "verify":
|
||||
problems = verify(args.python, args.lock)
|
||||
print("\n".join("FAIL " + p for p in problems) if problems else "OK")
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Extracts, from the retail capture of the password-mask probe, the width retail Firefox on Windows gives a password field, into ci/retail-password-mask.json.
|
||||
|
||||
The e2e test ``tests/test_a_password_field_is_as_wide_as_on_retail_windows_e2e.py`` compares the width a page reads on a password field of our engine with the width RETAIL Firefox 159 on
|
||||
Windows read in the same page. That number is typed nowhere: it is read here from the capture,
|
||||
|
||||
``captures/firefox-159.0/windows-server-2025/password-mask/<date>/result.json``: the page's whole reading (``fonts.arial16.password["40"].scrollWidth``, the ``scrollWidth`` of an
|
||||
``<input type=password>`` of 40 x "a" in Arial 16px, the number a page reads) and ``meta.json`` (the sha256 of every file of the capture, of the page, of the binaries).
|
||||
|
||||
What is refused rather than filled in: a ``result.json`` whose sha256 is not the one ``meta.json`` lists; a page that is not the page of the capture (the sha256 of
|
||||
``tests/data/password_mask_page.html`` must be ``meta.json``'s ``page.sha256``); a result with an ``error``, another ``n``, or no ``arial16`` reading; a reading that disagrees with itself (the width of
|
||||
the password field in its own box and in the box of the 1, 10, 40 series; the verdict of the page, which must name U+25CF alone, the character Windows masks with).
|
||||
|
||||
The file records the capture's commit and run, the browser (version, build id, installer, ``firefox.exe`` and ``xul.dll`` sha256) and the sha256 of every file read. The wrapper's CI has no capture, so the
|
||||
tests read the committed file and this module's functions are tested on a small sample (tests/test_the_retail_password_mask_width_is_extracted_from_the_capture_not_typed.py). One command regenerates it:
|
||||
|
||||
python scripts/extract_retail_password_mask.py --capture <RetailCaptures>/captures/firefox-159.0/windows-server-2025/password-mask/2026-12-02 --commit <RetailCaptures commit> --write
|
||||
|
||||
and the same without ``--write`` compares the committed file with what the capture gives (the check).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
DATA_PATH = ROOT / "ci" / "retail-password-mask.json"
|
||||
PAGE_PATH = ROOT / "tests" / "data" / "password_mask_page.html"
|
||||
|
||||
#: The characters of the field: ``N`` copies of "a", read in the font case ``arial16`` (``font-family:Arial;font-size:16px``).
|
||||
N = 40
|
||||
FONT_CASE = "arial16"
|
||||
#: What Windows masks a password field with, and what the page's verdict must therefore name.
|
||||
MASK = "U+25CF"
|
||||
FORMAT = "password-mask/1"
|
||||
|
||||
|
||||
class ExtractError(Exception):
|
||||
"""What the capture does not give, or gives two ways: nothing is invented in its place."""
|
||||
|
||||
|
||||
def sha256_of(path: Path) -> str:
|
||||
return hashlib.sha256(path.read_bytes()).hexdigest()
|
||||
|
||||
|
||||
def reading(result: Dict[str, Any], where: str) -> Dict[str, Any]:
|
||||
"""The width of the password field in ``arial16``, after the checks of the reading against itself."""
|
||||
if "error" in result:
|
||||
raise ExtractError("%s: the page recorded an error: %s" % (where, str(result["error"])[:200]))
|
||||
if result.get("format") != FORMAT or result.get("n") != N:
|
||||
raise ExtractError("%s: format %r and n %r, not %r and %r" % (where, result.get("format"), result.get("n"), FORMAT, N))
|
||||
try:
|
||||
font = result["fonts"][FONT_CASE]
|
||||
width = font["password"][str(N)]["scrollWidth"]
|
||||
main = font["password"][str(N)]["scrollWidth_main"]
|
||||
mask_width = font["refs"][MASK]["text_input"][str(N)]["scrollWidth"]
|
||||
verdict = font["verdict"]["by_text_input_scrollWidth"]
|
||||
platform, dpr = result["env"]["platform"], result["env"]["devicePixelRatio"]
|
||||
except (KeyError, TypeError) as exc:
|
||||
raise ExtractError("%s: the reading lacks %s: no retail value, none invented" % (where, exc))
|
||||
if not isinstance(width, int) or width <= 0:
|
||||
raise ExtractError("%s: the width %r is not a positive integer" % (where, width))
|
||||
if main != width:
|
||||
raise ExtractError("%s: the password field reads %r in its own box and %r in the series box" % (where, main, width))
|
||||
if mask_width != width or verdict != [MASK]:
|
||||
raise ExtractError("%s: the password field is %r wide, %s in a text input is %r and the page's verdict is %r: not the mask character of Windows" % (where, width, MASK, mask_width, verdict))
|
||||
if platform != "Win32":
|
||||
raise ExtractError("%s: navigator.platform is %r, not Win32: not a Windows capture" % (where, platform))
|
||||
return {"password_scrollWidth": width, "mask": MASK, "devicePixelRatio": dpr, "platform": platform}
|
||||
|
||||
|
||||
def build(capture: Path, commit: str, page: Path = PAGE_PATH) -> Dict[str, Any]:
|
||||
result_path, meta_path = capture / "result.json", capture / "meta.json"
|
||||
for path in (result_path, meta_path, page):
|
||||
if not path.is_file():
|
||||
raise ExtractError("missing %s" % path)
|
||||
meta = json.loads(meta_path.read_text(encoding="utf-8"))
|
||||
listed = meta.get("files", {}).get("result.json", {}).get("sha256")
|
||||
if listed != sha256_of(result_path):
|
||||
raise ExtractError("%s is %s and meta.json lists %r: not the file the capture recorded" % (result_path, sha256_of(result_path), listed))
|
||||
page_sha = sha256_of(page)
|
||||
if page_sha != meta.get("page", {}).get("sha256"):
|
||||
raise ExtractError("%s is %s and the capture's page is %r: the test would not read the page retail read" % (page, page_sha, meta.get("page", {}).get("sha256")))
|
||||
got = reading(json.loads(result_path.read_text(encoding="utf-8")), str(result_path))
|
||||
binaries = meta.get("binaries", {})
|
||||
return {
|
||||
"about": "What retail Firefox on Windows reads on a password field in the page tests/data/password_mask_page.html (the width of 40 x 'a' in Arial 16px, which is 40 times the advance of the mask character), extracted by scripts/extract_retail_password_mask.py. Never edited by hand.",
|
||||
"capture": {
|
||||
"folder": "captures/firefox-159.0/windows-server-2025/password-mask/%s" % capture.name,
|
||||
"retail_captures_commit": commit,
|
||||
"run": "https://github.com/%s/actions/runs/%s" % (meta["source_run"]["repo"], meta["source_run"]["run_id"]),
|
||||
"browser": {"firefox_version": meta["firefox_version"], "build_id": meta["build_id"], "installer_sha256": binaries.get("installer_sha256"),
|
||||
"firefox_exe_sha256": binaries.get("firefox_exe_sha256"), "xul_dll_sha256": binaries.get("xul_dll_sha256")},
|
||||
"host": {"runner_image": meta["host"]["runner_image"], "os_version": meta["host"]["os_version"], "os_ubr": meta["host"]["os_ubr"]},
|
||||
},
|
||||
"files": [{"path": "result.json", "sha256": sha256_of(result_path)}, {"path": "meta.json", "sha256": sha256_of(meta_path)}],
|
||||
"page": {"path": "tests/data/password_mask_page.html", "sha256": page_sha},
|
||||
"n": N,
|
||||
"cases": {FONT_CASE: got},
|
||||
}
|
||||
|
||||
|
||||
def dumps(data: Dict[str, Any]) -> str:
|
||||
return json.dumps(data, indent=2, sort_keys=False) + "\n"
|
||||
|
||||
|
||||
def main(argv: Optional[List[str]] = None) -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__.split("\n\n")[0])
|
||||
parser.add_argument("--capture", required=True, type=Path, help="the folder of the capture in RetailCaptures (result.json and meta.json)")
|
||||
parser.add_argument("--commit", required=True, help="the RetailCaptures commit the capture is in")
|
||||
parser.add_argument("--write", action="store_true", help="write ci/retail-password-mask.json; without it the committed file is compared with the capture")
|
||||
args = parser.parse_args(argv)
|
||||
try:
|
||||
text = dumps(build(args.capture.resolve(), args.commit))
|
||||
except ExtractError as exc:
|
||||
print("EXTRACTION FAILED: %s" % exc, file=sys.stderr)
|
||||
return 2
|
||||
if args.write:
|
||||
DATA_PATH.write_text(text, encoding="utf-8", newline="\n")
|
||||
print("wrote %s" % DATA_PATH)
|
||||
return 0
|
||||
if DATA_PATH.read_text(encoding="utf-8") != text:
|
||||
print("%s is not what the capture gives" % DATA_PATH, file=sys.stderr)
|
||||
return 1
|
||||
print("%s is what the capture gives" % DATA_PATH)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,628 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Extracts, from the retail capture ``popup-move-to``, what a popup of the maximized window reads after ``resizeBy(0, 0)``, ``moveBy(10, 10)`` and ``moveTo(99999, 0)``, per display case and per phase of the
|
||||
wrapper test, in the state of a profile whose XUL store holds the main window's entry, into ci/retail-popup-move-resize.json.
|
||||
|
||||
The e2e test ``tests/test_a_popup_moves_and_resizes_as_declared_e2e.py`` compares a popup of ours with what RETAIL Firefox 159 on Windows read. Mozilla's ``LoadPersistentWindowState`` (AppWindow.cpp:2322-2350) gives a popup
|
||||
the stored spec of the main window when the store has the entry and leaves it its own spec when it has not. A real user's profile has the entry (any maximize, resize or activation after the chrome loads writes it,
|
||||
AppWindow.cpp :2549, :2561, :2625, :2771), a NEW profile that nothing has changed does not: there the FIRST popup is born with its own spec and reads one device pixel less at 150% (inner width 499, outer 514, against 500
|
||||
and 515) and, in some runs, at 125% (inner height 399). So EVERY popup of the test, the first included, expects the numbers of the STORED state. They are read, never typed:
|
||||
|
||||
* ``popup-move-to/<date>/<dpr>/<panel>/<launch>/raw.json`` (format ``retail-popup-move-to/1``), four launches per display case, each popup opened by a real click with ``width=500,height=400`` and closed before the next:
|
||||
``a`` the test's order, ``b`` phase 3 alone, ``c`` a throwaway popup (no call) and then the three phases, ``d`` phase 2 alone. The popups after the first of a launch (``later``: c; a and c; a and c) were opened after the
|
||||
first one closed and the main window was activated again, with the entry in the store: they are the expectations (``cases``). The plan of every launch, the calls, the features, the close of every popup and the order
|
||||
of the moments are checked, and popups of the same phase and position must read the same, or the extraction fails.
|
||||
* The sha256 of every raw.json is checked against the ``meta.json`` of its scale before it is read, and the run id, the browser (version, build id, installer sha256) and the sha256 of ``firefox.exe`` and
|
||||
``xul.dll`` (``run-info.json``) are recorded.
|
||||
* ``scripts/retail_popup_formula.py`` is the formula of the size of a popup (the code of Mozilla it follows is in its docstring), with the fresh spec and with the stored spec. The extraction applies it with the STORED
|
||||
spec to EVERY popup captured while the store held the entry and REFUSES TO WRITE if one cell disagrees: the later popups of every ``--move-to-capture`` and ``--move-to-also`` folder, the popups of
|
||||
``--second-session-capture`` whose ``store_before`` had the main-window entry (the profile is closed after session 1 and opened again), and the ``popup_move_resize`` of the window-geometry rounds named on the command line
|
||||
(``--rounds``). The frame (border, client origin, chrome) is read from the same rounds. The expectations must also be what the formula gives (``stored_spec_formula``).
|
||||
* The first popups (ordinal 1) are not expectations. They are recorded as a note, ``new_profile_state``, with the run ids: those of the second session with no entry in the store (``entry_recorded`` false) must be
|
||||
reproduced by the formula with the FRESH spec, those of the popup-move-to runs (store not recorded) by the fresh or the stored spec; the note says which cells the fresh spec reproduces and which it does not.
|
||||
|
||||
The wrapper's CI has no capture, so the tests read the committed file and this module's functions are tested on a small sample (tests/test_the_retail_popup_moves_and_resizes_are_extracted_from_the_capture_not_typed.py).
|
||||
One command regenerates the file:
|
||||
|
||||
python scripts/extract_retail_popup_move_resize.py --captures <RetailCaptures>/captures --rounds 2026-11-29-window-geometry-r8 2026-11-30-window-geometry-r9 2026-11-30-window-geometry-r11 2026-12-01-window-geometry-r12 --commit <RetailCaptures commit> --move-to-capture <RetailCaptures>/captures/firefox-159.0/windows-server-2025/popup-move-to/2026-12-02-b --move-to-run-id <id of the run> --move-to-commit <RetailCaptures commit> --move-to-also <RetailCaptures>/captures/firefox-159.0/windows-server-2025/popup-move-to/2026-12-02 <id of its run> --second-session-capture <RetailCaptures>/captures/firefox-159.0/windows-server-2025/popup-move-to-second-session/2026-12-02 --second-session-run-id <id of the run> --write
|
||||
|
||||
and the same without ``--write`` compares the committed file with what the captures give (the check).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Optional, Tuple
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
|
||||
import retail_popup_formula as formula # noqa: E402
|
||||
from extract_retail_popup_sizes import BROWSER_DIR, DISPLAYS, ExtractError, case_id, sha256_of # noqa: E402
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
DATA_PATH = ROOT / "ci" / "retail-popup-move-resize.json"
|
||||
MOMENTS = ("initial", "resized", "moved", "moved_to")
|
||||
FEATURES = "width=500,height=400"
|
||||
#: ``popup-move-to`` capture: the format of its raw.json and meta.json, the phase, and the order of phases of launch ``a`` (the test's order: phase 3 is the third popup).
|
||||
MOVE_TO_FORMAT = "retail-popup-move-to/1"
|
||||
MOVE_TO_META_FORMAT = "retail-popup-move-to-meta/1"
|
||||
POSITION_FIRST = "first"
|
||||
POSITION_LATER = "later"
|
||||
MOVE_TO_PHASES = ["resize_by_zero", "move_by", "move_to_far_right"]
|
||||
#: The launches of the capture and the popups each opens in order (``scripts/popup_move_to/run.py``, LAUNCHES): a is the test's order (phase 1 is the first popup of the browser); b phase 3 alone; c a throwaway
|
||||
#: popup opened and closed first (no call), then the three phases; d phase 2 alone. Every phase is thus read as the first popup of a browser and as a later one.
|
||||
MOVE_TO_LAUNCHES = {
|
||||
"a": ["resize_by_zero", "move_by", "move_to_far_right"],
|
||||
"b": ["move_to_far_right"],
|
||||
"c": ["throwaway", "resize_by_zero", "move_by", "move_to_far_right"],
|
||||
"d": ["move_by"],
|
||||
}
|
||||
MOVE_TO_MOMENTS = {
|
||||
"throwaway": ("initial",),
|
||||
"resize_by_zero": ("initial", "resized"),
|
||||
"move_by": ("initial", "moved"),
|
||||
"move_to_far_right": ("initial", "moved", "moved_to"),
|
||||
}
|
||||
MOVE_TO_CALLS = {
|
||||
"throwaway": {},
|
||||
"resize_by_zero": {"resized": "window.resizeBy(0, 0)"},
|
||||
"move_by": {"moved": "window.moveBy(10, 10)"},
|
||||
"move_to_far_right": {"moved": "window.moveBy(10, 10)", "moved_to": "window.moveTo(99999, 0)"},
|
||||
}
|
||||
MOVE_TO_BINARIES = ("firefox.exe", "xul.dll")
|
||||
|
||||
|
||||
def moment_reading(moment: Dict[str, Any], where: str) -> Dict[str, Any]:
|
||||
try:
|
||||
return {
|
||||
"inner": [moment["innerWidth"], moment["innerHeight"]],
|
||||
"outer": [moment["outerWidth"], moment["outerHeight"]],
|
||||
"screen": [moment["screenX"], moment["screenY"]],
|
||||
"avail": [moment["availLeft"], moment["availWidth"]],
|
||||
}
|
||||
except (KeyError, TypeError) as exc:
|
||||
raise ExtractError("%s: the moment lacks %s" % (where, exc))
|
||||
|
||||
|
||||
def read_step(raw: Dict[str, Any], where: str) -> Dict[str, Dict[str, Any]]:
|
||||
try:
|
||||
step = raw["steps"]["popup_move_resize"]
|
||||
moments = step["moments"]
|
||||
except (KeyError, TypeError):
|
||||
raise ExtractError("%s has no step popup_move_resize with moments" % where)
|
||||
if step.get("features") != FEATURES:
|
||||
raise ExtractError("%s: the popup was opened with %r, not %r" % (where, step.get("features"), FEATURES))
|
||||
missing = [m for m in MOMENTS if m not in moments]
|
||||
if missing:
|
||||
raise ExtractError("%s lacks the moments %r: no retail value, none invented" % (where, missing))
|
||||
readings = {m: moment_reading(moments[m], "%s %s" % (where, m)) for m in MOMENTS}
|
||||
opened, resized, moved, moved_to = (readings[m]["screen"] for m in MOMENTS)
|
||||
if not (opened == resized and moved != opened and moved_to != moved):
|
||||
raise ExtractError("%s: the positions %r do not follow the order initial, resized, moved, moved_to" % (where, {m: readings[m]["screen"] for m in MOMENTS}))
|
||||
return readings
|
||||
|
||||
|
||||
def build(captures: Path, rounds: List[str], commit: str) -> Dict[str, Any]:
|
||||
if len(rounds) < 2:
|
||||
raise ExtractError("at least two rounds are needed to say that rounds agree")
|
||||
cases: Dict[str, Dict[str, Any]] = {}
|
||||
files: List[Dict[str, str]] = []
|
||||
browser: Optional[Dict[str, Any]] = None
|
||||
for dpr_dir, panel, scale in DISPLAYS:
|
||||
first: Optional[Dict[str, Any]] = None
|
||||
for round_name in rounds:
|
||||
for launch in ("a", "b"):
|
||||
path = captures / BROWSER_DIR / round_name / dpr_dir / panel / launch / "raw.json"
|
||||
if not path.is_file():
|
||||
raise ExtractError("missing %s" % path)
|
||||
raw = json.loads(path.read_text(encoding="utf-8"))
|
||||
if raw.get("dpr_asked") != scale:
|
||||
raise ExtractError("%s asks scale %r, not %r" % (path, raw.get("dpr_asked"), scale))
|
||||
meta = {"firefox_version": raw["firefox_version"], "build_id": raw["build_id"], "installer_sha256": raw["installer_sha256"]}
|
||||
if browser not in (None, meta):
|
||||
raise ExtractError("%s is not the same browser as the others: %r and %r" % (path, meta, browser))
|
||||
browser = meta
|
||||
readings = read_step(raw, str(path))
|
||||
if first is None:
|
||||
first = readings
|
||||
elif readings != first:
|
||||
raise ExtractError("%s %s: round %s launch %s reads %r, the first one read %r" % (dpr_dir, panel, round_name, launch, readings, first))
|
||||
files.append({"path": "%s/%s/%s/%s/raw.json" % (round_name, dpr_dir, panel, launch), "sha256": sha256_of(path)})
|
||||
cases[case_id(panel, scale)] = first or {}
|
||||
return {
|
||||
"about": "What retail Firefox reads in a popup of the maximized window after resizeBy(0, 0), moveBy(10, 10) and moveTo(99999, 0), per display case, extracted by scripts/extract_retail_popup_move_resize.py. Never edited by hand.",
|
||||
"capture": {"rounds": rounds, "retail_captures_commit": commit, "popup_features": FEATURES, "moments_in_order": list(MOMENTS), "browser": browser},
|
||||
"files": files,
|
||||
"cases": cases,
|
||||
}
|
||||
|
||||
|
||||
def move_to_reading(moment: Dict[str, Any], where: str) -> Dict[str, Any]:
|
||||
"""One moment of the ``popup-move-to`` format (short keys: ``iw``, ``ih``, ``ow``, ``oh``, ``sx``, ``sy``, ``availL``, ``availW``), in the shape of ``moment_reading``."""
|
||||
try:
|
||||
return {
|
||||
"inner": [moment["iw"], moment["ih"]],
|
||||
"outer": [moment["ow"], moment["oh"]],
|
||||
"screen": [moment["sx"], moment["sy"]],
|
||||
"avail": [moment["availL"], moment["availW"]],
|
||||
}
|
||||
except (KeyError, TypeError) as exc:
|
||||
raise ExtractError("%s: the moment lacks %s" % (where, exc))
|
||||
|
||||
|
||||
def position_of(ordinal: int) -> str:
|
||||
"""``first``: the first popup the browser opens; ``later``: any popup after it (a throwaway popup counts)."""
|
||||
return POSITION_FIRST if ordinal == 1 else POSITION_LATER
|
||||
|
||||
|
||||
def read_launch(raw: Dict[str, Any], launch: str, where: str) -> List[Tuple[str, int, Dict[str, Dict[str, Any]]]]:
|
||||
"""``[(phase, ordinal, readings)]`` of one launch of the ``popup-move-to`` capture, each phase checked against the plan of the launch, its calls and the order of its moments."""
|
||||
if raw.get("format") != MOVE_TO_FORMAT:
|
||||
raise ExtractError("%s has the format %r, not %r" % (where, raw.get("format"), MOVE_TO_FORMAT))
|
||||
if raw.get("error") is not None:
|
||||
raise ExtractError("%s ends with the error %r" % (where, raw.get("error")))
|
||||
if raw.get("launch") != launch:
|
||||
raise ExtractError("%s is launch %r, not %r" % (where, raw.get("launch"), launch))
|
||||
if raw.get("phases_planned") != MOVE_TO_LAUNCHES[launch]:
|
||||
raise ExtractError("%s ran the popups %r, not %r: the position of a phase in the browser's life is not the one this launch is for" % (
|
||||
where, raw.get("phases_planned"), MOVE_TO_LAUNCHES[launch]))
|
||||
found = []
|
||||
for ordinal, phase in enumerate(MOVE_TO_LAUNCHES[launch], 1):
|
||||
label = "%s step phase_%s" % (where, phase)
|
||||
try:
|
||||
step = raw["steps"]["phase_" + phase]
|
||||
moments = step["moments"]
|
||||
except (KeyError, TypeError):
|
||||
raise ExtractError("%s is missing: no retail value, none invented" % label)
|
||||
if step.get("ordinal") != ordinal:
|
||||
raise ExtractError("%s is popup number %r of the browser, the plan says %r" % (label, step.get("ordinal"), ordinal))
|
||||
if step.get("features") != FEATURES:
|
||||
raise ExtractError("%s: the popup was opened with %r, not %r" % (label, step.get("features"), FEATURES))
|
||||
if step.get("closed") is not True:
|
||||
raise ExtractError("%s: the popup was not closed (%r), the next popup would not be the next one of a test that closes each" % (label, step.get("closed")))
|
||||
if step.get("calls") != MOVE_TO_CALLS[phase]:
|
||||
raise ExtractError("%s: the calls are %r, not %r" % (label, step.get("calls"), MOVE_TO_CALLS[phase]))
|
||||
wanted = MOVE_TO_MOMENTS[phase]
|
||||
missing = [m for m in wanted if m not in moments]
|
||||
if missing:
|
||||
raise ExtractError("%s lacks the moments %r: no retail value, none invented" % (label, missing))
|
||||
readings = {m: move_to_reading(moments[m], "%s %s" % (label, m)) for m in wanted}
|
||||
at = {m: readings[m]["screen"] for m in wanted}
|
||||
if phase == "resize_by_zero":
|
||||
in_order = at["resized"] == at["initial"]
|
||||
elif phase == "move_by":
|
||||
in_order = at["moved"] != at["initial"]
|
||||
elif phase == "move_to_far_right":
|
||||
in_order = at["moved"] != at["initial"] and at["moved_to"] != at["moved"]
|
||||
else:
|
||||
in_order = True
|
||||
if not in_order:
|
||||
raise ExtractError("%s: the positions %r do not follow the order %r" % (label, at, list(wanted)))
|
||||
if phase != "throwaway":
|
||||
found.append((phase, ordinal, readings))
|
||||
return found
|
||||
|
||||
|
||||
def build_move_to(capture: Path, run_id: str, commit: str) -> Dict[str, Any]:
|
||||
"""The readings of every phase as the first popup of a browser and as a later popup: the four launches of the four display cases of one ``popup-move-to`` capture folder (the date folder), each
|
||||
raw.json checked against the sha256 of its ``meta.json``. Popups of the same phase and the same position (``first``, ``later``) must read the same, or the extraction fails."""
|
||||
run_info_path = capture / "run-info.json"
|
||||
if not run_info_path.is_file():
|
||||
raise ExtractError("missing %s" % run_info_path)
|
||||
run_info = json.loads(run_info_path.read_text(encoding="utf-8"))
|
||||
try:
|
||||
binaries = {name: run_info["binaries"][name]["sha256"] for name in MOVE_TO_BINARIES}
|
||||
except (KeyError, TypeError) as exc:
|
||||
raise ExtractError("%s lacks the sha256 of %s" % (run_info_path, exc))
|
||||
cases: Dict[str, Dict[str, Dict[str, Dict[str, Any]]]] = {}
|
||||
sources: Dict[str, Dict[str, Dict[str, List[str]]]] = {}
|
||||
files: List[Dict[str, str]] = []
|
||||
browser: Optional[Dict[str, Any]] = None
|
||||
for dpr_dir, panel, scale in DISPLAYS:
|
||||
meta_path = capture / dpr_dir / "meta.json"
|
||||
if not meta_path.is_file():
|
||||
raise ExtractError("missing %s" % meta_path)
|
||||
meta_file = json.loads(meta_path.read_text(encoding="utf-8"))
|
||||
if meta_file.get("format") != MOVE_TO_META_FORMAT:
|
||||
raise ExtractError("%s has the format %r, not %r" % (meta_path, meta_file.get("format"), MOVE_TO_META_FORMAT))
|
||||
groups: Dict[Tuple[str, str], List[Tuple[str, int, Dict[str, Dict[str, Any]]]]] = {}
|
||||
for launch in MOVE_TO_LAUNCHES:
|
||||
path = capture / dpr_dir / panel / launch / "raw.json"
|
||||
if not path.is_file():
|
||||
raise ExtractError("missing %s" % path)
|
||||
want = (meta_file.get("raw_sha256") or {}).get("%s/%s/raw.json" % (panel, launch))
|
||||
have = sha256_of(path)
|
||||
if want != have:
|
||||
raise ExtractError("%s has the sha256 %s, its meta.json says %s: the file is not the one the capture wrote" % (path, have, want))
|
||||
raw = json.loads(path.read_text(encoding="utf-8"))
|
||||
if raw.get("dpr_asked") != scale:
|
||||
raise ExtractError("%s asks scale %r, not %r" % (path, raw.get("dpr_asked"), scale))
|
||||
found = {"firefox_version": raw["firefox_version"], "build_id": raw["build_id"], "installer_sha256": raw["installer_sha256"]}
|
||||
if found != {k: meta_file.get(k) for k in found}:
|
||||
raise ExtractError("%s is not the browser its meta.json names: %r" % (path, found))
|
||||
if browser not in (None, found):
|
||||
raise ExtractError("%s is not the same browser as the others: %r and %r" % (path, found, browser))
|
||||
browser = found
|
||||
for phase, ordinal, readings in read_launch(raw, launch, str(path)):
|
||||
groups.setdefault((phase, position_of(ordinal)), []).append((launch, ordinal, readings))
|
||||
files.append({"path": "%s/%s/%s/raw.json" % (dpr_dir, panel, launch), "sha256": have})
|
||||
case: Dict[str, Dict[str, Dict[str, Any]]] = {}
|
||||
origin: Dict[str, Dict[str, List[str]]] = {}
|
||||
for phase in MOVE_TO_PHASES:
|
||||
for position in (POSITION_FIRST, POSITION_LATER):
|
||||
group = groups.get((phase, position))
|
||||
if not group:
|
||||
raise ExtractError("%s %s: no capture of %s as the %s popup of a browser: no retail value, none invented" % (dpr_dir, panel, phase, position))
|
||||
first_launch, first_ordinal, first_readings = group[0]
|
||||
for launch, ordinal, readings in group[1:]:
|
||||
if readings != first_readings:
|
||||
raise ExtractError("%s %s %s: the %s popup number %d of launch %s reads %r, popup number %d of launch %s read %r: popups of one position must agree" % (
|
||||
dpr_dir, panel, phase, position, ordinal, launch, readings, first_ordinal, first_launch, first_readings))
|
||||
case.setdefault(phase, {})[position] = first_readings
|
||||
origin.setdefault(phase, {})[position] = ["%s#%d" % (launch, ordinal) for launch, ordinal, _ in group]
|
||||
cases[case_id(panel, scale)] = case
|
||||
sources[case_id(panel, scale)] = origin
|
||||
named = (run_info.get("build") or {}).get("build_id")
|
||||
if named != (browser or {}).get("build_id"):
|
||||
raise ExtractError("%s names the build %r, the raw files %r" % (run_info_path, named, (browser or {}).get("build_id")))
|
||||
return {
|
||||
"about": "What retail Firefox reads in a popup of the maximized window, per display case, per phase of the wrapper test (resize_by_zero, move_by, move_to_far_right) and per position in the browser's life "
|
||||
"(first: the first popup the browser opens; later: any popup after it), from the popup-move-to capture; a test phase asserts against the position it has in the test. Extracted by "
|
||||
"scripts/extract_retail_popup_move_resize.py. Never edited by hand.",
|
||||
"capture": {
|
||||
"run_id": run_id,
|
||||
"retail_captures_commit": commit,
|
||||
"folder": capture.name,
|
||||
"format": MOVE_TO_FORMAT,
|
||||
"popup_features": FEATURES,
|
||||
"launches": MOVE_TO_LAUNCHES,
|
||||
"browser": browser,
|
||||
"binaries_sha256": binaries,
|
||||
},
|
||||
"files": files,
|
||||
"sources": sources,
|
||||
"cases": cases,
|
||||
}
|
||||
|
||||
|
||||
def cross_check(rounds: Dict[str, Any], cases: Dict[str, Any]) -> Dict[str, str]:
|
||||
"""What the window-geometry rounds read for a popup after ``resizeBy(0, 0)`` (``initial``, ``resized``) must be what the popup of the stored state reads in the popup-move-to capture (the rounds ran it as a
|
||||
later popup, after other popups): a value that is not the same is an anomaly, reported, not chosen. Returns, per case, the state that reproduces it."""
|
||||
reproduced_by: Dict[str, str] = {}
|
||||
for case, moments in rounds["cases"].items():
|
||||
got = cases[case]["resize_by_zero"]
|
||||
if not all(got[m] == moments[m] for m in ("initial", "resized")):
|
||||
raise ExtractError("%s: the rounds read %r after resizeBy(0, 0), the stored state of the popup-move-to capture reads %r" % (
|
||||
case, {m: moments[m] for m in ("initial", "resized")}, {m: got[m] for m in ("initial", "resized")}))
|
||||
reproduced_by[case] = STATE_STORED
|
||||
return reproduced_by
|
||||
|
||||
|
||||
# ---- the formula with the STORED spec must reproduce every popup captured while the store held the main window's entry ----
|
||||
|
||||
STATE_STORED = "stored"
|
||||
STATE_NEW_PROFILE = "new-profile"
|
||||
STATE_UNRECORDED_FIRST = "first-popup-store-not-recorded"
|
||||
SECOND_SESSION_FORMAT = "retail-popup-second-session/1"
|
||||
SECOND_SESSION_LAUNCH = "second-session"
|
||||
#: ``(inner, outer, window)`` of one moment of a popup, as ``retail_popup_formula.observed_sizes`` takes them.
|
||||
Moments = Dict[str, Dict[str, Dict[str, int]]]
|
||||
|
||||
|
||||
def _window_size(native: Dict[str, Any], where: str) -> Tuple[int, int]:
|
||||
try:
|
||||
rect = native["window_rect"]
|
||||
return rect[2] - rect[0], rect[3] - rect[1]
|
||||
except (KeyError, TypeError, IndexError) as exc:
|
||||
raise ExtractError("%s: the moment has no native window_rect (%s)" % (where, exc))
|
||||
|
||||
|
||||
def _observed(inner, outer, native: Dict[str, Any], where: str) -> Dict[str, Dict[str, int]]:
|
||||
return formula.observed_sizes(tuple(inner), tuple(outer), _window_size(native, where))
|
||||
|
||||
|
||||
def avail_css(steps: Dict[str, Any], where: str) -> Tuple[int, int]:
|
||||
"""The work area in CSS pixels the page of the maximized main window read."""
|
||||
try:
|
||||
content = steps["maximized"]["content"]
|
||||
except (KeyError, TypeError):
|
||||
raise ExtractError("%s has no step maximized with content" % where)
|
||||
for source in (content, (content.get("probe") or {}).get("screen") or {}):
|
||||
if "availWidth" in source and "availHeight" in source:
|
||||
return source["availWidth"], source["availHeight"]
|
||||
raise ExtractError("%s: the maximized main window has no availWidth and availHeight" % where)
|
||||
|
||||
|
||||
def frame_of_popup(raw: Dict[str, Any], scale: float, where: str) -> formula.Frame:
|
||||
"""The frame of the popup ``width=500,height=400`` in device pixels, read from the capture: the border (the maximized window starts at minus the border), the client origin below the top of the popup's
|
||||
window, and the chrome above its content (``mozInnerScreenY`` minus ``screenY``, in device pixels)."""
|
||||
try:
|
||||
steps = raw["steps"]
|
||||
border = -steps["maximized"]["native"]["window_rect"][0]
|
||||
popup = steps["popup"]
|
||||
if popup.get("features") != FEATURES:
|
||||
raise ExtractError("%s: the step popup was opened with %r, not %r" % (where, popup.get("features"), FEATURES))
|
||||
loaded = popup["content"]["early"]["load"]
|
||||
client_top = popup["native"]["client_origin"][1] - popup["native"]["window_rect"][1]
|
||||
ui = formula.round_half_up((loaded["mozInnerScreenY"] - loaded["screenY"]) * scale)
|
||||
except (KeyError, TypeError, IndexError) as exc:
|
||||
raise ExtractError("%s: the frame of the popup cannot be read (%s)" % (where, exc))
|
||||
return formula.Frame(border, client_top, ui)
|
||||
|
||||
|
||||
def frames_from_rounds(captures: Path, rounds: List[str]) -> Dict[float, formula.Frame]:
|
||||
"""The frame of every scale, from the window-geometry rounds (launches a and b, every round); two readings of one scale that differ are a failure."""
|
||||
frames: Dict[float, formula.Frame] = {}
|
||||
for dpr_dir, panel, scale in DISPLAYS:
|
||||
for round_name in rounds:
|
||||
for launch in ("a", "b"):
|
||||
path = captures / BROWSER_DIR / round_name / dpr_dir / panel / launch / "raw.json"
|
||||
if not path.is_file():
|
||||
raise ExtractError("missing %s" % path)
|
||||
raw = json.loads(path.read_text(encoding="utf-8"))
|
||||
if "popup" not in (raw.get("steps") or {}):
|
||||
continue
|
||||
frame = frame_of_popup(raw, scale, str(path))
|
||||
if frames.setdefault(scale, frame) != frame:
|
||||
raise ExtractError("%s: the frame of the popup is %r, another capture of the scale %s read %r" % (path, frame, scale, frames[scale]))
|
||||
if scale not in frames:
|
||||
raise ExtractError("no capture of the rounds has the step popup at the scale %s: no frame, none invented" % scale)
|
||||
return frames
|
||||
|
||||
|
||||
def _cell(case: str, source: str, run: str, scale: float, avail: Tuple[int, int], where: str, state: str, entry: Optional[bool], moments: Moments) -> Dict[str, Any]:
|
||||
return {"case": case, "source": source, "run": run, "scale": scale, "avail": avail, "cell": where, "state": state, "entry_recorded": entry, "moments": moments}
|
||||
|
||||
|
||||
def move_to_cells(capture: Path, run_id: str) -> Tuple[List[Dict[str, Any]], List[Dict[str, str]]]:
|
||||
"""Every popup of a ``popup-move-to`` capture folder: the first of a launch (ordinal 1) is a popup whose store state the run did not record, the ones after it were opened after the main window had been
|
||||
activated again by the first one closing. Every raw.json is checked against the sha256 of its meta.json."""
|
||||
cells: List[Dict[str, Any]] = []
|
||||
files: List[Dict[str, str]] = []
|
||||
for dpr_dir, panel, scale in DISPLAYS:
|
||||
meta_path = capture / dpr_dir / "meta.json"
|
||||
if not meta_path.is_file():
|
||||
raise ExtractError("missing %s" % meta_path)
|
||||
meta_file = json.loads(meta_path.read_text(encoding="utf-8"))
|
||||
for launch in MOVE_TO_LAUNCHES:
|
||||
path = capture / dpr_dir / panel / launch / "raw.json"
|
||||
if not path.is_file():
|
||||
raise ExtractError("missing %s" % path)
|
||||
have = sha256_of(path)
|
||||
want = (meta_file.get("raw_sha256") or {}).get("%s/%s/raw.json" % (panel, launch))
|
||||
if want != have:
|
||||
raise ExtractError("%s has the sha256 %s, its meta.json says %s: the file is not the one the capture wrote" % (path, have, want))
|
||||
raw = json.loads(path.read_text(encoding="utf-8"))
|
||||
if raw.get("dpr_asked") != scale:
|
||||
raise ExtractError("%s asks scale %r, not %r" % (path, raw.get("dpr_asked"), scale))
|
||||
avail = avail_css(raw.get("steps") or {}, str(path))
|
||||
for ordinal, phase in enumerate(MOVE_TO_LAUNCHES[launch], 1):
|
||||
where = "%s %s#%d %s" % (capture.name, launch, ordinal, phase)
|
||||
try:
|
||||
moments = raw["steps"]["phase_" + phase]["moments"]
|
||||
except (KeyError, TypeError):
|
||||
raise ExtractError("%s step phase_%s is missing" % (path, phase))
|
||||
seen: Moments = {}
|
||||
for name in ("initial", "resized"):
|
||||
if name in moments:
|
||||
m = moments[name]
|
||||
seen[name] = _observed((m["iw"], m["ih"]), (m["ow"], m["oh"]), m.get("native") or {}, "%s %s" % (where, name))
|
||||
cells.append(_cell(case_id(panel, scale), capture.name, run_id, scale, avail, where, STATE_UNRECORDED_FIRST if ordinal == 1 else STATE_STORED, None, seen))
|
||||
files.append({"path": "%s/%s/%s/%s/%s/raw.json" % (capture.parent.name, capture.name, dpr_dir, panel, launch), "sha256": have})
|
||||
return cells, files
|
||||
|
||||
|
||||
def second_session_cells(capture: Path, run_id: str) -> Tuple[List[Dict[str, Any]], List[Dict[str, str]]]:
|
||||
"""Every popup of the second session of a profile (``popup-move-to-second-session``): each carries the main-window entry of the XUL store recorded just before it (``store_before``): a popup opened with the entry
|
||||
present is of the stored state, one opened with no entry is of the new-profile state."""
|
||||
cells: List[Dict[str, Any]] = []
|
||||
files: List[Dict[str, str]] = []
|
||||
for dpr_dir, panel, scale in DISPLAYS:
|
||||
meta_path = capture / dpr_dir / "meta.json"
|
||||
if not meta_path.is_file():
|
||||
raise ExtractError("missing %s" % meta_path)
|
||||
meta_file = json.loads(meta_path.read_text(encoding="utf-8"))
|
||||
path = capture / dpr_dir / panel / SECOND_SESSION_LAUNCH / "raw.json"
|
||||
if not path.is_file():
|
||||
raise ExtractError("missing %s" % path)
|
||||
have = sha256_of(path)
|
||||
want = (meta_file.get("raw_sha256") or {}).get("%s/%s/raw.json" % (panel, SECOND_SESSION_LAUNCH))
|
||||
if want != have:
|
||||
raise ExtractError("%s has the sha256 %s, its meta.json says %s: the file is not the one the capture wrote" % (path, have, want))
|
||||
raw = json.loads(path.read_text(encoding="utf-8"))
|
||||
if raw.get("format") != SECOND_SESSION_FORMAT:
|
||||
raise ExtractError("%s has the format %r, not %r" % (path, raw.get("format"), SECOND_SESSION_FORMAT))
|
||||
if raw.get("error") is not None or raw.get("dpr_asked") != scale or raw.get("phases_planned") != MOVE_TO_LAUNCHES["a"]:
|
||||
raise ExtractError("%s: error %r, scale %r, phases %r" % (path, raw.get("error"), raw.get("dpr_asked"), raw.get("phases_planned")))
|
||||
steps = (raw.get("session2") or {}).get("steps") or {}
|
||||
avail = avail_css(steps, str(path))
|
||||
for ordinal, phase in enumerate(MOVE_TO_LAUNCHES["a"], 1):
|
||||
where = "second-session/%s %s#%d %s" % (capture.name, SECOND_SESSION_LAUNCH, ordinal, phase)
|
||||
try:
|
||||
step = steps["phase_" + phase]
|
||||
before = step["store_before"]
|
||||
entry = before["memory"].get("width") is not None or before["disk"].get("entry") is not None
|
||||
moments = step["moments"]
|
||||
except (KeyError, TypeError, AttributeError):
|
||||
raise ExtractError("%s of %s has no store_before or no moments: the state of the store is not recorded" % (where, path))
|
||||
if step.get("ordinal") != ordinal:
|
||||
raise ExtractError("%s is popup number %r of the browser, the plan says %r" % (where, step.get("ordinal"), ordinal))
|
||||
seen: Moments = {}
|
||||
for name in ("initial", "resized"):
|
||||
if name in moments:
|
||||
m = moments[name]
|
||||
seen[name] = _observed((m["iw"], m["ih"]), (m["ow"], m["oh"]), m.get("native") or {}, "%s %s" % (where, name))
|
||||
cells.append(_cell(case_id(panel, scale), "second-session/" + capture.name, run_id, scale, avail, where, STATE_STORED if entry else STATE_NEW_PROFILE, entry, seen))
|
||||
files.append({"path": "%s/%s/%s/%s/%s/raw.json" % (capture.parent.name, capture.name, dpr_dir, panel, SECOND_SESSION_LAUNCH), "sha256": have})
|
||||
return cells, files
|
||||
|
||||
|
||||
def rounds_cells(captures: Path, rounds: List[str]) -> List[Dict[str, Any]]:
|
||||
"""The popup of ``popup_move_resize`` in the window-geometry rounds: a later popup after many steps of one browser (the store holds the main window)."""
|
||||
cells: List[Dict[str, Any]] = []
|
||||
for dpr_dir, panel, scale in DISPLAYS:
|
||||
for round_name in rounds:
|
||||
for launch in ("a", "b"):
|
||||
path = captures / BROWSER_DIR / round_name / dpr_dir / panel / launch / "raw.json"
|
||||
if not path.is_file():
|
||||
raise ExtractError("missing %s" % path)
|
||||
raw = json.loads(path.read_text(encoding="utf-8"))
|
||||
avail = avail_css(raw.get("steps") or {}, str(path))
|
||||
try:
|
||||
moments = raw["steps"]["popup_move_resize"]["moments"]
|
||||
except (KeyError, TypeError):
|
||||
raise ExtractError("%s has no step popup_move_resize with moments" % path)
|
||||
where = "%s %s %s" % (round_name, dpr_dir, launch)
|
||||
seen: Moments = {}
|
||||
for name in ("initial", "resized"):
|
||||
if name not in moments:
|
||||
raise ExtractError("%s lacks the moment %r: no retail value, none invented" % (where, name))
|
||||
m = moments[name]
|
||||
seen[name] = _observed((m["innerWidth"], m["innerHeight"]), (m["outerWidth"], m["outerHeight"]), m.get("native") or {}, "%s %s" % (where, name))
|
||||
cells.append(_cell(case_id(panel, scale), round_name, "", scale, avail, where, STATE_STORED, None, seen))
|
||||
return cells
|
||||
|
||||
|
||||
def check_cells(cells: List[Dict[str, Any]], frames: Dict[float, formula.Frame]) -> Tuple[Dict[str, Any], List[Dict[str, Any]]]:
|
||||
"""Applies the formula to every cell, and returns ``(summary, notes)``. A cell of the STORED state that the stored-spec formula does not reproduce, a cell of the NEW-PROFILE state (the store was seen with no
|
||||
entry) that the fresh-spec formula does not reproduce, or a first popup whose store was not recorded that neither reproduces, fails the extraction. ``notes`` has the cells of the two states that are
|
||||
not expectations (every first popup), each with whether the fresh and the stored spec reproduce it."""
|
||||
mismatches: List[str] = []
|
||||
notes: List[Dict[str, Any]] = []
|
||||
counts: Dict[str, Dict[str, int]] = {}
|
||||
for cell in cells:
|
||||
scale, avail = cell["scale"], tuple(cell["avail"])
|
||||
sizes = {spec: formula.popup_sizes(scale, avail, frames[scale], spec) for spec in formula.SPECS}
|
||||
reproduces = {spec: all(cell["moments"][m] == formula.expected_for_moment(sizes[spec], m) for m in cell["moments"]) for spec in formula.SPECS}
|
||||
state = cell["state"]
|
||||
ok = {STATE_STORED: reproduces[formula.STORED], STATE_NEW_PROFILE: reproduces[formula.FRESH], STATE_UNRECORDED_FIRST: reproduces[formula.FRESH] or reproduces[formula.STORED]}[state]
|
||||
counts.setdefault(cell["source"], {}).setdefault(state, 0)
|
||||
counts[cell["source"]][state] += 1
|
||||
if not ok:
|
||||
spec = formula.FRESH if state == STATE_NEW_PROFILE else formula.STORED
|
||||
mismatches.append("%s (%s, %s): read %r, the %s-spec formula gives %r" % (
|
||||
cell["cell"], cell["case"], state, cell["moments"], spec, {m: formula.expected_for_moment(sizes[spec], m) for m in cell["moments"]}))
|
||||
if state != STATE_STORED:
|
||||
notes.append({"source": cell["source"], "run": cell["run"], "case": cell["case"], "cell": cell["cell"], "entry_recorded": cell["entry_recorded"],
|
||||
"fresh_spec_reproduces": reproduces[formula.FRESH], "stored_spec_reproduces": reproduces[formula.STORED]})
|
||||
if mismatches:
|
||||
raise ExtractError("the formula does not reproduce %d captured popups, nothing is written:\n %s" % (len(mismatches), "\n ".join(mismatches[:12])))
|
||||
summary = {"cells_checked": len(cells), "cells_by_source_and_state": counts}
|
||||
return summary, notes
|
||||
|
||||
|
||||
def stored_expectations(cases: Dict[str, Any], cells: List[Dict[str, Any]], frames: Dict[float, formula.Frame]) -> Dict[str, Any]:
|
||||
"""The numbers the formula gives with the stored spec, per case; the readings the test expects (``cases``, read from the later popups) must be those numbers, inner and outer, at every moment they have."""
|
||||
expected: Dict[str, Any] = {}
|
||||
for dpr_dir, panel, scale in DISPLAYS:
|
||||
case = case_id(panel, scale)
|
||||
avails = {tuple(c["avail"]) for c in cells if c["case"] == case}
|
||||
if len(avails) != 1:
|
||||
raise ExtractError("%s: the captures read the work area %r, not one" % (case, sorted(avails)))
|
||||
avail = avails.pop()
|
||||
sizes = formula.popup_sizes(scale, avail, frames[scale], formula.STORED)
|
||||
for phase, moments in cases[case].items():
|
||||
for name, reading in moments.items():
|
||||
if name not in ("initial", "resized"):
|
||||
continue
|
||||
want = formula.expected_for_moment(sizes, name)
|
||||
got = {axis: {"inner": reading["inner"][i], "outer": reading["outer"][i]} for i, axis in enumerate(formula.AXES)}
|
||||
if any(got[axis]["inner"] != want[axis]["inner"] or got[axis]["outer"] != want[axis]["outer"] for axis in formula.AXES):
|
||||
raise ExtractError("%s %s %s: the capture's later popup reads %r, the stored-spec formula gives %r" % (case, phase, name, got, want))
|
||||
expected[case] = {"scale": scale, "avail_css": list(avail), "frame": frames[scale]._asdict(), "sizes": sizes}
|
||||
return expected
|
||||
|
||||
|
||||
def stored_state_of(data: Dict[str, Any]) -> Dict[str, Any]:
|
||||
"""``build_move_to``'s readings by position, reduced to what the test expects: the popup of the stored state (the ``later`` readings). The ``first`` readings are the new-profile state, not expectations."""
|
||||
return {case: {phase: positions[POSITION_LATER] for phase, positions in phases.items()} for case, phases in data["cases"].items()}
|
||||
|
||||
|
||||
def dumps(data: Dict[str, Any]) -> str:
|
||||
return json.dumps(data, indent=2) + "\n"
|
||||
|
||||
|
||||
def build_all(args: argparse.Namespace) -> Dict[str, Any]:
|
||||
rounds = build(args.captures, args.rounds, args.commit)
|
||||
data = build_move_to(args.move_to_capture, args.move_to_run_id, args.move_to_commit)
|
||||
frames = frames_from_rounds(args.captures, args.rounds)
|
||||
cells, check_files = move_to_cells(args.move_to_capture, args.move_to_run_id)
|
||||
runs = [{"folder": args.move_to_capture.name, "run_id": args.move_to_run_id}]
|
||||
for folder, run_id in args.move_to_also or []:
|
||||
more, more_files = move_to_cells(Path(folder), run_id)
|
||||
cells += more
|
||||
check_files += more_files
|
||||
runs.append({"folder": Path(folder).name, "run_id": run_id})
|
||||
session_cells, session_files = second_session_cells(args.second_session_capture, args.second_session_run_id)
|
||||
cells += session_cells
|
||||
check_files += session_files
|
||||
runs.append({"folder": "popup-move-to-second-session/%s" % args.second_session_capture.name, "run_id": args.second_session_run_id})
|
||||
cells += rounds_cells(args.captures, args.rounds)
|
||||
summary, notes = check_cells(cells, frames)
|
||||
cases = stored_state_of(data)
|
||||
expected = stored_expectations(cases, cells, frames)
|
||||
first_readings = {case: {phase: positions[POSITION_FIRST] for phase, positions in phases.items()} for case, phases in data["cases"].items()}
|
||||
data["cases"] = cases
|
||||
data["sources"] = {case: {phase: positions[POSITION_LATER] for phase, positions in phases.items()} for case, phases in data["sources"].items()}
|
||||
data["about"] = ("What retail Firefox reads in a popup of the maximized window, per display case and per phase of the wrapper test (resize_by_zero, move_by, move_to_far_right), in the state of a profile whose XUL store "
|
||||
"holds the main window's entry (a real user's profile: any maximize, resize or activation after the chrome loads writes it), from the popup-move-to capture; every popup captured in that state "
|
||||
"is reproduced by the formula of scripts/retail_popup_formula.py with the stored spec, or the extraction refuses to write. Extracted by scripts/extract_retail_popup_move_resize.py. Never edited by hand.")
|
||||
data["stored_spec_formula"] = {
|
||||
"about": "The formula (scripts/retail_popup_formula.py) with the STORED spec reproduces every popup captured while the store held the main window's entry: the later popups of the popup-move-to runs, "
|
||||
"the popups of the second session whose store_before had the entry, and the popup_move_resize of the window-geometry rounds. The frame is read from the capture (the border of the maximized "
|
||||
"window, the client origin and the chrome of the popup of the rounds).",
|
||||
"checked": summary,
|
||||
"runs": runs,
|
||||
"cases": expected,
|
||||
}
|
||||
data["new_profile_state"] = {
|
||||
"about": "New-profile state: the first popup a browser opens, captured with a fresh profile whose store had no main-window entry (the second session at 1.25, 1.5 and 2, recorded: entry_recorded false) or whose "
|
||||
"store was not recorded (the popup-move-to runs, entry_recorded null). Not an expectation of any test. The formula with the FRESH spec reproduces them; the cells where the fresh spec does not "
|
||||
"(fresh_spec_reproduces false) read the stored-spec numbers.",
|
||||
"runs": runs,
|
||||
"first_popup_readings_of_the_extracted_run": first_readings,
|
||||
"cells": notes,
|
||||
}
|
||||
own = "%s/%s/" % (args.move_to_capture.parent.name, args.move_to_capture.name)
|
||||
data["files"] = data["files"] + [f for f in check_files if not f["path"].startswith(own)]
|
||||
data["rounds_cross_check"] = {
|
||||
"about": "The window-geometry rounds (a popup after resizeBy(0, 0) as a later popup of a long browser life) read what the stored state reads in the popup-move-to capture; they are not read by the test.",
|
||||
"capture": rounds["capture"],
|
||||
"files": rounds["files"],
|
||||
"reproduced_by": cross_check(rounds, cases),
|
||||
}
|
||||
return data
|
||||
|
||||
|
||||
def main(argv: Optional[List[str]] = None) -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__.split("\n\n")[0])
|
||||
parser.add_argument("--captures", required=True, type=Path, help="the captures folder of RetailCaptures")
|
||||
parser.add_argument("--rounds", required=True, nargs="+")
|
||||
parser.add_argument("--commit", required=True, help="the RetailCaptures commit the rounds are in")
|
||||
parser.add_argument("--move-to-capture", required=True, type=Path, help="the date folder of the popup-move-to capture the expectations are read from (with run-info.json and the dpr folders)")
|
||||
parser.add_argument("--move-to-run-id", required=True, help="the id of the run that made the popup-move-to capture")
|
||||
parser.add_argument("--move-to-commit", required=True, help="the RetailCaptures commit the popup-move-to capture is in")
|
||||
parser.add_argument("--move-to-also", action="append", nargs=2, metavar=("FOLDER", "RUN_ID"), help="another popup-move-to date folder and its run id: every popup in it is checked against the formula (repeatable)")
|
||||
parser.add_argument("--second-session-capture", required=True, type=Path, help="the date folder of the popup-move-to-second-session capture")
|
||||
parser.add_argument("--second-session-run-id", required=True, help="the id of the run that made the second-session capture")
|
||||
parser.add_argument("--write", action="store_true", help="write ci/retail-popup-move-resize.json; without it the committed file is compared with the captures")
|
||||
args = parser.parse_args(argv)
|
||||
try:
|
||||
text = dumps(build_all(args))
|
||||
except ExtractError as exc:
|
||||
print("EXTRACTION FAILED: %s" % exc, file=sys.stderr)
|
||||
return 2
|
||||
if args.write:
|
||||
DATA_PATH.write_text(text, encoding="utf-8", newline="\n")
|
||||
print("wrote %s" % DATA_PATH)
|
||||
return 0
|
||||
if DATA_PATH.read_text(encoding="utf-8") != text:
|
||||
print("%s is not what the captures give" % DATA_PATH, file=sys.stderr)
|
||||
return 1
|
||||
print("%s is what the captures give" % DATA_PATH)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,175 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Extracts, from a retail capture of the window geometry, the sizes retail Firefox gives a popup opened from a maximized main window, into ci/retail-popup-sizes.json.
|
||||
|
||||
The e2e test ``tests/test_a_popup_reads_the_retail_sizes_of_a_maximized_main_window_e2e.py`` compares what a popup reads with what RETAIL Firefox 159 on Windows read. Those numbers were a table typed
|
||||
by hand, and one was wrong (outer width 514 at scale 1.5, the value of 1.25; retail read 515). They are therefore read from the capture, never typed:
|
||||
|
||||
* ``<round>/<dpr>/<panel>/<launch>/raw.json``, step ``popup_sizes``, variant by variant (one variant per feature string; the variant says which string it is in ``features``): the popup at
|
||||
one second after its load (``at_1s``: inner, outer, ``screenX``/``screenY``) and the visual viewport at ``load`` (``early.load``). Launch ``a`` is the one extracted; launch ``b`` (a second
|
||||
launch of the same display case) must give the same values, or the extraction fails: a value the two launches disagree on is not a value.
|
||||
* ``captures/WINDOW_GEOMETRY_POPUP_FRAME.csv`` (when given): its rows of step ``popup`` (``width=500,height=400``, launch ``a``, every round) must give the inner, outer and screen position that
|
||||
``popup_sizes`` gives for the same string, or the extraction fails.
|
||||
|
||||
The file records the round, the browser (version, build id, installer sha256), the sha256 of every raw.json and of the CSV that were read. The wrapper's CI has no capture, so the tests read the
|
||||
committed file and this module's functions are tested on a small sample (tests/test_the_retail_popup_sizes_are_extracted_from_the_capture_not_typed.py). One command regenerates the file:
|
||||
|
||||
python scripts/extract_retail_popup_sizes.py --captures <RetailCaptures>/captures --round 2026-12-01-window-geometry-r12 --run-url <url of the run> --commit <RetailCaptures commit> --write
|
||||
|
||||
and the same without ``--write`` compares the committed file with what the capture gives (the check).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import csv
|
||||
import hashlib
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Optional, Tuple
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
DATA_PATH = ROOT / "ci" / "retail-popup-sizes.json"
|
||||
|
||||
BROWSER_DIR = "firefox-159.0/github-runner"
|
||||
CSV_NAME = "WINDOW_GEOMETRY_POPUP_FRAME.csv"
|
||||
#: The four display cases, in the order of their scale: (folder of the dpr, panel, scale).
|
||||
DISPLAYS = (("dpr1", "1920x1080", 1.0), ("dpr1.25", "1920x1080", 1.25), ("dpr1.5", "1920x1080", 1.5), ("dpr2", "1600x1200", 2.0))
|
||||
#: The feature strings the e2e test opens popups with (the tab, ``''``, is not a popup).
|
||||
FEATURES = ("width=500,height=400", "popup", "width=500", "height=400", "width=300,height=200", "width=800,height=600", "left=100,top=100", "left=5000,top=5000")
|
||||
|
||||
|
||||
class ExtractError(Exception):
|
||||
"""What the capture does not give, or gives two ways: nothing is invented in its place."""
|
||||
|
||||
|
||||
def case_id(panel: str, scale: float) -> str:
|
||||
return "%s-dpr%s" % (panel, scale)
|
||||
|
||||
|
||||
def sha256_of(path: Path) -> str:
|
||||
return hashlib.sha256(path.read_bytes()).hexdigest()
|
||||
|
||||
|
||||
def variants_of(raw: Dict[str, Any], where: str) -> Dict[str, Dict[str, Any]]:
|
||||
"""``{features: variant}`` of the step ``popup_sizes`` of one raw.json."""
|
||||
try:
|
||||
found = raw["steps"]["popup_sizes"]["variants"]
|
||||
except (KeyError, TypeError):
|
||||
raise ExtractError("%s has no step popup_sizes with variants" % where)
|
||||
return {v["features"]: v for v in found.values() if isinstance(v, dict) and "features" in v}
|
||||
|
||||
|
||||
def reading(variant: Dict[str, Any], where: str) -> Dict[str, Any]:
|
||||
"""What retail read for one variant: inner, outer, screen (one second after the load) and the visual viewport height (at ``load``)."""
|
||||
try:
|
||||
at, load = variant["at_1s"], variant["early"]["load"]
|
||||
return {
|
||||
"inner": [at["innerWidth"], at["innerHeight"]],
|
||||
"outer": [at["outerWidth"], at["outerHeight"]],
|
||||
"screen": [at["screenX"], at["screenY"]],
|
||||
"vv_height": load["visualViewportHeight"],
|
||||
}
|
||||
except (KeyError, TypeError) as exc:
|
||||
raise ExtractError("%s: the variant lacks %s" % (where, exc))
|
||||
|
||||
|
||||
def extract_display(capture: Path, dpr_dir: str, panel: str, scale: float) -> Tuple[Dict[str, Dict[str, Any]], List[Dict[str, str]], Dict[str, Any]]:
|
||||
"""The readings of one display case, from launch ``a``, checked against launch ``b``; the files read; the browser they come from."""
|
||||
files, per_launch, meta = [], {}, {}
|
||||
for launch in ("a", "b"):
|
||||
path = capture / dpr_dir / panel / launch / "raw.json"
|
||||
if not path.is_file():
|
||||
raise ExtractError("missing %s" % path)
|
||||
raw = json.loads(path.read_text(encoding="utf-8"))
|
||||
if raw.get("dpr_asked") != scale:
|
||||
raise ExtractError("%s asks scale %r, not %r" % (path, raw.get("dpr_asked"), scale))
|
||||
found = variants_of(raw, str(path))
|
||||
per_launch[launch] = {}
|
||||
for features in FEATURES:
|
||||
if features not in found:
|
||||
raise ExtractError("%s has no popup_sizes variant for %r: no retail value, none invented" % (path, features))
|
||||
per_launch[launch][features] = reading(found[features], "%s %r" % (path, features))
|
||||
files.append({"path": "%s/%s/%s/raw.json" % (dpr_dir, panel, launch), "sha256": sha256_of(path)})
|
||||
meta[launch] = {"firefox_version": raw["firefox_version"], "build_id": raw["build_id"], "installer_sha256": raw["installer_sha256"]}
|
||||
for features in FEATURES:
|
||||
if per_launch["a"][features] != per_launch["b"][features]:
|
||||
raise ExtractError("%s %s %r: launch a reads %r and launch b reads %r" % (dpr_dir, panel, features, per_launch["a"][features], per_launch["b"][features]))
|
||||
if meta["a"] != meta["b"]:
|
||||
raise ExtractError("%s %s: the two launches are not the same browser: %r" % (dpr_dir, panel, meta))
|
||||
return per_launch["a"], files, meta["a"]
|
||||
|
||||
|
||||
def check_csv(csv_path: Path, cases: Dict[str, Dict[str, Dict[str, Any]]]) -> None:
|
||||
"""Every ``popup`` row of launch ``a`` of the CSV (``width=500,height=400``, every round) agrees with the extracted reading of the same display case."""
|
||||
seen = 0
|
||||
with csv_path.open(encoding="utf-8", newline="") as handle:
|
||||
for number, row in enumerate(csv.DictReader(handle), start=2):
|
||||
if row["step"] != "popup" or row["launch"] != "a":
|
||||
continue
|
||||
panel = row["path"].split("/")[-3]
|
||||
case = case_id(panel, float(row["dpr_asked"]))
|
||||
got = cases.get(case, {}).get(row["features"])
|
||||
if got is None:
|
||||
raise ExtractError("%s row %d: no extracted reading for %s, %r" % (csv_path.name, number, case, row["features"]))
|
||||
seen += 1
|
||||
have = {"inner": [int(row["innerWidth"]), int(row["innerHeight"])], "outer": [int(row["outerWidth"]), int(row["outerHeight"])], "screen": [int(row["screenX"]), int(row["screenY"])]}
|
||||
for key, value in have.items():
|
||||
if got[key] != value:
|
||||
raise ExtractError("%s row %d (%s, %r): %s is %r in the CSV and %r in popup_sizes" % (csv_path.name, number, case, row["features"], key, value, got[key]))
|
||||
if not seen:
|
||||
raise ExtractError("%s has no popup row of launch a" % csv_path.name)
|
||||
|
||||
|
||||
def build(captures: Path, round_name: str, run_url: str, commit: str) -> Dict[str, Any]:
|
||||
capture = captures / BROWSER_DIR / round_name
|
||||
cases: Dict[str, Dict[str, Dict[str, Any]]] = {}
|
||||
files: List[Dict[str, str]] = []
|
||||
browser: Optional[Dict[str, Any]] = None
|
||||
for dpr_dir, panel, scale in DISPLAYS:
|
||||
readings, read, meta = extract_display(capture, dpr_dir, panel, scale)
|
||||
if browser not in (None, meta):
|
||||
raise ExtractError("the display cases come from two browsers: %r and %r" % (browser, meta))
|
||||
browser = meta
|
||||
cases[case_id(panel, scale)] = readings
|
||||
files.extend(read)
|
||||
csv_path = captures / CSV_NAME
|
||||
check_csv(csv_path, cases)
|
||||
return {
|
||||
"about": "What retail Firefox reads in a popup opened from a maximized main window, per display case and feature string, extracted by scripts/extract_retail_popup_sizes.py. Never edited by hand.",
|
||||
"capture": {"round": round_name, "run": run_url, "retail_captures_commit": commit, "browser": browser},
|
||||
"files": files,
|
||||
"csv_checked": {"path": CSV_NAME, "sha256": sha256_of(csv_path)},
|
||||
"cases": cases,
|
||||
}
|
||||
|
||||
|
||||
def dumps(data: Dict[str, Any]) -> str:
|
||||
return json.dumps(data, indent=2, sort_keys=False) + "\n"
|
||||
|
||||
|
||||
def main(argv: Optional[List[str]] = None) -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__.split("\n\n")[0])
|
||||
parser.add_argument("--captures", required=True, type=Path, help="the captures folder of RetailCaptures")
|
||||
parser.add_argument("--round", required=True)
|
||||
parser.add_argument("--run-url", required=True)
|
||||
parser.add_argument("--commit", required=True, help="the RetailCaptures commit the round is in")
|
||||
parser.add_argument("--write", action="store_true", help="write ci/retail-popup-sizes.json; without it the committed file is compared with the capture")
|
||||
args = parser.parse_args(argv)
|
||||
try:
|
||||
text = dumps(build(args.captures, args.round, args.run_url, args.commit))
|
||||
except ExtractError as exc:
|
||||
print("EXTRACTION FAILED: %s" % exc, file=sys.stderr)
|
||||
return 2
|
||||
if args.write:
|
||||
DATA_PATH.write_text(text, encoding="utf-8", newline="\n")
|
||||
print("wrote %s" % DATA_PATH)
|
||||
return 0
|
||||
if DATA_PATH.read_text(encoding="utf-8") != text:
|
||||
print("%s is not what the capture gives" % DATA_PATH, file=sys.stderr)
|
||||
return 1
|
||||
print("%s is what the capture gives" % DATA_PATH)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,155 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Writes ``surface.systemColors`` of the host-gate retail reference from the retail captures of the system colors, never typed.
|
||||
|
||||
The host gate (``scripts/ci_host_gate.py``) holds each leg's reading of every CSS system color keyword to the reading of RETAIL Firefox 159 on Windows. The reference it reads is
|
||||
``scripts/host_gate/reference/firefox-159/dpr<x>.json.gz``; its item ``surface.systemColors`` (the computed ``color`` of an element given each keyword, light scheme: the way
|
||||
``host_gate_page.html`` reads it) is written by this script from the retail captures of RetailCaptures, in the folder ``captures/firefox-159.0/<image>/syscolors/<date>``: ``result.json`` (the page's
|
||||
whole reading, ``element.light.<keyword>.color``) and ``meta.json`` (the sha256 of every file of the capture, the browser).
|
||||
|
||||
Two captures at least are read, on different Windows builds (build 26100 and client build 26200), and they must agree on every keyword: a keyword the captures read two ways is refused, not chosen.
|
||||
What is refused rather than filled in: a ``result.json`` whose sha256 is not the one ``meta.json`` lists; a capture that is not Windows (``navigator.platform`` Win32); a capture of another Firefox than the
|
||||
reference's; a keyword of the reference that a capture does not read (a keyword Firefox refuses reads the element's own color, as on the page, and the captures must agree on that too). The CSS colors do not depend on the DPR, so the same values go into every ``dpr<x>.json.gz``; only
|
||||
``surface.systemColors`` of each is written, and the key order of the reference is kept. The sources (folder, sha256 of ``result.json``, the browser's build and ``xul.dll`` sha256, the RetailCaptures commit) are recorded in
|
||||
``scripts/host_gate/reference/firefox-159/syscolors-source.json``. One command regenerates both:
|
||||
|
||||
python scripts/extract_retail_syscolors.py --capture <RetailCaptures>/captures/firefox-159.0/windows-server-2025/syscolors/2026-12-01 \\
|
||||
--capture <RetailCaptures>/captures/firefox-159.0/windows-11-arm/syscolors/2026-12-02 --commit <RetailCaptures commit> --write
|
||||
|
||||
and the same without ``--write`` compares the committed files with what the captures give (the check).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import gzip
|
||||
import hashlib
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
REFERENCE = ROOT / "scripts" / "host_gate" / "reference" / "firefox-159"
|
||||
SOURCE_PATH = REFERENCE / "syscolors-source.json"
|
||||
ITEM = "surface.systemColors"
|
||||
FORMAT = "retail-syscolors/1"
|
||||
FIREFOX = "159.0"
|
||||
SCHEME = "light"
|
||||
|
||||
|
||||
class ExtractError(Exception):
|
||||
"""What the captures do not give, or give two ways: nothing is invented in its place."""
|
||||
|
||||
|
||||
def sha256_of(path: Path) -> str:
|
||||
return hashlib.sha256(path.read_bytes()).hexdigest()
|
||||
|
||||
|
||||
def read_capture(folder: Path, keywords: List[str]) -> Dict[str, Any]:
|
||||
"""One capture: its colors for ``keywords`` and its sources, after the checks of the capture against itself."""
|
||||
result_path, meta_path = folder / "result.json", folder / "meta.json"
|
||||
for path in (result_path, meta_path):
|
||||
if not path.is_file():
|
||||
raise ExtractError("missing %s" % path)
|
||||
meta = json.loads(meta_path.read_text(encoding="utf-8"))
|
||||
listed = meta.get("files", {}).get("result.json", {}).get("sha256")
|
||||
if listed != sha256_of(result_path):
|
||||
raise ExtractError("%s is %s and meta.json lists %r: not the file the capture recorded" % (result_path, sha256_of(result_path), listed))
|
||||
if meta.get("format") != FORMAT or meta.get("firefox_version") != FIREFOX:
|
||||
raise ExtractError("%s: format %r, Firefox %r, not %r and %r: not the capture of the reference" % (meta_path, meta.get("format"), meta.get("firefox_version"), FORMAT, FIREFOX))
|
||||
result = json.loads(result_path.read_text(encoding="utf-8"))
|
||||
try:
|
||||
platform = result["env"]["platform"]
|
||||
scheme = result["element"][SCHEME]
|
||||
except (KeyError, TypeError) as exc:
|
||||
raise ExtractError("%s lacks %s: no retail value, none invented" % (result_path, exc))
|
||||
if platform != "Win32":
|
||||
raise ExtractError("%s: navigator.platform is %r, not Win32: not a Windows capture" % (result_path, platform))
|
||||
colors = {}
|
||||
for keyword in keywords:
|
||||
read = scheme.get(keyword)
|
||||
if not isinstance(read, dict) or not isinstance(read.get("color"), str) or not isinstance(read.get("accepted"), bool):
|
||||
raise ExtractError("%s: the keyword %r is %r in the capture: no retail value, none invented" % (result_path, keyword, read))
|
||||
# a keyword Firefox refuses (accepted false) leaves the element's own color: that is what the page reads, and what the reference holds
|
||||
colors[keyword] = (read["color"], read["accepted"])
|
||||
binaries = meta.get("binaries", {})
|
||||
return {"colors": colors, "source": {"folder": "captures/firefox-159.0/%s/syscolors/%s" % (folder.parent.parent.name, folder.name), "result_sha256": listed,
|
||||
"build_id": meta.get("build_id"), "xul_dll_sha256": binaries.get("xul_dll_sha256"),
|
||||
"firefox_exe_sha256": binaries.get("firefox_exe_sha256")}}
|
||||
|
||||
|
||||
def build(captures: List[Path], reference_keywords: List[str], commit: str) -> Dict[str, Any]:
|
||||
"""The values of ``surface.systemColors`` and their sources, from two captures that agree."""
|
||||
if len(captures) < 2:
|
||||
raise ExtractError("%d capture: the reference is read from two captures on two Windows builds that agree, not from one" % len(captures))
|
||||
read = [read_capture(folder, reference_keywords) for folder in captures]
|
||||
values = {}
|
||||
for keyword in reference_keywords:
|
||||
seen = [(r["source"]["folder"], r["colors"][keyword]) for r in read]
|
||||
if len({reading for _, reading in seen}) != 1:
|
||||
raise ExtractError("the captures read %s two ways: %s: none is chosen" % (keyword, "; ".join("%s %s" % (folder, reading) for folder, reading in seen)))
|
||||
values[keyword] = seen[0][1][0]
|
||||
return {"about": "Where surface.systemColors of dpr1.0.json.gz and dpr1.5.json.gz comes from: retail Firefox 159 on Windows, written by scripts/extract_retail_syscolors.py from these captures. Never edited by hand.",
|
||||
"retail_captures_commit": commit, "captures": [r["source"] for r in read], "values": values}
|
||||
|
||||
|
||||
def _load(path: Path) -> Dict[str, Any]:
|
||||
return json.loads(gzip.decompress(path.read_bytes()))
|
||||
|
||||
|
||||
def _dump(data: Dict[str, Any]) -> bytes:
|
||||
# the format of the existing reference: compact, UTF-8 as is; mtime 0 so the same content is the same bytes
|
||||
return gzip.compress(json.dumps(data, separators=(",", ":"), ensure_ascii=False).encode("utf-8"), mtime=0)
|
||||
|
||||
|
||||
def reference_files(reference: Path = REFERENCE) -> List[Path]:
|
||||
return sorted(reference.glob("dpr*.json.gz"))
|
||||
|
||||
|
||||
def apply(reference: Path, source: Dict[str, Any]) -> Dict[Path, Dict[str, Any]]:
|
||||
"""Each reference file as it is with ``surface.systemColors`` set from ``source['values']``, key order kept."""
|
||||
out = {}
|
||||
for path in reference_files(reference):
|
||||
data = _load(path)
|
||||
old = data["items"].get(ITEM)
|
||||
if old is None or list(old) != list(source["values"]):
|
||||
raise ExtractError("%s has no %s with the keywords of the captures" % (path, ITEM))
|
||||
data["items"][ITEM] = dict(source["values"])
|
||||
out[path] = data
|
||||
return out
|
||||
|
||||
|
||||
def dumps(source: Dict[str, Any]) -> str:
|
||||
return json.dumps(source, indent=2) + "\n"
|
||||
|
||||
|
||||
def main(argv: Optional[List[str]] = None) -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__.split("\n\n")[0])
|
||||
parser.add_argument("--capture", required=True, action="append", type=Path, help="a folder of a syscolors capture in RetailCaptures (result.json and meta.json); two at least")
|
||||
parser.add_argument("--commit", required=True, help="the RetailCaptures commit the captures are in")
|
||||
parser.add_argument("--write", action="store_true", help="write the reference and its source file; without it they are compared with the captures")
|
||||
args = parser.parse_args(argv)
|
||||
try:
|
||||
first = _load(reference_files()[0])["items"][ITEM]
|
||||
source = build([c.resolve() for c in args.capture], list(first), args.commit)
|
||||
files = apply(REFERENCE, source)
|
||||
except ExtractError as exc:
|
||||
print("EXTRACTION FAILED: %s" % exc, file=sys.stderr)
|
||||
return 2
|
||||
if args.write:
|
||||
for path, data in files.items():
|
||||
path.write_bytes(_dump(data))
|
||||
SOURCE_PATH.write_text(dumps(source), encoding="utf-8", newline="\n")
|
||||
print("wrote %s and %s" % (", ".join(p.name for p in files), SOURCE_PATH.name))
|
||||
return 0
|
||||
stale = [p.name for p in files if _load(p) != files[p]]
|
||||
if not SOURCE_PATH.is_file() or SOURCE_PATH.read_text(encoding="utf-8") != dumps(source):
|
||||
stale.append(SOURCE_PATH.name)
|
||||
if stale:
|
||||
print("%s: not what the captures give" % ", ".join(stale), file=sys.stderr)
|
||||
return 1
|
||||
print("the reference is what the captures give")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,135 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Extracts the retail frame and chrome of the maximized window at scale 1.0 and 1.25 from the 1920x1080 captures, into ci/retail-window-formula.json.
|
||||
|
||||
The e2e cases of a persona larger than any runner (2560x1440) have no retail capture of their own; their expected numbers are ``tests/_retail_window_formula.py`` applied to the persona's work area, with
|
||||
the border and the chrome of retail read here, from the same 1920x1080 raw.json files ``ci/retail-popup-sizes.json`` comes from:
|
||||
|
||||
* ``steps.maximized.native.window_rect`` -> the border in device pixels (the window starts at -border); ``steps.maximized.content.mozInnerScreenY`` times the scale -> the chrome (``ui``);
|
||||
* ``steps.popup_sizes`` variant ``width=500,height=400`` -> the frame of a popup;
|
||||
* launch ``b`` must give the same values as launch ``a``.
|
||||
|
||||
The formula is then APPLIED to the 1920x1080 work area the capture's page read (``screen.availWidth/availHeight``) and must give the capture's own ``outerWidth``, ``outerHeight``, ``innerWidth``,
|
||||
``innerHeight``, ``screenX``, ``screenY``, ``mozInnerScreenX/Y`` and the popup that names no size, exactly, or the extraction fails: a formula that does not reproduce the capture is not a formula.
|
||||
The file carries those capture values (``capture_case``) so that the unit test repeats the proof without the capture. One command writes it; without ``--write`` it compares:
|
||||
|
||||
python scripts/extract_retail_window_formula.py --captures <RetailCaptures>/captures --round 2026-12-01-window-geometry-r12 --run-url <url> --commit <RetailCaptures commit> --write
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(ROOT / "scripts"))
|
||||
sys.path.insert(0, str(ROOT / "tests"))
|
||||
|
||||
import _retail_window_formula as formula # noqa: E402
|
||||
import extract_retail_popup_sizes as popup # noqa: E402
|
||||
|
||||
DATA_PATH = formula.DATA_PATH
|
||||
#: The two scales of the cases larger than any runner: (folder of the dpr, panel of the capture, scale).
|
||||
DISPLAYS = (("dpr1", "1920x1080", 1.0), ("dpr1.25", "1920x1080", 1.25))
|
||||
ExtractError = popup.ExtractError
|
||||
|
||||
|
||||
def read_launch(capture: Path, dpr_dir: str, panel: str, scale: float, launch: str) -> Dict[str, Any]:
|
||||
path = capture / dpr_dir / panel / launch / "raw.json"
|
||||
if not path.is_file():
|
||||
raise ExtractError("missing %s" % path)
|
||||
raw = json.loads(path.read_text(encoding="utf-8"))
|
||||
if raw.get("dpr_asked") != scale:
|
||||
raise ExtractError("%s asks scale %r, not %r" % (path, raw.get("dpr_asked"), scale))
|
||||
try:
|
||||
maximized = raw["steps"]["maximized"]
|
||||
content, native = maximized["content"], maximized["native"]
|
||||
screen = content["probe"]["screen"]
|
||||
window_rect = native["window_rect"]
|
||||
border = -window_rect[0]
|
||||
if window_rect[0] != window_rect[1] or window_rect[2] - native["work_rect"][2] != border or window_rect[3] - native["work_rect"][3] != border:
|
||||
raise ExtractError("%s: the maximized window rect %r is not the work area %r inflated by one border" % (path, window_rect, native["work_rect"]))
|
||||
ui = formula.js_round(content["mozInnerScreenY"] * scale)
|
||||
names = (("ow", "outerWidth"), ("oh", "outerHeight"), ("iw", "innerWidth"), ("ih", "innerHeight"), ("sx", "screenX"), ("sy", "screenY"),
|
||||
("mx", "mozInnerScreenX"), ("my", "mozInnerScreenY"))
|
||||
observed = {key: content[name] for key, name in names}
|
||||
avail = [screen["availWidth"], screen["availHeight"]]
|
||||
except (KeyError, TypeError, IndexError) as exc:
|
||||
raise ExtractError("%s: the step maximized lacks %s" % (path, exc))
|
||||
variants = popup.variants_of(raw, str(path))
|
||||
if formula.SIZED not in variants or "popup" not in variants:
|
||||
raise ExtractError("%s has no popup_sizes variant for %r and 'popup'" % (path, formula.SIZED))
|
||||
sized, unsized = popup.reading(variants[formula.SIZED], "%s sized" % path), popup.reading(variants["popup"], "%s popup" % path)
|
||||
return {"border": border, "ui": ui, "avail_css": avail, "observed": observed, "popup_frame": list(formula.popup_frame(sized)),
|
||||
"popup_observed": {"inner": unsized["inner"], "outer": unsized["outer"], "screen": unsized["screen"]},
|
||||
"sha256": popup.sha256_of(path), "path": "%s/%s/%s/raw.json" % (dpr_dir, panel, launch),
|
||||
"browser": {"firefox_version": raw["firefox_version"], "build_id": raw["build_id"], "installer_sha256": raw["installer_sha256"]}}
|
||||
|
||||
|
||||
def prove(case: Dict[str, Any], scale: float, where: str) -> None:
|
||||
"""The formula applied to the capture's work area gives the capture's window and popup, exactly."""
|
||||
got = formula.expected_window(case["avail_css"], scale, case["border"], case["ui"])
|
||||
for key, want in case["observed"].items():
|
||||
if abs(got[key] - want) > 0.001:
|
||||
raise ExtractError("%s: the formula gives %s %r, the capture reads %r: not a formula of the frame" % (where, key, got[key], want))
|
||||
pop = formula.expected_popup("popup", got, tuple(case["popup_frame"]), scale, case["avail_css"])
|
||||
obs = case["popup_observed"]
|
||||
for key in ("inner", "outer", "screen"):
|
||||
if list(pop[key]) != list(obs[key]):
|
||||
raise ExtractError("%s: the formula gives the popup %s %r, the capture reads %r" % (where, key, list(pop[key]), obs[key]))
|
||||
|
||||
|
||||
def build(captures: Path, round_name: str, run_url: str, commit: str) -> Dict[str, Any]:
|
||||
capture = captures / popup.BROWSER_DIR / round_name
|
||||
cases: Dict[str, Any] = {}
|
||||
files: List[Dict[str, str]] = []
|
||||
browser: Optional[Dict[str, Any]] = None
|
||||
for dpr_dir, panel, scale in DISPLAYS:
|
||||
a, b = (read_launch(capture, dpr_dir, panel, scale, launch) for launch in ("a", "b"))
|
||||
for one in (a, b):
|
||||
files.append({"path": one["path"], "sha256": one["sha256"]})
|
||||
key = {k: v for k, v in a.items() if k not in ("sha256", "path")}
|
||||
if key != {k: v for k, v in b.items() if k not in ("sha256", "path")}:
|
||||
raise ExtractError("%s %s: launch a reads %r and launch b reads %r" % (dpr_dir, panel, key, b))
|
||||
if browser not in (None, a["browser"]):
|
||||
raise ExtractError("the scales come from two browsers: %r and %r" % (browser, a["browser"]))
|
||||
browser = a["browser"]
|
||||
prove(key, scale, "%s/%s" % (dpr_dir, panel))
|
||||
cases[str(scale)] = {"border": key["border"], "ui": key["ui"], "popup_frame": key["popup_frame"],
|
||||
"capture_case": {"panel": panel, "avail_css": key["avail_css"], "observed": key["observed"], "popup_observed": key["popup_observed"]}}
|
||||
return {
|
||||
"about": "The retail border, chrome and popup frame of the maximized window at scale 1.0 and 1.25, read from the 1920x1080 captures by scripts/extract_retail_window_formula.py; "
|
||||
"tests/_retail_window_formula.py applies them to any work area. Never edited by hand.",
|
||||
"capture": {"round": round_name, "run": run_url, "retail_captures_commit": commit, "browser": browser},
|
||||
"files": files,
|
||||
"scales": cases,
|
||||
}
|
||||
|
||||
|
||||
def main(argv: Optional[List[str]] = None) -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__.split("\n\n")[0])
|
||||
parser.add_argument("--captures", required=True, type=Path)
|
||||
parser.add_argument("--round", required=True)
|
||||
parser.add_argument("--run-url", required=True)
|
||||
parser.add_argument("--commit", required=True)
|
||||
parser.add_argument("--write", action="store_true")
|
||||
args = parser.parse_args(argv)
|
||||
try:
|
||||
text = popup.dumps(build(args.captures, args.round, args.run_url, args.commit))
|
||||
except ExtractError as exc:
|
||||
print("EXTRACTION FAILED: %s" % exc, file=sys.stderr)
|
||||
return 2
|
||||
if args.write:
|
||||
DATA_PATH.write_text(text, encoding="utf-8", newline="\n")
|
||||
print("wrote %s" % DATA_PATH)
|
||||
return 0
|
||||
if not DATA_PATH.is_file() or DATA_PATH.read_text(encoding="utf-8") != text:
|
||||
print("%s is not what the capture gives" % DATA_PATH, file=sys.stderr)
|
||||
return 1
|
||||
print("%s is what the capture gives" % DATA_PATH)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -11,12 +11,15 @@ trace: with a traced stock walk, ours must do what stock does: exit 0 when, for
|
||||
types as stock and left no more server hits unreported; 1 otherwise; 2 when stock reported no sendBeacon (a broken control, not a
|
||||
difference of ours). Without a traced stock walk (--no-stock): exit 0 when every sendBeacon request the client reported has the
|
||||
type `beacon`, there is at least one, and the client reported at least as many keepalive requests as the server saw; 1 otherwise.
|
||||
Both read the file run_fakeweb.py wrote, so a row is a JSON list, not a tuple. A report that cannot be read exits 4, one the reader
|
||||
breaks on exits 5: never 0 to 3, which are verdicts.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import collections
|
||||
import json
|
||||
import sys
|
||||
import traceback
|
||||
from urllib.parse import parse_qs, urlsplit
|
||||
|
||||
|
||||
@@ -48,7 +51,7 @@ def journey(report):
|
||||
out += ["### FAIL lines", ""]
|
||||
if report["fails"]:
|
||||
out.append("```")
|
||||
out += ["FAIL round %d step %d %s: stock=%r candidate=%r" % f for f in report["fails"]]
|
||||
out += ["FAIL round %d step %d %s: stock=%r candidate=%r" % tuple(f) for f in report["fails"]]
|
||||
out.append("```")
|
||||
else:
|
||||
out.append("none")
|
||||
@@ -199,7 +202,12 @@ def main(argv=None):
|
||||
except (OSError, ValueError) as exc:
|
||||
print("## Fake web, profile P4\n\n**RED: no report (%s). The runner did not finish.**\n" % exc)
|
||||
return 4
|
||||
text, code = (journey if argv[0] == "journey" else trace)(report)
|
||||
try:
|
||||
text, code = (journey if argv[0] == "journey" else trace)(report)
|
||||
except Exception: # a reader that breaks is no verdict: never an exit code the workflow reads as one (0 to 4)
|
||||
traceback.print_exc()
|
||||
print("## Fake web, profile P4\n\n**RED: the report could not be read (see the traceback in the log).**\n")
|
||||
return 5
|
||||
print(text)
|
||||
return code
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"about": "Where surface.systemColors of dpr1.0.json.gz and dpr1.5.json.gz comes from: retail Firefox 159 on Windows, written by scripts/extract_retail_syscolors.py from these captures. Never edited by hand.",
|
||||
"retail_captures_commit": "d5f8e27",
|
||||
"captures": [
|
||||
{
|
||||
"folder": "captures/firefox-159.0/windows-server-2025/syscolors/2026-12-01",
|
||||
"result_sha256": "58ea6e10af5b08809922c43860564277e4d4b4234ce5b1c983ff91df512439d0",
|
||||
"build_id": "20261022150525",
|
||||
"xul_dll_sha256": "fec21f3e7c281c836ff4fb9658bf321857e101750bc4a6280d1b419996ce7e29",
|
||||
"firefox_exe_sha256": "d8b5ed82fcd9c0f159dc86dc1c4526ceae981c4d9651f21908b6de90d0a56d85"
|
||||
},
|
||||
{
|
||||
"folder": "captures/firefox-159.0/windows-11-arm/syscolors/2026-12-02",
|
||||
"result_sha256": "58ea6e10af5b08809922c43860564277e4d4b4234ce5b1c983ff91df512439d0",
|
||||
"build_id": "20261022150525",
|
||||
"xul_dll_sha256": "204f37aae8e3f0416d92eeae572a78115992aca16c60092f3ad859ac69ee5f30",
|
||||
"firefox_exe_sha256": "c76a6fac5414effdc81f3735faa87b94e91fce46960a290b94054c1379682b93"
|
||||
}
|
||||
],
|
||||
"values": {
|
||||
"AccentColor": "rgb(0, 96, 223)",
|
||||
"AccentColorText": "rgb(255, 255, 255)",
|
||||
"ActiveText": "rgb(238, 0, 0)",
|
||||
"ButtonBorder": "rgb(129, 127, 132)",
|
||||
"ButtonFace": "rgb(233, 233, 237)",
|
||||
"ButtonText": "rgb(0, 0, 0)",
|
||||
"Canvas": "rgb(255, 255, 255)",
|
||||
"CanvasText": "rgb(0, 0, 0)",
|
||||
"Field": "rgb(255, 255, 255)",
|
||||
"FieldText": "rgb(0, 0, 0)",
|
||||
"GrayText": "rgb(109, 109, 109)",
|
||||
"Highlight": "rgb(0, 120, 212)",
|
||||
"HighlightText": "rgb(255, 255, 255)",
|
||||
"LinkText": "rgb(0, 0, 238)",
|
||||
"Mark": "rgb(255, 255, 0)",
|
||||
"MarkText": "rgb(0, 0, 0)",
|
||||
"SelectedItem": "rgb(0, 120, 212)",
|
||||
"SelectedItemText": "rgb(255, 255, 255)",
|
||||
"VisitedText": "rgb(85, 26, 139)",
|
||||
"ActiveBorder": "rgb(129, 127, 132)",
|
||||
"ActiveCaption": "rgb(255, 255, 255)",
|
||||
"AppWorkspace": "rgb(255, 255, 255)",
|
||||
"Background": "rgb(255, 255, 255)",
|
||||
"ButtonHighlight": "rgb(233, 233, 237)",
|
||||
"ButtonShadow": "rgb(233, 233, 237)",
|
||||
"CaptionText": "rgb(0, 0, 0)",
|
||||
"InactiveBorder": "rgb(129, 127, 132)",
|
||||
"InactiveCaption": "rgb(255, 255, 255)",
|
||||
"InactiveCaptionText": "rgb(109, 109, 109)",
|
||||
"InfoBackground": "rgb(255, 255, 255)",
|
||||
"InfoText": "rgb(0, 0, 0)",
|
||||
"Menu": "rgb(255, 255, 255)",
|
||||
"MenuText": "rgb(0, 0, 0)",
|
||||
"Scrollbar": "rgb(255, 255, 255)",
|
||||
"ThreeDDarkShadow": "rgb(129, 127, 132)",
|
||||
"ThreeDFace": "rgb(233, 233, 237)",
|
||||
"ThreeDHighlight": "rgb(129, 127, 132)",
|
||||
"ThreeDLightShadow": "rgb(129, 127, 132)",
|
||||
"ThreeDShadow": "rgb(129, 127, 132)",
|
||||
"Window": "rgb(255, 255, 255)",
|
||||
"WindowFrame": "rgb(129, 127, 132)",
|
||||
"WindowText": "rgb(0, 0, 0)",
|
||||
"-moz-buttonhoverface": "rgb(0, 0, 0)",
|
||||
"-moz-buttonhovertext": "rgb(0, 0, 0)",
|
||||
"-moz-cellhighlight": "rgb(206, 206, 206)",
|
||||
"-moz-dialog": "rgb(255, 255, 255)",
|
||||
"-moz-dialogtext": "rgb(0, 0, 0)",
|
||||
"-moz-oddtreerow": "rgb(255, 255, 255)"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
"""The size of a popup opened with ``window.open(url, '', 'width=W,height=H')`` from a maximized main window, as a formula of the scale, the work area and the frame: what Mozilla's code computes.
|
||||
|
||||
The numbers of a popup are not typed anywhere in the wrapper: ``scripts/extract_retail_popup_move_resize.py`` applies this formula to every retail capture of a popup (the later popups of a browser, the popups of a
|
||||
second session of a profile whose store holds the main window, the older window-geometry rounds) and refuses to write ``ci/retail-popup-move-resize.json`` unless the formula reproduces every one of them.
|
||||
|
||||
The chain (Firefox 159, the code is unchanged in the series; every step is in device pixels, the only CSS detours are the shell size and the spec):
|
||||
|
||||
1. ``AppWindow::CreateNewContentWindow`` makes the window and spins until the chrome is loaded (AppWindow.cpp:2225-2275).
|
||||
2. ``AppWindow::SizeShell`` (AppWindow.cpp:2408): the spec is the XUL attribute (CSS integer) plus ``R(NC / s)`` (windowDiff :2418, :2441-2442); ``SetSpecifiedSize`` (:1249) gives the window ``w0 = R(spec * s)``
|
||||
(:1272-1273). The attribute is the store of the XUL (``GetPersistentValue`` :1598, outer to inner by ``ConvertWindowSize`` :1572) or, with no store, ``browser-init.js:129-135``: ``int(min(0.9 * avail, 1280 or 1040))``.
|
||||
3. ``LoadPersistentWindowState`` (AppWindow.cpp:2322-2350): a popup gets the stored spec of the MAIN window when the store has the entry, and keeps its own spec when it has not. The entry is written by any
|
||||
maximize, resize or activation after the chrome has loaded (AppWindow.cpp :2549, :2561, :2625, :2771): a profile that ever opened a window for a user holds it; a NEW profile that was never changed does not.
|
||||
4. ``SizeOpenedWindow`` (nsWindowWatcher.cpp:2262, inner size on both axes :2473-2483): ``A = R(asked * s)``, then ``SetPrimaryContentSize`` (AppWindow.cpp:2116) and ``SizeShellToWithLimit`` (:2490): the shell is
|
||||
``R(R(c0 / s) * s)`` for the client ``c0`` the window has at birth (``GetPrimaryRemoteTabSize`` :2086-2088), and the window becomes ``max(w0 + (A - shell), A)`` (:2505).
|
||||
|
||||
The formula, per axis, in device pixels (``R(x) = floor(x + 0.5)``, ``NSToIntRound``)::
|
||||
|
||||
w0 = R(S * s) c0 = w0 - NC - T W = w0 + R(ask * s) - R(css(c0) * s)
|
||||
client = W - NC inner = css(client - T) outer = R(W / s) resizeBy(0, 0): W' = R(outer * s)
|
||||
|
||||
``S`` is the spec the window is born with: the FRESH spec (the popup keeps its own, ``attr + R(NC_popup / s)``) or the STORED spec (the main window's, ``attr + R(NC_main / s)`` converted through the store). ``NC`` is the
|
||||
popup's non-client size (``2 * border`` wide; ``client_top + border`` high), ``T`` its toolbar (``popup_ui - client_top`` high, 0 wide), ``css(d)`` the CSS size of ``d`` device pixels by app units per device pixel
|
||||
(``round(60 / s)``, 60 app units a CSS pixel). The frame (``border``, ``client_top``, ``popup_ui``) is read from the retail capture by the extractor.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import math
|
||||
from typing import Dict, NamedTuple, Tuple
|
||||
|
||||
#: The popup of the test: ``width=500,height=400``.
|
||||
ASK = (500, 400)
|
||||
#: The two states of the store the popup is born in.
|
||||
FRESH = "fresh"
|
||||
STORED = "stored"
|
||||
SPECS = (FRESH, STORED)
|
||||
#: ``browser-init.js:129-135``: the CSS size of the main window with no store, at most 1280 by 1040.
|
||||
ATTR_LIMIT = (1280, 1040)
|
||||
ATTR_FRACTION = 0.9
|
||||
AXES = ("w", "h")
|
||||
|
||||
|
||||
class Frame(NamedTuple):
|
||||
"""The frame of the popup in device pixels: the border, the client origin below the top of the window, and the chrome above the content (the toolbar included)."""
|
||||
border: int
|
||||
client_top: int
|
||||
ui: int
|
||||
|
||||
|
||||
def round_half_up(x: float) -> int:
|
||||
return int(math.floor(x + 0.5))
|
||||
|
||||
|
||||
def css_of_device(d: int, scale: float) -> int:
|
||||
"""``StealthCssOfDevice``: the CSS size of ``d`` device pixels, by app units per device pixel."""
|
||||
per_device = max(1, round_half_up(60.0 / scale))
|
||||
return round_half_up(d * per_device / 60.0)
|
||||
|
||||
|
||||
def _specs(scale: float, avail_css: Tuple[int, int], frame: Frame):
|
||||
attr = tuple(int(min(avail_css[axis] * ATTR_FRACTION, ATTR_LIMIT[axis])) for axis in (0, 1))
|
||||
main_nc = (2 * frame.border, frame.border)
|
||||
popup_nc = (2 * frame.border, frame.client_top + frame.border)
|
||||
toolbar = (0, frame.ui - frame.client_top)
|
||||
spec = []
|
||||
for axis in (0, 1):
|
||||
fresh = attr[axis] + round_half_up(popup_nc[axis] / scale)
|
||||
main = attr[axis] + round_half_up(main_nc[axis] / scale)
|
||||
stored = css_of_device(round_half_up(main * scale) - main_nc[axis], scale) + round_half_up(main_nc[axis] / scale)
|
||||
spec.append({FRESH: fresh, STORED: stored})
|
||||
return spec, popup_nc, toolbar
|
||||
|
||||
|
||||
def popup_sizes(scale: float, avail_css: Tuple[int, int], frame: Frame, spec: str, ask: Tuple[int, int] = ASK) -> Dict[str, Dict[str, int]]:
|
||||
"""Per axis (``w``, ``h``): ``spec`` (CSS), ``window`` (device), ``inner`` and ``outer`` (CSS) of the popup as opened, and ``resized_window``, ``resized_inner``, ``resized_outer`` after ``resizeBy(0, 0)``."""
|
||||
if spec not in SPECS:
|
||||
raise ValueError("the spec is %r, not one of %r" % (spec, SPECS))
|
||||
specs, nc, toolbar = _specs(scale, avail_css, frame)
|
||||
out: Dict[str, Dict[str, int]] = {}
|
||||
for axis, name in enumerate(AXES):
|
||||
s = specs[axis][spec]
|
||||
w0 = round_half_up(s * scale)
|
||||
c0 = w0 - nc[axis] - toolbar[axis]
|
||||
window = w0 + round_half_up(ask[axis] * scale) - round_half_up(css_of_device(c0, scale) * scale)
|
||||
outer = round_half_up(window / scale)
|
||||
resized = round_half_up(outer * scale)
|
||||
out[name] = {
|
||||
"spec": s,
|
||||
"window": window,
|
||||
"inner": css_of_device(window - nc[axis] - toolbar[axis], scale),
|
||||
"outer": outer,
|
||||
"resized_window": resized,
|
||||
"resized_inner": css_of_device(resized - nc[axis] - toolbar[axis], scale),
|
||||
"resized_outer": round_half_up(resized / scale),
|
||||
}
|
||||
return out
|
||||
|
||||
|
||||
def observed_sizes(inner: Tuple[int, int], outer: Tuple[int, int], window: Tuple[int, int]) -> Dict[str, Dict[str, int]]:
|
||||
"""What a capture read, in the shape of ``popup_sizes`` for one moment (``window`` is the size of the native window rect)."""
|
||||
return {name: {"inner": inner[axis], "outer": outer[axis], "window": window[axis]} for axis, name in enumerate(AXES)}
|
||||
|
||||
|
||||
def expected_for_moment(sizes: Dict[str, Dict[str, int]], moment: str) -> Dict[str, Dict[str, int]]:
|
||||
"""The formula's numbers for the moment ``initial`` (as opened) or ``resized`` (after ``resizeBy(0, 0)``), in the shape of ``observed_sizes``."""
|
||||
keys = {"initial": ("inner", "outer", "window"), "resized": ("resized_inner", "resized_outer", "resized_window")}[moment]
|
||||
return {name: {"inner": sizes[name][keys[0]], "outer": sizes[name][keys[1]], "window": sizes[name][keys[2]]} for name in AXES}
|
||||
+26
-2
@@ -33,13 +33,33 @@ from fakeweb import journey_site, profile_p2, profile_p4, sites # noqa: E402
|
||||
HARD = ["leaving_beacons_subframe", "leaving_beacons", "cancel_among_beacons"]
|
||||
|
||||
|
||||
def step_evidence(keys, steps, client_log, site_records):
|
||||
"""For each (round, step) of `keys`: the step's record with its moments (`m_*`, time.perf_counter() of this process) and what
|
||||
the client counted in flight, then what the client heard and what the site saw between the start of the step and the end of
|
||||
its idle wait. Kept for a step that differs or whose control broke, so the report says where an open request stopped: never sent,
|
||||
never answered, or answered and never heard. Never compared."""
|
||||
out = []
|
||||
for rec in steps:
|
||||
if (rec["round"], rec["n"]) not in keys or "m_step_start" not in rec or "m_idle_end" not in rec:
|
||||
continue
|
||||
lo, hi = rec["m_step_start"], rec["m_idle_end"]
|
||||
def within(e):
|
||||
return any(isinstance(v, (int, float)) and lo <= v <= hi for k, v in e.items() if k.startswith("m"))
|
||||
out.append({"round": rec["round"], "n": rec["n"], "step": {k: v for k, v in rec.items() if k.startswith(("m_", "t_", "in_flight"))},
|
||||
"client": [e for e in client_log if within(e)], "site": [e for e in site_records if within(e)]})
|
||||
return out
|
||||
|
||||
|
||||
def run_p4(args, sync_playwright, not_idle_steps):
|
||||
rounds = args.repetitions or 1
|
||||
kw = {"idle_timeout_ms": args.idle_timeout_ms or 15000, "trace": args.trace}
|
||||
logs = {"stock": ([], []), "candidate": ([], [])} # (client_log, step_log) of each browser, for the evidence of a red
|
||||
origin_a, origin_o, stop = journey_site.start((0, 0))
|
||||
try: # stock first, then ours: the same invocation, one browser at a time
|
||||
stock = [] if args.no_stock else profile_p4.run_on_stock(sync_playwright, origin_a, origin_o, rounds, **kw)
|
||||
candidate = profile_p4.run_on_candidate(sync_playwright, args.binary, origin_a, origin_o, rounds, **kw)
|
||||
stock = [] if args.no_stock else profile_p4.run_on_stock(
|
||||
sync_playwright, origin_a, origin_o, rounds, client_log=logs["stock"][0], step_log=logs["stock"][1], **kw)
|
||||
candidate = profile_p4.run_on_candidate(
|
||||
sync_playwright, args.binary, origin_a, origin_o, rounds, client_log=logs["candidate"][0], step_log=logs["candidate"][1], **kw)
|
||||
finally:
|
||||
stop()
|
||||
if args.no_stock: # stock is what pages.json says it is
|
||||
@@ -47,6 +67,10 @@ def run_p4(args, sync_playwright, not_idle_steps):
|
||||
fails, broken = profile_p4.verdict(candidate, stock, not_idle_steps)
|
||||
report = {"profile": "p4", "rounds": rounds, "candidate": candidate, "stock": stock,
|
||||
"fails": fails, "broken_control": broken}
|
||||
keys = {(r, n) for r, n, *_ in fails} | {(r, n) for r, n, *_ in broken}
|
||||
if keys:
|
||||
records = list(stop.state.records)
|
||||
report["evidence"] = {side: step_evidence(keys, logs[side][1], logs[side][0], records) for side in logs}
|
||||
if args.out:
|
||||
pathlib.Path(args.out).write_text(json.dumps(report, indent=1), encoding="utf-8")
|
||||
print("%-5s %-42s %-6s %-6s %s" % ("step", "name", "stock", "ours", "idle (stock/ours)"))
|
||||
|
||||
+75
-10
@@ -170,6 +170,36 @@ return JSON.stringify({outer: [win.outerWidth, win.outerHeight], inner: [win.inn
|
||||
"""
|
||||
|
||||
|
||||
#: Sets the outer size of the window in DEVICE pixels, from chrome scope: ``WebDriver:SetWindowRect`` takes whole CSS pixels only, and at a display scale of 2 the content area that ours declares
|
||||
#: (``innerHeight`` 558.5 at 2.0) is an odd number of device pixels, which no whole CSS size of the outer window gives. ``resizeTo`` is this call after the conversion of CSS pixels to device pixels
|
||||
#: (nsGlobalWindowOuter::SetOuterSize -> nsIBaseWindow.setSize), so the window is the same one.
|
||||
RESIZE_JS = """
|
||||
const [width, height] = arguments;
|
||||
const win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
const scale = win.devicePixelRatio;
|
||||
win.docShell.treeOwner.QueryInterface(Ci.nsIBaseWindow).setSize(Math.round(width * scale), Math.round(height * scale), true);
|
||||
return JSON.stringify({ok: true});
|
||||
"""
|
||||
|
||||
|
||||
#: Sizes the window so that its content area (``innerWidth`` x ``innerHeight`` of the chrome window, fractional CSS pixels) is the one asked, and reads the window's own frame in DEVICE pixels in the same
|
||||
#: chrome read: frame = ``nsIBaseWindow.getSize`` (the whole window, device pixels) less the content area in device pixels (``inner * devicePixelRatio``, whole device pixels as the widget gives them).
|
||||
#: The window is then set to the asked content area plus that frame, all in device pixels, so an odd number of device pixels (558.5 CSS = 1117 device at a scale of 2) is reachable, which no whole CSS
|
||||
#: ``outerHeight`` is: ``outerWidth`` and ``outerHeight`` are whole CSS pixels (nsGlobalWindowOuter::GetOuterSize rounds, nsGlobalWindowOuter.cpp:3573), ``innerWidth`` and ``innerHeight`` are not.
|
||||
CONTENT_JS = """
|
||||
const [width, height] = arguments;
|
||||
const win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
const scale = win.devicePixelRatio;
|
||||
const base = win.docShell.treeOwner.QueryInterface(Ci.nsIBaseWindow);
|
||||
const w = {}, h = {};
|
||||
base.getSize(w, h);
|
||||
const frame = [w.value - Math.round(win.innerWidth * scale), h.value - Math.round(win.innerHeight * scale)];
|
||||
const asked = [Math.round(width * scale) + frame[0], Math.round(height * scale) + frame[1]];
|
||||
base.setSize(asked[0], asked[1], true);
|
||||
return JSON.stringify({frame, asked, scale});
|
||||
"""
|
||||
|
||||
|
||||
class RetailSession:
|
||||
"""Retail Firefox 159 with Marionette, headed, one profile; closed with its whole tree."""
|
||||
|
||||
@@ -208,8 +238,14 @@ class RetailSession:
|
||||
return self._marionette.call(command, params)
|
||||
|
||||
def set_window_size(self, outer: Tuple[float, float]) -> Dict[str, Any]:
|
||||
"""Sets the window's outer size to ``outer`` (CSS pixels of the chrome), at the origin of the screen, and reads back the sizes the chrome window answers."""
|
||||
self.call("content", "WebDriver:SetWindowRect", {"x": 0, "y": 0, "width": int(outer[0]), "height": int(outer[1])})
|
||||
"""Sets the window's outer size to ``outer`` (CSS pixels of the chrome) and reads back the sizes the chrome window answers. The first call also puts it at the origin of the screen.
|
||||
|
||||
Whole numbers go through Marionette (``WebDriver:SetWindowRect``, which takes only those); a size with a fraction (a content area of an odd number of device pixels at a scale of 2) is set
|
||||
from chrome scope in device pixels (``RESIZE_JS``)."""
|
||||
if all(float(v).is_integer() for v in outer):
|
||||
self.call("content", "WebDriver:SetWindowRect", {"x": 0, "y": 0, "width": int(outer[0]), "height": int(outer[1])})
|
||||
else:
|
||||
self.call("chrome", "WebDriver:ExecuteScript", {"script": RESIZE_JS, "args": [outer[0], outer[1]]})
|
||||
read = SIZE_JS
|
||||
out: Dict[str, Any] = {}
|
||||
for _ in range(int(DEADLINE_S * 10)):
|
||||
@@ -219,6 +255,22 @@ class RetailSession:
|
||||
time.sleep(0.1)
|
||||
return out
|
||||
|
||||
def set_inner_size(self, inner: Tuple[float, float]) -> Dict[str, Any]:
|
||||
"""Sets the window so that its content area is ``inner`` (CSS pixels of the chrome, fractions allowed) and reads back what the chrome window answers. The window is put at the origin of the screen.
|
||||
|
||||
The frame is read in device pixels through the chrome (``CONTENT_JS``) and the window is set to ``inner`` plus that frame in device pixels. The answer has ``outer`` and ``inner`` (CSS pixels, as
|
||||
the window reads them: ``outer`` is whole), ``frame_device`` and ``asked_outer`` (device pixels, and the same in CSS pixels, the last fractional)."""
|
||||
self.call("content", "WebDriver:SetWindowRect", {"x": 0, "y": 0})
|
||||
asked = json.loads(self.call("chrome", "WebDriver:ExecuteScript", {"script": CONTENT_JS, "args": [inner[0], inner[1]]})["value"])
|
||||
out: Dict[str, Any] = {}
|
||||
for _ in range(int(DEADLINE_S * 10)):
|
||||
out = json.loads(self.call("chrome", "WebDriver:ExecuteScript", {"script": SIZE_JS, "args": []})["value"])
|
||||
if out["inner"] == [inner[0], inner[1]]:
|
||||
break
|
||||
time.sleep(0.1)
|
||||
out.update({"frame_device": asked["frame"], "asked_outer_device": asked["asked"], "asked_outer": [asked["asked"][i] / asked["scale"] for i in range(2)]})
|
||||
return out
|
||||
|
||||
def __exit__(self, *exc) -> None:
|
||||
if self._marionette is not None:
|
||||
self._marionette.close()
|
||||
@@ -294,12 +346,25 @@ class RetailDriver(Driver):
|
||||
time.sleep(ms / 1000.0)
|
||||
|
||||
|
||||
def size_by_content(session: Any, ours_inner: Any) -> Tuple[list, Dict[str, Any]]:
|
||||
"""``(asked, got)``: the retail window sized so that its content area (``inner``) is the one of ours, whatever its frame is.
|
||||
|
||||
Ours declares a frame of its own (the one of a Windows window), and the retail window has the one of its system and display (none on Xvfb without a window manager, 8x4 CSS pixels at a scale of 2 on
|
||||
a Windows runner), so the same OUTER size is not the same content area. The frame is read in exact device pixels through the chrome (``RetailSession.set_inner_size``) and the window is asked
|
||||
ours' inner size plus that frame. ``asked`` is the outer size asked (CSS pixels, fractional when the device pixels are odd at the scale), ``got`` what the window answers to it. The outer size the
|
||||
window reads back is not compared with ``asked``: ``outerWidth`` and ``outerHeight`` are whole CSS pixels (nsGlobalWindowOuter::GetOuterSize rounds, nsGlobalWindowOuter.cpp:3573), ``innerWidth``
|
||||
and ``innerHeight`` are fractional, so a content area of an odd number of device pixels at a scale of 2 has no outer size that reads back as asked."""
|
||||
got = session.set_inner_size((ours_inner[0], ours_inner[1]))
|
||||
return list(got["asked_outer"]), got
|
||||
|
||||
|
||||
def run_retail_twin(case: str, firefox_binary: str, measure: Callable[[Driver], Dict[str, Any]]) -> Tuple[Dict[str, Any], Dict[str, Any]]:
|
||||
"""(retail's record, ours): the same ``measure(driver)`` on our engine and on the retail reference, one browser at a time. Needs MOZ_REMOTE_ALLOW_SYSTEM_ACCESS=1 for ours.
|
||||
|
||||
Ours goes first, for its window: the retail window is given the SAME outer size as ours (the maximized window of the case's declared screen, as ``launch_case`` makes it, read from the
|
||||
chrome window's ``outerWidth`` and ``outerHeight``), and the inner sizes both chrome windows answer are compared before anything is measured: when they differ the verdict is BROKEN CONTROL,
|
||||
not a finding about ours. Both sizes are in each record (``scales.chrome_outer``, ``scales.chrome_inner``), with the size the retail window was asked (``scales.window_asked_outer``)."""
|
||||
Ours goes first, for its window: the retail window is given the SAME content area as ours (the maximized window of the case's declared screen, as ``launch_case`` makes it, read from the chrome
|
||||
window's ``innerWidth`` and ``innerHeight``) by ``size_by_content``: ours' inner size plus the frame the retail window shows, read in device pixels. The inner sizes both chrome windows answer are
|
||||
compared before anything is measured: when they differ the verdict is BROKEN CONTROL, not a finding about ours. The outer size the retail window reads back is not a condition (it is whole CSS
|
||||
pixels). Both sizes are in each record (``scales.chrome_outer``, ``scales.chrome_inner``), with the outer size the retail window was asked (``scales.window_asked_outer``)."""
|
||||
executable = retail_executable()
|
||||
with launch_case(firefox_binary, case, extra_args=MARIONETTE_ARGS, extra_prefs={"marionette.port": 0}) as browser:
|
||||
page = browser.new_page() # first: the window the session below waits for
|
||||
@@ -308,12 +373,12 @@ def run_retail_twin(case: str, firefox_binary: str, measure: Callable[[Driver],
|
||||
ours = measure(PlaywrightDriver(page, chrome))
|
||||
finally:
|
||||
chrome.close()
|
||||
asked = ours["scales"]["chrome_outer"]
|
||||
with RetailSession(executable, CASES[case][0]) as session:
|
||||
got = session.set_window_size((asked[0], asked[1]))
|
||||
if got.get("outer") != asked or got.get("inner") != ours["scales"]["chrome_inner"]:
|
||||
raise BrokenControl("BROKEN CONTROL, no finding about ours: the retail window was asked the outer size of ours %r and answers outer %r and inner %r; ours has inner %r (case %s)"
|
||||
% (asked, got.get("outer"), got.get("inner"), ours["scales"]["chrome_inner"], case))
|
||||
asked, got = size_by_content(session, ours["scales"]["chrome_inner"])
|
||||
if got.get("inner") != ours["scales"]["chrome_inner"]:
|
||||
raise BrokenControl("BROKEN CONTROL, no finding about ours: the retail window was asked the outer size %r (the content area of ours %r plus its own frame; the outer size of ours is %r) and answers outer %r and inner %r; "
|
||||
"ours has inner %r (case %s)"
|
||||
% (asked, ours["scales"]["chrome_inner"], ours["scales"]["chrome_outer"], got.get("outer"), got.get("inner"), ours["scales"]["chrome_inner"], case))
|
||||
retail = measure(RetailDriver(session))
|
||||
retail["scales"]["window_asked_outer"] = asked
|
||||
return retail, ours
|
||||
@@ -0,0 +1,102 @@
|
||||
"""The maximized window and its popups of a persona larger than any runner (2560x1440, scale 1.0 and 1.25), as ONE formula from the retail frame.
|
||||
|
||||
No retail capture exists at 2560x1440 (the runners' display driver offers no such mode). What a retail window reads is a formula of three things: the work area of the screen, the frame
|
||||
Windows draws around it (the border, in device pixels) and the browser chrome above the page (``ui``, in device pixels). The work area is the persona's, declared and read by the page
|
||||
(``screen.availWidth``, ``screen.availHeight``); the border and the chrome are retail's, read by ``scripts/extract_retail_window_formula.py`` from the 1920x1080 captures of the same scale (the
|
||||
captures ``ci/retail-popup-sizes.json`` comes from: ``native.window_rect`` for the border, ``mozInnerScreenY`` for the chrome) and written to ``ci/retail-window-formula.json``. The formula is
|
||||
proven where there is a capture: applied to the 1920x1080 work area it gives the capture's numbers exactly (the script refuses to write a file otherwise, and
|
||||
``tests/test_the_retail_window_formula_reproduces_the_1920x1080_captures.py`` repeats it). Both screens go through the same function.
|
||||
|
||||
In device pixels (W, H the work area, B the border, ui the chrome, d the scale, ``round`` is JavaScript's ``Math.round``):
|
||||
|
||||
outerWidth = round((W + 2B) / d) outerHeight = round((H + 2B) / d)
|
||||
innerWidth = round(W / d) innerHeight = round((H - ui) / d)
|
||||
screenX = screenY = round(-B / d) mozInnerScreenX = 0, mozInnerScreenY = ui / d
|
||||
|
||||
and for the popup that names no size (it takes the window of the main one) the popup's own frame (fw, fh) is the outer minus the inner of the capture's ``width=500,height=400`` popup (a size
|
||||
asked is the size of the page, so the frame is the difference): ``popup`` inner = (main outer width - fw, main outer height - fh), outer = the main window's, screen = the main window's.
|
||||
The chrome of 1920x1080 and of 2560x1440 is the same bar: at both scales the work area is tall enough for the full-height bar.
|
||||
|
||||
``width=500,height=400`` is NOT the size asked: Mozilla sizes the popup by a difference, from the content size of the window it is born with, measured as a whole number of CSS pixels
|
||||
(``AppWindow::GetPrimaryRemoteTabSize``, AppWindow.cpp:2086-2088, then ``SizeShellToWithLimit``). Its inner and outer size are ``scripts/retail_popup_formula.py`` with the STORED spec (the main
|
||||
window is maximized, so the store holds its entry) and the popup frame of the same scale from ``ci/retail-popup-move-resize.json``, the formula the extraction checks against every retail popup
|
||||
captured. At 2560x1440 and 1.25 the window is born 1250 device pixels tall, its content 1152 (921.6 CSS, read as 922, back as 1153), so the window ends at 597 and the page reads 500x399.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import math
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, Tuple
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "scripts"))
|
||||
|
||||
import retail_popup_formula as popup_formula # noqa: E402
|
||||
|
||||
#: case id -> (display scale, panel in device pixels).
|
||||
BIG_CASES: Dict[str, Tuple[float, Tuple[int, int]]] = {
|
||||
"2560x1440-dpr1.0": (1.0, (2560, 1440)),
|
||||
"2560x1440-dpr1.25": (1.25, (2560, 1440)),
|
||||
}
|
||||
|
||||
DATA_PATH = Path(__file__).resolve().parent.parent / "ci" / "retail-window-formula.json"
|
||||
#: The popup frame per scale (border, client top, chrome), read from the retail capture by ``scripts/extract_retail_popup_move_resize.py``.
|
||||
POPUP_FORMULA_PATH = Path(__file__).resolve().parent.parent / "ci" / "retail-popup-move-resize.json"
|
||||
#: The popup the frame of a popup is the difference of.
|
||||
SIZED = "width=500,height=400"
|
||||
|
||||
|
||||
def js_round(value: float) -> int:
|
||||
"""``Math.round``: halves go up (the way a page reads -6.5 as -6 and 6.5 as 7)."""
|
||||
return int(math.floor(value + 0.5))
|
||||
|
||||
|
||||
def load() -> Dict[str, Any]:
|
||||
return json.loads(DATA_PATH.read_text(encoding="utf-8"))
|
||||
|
||||
|
||||
def device(avail_css: Tuple[float, float], scale: float) -> Tuple[int, int]:
|
||||
"""The work area in device pixels from the one the page reads (CSS pixels)."""
|
||||
return js_round(avail_css[0] * scale), js_round(avail_css[1] * scale)
|
||||
|
||||
|
||||
def expected_window(avail_css: Tuple[float, float], scale: float, border: int, ui: int) -> Dict[str, Any]:
|
||||
"""What a page reads in the maximized window of a screen whose work area is ``avail_css``, given the retail border and chrome (device pixels)."""
|
||||
w, h = device(avail_css, scale)
|
||||
return {"ow": js_round((w + 2 * border) / scale), "oh": js_round((h + 2 * border) / scale), "iw": js_round(w / scale), "ih": js_round((h - ui) / scale),
|
||||
"sx": js_round(-border / scale), "sy": js_round(-border / scale), "mx": 0, "my": ui / scale}
|
||||
|
||||
|
||||
def popup_frame(sized: Dict[str, Any]) -> Tuple[int, int]:
|
||||
"""The frame of a popup (outer minus inner) from retail's ``width=500,height=400`` reading."""
|
||||
return sized["outer"][0] - sized["inner"][0], sized["outer"][1] - sized["inner"][1]
|
||||
|
||||
|
||||
def popup_frame_of_scale(scale: float) -> "popup_formula.Frame":
|
||||
"""The retail popup frame (device pixels) of the scale, from the extracted capture."""
|
||||
cases = json.loads(POPUP_FORMULA_PATH.read_text(encoding="utf-8"))["stored_spec_formula"]["cases"]
|
||||
frames = [case["frame"] for case in cases.values() if case["scale"] == scale]
|
||||
if len(frames) != 1:
|
||||
raise KeyError("%d captured cases at scale %r in %s" % (len(frames), scale, POPUP_FORMULA_PATH))
|
||||
return popup_formula.Frame(**frames[0])
|
||||
|
||||
|
||||
def expected_popup(features: str, window: Dict[str, Any], frame: Tuple[int, int], scale: float, avail_css: Tuple[int, int]) -> Dict[str, Any]:
|
||||
"""The popup ``features`` opens from the maximized main window ``window`` (the dict ``expected_window`` gives) on the work area ``avail_css`` at ``scale``; ``frame`` is ``popup_frame``."""
|
||||
if features == SIZED:
|
||||
sizes = popup_formula.popup_sizes(scale, (int(avail_css[0]), int(avail_css[1])), popup_frame_of_scale(scale), popup_formula.STORED)
|
||||
return {"inner": (sizes["w"]["inner"], sizes["h"]["inner"]), "outer": (sizes["w"]["outer"], sizes["h"]["outer"])}
|
||||
if features == "popup":
|
||||
outer = (window["ow"], window["oh"])
|
||||
return {"inner": (outer[0] - frame[0], outer[1] - frame[1]), "outer": outer, "screen": (window["sx"], window["sy"])}
|
||||
raise KeyError(features)
|
||||
|
||||
|
||||
def launch_big(firefox_binary: str, case: str, **extra: Any):
|
||||
"""The product on one of the cases above: seed 42, the panel and the scale pinned, headless, no humanizing (``_window_origin.launch_case`` for the four runner-sized cases)."""
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
dpr, panel = BIG_CASES[case]
|
||||
pin = {"screen.width": panel[0], "screen.height": panel[1], "screen.dpr": dpr}
|
||||
return InvisiblePlaywright(seed=42, pin=pin, binary_path=firefox_binary, headless=True, humanize=False, **extra)
|
||||
@@ -1,7 +1,7 @@
|
||||
"""The strace stand-in of the Linux font tests: the engine's directory as links, whose executable runs the real one under ``strace`` in the
|
||||
engine's place (same pid, same process group), and what reads its log (who is the parent and who a content process) and cleans its group.
|
||||
|
||||
Used by tests/test_the_parent_reads_the_bundle_from_fontconfig_s_cache_linux_e2e.py. No test of its own, no browser."""
|
||||
Used by tests/test_the_parent_reads_the_bundle_from_fontconfig_s_cache_linux_e2e.py and tests/test_no_fontconfig_file_of_the_host_is_opened_and_the_screenshot_draws_the_bundle_linux_e2e.py. No test of its own, no browser."""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
"""What the X server says about the real window of a popup, and a root window that answers as a window manager does: the two things the declared-frame e2e of Linux needs.
|
||||
|
||||
The engine tells a page a declared frame around a popup (``outerWidth`` is the size declared at birth, whatever the real window is), so a page cannot read whether the
|
||||
GTK window of the popup really has the declared frame in its client area or has Mozilla's own: the real window is a thing of the X server. ``XFrame`` reads its width
|
||||
through a connection of its own to the display (libX11, as ``_os_focus.XFocus``, whose connection and window lookup by title this reuses), and puts on the root window
|
||||
what a window manager puts there and a widget could read: ``_NET_SUPPORTING_WM_CHECK`` on the root and on a checking window, and ``_NET_WM_STATE_FULLSCREEN`` in
|
||||
``_NET_SUPPORTED`` (what ``gdk_x11_screen_supports_net_wm_hint`` asks). No window manager is started: the properties are all the engine's old test of "a window manager
|
||||
is here" read, and no window is reparented.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import ctypes
|
||||
from typing import Optional
|
||||
|
||||
from _os_focus import XFocus, _XWindowAttributes
|
||||
|
||||
#: ``XA_ATOM`` and ``XA_WINDOW`` (``Xatom.h``), ``PropModeReplace`` (``X.h``).
|
||||
_XA_ATOM, _XA_WINDOW, _PROP_MODE_REPLACE = 4, 33, 0
|
||||
|
||||
|
||||
class XFrame(XFocus):
|
||||
"""An X connection that reads the real size of a toplevel and makes the root answer as a window manager."""
|
||||
|
||||
def __init__(self, display: str) -> None:
|
||||
super().__init__(display)
|
||||
x11 = self.x11
|
||||
x11.XCreateSimpleWindow.restype = ctypes.c_ulong
|
||||
x11.XCreateSimpleWindow.argtypes = (ctypes.c_void_p, ctypes.c_ulong, ctypes.c_int, ctypes.c_int, ctypes.c_uint, ctypes.c_uint, ctypes.c_uint,
|
||||
ctypes.c_ulong, ctypes.c_ulong)
|
||||
x11.XChangeProperty.argtypes = (ctypes.c_void_p, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_int, ctypes.c_int, ctypes.c_void_p, ctypes.c_int)
|
||||
x11.XDeleteProperty.argtypes = (ctypes.c_void_p, ctypes.c_ulong, ctypes.c_ulong)
|
||||
x11.XDestroyWindow.argtypes = (ctypes.c_void_p, ctypes.c_ulong)
|
||||
self._check_window: Optional[int] = None
|
||||
self._atom = lambda name: x11.XInternAtom(self.connection, name, False)
|
||||
|
||||
def width_of(self, window: int) -> int:
|
||||
"""The width of a toplevel in device pixels, as the X server has it (the window the engine made, not a number the engine says)."""
|
||||
attributes = _XWindowAttributes()
|
||||
self.x11.XGetWindowAttributes(self.connection, window, ctypes.byref(attributes))
|
||||
return int(attributes.width)
|
||||
|
||||
def answer_as_a_window_manager(self) -> None:
|
||||
"""The properties of a window manager: the root and a checking window name the checking window, and the root lists ``_NET_WM_STATE_FULLSCREEN``."""
|
||||
x11 = self.x11
|
||||
self._check_window = int(x11.XCreateSimpleWindow(self.connection, self.root, -10, -10, 1, 1, 0, 0, 0))
|
||||
check = (ctypes.c_long * 1)(self._check_window)
|
||||
fullscreen = (ctypes.c_long * 1)(self._atom(b"_NET_WM_STATE_FULLSCREEN"))
|
||||
for window in (self.root, self._check_window):
|
||||
x11.XChangeProperty(self.connection, window, self._atom(b"_NET_SUPPORTING_WM_CHECK"), _XA_WINDOW, 32, _PROP_MODE_REPLACE, ctypes.addressof(check), 1)
|
||||
x11.XChangeProperty(self.connection, self.root, self._atom(b"_NET_SUPPORTED"), _XA_ATOM, 32, _PROP_MODE_REPLACE, ctypes.addressof(fullscreen), 1)
|
||||
x11.XSync(self.connection, False)
|
||||
|
||||
def window_manager_check(self) -> Optional[int]:
|
||||
"""The checking window the root names (``_NET_SUPPORTING_WM_CHECK``), read back from the server, or None when the root names none."""
|
||||
kind, size, count, left, data = ctypes.c_ulong(), ctypes.c_int(), ctypes.c_ulong(), ctypes.c_ulong(), ctypes.c_void_p()
|
||||
status = self.x11.XGetWindowProperty(self.connection, self.root, self._atom(b"_NET_SUPPORTING_WM_CHECK"), 0, 1, False, _XA_WINDOW, ctypes.byref(kind),
|
||||
ctypes.byref(size), ctypes.byref(count), ctypes.byref(left), ctypes.byref(data))
|
||||
if status != 0 or not data.value or count.value != 1:
|
||||
return None
|
||||
try:
|
||||
return int(ctypes.c_long.from_address(data.value).value)
|
||||
finally:
|
||||
self.x11.XFree(data)
|
||||
|
||||
def stop_answering(self) -> None:
|
||||
"""The root as it was: no property, no checking window."""
|
||||
if self._check_window is None or self.connection is None:
|
||||
return
|
||||
for name in (b"_NET_SUPPORTED", b"_NET_SUPPORTING_WM_CHECK"):
|
||||
self.x11.XDeleteProperty(self.connection, self.root, self._atom(name))
|
||||
self.x11.XDestroyWindow(self.connection, self._check_window)
|
||||
self.x11.XSync(self.connection, False)
|
||||
self._check_window = None
|
||||
@@ -0,0 +1,18 @@
|
||||
# Source of the fixture of run 47107160488
|
||||
|
||||
- what: Linux, the A/B verdict (`diff.json`) of the host oracle in the candidate run
|
||||
- repository: oss-invisible/firefox_antidetect_patch
|
||||
- run: 47107160488
|
||||
|
||||
| fixture | origin file | sha256 of the origin file | sha256 of the fixture | bytes |
|
||||
|---|---|---|---|---|
|
||||
| diff-47107160488.json | diff.json | 571753a3327ea12be407bc19213a6b9dfdc482ecaf280bc493b7dad877bc08be (286470 bytes) | 286cd6c74c5d8c56776aa8ae3614b6617dc4bab913979af40a98daf5aa709ea5 | 286347 |
|
||||
|
||||
## Reduction
|
||||
|
||||
It is the same as for the fixtures of tests/data/ab_host_aa. Nothing else of the file changes.
|
||||
|
||||
- **Home folder.** The first folder under `/home/` becomes the same name under `/var/`, in every path, and the `user_root` of the file goes with it (`\home` becomes `\var`). The origin file holds no `/var/` path, so the folder is still found only through `user_root`, and the rows the script derives keep the same names.
|
||||
- **Public addresses.** These become addresses of 203.0.113.0/24, one to one and in numeric order, from `.1`. There are 4 of them, all in the warm-up `net` of the two sides, and no rule reads them.
|
||||
|
||||
The rows of `ci/ab-host-expected.json` are the output of `scripts/ci_ab_retail.py host-only` on this fixture, so their `diff_sha256` is the fixture's.
|
||||
File diff suppressed because it is too large.
Load diff
@@ -89,7 +89,7 @@
|
||||
"n": 5864
|
||||
},
|
||||
"dom.system_colors": {
|
||||
"s": "[[\"Canvas\",\"rgb(255, 255, 255)\"],[\"CanvasText\",\"rgb(0, 0, 0)\"],[\"ButtonFace\",\"rgb(233, 233, 237)\"],[\"ButtonText\",\"rgb(0, 0, 0)\"],[\"ButtonBorder\",\"rgb(129, 127, 132)\"],[\"Field\",\"rgb(255, 255, 255)\"],[\"FieldText\",\"rgb(0, 0, 0)\"],[\"Highlight\",\"rgb(0, 120, 215)\"],[\"HighlightText\",\"rgb(255, 255, 255)\"],[\"GrayText\",\"rgb(109, 109, 109)\"],[\"LinkText\",\"rgb(0, 0, 238)\"],[\"VisitedText\",\"rgb(85, 26, 139)\"],[\"ActiveText\",\"rgb(238, 0, 0)\"],[\"Mark\",\"rgb(255, 255, 0)\"],[\"MarkText\",\"rgb(0, 0, 0)\"],[\"AccentColor\",\"rgb(0, 96, 223)\"],[\"AccentColorText\",\"rgb(255, 255, 255)\"],[\"SelectedItem\",\"rgb(0, 120, 215)\"],[\"SelectedItemText\",\"rgb(255, 255, 255)\"]]"
|
||||
"s": "[[\"Canvas\",\"rgb(255, 255, 255)\"],[\"CanvasText\",\"rgb(0, 0, 0)\"],[\"ButtonFace\",\"rgb(233, 233, 237)\"],[\"ButtonText\",\"rgb(0, 0, 0)\"],[\"ButtonBorder\",\"rgb(129, 127, 132)\"],[\"Field\",\"rgb(255, 255, 255)\"],[\"FieldText\",\"rgb(0, 0, 0)\"],[\"Highlight\",\"rgb(0, 120, 212)\"],[\"HighlightText\",\"rgb(255, 255, 255)\"],[\"GrayText\",\"rgb(109, 109, 109)\"],[\"LinkText\",\"rgb(0, 0, 238)\"],[\"VisitedText\",\"rgb(85, 26, 139)\"],[\"ActiveText\",\"rgb(238, 0, 0)\"],[\"Mark\",\"rgb(255, 255, 0)\"],[\"MarkText\",\"rgb(0, 0, 0)\"],[\"AccentColor\",\"rgb(0, 96, 223)\"],[\"AccentColorText\",\"rgb(255, 255, 255)\"],[\"SelectedItem\",\"rgb(0, 120, 212)\"],[\"SelectedItemText\",\"rgb(255, 255, 255)\"]]"
|
||||
},
|
||||
"env.dpr": {
|
||||
"s": "1"
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
"n": 5863
|
||||
},
|
||||
"dom.system_colors": {
|
||||
"s": "[[\"Canvas\",\"rgb(255, 255, 255)\"],[\"CanvasText\",\"rgb(0, 0, 0)\"],[\"ButtonFace\",\"rgb(233, 233, 237)\"],[\"ButtonText\",\"rgb(0, 0, 0)\"],[\"ButtonBorder\",\"rgb(129, 127, 132)\"],[\"Field\",\"rgb(255, 255, 255)\"],[\"FieldText\",\"rgb(0, 0, 0)\"],[\"Highlight\",\"rgb(0, 120, 215)\"],[\"HighlightText\",\"rgb(255, 255, 255)\"],[\"GrayText\",\"rgb(109, 109, 109)\"],[\"LinkText\",\"rgb(0, 0, 238)\"],[\"VisitedText\",\"rgb(85, 26, 139)\"],[\"ActiveText\",\"rgb(238, 0, 0)\"],[\"Mark\",\"rgb(255, 255, 0)\"],[\"MarkText\",\"rgb(0, 0, 0)\"],[\"AccentColor\",\"rgb(0, 96, 223)\"],[\"AccentColorText\",\"rgb(255, 255, 255)\"],[\"SelectedItem\",\"rgb(0, 120, 215)\"],[\"SelectedItemText\",\"rgb(255, 255, 255)\"]]"
|
||||
"s": "[[\"Canvas\",\"rgb(255, 255, 255)\"],[\"CanvasText\",\"rgb(0, 0, 0)\"],[\"ButtonFace\",\"rgb(233, 233, 237)\"],[\"ButtonText\",\"rgb(0, 0, 0)\"],[\"ButtonBorder\",\"rgb(129, 127, 132)\"],[\"Field\",\"rgb(255, 255, 255)\"],[\"FieldText\",\"rgb(0, 0, 0)\"],[\"Highlight\",\"rgb(0, 120, 212)\"],[\"HighlightText\",\"rgb(255, 255, 255)\"],[\"GrayText\",\"rgb(109, 109, 109)\"],[\"LinkText\",\"rgb(0, 0, 238)\"],[\"VisitedText\",\"rgb(85, 26, 139)\"],[\"ActiveText\",\"rgb(238, 0, 0)\"],[\"Mark\",\"rgb(255, 255, 0)\"],[\"MarkText\",\"rgb(0, 0, 0)\"],[\"AccentColor\",\"rgb(0, 96, 223)\"],[\"AccentColorText\",\"rgb(255, 255, 255)\"],[\"SelectedItem\",\"rgb(0, 120, 212)\"],[\"SelectedItemText\",\"rgb(255, 255, 255)\"]]"
|
||||
},
|
||||
"env.dpr": {
|
||||
"s": "1"
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<title>password mask character, read as widths</title>
|
||||
<body style="margin:0;background:#fff">
|
||||
<script>
|
||||
"use strict";
|
||||
// Which character does an <input type=password> mask with? A page cannot read it, but it can read widths: the
|
||||
// scrollWidth of a password field holding N copies of "a" is N times the advance of the mask character in the field's
|
||||
// font. The same box styles hold N copies of each candidate character in a text input (scrollWidth) and in an inline span
|
||||
// (getBoundingClientRect). The mask character is the candidate whose width equals the password width.
|
||||
// Two fonts: Arial 16px, and the default font of an input (only the size is set). Also recorded: measureText of each
|
||||
// candidate in a canvas with the same font, devicePixelRatio, the computed font-family of the input, navigator.platform.
|
||||
const N = 40;
|
||||
const CANDS = [["U+25CF", "●"], ["U+2022", "•"], ["U+2731", "✱"], ["U+273A", "✺"], ["*", "*"]];
|
||||
const FONTS = [["arial16", "font-family:Arial;font-size:16px"], ["default16", "font-size:16px"]];
|
||||
const BOX = "box-sizing:content-box;margin:0;padding:0;border:0;width:20px;height:24px;outline:0;";
|
||||
const SPAN = "display:inline-block;white-space:pre;margin:0;padding:0;border:0;";
|
||||
|
||||
function input(type, value, font) {
|
||||
const el = document.createElement("input");
|
||||
el.type = type;
|
||||
el.value = value;
|
||||
el.setAttribute("style", BOX + font);
|
||||
document.body.appendChild(el);
|
||||
return el;
|
||||
}
|
||||
|
||||
function span(text, familyCss) {
|
||||
const el = document.createElement("span");
|
||||
el.textContent = text;
|
||||
el.setAttribute("style", SPAN + familyCss);
|
||||
document.body.appendChild(el);
|
||||
return el;
|
||||
}
|
||||
|
||||
function measureFont(fontCase, font) {
|
||||
const out = {};
|
||||
const pw = input("password", "a".repeat(N), font);
|
||||
const cs = getComputedStyle(pw);
|
||||
const family = cs.fontFamily;
|
||||
out.input_font_family = family;
|
||||
out.input_font_size = cs.fontSize;
|
||||
out.input_font = cs.font;
|
||||
const spanFont = "font-family:" + family + ";font-size:16px";
|
||||
// password widths with 1, 10 and N characters: per-character advance = (w[N] - w[10]) / (N - 10)
|
||||
out.password = {};
|
||||
for (const n of [1, 10, N]) {
|
||||
const e = input("password", "a".repeat(n), font);
|
||||
out.password[n] = {scrollWidth: e.scrollWidth, clientWidth: e.clientWidth};
|
||||
e.remove();
|
||||
}
|
||||
out.password[N].scrollWidth_main = pw.scrollWidth;
|
||||
out.password.per_char = (out.password[N].scrollWidth - out.password[10].scrollWidth) / (N - 10);
|
||||
out.refs = {};
|
||||
for (const [name, ch] of CANDS) {
|
||||
const r = {};
|
||||
r.text_input = {};
|
||||
for (const n of [1, 10, N]) {
|
||||
const e = input("text", ch.repeat(n), font);
|
||||
r.text_input[n] = {scrollWidth: e.scrollWidth};
|
||||
e.remove();
|
||||
}
|
||||
r.text_input.per_char = (r.text_input[N].scrollWidth - r.text_input[10].scrollWidth) / (N - 10);
|
||||
const sp = span(ch.repeat(N), spanFont);
|
||||
r.span_width = sp.getBoundingClientRect().width;
|
||||
r.span_width_1 = (() => { const s1 = span(ch, spanFont); const w = s1.getBoundingClientRect().width; s1.remove(); return w; })();
|
||||
sp.remove();
|
||||
const c = document.createElement("canvas").getContext("2d");
|
||||
c.font = (fontCase === "arial16" ? "16px Arial" : "16px " + family);
|
||||
r.canvas_measureText = c.measureText(ch).width;
|
||||
r.canvas_font = c.font;
|
||||
out.refs[name] = r;
|
||||
}
|
||||
const pwWidth = out.password[N].scrollWidth;
|
||||
out.verdict = {
|
||||
by_text_input_scrollWidth: CANDS.map(c => c[0]).filter(k => out.refs[k].text_input[N].scrollWidth === pwWidth),
|
||||
by_span_width: CANDS.map(c => c[0]).filter(k => Math.abs(out.refs[k].span_width - pwWidth) < 1),
|
||||
by_per_char: CANDS.map(c => c[0]).filter(k => out.refs[k].text_input.per_char === out.password.per_char),
|
||||
};
|
||||
pw.remove();
|
||||
return out;
|
||||
}
|
||||
|
||||
(async () => {
|
||||
let result;
|
||||
try {
|
||||
result = {format: "password-mask/1", n: N,
|
||||
env: {userAgent: navigator.userAgent, platform: navigator.platform, devicePixelRatio: window.devicePixelRatio,
|
||||
width: screen.width, height: screen.height},
|
||||
fonts: {}};
|
||||
for (const [fontCase, font] of FONTS) result.fonts[fontCase] = measureFont(fontCase, font);
|
||||
} catch (e) {
|
||||
result = {format: "password-mask/1", error: String(e && e.stack || e)};
|
||||
}
|
||||
window.__result = result;
|
||||
const label = location.search.slice(1) || "result";
|
||||
try { await fetch("/result?" + label, {method: "POST", body: JSON.stringify(result)}); } catch (e) { /* recorded in window.__result */ }
|
||||
document.title = "done";
|
||||
})();
|
||||
</script>
|
||||
@@ -581,10 +581,20 @@ def drive(browser, origin_a, origin_o, rounds=1, idle_timeout_ms=15000, trace=Fa
|
||||
page = context.new_page()
|
||||
records += run_round(Journey(context, page, origin_a, origin_o, hang_guard_ms), tracer, r, idle_timeout_ms, step_log)
|
||||
finally:
|
||||
# Every page of the site still open with its noise sends two requests from its pagehide as the context closes it (a beacon and a keep-alive
|
||||
# POST), and they reach the server after close() has returned. The walk returns when the server has them, so they are the requests of the
|
||||
# last step: with no wait one of them landed after the walk, in the lab's "end" (run 47209890618, Windows seed 2). An event, not a delay.
|
||||
try:
|
||||
leaving = 2 * sum(1 for p in context.pages if p.url.startswith((origin_a, origin_o)) and "noise=0" not in p.url)
|
||||
except Exception:
|
||||
leaving = 0
|
||||
before = pagehide_requests() if leaving else 0
|
||||
try:
|
||||
context.close()
|
||||
except Exception:
|
||||
pass
|
||||
leaving = 0
|
||||
if leaving:
|
||||
wait_for_pagehide_requests(before + leaving)
|
||||
return records
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
{"file": "test_a_granted_permission_is_the_one_the_page_asks_for_e2e.py", "scope": "<module>.READ", "rule": "js-timer", "nth": 1, "kind": "hang-detector", "reason": "The timer of 30 s only ends a read of the position that never answers: the answer is a position or an error as soon as the engine gives one, and no verdict reads when the timer fired."},
|
||||
{"file": "test_a_held_ice_port_blinds_the_loopback_checks_e2e.py", "scope": "<module>._START_JS", "rule": "js-timer", "nth": 1, "kind": "hang-detector", "reason": "The 5 ms step of the page's two waits, each with a deadline of 30 s: for the host UDP candidate of the first connection, and for the data channel to open and echo; the second loop keeps the longest time it did not run, so the time the connection took is judged only when the page itself was not stopped by the machine (`_e2e_verdicts.opened_at_the_retry_problem`)."},
|
||||
{"file": "test_a_page_cannot_probe_the_juggler_e2e.py", "scope": "<module>._CHANNELS", "rule": "js-timer", "nth": 1, "kind": "hang-detector", "reason": "The 30 s of each channel are the deadline of its wait (`no answer` is a channel that stays silent). Every channel of a URL is asked at once and a name that is nowhere answers all of them, so on a healthy run no silence is waited for, and a stall of the machine cannot make one URL answer and the other not."},
|
||||
{"file": "test_a_page_function_called_by_the_client_sees_only_page_frames_e2e.py", "scope": "test_a_timer_callback_the_client_started_has_only_its_own_frame_and_no_caller", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "The timer the client's evaluate starts is the subject of the test (the stack and the caller of its callback are what it asserts); the test waits for the callback to have run with a deadline of 30 s, and no verdict reads when the timer fired."},
|
||||
{"file": "test_a_page_over_ipv6_gathers_on_a_machine_declared_without_it_e2e.py", "scope": "<module>._GATHER_JS", "rule": "js-timer", "nth": 1, "kind": "hang-detector", "reason": "The timer of 30 s is the deadline of the wait for the end of the ICE gathering: the wait ends when the page says `complete`, a gathering that never completes returns what it has and fails the assertions on the candidates, and no verdict reads when the timer fired."},
|
||||
{"file": "test_a_page_that_moves_on_e2e.py", "scope": "_replace_after_load", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "The page's own timer moves the page 0, 50 or 300 ms after the load, and the reads made while it moves accept both states (the page before the move or the page it moved to) and never an engine error; nothing reads when the timer fired, and the waits that lead up to the reads have a deadline of 30 s."},
|
||||
{"file": "test_a_page_that_moves_on_e2e.py", "scope": "test_reads_wait_as_playwright_s_do", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "The page's own timer adds the element 500 ms after the call; the read waits for it with a deadline of 30 s, and the verdict is the text read, never when the timer fired."},
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
"""A click on the password field of a login form, with the login autocomplete list open over it, reaches the page: the page hears the click and no tab opens, as with stock Firefox and Playwright.
|
||||
|
||||
Firefox opens the autocomplete list (``#PopupAutoComplete``, a panel of the browser's own UI) by itself when a login field takes the focus. On a form whose first row is the insecure-login warning
|
||||
(the form's action is an ``http`` address that is not local, so the form is not secure whatever the page is) the list opens under ``#user`` and covers the field below it. Stock Playwright sends a press
|
||||
to the page through such a panel, as through the password doorhanger, so the page hears the whole click on ``#pass`` and the focus goes to it. An engine whose door sent the press to the popup
|
||||
widget put it on the warning row, which opens a tab of the support site: the page heard nothing, and a page appeared.
|
||||
|
||||
Per scale (1, 1.25 and 1.5), the client's own mouse: a click on ``#user`` (the list must be open, read from the chrome: without it the case would pass for nothing), then a click on ``#pass``. The page records
|
||||
``pointerdown``, ``mousedown``, ``pointerup``, ``mouseup`` and ``click`` in the capture phase. The test waits (a condition with a deadline) until the page has heard the click on ``#pass`` and the focus is
|
||||
there, and then watches the number of pages of the context for one second (``observe``): it must stay what it was.
|
||||
|
||||
Needs ``MOZ_REMOTE_ALLOW_SYSTEM_ACCESS=1`` for the chrome reads. Red on an engine whose door lets the autocomplete list take part in the input path: the page hears nothing of the click on ``#pass`` and a page
|
||||
opens.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
from typing import Any, Iterator, List, Tuple
|
||||
|
||||
import pytest
|
||||
from _fission_frames import Sites
|
||||
from _stock_twin import MARIONETTE_ARGS, BrokenControl, Chrome
|
||||
from _window_origin import CASES, DEADLINE_S, launch_case, observe, wait_for
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
#: The display scales of the cases: 1, 1.25 and 1.5.
|
||||
SCALES = sorted(case for case, (scale, _panel) in CASES.items() if scale <= 1.5)
|
||||
#: How long the number of pages is watched once the page has heard the click.
|
||||
WATCH_S = 1.0
|
||||
|
||||
#: The two fields, one under the other (CSS pixels of the viewport): ``#user`` at (20, 20, 200 x 30), ``#pass`` at (20, 60, 200 x 30). The list opens under ``#user`` and covers ``#pass``.
|
||||
USER_CENTRE = (120, 35)
|
||||
PASS_CENTRE = (120, 75)
|
||||
#: What the page hears on ``#pass``, in the order of a click.
|
||||
PASS_CLICK = [["pointerdown", "pass"], ["mousedown", "pass"], ["pointerup", "pass"], ["mouseup", "pass"], ["click", "pass"]]
|
||||
|
||||
#: The login form. Its action is an ``http`` address that is not local and is never visited (nothing submits it): it makes the form insecure, so the list that opens on ``#user`` holds the warning row.
|
||||
PAGE = """<!doctype html><meta charset=utf-8><title>login</title>
|
||||
<style>html,body{margin:0;padding:0;height:100%}input{position:absolute;left:20px;width:200px;height:30px;box-sizing:border-box}#user{top:20px}#pass{top:60px}</style>
|
||||
<body><form method=post action="http://login-target.example/signin">
|
||||
<input id=user name=user type=text><input id=pass name=password type=password></form>
|
||||
<script>
|
||||
window.__events = [];
|
||||
for (const type of ['pointerdown', 'mousedown', 'pointerup', 'mouseup', 'click'])
|
||||
window.addEventListener(type, e => window.__events.push([e.type, e.target.id || e.target.nodeName.toLowerCase()]), true);
|
||||
window.__read = () => ({events: window.__events.slice(), active: document.activeElement && document.activeElement.id});
|
||||
window.__reset = () => { window.__events.length = 0; };
|
||||
</script>"""
|
||||
|
||||
#: The prefs of the launch. ``-marionette`` applies Marionette's recommended preferences, which set ``signon.rememberSignons`` to false on the default branch, and a real user's Firefox has it true (the default):
|
||||
#: the user branch, which wins over the default one, gets it back, so the login manager marks the field and the list opens.
|
||||
EXTRA_PREFS = {"marionette.port": 0, "signon.rememberSignons": True}
|
||||
|
||||
#: The state of the autocomplete list, read in the chrome (``absent`` where the element is not there).
|
||||
STATE_JS = """
|
||||
const win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
const popup = win.document.getElementById("PopupAutoComplete");
|
||||
return JSON.stringify({autocomplete: popup && typeof popup.state === "string" ? popup.state : "absent"});
|
||||
"""
|
||||
#: The pref that lets the login manager mark a field as autocompletable (``LoginHelper.enabled``).
|
||||
PREF_JS = """
|
||||
return JSON.stringify({rememberSignons: Services.prefs.getBoolPref("signon.rememberSignons", null)});
|
||||
"""
|
||||
#: Closes the list, so the page closes clean.
|
||||
HIDE_JS = """
|
||||
const win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
const popup = win.document.getElementById("PopupAutoComplete");
|
||||
if (popup && typeof popup.hidePopup === "function" && popup.state !== "closed") popup.hidePopup();
|
||||
return JSON.stringify({});
|
||||
"""
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def _session(firefox_binary: str, monkeypatch, case: str) -> Iterator[Tuple[Any, Any, Chrome, Sites]]:
|
||||
"""Our browser on ``case`` with the login page served: ``(page, context, chrome, sites)``. The first page is kept open (the window the chrome session waits for)."""
|
||||
monkeypatch.setenv("MOZ_REMOTE_ALLOW_SYSTEM_ACCESS", "1") # the chrome-scope reads
|
||||
with Sites() as sites, launch_case(firefox_binary, case, extra_args=MARIONETTE_ARGS, extra_prefs=EXTRA_PREFS) as browser:
|
||||
sites.route("A", "/login", PAGE)
|
||||
holder = browser.new_page()
|
||||
chrome = Chrome(holder)
|
||||
page = browser.new_page()
|
||||
try:
|
||||
page.goto(sites.url("A", "/login"))
|
||||
yield page, page.context, chrome, sites
|
||||
finally:
|
||||
chrome.script(HIDE_JS)
|
||||
chrome.close()
|
||||
|
||||
|
||||
def _list_state(chrome: Chrome) -> str:
|
||||
return chrome.script(STATE_JS)["autocomplete"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("case", SCALES)
|
||||
def test_a_click_on_the_password_field_under_the_login_list_reaches_the_page(firefox_binary, monkeypatch, case):
|
||||
with _session(firefox_binary, monkeypatch, case) as (page, context, chrome, _sites):
|
||||
page.mouse.click(*USER_CENTRE)
|
||||
opened = wait_for(page, lambda: _list_state(chrome) == "open", DEADLINE_S)
|
||||
if not opened:
|
||||
raise BrokenControl("BROKEN CONTROL, no finding about ours: a click on #user did not open the login autocomplete list (state %r, signon.rememberSignons %r): the case would pass for nothing"
|
||||
% (_list_state(chrome), chrome.script(PREF_JS)["rememberSignons"]))
|
||||
# The release of the first click is heard by the page after the click returned: wait for it, then start from an empty record.
|
||||
assert wait_for(page, lambda: ["click", "user"] in page.evaluate("() => window.__read()")["events"], DEADLINE_S), "the page never heard the click on #user"
|
||||
page.evaluate("() => window.__reset()")
|
||||
pages_before = len(context.pages)
|
||||
if _list_state(chrome) != "open":
|
||||
raise BrokenControl("BROKEN CONTROL, no finding about ours: the login autocomplete list is not open right before the press on #pass (state %r, signon.rememberSignons %r)"
|
||||
% (_list_state(chrome), chrome.script(PREF_JS)["rememberSignons"]))
|
||||
|
||||
page.mouse.click(*PASS_CENTRE)
|
||||
|
||||
def heard() -> bool:
|
||||
reading = page.evaluate("() => window.__read()")
|
||||
return reading["events"] == PASS_CLICK and reading["active"] == "pass"
|
||||
|
||||
arrived = wait_for(page, heard, DEADLINE_S)
|
||||
reading = page.evaluate("() => window.__read()")
|
||||
assert arrived, ("the page did not hear the whole click on #pass with the focus on it (waited %s s; the list was %r): it heard %r, the active element is %r"
|
||||
% (DEADLINE_S, _list_state(chrome), reading["events"], reading["active"]))
|
||||
counts: List[int] = observe(page, lambda: len(context.pages), WATCH_S)
|
||||
assert counts == [pages_before], "a click on #pass opened a page (the pages of the context over %s s: %r, before it %d)" % (WATCH_S, counts, pages_before)
|
||||
@@ -263,8 +263,8 @@ def test_ours_gets_the_answer_of_its_session_in_a_retail_twin(world, monkeypatch
|
||||
def __exit__(self, *exc):
|
||||
return False
|
||||
|
||||
def set_window_size(self, outer):
|
||||
return {"outer": [800, 600], "inner": [790, 500]}
|
||||
def set_inner_size(self, inner):
|
||||
return {"outer": [800, 600], "inner": [790, 500], "asked_outer": [800, 600]}
|
||||
|
||||
monkeypatch.setattr(_retail_reference, "retail_executable", lambda: "retail")
|
||||
monkeypatch.setattr(_retail_reference, "RetailSession", FakeRetail)
|
||||
|
||||
@@ -0,0 +1,406 @@
|
||||
"""A page function that the client's call reaches sees only the page's own frames: no eval code, no debugger code, no function of the client.
|
||||
|
||||
A page can read `new Error().stack` and `fn.caller` inside any function of its own. When the client runs `page.evaluate("() => probe()")` the page function is called by
|
||||
a function the automation compiled, and a page that looks sees it: an `eval code` / `debugger eval code` line below its own frame and a `probe.caller` that is the
|
||||
client's function. Retail Firefox, where the page is called by an extension content script or by the browser itself, shows page frames only and `caller` is null
|
||||
(a function called from native code or from privileged code has no content caller).
|
||||
|
||||
Ten cases, each says what it saw in its message:
|
||||
1. `page.evaluate("() => probe()")`: every line of the stack names the page's script (`name@URL:line:col`), the first one is `probe`, and `probe.caller` is null;
|
||||
2. `page.evaluate("() => a()")` with `a` calling `b` calling `probe`: exactly three lines, `probe`, `b`, `a`, in this order, and nothing else (`probe.caller` is the page's own `b`);
|
||||
3. `page.evaluate("() => { setTimeout(probe2, 0) }")`: the stack of the timer callback is read later from `window.__timer`: one page frame, `probe2`, and a null caller;
|
||||
4. a click listener of the page records its stack and `arguments.callee.caller`, the client does `page.click('#btn')`: the listener is the only frame and the caller is null;
|
||||
5. `page.evaluate("() => { throw new Error('x') }")` still raises in the client, with the message;
|
||||
6. the atoms (`Page.elementAtom`, `isElementDisplayed` and `getVisibleText`, sent raw: no client call reaches them) run in the engine's own sandbox over Xrays: the page wrapped
|
||||
`getClientRects`, `getBoundingClientRect`, `checkVisibility`, `getComputedStyle`, the `innerText` and `textContent` getters, and each wrapper was either never called (the
|
||||
expectation, through Xrays) or, if called, saw only page frames and a null caller;
|
||||
7. a `securitypolicyviolation` the client's evaluate causes (an image under `img-src 'none'`) reports a `sourceFile` that is not a location of the client's world;
|
||||
8. an uncaught error thrown by a listener the client's evaluate registered, triggered by the page itself (its own listener, run when the test clicks a trigger button): the listener ran exactly once (a marker it
|
||||
sets on the page's DOM) and `window.onerror` was never called for it, as Mozilla does not report an exception of a sandbox-world listener to the page's window (see below);
|
||||
9. the same as 8 with `throw 5` (not an Error);
|
||||
10. `import()` called by the client's evaluate asks the server for the module like the page's own `import()` of an inline script does: the same path base and the same Referer, none of them a
|
||||
location of the client's world (the server records the path and the Referer of every request of the module).
|
||||
Cases 7 to 10 each have a control that the page makes itself (a violation, a throwing listener), which must name the page's own script: it proves the page's record works.
|
||||
What stock gives for 7 and 10 is not known from a measurement (no browser runs here): the expectation asserted is the one that holds on any engine that hides its world, "not a
|
||||
location of the world", and the message says what was seen, so a first run shows the stock value.
|
||||
|
||||
WHAT MOZILLA DOES FOR 8 AND 9, from its code (unchanged from the Firefox 159 tag): the error of a listener whose function lives in a sandbox (the world of the client's evaluate) is never dispatched to
|
||||
the page's `window.onerror`. `CallSetup::~CallSetup` (dom/bindings/CallbackObject.cpp:439-443) reports the pending exception on the context; `AutoJSAPI::ReportException`
|
||||
(dom/script/ScriptSettings.cpp:521-541) takes `inner = xpc::WindowOrNull(errorGlobal)`, which is null for a sandbox global, and its own comment says a window found only through `SandboxWindowOrNull` serves
|
||||
the `innerWindowID` alone ("we don't want to dispatch exceptions caused by the content script to the webpage"); `DispatchScriptErrorEvent` runs only `if (inner ...)`. The global of the call is the sandbox's,
|
||||
not the window (`CallSetup::GetActiveGlobalObjectForCall`, dom/bindings/CallbackObject.cpp:195-214). So the cases assert what Mozilla does: the listener ran once and onerror was not called, with the page's
|
||||
own throwing listener as the control that onerror is alive (and, once more after the marker, as the barrier: the report of the evaluate's listener is made in the same task as its marker, so it would be in
|
||||
the list before the barrier's). Our dump of candidate 46941424205 (evidence sandbox-listener-onerror): the marked listener ran count=1, heard=False after 30 s; the page's control heard.
|
||||
|
||||
WHAT STOCK GIVES, and how it is derived (nothing was measured here: no browser runs on this machine). In Firefox the stack of an `Error` is the chain of JS frames of the
|
||||
current JS stack that the reader may see, and `Function.prototype.caller` is the JS function below on that same stack, null when the one below is native or privileged.
|
||||
A timer callback (case 3) and an event listener of a trusted event (case 4) are called by the event loop and by the event dispatch, which are native: the listener or the
|
||||
callback is the BOTTOM of the JS stack, so one line and a null caller. Playwright's own click on stock Firefox is a protocol `Input.dispatchMouseEvent`, which reaches the
|
||||
page as a native event and runs no function of the page's world, so the listener is alone. A page function called by the client's `evaluate` (cases 1 and 2) is the bottom of
|
||||
the page's chain when the call comes from privileged code: stock's evaluate runs the function in the page's world through the browser's own call, so `probe` is the bottom of
|
||||
the stack in case 1 and `a` in case 2. The two readings that differ from these are exactly what the cases catch: an extra line that is not the script of the page, or a caller.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
import threading
|
||||
from http.server import BaseHTTPRequestHandler
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
|
||||
from _servers import LocalServer
|
||||
from _waits import wait_until
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
#: Far beyond what a healthy run needs; it is the only clock the verdict depends on.
|
||||
DEADLINE = 30.0
|
||||
|
||||
PAGE = b"""<!doctype html><title>frames</title><button id="btn">go</button><script src="/page.js"></script>"""
|
||||
|
||||
SCRIPT = b"""function probe() {
|
||||
return {stack: new Error().stack,
|
||||
caller: probe.caller === null ? null : typeof probe.caller,
|
||||
callerSrc: probe.caller ? String(probe.caller).slice(0, 80) : null};
|
||||
}
|
||||
function a() { return b(); }
|
||||
function b() { return probe(); }
|
||||
function probe2() {
|
||||
window.__timer = {stack: new Error().stack, caller: probe2.caller === null ? null : typeof probe2.caller};
|
||||
}
|
||||
document.getElementById('btn').addEventListener('click', function listener() {
|
||||
var caller = arguments.callee.caller;
|
||||
window.__click = {stack: new Error().stack, caller: caller === null ? null : typeof caller};
|
||||
});
|
||||
"""
|
||||
|
||||
#: The page of the atoms: a visible element and a hidden one, and a script that wraps what the atoms (Marionette's `isElementDisplayed` and `getVisibleText`) could read
|
||||
#: of the page's elements: the methods `getClientRects`, `getBoundingClientRect`, `checkVisibility` of Element, `getComputedStyle` of the window, and the getters
|
||||
#: `innerText` of HTMLElement and `textContent` of Node. Each wrapper counts the call and records `new Error().stack` and the type of its own `caller`; the page calls
|
||||
#: each one once itself at load (the control: a count of 1 proves the wrapper runs when something calls it).
|
||||
ATOMS_PAGE = b"""<!doctype html><title>atoms</title><p id="shown">hello visible world</p><p id="none" style="display:none">secret</p><script src="/atoms.js"></script>"""
|
||||
|
||||
ATOMS_SCRIPT = b"""window.__calls = {}; window.__seen = {}; window.__wrapped = [];
|
||||
function record(key, stack, caller) {
|
||||
window.__calls[key] = (window.__calls[key] || 0) + 1;
|
||||
(window.__seen[key] = window.__seen[key] || []).push({stack: stack, caller: caller});
|
||||
}
|
||||
function wrapMethod(owner, name) {
|
||||
if (typeof owner[name] !== 'function') return;
|
||||
var orig = owner[name];
|
||||
var w = function w() { record(name, new Error().stack, w.caller === null ? null : typeof w.caller); return orig.apply(this, arguments); };
|
||||
Object.defineProperty(owner, name, {value: w, writable: true, configurable: true});
|
||||
window.__wrapped.push(name);
|
||||
}
|
||||
function wrapGetter(owner, name) {
|
||||
var d = Object.getOwnPropertyDescriptor(owner, name);
|
||||
if (!d || !d.get) return;
|
||||
var g = function g() { record(name, new Error().stack, g.caller === null ? null : typeof g.caller); return d.get.call(this); };
|
||||
Object.defineProperty(owner, name, {get: g, set: d.set, configurable: true});
|
||||
window.__wrapped.push(name);
|
||||
}
|
||||
wrapMethod(Element.prototype, 'getClientRects');
|
||||
wrapMethod(Element.prototype, 'getBoundingClientRect');
|
||||
wrapMethod(Element.prototype, 'checkVisibility');
|
||||
wrapMethod(window, 'getComputedStyle');
|
||||
wrapGetter(HTMLElement.prototype, 'innerText');
|
||||
wrapGetter(Node.prototype, 'textContent');
|
||||
window.__reset = function () { window.__calls = {}; window.__seen = {}; };
|
||||
var el = document.getElementById('shown');
|
||||
el.getClientRects(); el.getBoundingClientRect(); if (el.checkVisibility) el.checkVisibility();
|
||||
getComputedStyle(el); void el.innerText; void el.textContent;
|
||||
"""
|
||||
|
||||
#: Case 7: a page under `img-src 'none'` that records every `securitypolicyviolation` (file, line, column, what was blocked); the page causes one itself at load (the control).
|
||||
CSP_PAGE = b"""<!doctype html><title>csp</title><body><script src="/csp.js"></script>"""
|
||||
CSP_SCRIPT = b"""window.__violations = [];
|
||||
document.addEventListener('securitypolicyviolation', function (e) {
|
||||
window.__violations.push({file: e.sourceFile, line: e.lineNumber, column: e.columnNumber, blocked: e.blockedURI});
|
||||
});
|
||||
var img = document.createElement('img'); img.src = '/by-the-page.png'; document.body.appendChild(img);
|
||||
"""
|
||||
|
||||
#: Cases 8 and 9: a page whose `window.onerror` records every call it gets (`__oes`); a listener of the page on #c (and #d) that counts itself in `__ctl` and throws (the control, then the barrier), a button #b for the client's listener, and
|
||||
#: `fire`, which the page itself runs when the test clicks a trigger button (#go-b, #go-c, #go-d): the page's own listener of the trigger clicks the target.
|
||||
OE_PAGE = b"""<!doctype html><title>oe</title><button id="b">b</button><button id="c">c</button><button id="d">d</button><button id="go-b">go-b</button><button id="go-c">go-c</button><button id="go-d">go-d</button><script src="/oe.js"></script>"""
|
||||
OE_SCRIPT = b"""window.__oes = [];
|
||||
window.__ctl = 0;
|
||||
window.onerror = function (msg, file, line, col, err) { window.__oes.push({msg: String(msg), file: file, line: line, col: col, stack: err && err.stack}); };
|
||||
document.getElementById('c').addEventListener('click', function () { window.__ctl++; throw new Error('page-made'); });
|
||||
document.getElementById('d').addEventListener('click', function () { window.__ctl++; throw 5; });
|
||||
function fire(id) { document.getElementById(id).click(); }
|
||||
['b', 'c', 'd'].forEach(function (id) { document.getElementById('go-' + id).addEventListener('click', function () { fire(id); }); });
|
||||
"""
|
||||
|
||||
#: What identifies the client's world in anything a page reads: the code of an evaluate, the debugger's code, the engine's own URLs.
|
||||
WORLD_MARKERS = ("debugger eval", "eval code", "eval", "chrome://", "resource://", "moz-extension://", "juggler", "about:", "createElement('img')", "=>")
|
||||
|
||||
|
||||
def _world_marks(text):
|
||||
return [m for m in WORLD_MARKERS if m in (text or "")]
|
||||
|
||||
#: Case 10: a page whose own inline script imports a module at load (the control); the server records the path and the Referer of every request of `/mod.js`.
|
||||
#: The control is an INLINE classic script of the document: a dynamic import() takes its referrer and base from the script that runs it, so the inline one has the document's URL
|
||||
#: as the evaluate's import has. `/imp.js` makes a second import (`from=file`), informational only: its referrer is the script file, and nothing is compared with it.
|
||||
IMP_PAGE = b"""<!doctype html><title>imp</title><script>window.__imported = import('/mod.js?from=page').then(function (m) { return m.default; });</script><script src="/imp.js"></script>"""
|
||||
IMP_SCRIPT = b"""window.__file = import('/mod.js?from=file').then(function (m) { return m.default; });"""
|
||||
MOD_SCRIPT = b"export default 1;"
|
||||
|
||||
|
||||
class _Handler(BaseHTTPRequestHandler):
|
||||
def log_message(self, *a):
|
||||
pass
|
||||
|
||||
def do_GET(self):
|
||||
path = self.path.split("?", 1)[0]
|
||||
if path == "/mod.js":
|
||||
self.server.requests.append((self.path, self.headers.get("Referer")))
|
||||
body, kind = {
|
||||
"/imp": (IMP_PAGE, "text/html; charset=utf-8"),
|
||||
"/imp.js": (IMP_SCRIPT, "application/javascript"),
|
||||
"/mod.js": (MOD_SCRIPT, "application/javascript"),
|
||||
"/csp": (CSP_PAGE, "text/html; charset=utf-8"),
|
||||
"/csp.js": (CSP_SCRIPT, "application/javascript"),
|
||||
"/oe": (OE_PAGE, "text/html; charset=utf-8"),
|
||||
"/oe.js": (OE_SCRIPT, "application/javascript"),
|
||||
"/page.js": (SCRIPT, "application/javascript"),
|
||||
"/atoms": (ATOMS_PAGE, "text/html; charset=utf-8"),
|
||||
"/atoms.js": (ATOMS_SCRIPT, "application/javascript"),
|
||||
}.get(path, (PAGE, "text/html; charset=utf-8"))
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", kind)
|
||||
self.send_header("Content-Length", str(len(body)))
|
||||
self.send_header("Cache-Control", "no-store")
|
||||
if path == "/csp":
|
||||
self.send_header("Content-Security-Policy", "img-src 'none'")
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def site():
|
||||
srv = LocalServer(("127.0.0.1", 0), _Handler)
|
||||
srv.requests = []
|
||||
threading.Thread(target=srv.serve_forever, daemon=True).start()
|
||||
try:
|
||||
yield SimpleNamespace(url="http://127.0.0.1:%d/" % srv.server_address[1], requests=srv.requests)
|
||||
finally:
|
||||
srv.shutdown()
|
||||
srv.server_close()
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def invisible(firefox_binary):
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
with InvisiblePlaywright(seed=4275, binary_path=firefox_binary, headless=True) as b:
|
||||
yield b
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def page(invisible, site):
|
||||
context = invisible.new_context()
|
||||
page = context.new_page()
|
||||
page.goto(site.url, wait_until="load")
|
||||
try:
|
||||
yield page
|
||||
finally:
|
||||
context.close()
|
||||
|
||||
|
||||
def _frames(stack):
|
||||
return [line for line in stack.splitlines() if line.strip()]
|
||||
|
||||
|
||||
def _names(stack, site):
|
||||
"""The function names of a stack whose every line is `name@<script of the page>:line:col`; a line that is anything else comes back as itself, so the assertion shows it."""
|
||||
pattern = re.compile(r"([^@\s]*)@" + re.escape(site.url + "page.js") + r":\d+:\d+")
|
||||
names = []
|
||||
for line in _frames(stack):
|
||||
found = pattern.fullmatch(line)
|
||||
names.append(found.group(1) if found else "NOT A FRAME OF THE PAGE'S SCRIPT: %r" % line)
|
||||
return names
|
||||
|
||||
|
||||
def test_a_function_called_by_evaluate_sees_only_its_own_frame_and_no_caller(page, site):
|
||||
seen = page.evaluate("() => probe()")
|
||||
assert _names(seen["stack"], site) == ["probe"], "the page's function called by evaluate saw this stack: %r" % seen["stack"]
|
||||
assert seen["caller"] is None, "the page's function called by evaluate saw a caller of type %r: %r" % (seen["caller"], seen["callerSrc"])
|
||||
|
||||
|
||||
def test_a_chain_of_page_functions_called_by_evaluate_shows_exactly_the_three_page_frames(page, site):
|
||||
seen = page.evaluate("() => a()")
|
||||
assert _names(seen["stack"], site) == ["probe", "b", "a"], "the chain a, b, probe called by evaluate saw this stack: %r" % seen["stack"]
|
||||
assert seen["caller"] == "function" and (seen["callerSrc"] or "").startswith("function b"), (
|
||||
"probe.caller in the chain was %r, %r (expected the page's own b)" % (seen["caller"], seen["callerSrc"]))
|
||||
|
||||
|
||||
def test_a_timer_callback_the_client_started_has_only_its_own_frame_and_no_caller(page, site):
|
||||
page.evaluate("() => { setTimeout(probe2, 0); }")
|
||||
# The client is a sync one: events are delivered while it calls the browser, so the wait is a call.
|
||||
seen = {}
|
||||
|
||||
def read():
|
||||
seen["timer"] = page.evaluate("() => window.__timer || null")
|
||||
return seen["timer"]
|
||||
|
||||
assert wait_until(read, DEADLINE, lambda: page.wait_for_timeout(50)), "the timer callback of the page never ran (after %.0f s)" % DEADLINE
|
||||
timer = seen["timer"]
|
||||
assert _names(timer["stack"], site) == ["probe2"], "the timer callback saw this stack: %r" % timer["stack"]
|
||||
assert timer["caller"] is None, "the timer callback saw a caller of type %r" % timer["caller"]
|
||||
|
||||
|
||||
def test_a_click_listener_of_the_page_has_only_its_own_frame_and_no_caller_when_the_client_clicks(page, site):
|
||||
page.click("#btn")
|
||||
seen = {}
|
||||
|
||||
def read():
|
||||
seen["click"] = page.evaluate("() => window.__click || null")
|
||||
return seen["click"]
|
||||
|
||||
assert wait_until(read, DEADLINE, lambda: page.wait_for_timeout(50)), "the click listener of the page never ran (after %.0f s)" % DEADLINE
|
||||
click = seen["click"]
|
||||
assert _names(click["stack"], site) == ["listener"], "the click listener saw this stack: %r" % click["stack"]
|
||||
assert click["caller"] is None, "the click listener saw a caller of type %r" % click["caller"]
|
||||
|
||||
|
||||
def test_an_error_thrown_by_an_evaluate_still_reaches_the_client_with_its_message(page):
|
||||
from invisible_playwright.sync_api import Error
|
||||
|
||||
with pytest.raises(Error) as raised:
|
||||
page.evaluate("() => { throw new Error('x') }")
|
||||
assert "x" in str(raised.value), "the client raised %r for a thrown Error('x'): the message is lost" % str(raised.value)
|
||||
|
||||
|
||||
def _raw_atom(page, handle, atom):
|
||||
"""What `Page.elementAtom` answers for the element of `handle`, sent on the in-process connection of the page's session as tests/test_page_element_atoms_run_in_a_sandbox_e2e.py does."""
|
||||
impl = handle._impl_obj
|
||||
server = impl._connection._transport._server
|
||||
element = server.object(impl._guid)
|
||||
injected = server.object(page._impl_obj._guid).injected
|
||||
return injected.c.send(
|
||||
"Page.elementAtom",
|
||||
{"frameId": element.frame.frame_id, "objectId": element.object_id, "atom": atom},
|
||||
session=injected.session, timeout=None)["result"]
|
||||
|
||||
|
||||
def test_the_atoms_call_nothing_of_the_page_or_are_seen_with_page_frames_only(invisible, site):
|
||||
context = invisible.new_context()
|
||||
try:
|
||||
page = context.new_page()
|
||||
page.goto(site.url + "atoms", wait_until="load")
|
||||
handles = [page.query_selector("#shown"), page.query_selector("#none")]
|
||||
control = page.evaluate("() => ({calls: {...window.__calls}, wrapped: window.__wrapped})")
|
||||
wrong = {key: control["calls"].get(key) for key in control["wrapped"] if control["calls"].get(key) != 1}
|
||||
assert control["wrapped"] and not wrong, "the page's own call of each wrapper did not count 1 (the wrappers do not work as the test needs): %r of %r" % (wrong, control["wrapped"])
|
||||
page.evaluate("() => window.__reset()")
|
||||
|
||||
for handle in handles:
|
||||
for atom in ("isElementDisplayed", "getVisibleText"):
|
||||
_raw_atom(page, handle, atom)
|
||||
after = page.evaluate("() => ({calls: window.__calls, seen: window.__seen})")
|
||||
finally:
|
||||
context.close()
|
||||
|
||||
pattern = re.compile(r"[^@\s]*@" + re.escape(site.url + "atoms.js") + r":\d+:\d+")
|
||||
bad = []
|
||||
for key, entries in after["seen"].items():
|
||||
for entry in entries:
|
||||
lines = _frames(entry["stack"])
|
||||
if not lines or not all(pattern.fullmatch(line) for line in lines) or entry["caller"] is not None:
|
||||
bad.append("%s: stack %r, caller %r" % (key, entry["stack"], entry["caller"]))
|
||||
assert not bad, "the atoms called %r of the page's wrappers (call counts), and these calls saw more than page frames or a caller: %s" % (after["calls"], "; ".join(bad))
|
||||
|
||||
|
||||
def test_a_violation_the_clients_evaluate_causes_does_not_name_a_location_of_the_clients_world(invisible, site):
|
||||
context = invisible.new_context()
|
||||
try:
|
||||
page = context.new_page()
|
||||
page.goto(site.url + "csp", wait_until="load")
|
||||
|
||||
def violations():
|
||||
return page.evaluate("() => window.__violations.slice()")
|
||||
|
||||
assert wait_until(lambda: len(violations()) >= 1, DEADLINE, lambda: page.wait_for_timeout(50)), (
|
||||
"the violation the page itself causes was never recorded (after %.0f s)" % DEADLINE)
|
||||
control = violations()[0]
|
||||
assert control["file"].endswith("/csp.js"), "the control (a violation caused by the page's own script) reported the file %r, not the page's script" % control["file"]
|
||||
page.evaluate("() => { const i = document.createElement('img'); i.src = '/by-evaluate.png'; document.body.appendChild(i); }")
|
||||
assert wait_until(lambda: len(violations()) >= 2, DEADLINE, lambda: page.wait_for_timeout(50)), (
|
||||
"the violation the client's evaluate causes was never recorded (after %.0f s): %r" % (DEADLINE, violations()))
|
||||
seen = violations()[1]
|
||||
finally:
|
||||
context.close()
|
||||
assert "by-evaluate" in seen["blocked"], "the second violation was not the evaluate's: %r" % seen
|
||||
marks = _world_marks(seen["file"])
|
||||
assert not marks, "the violation caused by the client's evaluate reported sourceFile %r (line %r, column %r), which names the client's world (%r)" % (
|
||||
seen["file"], seen["line"], seen["column"], marks)
|
||||
|
||||
|
||||
def _a_listener_of_the_clients_evaluate_runs_once_and_is_never_reported_to_onerror(invisible, site, control, listener):
|
||||
"""Cases 8 and 9. `control` is the id of the page's own throwing button (c or d), `listener` the source of the client's listener (it throws).
|
||||
|
||||
The order of events, none of them a duration: the control (the page's own listener throws, onerror hears it: the record is alive); the client's listener is registered and the page clicks it; the test
|
||||
waits for the MARKER the listener sets on the DOM (it ran); the report of its exception, if any, is made in the same task as the marker, so onerror's list is complete when the marker is read; the barrier
|
||||
(the page's own throwing listener once more, awaited by its counter) proves the record still works and that nothing came before it.
|
||||
"""
|
||||
context = invisible.new_context()
|
||||
try:
|
||||
page = context.new_page()
|
||||
page.goto(site.url + "oe", wait_until="load")
|
||||
|
||||
def state():
|
||||
return page.evaluate("() => ({ran: Number(document.getElementById('b').getAttribute('data-ran') || 0), ctl: window.__ctl, heard: window.__oes})")
|
||||
|
||||
page.click("#go-" + control)
|
||||
assert wait_until(lambda: state()["ctl"] >= 1, DEADLINE, lambda: page.wait_for_timeout(50)), "the page's own throwing listener never ran (after %.0f s)" % DEADLINE
|
||||
heard = state()["heard"]
|
||||
assert len(heard) == 1 and str(heard[0]["file"]).endswith("/oe.js"), "the control (a listener made by the page) was not heard once with the page's script as file: %r" % (heard,)
|
||||
page.evaluate("() => { window.__oes = []; }")
|
||||
|
||||
# the listener is made IN the evaluate and marks the page's DOM before it throws; the test clicks the trigger, and the PAGE (its own function `fire`, run by its own listener of the trigger) clicks the button
|
||||
page.evaluate("() => { const b = document.getElementById('b'); b.addEventListener('click', () => { b.setAttribute('data-ran', String(Number(b.getAttribute('data-ran') || 0) + 1)); %s }); }" % listener)
|
||||
page.click("#go-b")
|
||||
assert wait_until(lambda: state()["ran"] >= 1, DEADLINE, lambda: page.wait_for_timeout(50)), (
|
||||
"the listener the client's evaluate registered never ran: its marker is not on the page (after %.0f s)" % DEADLINE)
|
||||
at_marker = state()
|
||||
|
||||
page.click("#go-" + control)
|
||||
assert wait_until(lambda: state()["ctl"] >= 2, DEADLINE, lambda: page.wait_for_timeout(50)), "the barrier (the page's own throwing listener, again) never ran (after %.0f s)" % DEADLINE
|
||||
final = state()
|
||||
finally:
|
||||
context.close()
|
||||
assert at_marker["heard"] == [], (
|
||||
"window.onerror was called for the listener of the client's evaluate, which Mozilla never reports to the page (dom/script/ScriptSettings.cpp:521-541: the exception of a sandbox-world listener is not dispatched to the window): %r" % (at_marker["heard"],))
|
||||
assert final["ran"] == 1, "the listener of the client's evaluate ran %r times, not once" % (final["ran"],)
|
||||
assert len(final["heard"]) == 1 and str(final["heard"][0]["file"]).endswith("/oe.js"), (
|
||||
"after the barrier window.onerror had %d calls; only the barrier's (the page's own throw, with its script as file) was expected: %r" % (len(final["heard"]), final["heard"]))
|
||||
|
||||
|
||||
def test_an_error_thrown_by_a_listener_the_clients_evaluate_registered_runs_once_and_never_reaches_window_onerror(invisible, site):
|
||||
_a_listener_of_the_clients_evaluate_runs_once_and_is_never_reported_to_onerror(invisible, site, "c", "throw new Error('w');")
|
||||
|
||||
|
||||
def test_a_non_error_thrown_by_a_listener_the_clients_evaluate_registered_runs_once_and_never_reaches_window_onerror(invisible, site):
|
||||
_a_listener_of_the_clients_evaluate_runs_once_and_is_never_reported_to_onerror(invisible, site, "d", "throw 5;")
|
||||
|
||||
|
||||
def test_an_import_called_by_the_clients_evaluate_asks_for_the_module_as_the_pages_own_import_does(invisible, site):
|
||||
context = invisible.new_context()
|
||||
try:
|
||||
page = context.new_page()
|
||||
page.goto(site.url + "imp", wait_until="load")
|
||||
assert page.evaluate("() => window.__imported") == 1, "the page's own import() did not give the module"
|
||||
assert page.evaluate("() => window.__file") == 1, "the import() of the page's script file did not give the module"
|
||||
# `.then` only so that the answer is a number the client can carry (a module namespace is not serializable); the request is the import's
|
||||
assert page.evaluate("() => import('/mod.js?from=world').then(m => m.default)") == 1, "the import() of the client's evaluate did not give the module"
|
||||
finally:
|
||||
context.close()
|
||||
asked = dict(site.requests)
|
||||
assert "/mod.js?from=page" in asked and "/mod.js?from=world" in asked, "the server heard these requests of the module (path, Referer): %r" % site.requests
|
||||
page_referer, world_referer = asked["/mod.js?from=page"], asked["/mod.js?from=world"]
|
||||
assert world_referer == page_referer, "the import() of the client's evaluate came with the Referer %r, the page's own import() with %r (the import() of the script file had %r; requests: %r)" % (
|
||||
world_referer, page_referer, asked.get("/mod.js?from=file"), site.requests)
|
||||
for who, referer in (("page", page_referer), ("world", world_referer)):
|
||||
assert not _world_marks(referer), "the Referer of the %s's import() is %r, which names the client's world (%r)" % (who, referer, _world_marks(referer))
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
"""With `headless=True` a page sees no pointer or mouse event until the test's own first input.
|
||||
|
||||
What it proves: the engine runs on the core's own hidden display (an Xvfb on Linux, a private desktop on Windows), and
|
||||
the host pointer is not part of it. A page that listens from the first line of its `<head>` hears nothing at all with no
|
||||
input: no `pointerover`, `pointerenter`, `mouseover` or `mouseenter` at the centre of the screen, no move, no wheel. The
|
||||
first thing it hears is what the test's own `page.mouse.move` makes, at the point the test asked for, trusted.
|
||||
|
||||
Why it matters: an event the page hears before any input is an input nobody made. A real user's page gets its first
|
||||
`mouseover` when the pointer enters it, at the place the pointer is, never at the centre of the screen on its birth. The
|
||||
pointer of the host is the one thing the hidden display must not give the page: whatever the machine's cursor is doing
|
||||
(the runner's, a person's at their desk) is not something a page may read.
|
||||
|
||||
Measured on the published engine (run 46840604601 of this repository): every page on Linux got a trusted
|
||||
`pointerover`, `pointerenter`, `mouseover` and `mouseenter` at the centre of the screen with no input at all, 42 to 160 ms
|
||||
after its birth, and Windows got none. The engine makes its window ignore the host pointer on that display, on both systems.
|
||||
|
||||
How the proof is made, with no clock. What must not happen is an event that arrives on its own, and "nothing arrived in
|
||||
some time" would judge the machine. So the proof is an outcome: after `TURNS` frames of the page (a count of the page's own
|
||||
`requestAnimationFrame` turns, never a time) the test makes ONE input, a `page.mouse.move` to a point that is not the centre
|
||||
of the screen, and waits until the page has recorded it. The page must then have recorded, as its very first pointer or
|
||||
mouse event, the one that move made: an over, an enter or a move at that point, trusted. A crossing made by the host pointer
|
||||
is synthesized on layout and paint, within the first frames of a page, so it lands before the move and is the first event
|
||||
the page recorded: the test is red on it, with the event in the message.
|
||||
|
||||
Two tests, one launch each, on Linux and on Windows:
|
||||
|
||||
* the first input, in three situations: the page the test serves on 127.0.0.1 (first document of its tab); a page that
|
||||
stood on `about:blank` (the recorder is put there by the test); and a page that stood on `about:blank` for its frames with
|
||||
no input and was then navigated to the served page. In each, the sentinel move is the first event recorded;
|
||||
* the first input in full: on the served page, the move is the first event, and every event of it is trusted, at (x, y) in
|
||||
client coordinates, and of a kind a move alone makes.
|
||||
|
||||
The listeners are on `window` in the capture phase (a `mouseenter` does not bubble) and on `document`. The humaniser is off:
|
||||
the move is one move, not a stroke from somewhere else.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
from _fission_frames import Sites
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
#: Every pointer and mouse event a page can be given by a pointer that moves, presses or wheels.
|
||||
TYPES = ["pointerover", "pointerout", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup",
|
||||
"mouseover", "mouseout", "mouseenter", "mouseleave", "mousemove", "mousedown", "mouseup", "click", "wheel",
|
||||
"contextmenu"]
|
||||
|
||||
#: Frames of the page (its own `requestAnimationFrame` turns) before the sentinel move is made (see the docstring).
|
||||
TURNS = 30
|
||||
|
||||
#: Where the moves go: inside the default viewport, and not at its centre. One per situation of the first test.
|
||||
X, Y = 211, 137
|
||||
POINTS = [(211, 137), (173, 251), (329, 97)]
|
||||
FIRST_KINDS = ("pointerover", "pointerenter", "mouseover", "mouseenter", "pointermove", "mousemove")
|
||||
|
||||
#: The recorder: the page runs it from the first line of its `<head>`, and the test runs it on `about:blank`.
|
||||
RECORDER = """
|
||||
window.__ev = [];
|
||||
window.__turns = 0;
|
||||
(function () {
|
||||
const types = %s;
|
||||
for (const where of [window, document]) {
|
||||
const name = where === window ? 'window' : 'document';
|
||||
for (const t of types) {
|
||||
where.addEventListener(t, e => {
|
||||
window.__ev.push({t: t, via: name, trusted: e.isTrusted, x: e.clientX, y: e.clientY});
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
const turn = () => { window.__turns++; requestAnimationFrame(turn); };
|
||||
requestAnimationFrame(turn);
|
||||
})();
|
||||
""" % repr(TYPES)
|
||||
|
||||
PAGE = """<!doctype html><html><head><meta charset=utf-8><title>listening</title>
|
||||
<script>%s</script>
|
||||
<style>html,body{margin:0;height:100%%}</style></head><body></body></html>""" % RECORDER
|
||||
|
||||
|
||||
def _frames(page):
|
||||
"""Until the page has run `TURNS` frames of its own (a count of its turns, with a deadline)."""
|
||||
page.wait_for_function("(turns) => window.__turns >= turns", arg=TURNS, timeout=30_000)
|
||||
|
||||
|
||||
def _heard(page):
|
||||
return page.evaluate("() => window.__ev")
|
||||
|
||||
|
||||
def _launch(binary, seed):
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
return InvisiblePlaywright(seed=seed, binary_path=binary, headless=True, humanize=False)
|
||||
|
||||
|
||||
def _the_move_is_the_first_event(page, point, where):
|
||||
"""One move after the frames; it must be recorded, and be the first event the page recorded."""
|
||||
_frames(page)
|
||||
page.mouse.move(*point)
|
||||
page.wait_for_function("([x, y]) => window.__ev.some(e => e.t === 'mousemove' && e.x === x && e.y === y)",
|
||||
arg=list(point), timeout=30_000)
|
||||
events = _heard(page)
|
||||
first = events[0]
|
||||
assert first["t"] in FIRST_KINDS and (first["x"], first["y"]) == point and first["trusted"], (
|
||||
"%s: the first event the page recorded is %r, not an over, an enter or a move of the move at %r; all: %r" % (where, first, point, events))
|
||||
|
||||
|
||||
def test_a_page_sees_no_pointer_or_mouse_event_before_the_first_input_on_the_hidden_display(firefox_binary):
|
||||
with Sites() as sites:
|
||||
sites.route("A", "/listening", PAGE)
|
||||
with _launch(firefox_binary, 7201) as browser:
|
||||
# a page served on 127.0.0.1, listened to from the first line of its head
|
||||
page = browser.new_page()
|
||||
page.goto(sites.url("A", "/listening"), wait_until="load", timeout=30_000)
|
||||
_the_move_is_the_first_event(page, POINTS[0], "the served page")
|
||||
|
||||
# about:blank itself, with the recorder put there by the test
|
||||
blank = browser.new_page()
|
||||
blank.evaluate("() => { %s }" % RECORDER)
|
||||
_the_move_is_the_first_event(blank, POINTS[1], "about:blank")
|
||||
|
||||
# about:blank first, its frames run with no input, then navigated: the pointer of this tab has not been moved by the
|
||||
# test before its sentinel, so a crossing the page hears first can only be one nobody made
|
||||
later = browser.new_page()
|
||||
later.evaluate("() => { %s }" % RECORDER)
|
||||
_frames(later)
|
||||
later.goto(sites.url("A", "/listening"), wait_until="load", timeout=30_000)
|
||||
_the_move_is_the_first_event(later, POINTS[2], "the page navigated to after about:blank")
|
||||
|
||||
|
||||
def test_the_first_event_a_page_sees_is_the_one_the_first_mouse_move_makes(firefox_binary):
|
||||
with Sites() as sites:
|
||||
sites.route("A", "/listening", PAGE)
|
||||
with _launch(firefox_binary, 7202) as browser:
|
||||
page = browser.new_page()
|
||||
page.goto(sites.url("A", "/listening"), wait_until="load", timeout=30_000)
|
||||
_frames(page)
|
||||
|
||||
page.mouse.move(X, Y)
|
||||
page.wait_for_function("([x, y]) => window.__ev.some(e => e.t === 'mousemove' && e.x === x && e.y === y)",
|
||||
arg=[X, Y], timeout=30_000)
|
||||
events = _heard(page)
|
||||
|
||||
assert events, "the page heard nothing of the move"
|
||||
first = events[0]
|
||||
assert first["t"] in FIRST_KINDS and (first["x"], first["y"]) == (X, Y), (
|
||||
"the first event of the page is %r, not an over, an enter or a move at the move's point %r; all: %r" % (first, (X, Y), events))
|
||||
assert all(e["trusted"] for e in events), "an event of the move is not trusted: %r" % [e for e in events if not e["trusted"]]
|
||||
assert all((e["x"], e["y"]) == (X, Y) for e in events), "an event of the move is not at %r: %r" % ((X, Y), events)
|
||||
assert {e["t"] for e in events} <= set(FIRST_KINDS), (
|
||||
"a move made an event a move does not make: %r" % sorted({e["t"] for e in events} - set(FIRST_KINDS)))
|
||||
+316
@@ -0,0 +1,316 @@
|
||||
"""A page's own `RegExp[Symbol.hasInstance]` and `Date[Symbol.hasInstance]` are never called by the automation while the client listens to console events.
|
||||
|
||||
Retail Firefox never calls them: nothing of the browser asks the page's `RegExp` or `Date` whether a value is an instance of it. The engine's Juggler classifies
|
||||
the arguments of a console message (`rawObj instanceof this._domWindow[className]`, `juggler/content/Runtime.js`, `_createRemoteObject`), and an `instanceof` runs
|
||||
`Symbol.hasInstance` of the constructor on its right: a page that defines it on `RegExp` or `Date` (a plain `Object.defineProperty`, a thing any script can do)
|
||||
counts the calls and learns that something looked at its objects, which no retail Firefox does.
|
||||
|
||||
The page defines the hook on `RegExp` and on `Date` BEFORE any log, and a third one on a class of its own (`Probe`) that the page itself tests once with
|
||||
`instanceof`: that control is 1 when the hook works, so a count of 0 on `RegExp` and `Date` means nothing was called, not that the hook never ran. The client
|
||||
registers `page.on("console")`, the page logs `{}`, `/x/`, `new Date(0)` and `[1]` (an object, a RegExp, a Date, an array: the classification of the engine
|
||||
goes through each of them), the test waits until the client has heard the four, and then reads the counters.
|
||||
|
||||
What the client sees of the two values, and what is checked of it: the wrapper hands the client a console message whose `args` is empty and whose `text` is built
|
||||
from what Juggler sends for each argument (`_console_text`, `_juggler/_marshal.py`; Juggler sends a type and a subtype for an object and no preview). So the client
|
||||
cannot read a "regexp" or a "date" in the message; what it must still see is that the four messages arrive, in the order of the page, each a `log` with a text
|
||||
that is not empty (a classification that threw, or an `instanceof` that was stopped, would lose the message or leave it empty). That is what the last
|
||||
assertions check, for the RegExp and the Date as for the others.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import html
|
||||
import json
|
||||
import threading
|
||||
from collections import namedtuple
|
||||
from http.server import BaseHTTPRequestHandler
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
|
||||
from _servers import LocalServer
|
||||
from _waits import wait_until
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
#: Far beyond what a healthy run needs (a few hundred ms); it is the only clock the verdict depends on.
|
||||
DEADLINE = 30.0
|
||||
|
||||
PAGE = b"""<!doctype html><title>hasinstance</title><script>
|
||||
window.__hits = {re: 0, date: 0, probe: 0};
|
||||
function hook(ctor, key) {
|
||||
Object.defineProperty(ctor, Symbol.hasInstance, {
|
||||
value(o) { window.__hits[key]++; return Function.prototype[Symbol.hasInstance].call(this, o); },
|
||||
configurable: true,
|
||||
});
|
||||
}
|
||||
hook(RegExp, 're');
|
||||
hook(Date, 'date');
|
||||
class Probe {}
|
||||
hook(Probe, 'probe');
|
||||
// The control: the page itself asks once, so the hook is proved to run when something runs `instanceof`.
|
||||
void ({} instanceof Probe);
|
||||
</script>"""
|
||||
|
||||
#: A page whose `Error.prototype.message` and `Error.prototype.stack` are counting getters (fixed strings, configurable, a no-op setter for `stack`). An error made by
|
||||
#: `new Error('...')` carries its own data property `message`, set by the constructor, so the getter on the prototype is read only by code that reads a
|
||||
#: message the error does not have, and `stack` (an accessor of the prototype in Firefox) only by code that reads the stack of the error.
|
||||
ERRORS_PAGE = b"""<!doctype html><title>errors</title><script>
|
||||
window.__errHits = {message: 0, stack: 0};
|
||||
Object.defineProperty(Error.prototype, 'message', {get() { window.__errHits.message++; return 'page-message'; }, configurable: true});
|
||||
Object.defineProperty(Error.prototype, 'stack', {get() { window.__errHits.stack++; return 'page-stack'; }, set(v) {}, configurable: true});
|
||||
</script>"""
|
||||
|
||||
BLANK_PAGE = b"<!doctype html><title>blank</title>"
|
||||
|
||||
#: The page of the handle reads, without its plant script (`TARGETS_PAGE`, built after `PLANT`, fills `{plant}` and `{frame}`): an iframe of the same origin (its own
|
||||
#: document, whose `srcdoc` is `{frame}`), a visible block, a block far below the fold (a scroll is needed to see it) and a button there.
|
||||
_TARGETS_BODY = """<!doctype html><title>targets</title>
|
||||
<style>body {{margin: 0}} #low {{position: absolute; top: 3000px; left: 10px; width: 100px; height: 30px}}
|
||||
#btn {{position: absolute; top: 3400px; left: 10px; width: 100px; height: 30px}}</style>
|
||||
{plant}
|
||||
<iframe id="f" srcdoc="{frame}" style="width: 200px; height: 100px"></iframe>
|
||||
<div id="outer">outer</div><div id="low">low</div><button id="btn">go</button>"""
|
||||
|
||||
#: The four logs of the page, in this order: the classification of Juggler goes through an object, a RegExp, a Date and an array.
|
||||
LOGS = "() => { console.log({}); console.log(/x/); console.log(new Date(0)); console.log([1]); }"
|
||||
KINDS = ["object", "RegExp", "Date", "array"]
|
||||
|
||||
|
||||
class _Handler(BaseHTTPRequestHandler):
|
||||
def log_message(self, *a):
|
||||
pass
|
||||
|
||||
def do_GET(self):
|
||||
body = {"/errors": ERRORS_PAGE, "/targets": TARGETS_PAGE, "/blank": BLANK_PAGE}.get(self.path, PAGE)
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "text/html; charset=utf-8")
|
||||
self.send_header("Content-Length", str(len(body)))
|
||||
self.send_header("Cache-Control", "no-store")
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def site():
|
||||
srv = LocalServer(("127.0.0.1", 0), _Handler)
|
||||
threading.Thread(target=srv.serve_forever, daemon=True).start()
|
||||
try:
|
||||
yield SimpleNamespace(url="http://127.0.0.1:%d/" % srv.server_address[1])
|
||||
finally:
|
||||
srv.shutdown()
|
||||
srv.server_close()
|
||||
|
||||
|
||||
def test_the_page_own_regexp_and_date_hasinstance_are_not_called_by_a_console_listener(firefox_binary, site):
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
seen = []
|
||||
with InvisiblePlaywright(seed=4271, binary_path=firefox_binary, headless=True) as browser:
|
||||
page = browser.new_page()
|
||||
page.on("console", lambda m: seen.append((m.type, m.text)))
|
||||
page.goto(site.url, wait_until="load")
|
||||
page.evaluate(LOGS)
|
||||
# The client is a sync one: events are delivered while it calls the browser, so the wait is a call.
|
||||
# What is awaited: the client has heard the four console events.
|
||||
wait_until(lambda: len(seen) >= len(KINDS), DEADLINE, lambda: page.wait_for_timeout(50))
|
||||
hits = page.evaluate("() => window.__hits")
|
||||
|
||||
assert len(seen) == len(KINDS), "the client heard %d console events of the 4 the page logged (after %.0f s): %r" % (
|
||||
len(seen), DEADLINE, seen)
|
||||
assert hits["re"] == 0, "the page's RegExp[Symbol.hasInstance] was called %d times while the client listened to console events" % hits["re"]
|
||||
assert hits["date"] == 0, "the page's Date[Symbol.hasInstance] was called %d times while the client listened to console events" % hits["date"]
|
||||
assert hits["probe"] == 1, "the control (the hook of a class of the page, tested once by the page) counted %d, not 1: the hook did not run as the test needs, counters %r" % (
|
||||
hits["probe"], hits)
|
||||
# What the client sees: the four messages, in the order of the page, each a `log` with a text (see the docstring: the wrapper carries no args and no preview).
|
||||
for kind, (type_, text) in zip(KINDS, seen):
|
||||
assert type_ == "log", "the console message of the %s reached the client as type %r, not 'log': %r" % (kind, type_, seen)
|
||||
assert isinstance(text, str) and text.strip(), "the console message of the %s reached the client with the text %r: %r" % (kind, text, seen)
|
||||
|
||||
|
||||
def _raised(page, expression):
|
||||
"""The text of the exception the client raises for `expression`, or None when it raised nothing."""
|
||||
try:
|
||||
page.evaluate(expression)
|
||||
except Exception as exc: # noqa: BLE001 - what the client raises is what is judged
|
||||
return str(exc)
|
||||
return None
|
||||
|
||||
|
||||
def test_the_page_own_error_message_and_stack_getters_are_not_read_when_an_evaluate_fails(firefox_binary, site):
|
||||
"""The page's `Error.prototype.message` and `.stack` are counting getters; an evaluate that throws and one that rejects must not read them, and the client
|
||||
must still get the error's own message: `new Error('boom')` has `message` as its own data property, which the constructor sets and no getter shadows, so
|
||||
the text 'boom' (and 'later') reaches the client in the exception text. The counters are read by a THIRD evaluate that returns a plain object and throws
|
||||
nothing, so the read cannot touch an error itself."""
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
with InvisiblePlaywright(seed=4272, binary_path=firefox_binary, headless=True) as browser:
|
||||
page = browser.new_page()
|
||||
page.goto(site.url + "errors", wait_until="load")
|
||||
thrown = _raised(page, "() => { throw new Error('boom') }")
|
||||
rejected = _raised(page, "() => Promise.reject(new Error('later'))")
|
||||
hits = page.evaluate("() => window.__errHits")
|
||||
|
||||
assert thrown is not None, "the evaluate that throws raised nothing in the client"
|
||||
assert rejected is not None, "the evaluate that returns a rejected promise raised nothing in the client"
|
||||
assert hits == {"message": 0, "stack": 0}, "the page's Error.prototype getters were read while the client evaluated: counters %r (message, stack)" % hits
|
||||
assert "boom" in thrown, "the client's exception for the thrown Error('boom') does not carry its message: %r" % thrown
|
||||
assert "later" in rejected, "the client's exception for the rejected Error('later') does not carry its message: %r" % rejected
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
# The arguments of an exposed function cross as the page's own clone would read them
|
||||
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
#: Defines, in the page, a factory of an object whose properties are counting getters (two on the object, one on a nested object), and measures what the PAGE's own
|
||||
#: `structuredClone` reads: the counters of one clone of a fresh object, then reset.
|
||||
CLONE_PROBE = """() => {
|
||||
window.__bp = {a: 0, b: 0, c: 0};
|
||||
window.__make = () => ({
|
||||
get a() { window.__bp.a++; return 1; },
|
||||
get b() { window.__bp.b++; return 2; },
|
||||
nested: {get c() { window.__bp.c++; return 3; }},
|
||||
});
|
||||
structuredClone(window.__make());
|
||||
const clone = {...window.__bp};
|
||||
window.__bp = {a: 0, b: 0, c: 0};
|
||||
return clone;
|
||||
}"""
|
||||
|
||||
|
||||
def test_the_getters_of_an_object_passed_to_an_exposed_function_are_read_as_the_page_s_own_clone_reads_them(firefox_binary, site):
|
||||
"""What a page can count when it calls an exposed function with an object made of getters. `structuredClone` of the same shape reads every own enumerable property
|
||||
ONCE (the two of the object and the one of the nested object), so the page's own clone is 1, 1, 1: that is the count expected here, measured in the page first
|
||||
and not only written as a number. A stock client serializes the arguments of a binding by reading the properties once, to send them, so it is held to the same
|
||||
count. A getter read twice, or a nested one read at another time, is a second reader of the page's objects. What the client receives is what one read of each
|
||||
getter gives: {a: 1, b: 2, nested: {c: 3}}."""
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
received = []
|
||||
with InvisiblePlaywright(seed=4273, binary_path=firefox_binary, headless=True) as browser:
|
||||
page = browser.new_page()
|
||||
page.expose_function("probe", lambda value: received.append(value))
|
||||
page.goto(site.url + "blank", wait_until="load")
|
||||
cloned = page.evaluate(CLONE_PROBE)
|
||||
page.evaluate("() => window.probe(window.__make())")
|
||||
wait_until(lambda: received, DEADLINE, lambda: page.wait_for_timeout(50))
|
||||
hits = page.evaluate("() => ({...window.__bp})")
|
||||
|
||||
assert cloned == {"a": 1, "b": 1, "c": 1}, "the page's own structuredClone read the getters %r times (expected once each): the measure is not the one this test compares with" % cloned
|
||||
assert received == [{"a": 1, "b": 2, "nested": {"c": 3}}], "the exposed function received %r, not the one read of each getter" % received
|
||||
assert hits == cloned, "the getters of the object passed to the exposed function were read %r times, the page's own structuredClone of the same shape reads them %r" % (hits, cloned)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
# A client call on a handle reads nothing the page can count: one case per block of the engine's PageAgent that reads the element it is given
|
||||
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
#: Plants a counting getter on each named property of each target, in the frame it runs in, and returns the reads the PAGE made of each one by reading it once
|
||||
#: (the control: 1 when the getter works, the proof that a count of 0 later is not a plant that never took). The getter hands back what the property gave (the
|
||||
#: native accessor or value found on the prototype chain, nothing for a name the page cannot see) so the page keeps working; the reads are reset to 0 after the control.
|
||||
#: A property shadowed on the INSTANCE is what a chrome script holding the element WITHOUT an Xray would read; an Xray reads the native one and the page counts nothing.
|
||||
#: It must run in the PAGE's own realm (`window.__plant`, see `PLANT_SCRIPT`): `page.evaluate` runs in the caller's world, a sandbox (juggler/content/FrameTree.js),
|
||||
#: where the hybrid Xray resolves a name that a standard level knows to the native accessor (StealthHybridXray.cpp:138-185), so a getter planted there is never the
|
||||
#: one the page reads (a control of 0 for `innerWidth`, `ownerDocument`...; 1 only for the names no standard level knows, such as `getBoxQuads`, `browsingContext`, `nodePrincipal`).
|
||||
PLANT = """(targets) => {
|
||||
window.__reads = {};
|
||||
const control = {};
|
||||
const resolve = of => of === 'window' ? window : of === 'document' ? document : of === 'root' ? document.documentElement : document.querySelector(of);
|
||||
for (const [of, names] of targets) {
|
||||
const target = resolve(of);
|
||||
for (const name of names) {
|
||||
const key = of + '.' + name;
|
||||
let owner = target, found = null;
|
||||
while (owner && !(found = Object.getOwnPropertyDescriptor(owner, name))) owner = Object.getPrototypeOf(owner);
|
||||
window.__reads[key] = 0;
|
||||
try {
|
||||
Object.defineProperty(target, name, {
|
||||
get() { window.__reads[key]++; return found ? (found.get ? found.get.call(this) : found.value) : undefined; },
|
||||
set(v) {}, configurable: true});
|
||||
} catch (e) { control[key] = 'cannot plant: ' + e.message; continue; }
|
||||
void target[name];
|
||||
control[key] = window.__reads[key];
|
||||
window.__reads[key] = 0;
|
||||
}
|
||||
}
|
||||
return control;
|
||||
}"""
|
||||
|
||||
#: The plant as the page's own script: `window.__plant(text)` takes the targets as JSON text (a string crosses the worlds as it is; the page parses it) and returns
|
||||
#: the control as JSON text. The client calls it with `page.evaluate("t => window.__plant(t)", text)` and reads the control back with `json.loads`.
|
||||
PLANT_SCRIPT = "<script>window.__plant = (text) => JSON.stringify((%s)(JSON.parse(text)));</script>" % PLANT
|
||||
|
||||
#: The page of the handle reads, with the plant in its own script and in the script of its iframe (each document has its own `window.__plant` and `window.__reads`).
|
||||
TARGETS_PAGE = _TARGETS_BODY.format(plant=PLANT_SCRIPT, frame=html.escape("<!doctype html>%s<p id=inner>in</p>" % PLANT_SCRIPT, quote=True)).encode("utf-8")
|
||||
|
||||
|
||||
def plant_in_page(frame, targets):
|
||||
"""Runs the plant IN THE PAGE of `frame` (its own `window.__plant`), so the page's own read of a planted property is the one counted; returns the control."""
|
||||
return json.loads(frame.evaluate("t => window.__plant(t)", json.dumps(targets)))
|
||||
|
||||
|
||||
Case = namedtuple("Case", "id block call plants")
|
||||
|
||||
#: `block`: the function of juggler/content/PageAgent.js with its lines and the Juggler command the client's call makes; `plants`: (frame, [(target, [properties])]),
|
||||
#: the properties that block reads off the element it is given (and off the documents and windows it reaches).
|
||||
CASES = [
|
||||
Case("adopt", "_adoptNode :571 and :575 (Page.adoptNode): nodePrincipal of the element and of the document it is adopted into",
|
||||
lambda h, child: child.evaluate("e => e.id", h["#outer"]),
|
||||
[("main", [("#outer", ["nodePrincipal"])]), ("child", [("document", ["nodePrincipal"])])]),
|
||||
Case("quads", "_getFrameQuads :813-:828 (Page.getContentQuads): getBoxQuads of the element, innerWidth and innerHeight of the main window",
|
||||
lambda h, child: h["#outer"].bounding_box(),
|
||||
[("main", [("#outer", ["getBoxQuads"]), ("window", ["innerWidth", "innerHeight"])])]),
|
||||
Case("describe", "_describeNode :833-:848 (Page.describeNode): browsingContext, localName, contentWindow and ownerDocument of the iframe",
|
||||
lambda h, child: h["#f"].content_frame(),
|
||||
[("main", [("#f", ["browsingContext", "localName", "contentWindow", "ownerDocument"])])]),
|
||||
Case("scroll", "_scrollIntoViewIfNeeded :907-:934 (Page.scrollIntoViewIfNeeded): isConnected, nodeType, ownerDocument, getClientRects, getBoundingClientRect, "
|
||||
"scrollIntoView of the element, defaultView of its document, clientWidth and clientHeight of the root, innerWidth, innerHeight and frameElement of the window",
|
||||
lambda h, child: h["#low"].scroll_into_view_if_needed(),
|
||||
[("main", [("#low", ["isConnected", "nodeType", "ownerDocument", "getClientRects", "getBoundingClientRect", "scrollIntoView"]),
|
||||
("document", ["defaultView"]), ("root", ["clientWidth", "clientHeight"]),
|
||||
("window", ["innerWidth", "innerHeight", "frameElement"])])]),
|
||||
Case("click", "_armLanding :1084 (the landing is armed before the event), what it feeds (_pruneArmedLandings :1107-:1112: ownerDocument, defaultView; _landingOn :1160-:1180: "
|
||||
"ownerDocument, contains) and the quads and scroll blocks that a click runs first",
|
||||
lambda h, child: h["#btn"].click(),
|
||||
[("main", [("#btn", ["ownerDocument", "contains", "isConnected", "nodeType", "getClientRects", "getBoundingClientRect", "scrollIntoView", "getBoxQuads"]),
|
||||
("document", ["defaultView"])])]),
|
||||
]
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def invisible(firefox_binary):
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
with InvisiblePlaywright(seed=4274, binary_path=firefox_binary, headless=True) as b:
|
||||
yield b
|
||||
|
||||
|
||||
@pytest.mark.parametrize("case", CASES, ids=[c.id for c in CASES])
|
||||
def test_a_client_call_on_a_handle_reads_none_of_the_getters_the_page_planted(invisible, site, case):
|
||||
"""Retail Firefox reads nothing of a page's element for an automation call. The page plants counting getters on the properties the block of PageAgent reads
|
||||
(instance properties, which a chrome script without an Xray would read and which the page can count), the client makes the call on a handle it held BEFORE the
|
||||
plant, and every counter must still be 0. A control first: the page reads each planted property once, and each must have counted 1. The page plants (its own
|
||||
`window.__plant`, in the page and in the iframe), so the read that is counted is the page's own, not one made through the client's world."""
|
||||
page = invisible.new_context().new_page()
|
||||
page.goto(site.url + "targets", wait_until="load")
|
||||
handles = {sel: page.query_selector(sel) for sel in ("#f", "#outer", "#low", "#btn")}
|
||||
child = handles["#f"].content_frame()
|
||||
child.wait_for_selector("#inner")
|
||||
where = {"main": page, "child": child}
|
||||
|
||||
controls = {}
|
||||
for frame_key, targets in case.plants:
|
||||
for key, count in plant_in_page(where[frame_key], targets).items():
|
||||
controls["%s:%s" % (frame_key, key)] = count
|
||||
assert all(count == 1 for count in controls.values()), "the planted getters did not count one read by the page itself: %r (case %s)" % (controls, case.id)
|
||||
|
||||
failure = None
|
||||
try:
|
||||
case.call(handles, child)
|
||||
except Exception as exc: # noqa: BLE001 - what the call raised is part of what is reported
|
||||
failure = str(exc)
|
||||
called = {}
|
||||
for frame_key in {frame_key for frame_key, _ in case.plants}:
|
||||
for key, count in where[frame_key].evaluate("() => window.__reads").items():
|
||||
if count:
|
||||
called["%s:%s" % (frame_key, key)] = count
|
||||
assert not called, "the client's call read getters of the page: %r (block: %s)%s" % (
|
||||
called, case.block, "; the call itself failed with %s" % failure if failure else "")
|
||||
assert failure is None, "the client's call failed with %s (block: %s)" % (failure, case.block)
|
||||
@@ -0,0 +1,91 @@
|
||||
"""A password field of 40 characters is as wide as on retail Firefox on Windows: the engine masks it with U+25CF, on Linux and on Windows.
|
||||
|
||||
What it fixes: the character an ``<input type=password>`` is masked with. Windows retail masks with U+25CF (``widget/windows/nsLookAndFeel.cpp``), a GTK build with the ``invisible-char`` of a
|
||||
GTK entry, which is ``*`` where the host's GTK picks it from its font list. A page cannot read the character, but it reads widths: the ``scrollWidth`` of a password field holding 40 x "a" is 40 times
|
||||
the advance of the mask character in the field's font (Arial 16px: 387 px for U+25CF, 249 px for ``*``). The declared machine is a Windows one, so a page on it must read what a page reads on
|
||||
retail Windows, whatever the host.
|
||||
|
||||
The page is the page of the retail capture, byte for byte (``tests/data/password_mask_page.html``, its sha256 is the capture's): it reads the width of the password field, and the widths of 40 x
|
||||
each candidate mask character in the same box, in a text input (``scrollWidth``), an inline span and a canvas. The test reads the number the capture's analysis reads, ``fonts.arial16.password["40"].scrollWidth``
|
||||
(a password field of 40 x "a", ``font-family:Arial;font-size:16px``, a box 20 px wide with no padding or border), and compares it with the retail value.
|
||||
|
||||
NO NUMBER OF RETAIL IS TYPED HERE. The retail width is read from ``ci/retail-password-mask.json``, which ``scripts/extract_retail_password_mask.py`` extracts from the retail capture (Firefox 159.0 on a
|
||||
Windows Server 2025 runner, run 46769343558; the file carries the browser's version, build id and installer sha256 and the sha256 of every file read).
|
||||
|
||||
The launch is the product's, ``InvisiblePlaywright(seed=4, binary_path=..., headless=True)``: seed 4 declares a display of scale 1, the scale of the capture, and the test says so if it did not (a
|
||||
reading at another scale is not the reading the capture holds). Linux and Windows run the same assertions.
|
||||
|
||||
Red on an engine whose GTK widget layer answers ``*`` (the width is 249, not 387); green where the widget layer gives U+25CF, as Windows does.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
import threading
|
||||
from http.server import BaseHTTPRequestHandler
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from _servers import LocalServer
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
PAGE = (ROOT / "tests" / "data" / "password_mask_page.html").read_bytes()
|
||||
#: The retail reading: the file the extraction script writes from the capture; nothing below is typed.
|
||||
RETAIL = json.loads((ROOT / "ci" / "retail-password-mask.json").read_text(encoding="utf-8"))
|
||||
CASE = RETAIL["cases"]["arial16"]
|
||||
#: The seed that declares a display of scale 1, the scale of the retail capture.
|
||||
SEED = 4
|
||||
DEADLINE_MS = 30_000
|
||||
|
||||
|
||||
class _Page(BaseHTTPRequestHandler):
|
||||
"""Serves the page of the capture; the page posts its result (the test reads ``window.__result``, so the body is only drained)."""
|
||||
|
||||
def log_message(self, *args):
|
||||
pass
|
||||
|
||||
def do_GET(self):
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "text/html; charset=utf-8")
|
||||
self.send_header("Content-Length", str(len(PAGE)))
|
||||
self.end_headers()
|
||||
self.wfile.write(PAGE)
|
||||
|
||||
def do_POST(self):
|
||||
self.rfile.read(int(self.headers.get("Content-Length") or 0))
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Length", "0")
|
||||
self.end_headers()
|
||||
|
||||
|
||||
def test_a_password_field_of_40_characters_is_as_wide_as_on_retail_windows(firefox_binary):
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
served = hashlib.sha256(PAGE).hexdigest()
|
||||
assert served == RETAIL["page"]["sha256"], "BROKEN CONTROL, no finding about ours: the page served is %s and the page of the capture is %s" % (served, RETAIL["page"]["sha256"])
|
||||
with LocalServer(("127.0.0.1", 0), _Page) as server:
|
||||
threading.Thread(target=server.serve_forever, daemon=True).start()
|
||||
try:
|
||||
with InvisiblePlaywright(seed=SEED, binary_path=firefox_binary, headless=True) as browser:
|
||||
page = browser.new_context().new_page()
|
||||
page.goto("http://127.0.0.1:%d/index.html?dpr1" % server.server_address[1], timeout=DEADLINE_MS)
|
||||
page.wait_for_function("window.__result !== undefined && document.title === 'done'", timeout=DEADLINE_MS)
|
||||
result = page.evaluate("window.__result")
|
||||
finally:
|
||||
server.shutdown()
|
||||
assert "error" not in result, "BROKEN CONTROL, no finding about ours: the page recorded an error: %s" % result.get("error")
|
||||
env = result["env"]
|
||||
assert env["devicePixelRatio"] == CASE["devicePixelRatio"], (
|
||||
"BROKEN CONTROL, no finding about ours: the page ran at devicePixelRatio %r and the retail capture at %r (seed %d)" % (env["devicePixelRatio"], CASE["devicePixelRatio"], SEED))
|
||||
font = result["fonts"]["arial16"]
|
||||
width = font["password"][str(RETAIL["n"])]["scrollWidth"]
|
||||
masks = font["verdict"]["by_text_input_scrollWidth"]
|
||||
assert width == CASE["password_scrollWidth"], (
|
||||
"a password field of %d x 'a' in Arial 16px is %r px wide (scrollWidth) on this engine, and %r px on retail Firefox %s on Windows: the mask character the page's widths name is %s here, %s on retail "
|
||||
"(per-character advance %r px here; a text input of 40 x U+25CF reads %r px, 40 x '*' reads %r px). navigator.platform %r, devicePixelRatio %r, computed font-family %r"
|
||||
% (RETAIL["n"], width, CASE["password_scrollWidth"], RETAIL["capture"]["browser"]["firefox_version"], masks, CASE["mask"], font["password"]["per_char"],
|
||||
font["refs"]["U+25CF"]["text_input"][str(RETAIL["n"])]["scrollWidth"], font["refs"]["*"]["text_input"][str(RETAIL["n"])]["scrollWidth"],
|
||||
env["platform"], env["devicePixelRatio"], font["input_font_family"]))
|
||||
@@ -5,13 +5,15 @@ absolute result to the parent, which applies it to the real window. A popup whos
|
||||
puts the popup where it likes, and its frame is the host's) must still answer these calls as the retail window does. Three things, per display case (the four of
|
||||
the window tests), each in a popup of its own opened by a real click, ``window.open(url, '_blank', 'width=500,height=400')``:
|
||||
|
||||
1. ``resizeBy(0, 0)``: ``innerWidth``, ``innerHeight``, ``outerWidth`` and ``outerHeight`` stay what they were. A call that adds nothing must change nothing; if the
|
||||
parent converted the declared outer size into the real one with the wrong frame, the real inner size would move by the difference of the two frames (retail
|
||||
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.
|
||||
1. ``resizeBy(0, 0)``: ``innerWidth``, ``innerHeight``, ``outerWidth`` and ``outerHeight`` are what RETAIL read, before and after the same call, in a popup of a profile whose store holds the main window
|
||||
(``MOMENTS``, below: the stored state, the formula of ``scripts/retail_popup_formula.py`` with the stored spec). At a real 150% that popup is 500 inside and 515 outside and the call takes it to 501 (the device
|
||||
rounding of the real window, which the call sends back to it). If the parent converted the declared outer size into the real one with the wrong frame, the real inner size would move by the difference of the
|
||||
two frames. The page is watched for 1.5 s after the call, so a change that arrives late is seen. The first popup of a NEW profile (no main-window entry in the store yet) is a device pixel narrower
|
||||
(inner 499, outer 514): that is the state of a profile nothing has changed, not of a user's, and no test expects it.
|
||||
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. ``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
|
||||
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 in the stored state
|
||||
(``MOVE_TO``, 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.
|
||||
|
||||
@@ -23,6 +25,8 @@ differ, so this test is RED there, on purpose. It enters the suite with the engi
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, Tuple
|
||||
|
||||
import pytest
|
||||
@@ -31,9 +35,16 @@ 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.
|
||||
#: What RETAIL read: the file ``scripts/extract_retail_popup_move_resize.py`` writes from the ``popup-move-to`` capture (retail Firefox 159.0 on Windows, four launches per display case; the file carries the run id, the RetailCaptures commit, the browser's build id and
|
||||
#: installer sha256, the sha256 of ``firefox.exe`` and ``xul.dll`` and of each raw.json, verified against the capture's meta.json). Every phase expects what a popup reads in the STORED state: a real user's profile
|
||||
#: holds the main window's entry in its store (any maximize, resize or activation after the chrome loads writes it, AppWindow.cpp :2549, :2561, :2625, :2771) and Mozilla's ``LoadPersistentWindowState``
|
||||
#: (AppWindow.cpp:2322-2350) gives a popup that stored spec. The extractor refuses to write the file unless the formula with the stored spec reproduces every popup captured with the entry in the store, so the
|
||||
#: first popup of this test is expected like the others. The numbers are the capture's, never typed or computed here.
|
||||
_RETAIL = json.loads((Path(__file__).resolve().parent.parent / "ci" / "retail-popup-move-resize.json").read_text(encoding="utf-8"))
|
||||
#: Phase 1 (``initial``, ``resized``).
|
||||
MOMENTS = {case: phases["resize_by_zero"] for case, phases in _RETAIL["cases"].items()}
|
||||
#: Phase 3 (``moved``, ``moved_to``).
|
||||
MOVE_TO = {case: phases["move_to_far_right"] for case, phases in _RETAIL["cases"].items()}
|
||||
#:
|
||||
#: 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``
|
||||
@@ -41,12 +52,14 @@ pytestmark = pytest.mark.e2e
|
||||
#: 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),
|
||||
}
|
||||
|
||||
|
||||
def _retail(case: str) -> Tuple[Tuple[int, int], Tuple[int, int], int]:
|
||||
"""(moved (screenX, screenY), moved_to (screenX, screenY), outerWidth) of retail in phase 3, in the stored state."""
|
||||
m = MOVE_TO[case]
|
||||
return tuple(m["moved"]["screen"]), tuple(m["moved_to"]["screen"]), m["moved_to"]["outer"][0]
|
||||
|
||||
|
||||
#: 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"
|
||||
@@ -87,13 +100,17 @@ def _phase_resize_by_zero(page, sites, case: str) -> None:
|
||||
popup = _open(page, sites)
|
||||
try:
|
||||
before = _settled_popup(popup)
|
||||
assert (before["iw"], before["ih"]) == (500, 400), "%s: the popup is %rx%r inside before the call, it was asked 500x400 (%r)" % (
|
||||
case, before["iw"], before["ih"], before)
|
||||
opened = tuple(MOMENTS[case]["initial"]["inner"])
|
||||
assert (before["iw"], before["ih"]) == opened, "%s: the popup is %rx%r inside before the call, retail reads %rx%r (it was asked 500x400) (%r)" % (
|
||||
case, before["iw"], before["ih"], opened[0], opened[1], before)
|
||||
popup.evaluate("() => { window.resizeBy(0, 0); }")
|
||||
after = observe(popup, lambda: tuple(popup.evaluate(SIZE)), WATCH_S)
|
||||
was = (before["iw"], before["ih"], before["ow"], before["oh"])
|
||||
assert after == [was], (
|
||||
"%s: resizeBy(0, 0) changed the window: (innerWidth, innerHeight, outerWidth, outerHeight) was %r and the page then read %r" % (case, was, after))
|
||||
resized = MOMENTS[case]["resized"]
|
||||
expected = (*resized["inner"], *resized["outer"])
|
||||
assert after == [expected], (
|
||||
"%s: after resizeBy(0, 0) the page read (innerWidth, innerHeight, outerWidth, outerHeight) %r; retail reads %r (the window was %r before the call)" % (
|
||||
case, after, expected, was))
|
||||
finally:
|
||||
popup.close()
|
||||
|
||||
@@ -114,7 +131,7 @@ 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]
|
||||
moved, moved_to, outer_width = _retail(case)
|
||||
popup = _open(page, sites)
|
||||
try:
|
||||
before = _settled_popup(popup)
|
||||
|
||||
@@ -6,23 +6,21 @@ content area, less the popup's own frame); the screen and the scale decide the n
|
||||
maximized main window whose state the browser has stored, per display case: scale 1.0, 1.25 and 1.5 on a 1920x1080 panel and scale 2.0 on a 1600x1200 one (device
|
||||
pixels), the four cases of ``_window_origin.CASES``.
|
||||
|
||||
NO NUMBER OF RETAIL IS TYPED HERE. Every retail value is read from ``ci/retail-popup-sizes.json``, which ``scripts/extract_retail_popup_sizes.py`` extracts from the retail
|
||||
capture (round 12 of the window-geometry capture: the ``popup_sizes`` step of each raw.json, launch ``a`` checked against launch ``b``, and the ``popup`` rows of
|
||||
``captures/WINDOW_GEOMETRY_POPUP_FRAME.csv`` checked against it; the file carries the round, the run, the browser's version, build id and installer sha256, and the sha256 of every
|
||||
file read). A hand table in this docstring was wrong once (an outer width of 514 at scale 1.5, the value of 1.25; retail read 515), which is why there is none.
|
||||
|
||||
Each popup reads its own window twice: in its first inline script (the moment a page's first script can look) and at ``load``. Both readings are asserted, one test
|
||||
function per feature string, each in a fresh browser and page with ONE popup per case:
|
||||
|
||||
* ``width=500,height=400``: inner 500x400 at every scale; outer 516x480, 514x478, 514x478, 513x476; ``visualViewport.height`` 399.5 at 2.0 and 400 elsewhere.
|
||||
* ``popup``: inner 1920x968, 1536x752, 1280x609, 800x489; outer 1936x1048, 1550x830, 1295x687, 813x565; ``visualViewport.height`` 968, 752, 608.67, 488.5.
|
||||
* ``width=500``: inner 500x856, 500x662, 501x533, 500x428.
|
||||
* ``height=400``: inner 1280x400, 1280x401, 1153x400, 720x400.
|
||||
* ``width=300,height=200``: 300x200 at every scale.
|
||||
* ``width=800,height=600``: 800x600, 800x600, 800x594, 787x476.
|
||||
* ``width=500,height=400``, ``popup``: inner size, outer size and ``visualViewport.height`` (the two the capture of the feature string gave and the test has always compared);
|
||||
* ``width=500``, ``height=400``, ``width=300,height=200``, ``width=800,height=600``: inner size.
|
||||
|
||||
A popup that names a position and no size (``left=100,top=100``, ``left=5000,top=5000``) opens normal, not maximized, at the size the main window stored, at the page's
|
||||
position kept inside the work area (retail Firefox 159 on Windows, measured, the same main window): inner, outer and ``screenX``/``screenY`` are asserted.
|
||||
position kept inside the work area (the same main window): inner, outer and ``screenX``/``screenY`` are asserted.
|
||||
|
||||
* ``left=100,top=100``: inner 1280x856, 1280x662, 1153x533, 720x428; outer 1296x936, 1294x741, 1168x611, 733x504; screen 100,96, 100,75, 100,61, 67,48.
|
||||
* ``left=5000,top=5000``: the same sizes, moved to the right edge, the same top: screen 624,96, 242,75, 112,61, 67,48.
|
||||
|
||||
Also read, and named in the failure message but not asserted (no retail value was measured for them): ``visualViewport.width``, and ``screenX``, ``screenY`` for the
|
||||
Also read, and named in the failure message but not asserted (the extract carries no value for them): ``visualViewport.width``, and ``screenX``, ``screenY`` for the
|
||||
feature strings that name no position. ``devicePixelRatio`` is asserted equal to the case's scale.
|
||||
|
||||
Why a page reads it: the size of a popup it opened, and the outer size around it, are one line of script; a popup whose sizes are the host window manager's is a
|
||||
@@ -30,15 +28,18 @@ browser that does not run on Windows. Linux and Windows run the same assertions:
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, Optional, Tuple
|
||||
|
||||
import pytest
|
||||
from _fission_frames import Sites
|
||||
import _retail_window_formula as formula
|
||||
from _window_origin import CASES, DEADLINE_S, launch_case, settled, wait_for
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
#: The four cases in the order of their scale: 1.0, 1.25, 1.5, 2.0 (the keys of ``_window_origin.CASES``, in the order of the numbers below).
|
||||
#: The four cases in the order of their scale: 1.0, 1.25, 1.5, 2.0 (the keys of ``_window_origin.CASES``, in the order of their scale).
|
||||
ORDER = ["1920x1080-dpr1.0", "1920x1080-dpr1.25", "1920x1080-dpr1.5", "1600x1200-dpr2.0"]
|
||||
|
||||
#: The button that opens the popup: ``position:fixed`` at (20, 20), 160x40 CSS pixels; its centre is the point of the real click.
|
||||
@@ -63,30 +64,40 @@ window.addEventListener('load', () => { window.__load = read(); });
|
||||
|
||||
READ = "() => ({first: window.__first, load: window.__load || null})"
|
||||
|
||||
#: case -> (inner, outer or None, visualViewport.height or None): retail's numbers; None where retail was not measured for the feature string.
|
||||
#: The retail numbers: the file the extraction script writes from the capture (``scripts/extract_retail_popup_sizes.py``); nothing below is typed.
|
||||
RETAIL = json.loads((Path(__file__).resolve().parent.parent / "ci" / "retail-popup-sizes.json").read_text(encoding="utf-8"))["cases"]
|
||||
|
||||
#: case -> (inner, outer or None, visualViewport.height or None): retail's numbers for a feature string; the outer size and the viewport height are compared for these two strings.
|
||||
Row = Tuple[Tuple[int, int], Optional[Tuple[int, int]], Optional[float]]
|
||||
COMPARES_OUTER_AND_VIEWPORT = ("width=500,height=400", "popup")
|
||||
|
||||
|
||||
def _table(*rows: Row) -> Dict[str, Row]:
|
||||
return dict(zip(ORDER, rows))
|
||||
def _table(features: str) -> Dict[str, Row]:
|
||||
"""The rows of one feature string, for the four cases, from the extract."""
|
||||
rows: Dict[str, Row] = {}
|
||||
for case in ORDER:
|
||||
r = RETAIL[case][features]
|
||||
both = features in COMPARES_OUTER_AND_VIEWPORT
|
||||
rows[case] = (tuple(r["inner"]), tuple(r["outer"]) if both else None, r["vv_height"] if both else None)
|
||||
return rows
|
||||
|
||||
|
||||
SIZED = _table(((500, 400), (516, 480), 400), ((500, 400), (514, 478), 400), ((500, 400), (514, 478), 400), ((500, 400), (513, 476), 399.5))
|
||||
POPUP_ONLY = _table(((1920, 968), (1936, 1048), 968), ((1536, 752), (1550, 830), 752), ((1280, 609), (1295, 687), 608.67), ((800, 489), (813, 565), 488.5))
|
||||
WIDTH_ONLY = _table(((500, 856), None, None), ((500, 662), None, None), ((501, 533), None, None), ((500, 428), None, None))
|
||||
HEIGHT_ONLY = _table(((1280, 400), None, None), ((1280, 401), None, None), ((1153, 400), None, None), ((720, 400), None, None))
|
||||
SMALL = _table(((300, 200), None, None), ((300, 200), None, None), ((300, 200), None, None), ((300, 200), None, None))
|
||||
MEDIUM = _table(((800, 600), None, None), ((800, 600), None, None), ((800, 594), None, None), ((787, 476), None, None))
|
||||
SIZED = _table("width=500,height=400")
|
||||
POPUP_ONLY = _table("popup")
|
||||
WIDTH_ONLY = _table("width=500")
|
||||
HEIGHT_ONLY = _table("height=400")
|
||||
SMALL = _table("width=300,height=200")
|
||||
MEDIUM = _table("width=800,height=600")
|
||||
|
||||
|
||||
def _read_popup(firefox_binary: str, case: str, features: str, viewport: Optional[Dict[str, int]] = None) -> Dict[str, Any]:
|
||||
def _read_popup(firefox_binary: str, case: str, features: str, viewport: Optional[Dict[str, int]] = None, launch=launch_case) -> Dict[str, Any]:
|
||||
"""One popup of ``features`` from a real click on a fresh page, read in its first script and at load (the load reading after two equal looks).
|
||||
|
||||
``viewport`` is the one the user gives ``new_page``; without it the page takes the viewport the core declares for the main window."""
|
||||
with Sites() as sites:
|
||||
sites.route("A", "/page", TOP)
|
||||
sites.route("A", "/popup", POPUP)
|
||||
with launch_case(firefox_binary, case) as browser:
|
||||
with launch(firefox_binary, case) as browser:
|
||||
page = browser.new_page(viewport=viewport) if viewport else browser.new_page()
|
||||
page.goto(sites.url("A", "/page"), wait_until="load", timeout=30000)
|
||||
page.evaluate("([url, features]) => { window.__popupUrl = url; window.__popupFeatures = features; }", [sites.url("A", "/popup"), features])
|
||||
@@ -96,7 +107,9 @@ def _read_popup(firefox_binary: str, case: str, features: str, viewport: Optiona
|
||||
try:
|
||||
popup.wait_for_load_state("load", timeout=30000)
|
||||
wait_for(popup, lambda: popup.evaluate(READ)["load"] is not None, DEADLINE_S)
|
||||
return settled(popup, lambda: popup.evaluate(READ))
|
||||
reading = settled(popup, lambda: popup.evaluate(READ))
|
||||
reading["avail"] = page.evaluate("() => [screen.availWidth, screen.availHeight]")
|
||||
return reading
|
||||
finally:
|
||||
popup.close()
|
||||
|
||||
@@ -105,12 +118,13 @@ def _read_popup(firefox_binary: str, case: str, features: str, viewport: Optiona
|
||||
Placed = Tuple[Tuple[int, int], Tuple[int, int], Tuple[int, int]]
|
||||
|
||||
|
||||
def _placed(*rows: Placed) -> Dict[str, Placed]:
|
||||
return dict(zip(ORDER, rows))
|
||||
def _placed(features: str) -> Dict[str, Placed]:
|
||||
"""The rows of one feature string that names a position and no size, for the four cases, from the extract."""
|
||||
return {case: (tuple(RETAIL[case][features]["inner"]), tuple(RETAIL[case][features]["outer"]), tuple(RETAIL[case][features]["screen"])) for case in ORDER}
|
||||
|
||||
|
||||
NEAR = _placed(((1280, 856), (1296, 936), (100, 96)), ((1280, 662), (1294, 741), (100, 75)), ((1153, 533), (1168, 611), (100, 61)), ((720, 428), (733, 504), (67, 48)))
|
||||
FAR = _placed(((1280, 856), (1296, 936), (624, 96)), ((1280, 662), (1294, 741), (242, 75)), ((1153, 533), (1168, 611), (112, 61)), ((720, 428), (733, 504), (67, 48)))
|
||||
NEAR = _placed("left=100,top=100")
|
||||
FAR = _placed("left=5000,top=5000")
|
||||
|
||||
|
||||
def _check_placed(firefox_binary: str, case: str, features: str, table: Dict[str, Placed]) -> None:
|
||||
@@ -197,3 +211,29 @@ def test_a_popup_with_no_size_reads_the_viewport_the_user_set(firefox_binary):
|
||||
assert (r["iw"], r["ih"]) == (USER_VIEWPORT["width"], USER_VIEWPORT["height"]), (
|
||||
"%s, new_page(viewport=%r), window.open(url, '', 'popup'): the popup is %rx%r inside, as stock Playwright it reads the viewport %s" % (
|
||||
case, USER_VIEWPORT, r["iw"], r["ih"], seen))
|
||||
|
||||
|
||||
@pytest.mark.parametrize("features", [formula.SIZED, "popup"])
|
||||
@pytest.mark.parametrize("case", sorted(formula.BIG_CASES))
|
||||
def test_a_popup_of_a_persona_larger_than_any_runner_reads_the_retail_sizes(firefox_binary, case, features):
|
||||
"""A persona whose screen (2560x1440, scale 1.0 and 1.25) is larger than the screen of every runner: the popup reads what retail reads on such a display.
|
||||
|
||||
No retail capture exists at that size: the expected numbers are the formula of ``tests/_retail_window_formula.py`` (the persona's work area, which the page reads, and the retail border, chrome
|
||||
and popup frame of the same scale from ``ci/retail-window-formula.json``). ``popup`` takes its size from the main window, so a main window that is the host's rectangle and not the declared
|
||||
one gives a popup of another size."""
|
||||
scale = formula.BIG_CASES[case][0]
|
||||
frame = formula.load()["scales"][str(scale)]
|
||||
reading = _read_popup(firefox_binary, case, features, launch=formula.launch_big)
|
||||
avail = reading["avail"]
|
||||
window = formula.expected_window(avail, scale, frame["border"], frame["ui"])
|
||||
expected = formula.expected_popup(features, window, tuple(frame["popup_frame"]), scale, avail)
|
||||
for when in ("first", "load"):
|
||||
r = reading[when]
|
||||
label = "%s, window.open(url, '', %r), read in the %s" % (case, features, "first inline script" if when == "first" else "load event")
|
||||
assert r is not None, "%s: nothing was read" % label
|
||||
seen = "(inner %rx%r, outer %rx%r, devicePixelRatio %r, screen %r,%r; work area %r)" % (r["iw"], r["ih"], r["ow"], r["oh"], r["dpr"], r["sx"], r["sy"], avail)
|
||||
assert (r["iw"], r["ih"]) == expected["inner"], "%s: the popup is %rx%r inside, retail reads %rx%r %s" % (label, r["iw"], r["ih"], expected["inner"][0], expected["inner"][1], seen)
|
||||
assert r["dpr"] == scale, "%s: devicePixelRatio is %r, the case declares %r %s" % (label, r["dpr"], scale, seen)
|
||||
assert (r["ow"], r["oh"]) == expected["outer"], "%s: outerWidth x outerHeight is %rx%r, retail reads %rx%r %s" % (label, r["ow"], r["oh"], expected["outer"][0], expected["outer"][1], seen)
|
||||
if "screen" in expected:
|
||||
assert (r["sx"], r["sy"]) == expected["screen"], "%s: screenX, screenY is %r,%r, retail reads %r,%r %s" % (label, r["sx"], r["sy"], expected["screen"][0], expected["screen"][1], seen)
|
||||
@@ -0,0 +1,149 @@
|
||||
"""A press outside the open list of a ``<datalist>`` ends as it does on stock Firefox with stock Playwright: the page hears what stock's page hears, and the list is in the state stock leaves it in.
|
||||
|
||||
WHY THIS TWIN. The engine's door rolls the popups of the chrome up the way the platform does before a press reaches the page (the select dropdown, the menus), and the list of a datalist is NOT one of
|
||||
the popups it rolls up (the page hears a press on the input whole, ``test_a_press_on_the_input_of_an_open_datalist_reaches_the_page`` of the rollup file). What a press OUTSIDE that list does is the
|
||||
other half of that exclusion, and its verdict is not a list of ours: it is what stock Firefox does for the same press, measured in the same run.
|
||||
|
||||
THE VERDICT IS "THE SAME AS STOCK" (``_stock_twin``): Playwright's own Firefox, driven by the stock Playwright client, does the same steps first, on the same local page, at the same window size and scale, and
|
||||
ours must read the same. What stock reads is the expected value; the test has no list of events of its own.
|
||||
|
||||
What it does, per display case (the four of the window tests), on each browser, with the client's own mouse and keyboard: a page of one site holds an ``<input list=dl>`` with a ``<datalist id=dl>`` of three options
|
||||
(``apple``, ``apricot``, ``avocado``) at (20, 20), 200 x 30, and a plain box ``#far`` at (450, 250), 250 x 100, clear of the input and of the list that opens under it. The page records, in the capture phase,
|
||||
``pointerdown``, ``mousedown``, ``pointerup``, ``mouseup``, ``click``, ``focus`` and ``blur`` (type, id of the target, ``isTrusted``) in ``window.__events``.
|
||||
|
||||
1. a click on the input and one typed letter (``a``) open the list;
|
||||
2. THE PRECONDITION, asserted in chrome on each browser: ``#PopupAutoComplete`` is ``open``, and the point of the press is outside its real rectangle (``getOuterScreenRect()`` against the real screen point of
|
||||
the press, as the tooltip twin converts it) and outside the input. A browser that does not reach it is a BROKEN CONTROL (red, no finding about ours), never a pass;
|
||||
3. the events are cleared, and the press and release go to the centre of ``#far``;
|
||||
4. the page's events are read once it has heard the click (or at the deadline, when a browser swallows it: that is a record too), and the state of ``#PopupAutoComplete`` and the focused element are watched for one
|
||||
second (``observe``, the one bounded look of ``_window_origin``); the last look is the record;
|
||||
5. THE POSITIVE CONTROL: with the list closed, the same press and release at the same point must be heard whole on ``#far`` by each browser (a page that heard nothing in step 4 is then a page that could hear,
|
||||
and the recorder works).
|
||||
|
||||
The record of a browser is ``{"press": {"events": [[type, target, trusted], ...], "list": state, "active": id}}``; the scales of each browser (page and chrome ``devicePixelRatio``, the real scale of the screen) are
|
||||
kept apart and printed when the records differ. Ours equals stock in every field of ``press``: no field is left out of the comparison.
|
||||
|
||||
The engine under test is not released yet: a door that rolls the list up with the platform's rule and does not give the page the press, or does not close the list, reads other than stock here and is RED on purpose.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Dict, List
|
||||
|
||||
import pytest
|
||||
from _fission_frames import Sites
|
||||
from _stock_twin import BrokenControl, Chrome, both, differences, run_twin
|
||||
from _window_origin import CASES, DEADLINE_S, observe, wait_for
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
#: The input, 200 x 30 at (20, 20); the far box, 250 x 100 at (450, 250), and the point of the press, its centre. The smallest viewport of the cases is 800 x 479 CSS pixels, so every point is inside it.
|
||||
INPUT_CENTRE = (120, 35)
|
||||
FAR_CENTRE = (575, 300)
|
||||
#: How long the list and the focus are watched after the press.
|
||||
WATCH_S = 1.0
|
||||
#: The types the page records.
|
||||
TYPES = ["pointerdown", "mousedown", "pointerup", "mouseup", "click", "focus", "blur"]
|
||||
|
||||
PAGE = """<!doctype html><meta charset=utf-8><title>datalist</title>
|
||||
<style>html,body{margin:0;padding:0;height:100%%}
|
||||
#i{position:absolute;left:20px;top:20px;width:200px;height:30px;box-sizing:border-box}
|
||||
#far{position:absolute;left:450px;top:250px;width:250px;height:100px;background:#bd9}</style>
|
||||
<body><input id=i list=dl><datalist id=dl><option value=apple><option value=apricot><option value=avocado></datalist><div id=far>far</div><script>
|
||||
window.__events = [];
|
||||
(function () {
|
||||
const name = n => n === window ? 'window' : n === document ? 'document' : n && n.nodeType === 1 ? (n.id || n.nodeName.toLowerCase()) : null;
|
||||
for (const type of %s) window.addEventListener(type, e => window.__events.push([e.type, name(e.target), e.isTrusted]), true);
|
||||
window.__reset = () => { window.__events.length = 0; };
|
||||
window.__read = () => ({events: window.__events.slice(), active: name(document.activeElement)});
|
||||
})();
|
||||
</script>""" % repr(TYPES)
|
||||
|
||||
#: The state of the datalist's list in the chrome.
|
||||
LIST_STATE_JS = """
|
||||
const win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
const popup = win.document.getElementById("PopupAutoComplete");
|
||||
return JSON.stringify({state: popup && typeof popup.state === "string" ? popup.state : "absent"});
|
||||
"""
|
||||
#: Where the list really is, and where a point of the page really is, both in CSS pixels of the screen of the chrome: whether the point is inside the list's rectangle.
|
||||
LIST_RECT_JS = """
|
||||
const [point] = arguments;
|
||||
const win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
const popup = win.document.getElementById("PopupAutoComplete");
|
||||
const b = win.gBrowser.selectedBrowser.getBoundingClientRect();
|
||||
const p = win.windowUtils.toScreenRectInCSSUnits(b.left + point.x, b.top + point.y, 0, 0);
|
||||
const r = popup.getOuterScreenRect();
|
||||
return JSON.stringify({state: popup.state, pointer: {x: p.left, y: p.top}, list: {left: r.left, top: r.top, right: r.right, bottom: r.bottom},
|
||||
inside: p.left >= r.left && p.left <= r.right && p.top >= r.top && p.top <= r.bottom});
|
||||
"""
|
||||
|
||||
#: Closes the list from chrome, for the control press.
|
||||
HIDE_LIST_JS = """
|
||||
const win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
const popup = win.document.getElementById("PopupAutoComplete");
|
||||
if (popup && popup.state !== "closed") popup.hidePopup();
|
||||
return JSON.stringify({});
|
||||
"""
|
||||
|
||||
PRESS_EVENTS = [["pointerdown", "far", True], ["mousedown", "far", True], ["pointerup", "far", True], ["mouseup", "far", True], ["click", "far", True]]
|
||||
|
||||
|
||||
def _state(chrome: Chrome) -> str:
|
||||
return chrome.script(LIST_STATE_JS)["state"]
|
||||
|
||||
|
||||
def _read(page) -> Dict[str, Any]:
|
||||
return page.evaluate("() => window.__read()")
|
||||
|
||||
|
||||
def _clicked(page) -> bool:
|
||||
return any(row[0] == "click" for row in _read(page)["events"])
|
||||
|
||||
|
||||
def _steps(sites, page, chrome: Chrome) -> Dict[str, Any]:
|
||||
"""What one browser does and what the page and the chrome read of it. {"scales": ..., "press": {...}}."""
|
||||
page.goto(sites.url("A", "/page"), wait_until="load", timeout=30000)
|
||||
scales = chrome.scales()
|
||||
|
||||
page.mouse.click(*INPUT_CENTRE)
|
||||
page.keyboard.type("a")
|
||||
opened = wait_for(page, lambda: _state(chrome) == "open", DEADLINE_S)
|
||||
if not opened:
|
||||
raise BrokenControl("BROKEN CONTROL, no finding about ours: a click on the input and a typed letter did not open the list of the datalist (#PopupAutoComplete is %r; page %r)" % (_state(chrome), _read(page)))
|
||||
where = chrome.script(LIST_RECT_JS, ({"x": FAR_CENTRE[0], "y": FAR_CENTRE[1]},))
|
||||
if where["state"] != "open" or where["inside"]:
|
||||
raise BrokenControl("BROKEN CONTROL, no finding about ours: the point of the press must be outside the open list (state %r, point inside the list: %r; list %r, point %r)"
|
||||
% (where["state"], where["inside"], where["list"], where["pointer"]))
|
||||
active = _read(page)["active"]
|
||||
if active != "i":
|
||||
raise BrokenControl("BROKEN CONTROL, no finding about ours: the input must hold the focus while the list is open (focused: %r)" % active)
|
||||
|
||||
page.evaluate("() => window.__reset()")
|
||||
page.mouse.click(*FAR_CENTRE)
|
||||
wait_for(page, lambda: _clicked(page), DEADLINE_S) # at the deadline the browser has swallowed the press: the record says so
|
||||
looks: List[Any] = observe(page, lambda: [_state(chrome), _read(page)["active"]], WATCH_S)
|
||||
read = _read(page)
|
||||
press = {"events": read["events"], "list": looks[-1][0], "active": looks[-1][1]}
|
||||
|
||||
# the positive control: with the list closed, the same press is heard whole at the same point
|
||||
chrome.script(HIDE_LIST_JS)
|
||||
if not wait_for(page, lambda: _state(chrome) == "closed", DEADLINE_S):
|
||||
raise BrokenControl("BROKEN CONTROL, no finding about ours: the list did not close from chrome before the control press (state %r)" % _state(chrome))
|
||||
page.evaluate("() => window.__reset()")
|
||||
page.mouse.click(*FAR_CENTRE)
|
||||
wait_for(page, lambda: _clicked(page), DEADLINE_S)
|
||||
control = _read(page)["events"]
|
||||
if control != PRESS_EVENTS:
|
||||
raise BrokenControl("BROKEN CONTROL, no finding about ours: with no popup open, a press at the same point was not heard whole on #far (heard %r, expected %r)" % (control, PRESS_EVENTS))
|
||||
return {"scales": scales, "press": press}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("case", sorted(CASES))
|
||||
def test_a_press_outside_an_open_datalist_list_ends_as_on_stock(firefox_binary, monkeypatch, case):
|
||||
monkeypatch.setenv("MOZ_REMOTE_ALLOW_SYSTEM_ACCESS", "1") # the chrome-scope reads
|
||||
with Sites() as sites:
|
||||
sites.route("A", "/page", PAGE)
|
||||
stock, ours = run_twin(case, firefox_binary, lambda page, chrome: _steps(sites, page, chrome))
|
||||
differing = differences(stock["press"], ours["press"], None, "press")
|
||||
assert not differing, (
|
||||
"%s: a press outside the open list of a datalist ends otherwise on ours than on stock (the page's events as [type, target, trusted], the state of #PopupAutoComplete after, the focused element):\n %s%s"
|
||||
% (case, "\n ".join(differing), both(case, stock, ours)))
|
||||
+603
-7
@@ -14,8 +14,11 @@ import copy
|
||||
import datetime
|
||||
import inspect
|
||||
import json
|
||||
import ntpath
|
||||
import posixpath
|
||||
import shutil
|
||||
import sysconfig
|
||||
import types
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
@@ -241,8 +244,38 @@ def test_nothing_is_excused_there_is_no_list_of_noise():
|
||||
# -
|
||||
# The declared differences.
|
||||
|
||||
def test_the_file_declares_nothing_now_that_the_published_engine_no_longer_spawns_gfxtest_and_the_row_of_the_test_is_by_kind():
|
||||
assert host.load_expected() == [], "the published engine is the 70, which does not spawn gfxtest: its row would be stale in every run (the list may only shrink)"
|
||||
#: The host only rows of the A/B of Linux (candidate run 47107160488, tests/data/ab_host_linux/diff-47107160488.json): 104 leaves, the same in each of its 5 seeds.
|
||||
HOST_ONLY_LINUX_ROWS = 104
|
||||
|
||||
|
||||
def test_the_file_declares_the_seven_of_the_real_window_the_three_of_the_hidden_desktop_the_one_of_the_host_by_hand_and_the_host_only_rows_of_linux_each_with_its_own_run_and_the_row_of_the_test_is_by_kind():
|
||||
everything = host.load_expected()
|
||||
rows = [r for r in everything if r["os"] == "windows"]
|
||||
linux = [r for r in everything if r["os"] == "linux"]
|
||||
host_only_reason = "host only: our firefox.exe differs from retail's in its resources (Nightly branding); no page reads them"
|
||||
assert len(rows) == 11 and {r["reason"] for r in rows} == {"real window, decided 01/12", "hidden desktop", host_only_reason}
|
||||
assert {r["os"] for r in everything} == {"windows", "linux"} and len(everything) == 11 + HOST_ONLY_LINUX_ROWS and len(linux) == HOST_ONLY_LINUX_ROWS
|
||||
assert {r["reason"] for r in linux} == {"host only"}, "the published engine is the 70, which does not spawn gfxtest: the Linux rows are the host only ones, derived by scripts/ci_ab_retail.py host-only"
|
||||
window = [r for r in rows if r["reason"] == "real window, decided 01/12"]
|
||||
hidden = [r for r in rows if r["reason"] == "hidden desktop"]
|
||||
by_hand = [r for r in rows if r["reason"] == host_only_reason]
|
||||
host_only = [r for r in everything if r["reason"] == "host only"]
|
||||
assert (len(window), len(hidden), len(by_hand), len(host_only)) == (7, 3, 1, HOST_ONLY_LINUX_ROWS), "7 + 3 + 1 Windows, plus the Linux host only rows: the count of each reason is pinned, so a row cannot be added under a reason in silence"
|
||||
assert {(r["published"], r["candidate"]) for r in window} == {("absent", "present")} and sorted(r["category"] for r in window) == ["file"] * 6 + ["proc"]
|
||||
assert all(r["source"]["run_id"] == "46900013043" and len(r["source"]["xul_sha256"]) == 64 and r["source"]["capture"].endswith("footprint-windowed/2026-12-02/footprint-retail.json") for r in window)
|
||||
assert sorted((r["name"], r["published"], r["candidate"]) for r in hidden) == sorted([
|
||||
("c:\\windows\\system32\\msctfmonitor.dll", "absent", "present"), ("c:\\windows\\system32\\msutb.dll", "absent", "present"),
|
||||
("<profile>\\appdata\\roaming\\microsoft\\windows\\recent\\customdestinations", "present", "absent")])
|
||||
assert all(r["category"] == "file" and r["source"]["run_id"] == "46903007316" and len(r["source"]["xul_sha256"]) == 64
|
||||
and r["source"]["capture"].endswith("footprint-windowed-hidden-desktop/2026-12-02/footprint-retail.json") for r in hidden)
|
||||
# the one row declared BY HAND (not derived: scripts/ci_ab_retail.py derive refuses a path that retail windowed does not read): the resources of our own firefox.exe, in the folder the engine is staged in
|
||||
(mun,) = by_hand
|
||||
assert (mun["category"], mun["name"], mun["published"], mun["candidate"]) == ("file", "<engine>\\systemresources\\firefox.exe.mun", "absent", "present"), "the leaf is the normalised one (host.normalise_leaf), absent in the published engine"
|
||||
assert host.normalise_leaf("d:\\a\\_temp\\ab-host\\engine\\systemresources\\firefox.exe.mun") == mun["name"]
|
||||
assert "by hand" in mun["source"]["declared"] and mun["source"]["ours"]["run_id"] == "46941424205"
|
||||
assert {(c["run_id"], c["launches_with_it"]) for c in mun["source"]["retail"]} == {("46900013043", "0/3"), ("46903007316", "0/3")}, "retail reads it 0 times in 3 launches in both captures"
|
||||
assert {r["source"]["xul_sha256"] for r in rows} == {"fec21f3e7c281c836ff4fb9658bf321857e101750bc4a6280d1b419996ce7e29"}, "the same retail xul.dll in both captures"
|
||||
assert not {r["name"] for r in rows} & {"c:\\windows\\fonts"}, "the fonts folder is opened as retail opens it: nothing to declare"
|
||||
assert [(e["id"], e["os"], e["category"], e["name"]) for e in expected()] == [("gfxtest-69", "linux", "proc", "gfxtest")]
|
||||
|
||||
|
||||
@@ -2281,6 +2314,13 @@ def with_system(fp, per_launch):
|
||||
return fp
|
||||
|
||||
|
||||
def _no_declared_differences(tmp_path):
|
||||
"""A unit case hands in its own declared differences (none), never the rows of the real ci/ab-host-expected.json."""
|
||||
path = tmp_path / "no-declared-differences.json"
|
||||
path.write_text(json.dumps({"format": host.EXPECTED_FORMAT, "differences": []}), encoding="utf-8")
|
||||
return path
|
||||
|
||||
|
||||
def win(engine="firefox-68", **kw):
|
||||
return footprint(engine, platform="win32", **kw)
|
||||
|
||||
@@ -2302,7 +2342,7 @@ def test_the_ab_passes_the_other_run_of_the_68_to_the_judge(tmp_path, monkeypatc
|
||||
monkeypatch.setattr(host, "run_stock_control", lambda leg, out: {"stock": True})
|
||||
real = host.judge
|
||||
monkeypatch.setattr(host, "judge", lambda a, b, **kw: seen.update(kw) or real(a, b, **kw))
|
||||
host.ab(cand, Path("seal"), "win-x86_64", tmp_path / "o", "firefox-68", [11, 12])
|
||||
host.ab(cand, Path("seal"), "win-x86_64", tmp_path / "o", "firefox-68", [11, 12], expected_file=_no_declared_differences(tmp_path))
|
||||
assert seen["also_68"][0]["engine"] == "again"
|
||||
|
||||
|
||||
@@ -2405,7 +2445,8 @@ def test_the_core_is_run_through_gdb_with_the_three_commands_and_the_build_ids_a
|
||||
gdb = [c for c in run.calls if c[0].endswith("gdb")][0]
|
||||
assert gdb[:2] == ["/usr/bin/gdb", "-batch"] and gdb[-2:] == [str(binary), str(core)]
|
||||
commands = [gdb[i + 1] for i, a in enumerate(gdb) if a == "-ex"]
|
||||
assert commands == ["thread apply all bt", "x/s *(char**)&gMozCrashReason", "info sharedlibrary"]
|
||||
assert len(commands) == 4 and commands[:3] == ["thread apply all bt", "x/s *(char**)&gMozCrashReason", "info sharedlibrary"], "the three, then the one that prints the whole argv"
|
||||
assert commands[3].startswith("python exec(") and commands[3] == crash.GDB_COMMANDS[3]
|
||||
assert "Thread 1 (" in got["cores"]["backtraces"][core.name] and "MOZ_CRASH(shutdown)" in got["cores"]["backtraces"][core.name]
|
||||
ids = got["cores"]["build_ids"][core.name]
|
||||
assert ids["binary"] == "Build ID: abc123" and ids["libxul"] == "Build ID: abc123" and "deadbeef" in ids["core"]
|
||||
@@ -3264,15 +3305,60 @@ def test_run_stock_says_its_phases_from_the_trace_to_the_result_and_the_subproce
|
||||
assert "crash.run_tree(" in source and "sys.stdout.write(done.stdout)" in source, "its output is run_tree's files, printed on the output of the oracle: the phases are in the log"
|
||||
|
||||
|
||||
def test_a_stock_process_that_stands_still_is_a_broken_control_that_names_its_last_phase_within_the_limit_and_the_log_keeps_what_it_said(tmp_path, capsys, monkeypatch):
|
||||
class _ClockOfTheStockControl:
|
||||
"""The clock `run_tree` reads for the stock control, standing still until the stand-in has said `evaluate begin` and running from then on.
|
||||
|
||||
The limit of the real control counts from the launch of its process (`run_tree` starts its clock at `Popen`), and that is right for it: a Firefox that starts and answers takes
|
||||
seconds. A stand-in that a loaded machine starts late has not said a phase when 2 s of the real clock are gone, and the message then says "no phase had been said", which is
|
||||
true and is not what this test is about. With this clock the 2 s are counted from the phase: the precondition is the phase being said (read from the file `run_tree` keeps),
|
||||
and the result under test is the kill and the message that names it. `delay` in the test is how late the stand-in is: it passes in the host's time, not in this clock's.
|
||||
Only `monotonic` is this clock's; the rest of `time` is the real one."""
|
||||
|
||||
def __init__(self, stdout_path):
|
||||
self.stdout_path = stdout_path
|
||||
self.ran_from = None
|
||||
|
||||
def _the_phase_was_said(self):
|
||||
try:
|
||||
return "stock phase evaluate begin at" in self.stdout_path.read_text(encoding="utf-8", errors="replace")
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
def monotonic(self):
|
||||
import time
|
||||
|
||||
if self.ran_from is None:
|
||||
if not self._the_phase_was_said():
|
||||
return 0.0
|
||||
self.ran_from = time.monotonic()
|
||||
return time.monotonic() - self.ran_from
|
||||
|
||||
def __getattr__(self, name):
|
||||
import time
|
||||
|
||||
return getattr(time, name)
|
||||
|
||||
|
||||
#: `delay`: how long the stand-in takes before it says its first phase. 0 is the machine at rest; 3 is the forced case: longer than the 2 s of the limit, so a clock that begins at
|
||||
#: `Popen` has run out before any phase exists.
|
||||
@pytest.mark.parametrize("delay", [0, 3])
|
||||
@pytest.mark.timeout(120, method="thread")
|
||||
def test_a_stock_process_that_stands_still_is_a_broken_control_that_names_its_last_phase_within_the_limit_and_the_log_keeps_what_it_said(tmp_path, capsys, monkeypatch, delay):
|
||||
import time
|
||||
|
||||
import ci_crash_evidence as crash
|
||||
|
||||
def clock_of(path):
|
||||
monkeypatch.setattr(crash, "time", _ClockOfTheStockControl(Path(path).with_suffix(".tree") / "run-tree.stdout"))
|
||||
|
||||
script = ("import sys, time, datetime\n"
|
||||
"time.sleep(%s)\n" % delay +
|
||||
"print('stock phase launch at', datetime.datetime.now(datetime.timezone.utc).isoformat(timespec='seconds'), flush=True)\n"
|
||||
"print('stock phase evaluate begin at', datetime.datetime.now(datetime.timezone.utc).isoformat(timespec='seconds'), flush=True)\n"
|
||||
"time.sleep(60)\n")
|
||||
out = tmp_path / "footprint-stock.json"
|
||||
began = time.monotonic()
|
||||
clock_of(out)
|
||||
rc = host.run_stock_subprocess("windows-x86_64", out, limit_s=2, command=[sys.executable, "-u", "-c", script])
|
||||
assert time.monotonic() - began < 20 and rc == 0
|
||||
document = host.read_json(out)
|
||||
@@ -3285,7 +3371,11 @@ def test_a_stock_process_that_stands_still_is_a_broken_control_that_names_its_la
|
||||
monkey_out = tmp_path / "o"
|
||||
monkey_out.mkdir()
|
||||
real = host.run_stock_subprocess
|
||||
monkeypatch.setattr(host, "run_stock_subprocess", lambda leg, path: real(leg, path, limit_s=2, command=[sys.executable, "-u", "-c", script]))
|
||||
def run_late_stand_in(leg, path):
|
||||
clock_of(path)
|
||||
return real(leg, path, limit_s=2, command=[sys.executable, "-u", "-c", script])
|
||||
|
||||
monkeypatch.setattr(host, "run_stock_subprocess", run_late_stand_in)
|
||||
assert host.run_stock_control("windows-x86_64", monkey_out) is None
|
||||
printed = capsys.readouterr().out
|
||||
assert "FAIL stock control: the stock control did not end within 2 s" in printed and "BROKEN CONTROL: the stock control did not run to the end" in printed
|
||||
@@ -3817,4 +3907,510 @@ def test_the_row_of_the_graphics_probe_is_stale_when_the_published_engine_no_lon
|
||||
report = judge(a, b, expected=expected())
|
||||
assert report["verdict"] == "red" and report["stale"] == ["gfxtest-69"] and report["declared"] == [] and report["differences"] == []
|
||||
assert report["problems"] == ["the declared difference 'gfxtest-69' (%s) does not show in this run: it is stale, remove it" % GFXTEST_ROW["reason"]]
|
||||
assert judge(a, b, expected=host.load_expected())["verdict"] == "green", "the file declares nothing: the same run is green"
|
||||
again = judge(a, b, expected=host.load_expected())
|
||||
assert "gfxtest" not in {r["name"] for r in host.load_expected()} and again["declared"] == [] and again["differences"] == [], "the file declares nothing about the graphics probe"
|
||||
assert again["stale"] == [r["id"] for r in host.load_expected() if r["os"] == "linux"], "what the file declares for Linux is the host only rows, and a run without their paths says each is stale: the graphics probe is not among them"
|
||||
|
||||
|
||||
# -
|
||||
# The declared difference in the other direction (the published engine does not have it, the candidate does), and the `file` rows by leaf.
|
||||
|
||||
GPU_ROW = {"id": "gpu-windowed", "os": "linux", "category": "proc", "name": "gpu", "published": "absent", "candidate": "present", "reason": "real window, decided 01/12"}
|
||||
WIN_FILE_ROWS = [
|
||||
{"id": "file-dwmapi", "os": "windows", "category": "file", "name": "c:\\windows\\system32\\dwmapi.dll", "published": "absent", "candidate": "present", "reason": "real window, decided 01/12"},
|
||||
{"id": "file-mun", "os": "windows", "category": "file", "name": "<engine>\\systemresources\\firefox.exe.mun", "published": "absent", "candidate": "present", "reason": "real window, decided 01/12"},
|
||||
]
|
||||
RUN_TEMP_MUN = "d:\\a\\_temp\\ab-host\\engine\\systemresources\\firefox.exe.mun"
|
||||
DWMAPI = "c:\\windows\\system32\\dwmapi.dll"
|
||||
WITHOUT_GPU = {k: n for k, n in KINDS.items() if k != "gpu"}
|
||||
|
||||
|
||||
def windows_with_window_files(*extra):
|
||||
return windows_footprints(candidate_files=WIN_FILES + list(extra))
|
||||
|
||||
|
||||
def test_a_declared_proc_the_published_engine_lacks_and_the_candidate_has_passes_in_an_a_b():
|
||||
report = judge(footprint("firefox-70", kinds=WITHOUT_GPU), footprint("candidate"), expected=[GPU_ROW])
|
||||
assert report["verdict"] == "green", report["problems"]
|
||||
assert [d["leaf"] for d in report["declared"]] == ["proc.gpu", "proc.gpu"] and report["stale"] == []
|
||||
assert judge(footprint("firefox-70", kinds=WITHOUT_GPU), footprint("candidate"), expected=[])["verdict"] == "red", "undeclared it is a difference"
|
||||
|
||||
|
||||
def test_a_proc_row_of_that_direction_is_red_the_other_way_round_and_stale_when_it_does_not_show():
|
||||
other_way = judge(footprint("firefox-70"), footprint("candidate", kinds=WITHOUT_GPU), expected=[GPU_ROW])
|
||||
assert other_way["verdict"] == "red" and other_way["stale"] == ["gpu-windowed"] and any(d["leaf"] == "proc.gpu" for d in other_way["differences"])
|
||||
same = judge(footprint("firefox-70"), footprint("candidate"), expected=[GPU_ROW])
|
||||
assert same["verdict"] == "red" and same["stale"] == ["gpu-windowed"]
|
||||
|
||||
|
||||
def test_the_row_of_the_old_direction_still_means_published_present_candidate_absent():
|
||||
row = dict(GFXTEST_ROW)
|
||||
row.pop("published"), row.pop("candidate")
|
||||
assert judge(footprint(), a_candidate_without_gfxtest(), expected=[row])["verdict"] == "green"
|
||||
assert judge(a_candidate_without_gfxtest(), footprint(), expected=[row])["verdict"] == "red"
|
||||
|
||||
|
||||
def test_the_row_of_the_file_for_the_resources_of_our_firefox_exe_covers_that_leaf_and_is_stale_when_it_does_not_show():
|
||||
rows = [r for r in host.load_expected() if r["id"] == "file-engine-systemresources-firefox-exe-mun"]
|
||||
assert len(rows) == 1
|
||||
published, candidate = windows_with_window_files(RUN_TEMP_MUN)
|
||||
report = judge(published, candidate, expected=rows)
|
||||
assert report["verdict"] == "green", report["problems"]
|
||||
assert [d["leaf"] for d in report["declared"]] == ["file." + RUN_TEMP_MUN] * len(SEEDS) and report["stale"] == []
|
||||
absent = judge(*windows_with_window_files(), expected=rows)
|
||||
assert absent["verdict"] == "red" and absent["stale"] == [rows[0]["id"]], "a row that does not show in the run is stale"
|
||||
assert judge(published, candidate, expected=[])["verdict"] == "red", "undeclared it is a difference"
|
||||
|
||||
|
||||
def test_a_file_row_covers_the_leaf_of_a_path_by_its_normalised_spelling_and_nothing_else():
|
||||
published, candidate = windows_with_window_files(DWMAPI, RUN_TEMP_MUN)
|
||||
report = judge(published, candidate, expected=WIN_FILE_ROWS)
|
||||
assert report["verdict"] == "green", report["problems"]
|
||||
assert sorted({d["leaf"] for d in report["declared"]}) == ["file." + DWMAPI, "file." + RUN_TEMP_MUN] and report["stale"] == []
|
||||
assert len(report["declared"]) == 2 * len(SEEDS)
|
||||
assert judge(published, candidate, expected=[])["verdict"] == "red"
|
||||
other_temp = judge(*windows_with_window_files(DWMAPI, "e:\\work\\tmp\\ab-host\\engine\\systemresources\\firefox.exe.mun"), expected=WIN_FILE_ROWS)
|
||||
assert other_temp["verdict"] == "green", "the run's temp folder is not part of the leaf"
|
||||
|
||||
|
||||
def test_a_file_row_does_not_cover_another_path_and_a_path_next_to_it_is_still_a_difference():
|
||||
next_to = "c:\\windows\\system32\\dwmapi.dll.mui"
|
||||
report = judge(*windows_with_window_files(DWMAPI, next_to), expected=[WIN_FILE_ROWS[0]])
|
||||
assert report["verdict"] == "red" and {d["leaf"] for d in report["differences"]} == {"file." + next_to}
|
||||
assert [d["leaf"] for d in report["declared"]] == ["file." + DWMAPI] * len(SEEDS)
|
||||
|
||||
|
||||
def test_a_file_row_is_red_the_other_way_round_and_stale_when_the_path_does_not_show():
|
||||
published, candidate = windows_footprints(candidate_files=WIN_FILES)
|
||||
reversed_run = judge(footprint(platform="win32", kinds=WIN_KINDS, files=WIN_FILES + [DWMAPI]), candidate, expected=[WIN_FILE_ROWS[0]])
|
||||
assert reversed_run["verdict"] == "red" and reversed_run["stale"] == ["file-dwmapi"] and {d["leaf"] for d in reversed_run["differences"]} == {"file." + DWMAPI}
|
||||
absent = judge(published, candidate, expected=[WIN_FILE_ROWS[0]])
|
||||
assert absent["verdict"] == "red" and absent["stale"] == ["file-dwmapi"]
|
||||
assert any("stale" in p and "file-dwmapi" in p for p in absent["problems"])
|
||||
|
||||
|
||||
def test_a_file_row_can_declare_a_path_only_the_published_engine_has():
|
||||
row = dict(WIN_FILE_ROWS[0], id="file-fonts", name="c:\\windows\\fonts", published="present", candidate="absent")
|
||||
published = footprint(platform="win32", kinds=WIN_KINDS, files=WIN_FILES + ["c:\\windows\\fonts"])
|
||||
candidate = footprint("candidate", platform="win32", kinds=WIN_KINDS, files=WIN_FILES)
|
||||
assert judge(published, candidate, expected=[row])["verdict"] == "green"
|
||||
assert judge(published, candidate, expected=[dict(row, published="absent", candidate="present")])["verdict"] == "red"
|
||||
|
||||
|
||||
def test_a_file_row_of_another_os_is_not_applied_and_the_a_a_ignores_it():
|
||||
published, candidate = windows_with_window_files(DWMAPI)
|
||||
assert judge(footprint(), footprint("candidate"), expected=WIN_FILE_ROWS)["verdict"] == "green", "a Windows row is neither applied nor stale on Linux"
|
||||
a_a = judge(published, candidate, expected=WIN_FILE_ROWS, a_a=True)
|
||||
assert a_a["verdict"] == "red" and a_a["declared"] == [] and a_a["stale"] == []
|
||||
|
||||
|
||||
def test_normalise_leaf_puts_the_engine_folder_and_the_profile_folder_in_a_placeholder():
|
||||
assert host.normalise_leaf(RUN_TEMP_MUN) == "<engine>\\systemresources\\firefox.exe.mun"
|
||||
tail = "\\appdata\\roaming\\microsoft\\windows\\recent\\customdestinations"
|
||||
assert host.normalise_leaf(TEST_ROOT + "\\someone" + tail, TEST_ROOT) == "<profile>" + tail
|
||||
assert host.normalise_leaf(TEST_ROOT.upper() + "\\someone" + tail, TEST_ROOT) == "<profile>" + tail, "the spelling of the case is the footprint's, the root is compared as such"
|
||||
assert host.normalise_leaf(TEST_ROOT + "\\someone" + tail) == TEST_ROOT + "\\someone" + tail, "without the root the recorder named, nothing is a profile"
|
||||
assert host.normalise_leaf(TEST_ROOT + "-other\\someone" + tail, TEST_ROOT) == TEST_ROOT + "-other\\someone" + tail, "a sibling folder of the root is not under it"
|
||||
assert host.normalise_leaf("c:\\windows\\fonts", TEST_ROOT) == "c:\\windows\\fonts"
|
||||
|
||||
|
||||
def test_the_footprint_of_this_machine_names_the_folder_that_holds_the_profiles_from_its_environment(monkeypatch):
|
||||
monkeypatch.setenv("USERPROFILE", TEST_ROOT + "\\someone")
|
||||
monkeypatch.setenv("HOME", TEST_ROOT + "\\someone")
|
||||
assert host.profile_root_of_this_machine() == TEST_ROOT
|
||||
|
||||
|
||||
@pytest.mark.parametrize("home, root", [
|
||||
(r"x:\home-root\someone", r"x:\home-root"),
|
||||
(r"X:\Home-Root\Someone", r"x:\home-root"),
|
||||
(r"x:/home-root/someone", r"x:\home-root"),
|
||||
(r"\\server\share\someone", r"\\server\share"),
|
||||
(r"/home/runner", r"\home"),
|
||||
(r"/Users/someone", r"\users"),
|
||||
])
|
||||
@pytest.mark.parametrize("host_path", [ntpath, posixpath], ids=["on a Windows host", "on a Linux host"])
|
||||
def test_the_profile_root_is_split_by_the_rules_of_the_path_the_environment_gives_not_of_the_host(monkeypatch, host_path, home, root):
|
||||
fake_os = types.SimpleNamespace(path=types.SimpleNamespace(expanduser=lambda _p: home, dirname=host_path.dirname))
|
||||
monkeypatch.setattr(host, "os", fake_os)
|
||||
assert host.profile_root_of_this_machine() == root
|
||||
|
||||
|
||||
def test_a_row_of_the_profile_folder_covers_the_leaf_under_the_root_the_footprint_recorded():
|
||||
leaf = TEST_ROOT + "\\someone\\appdata\\x"
|
||||
row = dict(WIN_FILE_ROWS[0], id="file-profile", name="<profile>\\appdata\\x")
|
||||
published, candidate = windows_footprints(candidate_files=WIN_FILES + [leaf])
|
||||
for fp in (published, candidate):
|
||||
fp["user_root"] = TEST_ROOT
|
||||
report = judge(published, candidate, expected=[row])
|
||||
assert report["verdict"] == "green" and report["user_root"] == TEST_ROOT and [d["leaf"] for d in report["declared"]] == ["file." + leaf] * len(SEEDS)
|
||||
del published["user_root"], candidate["user_root"]
|
||||
assert judge(published, candidate, expected=[row])["verdict"] == "red", "no recorded root, no profile"
|
||||
|
||||
|
||||
def test_the_candidate_is_launched_from_its_own_venv_with_the_pin_allowed_and_the_control_from_the_set_s(tmp_path, monkeypatch):
|
||||
pub = fake_engine(tmp_path / "fetch", "pub")
|
||||
cand = fake_engine(tmp_path / "checkout", "cand")
|
||||
monkeypatch.setattr(host.oracle, "fetch_published", lambda tag, work: (pub, None, "SET-PYTHON"))
|
||||
monkeypatch.setattr(host, "candidate_python", lambda: "CANDIDATE-PYTHON")
|
||||
monkeypatch.setattr(host, "FLOORS", SMALL)
|
||||
calls = {}
|
||||
docs = {"firefox-70": footprint("firefox-70"), "firefox-70 again": footprint("again"), "candidate": footprint("candidate")}
|
||||
|
||||
def fake_run(exe, seal, leg, out, label, seeds, **kw):
|
||||
calls[label] = kw
|
||||
name = {"firefox-70": "footprint-70.json", "firefox-70 again": "footprint-70-again.json", "candidate": "footprint-candidate.json"}[label]
|
||||
host.write_json(tmp_path / "o" / name, docs[label])
|
||||
return 0
|
||||
|
||||
monkeypatch.setattr(host, "run_subprocess", fake_run)
|
||||
host.ab(cand, Path("seal"), "linux-x86_64", tmp_path / "o", "firefox-70", [11, 12], expected_file=_no_declared_differences(tmp_path))
|
||||
assert calls["firefox-70"] == {"python": "SET-PYTHON"} and calls["firefox-70 again"] == {"python": "SET-PYTHON"}
|
||||
assert calls["candidate"] == {"python": "CANDIDATE-PYTHON", "pin_allow": True}, "its own venv, and its core is core_ref's, which the wrapper of wrapper_ref may not pin"
|
||||
|
||||
|
||||
def test_the_process_of_the_candidate_s_venv_is_clean_of_the_job_and_allows_the_pin_where_the_set_s_does_not(monkeypatch):
|
||||
monkeypatch.setenv("PYTHONPATH", "/job/site")
|
||||
monkeypatch.setenv("VIRTUAL_ENV", "/job/venv")
|
||||
candidate = host.oracle.process_env(Path("cand-seal"), "CANDIDATE-PYTHON", pin_allow=True)
|
||||
published = host.oracle.process_env(None, "SET-PYTHON")
|
||||
for env in (candidate, published):
|
||||
assert "PYTHONPATH" not in env and "VIRTUAL_ENV" not in env and env["INVISIBLE_CORE_AUTOFIX"] == "off"
|
||||
assert candidate["INVISIBLE_CORE_PIN"] == "allow" and candidate["INVISIBLE_SEAL_FILE"] == "cand-seal"
|
||||
assert published.get("INVISIBLE_CORE_PIN") != "allow", "the set's pin check stays on"
|
||||
|
||||
|
||||
def test_the_candidate_s_venv_is_made_from_the_run_s_wheelhouse_beside_the_published_set_s(tmp_path):
|
||||
house = tmp_path / "py-deps"
|
||||
house.mkdir()
|
||||
(house / "lock.txt").write_text("", encoding="utf-8")
|
||||
made = []
|
||||
stale = tmp_path / host.CANDIDATE_VENV
|
||||
stale.mkdir()
|
||||
(stale / "left-over").write_text("an earlier run", encoding="utf-8")
|
||||
python = host.candidate_python(environ={"RUNNER_TEMP": str(tmp_path)}, install=lambda h, v: made.append((h, v, v.exists())) or v / "bin" / "python")
|
||||
assert made == [(house, tmp_path / "candidate-set", False)], "directly under the temp root, with a name that never changes, and nothing of an earlier run in it"
|
||||
assert python == str(tmp_path / "candidate-set" / "bin" / "python")
|
||||
elsewhere = tmp_path / "elsewhere"
|
||||
elsewhere.mkdir()
|
||||
(elsewhere / "lock.txt").write_text("", encoding="utf-8")
|
||||
made.clear()
|
||||
host.candidate_python(environ={"RUNNER_TEMP": str(tmp_path), host.WHEELHOUSE_ENV: str(elsewhere)}, install=lambda h, v: made.append(h) or v)
|
||||
assert made == [elsewhere], "INVPW_WHEELHOUSE wins over the gate's default folder"
|
||||
|
||||
|
||||
def test_without_a_wheelhouse_the_candidate_runs_as_before_but_never_next_to_a_published_set(tmp_path):
|
||||
assert host.candidate_python(environ={}, install=lambda h, v: pytest.fail("no wheelhouse, nothing to install")) is None
|
||||
with pytest.raises(RuntimeError, match="candidate's venv cannot be made"):
|
||||
host.candidate_python(environ={host.oracle.PUBLISHED_PYTHON_ENV: "SET-PYTHON", "RUNNER_TEMP": str(tmp_path)}, install=lambda h, v: pytest.fail("no lock.txt"))
|
||||
|
||||
|
||||
# -
|
||||
# The retail capture and the rows it explains (scripts/ci_ab_retail.py).
|
||||
|
||||
retail = __import__("ci_ab_retail")
|
||||
|
||||
RETAIL_MUN = "d:\\a\\_temp\\ab-host\\engine\\systemresources\\firefox.exe.mun"
|
||||
PYTHON_LIB = "c:\\hostedtoolcache\\windows\\python\\3.11.9\\x64\\lib"
|
||||
FONTS = "c:\\windows\\fonts"
|
||||
CAPTURE = "captures/firefox-159.0/windows-server-2025/footprint-windowed/2026-12-02/footprint-retail.json"
|
||||
|
||||
|
||||
TEST_ROOT = "x:\\home-root" # not a form of any real profile folder: the root a recording run says is passed in, never typed as a path of this machine
|
||||
|
||||
|
||||
def a_retail_capture(files=(), kinds=None, launches=3, partial=(), mode=None):
|
||||
"""The document `retail` writes: `launches` measured launches, each with `files` and `kinds` (a path of `partial` only in the first launch); `mode` is what the capture on the core's
|
||||
hidden desktop says (`hidden desktop: ...`), none for the real window's."""
|
||||
seeds = []
|
||||
for index in range(launches):
|
||||
have = list(WIN_FILES) + [f for f in files if f not in partial or index == 0]
|
||||
seeds.append(seed_footprint(index, kinds=kinds or WIN_KINDS, files=have))
|
||||
return {"format": host.FORMAT, "engine": "retail windowed", "platform": "win32", "seeds": seeds, "problems": [], "xul_sha256": "a" * 64,
|
||||
"run": {"id": "123456", "sha": "b" * 40}, "build": {"sha256": "c" * 64, "build_id": "20261022150525"}, "user_root": TEST_ROOT,
|
||||
**({"mode": mode} if mode else {})}
|
||||
|
||||
|
||||
def a_candidate_diff(candidate_files, candidate_kinds=None, published_files=None):
|
||||
published = footprint(platform="win32", kinds=WIN_KINDS, files=published_files or WIN_FILES)
|
||||
candidate = footprint("candidate", platform="win32", kinds=candidate_kinds or WIN_KINDS, files=candidate_files)
|
||||
published["user_root"] = candidate["user_root"] = TEST_ROOT
|
||||
return judge(published, candidate, expected=[]), published, candidate
|
||||
|
||||
|
||||
def test_the_retail_profile_has_the_prefs_that_keep_the_welcome_page_and_the_default_browser_question_out():
|
||||
text = retail.user_js()
|
||||
assert 'user_pref("browser.aboutwelcome.enabled", false);\n' in text and 'user_pref("browser.shell.checkDefaultBrowser", false);\n' in text
|
||||
assert text.count("user_pref") == len(retail.RETAIL_PREFS)
|
||||
|
||||
|
||||
def test_the_browser_parent_is_the_oldest_firefox_without_contentproc_that_names_the_profile():
|
||||
class P:
|
||||
def __init__(self, name, cmd, born, pid):
|
||||
self._name, self._cmd, self._born, self.pid = name, cmd, born, pid
|
||||
|
||||
def name(self):
|
||||
return self._name
|
||||
|
||||
def cmdline(self):
|
||||
return self._cmd
|
||||
|
||||
def create_time(self):
|
||||
return self._born
|
||||
|
||||
profile = Path("work/profile")
|
||||
processes = [P("firefox.exe", ["firefox.exe", "-contentproc", "-profile", str(profile)], 1, 10), P("firefox.exe", ["firefox.exe", "-profile", "other"], 2, 11),
|
||||
P("firefox.exe", ["firefox.exe", "-profile", str(profile)], 5, 12), P("firefox.exe", ["firefox.exe", "-profile", str(profile)], 4, 13),
|
||||
P("python.exe", ["python.exe", str(profile)], 0, 14)]
|
||||
assert retail.browser_parent_of(profile, processes) == 13
|
||||
assert retail.browser_parents_of(profile, processes) == [13, 12], "the launcher and the browser it starts: the window is the younger one's, so the close is asked of both"
|
||||
assert retail.browser_parent_of(profile, processes[:2]) is None
|
||||
|
||||
|
||||
def test_wait_for_gives_the_value_as_soon_as_it_is_there_and_none_when_the_limit_runs_out():
|
||||
clock = [0.0]
|
||||
calls = []
|
||||
assert retail.wait_for(lambda: calls.append(1) or (len(calls) >= 3 and "up"), 10, sleep=lambda s: clock.__setitem__(0, clock[0] + s), now=lambda: clock[0]) == "up"
|
||||
clock[0] = 0.0
|
||||
assert retail.wait_for(lambda: None, 2, period=1, sleep=lambda s: clock.__setitem__(0, clock[0] + s), now=lambda: clock[0]) is None and clock[0] == 2.0
|
||||
|
||||
|
||||
def test_the_last_stage_of_the_lab_page_is_the_request_of_its_stylesheet_ld3():
|
||||
state = types.SimpleNamespace(records=[{"ev": "request", "path": "/"}, {"ev": "request", "path": "/r?kind=css&id=ld2"}])
|
||||
assert not retail.last_stage_served(state)
|
||||
state.records.append({"ev": "request", "path": "/r?kind=css&id=ld3"})
|
||||
assert retail.last_stage_served(state)
|
||||
|
||||
|
||||
def test_a_difference_retail_windowed_also_shows_becomes_a_row_with_its_source_and_the_rest_is_listed():
|
||||
report, _published, _candidate = a_candidate_diff(WIN_FILES + [DWMAPI, RETAIL_MUN, PYTHON_LIB], dict(WIN_KINDS, gpu=1))
|
||||
document = a_retail_capture(files=[DWMAPI, "d:\\other\\work\\ab-host\\engine\\systemresources\\firefox.exe.mun"], kinds=dict(WIN_KINDS, gpu=1))
|
||||
rows, undeclared = retail.derive(report, document, CAPTURE)
|
||||
assert sorted(r["id"] for r in rows) == sorted(["file-c-windows-system32-dwmapi-dll", "file-engine-systemresources-firefox-exe-mun", "proc-gpu"])
|
||||
by_name = {r["name"]: r for r in rows}
|
||||
assert by_name[DWMAPI]["published"] == "absent" and by_name[DWMAPI]["candidate"] == "present" and by_name[DWMAPI]["os"] == "windows"
|
||||
assert "<engine>\\systemresources\\firefox.exe.mun" in by_name and by_name["gpu"]["category"] == "proc"
|
||||
for row in rows:
|
||||
assert row["reason"] == "real window, decided 01/12"
|
||||
assert row["source"] == {"capture": CAPTURE, "run_id": "123456", "xul_sha256": "a" * 64, "installer_sha256": "c" * 64, "build_id": "20261022150525"}
|
||||
assert [u["leaf"] for u in undeclared] == ["file." + PYTHON_LIB] and "does not have it" in undeclared[0]["why"] and undeclared[0]["retail_launches_with_it"] == "0/3"
|
||||
|
||||
|
||||
def test_the_derived_rows_cover_exactly_their_differences_in_the_judge():
|
||||
report, published, candidate = a_candidate_diff(WIN_FILES + [DWMAPI, RETAIL_MUN, PYTHON_LIB], dict(WIN_KINDS, gpu=1))
|
||||
rows, undeclared = retail.derive(report, a_retail_capture(files=[DWMAPI, RETAIL_MUN], kinds=dict(WIN_KINDS, gpu=1)), CAPTURE)
|
||||
again = judge(published, candidate, expected=rows)
|
||||
assert again["stale"] == [] and {d["leaf"] for d in again["differences"]} == {u["leaf"] for u in undeclared} == {"file." + PYTHON_LIB}
|
||||
assert {d["leaf"] for d in again["declared"]} == {"file." + DWMAPI, "file." + RETAIL_MUN, "proc.gpu"}
|
||||
|
||||
|
||||
def test_a_path_only_the_published_engine_reads_is_a_row_only_when_retail_windowed_does_not_read_it_either():
|
||||
only_published = "c:\\windows\\system32\\winhttp.dll"
|
||||
report, _p, _c = a_candidate_diff(WIN_FILES, published_files=WIN_FILES + [only_published])
|
||||
rows, undeclared = retail.derive(report, a_retail_capture(files=[]), CAPTURE)
|
||||
assert [(r["name"], r["published"], r["candidate"]) for r in rows] == [(only_published, "present", "absent")] and undeclared == []
|
||||
rows, undeclared = retail.derive(report, a_retail_capture(files=[only_published]), CAPTURE)
|
||||
assert rows == [] and [u["leaf"] for u in undeclared] == ["file." + only_published] and "retail windowed has it, the candidate does not have it" in undeclared[0]["why"]
|
||||
|
||||
|
||||
JUMP_LIST = TEST_ROOT + "\\runneradmin\\appdata\\roaming\\microsoft\\windows\\recent\\customdestinations"
|
||||
HIDDEN_MODE = "hidden desktop: invisible_core._headless.make_virtual_display() of the published core"
|
||||
MSCTFMONITOR = "c:\\windows\\system32\\msctfmonitor.dll"
|
||||
MSUTB = "c:\\windows\\system32\\msutb.dll"
|
||||
|
||||
|
||||
def test_the_fonts_folder_the_candidate_lacks_is_undeclared_by_the_rule_of_every_path_where_retail_has_it_on_either_desktop():
|
||||
"""c:\\windows\\fonts was refused by name as "the sandbox level" (content level 4 did not open it). The core now gives content level 9 and GPU level 2 (core e72/hidden-desktop-label, 69a185796d), and run
|
||||
46929884829 shows the parent opening the folder again, as retail does 3/3 on the hidden desktop (run 46903007316): no desktop and no sandbox level explains a miss any more, so the path has no rule of its own."""
|
||||
assert not hasattr(retail, "HIDDEN_DESKTOP")
|
||||
report, _p, _c = a_candidate_diff(WIN_FILES, published_files=WIN_FILES + [FONTS])
|
||||
for mode, hidden in ((None, False), (HIDDEN_MODE, True)):
|
||||
rows, undeclared = retail.derive(report, a_retail_capture(files=[FONTS], mode=mode), CAPTURE, hidden_desktop=hidden)
|
||||
assert rows == [] and [u["leaf"] for u in undeclared] == ["file." + FONTS]
|
||||
assert "retail windowed has it, the candidate does not have it" in undeclared[0]["why"] and "cost" not in undeclared[0] and "sandbox" not in undeclared[0]["why"]
|
||||
|
||||
|
||||
def test_what_retail_shows_on_the_hidden_desktop_is_a_row_with_the_reason_hidden_desktop_in_both_directions_for_a_file():
|
||||
report, published, candidate = a_candidate_diff(WIN_FILES + [MSCTFMONITOR, MSUTB], published_files=WIN_FILES + [JUMP_LIST])
|
||||
document = a_retail_capture(files=[MSCTFMONITOR, MSUTB], mode=HIDDEN_MODE)
|
||||
rows, undeclared = retail.derive(report, document, CAPTURE, hidden_desktop=True)
|
||||
assert undeclared == [] and {r["reason"] for r in rows} == {"hidden desktop"}
|
||||
assert {(r["name"], r["published"], r["candidate"]) for r in rows} == {
|
||||
(MSCTFMONITOR, "absent", "present"), (MSUTB, "absent", "present"),
|
||||
("<profile>\\appdata\\roaming\\microsoft\\windows\\recent\\customdestinations", "present", "absent")}
|
||||
again = judge(published, candidate, expected=rows)
|
||||
assert again["stale"] == [] and again["differences"] == [] and len({d["leaf"] for d in again["declared"]}) == 3
|
||||
|
||||
|
||||
def test_the_jump_list_the_candidate_lacks_stays_undeclared_where_retail_has_it_whichever_the_desktop():
|
||||
report, _p, _c = a_candidate_diff(WIN_FILES, published_files=WIN_FILES + [JUMP_LIST])
|
||||
for mode, hidden in ((None, False), (HIDDEN_MODE, True)):
|
||||
rows, undeclared = retail.derive(report, a_retail_capture(files=[JUMP_LIST], mode=mode), CAPTURE, hidden_desktop=hidden)
|
||||
assert rows == [] and "retail windowed has it, the candidate does not have it" in undeclared[0]["why"] and undeclared[0]["retail_launches_with_it"] == "3/3"
|
||||
|
||||
|
||||
def test_the_reason_of_a_row_is_the_captures_own_a_hidden_desktop_capture_is_never_a_real_window_and_the_other_way_round():
|
||||
report, _p, _c = a_candidate_diff(WIN_FILES + [DWMAPI])
|
||||
with pytest.raises(ValueError, match="hidden-desktop capture"):
|
||||
retail.derive(report, a_retail_capture(files=[DWMAPI], mode=HIDDEN_MODE), CAPTURE)
|
||||
with pytest.raises(ValueError, match="hidden-desktop capture"):
|
||||
retail.derive(report, a_retail_capture(files=[DWMAPI]), CAPTURE, hidden_desktop=True)
|
||||
|
||||
|
||||
def test_a_path_retail_windowed_has_in_some_launches_only_is_left_undeclared_whichever_way_it_goes():
|
||||
report, _p, _c = a_candidate_diff(WIN_FILES + [DWMAPI])
|
||||
rows, undeclared = retail.derive(report, a_retail_capture(files=[DWMAPI], partial=[DWMAPI]), CAPTURE)
|
||||
assert rows == [] and undeclared[0]["retail_launches_with_it"] == "1/3" and "1 of 3 launches" in undeclared[0]["why"]
|
||||
|
||||
|
||||
def test_a_leaf_that_differs_the_other_way_in_one_seed_is_undeclared_and_a_capture_without_launches_is_refused():
|
||||
report, _p, _c = a_candidate_diff(WIN_FILES + [DWMAPI])
|
||||
mixed = {"differences": [dict(report["differences"][0]), dict(report["differences"][1], a=1, b=host.MISSING)]}
|
||||
mixed["differences"][1]["leaf"] = mixed["differences"][0]["leaf"]
|
||||
rows, undeclared = retail.derive(mixed, a_retail_capture(files=[DWMAPI]), CAPTURE)
|
||||
assert rows == [] and "not the same in every seed" in undeclared[0]["why"]
|
||||
with pytest.raises(ValueError, match="no measured launch"):
|
||||
retail.derive(report, a_retail_capture(launches=0), CAPTURE)
|
||||
|
||||
|
||||
def test_derive_writes_the_rows_into_the_expected_file_and_replaces_a_row_of_the_same_id(tmp_path):
|
||||
report, _p, _c = a_candidate_diff(WIN_FILES + [DWMAPI])
|
||||
paths = {"diff": tmp_path / "diff.json", "retail": tmp_path / "retail.json", "expected": tmp_path / "expected.json"}
|
||||
paths["diff"].write_text(json.dumps(report), encoding="utf-8")
|
||||
paths["retail"].write_text(json.dumps(a_retail_capture(files=[DWMAPI])), encoding="utf-8")
|
||||
paths["expected"].write_text(json.dumps({"format": host.EXPECTED_FORMAT, "differences": [{"id": "file-c-windows-system32-dwmapi-dll", "old": True}]}), encoding="utf-8")
|
||||
argv = ["derive", "--diff", str(paths["diff"]), "--retail", str(paths["retail"]), "--capture", CAPTURE, "--expected", str(paths["expected"]), "--write"]
|
||||
assert retail.main(argv) == 0
|
||||
written = host.load_expected(paths["expected"])
|
||||
assert [r["id"] for r in written] == ["file-c-windows-system32-dwmapi-dll"] and "old" not in written[0] and written[0]["source"]["capture"] == CAPTURE
|
||||
|
||||
|
||||
def test_derive_with_hidden_desktop_writes_rows_with_that_reason_and_refuses_a_capture_that_is_not_one(tmp_path):
|
||||
report, _p, _c = a_candidate_diff(WIN_FILES + [MSUTB])
|
||||
paths = {"diff": tmp_path / "diff.json", "retail": tmp_path / "retail.json", "expected": tmp_path / "expected.json"}
|
||||
paths["diff"].write_text(json.dumps(report), encoding="utf-8")
|
||||
paths["retail"].write_text(json.dumps(a_retail_capture(files=[MSUTB], mode=HIDDEN_MODE)), encoding="utf-8")
|
||||
paths["expected"].write_text(json.dumps({"format": host.EXPECTED_FORMAT, "differences": []}), encoding="utf-8")
|
||||
argv = ["derive", "--diff", str(paths["diff"]), "--retail", str(paths["retail"]), "--capture", CAPTURE, "--expected", str(paths["expected"]), "--write"]
|
||||
with pytest.raises(ValueError, match="hidden-desktop capture"):
|
||||
retail.main(argv)
|
||||
assert retail.main(argv + ["--hidden-desktop"]) == 0
|
||||
assert [(r["name"], r["reason"]) for r in host.load_expected(paths["expected"])] == [(MSUTB, "hidden desktop")]
|
||||
|
||||
|
||||
def test_the_capture_runs_a_warm_up_and_the_measured_launches_and_names_what_it_ran(tmp_path, monkeypatch):
|
||||
made = []
|
||||
|
||||
def fake_seed(binary, index, work, name, audit_dir=None):
|
||||
made.append((index, name))
|
||||
return {"seed": index, "kinds": dict(WIN_KINDS), "files": list(WIN_FILES), "problems": ["it did not close"] if name == "warmup" else []}
|
||||
|
||||
monkeypatch.setattr(retail, "run_retail_seed", fake_seed)
|
||||
document = retail.run_retail("C:\\stage\\firefox.exe", "windows-x86_64", 2, "retail windowed")
|
||||
assert made == [(0, "warmup"), (0, "measured0"), (1, "measured1")] and [s["seed"] for s in document["seeds"]] == [0, 1]
|
||||
assert document["problems"] == ["warm-up: it did not close"] and document["platform"] == sys.platform and document["prefs"] == retail.RETAIL_PREFS
|
||||
|
||||
|
||||
def test_the_capture_is_refused_off_windows_and_without_a_binary(tmp_path, monkeypatch):
|
||||
args = types.SimpleNamespace(binary=str(tmp_path / "none" / "firefox.exe"), leg="windows-x86_64", out=tmp_path / "o.json", build=None, launches=1, label="retail")
|
||||
if sys.platform == "win32":
|
||||
assert retail.capture(args) == 2
|
||||
monkeypatch.setattr(retail.sys, "platform", "linux")
|
||||
assert retail.capture(args) == 3
|
||||
|
||||
|
||||
# -
|
||||
# The host only rows of the A/B of Linux (scripts/ci_ab_retail.py host-only).
|
||||
|
||||
LINUX_DIFF = Path(__file__).resolve().parent / "data" / "ab_host_linux" / "diff-47107160488.json"
|
||||
LINUX_RUN = "47107160488"
|
||||
|
||||
|
||||
def linux_rows():
|
||||
return [r for r in host.load_expected() if r["os"] == "linux"]
|
||||
|
||||
|
||||
def linux_diff():
|
||||
return json.loads(LINUX_DIFF.read_text(encoding="utf-8"))
|
||||
|
||||
|
||||
def test_the_host_only_rows_are_pinned_per_cause_and_each_names_its_run_and_its_diff():
|
||||
rows = linux_rows()
|
||||
causes = {}
|
||||
for r in rows:
|
||||
causes[r["note"]] = causes.get(r["note"], 0) + 1
|
||||
assert causes == {retail.NOTE_GTK_SETTINGS: 2, retail.NOTE_FONTCONFIG: 91, retail.NOTE_XDG: 1, retail.NOTE_NOT_TRACED: 10}, "2 + 91 + 1 + 10 = 104: the count of each cause is pinned"
|
||||
assert len(rows) == HOST_ONLY_LINUX_ROWS == sum(causes.values())
|
||||
assert {r["reason"] for r in rows} == {"host only"} and {r["category"] for r in rows} == {"file"}
|
||||
assert len({r["id"] for r in rows}) == len({r["name"] for r in rows}) == len(rows), "one row per normalised leaf"
|
||||
assert {r["source"]["run_id"] for r in rows} == {LINUX_RUN} and {r["source"]["diff"] for r in rows} == {"diff.json"}
|
||||
assert {r["source"]["diff_sha256"] for r in rows} == {retail.sha256_file(LINUX_DIFF)}, "the rows come from the bytes of the diff the repository holds"
|
||||
assert {r["note"] for r in rows if r["name"].endswith("settings.ini")} == {retail.NOTE_GTK_SETTINGS} and "nsXPLookAndFeel.cpp:1024/:1035/:1087" in retail.NOTE_GTK_SETTINGS
|
||||
assert "bddc7de757" in retail.NOTE_FONTCONFIG and "#384" in retail.NOTE_XDG
|
||||
assert {(r["published"], r["candidate"]) for r in rows if r["note"] == retail.NOTE_GTK_SETTINGS} == {("absent", "present")}
|
||||
assert {(r["published"], r["candidate"]) for r in rows if r["note"] in (retail.NOTE_FONTCONFIG, retail.NOTE_XDG)} == {("present", "absent")}
|
||||
by_name = {r["name"]: r["note"] for r in rows}
|
||||
assert by_name["<profile>\\.config\\mozilla\\firefox\\Crash Reports"] == by_name["<profile>\\.config\\mozilla\\firefox\\Pending Pings"] == by_name["\\proc\\self"] == retail.NOTE_NOT_TRACED
|
||||
assert by_name["<profile>\\.config"] == by_name["<profile>\\.fonts.conf.d"] == by_name["\\usr\\share\\fontconfig\\conf.avail"] == retail.NOTE_FONTCONFIG
|
||||
|
||||
|
||||
def test_the_host_only_rows_are_what_the_script_writes_from_the_diff_not_typed(tmp_path):
|
||||
derived, refused = retail.derive_host_only(linux_diff(), LINUX_RUN, retail.sha256_file(LINUX_DIFF))
|
||||
assert refused == [] and derived == linux_rows(), "the rows of ci/ab-host-expected.json are the script's output on the diff: rerun `ci_ab_retail.py host-only --write`"
|
||||
expected_file = tmp_path / "expected.json"
|
||||
expected_file.write_text(json.dumps({"format": host.EXPECTED_FORMAT, "differences": [{"id": "windows-row", "os": "windows"}]}), encoding="utf-8")
|
||||
assert retail.main(["host-only", "--diff", str(LINUX_DIFF), "--run-id", LINUX_RUN, "--expected", str(expected_file), "--write"]) == 0
|
||||
written = host.load_expected(expected_file)
|
||||
assert written[0]["id"] == "windows-row" and written[1:] == linux_rows(), "the Windows rows stay, the host only rows follow"
|
||||
assert retail.main(["host-only", "--diff", str(LINUX_DIFF), "--run-id", LINUX_RUN, "--expected", str(expected_file), "--write"]) == 0
|
||||
assert host.load_expected(expected_file) == written, "a second run replaces the rows of the same id"
|
||||
|
||||
|
||||
def test_a_leaf_no_rule_names_refuses_the_whole_run_and_writes_nothing(tmp_path, capsys):
|
||||
diff = linux_diff()
|
||||
diff["differences"] += [{"seed": seed, "category": "file", "leaf": "file./etc/passwd", "a": 1, "b": host.MISSING, "by": {"A": ["parent"], "B": []}, "calls": {"A": ["access"], "B": []}}
|
||||
for seed in sorted({d["seed"] for d in diff["differences"]})]
|
||||
rows, refused = retail.derive_host_only(diff, LINUX_RUN, "0" * 64)
|
||||
assert [(e["leaf"], e["why"]) for e in refused] == [("file./etc/passwd", "no rule names it")] and len(rows) == HOST_ONLY_LINUX_ROWS, "no blanket row: the others are derived, that one is refused"
|
||||
diff_path, expected_file = tmp_path / "diff.json", tmp_path / "expected.json"
|
||||
diff_path.write_text(json.dumps(diff), encoding="utf-8")
|
||||
before = json.dumps({"format": host.EXPECTED_FORMAT, "differences": []})
|
||||
expected_file.write_text(before, encoding="utf-8")
|
||||
assert retail.main(["host-only", "--diff", str(diff_path), "--run-id", LINUX_RUN, "--expected", str(expected_file), "--write"]) == 2
|
||||
assert expected_file.read_text(encoding="utf-8") == before, "a refused run writes nothing"
|
||||
out = capsys.readouterr().out
|
||||
assert "REFUSED file./etc/passwd" in out and "no rule names it" in out and "nothing written" in out
|
||||
|
||||
|
||||
def test_a_leaf_a_rule_names_in_the_other_direction_or_in_some_seeds_only_or_that_is_not_a_path_is_refused():
|
||||
diff = linux_diff()
|
||||
seeds = sorted({d["seed"] for d in diff["differences"]})
|
||||
fonts = [d for d in diff["differences"] if d["leaf"] == "file./etc/fonts/fonts.conf"]
|
||||
flipped = [dict(d, a=d["b"], b=d["a"]) if d["leaf"] == "file./etc/fonts/fonts.conf" else d for d in diff["differences"]]
|
||||
rows, refused = retail.derive_host_only(dict(diff, differences=flipped), LINUX_RUN, "0" * 64)
|
||||
assert [e["leaf"] for e in refused] == ["file./etc/fonts/fonts.conf"] and "not as published absent, candidate present" in refused[0]["why"] and len(rows) == HOST_ONLY_LINUX_ROWS - 1
|
||||
some = [d for d in diff["differences"] if not (d["leaf"] == "file./etc/fonts/fonts.conf" and d["seed"] == seeds[-1])]
|
||||
rows, refused = retail.derive_host_only(dict(diff, differences=some), LINUX_RUN, "0" * 64)
|
||||
assert [e["leaf"] for e in refused] == ["file./etc/fonts/fonts.conf"] and "not the same in every seed" in refused[0]["why"] and len(fonts) == len(seeds)
|
||||
proc = diff["differences"] + [dict(d, category="proc", leaf="proc.gfxtest") for d in fonts]
|
||||
rows, refused = retail.derive_host_only(dict(diff, differences=proc), LINUX_RUN, "0" * 64)
|
||||
assert [e["leaf"] for e in refused] == ["proc.gfxtest"] and "not a path" in refused[0]["why"]
|
||||
with pytest.raises(ValueError, match="not an A/B verdict"):
|
||||
retail.derive_host_only(dict(diff, mode="a-a"), LINUX_RUN, "0" * 64)
|
||||
|
||||
|
||||
def test_a_path_under_the_home_folder_is_named_only_when_the_run_says_its_user_root():
|
||||
diff = linux_diff()
|
||||
# The fixture names the runner's /home/ as /var/ (the reduction in tests/data/ab_host_linux/SOURCES.md): the user root of the run is that folder.
|
||||
assert diff["user_root"] == "\\var", "the A/B of Linux says where the profile folders are: that is what turns the runner's home into <profile>"
|
||||
rows, refused = retail.derive_host_only(dict(diff, user_root=None), LINUX_RUN, "0" * 64)
|
||||
assert {e["leaf"].split("/")[1] for e in refused} == {"var"} and len(refused) == 11 and len(rows) == HOST_ONLY_LINUX_ROWS - 11
|
||||
|
||||
|
||||
def test_the_host_only_rows_cover_every_difference_of_the_diff_and_none_is_stale():
|
||||
diff = linux_diff()
|
||||
rows = linux_rows()
|
||||
covered = {r["id"]: [d for d in diff["differences"] if host._declared_covers(r, d, (), diff["user_root"])] for r in rows}
|
||||
assert all(len(hits) == len({d["seed"] for d in diff["differences"]}) for hits in covered.values()), "each row shows in every seed: none is stale"
|
||||
left = [d for d in diff["differences"] if not any(d in hits for hits in covered.values())]
|
||||
assert left == [] and sum(len(h) for h in covered.values()) == len(diff["differences"]) == 520, "0 undeclared: 104 leaves, 5 seeds, 520 differences, each covered by one row"
|
||||
|
||||
@@ -259,7 +259,10 @@ def run_ab(tmp_path, monkeypatch, docs):
|
||||
monkeypatch.setattr(host, "run_subprocess", fake_run)
|
||||
monkeypatch.setattr(host, "FLOORS", SMALL)
|
||||
monkeypatch.setattr(host, "run_stock_control", lambda leg, out: {"stock": True})
|
||||
return host.ab(cand, Path("seal"), "win-x86_64", tmp_path / "o", "firefox-68", list(SEEDS))
|
||||
# A unit case hands in its own declared differences (none), never the rows of the real ci/ab-host-expected.json, which are stale against synthetic footprints.
|
||||
expected = tmp_path / "expected.json"
|
||||
expected.write_text(json.dumps({"format": host.EXPECTED_FORMAT, "differences": []}), encoding="utf-8")
|
||||
return host.ab(cand, Path("seal"), "win-x86_64", tmp_path / "o", "firefox-68", list(SEEDS), expected_file=expected)
|
||||
|
||||
|
||||
def test_the_not_judged_list_is_a_file_of_its_own_next_to_the_verdict_of_the_a_a_and_of_the_a_b(tmp_path, monkeypatch):
|
||||
|
||||
+77
-11
@@ -2056,13 +2056,16 @@ def test_the_main_launch_waits_for_glean_after_the_journey_and_before_the_rest_o
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------------------- the guard that kills the whole tree
|
||||
#: The oracle of the test: it writes the line of a launch, starts a grandchild that inherits its stdout and sleeps, and sleeps itself. The grandchild is the firefox that holds the pipe.
|
||||
#: The pid file is written as soon as the grandchild exists, and the launch line and "the grandchild is alive" come after it. ``sys.argv[3]`` is the time the child takes
|
||||
#: before it makes the tree (a loaded machine starts a child late; here the delay is forced). The clock of the guards below begins at the pid file.
|
||||
_TREE_CHILD = '''
|
||||
import subprocess, sys, time
|
||||
sys.path.insert(0, sys.argv[2])
|
||||
import ci_crash_evidence as crash
|
||||
print(crash.launch_line(11, "exit-pings", "firefox-68-again"), flush=True)
|
||||
time.sleep(float(sys.argv[3]))
|
||||
grandchild = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(60)"])
|
||||
open(sys.argv[1], "w").write(str(grandchild.pid))
|
||||
print(crash.launch_line(11, "exit-pings", "firefox-68-again"), flush=True)
|
||||
print("the grandchild is alive", flush=True)
|
||||
time.sleep(60)
|
||||
'''
|
||||
@@ -2095,19 +2098,75 @@ def _kill_if_alive(pid):
|
||||
pass
|
||||
|
||||
|
||||
def _tree_command(tmp_path):
|
||||
def _tree_command(tmp_path, delay):
|
||||
pidfile = tmp_path / "grandchild.pid"
|
||||
return [sys.executable, "-u", "-c", _TREE_CHILD, str(pidfile), str(ROOT / "scripts")], pidfile
|
||||
return [sys.executable, "-u", "-c", _TREE_CHILD, str(pidfile), str(ROOT / "scripts"), str(delay)], pidfile
|
||||
|
||||
|
||||
def test_the_old_guard_leaves_the_grandchild_alive_and_on_windows_does_not_even_return_at_the_timeout(tmp_path):
|
||||
class _ClockOfTheTree:
|
||||
"""The clock ``run_tree`` reads, standing still until the tree exists and running from then on.
|
||||
|
||||
``run_tree`` starts its clock at ``Popen``, before the child has made its grandchild; on a loaded machine the child is late and the timeout fires on a tree that was
|
||||
never made (the pid file never exists). With this clock the time the guard counts is the time of the tree. The tree exists when its pid file is there and the
|
||||
child's words ("the grandchild is alive", after its launch line) are in the output ``run_tree`` keeps in ``stdout_path``; the clock then runs from the moment of the
|
||||
pid file (its mtime), which is before the launch line, so what the launch line allows (``_assert_alive_since_its_line``) is within what this clock has counted.
|
||||
``delay`` in the tests is how late the child is: it passes in the host's time, not in this clock's. Only ``monotonic`` is this clock's; the rest of ``time`` is
|
||||
the real one."""
|
||||
|
||||
def __init__(self, pidfile, stdout_path):
|
||||
self.pidfile, self.stdout_path = pidfile, stdout_path
|
||||
self.ran_from = None
|
||||
|
||||
def _the_tree_exists(self):
|
||||
try:
|
||||
return self.pidfile.is_file() and "the grandchild is alive" in self.stdout_path.read_text(encoding="utf-8", errors="replace")
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
def monotonic(self):
|
||||
if self.ran_from is None:
|
||||
if not self._the_tree_exists():
|
||||
return 0.0
|
||||
self.ran_from = time.monotonic() - max(0.0, time.time() - self.pidfile.stat().st_mtime)
|
||||
return time.monotonic() - self.ran_from
|
||||
|
||||
def __getattr__(self, name):
|
||||
return getattr(time, name)
|
||||
|
||||
|
||||
#: ``delay``: how long the child takes before it makes its tree. 0 is the machine at rest; 4 is the forced case: longer than the 3 s of the guards, so a clock that begins at
|
||||
#: ``Popen`` has run out before the tree exists.
|
||||
DELAYS = pytest.mark.parametrize("delay", [0, 4])
|
||||
|
||||
|
||||
@DELAYS
|
||||
@pytest.mark.timeout(120, method="thread")
|
||||
def test_the_old_guard_leaves_the_grandchild_alive_and_on_windows_does_not_even_return_at_the_timeout(tmp_path, monkeypatch, delay):
|
||||
"""The defect, shown: `subprocess.run(capture_output=True, timeout=...)` kills the child alone. The grandchild lives; on Windows `run` then waits for the pipe it holds
|
||||
(run 45121964904, Windows, job.log 546-557), here until we kill it."""
|
||||
(run 45121964904, Windows, job.log 546-557), here until we kill it.
|
||||
|
||||
The timeout of ``run`` begins when its ``communicate`` is called, at ``Popen``: a child that makes its tree late is killed before it has one. ``communicate`` here
|
||||
waits for the pid file before it counts its timeout, so the 3 s are the tree's; and the guard's kill is the event the test waits for, not a duration."""
|
||||
import subprocess
|
||||
import threading
|
||||
|
||||
command, pidfile = _tree_command(tmp_path)
|
||||
command, pidfile = _tree_command(tmp_path, delay)
|
||||
outcome = {}
|
||||
killed = threading.Event()
|
||||
communicate, kill = subprocess.Popen.communicate, subprocess.Popen.kill
|
||||
|
||||
def communicate_when_the_tree_exists(self, input=None, timeout=None):
|
||||
if timeout is not None:
|
||||
while not pidfile.is_file():
|
||||
time.sleep(0.01)
|
||||
return communicate(self, input, timeout)
|
||||
|
||||
def kill_and_say_so(self):
|
||||
kill(self)
|
||||
killed.set()
|
||||
|
||||
monkeypatch.setattr(subprocess.Popen, "communicate", communicate_when_the_tree_exists)
|
||||
monkeypatch.setattr(subprocess.Popen, "kill", kill_and_say_so)
|
||||
|
||||
def old():
|
||||
try:
|
||||
@@ -2117,8 +2176,8 @@ def test_the_old_guard_leaves_the_grandchild_alive_and_on_windows_does_not_even_
|
||||
|
||||
thread = threading.Thread(target=old, daemon=True)
|
||||
thread.start()
|
||||
thread.join(3 + 5)
|
||||
try:
|
||||
killed.wait()
|
||||
assert pidfile.is_file(), "the child did not get to start its grandchild"
|
||||
grandchild = int(pidfile.read_text())
|
||||
assert _alive(grandchild), "the grandchild outlives the timeout of the old guard"
|
||||
@@ -2130,14 +2189,21 @@ def test_the_old_guard_leaves_the_grandchild_alive_and_on_windows_does_not_even_
|
||||
thread.join(15)
|
||||
|
||||
|
||||
def test_the_tree_guard_returns_at_the_timeout_kills_the_grandchild_and_names_the_launch_that_was_alive(tmp_path):
|
||||
@DELAYS
|
||||
@pytest.mark.timeout(120, method="thread")
|
||||
def test_the_tree_guard_returns_at_the_timeout_kills_the_grandchild_and_names_the_launch_that_was_alive(tmp_path, monkeypatch, delay):
|
||||
"""``run_tree`` counts its timeout from the tree it was given, not from the instant it started a child that may be late: its ``time`` is the clock of the tree
|
||||
(``_ClockOfTheTree``), which does not run before the pid file exists. ``spent`` is read on that same clock, so it is what the guard spent on a tree that existed.
|
||||
A tree that is never made is no verdict of this test: ``pytest.mark.timeout`` ends it."""
|
||||
import ci_crash_evidence as crash
|
||||
|
||||
command, pidfile = _tree_command(tmp_path)
|
||||
began = time.monotonic()
|
||||
command, pidfile = _tree_command(tmp_path, delay)
|
||||
clock = _ClockOfTheTree(pidfile, tmp_path / "out" / "run-tree.stdout")
|
||||
monkeypatch.setattr(crash, "time", clock)
|
||||
began = clock.monotonic()
|
||||
try:
|
||||
run = crash.run_tree(command, tmp_path / "out", timeout_s=3)
|
||||
spent = time.monotonic() - began
|
||||
spent = clock.monotonic() - began
|
||||
assert run.timed_out and run.returncode is None
|
||||
assert spent < 3 + 5, "it returned a few seconds after the timeout, not when the grandchild would have ended (%.1f s)" % spent
|
||||
grandchild = int(pidfile.read_text())
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
"""The page oracle's declared differences (ci/ab-oracle-expected.json), judged against the run of the engine's final candidate (run 46227711139, Linux and Windows).
|
||||
"""The page oracle's declared differences (ci/ab-oracle-expected.json), judged against the runs of the engine's final candidate (run 46227711139 and candidate run 46792115974, Linux and Windows).
|
||||
|
||||
That run's A/B was red on 24 differences per system, all of them the bar of the main window above the content: seed 6 at 1.25 (106 device px as retail Firefox 159 measures it,
|
||||
the published engine's core said 107) and seed 63 at 1.5 (the compact density that retail picks by itself under 720 CSS px, 73 CSS px instead of the normal 85). The DIFF lines
|
||||
of that run are the data below, the same on both systems. The judge allows a difference only when a row of the file matches it exactly, is red on any other, red on a row that
|
||||
does not show (stale), and never applies the rows to the A/A.
|
||||
|
||||
The A/B of run 46792115974 was red on 12 more differences per system, the same on both: the system colors Highlight and SelectedItem, rgb(0, 120, 215) on the published engine
|
||||
and rgb(0, 120, 212) on the candidate, which is what retail Firefox 159 reads on Windows 11 builds 26100 and 26200.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -52,8 +55,22 @@ DIFF seed 63 dpr 1.5 leaf surface.visualViewport.height: firefox-70 587.33331298
|
||||
DIFF seed 63 dpr 1.5 leaf surface.window.innerHeight: firefox-70 587 | candidate 599
|
||||
DIFF seed 63 dpr 1.5 leaf surface.window.mozInnerScreenY: firefox-70 84.66666412353516 | candidate 72.66666412353516
|
||||
"""
|
||||
#: The 12 DIFF lines of the A/B of both systems in candidate run 46792115974 (identical on Linux and Windows), the ones left once the rows above were declared.
|
||||
COLORS = """DIFF seed 0 dpr 1.0 leaf relaunch.surface.systemColors.Highlight: firefox-70 "rgb(0, 120, 215)" | candidate "rgb(0, 120, 212)"
|
||||
DIFF seed 0 dpr 1.0 leaf relaunch.surface.systemColors.SelectedItem: firefox-70 "rgb(0, 120, 215)" | candidate "rgb(0, 120, 212)"
|
||||
DIFF seed 0 dpr 1.0 leaf surface.systemColors.Highlight: firefox-70 "rgb(0, 120, 215)" | candidate "rgb(0, 120, 212)"
|
||||
DIFF seed 0 dpr 1.0 leaf surface.systemColors.SelectedItem: firefox-70 "rgb(0, 120, 215)" | candidate "rgb(0, 120, 212)"
|
||||
DIFF seed 2 dpr 1.0 leaf surface.systemColors.Highlight: firefox-70 "rgb(0, 120, 215)" | candidate "rgb(0, 120, 212)"
|
||||
DIFF seed 2 dpr 1.0 leaf surface.systemColors.SelectedItem: firefox-70 "rgb(0, 120, 215)" | candidate "rgb(0, 120, 212)"
|
||||
DIFF seed 4 dpr 1.0 leaf surface.systemColors.Highlight: firefox-70 "rgb(0, 120, 215)" | candidate "rgb(0, 120, 212)"
|
||||
DIFF seed 4 dpr 1.0 leaf surface.systemColors.SelectedItem: firefox-70 "rgb(0, 120, 215)" | candidate "rgb(0, 120, 212)"
|
||||
DIFF seed 6 dpr 1.25 leaf surface.systemColors.Highlight: firefox-70 "rgb(0, 120, 215)" | candidate "rgb(0, 120, 212)"
|
||||
DIFF seed 6 dpr 1.25 leaf surface.systemColors.SelectedItem: firefox-70 "rgb(0, 120, 215)" | candidate "rgb(0, 120, 212)"
|
||||
DIFF seed 63 dpr 1.5 leaf surface.systemColors.Highlight: firefox-70 "rgb(0, 120, 215)" | candidate "rgb(0, 120, 212)"
|
||||
DIFF seed 63 dpr 1.5 leaf surface.systemColors.SelectedItem: firefox-70 "rgb(0, 120, 215)" | candidate "rgb(0, 120, 212)"
|
||||
"""
|
||||
_LINE = re.compile(r"^DIFF seed (\d+) dpr ([\d.]+) leaf (\S+): firefox-70 (.*) \| candidate (.*)$")
|
||||
DIFFS = [(int(m[1]), float(m[2]), m[3], json.loads(m[4]), json.loads(m[5])) for m in map(_LINE.match, TODAY.splitlines())]
|
||||
DIFFS = [(int(m[1]), float(m[2]), m[3], json.loads(m[4]), json.loads(m[5])) for m in map(_LINE.match, (TODAY + COLORS).splitlines())]
|
||||
|
||||
|
||||
def _put(items: dict, leaf: str, value) -> None:
|
||||
@@ -69,7 +86,7 @@ def _visit(seed: int, side: int | None) -> dict:
|
||||
engine, 1 the candidate)."""
|
||||
items = {"surface": {"navigator": {"hardwareConcurrency": 8, "language": "en-US"}, "screen": {"width": 1920, "height": 1080}}, "text": {"fonts": ["Arial", "Segoe UI"]}}
|
||||
for s, dpr, leaf, published, candidate in DIFFS:
|
||||
if s == seed:
|
||||
if s == seed and not leaf.startswith(gate.RELAUNCH): # a relaunch leaf is the second launch's copy of the first one's, made below
|
||||
_put(items, leaf, (published, candidate)[side])
|
||||
if seed == ab.RELAUNCH_SEED:
|
||||
items.update(copy.deepcopy(gate.relaunch_items(items)))
|
||||
@@ -97,31 +114,35 @@ def judge(published, candidate, os_name="linux", declared=None, expected=CANDIDA
|
||||
# Today's run, as data.
|
||||
|
||||
@pytest.mark.parametrize("os_name", ["linux", "windows"])
|
||||
def test_the_old_judge_is_red_on_the_24_differences_of_the_run_and_the_new_one_is_green_with_the_rows(os_name):
|
||||
def test_the_old_judge_is_red_on_the_36_differences_of_the_runs_and_the_new_one_is_green_with_the_rows(os_name):
|
||||
without = judge(dumps(0), dumps(1))
|
||||
assert without["verdict"] == "red" and len(without["differences"]) == 24
|
||||
assert without["verdict"] == "red" and len(without["differences"]) == 36
|
||||
assert {(d["seed"], d["dpr"], d["leaf"], json.dumps(d["a"]), json.dumps(d["b"])) for d in without["differences"]} == {(s, d, leaf, json.dumps(p), json.dumps(c)) for s, d, leaf, p, c in DIFFS}
|
||||
report = judge(dumps(0), dumps(1), os_name, declared=ab.load_expected(FILE))
|
||||
assert report["verdict"] == "green", report["problems"]
|
||||
assert len(report["declared"]) == 24 and report["differences"] == [] and report["stale"] == []
|
||||
assert len(report["declared"]) == 36 and report["differences"] == [] and report["stale"] == []
|
||||
|
||||
|
||||
def test_the_file_has_a_row_per_os_seed_and_leaf_of_the_run_with_its_two_values_and_exactly_the_keys():
|
||||
document = json.loads(FILE.read_text(encoding="utf-8"))
|
||||
assert document["format"] == "ab-oracle-expected/1"
|
||||
got = document["differences"]
|
||||
assert len(got) == 48
|
||||
assert len(got) == 72
|
||||
for row in got:
|
||||
assert sorted(row) == sorted(["id", "os", "seed", "dpr", "leaf", "published", "candidate", "reason"]), "no field that says who decided, nothing else"
|
||||
for os_name in ("linux", "windows"):
|
||||
assert sorted((r["seed"], r["dpr"], r["leaf"], json.dumps(r["published"]), json.dumps(r["candidate"])) for r in got if r["os"] == os_name) == \
|
||||
sorted((s, d, leaf, json.dumps(p), json.dumps(c)) for s, d, leaf, p, c in DIFFS)
|
||||
assert len({r["id"] for r in got}) == 48
|
||||
assert len({r["id"] for r in got}) == 72
|
||||
|
||||
|
||||
def test_every_row_says_the_retail_source_the_core_function_and_the_leaf():
|
||||
for row in ab.load_expected(FILE):
|
||||
reason = row["reason"]
|
||||
if "systemColors" in row["leaf"]:
|
||||
assert "nsLookAndFeel.cpp:188" in reason and "captures/firefox-159.0/windows-server-2025/syscolors/2026-12-01" in reason, row["id"]
|
||||
assert "captures/firefox-159.0/windows-11-arm/syscolors/2026-12-02" in reason and "46828919060" in reason and "only build 20348 reads 215" in reason, row["id"]
|
||||
continue
|
||||
assert "45672953042" in reason and "45679625406" in reason and "retail window-geometry capture workflow" in reason, row["id"]
|
||||
assert "window_frame.chrome_height_device" in reason and "This leaf: " in reason, row["id"]
|
||||
assert ("106 device px" in reason) if row["seed"] == 6 else ("720 CSS px" in reason and "gUIDensity" in reason and "compact" in reason), row["id"]
|
||||
@@ -143,7 +164,7 @@ def test_a_difference_that_no_row_covers_is_red_and_the_rows_stay_applied():
|
||||
candidate = dumps(1)
|
||||
candidate[(1.0, 2)]["surface"]["navigator"]["language"] = "it-IT"
|
||||
report = judge(dumps(0), candidate, declared=ab.load_expected(FILE))
|
||||
assert report["verdict"] == "red" and len(report["declared"]) == 24
|
||||
assert report["verdict"] == "red" and len(report["declared"]) == 36
|
||||
assert [(d["seed"], d["leaf"], d["a"], d["b"]) for d in report["differences"]] == [(2, "surface.navigator.language", "en-US", "it-IT")]
|
||||
assert report["problems"] == ["seed 2 dpr 1.0 surface.navigator.language: \"en-US\" vs \"it-IT\""]
|
||||
|
||||
@@ -166,22 +187,22 @@ def test_a_row_of_another_seed_dpr_or_os_does_not_cover_the_same_leaf():
|
||||
|
||||
def test_a_row_that_does_not_show_is_red_and_says_it_is_stale_and_to_remove_it():
|
||||
candidate = dumps(1)
|
||||
candidate[(1.5, 63)] = _visit(63, 0) # the candidate reads what the published engine reads at seed 63: its 24 - 15 rows are gone from the run
|
||||
candidate[(1.5, 63)] = _visit(63, 0) # the candidate reads what the published engine reads at seed 63: its 36 - 19 rows are gone from the run
|
||||
report = judge(dumps(0), candidate, declared=ab.load_expected(FILE))
|
||||
assert report["verdict"] == "red" and len(report["stale"]) == 15 and report["differences"] == []
|
||||
assert report["verdict"] == "red" and len(report["stale"]) == 17 and report["differences"] == []
|
||||
assert any("the declared difference 'linux-seed63-state.normal.innerHeight'" in p and "does not show in this run: it is stale, remove it" in p for p in report["problems"])
|
||||
|
||||
|
||||
def test_when_the_published_engine_is_the_candidate_s_own_work_every_row_is_stale():
|
||||
report = judge(dumps(1), dumps(1), declared=ab.load_expected(FILE))
|
||||
assert report["verdict"] == "red" and len(report["stale"]) == 24 and report["declared"] == [] and report["differences"] == []
|
||||
assert report["verdict"] == "red" and len(report["stale"]) == 36 and report["declared"] == [] and report["differences"] == []
|
||||
|
||||
|
||||
def test_a_row_of_a_visit_this_run_did_not_make_is_not_judged_here():
|
||||
only = ((1.0, 0),)
|
||||
report = judge({k: v for k, v in dumps(0).items() if k in only}, {k: v for k, v in dumps(1).items() if k in only}, declared=ab.load_expected(FILE), expected=only)
|
||||
assert report["verdict"] == "green", report["problems"]
|
||||
assert report["declared"] == [] and report["stale"] == []
|
||||
assert len(report["declared"]) == 4 and report["stale"] == [], "seed 0 at 1.0 has its four color rows (two leaves, two launches) and none of the bar rows of seeds 6 and 63"
|
||||
|
||||
|
||||
# -
|
||||
@@ -204,11 +225,11 @@ def test_the_rows_are_applied_to_the_a_b_from_the_files_and_never_to_the_a_a(tmp
|
||||
for leg in ("linux-x86_64", "win-x86_64"):
|
||||
rc, out = _run(tmp_path, capsys, "--leg", leg)
|
||||
assert rc == 0 and "AB ORACLE OK: 0 differences, 0 problems" in out
|
||||
assert out.count("DECLARED ") == 24 and "DIFF seed" not in out and "24 differences declared in ci/ab-oracle-expected.json" in out
|
||||
assert out.count("DECLARED ") == 36 and "DIFF seed" not in out and "36 differences declared in ci/ab-oracle-expected.json" in out
|
||||
rc, out = _run(tmp_path, capsys, "--a-a", "--leg", "linux-x86_64")
|
||||
report = json.loads((tmp_path / "diff-a-a.json").read_text(encoding="utf-8"))
|
||||
assert rc == 2 and report["declared"] == [] and report["stale"] == [] and len(report["differences"]) == 24, "the A/A is held to equality, whatever the file says"
|
||||
assert out.count("DIFF seed") == 24 and "DECLARED" not in out
|
||||
assert rc == 2 and report["declared"] == [] and report["stale"] == [] and len(report["differences"]) == 36, "the A/A is held to equality, whatever the file says"
|
||||
assert out.count("DIFF seed") == 36 and "DECLARED" not in out
|
||||
|
||||
|
||||
def test_the_a_b_from_the_files_is_red_on_the_old_command_line_data_without_the_rows_and_names_the_stale_one_with_them(tmp_path, monkeypatch, capsys):
|
||||
@@ -218,11 +239,11 @@ def test_the_a_b_from_the_files_is_red_on_the_old_command_line_data_without_the_
|
||||
_write(tmp_path, "dump-70.json", "firefox-70", dumps(0))
|
||||
_write(tmp_path, "dump-candidate.json", "candidate", dumps(1))
|
||||
rc, out = _run(tmp_path, capsys, "--leg", "linux-x86_64")
|
||||
assert rc == 1 and out.count("DIFF seed") == 24 and "AB ORACLE FAILED: 24 differences, 24 problems" in out
|
||||
assert rc == 1 and out.count("DIFF seed") == 36 and "AB ORACLE FAILED: 36 differences, 36 problems" in out
|
||||
monkeypatch.setattr(ab, "EXPECTED_FILE", FILE)
|
||||
_write(tmp_path, "dump-candidate.json", "candidate", dumps(0))
|
||||
rc, out = _run(tmp_path, capsys, "--leg", "win-x86_64")
|
||||
assert rc == 1 and out.count("is stale, remove it") == 24 and "FAIL the declared difference 'windows-seed6-state.normal.innerHeight'" in out
|
||||
assert rc == 1 and out.count("is stale, remove it") == 36 and "FAIL the declared difference 'windows-seed6-state.normal.innerHeight'" in out
|
||||
|
||||
|
||||
# -
|
||||
@@ -269,7 +290,7 @@ def test_a_run_applies_the_rows_of_its_leg_to_the_a_b_only_and_a_published_engin
|
||||
|
||||
monkeypatch.setattr(ab, "_dump_visits", fake([dumps(0), dumps(0), dumps(1)]))
|
||||
assert ab.run_ab("win-x86_64", tmp_path / "out", "firefox-70", ("pub", None), "cand", tmp_path / "s.json", list(CANDIDATE_SET)) == 0
|
||||
assert len(json.loads((tmp_path / "out" / "diff.json").read_text(encoding="utf-8"))["declared"]) == 24
|
||||
assert len(json.loads((tmp_path / "out" / "diff.json").read_text(encoding="utf-8"))["declared"]) == 36
|
||||
assert json.loads((tmp_path / "out" / "diff-a-a.json").read_text(encoding="utf-8"))["declared"] == []
|
||||
monkeypatch.setattr(ab, "_dump_visits", fake([dumps(0), dumps(1)])) # the published engine against itself reads what the candidate reads
|
||||
assert ab.run_ab("linux-x86_64", tmp_path / "out2", "firefox-70", ("pub", None), "cand", tmp_path / "s.json", list(CANDIDATE_SET)) == 2
|
||||
|
||||
@@ -671,3 +671,45 @@ def test_the_required_suites_of_the_oracles_say_the_control_is_the_set():
|
||||
for suite in ("wrapper.e2e.ab_oracle", "wrapper.e2e.ab_network", "wrapper.e2e.ab_host"):
|
||||
assert "published set" in rows[suite]["note"].lower(), suite
|
||||
assert "firefox-68" not in rows[suite]["note"], suite
|
||||
|
||||
|
||||
# -
|
||||
# The candidate's venv: the same kind of thing as the set's, from the candidate's wheels.
|
||||
|
||||
def test_the_candidate_s_venv_is_offline_over_the_gate_s_lock_with_the_candidate_s_two_wheels_and_nothing_of_the_job(tmp_path, monkeypatch):
|
||||
house, _lock, _published, _candidate = _tiny_house(tmp_path)
|
||||
ran = []
|
||||
monkeypatch.setenv("PYTHONPATH", "/candidate/site")
|
||||
monkeypatch.setattr(ps, "write_record", lambda venv, chosen: ran.append(("record", sorted(chosen))))
|
||||
ps.install_candidate(house, tmp_path / "venv", run=lambda cmd, **kw: ran.append((cmd, kw)) or types.SimpleNamespace(returncode=0, stdout="", stderr=""))
|
||||
venv_cmd, first, second, check, record = ran
|
||||
assert venv_cmd[0][1:] == ["-m", "venv", str(tmp_path / "venv")] and check[0][1:] == ["-m", "pip", "check"]
|
||||
assert record == ("record", ["invisible-core", "invisible-playwright"])
|
||||
for cmd, kw in (first, second):
|
||||
assert cmd[0] == str(ps.venv_python(tmp_path / "venv")) and "--no-index" in cmd and "PYTHONPATH" not in kw["env"]
|
||||
assert "--require-hashes" in first[0] and first[0][first[0].index("--find-links") + 1] == str(house) and first[0][-2:] == ["-r", str(house / "lock.txt")]
|
||||
assert "--no-deps" in second[0] and sorted(Path(x).name for x in second[0][-2:]) == ["invisible_core-70.83.0-py3-none-any.whl", "invisible_playwright-70.83.0-py3-none-any.whl"]
|
||||
assert all(Path(x).parent == house for x in second[0][-2:]), "the wheels of the wheelhouse's own folder, never published/"
|
||||
|
||||
|
||||
def test_the_candidate_s_venv_holds_the_candidate_s_wheels_read_back_from_the_disk(tmp_path):
|
||||
house, lock, published, candidate = _tiny_house(tmp_path)
|
||||
python = ps.install_candidate(house, tmp_path / "venv")
|
||||
done = subprocess.run([str(python), "-I", "-c", "import invisible_core, invisible_playwright; print(invisible_core.WHO, invisible_playwright.WHO)"],
|
||||
capture_output=True, text=True, check=True)
|
||||
assert done.stdout.split() == ["candidate", "candidate"]
|
||||
record = json.loads((tmp_path / "venv" / ps.RECORD_FILE).read_text(encoding="utf-8"))["packages"]
|
||||
assert {n: record[n.replace("_", "-")]["sha256"] for n in NAMES} == candidate and candidate != published
|
||||
|
||||
|
||||
def test_the_candidate_s_venv_is_refused_without_the_lock_and_without_exactly_one_candidate_wheel_of_each_package(tmp_path):
|
||||
with pytest.raises(FileNotFoundError, match="not a py-deps wheelhouse"):
|
||||
ps.install_candidate(tmp_path, tmp_path / "venv", run=lambda *a, **k: None)
|
||||
house, _lock, _published, _candidate = _tiny_house(tmp_path)
|
||||
(house / "invisible_core-70.84.0-py3-none-any.whl").write_bytes(b"x")
|
||||
with pytest.raises(FileNotFoundError, match="exactly one wheel of the candidate"):
|
||||
ps.install_candidate(house, tmp_path / "venv", run=lambda *a, **k: None)
|
||||
(house / "invisible_core-70.84.0-py3-none-any.whl").unlink()
|
||||
(house / "invisible_playwright-70.83.0-py3-none-any.whl").unlink()
|
||||
with pytest.raises(FileNotFoundError, match="holds 0"):
|
||||
ps.install_candidate(house, tmp_path / "venv", run=lambda *a, **k: None)
|
||||
@@ -116,12 +116,23 @@ _CLIENT = textwrap.dedent("""
|
||||
frame = frame.f_back
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def frames_of(frame, depth):
|
||||
# "<file>:<line> <function>", outermost first, read from the frame objects alone. Formatting a stack with its source
|
||||
# lines (traceback.format_stack) reads the files from disk through linecache: the first time, on a Windows runner, the
|
||||
# watcher waited for that disk and sampled nothing meanwhile, and the control saw 0 to 32 ms of a 400 ms hold.
|
||||
out = []
|
||||
while frame is not None and len(out) < depth:
|
||||
out.append("%s:%d %s" % (frame.f_code.co_filename, frame.f_lineno, frame.f_code.co_name))
|
||||
frame = frame.f_back
|
||||
return "\\n".join(reversed(out))
|
||||
|
||||
def stacks(self):
|
||||
frames = sys._current_frames()
|
||||
names = {t.ident: t.name for t in threading.enumerate()}
|
||||
return {
|
||||
"main": "".join(traceback.format_stack(frames[main_id])[-6:]),
|
||||
"others": {names.get(i, str(i)): "".join(traceback.format_stack(f)[-3:])
|
||||
"main": self.frames_of(frames[main_id], 6),
|
||||
"others": {names.get(i, str(i)): self.frames_of(f, 3)
|
||||
for i, f in frames.items() if i != main_id and i != threading.get_ident()}}
|
||||
|
||||
def note(self, frame):
|
||||
|
||||
+10
-10
@@ -175,14 +175,14 @@ def test_e9_linux_build_prefs_omits_windows_sandbox_key(monkeypatch):
|
||||
|
||||
@pytest.mark.e2e
|
||||
def test_e9b_windows_build_prefs_follows_the_desktop_that_was_created(monkeypatch):
|
||||
"""E9b (B172, 2026-08-24; inverted 2026-09-20): the two sandbox keys
|
||||
follow the FACT that a hidden desktop exists, never the platform.
|
||||
"""E9b (B172, 2026-08-24; inverted 2026-09-20; rewritten for the core that writes no sandbox pref): a hidden desktop adds no security.sandbox.* pref,
|
||||
with or without the desktop: the sandbox levels are Firefox 159's own defaults, content 9 (browser/app/profile/firefox.js:1701) and GPU 2 on Windows
|
||||
(modules/libpref/init/StaticPrefList.yaml:18839-18847), which the core does not write.
|
||||
|
||||
Until 2026-09-20 ``make_virtual_display()`` returned None on Windows
|
||||
(the binary cloaked its own window) and this test pinned the keys
|
||||
ABSENT there. Now Windows creates a Win32 desktop the browser is
|
||||
spawned on, so with ``headless=True`` the keys must be present - and
|
||||
with ``headless=False``, where no desktop is created, still absent.
|
||||
(the binary cloaked its own window). Now Windows creates a Win32 desktop
|
||||
the browser is spawned on, and with ``headless=True`` AND with
|
||||
``headless=False`` the core writes no sandbox key.
|
||||
What has not changed is the shape B172 fixed: ``virtual_display`` is
|
||||
read off ``self._virtual_display`` AFTER ``_resolve_headless()`` ran,
|
||||
not guessed from ``headless and platform=="win32"`` before it.
|
||||
@@ -206,16 +206,16 @@ def test_e9b_windows_build_prefs_follows_the_desktop_that_was_created(monkeypatc
|
||||
hidden._resolve_headless()
|
||||
assert hidden._virtual_display is not None, "the desktop was not wired up"
|
||||
prefs = hidden._build_prefs()
|
||||
assert prefs["security.sandbox.gpu.level"] == 0
|
||||
assert prefs["security.sandbox.content.level"] == 4
|
||||
# The core writes no security.sandbox.* pref: the sandbox is Firefox's own, at its retail default (content level 9 in browser/app/profile/firefox.js:1701,
|
||||
# GPU level 2 in modules/libpref/init/StaticPrefList.yaml:18839-18847, Firefox 159 tag), and the hidden desktop is made to fit it (invisible_core._headless).
|
||||
assert [k for k in prefs if k.startswith("security.sandbox.")] == []
|
||||
assert "zoom.stealth.cloak_windows" not in prefs
|
||||
|
||||
headed = InvisiblePlaywright(timezone="America/New_York", seed=42, headless=False)
|
||||
headed._resolve_headless()
|
||||
assert headed._virtual_display is None
|
||||
prefs = headed._build_prefs()
|
||||
assert "security.sandbox.gpu.level" not in prefs
|
||||
assert "security.sandbox.content.level" not in prefs
|
||||
assert [k for k in prefs if k.startswith("security.sandbox.")] == []
|
||||
|
||||
|
||||
@pytest.mark.e2e
|
||||
|
||||
@@ -30,6 +30,8 @@ PINNED_BY_BYTES = {
|
||||
"tests/gates/wire_method_debt.json": "tests/test_every_wire_method_is_served_or_refused.py",
|
||||
"ci/py-lock/gate.in": "tests/test_the_gate_lock_follows_the_sources.py",
|
||||
"ci/py-lock/gate.txt": "tests/test_the_gate_lock_follows_the_sources.py",
|
||||
"tests/data/password_mask_page.html": "tests/test_the_retail_password_mask_width_is_extracted_from_the_capture_not_typed.py",
|
||||
"tests/data/ab_host_linux/diff-47107160488.json": "tests/test_ab_host.py",
|
||||
}
|
||||
|
||||
# Every test file that hashes a file it reads, and where its fixtures come from.
|
||||
@@ -38,6 +40,9 @@ HASHING_TESTS = {
|
||||
"test_known_mozilla_defects_in_crash_evidence.py": "sources.json beside the evidence",
|
||||
"test_the_vendored_bundles_are_listed_with_their_hash.py": "the rows of tests/vendor/README.md",
|
||||
"test_ci_published_set.py": "a wheel the test builds in tmp_path: no fixture of the repository",
|
||||
"test_the_retail_password_mask_width_is_extracted_from_the_capture_not_typed.py": "tests/data/password_mask_page.html, the page of the retail capture (PINNED_BY_BYTES, `-text` in .gitattributes); the capture itself is built in tmp_path",
|
||||
"test_the_retail_popup_moves_and_resizes_are_extracted_from_the_capture_not_typed.py": "files the test builds in tmp_path (a small capture and its meta.json): no fixture of the repository",
|
||||
"test_the_host_gate_system_colors_are_extracted_from_the_retail_captures_not_typed.py": "files the test builds in tmp_path (two small captures with their result.json and meta.json): no fixture of the repository",
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ resource type than `beacon` is red. With a traced stock walk the trace verdict i
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
@@ -64,6 +65,29 @@ def test_a_difference_on_a_sound_walk_and_a_broken_control_on_another_is_both():
|
||||
assert report.journey(data)[1] == 3
|
||||
|
||||
|
||||
def test_a_report_read_from_its_file_gives_the_verdict_of_its_rows(tmp_path, capsys):
|
||||
"""The rows come from the JSON file run_fakeweb.py writes, so they are lists. RED on the old reader: `"..." % f` with a list
|
||||
raised TypeError, Python exited 1 and the workflow said "ours differs from stock" where stock was the broken control (run
|
||||
47365181687, Windows, step 13 of walk 1: stock busy, declared idle, ours idle)."""
|
||||
data = _walk()
|
||||
data["stock"][0]["idle"] = False
|
||||
data["broken_control"] = [(1, 1, "idle", "idle=False, declared idle")]
|
||||
data["fails"] = [(1, 1, "idle", False, True)]
|
||||
path = tmp_path / "fakeweb-p4.json"
|
||||
path.write_text(json.dumps(data, indent=1), encoding="utf-8")
|
||||
assert report.main(["journey", str(path)]) == 2
|
||||
out = capsys.readouterr().out
|
||||
assert "FAIL round 1 step 1 idle: stock=False candidate=True" in out
|
||||
assert "broken control (not a difference of ours)" in out
|
||||
|
||||
|
||||
def test_a_reader_that_breaks_is_not_a_verdict(tmp_path, capsys):
|
||||
path = tmp_path / "fakeweb-p4.json"
|
||||
path.write_text(json.dumps({"profile": "p4"}), encoding="utf-8") # no candidate: the reader cannot go on
|
||||
assert report.main(["journey", str(path)]) == 5
|
||||
assert "could not be read" in capsys.readouterr().out
|
||||
|
||||
|
||||
def test_a_missing_report_is_red(tmp_path, capsys):
|
||||
assert report.main(["journey", str(tmp_path / "nothing.json")]) == 4
|
||||
assert "RED" in capsys.readouterr().out
|
||||
|
||||
@@ -131,3 +131,18 @@ def test_the_run_is_red_on_a_fail_or_a_broken_control_even_with_an_unsettled_cel
|
||||
lines = capsys.readouterr().out.splitlines()
|
||||
assert code == 1
|
||||
assert lines[-1] == "cells: 2, fails: 0, broken controls: 1, stock unsettled: 1"
|
||||
|
||||
|
||||
def test_the_evidence_of_a_p4_step_is_what_the_client_heard_and_the_site_saw_while_the_step_ran():
|
||||
"""A step that differs or whose control broke keeps, in the report, its moments and what the client and the site logged between
|
||||
the start of the step and the end of its idle wait: where an open request stopped. Run 47365181687 (Windows) had a broken stock
|
||||
control at step 13 of walk 1 (three fonts open for 67 s) and nothing that said whether the site had ever seen them."""
|
||||
steps = [{"round": 1, "n": 12, "m_step_start": 1.0, "m_idle_end": 2.0},
|
||||
{"round": 1, "n": 13, "m_step_start": 2.0, "m_idle_end": 9.0, "in_flight_at_idle_end": ["font"], "ok": True}]
|
||||
client = [{"ev": "request", "m": 2.5, "url": "O/r?kind=woff2"}, {"ev": "request", "m": 1.5, "url": "A/search"}]
|
||||
site = [{"method": "GET", "path": "/r?kind=woff2", "m_arrive": 2.6, "m_end": 2.7}, {"method": "GET", "path": "/x", "m_arrive": 9.5}]
|
||||
out = run_fakeweb.step_evidence({(1, 13)}, steps, client, site)
|
||||
assert [(e["round"], e["n"]) for e in out] == [(1, 13)]
|
||||
assert out[0]["step"] == {"m_step_start": 2.0, "m_idle_end": 9.0, "in_flight_at_idle_end": ["font"]}
|
||||
assert out[0]["client"] == [client[0]]
|
||||
assert out[0]["site"] == [site[0]]
|
||||
@@ -44,8 +44,10 @@ on the next launch anyway.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import datetime
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
@@ -91,6 +93,69 @@ def _timestamps(exe: str) -> dict:
|
||||
return out
|
||||
|
||||
|
||||
#: The Application Event Log source the launcher writes its failures to (kEventSourceName in
|
||||
#: browser/app/winlauncher/ErrorHandler.cpp). Its payload names the failing call's file and line.
|
||||
LAUNCHER_EVENT_SOURCE = "Firefox Launcher"
|
||||
#: Shown as "absent" when the key has no such value, so the message always says which ones were looked for.
|
||||
EVIDENCE_SUFFIXES = ("Image", "Launcher", "Browser", "LauncherCrashTime", "Blocklist", "Telemetry")
|
||||
|
||||
|
||||
def _utc_now_iso() -> str:
|
||||
"""The moment as the event log's @SystemTime writes it (UTC, millisecond, Z)."""
|
||||
return datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] + "Z"
|
||||
|
||||
|
||||
def _launcher_values_text(exe: str) -> str:
|
||||
"""Every value under the launcher key whose name starts with `exe` (case-insensitive, as Windows
|
||||
compares paths), raw, with the expected suffixes listed as "absent" when missing."""
|
||||
import winreg
|
||||
|
||||
found = {}
|
||||
prefix = (exe + "|").lower()
|
||||
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, LAUNCHER_KEY) as key:
|
||||
i = 0
|
||||
while True:
|
||||
try:
|
||||
name, value, kind = winreg.EnumValue(key, i)
|
||||
except OSError:
|
||||
break
|
||||
i += 1
|
||||
if name.lower().startswith(prefix):
|
||||
found[name[len(prefix):]] = f"{value!r} (reg type {kind})"
|
||||
lines = [f" {exe}|{suffix} = {found.pop(suffix, 'absent')}" for suffix in EVIDENCE_SUFFIXES]
|
||||
lines += [f" {exe}|{suffix} = {raw}" for suffix, raw in sorted(found.items())]
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def _launcher_events_text(since_iso: str) -> str:
|
||||
"""The Application Event Log entries from the launcher's source written since `since_iso`."""
|
||||
query = (f"*[System[Provider[@Name='{LAUNCHER_EVENT_SOURCE}'] and "
|
||||
f"TimeCreated[@SystemTime>='{since_iso}']]]")
|
||||
done = subprocess.run(["wevtutil", "qe", "Application", f"/q:{query}", "/f:text", "/c:20", "/rd:true"],
|
||||
capture_output=True, timeout=30)
|
||||
out = done.stdout.decode("utf-8", errors="replace").strip()
|
||||
err = done.stderr.decode("utf-8", errors="replace").strip()
|
||||
if done.returncode != 0:
|
||||
return f"wevtutil exited {done.returncode}: {err or out}"
|
||||
return out or "no entry from this source since the test started"
|
||||
|
||||
|
||||
def _evidence(exe: str, since_iso: str) -> str:
|
||||
"""What the machine says about the launcher for `exe`, to append to a failure message. Never raises:
|
||||
a red test must stay the red it was, with whatever could be read next to it."""
|
||||
parts = ["\n--- launcher evidence (diagnostic only) ---"]
|
||||
try:
|
||||
parts.append(f"registry values under HKCU, key {LAUNCHER_KEY}, for this path:\n{_launcher_values_text(exe)}")
|
||||
except BaseException as exc: # noqa: BLE001 - a diagnostic must not replace the failure
|
||||
parts.append(f"registry values could not be read: {type(exc).__name__}: {exc}")
|
||||
try:
|
||||
parts.append(f"Application event log, source '{LAUNCHER_EVENT_SOURCE}', since {since_iso}:\n"
|
||||
f"{_launcher_events_text(since_iso)}")
|
||||
except BaseException as exc: # noqa: BLE001
|
||||
parts.append(f"event log could not be read: {type(exc).__name__}: {exc}")
|
||||
return "\n".join(parts)
|
||||
|
||||
|
||||
def _link_or_copy(src: str, dst: str) -> str:
|
||||
try:
|
||||
os.link(src, dst)
|
||||
@@ -120,7 +185,8 @@ def test_the_first_launch_from_a_new_path_works(new_path):
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
exe = new_path
|
||||
assert not any(_timestamps(exe).values()), "this path has run before"
|
||||
started = _utc_now_iso()
|
||||
assert not any(_timestamps(exe).values()), "this path has run before" + _evidence(exe, started)
|
||||
|
||||
with InvisiblePlaywright(binary_path=exe, headless=True, seed=1) as browser:
|
||||
page = browser.new_context().new_page()
|
||||
@@ -128,11 +194,11 @@ def test_the_first_launch_from_a_new_path_works(new_path):
|
||||
assert page.evaluate("1 + 1") == 2
|
||||
|
||||
stamps = _timestamps(exe)
|
||||
assert stamps["Launcher"], "the launcher process never recorded a start, so this was not a first launch"
|
||||
assert stamps["Launcher"], "the launcher process never recorded a start, so this was not a first launch" + _evidence(exe, started)
|
||||
assert stamps["Browser"], (
|
||||
"the launcher recorded a start and the browser never did: the launcher "
|
||||
"died before creating it, which is the first-launch failure this test exists for")
|
||||
assert stamps["Browser"] != 0, "the launcher was disabled after a failure instead of running"
|
||||
"died before creating it, which is the first-launch failure this test exists for" + _evidence(exe, started))
|
||||
assert stamps["Browser"] != 0, "the launcher was disabled after a failure instead of running" + _evidence(exe, started)
|
||||
assert stamps["Launcher"] < stamps["Browser"], (
|
||||
"the browser timestamp predates the launcher's, so the browser that ran "
|
||||
"was not the one this launcher created")
|
||||
"was not the one this launcher created" + _evidence(exe, started))
|
||||
@@ -301,7 +301,9 @@ def test_windows_virtual_display_with_socks_proxy(monkeypatch):
|
||||
)
|
||||
|
||||
assert pw_proxy is not None # a single path, here too
|
||||
assert prefs["security.sandbox.gpu.level"] == 0 # virtual_display branch
|
||||
# virtual_display writes no security.sandbox.* pref: the levels are Firefox 159's own defaults (content 9, browser/app/profile/firefox.js:1701; GPU 2 on Windows,
|
||||
# modules/libpref/init/StaticPrefList.yaml:18839-18847), which the core does not write.
|
||||
assert [k for k in prefs if k.startswith("security.sandbox.")] == []
|
||||
assert pw_proxy is not None # a single path
|
||||
assert "network.proxy.type" not in prefs
|
||||
# Windows exposes a validated persona renderer (calibrated clean bucket),
|
||||
|
||||
@@ -507,3 +507,99 @@ def test_the_a_a_run_prints_the_notes_and_keeps_them_in_its_report(world, monkey
|
||||
assert seen == [("firefox-70", True), ("firefox-70-again", True)], "the two dumps of the A/A are the control; no other dump is"
|
||||
assert "NOTE known Mozilla defect D31 (not filed): why: run firefox-70-again" in capsys.readouterr().out
|
||||
assert json.loads((out / "diff-a-a.json").read_text(encoding="utf-8"))["known_defects"] == ["known Mozilla defect D31 (not filed): why: run firefox-70-again"]
|
||||
|
||||
|
||||
# --- the process of a core whose `Core was generated by` line was cut: the whole argv is read out of the core, and what it cannot say is `unknown` (D31) ------------------------
|
||||
|
||||
ENGINE_PATH = "/opt/actions/work/firefox_antidetect_patch/firefox_antidetect_patch/ff/firefox" # 78 characters, as long as the engine path of the CI runner: the kernel's 80 bytes (79 with the NUL) end right after the next space
|
||||
|
||||
|
||||
def argv_lines(*argv):
|
||||
return "".join("INVPW-ARGV %d %s\n" % (i, json.dumps(a)) for i, a in enumerate(argv))
|
||||
|
||||
|
||||
def test_a_line_of_78_characters_is_a_cut_line_whose_flags_are_not_known():
|
||||
assert len(ENGINE_PATH) == 78
|
||||
text = HEADER % ENGINE_PATH
|
||||
assert crash.process_type(text) is None, "the 79th byte was the space before --backgroundtask, and gdb drops a trailing space: the old code said parent"
|
||||
assert crash.crash_record(text, "core.FSBroker1.2.3")["process"] == "unknown"
|
||||
|
||||
|
||||
def test_a_line_shorter_than_78_characters_is_a_whole_command_line_and_names_the_parent():
|
||||
text = HEADER % (ENGINE_PATH[:-5])
|
||||
assert crash.process_type(text) == "parent" and crash.crash_record(text, "core.x.1.2")["process"] == "parent"
|
||||
|
||||
|
||||
def test_the_whole_argv_names_the_process_whatever_the_line_of_the_header_kept():
|
||||
cut = HEADER % ENGINE_PATH
|
||||
assert crash.process_type(cut + argv_lines(ENGINE_PATH, "--backgroundtask", "pingsender")) == "backgroundtask"
|
||||
assert crash.crash_record(cut + argv_lines(ENGINE_PATH, "--backgroundtask", "pingsender"), "core.FSBroker1.2.3")["process"] == "backgroundtask"
|
||||
assert crash.process_type(cut + argv_lines(ENGINE_PATH, "-contentproc", "-childID", "4", "-isForBrowser", "tab")) == "tab"
|
||||
assert crash.process_type(cut + argv_lines(ENGINE_PATH, "-contentproc", "-childID", "4", "-isForBrowser", "notatype")) is None
|
||||
assert crash.process_type(cut + argv_lines(ENGINE_PATH, "--profile", "/p", "about:blank")) == "parent", "the whole argv has neither flag: the parent"
|
||||
assert crash.process_type(cut + argv_lines(ENGINE_PATH)) == "parent"
|
||||
|
||||
|
||||
def test_an_argv_that_is_not_whole_or_not_numbered_from_0_is_not_read():
|
||||
cut = HEADER % ENGINE_PATH
|
||||
for lines in ("INVPW-ARGV 1 \"--backgroundtask\"\n", argv_lines("a", "b") + "INVPW-ARGV 5 \"c\"\n", "INVPW-ARGV 0 not-json\n", "INVPW-ARGV-ERROR KeyError: 'AT_RANDOM'\n"):
|
||||
assert crash.argv_of(cut + lines) is None
|
||||
assert crash.crash_record(cut + lines, "core.x.1.2")["process"] == "unknown"
|
||||
|
||||
|
||||
def fake_gdb(argv, env=("HOME=/home/runner", "PATH=/usr/bin"), with_random=True):
|
||||
"""A gdb whose core holds the stack of an exec: AT_RANDOM (16 bytes), the platform string, the argument strings, the environment strings, the string AT_EXECFN names."""
|
||||
zero = bytes(1)
|
||||
base = 0x7FFD00000000
|
||||
random_at, platform_at = base, base + 16
|
||||
memory = bytes(16) + b"x86_64" + zero + bytes(9)
|
||||
strings_at = base + len(memory)
|
||||
memory += zero.join(s.encode() for s in list(argv) + list(env)) + zero
|
||||
execfn_at = base + len(memory)
|
||||
memory += argv[0].encode() + zero + bytes(64)
|
||||
aux = ["33 AT_SYSINFO_EHDR System-supplied DSO's ELF header 0x7ffd0000a000",
|
||||
"25 AT_RANDOM Address of 16 random bytes 0x%x" % random_at,
|
||||
"15 AT_PLATFORM String identifying platform 0x%x \"x86_64\"" % platform_at,
|
||||
"31 AT_EXECFN File name of executable 0x%x \"%s\"" % (execfn_at, argv[0]),
|
||||
"0 AT_NULL End of vector 0x0"]
|
||||
if not with_random:
|
||||
aux = [line for line in aux if "AT_RANDOM" not in line]
|
||||
|
||||
class Gdb:
|
||||
def execute(self, command, to_string=False):
|
||||
assert command == "info auxv" and to_string
|
||||
return "\n".join(aux) + "\n"
|
||||
|
||||
def selected_inferior(self):
|
||||
return self
|
||||
|
||||
def read_memory(self, address, size):
|
||||
if address < base or address + size > base + len(memory):
|
||||
raise RuntimeError("Cannot access memory at address %#x" % address)
|
||||
return memory[address - base:address - base + size]
|
||||
|
||||
assert strings_at > platform_at
|
||||
return Gdb()
|
||||
|
||||
|
||||
def run_argv_script(gdb, capsys):
|
||||
exec(crash.ARGV_SCRIPT, {"gdb": gdb})
|
||||
return capsys.readouterr().out
|
||||
|
||||
|
||||
def test_the_script_gdb_runs_in_the_core_prints_the_argument_strings_and_not_the_environment(capsys):
|
||||
out = run_argv_script(fake_gdb([ENGINE_PATH, "--backgroundtask", "pingsender"]), capsys)
|
||||
assert crash.argv_of(out) == [ENGINE_PATH, "--backgroundtask", "pingsender"]
|
||||
assert crash.process_type(HEADER % ENGINE_PATH + out) == "backgroundtask"
|
||||
assert crash.argv_of(run_argv_script(fake_gdb([ENGINE_PATH]), capsys)) == [ENGINE_PATH]
|
||||
assert crash.argv_of(run_argv_script(fake_gdb([ENGINE_PATH, "-contentproc", "-isForBrowser", "gpu"], env=()), capsys)) == [ENGINE_PATH, "-contentproc", "-isForBrowser", "gpu"]
|
||||
|
||||
|
||||
def test_the_script_says_why_when_the_core_does_not_give_the_stack(capsys):
|
||||
out = run_argv_script(fake_gdb([ENGINE_PATH, "--backgroundtask"], with_random=False), capsys)
|
||||
assert out.startswith("INVPW-ARGV-ERROR KeyError") and crash.argv_of(out) is None
|
||||
assert crash.crash_record(HEADER % ENGINE_PATH + out, "core.FSBroker1.2.3")["process"] == "unknown"
|
||||
|
||||
|
||||
def test_gdb_is_asked_for_the_argv_of_every_core():
|
||||
assert any(command.startswith("python exec(") and "INVPW-ARGV" in command and "\n" not in command for command in crash.GDB_COMMANDS)
|
||||
+407
@@ -0,0 +1,407 @@
|
||||
"""No fontconfig file of the host is opened, and the screenshot draws the bundle even when the host's caches are poisoned (e2e, Linux).
|
||||
|
||||
Why Linux only: fontconfig exists only there. On Windows the parent rebuilds a font from the path a text run carries with DirectWrite, which opens the
|
||||
file by its path and has no configuration and no cache of fonts to read; this test has no Windows form (the row of ``ci/required-suites.json`` says so:
|
||||
``linux_only``).
|
||||
|
||||
It replaces the test of the warm cache (``test_the_parent_reads_the_bundle_from_fontconfig_s_cache_linux_e2e.py``), which asked that a second launch read
|
||||
fontconfig's cache of the bundle. The engine no longer has that behaviour, on purpose: it runs fontconfig on its own empty configuration. It reads no
|
||||
``fonts.conf``, no rule, no cache folder and no GTK or Xft font option, it does not show ``<GRE>/fonts`` to fontconfig (the core declares
|
||||
``gfx.bundled-fonts.activate=0`` on Linux), and the screenshot takes the file and the face of each text run from the bundle's manifest. So the host's
|
||||
fontconfig can neither decide a face nor be asked.
|
||||
|
||||
What the test does, in one launch under strace (the stand-in of ``tests/_strace_stand_in.py``: the engine's folder as links, whose executable runs the real
|
||||
one under ``strace -f`` in its place):
|
||||
|
||||
(a) POISONS the caches first. Fontconfig names the cache of a folder by the md5 of its path and trusts it while the folder's mtime is the one the cache
|
||||
recorded. The test makes a copy of the engine's fonts folder (links to the files) WITHOUT one ``.ttc`` (``msgothic5_32.ttc``: MS Gothic, MS PGothic,
|
||||
MS UI Gothic), gives the copy the mtime of the real folder, and has ``fc-cache`` write the cache of the copy AS IF it were the real folder
|
||||
(``<remap-dir as-path=...>``: the cache is named for the real path and lists the real path), once into ``$HOME/.fontconfig`` and once into
|
||||
``$XDG_CACHE_HOME/fontconfig`` of the test, the two folders an old engine reads. A cache valid for the real folder that does not list that face. The
|
||||
test then asks fontconfig itself (``fc-list``, with the real folder and one cache folder) and fails if the face is listed or the real folder is
|
||||
not what it lists: a poison that is not in force would let every assertion below pass for the wrong reason;
|
||||
(b) asserts that NO process of the browser (the parent, the content processes, any other) OPENS a path under ``/etc/fonts``, a file called
|
||||
``fonts.conf``, or a fontconfig cache file (``*.cache-*``, also the ``.NEW`` and ``.TMP-*`` it is written through), whatever the result of the open:
|
||||
an open that is refused (no such file) is a look at the host's configuration all the same. The other calls that look at a path
|
||||
(stat, access, readlink) are written to the evidence and not judged;
|
||||
(c) takes a screenshot of Japanese text in a bundled face (MS PGothic, which is face 2 of the ``.ttc`` the poison lacks) and asserts it equals the content's
|
||||
own drawing, as ``tests/test_a_screenshot_draws_the_text_of_the_bundled_fonts_as_the_content_does_e2e.py`` does: the same text as HTML (the parent
|
||||
rebuilds it for the screenshot) and as a canvas the content drew, in the same screenshot, equal byte by byte.
|
||||
|
||||
Red on the old engine: it opens ``/etc/fonts/fonts.conf`` (and the caches) at ``FcInit``, and with the poisoned cache the parent asks fontconfig which file is the
|
||||
face of the text run, which does not list it: it draws another file's outlines (a font of the host), so the two boxes differ. Green on the engine that runs
|
||||
fontconfig on its own empty configuration.
|
||||
|
||||
The environment reaches the browser as it does for a user: the test sets ``HOME`` and ``XDG_CACHE_HOME`` in its own environment (and ``XDG_CONFIG_HOME`` to a
|
||||
folder with nothing in it; the core gives the engine empty configuration folders of its own, whatever the test sets), and the core composes the rest of the
|
||||
engine's environment from it. ``FONTCONFIG_FILE`` and ``FONTCONFIG_PATH`` of the runner are taken off.
|
||||
|
||||
Evidence, whatever the verdict: when ``RUNNER_TEMP`` is set the test writes ``result.json`` (the poison, what fontconfig says of it, every open of a
|
||||
forbidden path with the role of its process, every other forbidden look, the boxes of the screenshot) and the screenshot under
|
||||
``$RUNNER_TEMP/invpw-evidence/fontconfig-host-files/``.
|
||||
|
||||
Run: pytest tests/test_no_fontconfig_file_of_the_host_is_opened_and_the_screenshot_draws_the_bundle_linux_e2e.py -m e2e -v
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import posixpath
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
import _page_bytes as pb
|
||||
from _waits import wait_until
|
||||
from _strace_stand_in import (
|
||||
_detached, _group_members, _group_of, _kill_group, _LINE, _require_strace_can_trace, _RESUMED, _roles, _stand_in, _SYSCALLS, _wait_for_exit)
|
||||
from test_a_screenshot_draws_the_text_of_the_bundled_fonts_as_the_content_does_e2e import (
|
||||
BLOCK_H, BLOCK_W, EVIDENCE_FOLDER, PIN, VIEWPORT, _dark, _integer_box, _page)
|
||||
|
||||
pytestmark = [
|
||||
pytest.mark.e2e,
|
||||
pytest.mark.skipif(not sys.platform.startswith("linux"), reason="fontconfig is the Linux font system"),
|
||||
]
|
||||
|
||||
SEED = 21
|
||||
|
||||
#: The face of the screenshot: MS PGothic is face 2 of msgothic5_32.ttc (face 0 is MS Gothic), the file the poison lacks.
|
||||
FAMILY = "MS PGothic"
|
||||
MISSING_FACE_FILE = "msgothic5_32.ttc"
|
||||
|
||||
#: What is traced: the opens (what the test judges), the other calls that look at a path (evidence), and the clones and the execve (the role of a process).
|
||||
TRACE = _SYSCALLS + ",openat2"
|
||||
OPEN_CALLS = ("open", "openat", "openat2")
|
||||
_LOOK_CALLS = ("stat", "lstat", "newfstatat", "statx", "access", "faccessat", "faccessat2", "readlink")
|
||||
#: Calls whose first argument is a directory descriptor (``-y`` prints its path: ``3</etc/fonts/conf.d>``, ``AT_FDCWD</cwd>``).
|
||||
_AT_CALLS = ("openat", "openat2", "newfstatat", "statx", "faccessat", "faccessat2")
|
||||
|
||||
_QUOTED_FIRST = re.compile(r'^"((?:[^"\\]|\\.)*)"')
|
||||
_AT_ARGS = re.compile(r'^([^,"]*),\s*"((?:[^"\\]|\\.)*)"')
|
||||
_RETURN = re.compile(r"\)\s+=\s+(-?\d+)")
|
||||
#: A fontconfig cache file: ``<md5 or uuid>-<arch>.cache-<n>``, and what it is written through (``.NEW``, ``.TMP-xxxxxx``).
|
||||
_CACHE_FILE = re.compile(r"\.cache-\d+(\.|$)")
|
||||
|
||||
#: The folders an old engine reads a cache from, besides ``/var/cache/fontconfig``: the legacy ``~/.fontconfig`` and ``$XDG_CACHE_HOME/fontconfig``.
|
||||
POISONED_FOLDERS = ("home", "xdg")
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------------------------------------------------------------------
|
||||
# What the log says (pure: unit-tested without a browser, tests/unit/test_fontconfig_cache_criterion.py)
|
||||
# --------------------------------------------------------------------------------------------------------------------------------------
|
||||
def is_a_fontconfig_file_of_the_host(path: str) -> bool:
|
||||
"""A path the engine must never open: under ``/etc/fonts``, a file called ``fonts.conf`` (anywhere: a user's, the system's, a bundle's), or a
|
||||
fontconfig cache file (``*.cache-<n>`` and what it is written through)."""
|
||||
folder = posixpath.normpath(path)
|
||||
base = posixpath.basename(folder)
|
||||
return folder == "/etc/fonts" or folder.startswith("/etc/fonts/") or base == "fonts.conf" or _CACHE_FILE.search(base) is not None
|
||||
|
||||
|
||||
def _full_path(dirfd: str, path: str) -> str:
|
||||
"""The path a call names: absolute as it is; a relative one with the folder ``-y`` printed for its descriptor (``3</etc/fonts/conf.d>``)."""
|
||||
if path.startswith("/"):
|
||||
return posixpath.normpath(path)
|
||||
folder = re.search(r"<(.*)>", dirfd)
|
||||
return posixpath.normpath(posixpath.join(folder.group(1), path)) if folder else path
|
||||
|
||||
|
||||
def _results_of_unfinished(lines) -> dict:
|
||||
"""``{index of an unfinished call: its result}``: strace -f writes a call that another thread interrupts as "PID openat(...<unfinished ...>" and gives
|
||||
the result on the next line of that pid, "PID <... openat resumed>) = -1 ENOENT". An unfinished line with no resumed line has no entry."""
|
||||
pending, results = {}, {}
|
||||
for i, line in enumerate(lines):
|
||||
m = _LINE.match(line)
|
||||
if m and "<unfinished ...>" in m.group(3):
|
||||
pending[(int(m.group(1)), m.group(2))] = i
|
||||
continue
|
||||
r = _RESUMED.match(line)
|
||||
if r and (int(r.group(1)), r.group(2)) in pending:
|
||||
result = _RETURN.search(r.group(3))
|
||||
if result:
|
||||
results[pending.pop((int(r.group(1)), r.group(2)))] = int(result.group(1))
|
||||
return results
|
||||
|
||||
|
||||
def paths_of_calls(lines, calls) -> list:
|
||||
"""``[{"line", "pid", "call", "path", "result"}]``: every call of ``calls`` on the log, with the path it names, whatever its result (``None`` when the log
|
||||
has none: an unfinished call with no resumed line). A call that names a path through a descriptor with no printed folder keeps the relative path."""
|
||||
results = _results_of_unfinished(lines)
|
||||
found = []
|
||||
for i, line in enumerate(lines):
|
||||
m = _LINE.match(line)
|
||||
if not m or m.group(2) not in calls:
|
||||
continue
|
||||
call, rest = m.group(2), m.group(3)
|
||||
if call in _AT_CALLS:
|
||||
args = _AT_ARGS.match(rest)
|
||||
path = _full_path(args.group(1), args.group(2)) if args else None
|
||||
else:
|
||||
args = _QUOTED_FIRST.match(rest)
|
||||
path = posixpath.normpath(args.group(1)) if args else None
|
||||
if path is None:
|
||||
continue
|
||||
result = _RETURN.search(rest)
|
||||
found.append({"line": i, "pid": int(m.group(1)), "call": call, "path": path,
|
||||
"result": int(result.group(1)) if result else results.get(i)})
|
||||
return found
|
||||
|
||||
|
||||
def host_fontconfig_looks(lines, real: str) -> dict:
|
||||
"""``{"opens": [...], "other": [...]}``: the opens of a fontconfig file of the host by any process of the browser, and (evidence, not judged) the stat,
|
||||
access and readlink calls on one. Each has the role of its process (``parent``, ``content`` or ``other``)."""
|
||||
role, _argv = _roles(lines, real)
|
||||
out = {"opens": [], "other": []}
|
||||
for key, calls in (("opens", OPEN_CALLS), ("other", _LOOK_CALLS)):
|
||||
for call in paths_of_calls(lines, calls):
|
||||
if is_a_fontconfig_file_of_the_host(call["path"]):
|
||||
out[key].append(dict(call, role=role(call["pid"])))
|
||||
return out
|
||||
|
||||
|
||||
def poison_config(as_path: str, copy: str, cache_dir: str) -> str:
|
||||
"""The configuration ``fc-cache`` reads to write the poison: scan ``copy`` AS IF it were ``as_path`` (the cache is named for ``as_path`` and lists
|
||||
its path), into ``cache_dir`` only, and nothing else (no system folder, no rule)."""
|
||||
return ('<?xml version="1.0"?>\n<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">\n<fontconfig>\n'
|
||||
' <remap-dir as-path="%s">%s</remap-dir>\n <cachedir>%s</cachedir>\n</fontconfig>\n' % (as_path, copy, cache_dir))
|
||||
|
||||
|
||||
def reader_config(folder: str, cache_dir: str) -> str:
|
||||
"""The configuration that asks fontconfig what the cache holds for ``folder``: the folder and one cache folder, nothing else."""
|
||||
return ('<?xml version="1.0"?>\n<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">\n<fontconfig>\n'
|
||||
' <dir>%s</dir>\n <cachedir>%s</cachedir>\n</fontconfig>\n' % (folder, cache_dir))
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------------------------------------------------------------------
|
||||
# The test's own steps
|
||||
# --------------------------------------------------------------------------------------------------------------------------------------
|
||||
def _evidence_dir():
|
||||
base = os.environ.get("RUNNER_TEMP")
|
||||
return Path(base) / EVIDENCE_FOLDER / "fontconfig-host-files" if base else None
|
||||
|
||||
|
||||
def _tool_env(conf: Path, home: Path) -> dict:
|
||||
"""The environment of ``fc-cache`` and ``fc-list``: the test's own, with this one configuration and nothing of the variables the core strips."""
|
||||
env = {k: v for k, v in os.environ.items() if not k.startswith(("FONTCONFIG_", "FC_"))}
|
||||
env["FONTCONFIG_FILE"] = str(conf)
|
||||
env["HOME"] = str(home)
|
||||
return env
|
||||
|
||||
|
||||
def _run(argv, env) -> str:
|
||||
done = subprocess.run(argv, env=env, capture_output=True, text=True, timeout=300)
|
||||
assert done.returncode == 0, "%s failed (%d): %s" % (" ".join(argv), done.returncode, (done.stderr or done.stdout)[-800:])
|
||||
return done.stdout
|
||||
|
||||
|
||||
def _poison(work: Path, gre_fonts: str, home: Path, xdg_cache: Path) -> dict:
|
||||
"""Write the poisoned cache of the real fonts folder into ``home/.fontconfig`` and ``xdg_cache/fontconfig``; -> what was written and what fontconfig says
|
||||
of each (the files it lists for the real folder, read back by ``fc-list`` from that cache folder alone)."""
|
||||
copy = work / "fonts-without-one-ttc"
|
||||
copy.mkdir()
|
||||
entries = sorted((e for e in os.scandir(gre_fonts) if e.is_file()), key=lambda e: e.name)
|
||||
assert any(e.name == MISSING_FACE_FILE for e in entries), "<GRE>/fonts has no %s: the poison has nothing to lack" % MISSING_FACE_FILE
|
||||
for entry in entries:
|
||||
if entry.name != MISSING_FACE_FILE:
|
||||
(copy / entry.name).symlink_to(entry.path)
|
||||
stat = os.stat(gre_fonts)
|
||||
# The cache is valid while the folder's mtime is the one it recorded (the package gives the folder 1767225600): the copy gets the real folder's own, in
|
||||
# nanoseconds, after the links, which moved it.
|
||||
os.utime(copy, ns=(stat.st_atime_ns, stat.st_mtime_ns))
|
||||
md5 = hashlib.md5(gre_fonts.rstrip("/").encode()).hexdigest()
|
||||
caches = {"home": home / ".fontconfig", "xdg": xdg_cache / "fontconfig"}
|
||||
said = {}
|
||||
for name, folder in caches.items():
|
||||
folder.mkdir(parents=True, exist_ok=True)
|
||||
conf = work / ("poison-%s.conf" % name)
|
||||
conf.write_text(poison_config(gre_fonts, str(copy), str(folder)), encoding="utf-8")
|
||||
_run(["fc-cache", "-f", "-v"], _tool_env(conf, home))
|
||||
reader = work / ("reader-%s.conf" % name)
|
||||
reader.write_text(reader_config(gre_fonts, str(folder)), encoding="utf-8")
|
||||
listed = sorted(line for line in _run(["fc-list", "-f", "%{file}\\n"], _tool_env(reader, home)).splitlines() if line.strip())
|
||||
said[name] = {
|
||||
"cache_folder": str(folder),
|
||||
"cache_files": sorted(f.name for f in folder.iterdir() if f.is_file()),
|
||||
"listed_files": sorted(set(listed)),
|
||||
}
|
||||
return {"copy": str(copy), "real_folder": gre_fonts, "md5_of_the_real_folder": md5, "mtime_ns": stat.st_mtime_ns,
|
||||
"font_files_in_the_real_folder": [e.name for e in entries], "caches": said}
|
||||
|
||||
|
||||
def _poison_problems(poison: dict) -> list:
|
||||
"""Why the poison is not in force (empty when it is): a cache that fontconfig does not read for the real folder, or that still lists the face, is no poison."""
|
||||
problems = []
|
||||
real = poison["real_folder"]
|
||||
for name, said in poison["caches"].items():
|
||||
mine = [f for f in said["cache_files"] if f.startswith(poison["md5_of_the_real_folder"]) and _CACHE_FILE.search(f)]
|
||||
if not mine:
|
||||
problems.append("%s: no cache named for the real folder (%s-*.cache-*) in %s (it holds %s)"
|
||||
% (name, poison["md5_of_the_real_folder"], said["cache_folder"], said["cache_files"]))
|
||||
listed = said["listed_files"]
|
||||
if not listed:
|
||||
problems.append("%s: fontconfig lists no font for the real folder %s with this cache" % (name, real))
|
||||
elif any(posixpath.dirname(f) != real for f in listed):
|
||||
problems.append("%s: fontconfig lists files outside the real folder: %s" % (name, [f for f in listed if posixpath.dirname(f) != real][:3]))
|
||||
if any(posixpath.basename(f) == MISSING_FACE_FILE for f in listed):
|
||||
problems.append("%s: fontconfig lists %s for the real folder: the cache is not the poisoned one (the folder was scanned again)" % (name, MISSING_FACE_FILE))
|
||||
return problems
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def launch(firefox_binary, tmp_path_factory):
|
||||
"""The one launch under strace, with the caches poisoned: -> {poison, looks, measured, whole, dom, cv, ...}; the record is written before any assertion."""
|
||||
for tool in ("strace", "fc-cache", "fc-list"):
|
||||
if shutil.which(tool) is None:
|
||||
pytest.fail("needs %s (apt install strace fontconfig): without it nothing is measured" % tool, pytrace=False)
|
||||
work = tmp_path_factory.mktemp("fcfiles")
|
||||
_require_strace_can_trace(work)
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
real = os.path.realpath(firefox_binary)
|
||||
gre_fonts = os.path.join(os.path.dirname(real), "fonts")
|
||||
home, xdg_cache, xdg_config = work / "home", work / "xdg-cache", work / "xdg-config"
|
||||
for folder in (home, xdg_cache, xdg_config):
|
||||
folder.mkdir()
|
||||
out = {"poison": _poison(work, gre_fonts, home, xdg_cache)}
|
||||
|
||||
run = work / "run"
|
||||
run.mkdir()
|
||||
log, pidfile = run / "strace.log", run / "stand-in.pid"
|
||||
stand_in = _stand_in(firefox_binary, run / "engine", log, pidfile, syscalls=TRACE, fd_paths=True)
|
||||
shot, measured = None, None
|
||||
try:
|
||||
with pytest.MonkeyPatch.context() as patch:
|
||||
patch.setenv("HOME", str(home))
|
||||
patch.setenv("XDG_CACHE_HOME", str(xdg_cache))
|
||||
patch.setenv("XDG_CONFIG_HOME", str(xdg_config))
|
||||
for variable in ("FONTCONFIG_FILE", "FONTCONFIG_PATH"):
|
||||
patch.delenv(variable, raising=False)
|
||||
with InvisiblePlaywright(seed=SEED, binary_path=stand_in, headless=True, pin=PIN) as browser:
|
||||
page = browser.new_context(viewport=VIEWPORT).new_page()
|
||||
page.set_content(_page())
|
||||
page.evaluate("fam => { window.DONE = false; window.ERR = null;"
|
||||
" draw(fam).then(r => { window.R = r; window.DONE = true; },"
|
||||
" e => { window.ERR = String(e); window.DONE = true; }); }", FAMILY)
|
||||
page.wait_for_function("window.DONE === true", timeout=60_000)
|
||||
out["page_error"] = page.evaluate("window.ERR")
|
||||
measured = page.evaluate("window.R")
|
||||
shot = page.screenshot(type="png")
|
||||
finally:
|
||||
_kill_group(pidfile)
|
||||
lines = log.read_text(encoding="utf-8", errors="replace").splitlines()
|
||||
out["log_lines"] = len(lines)
|
||||
out["looks"] = host_fontconfig_looks(lines, real)
|
||||
out["measured"], out["shot"] = measured, shot
|
||||
if shot is not None and measured is not None:
|
||||
whole = pb.unfiltered(shot)
|
||||
out["whole"] = {"w": whole["w"], "h": whole["h"]}
|
||||
out["dom"] = _integer_box("DOM", measured["dom"])
|
||||
out["cv"] = _integer_box("canvas", measured["cv"])
|
||||
out["dom_img"] = pb.crop(whole, out["dom"]["x"], out["dom"]["y"], out["dom"]["width"], out["dom"]["height"])
|
||||
out["cv_img"] = pb.crop(whole, out["cv"]["x"], out["cv"]["y"], out["cv"]["width"], out["cv"]["height"])
|
||||
out["diff"] = pb.pixels_differ(out["dom_img"], out["cv_img"])
|
||||
where = _evidence_dir()
|
||||
if where is not None:
|
||||
try:
|
||||
where.mkdir(parents=True, exist_ok=True)
|
||||
record = {k: v for k, v in out.items() if k not in ("shot", "dom_img", "cv_img")}
|
||||
(where / "result.json").write_text(json.dumps(record, indent=1, sort_keys=True, default=str) + "\n", encoding="utf-8")
|
||||
if shot is not None:
|
||||
(where / "page.png").write_bytes(shot)
|
||||
except Exception as exc: # a record never changes the outcome
|
||||
print("the record could not be written:", repr(exc))
|
||||
return out
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------------------------------------------------------------------
|
||||
# The tests
|
||||
# --------------------------------------------------------------------------------------------------------------------------------------
|
||||
@pytest.mark.timeout(120, method="thread")
|
||||
def test_the_stand_in_stays_in_the_engine_s_place_and_its_group_is_killed_whole(tmp_path):
|
||||
"""The tool, without a browser. A fake engine (a script that starts a child and waits for it) is launched through the stand-in
|
||||
as the core launches the engine: the leader of a process group of its own (``_detached``). Once the fake engine says its child
|
||||
runs (a signal file, no pause), the process the launcher holds must be alive and be the fake engine's parent, strace: with the
|
||||
stand-in that exec'd ``setsid``, setsid forked (its caller led a group), its parent exited 0 at once, and the core saw the engine
|
||||
exit during startup (candidate 44161687675, job 134356188701). The group the cleanup kills is the launcher's, it holds strace and
|
||||
the fake engine's child, and nothing of it is left afterwards."""
|
||||
if shutil.which("strace") is None:
|
||||
pytest.fail("needs strace (apt install strace): without it the stand-in cannot be tried", pytrace=False)
|
||||
_require_strace_can_trace(tmp_path)
|
||||
real = tmp_path / "real" / "firefox"
|
||||
real.parent.mkdir()
|
||||
# The signal, written whole (a rename) once the child runs: the child's pid and the fake engine's parent, the process strace is.
|
||||
signal_file = tmp_path / "started"
|
||||
real.write_text('#!/bin/sh\nsleep 300 &\necho "$! $PPID" > %s.tmp && mv %s.tmp %s\nwait\n' % (signal_file, signal_file, signal_file))
|
||||
real.chmod(0o755)
|
||||
log, pidfile = tmp_path / "strace.log", tmp_path / "stand-in.pid"
|
||||
stand_in = _stand_in(str(real), tmp_path / "engine", log, pidfile)
|
||||
proc = _detached([stand_in], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
try:
|
||||
started = wait_until(signal_file.exists, 30, lambda: time.sleep(0.05))
|
||||
child, engine_parent = (int(word) for word in signal_file.read_text().split()) if started else (None, None)
|
||||
exited_with = proc.poll()
|
||||
pgid = _group_of(pidfile)
|
||||
members = _group_members(pgid) if pgid is not None else []
|
||||
comms = sorted(Path("/proc/%d/comm" % p).read_text().strip() for p in members if Path("/proc/%d/comm" % p).exists())
|
||||
killed = _kill_group(pidfile)
|
||||
proc.wait(timeout=30)
|
||||
left = _wait_for_exit(pgid) if pgid is not None else []
|
||||
finally:
|
||||
_kill_group(pidfile)
|
||||
if proc.poll() is None:
|
||||
proc.kill()
|
||||
proc.wait(timeout=30)
|
||||
assert started, "the fake engine did not start its child under the stand-in"
|
||||
assert exited_with is None and engine_parent == proc.pid, (
|
||||
"the process the launcher holds (pid %d, exited with %s) is not the one that runs the engine (its parent is %s): the launcher would "
|
||||
"see the engine gone" % (proc.pid, exited_with, engine_parent))
|
||||
assert pgid == proc.pid and pgid != os.getpgrp(), "the group is not the one the launcher gave (group %s, pid %d)" % (pgid, proc.pid)
|
||||
assert "strace" in comms and child in members, "the group holds %s (%s), not strace and the child %s" % (members, comms, child)
|
||||
assert killed == pgid and not left, "after the kill of group %s: killed %s, left %s" % (pgid, killed, left)
|
||||
|
||||
|
||||
@pytest.mark.timeout(900, method="thread")
|
||||
def test_the_caches_of_the_host_hold_a_valid_cache_of_the_bundle_that_lacks_a_face(launch):
|
||||
"""The precondition of the two below, in fontconfig's own words: without it a clean log and an equal screenshot would prove nothing."""
|
||||
problems = _poison_problems(launch["poison"])
|
||||
assert not problems, "the poison is not in force, so the test measures nothing: %s" % "; ".join(problems)
|
||||
|
||||
|
||||
@pytest.mark.timeout(900, method="thread")
|
||||
def test_no_process_of_the_browser_opens_a_fontconfig_file_of_the_host(launch):
|
||||
problems = _poison_problems(launch["poison"])
|
||||
assert not problems, "the poison is not in force, so the test measures nothing: %s" % "; ".join(problems)
|
||||
assert launch["log_lines"] > 0, "strace wrote nothing: the browser was not traced"
|
||||
opens = launch["looks"]["opens"]
|
||||
assert not opens, (
|
||||
"%d open(s) of a fontconfig file of the host by the browser (under /etc/fonts, a fonts.conf, or a *.cache-* cache), by role: %s. The first ones: %s. "
|
||||
"Looks that are not opens (stat, access, readlink), not judged: %d"
|
||||
% (len(opens), sorted({o["role"] for o in opens}),
|
||||
[(o["role"], o["call"], o["path"], o["result"]) for o in opens[:8]], len(launch["looks"]["other"])))
|
||||
|
||||
|
||||
@pytest.mark.timeout(900, method="thread")
|
||||
def test_the_screenshot_of_japanese_text_in_a_bundled_face_is_the_content_s_drawing_with_the_caches_poisoned(launch):
|
||||
problems = _poison_problems(launch["poison"])
|
||||
assert not problems, "the poison is not in force, so the test measures nothing: %s" % "; ".join(problems)
|
||||
assert launch["page_error"] is None, "the page could not draw the two blocks: %s" % launch["page_error"]
|
||||
measured, whole, dom, cv = launch["measured"], launch["whole"], launch["dom"], launch["cv"]
|
||||
assert measured["dpr"] == 1, "the device pixel ratio is %r, not 1: the boxes would be resampled" % measured["dpr"]
|
||||
assert (dom["width"], dom["height"]) == (cv["width"], cv["height"]) == (BLOCK_W, BLOCK_H), (dom, cv)
|
||||
assert measured["lines"] == 6, "the block has %r lines, not 6" % measured["lines"]
|
||||
assert (whole["w"], whole["h"]) == (VIEWPORT["width"], VIEWPORT["height"]), (
|
||||
"the screenshot is %dx%d for a viewport of %dx%d: the boxes are not where the page measured them"
|
||||
% (whole["w"], whole["h"], VIEWPORT["width"], VIEWPORT["height"]))
|
||||
dom_img, cv_img, diff = launch["dom_img"], launch["cv_img"], launch["diff"]
|
||||
# a box with no text in it would be equal to another box with no text in it
|
||||
assert _dark(dom_img) > 0, "the DOM box of %s is blank: the screenshot has no text there" % FAMILY
|
||||
assert _dark(cv_img) > 0, "the canvas box of %s is blank: the SVG image drew no text" % FAMILY
|
||||
assert dom_img["data"] == cv_img["data"], (
|
||||
"%s: the text the screenshot rebuilt in the parent (the DOM box) is not the text the content drew (the canvas box): %d of %d pixels differ, the first at %r, "
|
||||
"inside the box %r. With the caches of the host poisoned (a valid cache of the bundle without %s), the parent drew the face from another file."
|
||||
% (FAMILY, diff["pixels"], BLOCK_W * BLOCK_H, diff["first"], diff["box"], MISSING_FACE_FILE))
|
||||
@@ -1,6 +1,6 @@
|
||||
"""The arm of the prefs composition that exists on Windows only: the hidden desktop.
|
||||
|
||||
``test_a_hidden_desktop_brings_its_two_sandbox_keys_and_nothing_hides_by_pref`` is skipped on every other system (the hidden desktop is a Windows path),
|
||||
``test_a_hidden_desktop_writes_no_sandbox_pref_and_nothing_hides_by_pref`` is skipped on every other system (the hidden desktop is a Windows path),
|
||||
and a skip is red in the whole unit suite of the candidate, so it is a file of its own and only the row of Windows lists it (``tests/test_prefs_composition_arm.py``
|
||||
keeps what runs on both).
|
||||
"""
|
||||
@@ -21,15 +21,19 @@ pytestmark = pytest.mark.unit
|
||||
|
||||
@pytest.mark.skipif(sys.platform != "win32",
|
||||
reason="the hidden desktop is a Windows path")
|
||||
def test_a_hidden_desktop_brings_its_two_sandbox_keys_and_nothing_hides_by_pref():
|
||||
def test_a_hidden_desktop_writes_no_sandbox_pref_and_nothing_hides_by_pref():
|
||||
"""The window is hidden by WHERE the browser is created, not by a pref.
|
||||
|
||||
⛔ `zoom.stealth.cloak_windows` must never come back: from 2026-06-11 to
|
||||
2026-09-20 it switched on a DWMWA_CLOAK inside the binary, and the owner
|
||||
chose a stock engine on that surface. The two keys that DO ride with a
|
||||
hidden desktop are the sandbox workarounds measured in 2026-05 (§P16,
|
||||
#18 Bug A), emitted only when the desktop was actually created, with
|
||||
setdefault so an explicit override still wins.
|
||||
chose a stock engine on that surface. The two sandbox workarounds of
|
||||
2026-05 (§P16, #18 Bug A) are gone: the core writes NO ``security.sandbox.*``
|
||||
pref, with or without the desktop, and the hidden desktop is made to fit the
|
||||
browser's own sandbox. The levels are therefore Firefox 159's own defaults
|
||||
(content level 9, browser/app/profile/firefox.js:1701; GPU level 2 on Windows,
|
||||
modules/libpref/init/StaticPrefList.yaml:18839-18847, both unchanged from the
|
||||
FIREFOX_159_0_RELEASE tag), and this test asserts no value of them: only that
|
||||
the core wrote none. What the caller's own ``extra_prefs`` name is the caller's.
|
||||
"""
|
||||
without = build_prefs(profile=generate_profile(SEED), locale=LOCALE,
|
||||
timezone=TZ, extra_prefs=None,
|
||||
@@ -48,9 +52,10 @@ def test_a_hidden_desktop_brings_its_two_sandbox_keys_and_nothing_hides_by_pref(
|
||||
for prefs in (without, hidden, overridden):
|
||||
assert "zoom.stealth.cloak_windows" not in prefs, (
|
||||
"the in-binary cloak pref is back")
|
||||
assert "security.sandbox.gpu.level" not in without
|
||||
assert "security.sandbox.content.level" not in without
|
||||
assert hidden["security.sandbox.gpu.level"] == 0
|
||||
assert hidden["security.sandbox.content.level"] == 4
|
||||
for name, prefs in (("without a desktop", without), ("with a hidden desktop", hidden)):
|
||||
assert [k for k in prefs if k.startswith("security.sandbox.")] == [], (
|
||||
"the core wrote a sandbox pref %s: Firefox 159's own level is the one retail has" % name)
|
||||
assert [k for k in overridden if k.startswith("security.sandbox.")] == ["security.sandbox.gpu.level"], (
|
||||
"the caller named one sandbox pref and the core added another beside it")
|
||||
assert overridden["security.sandbox.gpu.level"] == 1, (
|
||||
"the desktop workaround overwrote an explicit override")
|
||||
"the caller's own value did not pass through")
|
||||
+47
-15
@@ -26,7 +26,7 @@ from invisible_core.process import (
|
||||
JobObjectGuard, NullGuard, SessionToken, find_processes, guard_for,
|
||||
)
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
pytestmark = [pytest.mark.unit, pytest.mark.timeout(120)]
|
||||
|
||||
psutil = pytest.importorskip("psutil")
|
||||
|
||||
@@ -45,6 +45,22 @@ def _spawn(token) -> subprocess.Popen:
|
||||
)
|
||||
|
||||
|
||||
def _wait_environ(*pids: int) -> None:
|
||||
"""Wait for the PRECONDITION of find_processes, never for its result: each pid exists and its environment block can be read.
|
||||
|
||||
That is the event the reaper's search needs, and it is not the code under test, so what the test then asserts about the search can fail with its own
|
||||
message. A process that has gone is a failure at once; one that never becomes readable is ended by the timeout of the module."""
|
||||
for pid in pids:
|
||||
while True:
|
||||
try:
|
||||
psutil.Process(pid).environ()
|
||||
break
|
||||
except psutil.NoSuchProcess:
|
||||
raise AssertionError(f"the process {pid} ended before its environment could be read")
|
||||
except psutil.Error:
|
||||
time.sleep(0.01)
|
||||
|
||||
|
||||
def _reap_all(*procs: subprocess.Popen) -> None:
|
||||
for p in procs:
|
||||
try:
|
||||
@@ -63,30 +79,45 @@ def test_it_finds_the_process_carrying_the_token():
|
||||
token = SessionToken.mint()
|
||||
proc = _spawn(token)
|
||||
try:
|
||||
time.sleep(0.6)
|
||||
_wait_environ(proc.pid)
|
||||
found = {p.pid for p in find_processes(token)}
|
||||
assert proc.pid in found
|
||||
finally:
|
||||
_reap_all(proc)
|
||||
|
||||
|
||||
def test_a_child_inherits_the_token_and_is_reaped_with_the_parent():
|
||||
#: The marked process of the tree test below. ``sys.argv[1]`` is how long it takes before it makes its grandchild (a loaded machine starts a child late; the
|
||||
#: test forces it). It prints the grandchild's pid once the grandchild exists, and that line is the event the test waits for.
|
||||
_TREE_PARENT = (
|
||||
"import subprocess,sys,time;"
|
||||
"time.sleep(float(sys.argv[1]));"
|
||||
f"g=subprocess.Popen([sys.executable,'-c','import time; time.sleep({_SLEEP})']);"
|
||||
"print(g.pid,flush=True);"
|
||||
f"time.sleep({_SLEEP})"
|
||||
)
|
||||
|
||||
|
||||
#: 0 is a machine at rest; 3 is the forced case, a parent that is late to make its grandchild.
|
||||
@pytest.mark.parametrize("delay", [0, 3])
|
||||
def test_a_child_inherits_the_token_and_is_reaped_with_the_parent(delay):
|
||||
"""The whole point on Windows: the tree, not the process we launched.
|
||||
|
||||
A grandchild spawned by the marked process carries the same environment,
|
||||
so it is found and killed even though nothing ever recorded its pid.
|
||||
|
||||
The test waits for the grandchild to exist (the parent prints its pid), never for a time; a hang is ended by the timeout above.
|
||||
"""
|
||||
token = SessionToken.mint()
|
||||
env = token.stamp(os.environ)
|
||||
parent = subprocess.Popen(
|
||||
[sys.executable, "-c",
|
||||
f"import subprocess,sys,time;"
|
||||
f"subprocess.Popen([sys.executable,'-c','import time; time.sleep({_SLEEP})']);"
|
||||
f"time.sleep({_SLEEP})"],
|
||||
env=env,
|
||||
[sys.executable, "-c", _TREE_PARENT, str(delay)],
|
||||
env=env, stdout=subprocess.PIPE,
|
||||
)
|
||||
try:
|
||||
time.sleep(1.5)
|
||||
line = parent.stdout.readline()
|
||||
assert line.strip().isdigit(), f"the parent did not say that its grandchild exists: {line!r}, exit {parent.poll()}"
|
||||
grandchild = int(line)
|
||||
_wait_environ(parent.pid, grandchild)
|
||||
pids = {p.pid for p in find_processes(token)}
|
||||
assert len(pids) >= 2, f"grandchild not found, only {pids}"
|
||||
killed = guard_for().reap(token)
|
||||
@@ -94,6 +125,7 @@ def test_a_child_inherits_the_token_and_is_reaped_with_the_parent():
|
||||
assert core_process.wait_until_gone(token, timeout=8.0)
|
||||
finally:
|
||||
_reap_all(parent)
|
||||
parent.stdout.close()
|
||||
|
||||
|
||||
def test_it_does_not_touch_a_process_with_a_different_token():
|
||||
@@ -106,7 +138,7 @@ def test_it_does_not_touch_a_process_with_a_different_token():
|
||||
mine, theirs = SessionToken.mint(), SessionToken.mint()
|
||||
a, b = _spawn(mine), _spawn(theirs)
|
||||
try:
|
||||
time.sleep(0.8)
|
||||
_wait_environ(a.pid, b.pid)
|
||||
mine_pids = {p.pid for p in find_processes(mine)}
|
||||
assert guard_for().reap(mine) >= 1
|
||||
assert core_process.wait_until_gone(mine, timeout=8.0)
|
||||
@@ -135,7 +167,7 @@ def test_it_does_not_touch_an_unmarked_process():
|
||||
token = SessionToken.mint()
|
||||
marked, plain = _spawn(token), _spawn(None)
|
||||
try:
|
||||
time.sleep(0.8)
|
||||
_wait_environ(marked.pid)
|
||||
guard_for().reap(token)
|
||||
assert core_process.wait_until_gone(token, timeout=8.0)
|
||||
assert plain.poll() is None, "an unmarked process was killed"
|
||||
@@ -171,7 +203,7 @@ def test_an_empty_token_never_matches_even_a_process_that_carries_an_empty_one()
|
||||
_reap_all(victim)
|
||||
raise
|
||||
try:
|
||||
time.sleep(0.8)
|
||||
_wait_environ(empty.pid)
|
||||
assert find_processes(SessionToken()) == []
|
||||
assert guard_for().reap(SessionToken()) == 0
|
||||
assert empty.poll() is None, "an empty token reaped a live process"
|
||||
@@ -205,7 +237,7 @@ def test_the_null_guard_still_reaps_because_that_part_needs_no_kernel():
|
||||
token = SessionToken.mint()
|
||||
proc = _spawn(token)
|
||||
try:
|
||||
time.sleep(0.8)
|
||||
_wait_environ(proc.pid)
|
||||
assert NullGuard().reap(token) >= 1
|
||||
assert core_process.wait_until_gone(token, timeout=8.0)
|
||||
finally:
|
||||
@@ -305,7 +337,7 @@ def test_the_final_reap_with_a_reaper_runs_after_it_and_spares_the_sender_until_
|
||||
reaper = _FakeReaper()
|
||||
_reaped._reapers[token.value] = [reaper]
|
||||
try:
|
||||
time.sleep(0.6)
|
||||
_wait_environ(sender.pid)
|
||||
assert _reaped.final_reap(guard_for(), token) == 0
|
||||
assert sender.poll() is None, "the final reap killed the sender before the reaper had finished"
|
||||
assert sender.pid in {p.pid for p in find_processes(token)}
|
||||
@@ -323,7 +355,7 @@ def test_the_final_reap_without_a_reaper_is_immediate():
|
||||
token = SessionToken.mint()
|
||||
proc = _spawn(token)
|
||||
try:
|
||||
time.sleep(0.6)
|
||||
_wait_environ(proc.pid)
|
||||
assert _reaped.final_reap(guard_for(), token) >= 1
|
||||
assert core_process.wait_until_gone(token, timeout=8.0)
|
||||
finally:
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
"""The watcher of the close-loop e2e (tests/test_closing_one_of_four_browsers_does_not_hold_the_loop_e2e.py) samples the loop's thread
|
||||
every few ms; it must never wait on a disk. It took a stack with its source lines (`traceback.format_stack`, which reads the files
|
||||
through linecache) when the loop's lateness crossed 30 ms: the first time in the process, on a Windows runner, it waited for those
|
||||
files, sampled nothing meanwhile, and the control saw 0, 32 and 31 ms of a loop held 400 ms (candidates 46583548241, 46854589434,
|
||||
47405642032). The watcher reads frames from the frame objects alone.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import ast
|
||||
import linecache
|
||||
import sys
|
||||
import textwrap
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
E2E = Path(__file__).resolve().parent / "test_closing_one_of_four_browsers_does_not_hold_the_loop_e2e.py"
|
||||
#: Calls that read source files (or may): none of them in the watcher's class.
|
||||
READS_SOURCE = {("traceback", "format_stack"), ("traceback", "extract_stack"), ("traceback", "format_list"),
|
||||
("traceback", "print_stack"), ("traceback", "StackSummary"), ("linecache", "getline"), ("linecache", "getlines"),
|
||||
("linecache", "checkcache"), ("inspect", "stack"), ("inspect", "getframeinfo"), ("inspect", "getsourcefile")}
|
||||
|
||||
|
||||
def _client():
|
||||
for node in ast.parse(E2E.read_text(encoding="utf-8")).body:
|
||||
if isinstance(node, ast.Assign) and getattr(node.targets[0], "id", "") == "_CLIENT":
|
||||
return eval(compile(ast.Expression(node.value), str(E2E), "eval"), {"textwrap": textwrap})
|
||||
raise AssertionError("no _CLIENT in %s" % E2E)
|
||||
|
||||
|
||||
def _instrument(tree):
|
||||
for node in ast.walk(tree):
|
||||
if isinstance(node, ast.ClassDef) and node.name == "Instrument":
|
||||
return node
|
||||
raise AssertionError("no class Instrument in the client")
|
||||
|
||||
|
||||
def test_the_watcher_calls_nothing_that_reads_a_source_file():
|
||||
found = []
|
||||
for node in ast.walk(_instrument(ast.parse(_client()))):
|
||||
if isinstance(node, ast.Attribute) and isinstance(node.value, ast.Name) and (node.value.id, node.attr) in READS_SOURCE:
|
||||
found.append("%s.%s (line %d of the client)" % (node.value.id, node.attr, node.lineno))
|
||||
assert not found, "the watcher of the close-loop e2e reads source files: %s" % ", ".join(found)
|
||||
|
||||
|
||||
def test_a_stack_of_the_watcher_names_file_line_and_function_without_linecache(monkeypatch):
|
||||
method = next(n for n in _instrument(ast.parse(_client())).body if isinstance(n, ast.FunctionDef) and n.name == "frames_of")
|
||||
method.decorator_list = []
|
||||
scope = {}
|
||||
exec(compile(ast.Module(body=[method], type_ignores=[]), "<client>", "exec"), scope)
|
||||
|
||||
def no_disk(*_a, **_k):
|
||||
raise AssertionError("linecache was asked for a source line")
|
||||
monkeypatch.setattr(linecache, "getline", no_disk)
|
||||
monkeypatch.setattr(linecache, "getlines", no_disk)
|
||||
monkeypatch.setattr(linecache, "checkcache", no_disk)
|
||||
|
||||
def inner():
|
||||
return scope["frames_of"](sys._getframe(), 2)
|
||||
text = inner()
|
||||
lines = text.split("\n")
|
||||
assert len(lines) == 2, text
|
||||
assert lines[-1].startswith(__file__) and lines[-1].endswith(" inner"), text
|
||||
assert lines[0].endswith(" test_a_stack_of_the_watcher_names_file_line_and_function_without_linecache"), text
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
"""On Linux the declared frame is in the real GTK window when the core owns the display, whatever a window manager's properties say, and is not there when it does not.
|
||||
|
||||
What it holds: the GTK declared-frame gtests of the engine (``TestStealthDeclaredFrameGtk.cpp``, deleted from the engine: a gtest process is forced to ``MOZ_HEADLESS`` and
|
||||
never opens a GDK display, so ``CreateTopLevelWindow`` gave no window and each of them stopped at its first assertion). The decision was ``StealthGtkHasDeclaredFrame``
|
||||
(``widget/gtk/StealthFrameGtk.cpp``): the declared frame is the client area's subtraction of a GTK window if, and only if, the core declared the display its own
|
||||
(``zoom.stealth.display.core_owned``, written by the core as true exactly for the display it started for ``headless=True``).
|
||||
|
||||
WHY THE REAL WINDOW IS READ FROM THE X SERVER. A page cannot tell: the outer size a page reads is the one declared at birth (``StealthDeclaredPopupOuterSize``), and a
|
||||
resize is mapped from the declared window to the real one by the difference, so ``outerWidth - innerWidth`` is the declared frame whatever frame the real window has
|
||||
(``test_popup_geometry_is_the_declared_frame_e2e.py`` holds that number). What differs is the REAL window: its client area is the real window less the margin the widget
|
||||
declares (``GetBounds() - GetClientBounds()``, the gtest's own words), so the X server's width of the popup's toplevel less the page's ``innerWidth`` (the client area, at
|
||||
scale 1.0 in device pixels) is ``2 * border`` when the widget takes the declared frame and 0 when it takes Mozilla's, which has no frame around a window no window manager
|
||||
draws one for. The test reads that width through a connection of its own to the display (``_x_window_frame.XFrame``), the real thing and not a number the engine says.
|
||||
|
||||
Three launches of a popup (``window.open`` from a click, 500x400), the screen pinned to 1920x1080 at scale 1.0 (the declared frame is then the core's ``WINDOW_FRAME_BY_DPR[1.0]``):
|
||||
|
||||
1. ``test_a_popup_on_the_display_the_core_owns_has_the_declared_frame_in_its_real_window``: the display the core started, no window manager. X width less ``innerWidth``
|
||||
is ``2 * border``. The control of the measure, and the gtest's first assertion (the declared frame answers for the window). Green on the old engine too.
|
||||
2. ``test_a_display_that_answers_as_a_window_manager_still_gives_the_declared_frame``: the same launch; once the page is up, the root window of the display is given the
|
||||
properties a window manager gives it (``_NET_SUPPORTING_WM_CHECK``, ``_NET_WM_STATE_FULLSCREEN`` in ``_NET_SUPPORTED``, read back from the server first) and a popup
|
||||
is opened after that. X width less ``innerWidth`` is still ``2 * border``. The gtest ``ADisplayWithAWindowManagerStillTakesTheDeclaredFrameWhenTheCoreOwnsIt`` did
|
||||
the same with the same properties and no window manager started.
|
||||
3. ``test_a_display_the_core_does_not_own_gives_a_popup_no_declared_frame``: the pref is false when the core did not start the display (``headless=False``: the
|
||||
session has no virtual display, core 08), the way a headed launch has it: the browser is launched headed on a private Xvfb of the test (``a_display_of_its_own``), every
|
||||
screen pref declared as always. X width less ``innerWidth`` is 0: Mozilla's client area is the window's own. The gtest ``APrefFalseTakesMozillasClientAreaNotTheDeclaredFrame``
|
||||
asked for "not the declared frame" and a client offset of (0, 0). The pref cannot be set after the launch: the core writes it as a fact of the session and an
|
||||
``extra_prefs`` value is overwritten (core README, ``tests/test_display_core_owned.py`` of the core), so the case is reached by the launch that makes it false.
|
||||
|
||||
RED ON THE ENGINE OF ROUND 6 (series 6716db9bfedb, before the client offset and core-owned change), by construction. There the decision was
|
||||
``StealthHasDeclaredFrame(window) && NoWindowManager()``, ``NoWindowManager()`` being ``!gdk_x11_screen_supports_net_wm_hint(_NET_WM_STATE_FULLSCREEN)``, and the pref was
|
||||
not read. In 2 the root answers as a window manager, ``NoWindowManager()`` is false, the popup's client area is Mozilla's and X width less ``innerWidth`` is 0, not
|
||||
``2 * border``. In 3 no window manager is on the private display, ``NoWindowManager()`` is true whatever the pref says, the popup takes the declared frame and X width less
|
||||
``innerWidth`` is ``2 * border``, not 0. In 1 round 6 is green: it is the measure's control.
|
||||
|
||||
NOT HERE: the client offset of the gtest ``AGtkWindowsClientOffsetIsItsOwnNotTheDeclaredMargin`` (``GetScreenBounds().TopLeft() + GetClientOffset() == WidgetToScreenOffset()``
|
||||
and a client offset of (0, 0)). ``BrowserParent`` places a page-opened popup from ``GetClientOffset()``, so it is held on a real launch by the select dropdown and the tooltip
|
||||
twins (``test_a_select_dropdown_opens_at_its_element_e2e.py``, ``test_a_tooltip_opens_at_the_pointer_e2e.py``: popup against the element's real screen rectangle, equal to retail
|
||||
within one and two device pixels), which the evidence of the round measured 8 device pixels away at scale 1.0 with the declared margin as the offset.
|
||||
|
||||
The engine that answers these values is not released yet: on the engine of the pin this test is red, on purpose, as the window tests of the same suite are. Linux only: the
|
||||
decision is the GTK widget's; Windows has its own (``TestStealthDeclaredFrameWin.cpp``, ``test_popup_geometry_is_the_declared_frame_e2e.py``).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
from _fission_frames import Sites
|
||||
from _os_focus import a_display_of_its_own
|
||||
from _popup_geometry import PIN, frame_of_the_declaration
|
||||
from _waits import wait_until
|
||||
from _x_window_frame import XFrame
|
||||
|
||||
pytestmark = [pytest.mark.e2e,
|
||||
pytest.mark.skipif(not sys.platform.startswith("linux"), reason="the decision is the GTK widget's: Windows has its own frame (test_popup_geometry_is_the_declared_frame_e2e.py)")]
|
||||
|
||||
#: The deadline of a wait for the popup's window to be as the engine makes it, in seconds.
|
||||
DEADLINE_S = 30
|
||||
#: The title of the popup's page: its toplevel is found on the display by ``_NET_WM_NAME``.
|
||||
POPUP_TITLE = "declared-frame-probe"
|
||||
MAIN = ("<!doctype html><title>main</title><button id='open' onclick=\"window.open('%s', 'p', 'width=500,height=400')\">open</button>")
|
||||
POPUP = "<!doctype html><title>%s</title>" % POPUP_TITLE
|
||||
|
||||
|
||||
def _real_width_less_inner_width(binary, headless, display_of, answer_as_a_window_manager, expected):
|
||||
"""A popup is opened from a click and ``(X width of its toplevel, innerWidth)`` is read until the X width less the inner width is ``expected`` (or the deadline: the last
|
||||
reading is returned either way, so the caller's assertion names what was read). ``display_of(session)`` names the display the session's browser is on, with the
|
||||
environment a connection to it needs set; ``answer_as_a_window_manager`` gives the root a window manager's properties once the first page is up."""
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
with Sites() as sites:
|
||||
sites.route("A", "/popup", POPUP)
|
||||
sites.route("A", "/main", MAIN % sites.url("A", "/popup"))
|
||||
session = InvisiblePlaywright(seed=42, pin=PIN, binary_path=binary, headless=headless, humanize=False)
|
||||
with session as browser:
|
||||
assert (session._virtual_display is not None) == headless, (
|
||||
"the session has %s virtual display for headless=%r: the core declares the display its own exactly for the one it started" % (
|
||||
"a" if session._virtual_display is not None else "no", headless))
|
||||
x = XFrame(display_of(session))
|
||||
try:
|
||||
page = browser.new_page()
|
||||
page.goto(sites.url("A", "/main"), wait_until="load", timeout=30000)
|
||||
if answer_as_a_window_manager:
|
||||
x.answer_as_a_window_manager()
|
||||
assert x.window_manager_check() is not None, "the properties of a window manager were not put on the root window of the display"
|
||||
# The properties reach the engine as events of its display connection; its main loop has turned over by the time it has answered the page twice.
|
||||
page.evaluate("() => 1")
|
||||
page.evaluate("() => 1")
|
||||
with page.expect_popup(timeout=30000) as info:
|
||||
page.click("#open", timeout=30000)
|
||||
popup = info.value
|
||||
popup.wait_for_load_state("load", timeout=30000)
|
||||
seen = {}
|
||||
|
||||
def settled():
|
||||
inner = popup.evaluate("() => innerWidth")
|
||||
window = x.window_titled(POPUP_TITLE)
|
||||
seen["now"] = {"inner_width": inner, "x_width": x.width_of(window) if window else None}
|
||||
return window is not None and inner > 0 and seen["now"]["x_width"] - inner == expected
|
||||
|
||||
wait_until(settled, DEADLINE_S, lambda: popup.wait_for_timeout(100))
|
||||
return seen["now"]
|
||||
finally:
|
||||
x.stop_answering()
|
||||
x.close()
|
||||
|
||||
|
||||
def _the_core_displays(monkeypatch):
|
||||
"""``display_of`` for a session on the display the core started: its name, and the cookie its server asks for in ``XAUTHORITY`` for this test's connection."""
|
||||
def display_of(session):
|
||||
env = session._virtual_display.launch_env()
|
||||
monkeypatch.setenv("XAUTHORITY", env["XAUTHORITY"])
|
||||
return env["DISPLAY"]
|
||||
|
||||
return display_of
|
||||
|
||||
|
||||
def _verdict(reading, expected, what):
|
||||
width, inner = reading["x_width"], reading["inner_width"]
|
||||
return ("%s: the X server's width of the popup's window is %r and the page's innerWidth %r, so the window is %r wider than its client area; it must be %d"
|
||||
% (what, width, inner, None if width is None or inner is None else width - inner, expected))
|
||||
|
||||
|
||||
def test_a_popup_on_the_display_the_core_owns_has_the_declared_frame_in_its_real_window(firefox_binary, monkeypatch):
|
||||
declared = 2 * frame_of_the_declaration().border
|
||||
reading = _real_width_less_inner_width(firefox_binary, True, _the_core_displays(monkeypatch), False, declared)
|
||||
assert reading["x_width"] is not None and reading["x_width"] - reading["inner_width"] == declared, _verdict(
|
||||
reading, declared, "on the display the core started, with no window manager, the declared frame is not in the real window")
|
||||
|
||||
|
||||
def test_a_display_that_answers_as_a_window_manager_still_gives_the_declared_frame(firefox_binary, monkeypatch):
|
||||
declared = 2 * frame_of_the_declaration().border
|
||||
reading = _real_width_less_inner_width(firefox_binary, True, _the_core_displays(monkeypatch), True, declared)
|
||||
assert reading["x_width"] is not None and reading["x_width"] - reading["inner_width"] == declared, _verdict(
|
||||
reading, declared, "on the display the core started, with the root answering as a window manager, the declared frame is not in the real window")
|
||||
|
||||
|
||||
def test_a_display_the_core_does_not_own_gives_a_popup_no_declared_frame(firefox_binary, monkeypatch):
|
||||
with a_display_of_its_own(monkeypatch) as display:
|
||||
reading = _real_width_less_inner_width(firefox_binary, False, lambda session: display, False, 0)
|
||||
assert reading["x_width"] is not None and reading["x_width"] - reading["inner_width"] == 0, _verdict(
|
||||
reading, 0, "on a display the core did not start (headless=False, zoom.stealth.display.core_owned false) the popup's real window has the declared frame in it")
|
||||
@@ -61,6 +61,8 @@ EXCLUDED = {
|
||||
(_BOTH, "wrapper.e2e.stock_twin.select: the same steps on a reference (Playwright's own Firefox, or retail Firefox 159 for the chrome popups) and on ours, which only the legs of that row install; the whole-suite rows have neither"),
|
||||
"tests/test_a_tooltip_opens_at_the_pointer_e2e.py":
|
||||
(_BOTH, "wrapper.e2e.stock_twin.tooltip: the same steps on a reference (Playwright's own Firefox, or retail Firefox 159 for the chrome popups) and on ours, which only the legs of that row install; the whole-suite rows have neither"),
|
||||
"tests/test_a_press_outside_an_open_datalist_list_ends_as_on_stock_e2e.py":
|
||||
(_BOTH, "wrapper.e2e.stock_twin.dnd (second file): the same steps on a reference (Playwright's own Firefox, or retail Firefox 159 for the chrome popups) and on ours, which only the legs of that row install; the whole-suite rows have neither"),
|
||||
"tests/test_intersection_and_lazy_loading_in_a_frame_of_another_site_e2e.py":
|
||||
(_BOTH, "wrapper.e2e.stock_twin.intersection: the same steps on a reference (Playwright's own Firefox, or retail Firefox 159 for the chrome popups) and on ours, which only the legs of that row install; the whole-suite rows have neither"),
|
||||
"tests/test_a_proxy_that_cannot_carry_udp_leaks_nothing_direct_e2e.py":
|
||||
@@ -83,10 +85,16 @@ EXCLUDED = {
|
||||
(("linux",), "skips on Linux: the hidden desktop is the Windows path; Linux hides via Xvfb"),
|
||||
"tests/test_first_launch_from_a_new_path.py::test_the_first_launch_from_a_new_path_works":
|
||||
(("linux",), "skips on Linux: the launcher process exists only on Windows"),
|
||||
"tests/test_the_declared_frame_of_a_window_follows_the_core_owned_display_linux_e2e.py":
|
||||
(("windows",), "skips on Windows: the decision is the GTK widget's (the core-owned display, the window manager properties of an X root); Windows has its own frame, held by test_popup_geometry_is_the_declared_frame_e2e.py"),
|
||||
"tests/test_the_host_gl_probe_runs_only_on_an_undeclared_engine_linux_e2e.py":
|
||||
(("windows",), "the GLX probe (gfxtest glx) is a child process of Firefox on GTK; Windows reads the adapter in the parent and has no such process"),
|
||||
"tests/test_the_parent_reads_the_bundle_from_fontconfig_s_cache_linux_e2e.py":
|
||||
(("windows",), "wrapper.e2e.fontconfig is linux_only: fontconfig exists only on Linux (DirectWrite opens a font from its path)"),
|
||||
"tests/test_no_fontconfig_file_of_the_host_is_opened_and_the_screenshot_draws_the_bundle_linux_e2e.py":
|
||||
(("windows",), "wrapper.e2e.fontconfig is linux_only: fontconfig exists only on Linux (DirectWrite opens a font from its path)"),
|
||||
"tests/test_the_host_fontconfig_rules_do_not_reach_the_text_pixels_linux_e2e.py":
|
||||
(("windows",), "wrapper.e2e.fontconfig is linux_only: fontconfig exists only on Linux (DirectWrite draws the text with no rule of a user)"),
|
||||
"tests/test_webgl_draws_on_the_engine_s_own_gl_e2e.py::test_webgl_draws_on_the_engine_s_own_gl":
|
||||
(("windows",), "skips on Windows: the engine's own GL is Linux's"),
|
||||
"tests/test_webgl_draws_on_the_engine_s_own_gl_e2e.py::test_every_declared_extension_answers_as_on_windows":
|
||||
@@ -99,7 +107,7 @@ EXCLUDED = {
|
||||
(("windows",), "skips on Windows: the Linux text path"),
|
||||
}
|
||||
#: Changed by hand, together with the list above: an exclusion is a test the candidate does not run, and it may not be added in silence.
|
||||
EXCLUDED_COUNT = 25
|
||||
EXCLUDED_COUNT = 29
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=None)
|
||||
|
||||
@@ -0,0 +1,463 @@
|
||||
"""The fontconfig rules of the host do not change a pixel of the text a page reads (e2e, Linux, a gate test that asserts the principle: same seed, same bytes).
|
||||
|
||||
Why Linux only: fontconfig exists only there. On Windows DirectWrite draws the text, with no rule of a user in between, so this test has no
|
||||
Windows form (the row of ``ci/required-suites.json`` says so: ``linux_only``).
|
||||
|
||||
The question. The engine draws a face with the parameters of its fontconfig pattern: ``rgba``, ``lcdfilter``, ``autohint``, ``embeddedbitmap``,
|
||||
``hintstyle`` and ``antialias``. On a machine, those are rules of a user (``~/.config/fontconfig``) or of the system (``/etc/fonts``), and the page
|
||||
reads their effect (``getImageData`` of a canvas with text). A value a page reads must not depend on the machine. The engine runs fontconfig on its
|
||||
own empty configuration: it reads no ``fonts.conf``, no rule, no cache folder and no GTK or Xft option, so every rule below must change nothing.
|
||||
|
||||
How a rule enters. As the rule of a host does, system-wide: ``/etc/fonts/local.conf``, the file the system ``fonts.conf`` includes for the rules of the
|
||||
administrator, written with ``sudo`` (the runner has it without a password) just before the launch and put back as it was (or removed, if there was
|
||||
none) when the launch ends, whatever its outcome. Not through the environment: the core owns ``XDG_CONFIG_HOME`` and ``XDG_CONFIG_DIRS`` and points
|
||||
both at empty folders of its own, and removes ``FONTCONFIG_*`` and ``FC_*``, so no variable the test sets can carry a rule to the engine, and a test
|
||||
built on one would be green for the wrong reason. The files of the system are where a host can still put a rule, and where the engine must not read it.
|
||||
|
||||
What is drawn. One local page (http://127.0.0.1, a secure context, so ``crypto.subtle`` answers) draws ``fillText`` with the same seed in every launch:
|
||||
|
||||
* on two canvases per row: (a) OPAQUE, ``getContext('2d', {alpha: false})``, white fill first (Skia turns subpixel anti-aliasing on only for an
|
||||
opaque canvas: ``SetPermitSubpixelAA(IsOpaque)``, which is where ``rgba`` and ``lcdfilter`` show); (b) the DEFAULT one, white fill first too,
|
||||
so that the only difference between the two is the opacity of the canvas;
|
||||
* with fonts of the engine's bundle (the manifest of the core: ``tests/_font_names.py``): Arial (Latin), SimSun and MS Gothic (CJK). The two CJK
|
||||
faces are the ones of the bundle that ship embedded bitmaps on a retail Windows (SimSun at 12 to 16 px, MS Gothic at its small sizes), so they
|
||||
are where ``embeddedbitmap`` can show; Arial and its outlines are the control that has none;
|
||||
* at 9, 11, 12, 13 and 16 px, one row per (font, size) and canvas.
|
||||
|
||||
Each row returns the sha256 of the ``getImageData`` bytes, the number of pixels with R != G or G != B (subpixel anti-aliasing: grayscale text has
|
||||
none), the number of pixels that are not white (the text is there) and the width ``measureText`` gives.
|
||||
|
||||
Seven launches, one engine, one seed, each with its own ``/etc/fonts/local.conf``:
|
||||
|
||||
1. nothing: a ``local.conf`` with no rule (the rules of the machine, whatever they are);
|
||||
2. ``rgba=none`` and ``lcdfilter=lcdnone`` (the runner's own rules say rgba=rgb: this is the other side of it);
|
||||
3. ``rgba=bgr``;
|
||||
4. ``embeddedbitmap=false``;
|
||||
5. ``autohint=true``;
|
||||
6. ``hintstyle=hintfull`` and ``antialias=false`` (the two the engine declares: a rule of a user must not move them either);
|
||||
7. a rule that really moves ``system-ui`` inside fontconfig: ``<match target="pattern">`` on the family ``system-ui``, ``<edit name="family"
|
||||
mode="prepend_first" binding="strong">`` of a face every runner has (the engine builds exactly such a pattern for a generic family:
|
||||
FC_FAMILY = "system-ui", FC_SCALABLE, FC_LANG, then ``FcConfigSubstitute`` and ``FcFontSort``).
|
||||
|
||||
Each is a separate configuration. The positive control: before each engine starts, ``fc-match`` runs on the HOST, in the environment of the test process
|
||||
(less ``FONTCONFIG_*`` and ``FC_*``), and says whether the rule is in force; a launch whose rule is not in force measures nothing and the test says so,
|
||||
and fails: a launch that measures nothing is not a pass (the raw lines are in ``result.json``). Why the system-ui rule did not take in the measurement of the old engine (run 45078210028): ``fc-match
|
||||
system-ui`` PARSES its argument as a fontconfig name, in which ``-`` starts the size (``family-size``), so fontconfig matched the family ``system``
|
||||
and the rule on ``system-ui`` never fired. The test asks ``fc-match`` for ``system\\-ui`` (the hyphen escaped), which is the family the engine builds.
|
||||
|
||||
The assertions:
|
||||
* every launch has its rule in force in fontconfig itself (the host control above), and every row drew text (a blank canvas would equal any other);
|
||||
* every launch gives the same pixel hashes as launch 1, row by row, for the opaque canvas and for the default one;
|
||||
* with the rule on ``system-ui``, a page reads the same computed ``font-family`` and the same widths (canvas and layout, Latin and CJK) as in launch 1.
|
||||
|
||||
Red on the old engine (run 45078210028: ``rgba=none`` with ``lcdfilter=none`` changed 11 of 15 opaque rows, and ``embeddedbitmap=false`` changed 8 of 15
|
||||
rows on both canvases): the rules reach the face through the host's configuration. Green on the engine that runs fontconfig on its own empty one.
|
||||
|
||||
Evidence, whatever the verdict: when ``RUNNER_TEMP`` is set the test writes ``result.json`` under ``$RUNNER_TEMP/invpw-evidence/fontconfig-rules/``: per
|
||||
launch, the configuration, the hashes and subpixel counts by row, the reads of ``system-ui``, what ``fc-match`` says and the ``FONTCONFIG_*`` / ``FC_*``
|
||||
variables seen in the engine's processes. A table is printed (launch by canvas: same or different from launch 1, subpixel pixels in total). A failure to
|
||||
write it never changes the outcome.
|
||||
|
||||
Run: pytest tests/test_the_host_fontconfig_rules_do_not_reach_the_text_pixels_linux_e2e.py -m e2e -v -s
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
import http.server
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import socketserver
|
||||
import subprocess
|
||||
import sys
|
||||
import threading
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from test_a_screenshot_draws_the_text_of_the_bundled_fonts_as_the_content_does_e2e import EVIDENCE_FOLDER
|
||||
|
||||
pytestmark = [
|
||||
pytest.mark.e2e,
|
||||
pytest.mark.skipif(not sys.platform.startswith("linux"), reason="fontconfig is the Linux font system"),
|
||||
]
|
||||
|
||||
SEED = 21
|
||||
|
||||
#: (font, text, why). The text of each is in the writing the face draws.
|
||||
FONTS = [
|
||||
("Arial", "Hamburgefonstiv 0123456789 éèàü", "Latin outlines: the control, no embedded bitmaps"),
|
||||
("SimSun", "中文汉字测试 ABC abc 0123", "CJK, embedded bitmaps at 12-16 px on a retail Windows"),
|
||||
("MS Gothic", "日本語のテキスト ABC abc アイウエオ", "CJK, embedded bitmaps at its small sizes"),
|
||||
]
|
||||
SIZES = [9, 11, 12, 13, 16]
|
||||
CANVASES = ["opaque", "default"]
|
||||
|
||||
#: A face a runner has, whose family differs from the one fontconfig answers to ``system-ui`` by default (a sans): the rule of the last launch
|
||||
#: puts it first.
|
||||
HOST_FACE_CANDIDATES = [
|
||||
("/usr/share/fonts/truetype/dejavu/DejaVuSerif.ttf", "DejaVu Serif"),
|
||||
("/usr/share/fonts/truetype/liberation/LiberationSerif-Regular.ttf", "Liberation Serif"),
|
||||
]
|
||||
|
||||
#: The system-wide file of the rules of a host; the system ``fonts.conf`` includes it.
|
||||
LOCAL_CONF = Path("/etc/fonts/local.conf")
|
||||
|
||||
#: name of the launch -> the rules, ``(property, kind, value)``. The ``local.conf`` of a launch holds them and nothing else.
|
||||
LAUNCHES = [
|
||||
("1_nothing", []),
|
||||
("2_rgba_none_lcdnone", [("rgba", "const", "none"), ("lcdfilter", "const", "lcdnone")]),
|
||||
("3_rgba_bgr", [("rgba", "const", "bgr")]),
|
||||
("4_embeddedbitmap_off", [("embeddedbitmap", "bool", "false")]),
|
||||
("5_autohint", [("autohint", "bool", "true")]),
|
||||
("6_hintfull_antialias_off", [("hintstyle", "const", "hintfull"), ("antialias", "bool", "false")]),
|
||||
("7_system_ui_prepend", []),
|
||||
]
|
||||
SYSTEM_UI_LAUNCH = "7_system_ui_prepend"
|
||||
BASE_LAUNCH = "1_nothing"
|
||||
#: The pattern the engine builds for a generic family (``gfxFcPlatformFontList::FindGenericFamilies``: FC_FAMILY = the generic name, FC_SCALABLE true,
|
||||
#: FC_LANG = the sample language), written as ``fc-match`` reads a name: the hyphen of ``system-ui`` is escaped, or it starts the size.
|
||||
ENGINE_PATTERN = "system\\-ui:scalable=true:lang=en"
|
||||
PROPERTIES = ("rgba", "lcdfilter", "autohint", "embeddedbitmap", "hintstyle", "antialias")
|
||||
#: What ``fc-match -f '%{property}'`` prints for the configuration of each launch: the integers are fontconfig's own constants (FC_RGBA_BGR 2,
|
||||
#: FC_RGBA_NONE 5, FC_LCD_NONE 0, FC_HINT_FULL 3), a boolean prints True or False. The raw ``fc-match -v`` lines of every launch are in result.json
|
||||
#: beside them. A value that is not the one written here still counts as the rule in force when it is DIFFERENT from what launch 1 prints for the
|
||||
#: same property (the form is uncertain, the move is not); both are recorded.
|
||||
EXPECTED_FC = {
|
||||
"2_rgba_none_lcdnone": {"rgba": "5", "lcdfilter": "0"},
|
||||
"3_rgba_bgr": {"rgba": "2"},
|
||||
"4_embeddedbitmap_off": {"embeddedbitmap": "False"},
|
||||
"5_autohint": {"autohint": "True"},
|
||||
"6_hintfull_antialias_off": {"hintstyle": "3", "antialias": "False"},
|
||||
}
|
||||
|
||||
#: Draws every row. ``args`` = [fonts, sizes]. Returns [{canvas, font, size, sha256, subpixel, ink, width, fallback_width}].
|
||||
ROWS_JS = """async (args) => {
|
||||
const [fonts, sizes] = args;
|
||||
const hex = (buf) => Array.from(new Uint8Array(buf)).map(b => b.toString(16).padStart(2, '0')).join('');
|
||||
const fnv = (bytes) => { let h = 0x811c9dc5; for (let i = 0; i < bytes.length; i++) { h ^= bytes[i]; h = Math.imul(h, 0x01000193) >>> 0; } return 'fnv:' + h.toString(16); };
|
||||
const out = [];
|
||||
for (const kind of ['opaque', 'default']) {
|
||||
for (const [family, text] of fonts) {
|
||||
for (const size of sizes) {
|
||||
const c = document.createElement('canvas'); c.width = 400; c.height = size * 2 + 12;
|
||||
const x = kind === 'opaque' ? c.getContext('2d', {alpha: false}) : c.getContext('2d');
|
||||
x.fillStyle = '#fff'; x.fillRect(0, 0, c.width, c.height);
|
||||
x.fillStyle = '#000'; x.textBaseline = 'alphabetic';
|
||||
x.font = size + 'px "' + family + '"';
|
||||
x.fillText(text, 4, size + 4);
|
||||
const width = x.measureText(text).width;
|
||||
x.font = size + 'px "NoSuchFamilyForTheFallback"';
|
||||
const fallback_width = x.measureText(text).width;
|
||||
const data = x.getImageData(0, 0, c.width, c.height).data;
|
||||
let subpixel = 0, ink = 0;
|
||||
for (let i = 0; i < data.length; i += 4) {
|
||||
if (data[i] !== data[i + 1] || data[i + 1] !== data[i + 2]) subpixel++;
|
||||
if (data[i] !== 255 || data[i + 1] !== 255 || data[i + 2] !== 255) ink++;
|
||||
}
|
||||
const sha256 = (window.crypto && crypto.subtle) ? hex(await crypto.subtle.digest('SHA-256', data)) : fnv(data);
|
||||
out.push({canvas: kind, font: family, size, sha256, subpixel, ink, width, fallback_width});
|
||||
}
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}"""
|
||||
|
||||
#: What a page reads of ``system-ui``.
|
||||
SYSTEM_UI_JS = """() => {
|
||||
const latin = 'Hamburgefonstiv 0123456789', cjk = '\\u4e2d';
|
||||
const span = (text) => { const s = document.createElement('span'); s.style.cssText = 'position:absolute;left:-9999px;white-space:pre;font:16px system-ui'; s.textContent = text; document.body.appendChild(s); return s; };
|
||||
const a = span(latin), b = span(cjk);
|
||||
const x = document.createElement('canvas').getContext('2d');
|
||||
x.font = '16px system-ui';
|
||||
const out = {
|
||||
computed_font_family: getComputedStyle(a).fontFamily,
|
||||
canvas_font: x.font,
|
||||
canvas_width_latin: x.measureText(latin).width,
|
||||
canvas_width_cjk: x.measureText(cjk).width,
|
||||
dom_width_latin: a.getBoundingClientRect().width,
|
||||
dom_width_cjk: b.getBoundingClientRect().width,
|
||||
};
|
||||
a.remove(); b.remove();
|
||||
return out;
|
||||
}"""
|
||||
|
||||
_PAGE = b"<!doctype html><meta charset=utf-8><title>fcrules</title><body style='margin:0;background:#fff'>"
|
||||
|
||||
|
||||
class _Handler(http.server.BaseHTTPRequestHandler):
|
||||
def do_GET(self): # noqa: N802
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "text/html; charset=utf-8")
|
||||
self.send_header("Content-Length", str(len(_PAGE)))
|
||||
self.end_headers()
|
||||
self.wfile.write(_PAGE)
|
||||
|
||||
def log_message(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
class _Server(socketserver.ThreadingTCPServer):
|
||||
allow_reuse_address = True
|
||||
daemon_threads = True
|
||||
|
||||
|
||||
def _evidence_dir():
|
||||
base = os.environ.get("RUNNER_TEMP")
|
||||
return Path(base) / EVIDENCE_FOLDER / "fontconfig-rules" if base else None
|
||||
|
||||
|
||||
def _config_text(name: str, rules, host_family: str) -> str:
|
||||
"""The ``/etc/fonts/local.conf`` of a launch: its rules and nothing else (the system ``fonts.conf`` includes it)."""
|
||||
parts = ['<?xml version="1.0"?>', '<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">', "<fontconfig>"]
|
||||
if name == SYSTEM_UI_LAUNCH:
|
||||
# STRONG, and first: the face comes before ``system-ui`` and before every family the rules of the system add behind it.
|
||||
parts.append(' <match target="pattern">')
|
||||
parts.append(' <test qual="any" name="family"><string>system-ui</string></test>')
|
||||
parts.append(' <edit name="family" mode="prepend_first" binding="strong"><string>%s</string></edit>' % host_family)
|
||||
parts.append(" </match>")
|
||||
for target in ("pattern", "font"):
|
||||
if rules:
|
||||
parts.append(' <match target="%s">' % target)
|
||||
for prop, kind, value in rules:
|
||||
parts.append(' <edit name="%s" mode="assign"><%s>%s</%s></edit>' % (prop, kind, value, kind))
|
||||
parts.append(" </match>")
|
||||
parts.append("</fontconfig>")
|
||||
return "\n".join(parts) + "\n"
|
||||
|
||||
|
||||
def _fc_env() -> dict:
|
||||
"""The environment ``fc-match`` runs in: the test's own, without the variables the core strips."""
|
||||
return {k: v for k, v in os.environ.items() if not k.startswith(("FONTCONFIG_", "FC_"))}
|
||||
|
||||
|
||||
def _sudo(*argv: str, data: bytes | None = None) -> subprocess.CompletedProcess:
|
||||
"""``sudo`` without a password prompt (``-n``): a runner without it fails here, loudly, and the test says so."""
|
||||
return subprocess.run(["sudo", "-n", *argv], input=data, capture_output=True, timeout=60)
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def _system_rule(text: str):
|
||||
"""``/etc/fonts/local.conf`` holds ``text`` inside the block; on the way out, whatever happened, the file is what it was before (or is removed, if there
|
||||
was none). A host that cannot be written to is a failure of the test, never a launch without its rule."""
|
||||
original = LOCAL_CONF.read_bytes() if LOCAL_CONF.is_file() else None
|
||||
try:
|
||||
done = _sudo("tee", str(LOCAL_CONF), data=text.encode("utf-8"))
|
||||
assert done.returncode == 0, "cannot write %s with sudo: %s" % (LOCAL_CONF, done.stderr.decode("utf-8", "replace").strip())
|
||||
yield
|
||||
finally:
|
||||
if original is None:
|
||||
done = _sudo("rm", "-f", str(LOCAL_CONF))
|
||||
else:
|
||||
done = _sudo("tee", str(LOCAL_CONF), data=original)
|
||||
assert done.returncode == 0, "cannot put %s back with sudo: %s" % (LOCAL_CONF, done.stderr.decode("utf-8", "replace").strip())
|
||||
|
||||
|
||||
def _fc_match(env: dict, pattern: str, fmt: str) -> str:
|
||||
done = subprocess.run(["fc-match", "-f", fmt, pattern], env=env, capture_output=True, text=True, timeout=60)
|
||||
return done.stdout.strip()
|
||||
|
||||
|
||||
def _what_fontconfig_says() -> dict:
|
||||
"""What fontconfig itself says on the host with the rule of this launch in place (the host tool, not the browser): the value of each property, the raw
|
||||
``fc-match -v`` lines of them, and the family it answers to ``system-ui`` (the pattern the engine builds)."""
|
||||
out = {}
|
||||
env = _fc_env()
|
||||
try:
|
||||
for key in PROPERTIES:
|
||||
out[key] = _fc_match(env, "sans", "%%{%s}" % key)
|
||||
verbose = subprocess.run(["fc-match", "-v", "sans"], env=env, capture_output=True, text=True, timeout=60).stdout
|
||||
out["raw"] = [line.strip() for line in verbose.splitlines() if line.strip().split(":", 1)[0] in PROPERTIES + ("hinting",)]
|
||||
out["system-ui_engine_pattern_family"] = _fc_match(env, ENGINE_PATTERN, "%{family}")
|
||||
out["system-ui_engine_pattern_asked"] = _fc_match(env, ENGINE_PATTERN, "%{pattern}")[:300]
|
||||
out["sans_family"] = _fc_match(env, "sans", "%{family}")
|
||||
except Exception as exc: # recorded; the precondition below then names it
|
||||
out["error"] = repr(exc)
|
||||
return out
|
||||
|
||||
|
||||
def _rule_in_force(name: str, said: dict, base_said: dict, host_family: str) -> dict:
|
||||
"""The precondition of a launch, decided BEFORE its engine starts: does fontconfig on the host apply the rule? A launch whose
|
||||
rule is not in force measures nothing (it would equal launch 1 whatever the engine does)."""
|
||||
problems, notes = [], []
|
||||
if "error" in said:
|
||||
problems.append("fc-match could not be run: %s" % said["error"])
|
||||
for prop, want in EXPECTED_FC.get(name, {}).items():
|
||||
got = said.get(prop)
|
||||
if got == want:
|
||||
continue
|
||||
if got and got != base_said.get(prop):
|
||||
notes.append("%s prints %r, not %r, and it is not what launch 1 prints (%r): the form is uncertain, the move is not"
|
||||
% (prop, got, want, base_said.get(prop)))
|
||||
else:
|
||||
problems.append("%s: fc-match prints %r (launch 1 prints %r), the rule wants %r" % (prop, got, base_said.get(prop), want))
|
||||
if name == SYSTEM_UI_LAUNCH:
|
||||
got = said.get("system-ui_engine_pattern_family", "")
|
||||
if not got.startswith(host_family):
|
||||
problems.append("fc-match %s answers %r (launch 1: %r), the rule wants %r"
|
||||
% (ENGINE_PATTERN, got, base_said.get("system-ui_engine_pattern_family"), host_family))
|
||||
if got and got == base_said.get("system-ui_engine_pattern_family"):
|
||||
problems.append("fc-match %s answers %r, the same as with no rule: the rule moved nothing" % (ENGINE_PATTERN, got))
|
||||
return {"ok": not problems, "problems": problems, "notes": notes}
|
||||
|
||||
|
||||
def _engine_environ(binary: str) -> dict:
|
||||
"""Evidence only: the processes of the engine seen in ``/proc`` and any ``FONTCONFIG_*`` / ``FC_*`` in their environment (the core removes them)."""
|
||||
seen = {"processes": 0, "fontconfig_variables": []}
|
||||
try:
|
||||
real = os.path.realpath(binary)
|
||||
for entry in os.scandir("/proc"):
|
||||
if not entry.name.isdigit():
|
||||
continue
|
||||
try:
|
||||
argv0 = Path(entry.path, "cmdline").read_bytes().split(b"\0")[0].decode("utf-8", "replace")
|
||||
if os.path.realpath(argv0) != real:
|
||||
continue
|
||||
env = dict(item.partition(b"=")[::2] for item in Path(entry.path, "environ").read_bytes().split(b"\0") if item)
|
||||
except OSError:
|
||||
continue
|
||||
seen["processes"] += 1
|
||||
seen["fontconfig_variables"] += sorted(k.decode("utf-8", "replace") for k in env if k.startswith((b"FONTCONFIG_", b"FC_")))
|
||||
except Exception as exc:
|
||||
seen["error"] = repr(exc)
|
||||
return seen
|
||||
|
||||
|
||||
def _launch(binary: str, url: str) -> dict:
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
result = {}
|
||||
# A FONTCONFIG_FILE or FONTCONFIG_PATH of the runner is taken off: with one of them, the system ``fonts.conf`` would not be read, nor would the
|
||||
# ``local.conf`` it includes.
|
||||
with pytest.MonkeyPatch.context() as patch:
|
||||
for variable in ("FONTCONFIG_FILE", "FONTCONFIG_PATH"):
|
||||
patch.delenv(variable, raising=False)
|
||||
with InvisiblePlaywright(seed=SEED, binary_path=binary, headless=True) as browser:
|
||||
page = browser.new_context().new_page()
|
||||
page.goto(url, timeout=30_000)
|
||||
result["rows"] = page.evaluate(ROWS_JS, [[[f, t] for f, t, _w in FONTS], SIZES])
|
||||
result["system_ui"] = page.evaluate(SYSTEM_UI_JS)
|
||||
result["engine_environ"] = _engine_environ(binary)
|
||||
return result
|
||||
|
||||
|
||||
def _by_row(rows) -> dict:
|
||||
return {(r["canvas"], r["font"], r["size"]): r for r in rows}
|
||||
|
||||
|
||||
def _compare(results: dict, base: str) -> dict:
|
||||
"""{launch: {canvas: [rows that differ from the base launch]}}."""
|
||||
ref = _by_row(results[base]["rows"])
|
||||
out = {}
|
||||
for name, res in results.items():
|
||||
mine = _by_row(res["rows"])
|
||||
out[name] = {canvas: sorted("%s %dpx" % (k[1], k[2]) for k, row in mine.items()
|
||||
if k[0] == canvas and row["sha256"] != ref[k]["sha256"]) for canvas in CANVASES}
|
||||
return out
|
||||
|
||||
|
||||
def _table(results: dict, base: str) -> str:
|
||||
diff = _compare(results, base)
|
||||
lines = ["", "launch x canvas -> vs %s (rows that differ / rows), subpixel pixels in total" % base]
|
||||
for name, res in results.items():
|
||||
cells = []
|
||||
for canvas in CANVASES:
|
||||
total = sum(r["subpixel"] for r in res["rows"] if r["canvas"] == canvas)
|
||||
rows = sum(1 for r in res["rows"] if r["canvas"] == canvas)
|
||||
d = diff[name][canvas]
|
||||
cells.append("%s: %s (%d/%d), subpixel %d" % (canvas, "same" if not d else "DIFFERENT", len(d), rows, total))
|
||||
lines.append(" %-26s %s" % (name, " | ".join(cells)))
|
||||
for name in results:
|
||||
for canvas in CANVASES:
|
||||
if diff[name][canvas]:
|
||||
lines.append(" %s %s differs in: %s" % (name, canvas, ", ".join(diff[name][canvas])))
|
||||
lines.append("system-ui reads:")
|
||||
for name in (base, SYSTEM_UI_LAUNCH):
|
||||
if name in results:
|
||||
lines.append(" %-26s %s" % (name, json.dumps(results[name]["system_ui"], sort_keys=True)))
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def launches(firefox_binary):
|
||||
"""Every launch, once per module. -> {name: result}; the record is written before the assertions run."""
|
||||
for tool in ("fc-match", "sudo"):
|
||||
if shutil.which(tool) is None:
|
||||
pytest.fail("needs %s (fontconfig, sudo): without it no rule can be put on the host and shown to be in force" % tool, pytrace=False)
|
||||
if _sudo("true").returncode != 0:
|
||||
pytest.fail("needs sudo without a password: a rule of the host is written to %s" % LOCAL_CONF, pytrace=False)
|
||||
face, host_family = next(((p, f) for p, f in HOST_FACE_CANDIDATES if os.path.exists(p)), (None, None))
|
||||
assert face, "no host face to put first for the system-ui launch: none of %r exists on this runner" % [p for p, _f in HOST_FACE_CANDIDATES]
|
||||
|
||||
server = _Server(("127.0.0.1", 0), _Handler)
|
||||
threading.Thread(target=server.serve_forever, daemon=True).start()
|
||||
url = "http://127.0.0.1:%d/" % server.server_address[1]
|
||||
results, fc = {}, {}
|
||||
try:
|
||||
for name, rules in LAUNCHES:
|
||||
config = _config_text(name, rules, host_family)
|
||||
with _system_rule(config):
|
||||
# Before the engine starts: fontconfig on the host with this rule in place. Its answer says whether the launch measures anything.
|
||||
fc[name] = _what_fontconfig_says()
|
||||
precondition = _rule_in_force(name, fc[name], fc.get(BASE_LAUNCH, fc[name]), host_family)
|
||||
results[name] = _launch(firefox_binary, url)
|
||||
results[name]["config"] = config
|
||||
results[name]["fc_match"] = fc[name]
|
||||
results[name]["precondition"] = precondition
|
||||
finally:
|
||||
server.shutdown()
|
||||
server.server_close()
|
||||
try:
|
||||
record = {
|
||||
"seed": SEED, "host_face": face, "host_family": host_family, "fonts": [f for f, _t, _w in FONTS], "sizes": SIZES,
|
||||
"launches": results, "differences_vs_1": _compare(results, BASE_LAUNCH) if BASE_LAUNCH in results else None,
|
||||
}
|
||||
where = _evidence_dir()
|
||||
if where is not None:
|
||||
where.mkdir(parents=True, exist_ok=True)
|
||||
(where / "result.json").write_text(json.dumps(record, indent=1, sort_keys=True), encoding="utf-8")
|
||||
if BASE_LAUNCH in results:
|
||||
print(_table(results, BASE_LAUNCH))
|
||||
print("FONTCONFIG_* / FC_* variables seen in the engine's processes:",
|
||||
{n: (r.get("engine_environ") or {}).get("fontconfig_variables") for n, r in results.items()})
|
||||
except Exception as exc: # a record never changes the outcome
|
||||
print("the record could not be written:", repr(exc))
|
||||
return results
|
||||
|
||||
|
||||
def _every_launch_measures_something(launches):
|
||||
"""The first assertion of every test: a launch whose rule fontconfig itself does not apply measures nothing, and the comparison would say "equal"."""
|
||||
assert set(launches) == {n for n, _r in LAUNCHES}, "not every launch ran: %s" % sorted(launches)
|
||||
for name, _rules in LAUNCHES:
|
||||
pre = launches[name]["precondition"]
|
||||
assert pre["ok"], "launch %s measures nothing: fontconfig does not apply its rule: %s (it said: %r)" % (
|
||||
name, "; ".join(pre["problems"]), launches[name]["fc_match"])
|
||||
|
||||
|
||||
@pytest.mark.timeout(900, method="thread")
|
||||
def test_every_launch_has_its_rule_in_force_in_fontconfig_itself_and_in_the_engine_s_environment(launches):
|
||||
"""Without this the equalities below would say nothing: a configuration fontconfig ignores is equal to any other. The rule is in force when ``fc-match``
|
||||
on the host obeys it (the engine's environment is not the route: the core gives the engine empty folders of its own)."""
|
||||
_every_launch_measures_something(launches)
|
||||
|
||||
|
||||
@pytest.mark.timeout(900, method="thread")
|
||||
def test_the_fontconfig_rules_of_the_user_do_not_move_a_pixel_of_the_text_a_page_reads(launches):
|
||||
_every_launch_measures_something(launches)
|
||||
# The comparison is not empty: every row drew text.
|
||||
blank = [(n, k) for n, res in launches.items() for k, r in _by_row(res["rows"]).items() if r["ink"] == 0]
|
||||
assert not blank, "rows with no text drawn (a blank canvas equals any other): %r" % blank[:6]
|
||||
diff = _compare(launches, BASE_LAUNCH)
|
||||
moved = {n: d for n, d in diff.items() if n != BASE_LAUNCH and any(d.values())}
|
||||
assert not moved, (
|
||||
"the fontconfig rules of the user change the pixels of the text a page reads (rows that differ from launch 1, by launch and canvas): %s"
|
||||
% json.dumps(moved, sort_keys=True))
|
||||
|
||||
|
||||
@pytest.mark.timeout(900, method="thread")
|
||||
def test_a_rule_of_the_user_on_system_ui_does_not_choose_the_face_a_page_reads(launches):
|
||||
_every_launch_measures_something(launches)
|
||||
first, other = launches[BASE_LAUNCH]["system_ui"], launches[SYSTEM_UI_LAUNCH]["system_ui"]
|
||||
assert first == other, (
|
||||
"a fontconfig rule on system-ui reaches what a page reads of it: launch 1 read %s, launch %s read %s"
|
||||
% (json.dumps(first, sort_keys=True), SYSTEM_UI_LAUNCH, json.dumps(other, sort_keys=True)))
|
||||
+143
@@ -0,0 +1,143 @@
|
||||
"""The system colors of the host gate's retail reference come from the retail captures by a script, and the committed reference is what that script writes: nothing is typed.
|
||||
|
||||
``scripts/ci_host_gate.py`` holds every CSS system color keyword (``surface.systemColors``) of each leg to the reading of retail Firefox 159 on Windows, kept in
|
||||
``scripts/host_gate/reference/firefox-159/dpr<x>.json.gz``. Candidate 46941424205's host gate was red on 8 leaves (Highlight and SelectedItem, linux and win, DPR 1.0 and 1.5): the reference said
|
||||
the value of a Windows build no current Windows runs, and nobody had read it from the two captures of RetailCaptures (``syscolors``, build 26100 on 2026-12-01 and client build 26200 on 2026-12-02,
|
||||
run 46828919060), which agree. ``scripts/extract_retail_syscolors.py`` now writes ``surface.systemColors`` of every reference file from them. With no browser and no capture:
|
||||
|
||||
1. the extraction runs on two small captures made here (the shape of ``result.json`` and ``meta.json``): it gives their colors, with the sha256 of the files read;
|
||||
2. known-bad captures are refused, never filled in: one capture alone, a ``result.json`` that is not the file ``meta.json`` lists, two captures that read a keyword two ways, a capture that is not
|
||||
Windows, one that does not read a keyword of the reference, one of another Firefox;
|
||||
3. the committed reference has, at every DPR it holds, exactly the colors of ``syscolors-source.json`` (what the script wrote from the captures), the source lists two captures on two builds with
|
||||
the sha256 of their ``result.json``, and the key order of the gate's list is the reference's.
|
||||
|
||||
Known-bad: a reference with a color nobody read from a capture (the old file has no ``syscolors-source.json`` at all). Green: the state of the repository.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import copy
|
||||
import gzip
|
||||
import hashlib
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List
|
||||
|
||||
import pytest
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(ROOT / "scripts"))
|
||||
|
||||
import extract_retail_syscolors as ex # noqa: E402
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
KEYWORDS = ["Canvas", "Highlight", "-moz-buttonhoverface"]
|
||||
COLORS = {"Canvas": ("rgb(255, 255, 255)", True), "Highlight": ("rgb(1, 2, 3)", True), "-moz-buttonhoverface": ("rgb(0, 0, 0)", False)}
|
||||
|
||||
|
||||
def _result(colors: Dict[str, Any] = None, platform: str = "Win32") -> Dict[str, Any]:
|
||||
colors = colors or COLORS
|
||||
return {"env": {"platform": platform},
|
||||
"element": {"light": {k: {"accepted": ok, "color": c, "backgroundColor": c, "group": "g"} for k, (c, ok) in colors.items()}, "dark": {}}}
|
||||
|
||||
|
||||
def _capture(tmp_path: Path, image: str, date: str, result: Dict[str, Any] = None, *, listed_sha: str = None, firefox: str = "159.0") -> Path:
|
||||
folder = tmp_path / "captures" / "firefox-159.0" / image / "syscolors" / date
|
||||
folder.mkdir(parents=True)
|
||||
path = folder / "result.json"
|
||||
path.write_text(json.dumps(result or _result()), encoding="utf-8")
|
||||
meta = {"format": "retail-syscolors/1", "firefox_version": firefox, "build_id": "20261022150525",
|
||||
"files": {"result.json": {"sha256": listed_sha or hashlib.sha256(path.read_bytes()).hexdigest()}},
|
||||
"binaries": {"xul_dll_sha256": image.encode().hex() * 4, "firefox_exe_sha256": "cd" * 32}}
|
||||
(folder / "meta.json").write_text(json.dumps(meta), encoding="utf-8")
|
||||
return folder
|
||||
|
||||
|
||||
def _two(tmp_path: Path, **second) -> List[Path]:
|
||||
return [_capture(tmp_path, "windows-a", "2026-12-01"), _capture(tmp_path, "windows-b", "2026-12-02", **second)]
|
||||
|
||||
|
||||
def _refused(captures: List[Path], fragment: str) -> None:
|
||||
with pytest.raises(ex.ExtractError) as info:
|
||||
ex.build(captures, KEYWORDS, "abc123")
|
||||
assert fragment in str(info.value), str(info.value)
|
||||
|
||||
|
||||
def test_the_extraction_gives_the_colors_the_two_captures_read_with_the_sha256_of_the_files_read(tmp_path):
|
||||
captures = _two(tmp_path)
|
||||
data = ex.build(captures, KEYWORDS, "abc123")
|
||||
assert data["values"] == {k: c for k, (c, _) in COLORS.items()} and list(data["values"]) == KEYWORDS
|
||||
assert data["retail_captures_commit"] == "abc123"
|
||||
assert [c["result_sha256"] for c in data["captures"]] == [ex.sha256_of(f / "result.json") for f in captures]
|
||||
assert [c["folder"] for c in data["captures"]] == ["captures/firefox-159.0/windows-a/syscolors/2026-12-01", "captures/firefox-159.0/windows-b/syscolors/2026-12-02"]
|
||||
|
||||
|
||||
def test_one_capture_alone_is_refused(tmp_path):
|
||||
_refused(_two(tmp_path)[:1], "not from one")
|
||||
|
||||
|
||||
def test_a_result_that_is_not_the_file_the_capture_listed_is_refused(tmp_path):
|
||||
_refused(_two(tmp_path, listed_sha="0" * 64), "not the file the capture recorded")
|
||||
|
||||
|
||||
def test_two_captures_that_read_a_keyword_two_ways_are_refused_and_none_is_chosen(tmp_path):
|
||||
other = dict(COLORS, Highlight=("rgb(9, 9, 9)", True))
|
||||
_refused(_two(tmp_path, result=_result(other)), "read Highlight two ways")
|
||||
|
||||
|
||||
def test_two_captures_that_disagree_on_whether_firefox_accepts_a_keyword_are_refused(tmp_path):
|
||||
other = dict(COLORS, **{"-moz-buttonhoverface": ("rgb(0, 0, 0)", True)})
|
||||
_refused(_two(tmp_path, result=_result(other)), "read -moz-buttonhoverface two ways")
|
||||
|
||||
|
||||
def test_a_capture_that_is_not_windows_is_refused(tmp_path):
|
||||
_refused(_two(tmp_path, result=_result(platform="Linux x86_64")), "not a Windows capture")
|
||||
|
||||
|
||||
def test_a_capture_that_does_not_read_a_keyword_of_the_reference_is_refused(tmp_path):
|
||||
short = {k: v for k, v in COLORS.items() if k != "Highlight"}
|
||||
_refused(_two(tmp_path, result=_result(short)), "no retail value, none invented")
|
||||
|
||||
|
||||
def test_a_capture_of_another_firefox_is_refused(tmp_path):
|
||||
_refused(_two(tmp_path, firefox="160.0"), "not the capture of the reference")
|
||||
|
||||
|
||||
def test_a_reference_with_other_keywords_than_the_captures_is_refused(tmp_path):
|
||||
ref = tmp_path / "reference"
|
||||
ref.mkdir()
|
||||
(ref / "dpr1.0.json.gz").write_bytes(gzip.compress(json.dumps({"items": {ex.ITEM: {"Canvas": "rgb(0, 0, 0)"}}}).encode()))
|
||||
with pytest.raises(ex.ExtractError) as info:
|
||||
ex.apply(ref, ex.build(_two(tmp_path), KEYWORDS, "abc123"))
|
||||
assert "with the keywords of the captures" in str(info.value)
|
||||
|
||||
|
||||
def test_apply_changes_the_system_colors_alone_and_keeps_the_rest_of_the_reference(tmp_path):
|
||||
ref = tmp_path / "reference"
|
||||
ref.mkdir()
|
||||
old = {"format": "host-gate/1", "items": {ex.ITEM: {k: "rgb(7, 7, 7)" for k in KEYWORDS}, "surface.math": {"sin": 1}}}
|
||||
(ref / "dpr1.0.json.gz").write_bytes(gzip.compress(json.dumps(old).encode()))
|
||||
(out,) = ex.apply(ref, ex.build(_two(tmp_path), KEYWORDS, "abc123")).values()
|
||||
expected = copy.deepcopy(old)
|
||||
expected["items"][ex.ITEM] = {k: c for k, (c, _) in COLORS.items()}
|
||||
assert out == expected
|
||||
|
||||
|
||||
def test_the_committed_reference_holds_exactly_the_colors_the_script_wrote_from_the_captures():
|
||||
source = json.loads(ex.SOURCE_PATH.read_text(encoding="utf-8"))
|
||||
files = ex.reference_files()
|
||||
assert [p.name for p in files] == ["dpr1.0.json.gz", "dpr1.5.json.gz"], files
|
||||
for path in files:
|
||||
held = json.loads(gzip.decompress(path.read_bytes()))["items"][ex.ITEM]
|
||||
assert held == source["values"] and list(held) == list(source["values"]), "%s: surface.systemColors is not what scripts/extract_retail_syscolors.py wrote" % path.name
|
||||
|
||||
|
||||
def test_the_source_lists_two_captures_on_two_builds_with_the_sha256_of_what_was_read():
|
||||
source = json.loads(ex.SOURCE_PATH.read_text(encoding="utf-8"))
|
||||
captures = source["captures"]
|
||||
assert len(captures) >= 2 and len({c["xul_dll_sha256"] for c in captures}) == len(captures) and len({c["folder"] for c in captures}) == len(captures)
|
||||
for c in captures:
|
||||
assert len(c["result_sha256"]) == 64 and len(c["xul_dll_sha256"]) == 64 and c["build_id"], c
|
||||
assert "/syscolors/" in c["folder"] and "windows" in c["folder"], c
|
||||
assert source["retail_captures_commit"]
|
||||
@@ -14,13 +14,15 @@ from __future__ import annotations
|
||||
import os
|
||||
import pathlib
|
||||
import re
|
||||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
import textwrap
|
||||
|
||||
import pytest
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
# `timeout` is only the bound on a hang (44 starts of a shim at 4 s each, what a machine under a hundred busy processes took, are 3 minutes of real time): the verdict on a wait that ignores its deadline is the fake clock's, in fake seconds (see _FAKE_CLOCK).
|
||||
pytestmark = [pytest.mark.unit, pytest.mark.timeout(600, method="thread")]
|
||||
|
||||
ROOT = pathlib.Path(__file__).resolve().parent.parent
|
||||
WORKFLOW = ROOT / ".github" / "workflows" / "user-install.yml"
|
||||
@@ -35,7 +37,8 @@ def _wait_script() -> str:
|
||||
return textwrap.dedent(m.group(1)) + "\n"
|
||||
|
||||
|
||||
# How a fake installer counts its calls. ATOMIC: the wait kills a call that does not answer and reads the count while calls run, and
|
||||
# How a fake installer COUNTED its calls before the shims were not Python any more (the shims below append one line to their count file, which
|
||||
# never truncates; this snippet stays as the case the kill test at the end of the first block of tests holds). ATOMIC: the wait kills a call that does not answer and reads the count while calls run, and
|
||||
# `write_text` truncates the file before it writes, so a call killed or read in between left an empty counter (`int('')`, a ValueError
|
||||
# in the release gate of 14/11). The new count goes to a file of its own and replaces the old one in one step.
|
||||
_COUNT_CALL = """
|
||||
@@ -56,7 +59,8 @@ os.replace(tmp, p)
|
||||
# with) polls `waitpid` in a loop that sleeps through the MODULE attribute `time.sleep`, up to 0.05 s a turn. A child that has closed its pipes and is not
|
||||
# yet reaped (an interpreter shutting down on a busy machine) made that loop spin with the fake sleep, each turn adding up to 0.05 s of fake time at no
|
||||
# real cost: 60 turns passed the 3 s of INDEX_WAIT_SECONDS after one all-yes round ("1 of 3 rounds in a row ()" on the Linux job of #612). So the real
|
||||
# `run` executes with the real clock back in place, and the fake one is put back when it returns.
|
||||
# `run` executes with the real clock back in place, and the fake one is put back when it returns. The fake clock is also the judge of a wait that
|
||||
# ignores its deadline: once fake time passes `_LIMIT` (set by the test to 10 times INDEX_WAIT_SECONDS) the fake sleep raises AssertionError, in fake seconds.
|
||||
_HUNG = 99
|
||||
_FAKE_CLOCK = """
|
||||
import subprocess, time
|
||||
@@ -66,14 +70,19 @@ _real_monotonic = time.monotonic
|
||||
_real_sleep = time.sleep
|
||||
|
||||
|
||||
_LIMIT = [None]
|
||||
|
||||
|
||||
def _fake_sleep(seconds):
|
||||
_now[0] += seconds
|
||||
if _LIMIT[0] is not None and _now[0] > _LIMIT[0]:
|
||||
raise AssertionError("it does not read its deadline")
|
||||
|
||||
|
||||
def _run_in_fake_time(*args, **kwargs):
|
||||
time.monotonic, time.sleep = _real_monotonic, _real_sleep
|
||||
try:
|
||||
done = _run(*args, **dict(kwargs, timeout=60))
|
||||
done = _run(*args, **dict(kwargs, timeout=None))
|
||||
finally:
|
||||
time.monotonic, time.sleep = lambda: _now[0], _fake_sleep
|
||||
if done.returncode == %d:
|
||||
@@ -88,50 +97,92 @@ time.sleep = _fake_sleep
|
||||
""" % _HUNG
|
||||
|
||||
|
||||
_WINDOWS = os.name == "nt"
|
||||
|
||||
|
||||
def _tool(tmp_path, name, plan, load=0.0, linger=0.0):
|
||||
"""A regular package `name` on the shim path whose `__main__` answers call number i as plan[i] says (the last letter repeats):
|
||||
"""A `pip` or `uv` that is NOT a Python process (a start of one costs seconds on a busy machine, and the wait starts two for each of its 22 rounds):
|
||||
a .cmd on Windows, an sh script on Linux, named as the tool, in `<tmp_path>/shim`. It answers call number i as plan[i] says (the last letter repeats):
|
||||
y = resolves it, n = no such version, h = does not answer (exits with HUNG, which the fake clock below turns into a call that outlived its limit).
|
||||
It counts its calls in `<name>-calls`. `load` is real time every call spends before it answers: what a machine busy with other work takes.
|
||||
`linger` is real time it spends AFTER it answered and closed its pipes, before it exits: a child that is not yet reaped (the window a busy machine opens)."""
|
||||
shim = tmp_path / "shim" / name
|
||||
shim.mkdir(parents=True)
|
||||
(shim / "__init__.py").write_text("", encoding="utf-8") # a REGULAR package: a namespace one loses to the real one of the environment
|
||||
(shim / "__main__.py").write_text(_COUNT_CALL % str(tmp_path / (name + "-calls")) + textwrap.dedent("""
|
||||
import os, sys, time
|
||||
sys.stdin.read() if %r == "uv" else None
|
||||
plan = %r
|
||||
what = plan[min(n, len(plan) - 1)]
|
||||
time.sleep(%r)
|
||||
code = %d if what == "h" else 0 if what == "y" else 1
|
||||
if what == "n":
|
||||
sys.stderr.write("ERROR: No matching distribution found for invisible-playwright==9.9.9" + chr(10))
|
||||
if %r:
|
||||
sys.stdout.flush(); sys.stderr.flush()
|
||||
os.close(1); os.close(2)
|
||||
time.sleep(%r)
|
||||
os._exit(code)
|
||||
sys.exit(code)
|
||||
""") % (name, plan, load, _HUNG, linger, linger), encoding="utf-8")
|
||||
Each call appends one line to `<name>-calls`, which the test counts. `load` is real time every call spends before it answers: what a machine busy
|
||||
with other work takes. `linger` is real time it spends AFTER it answered, before it exits (on POSIX with its pipes closed first: a child that is not
|
||||
yet reaped, the window a busy machine opens). On Windows a delay is `ping`, whole seconds (cmd has no shorter sleep that needs no new process).
|
||||
On Windows the uv shim leaves its stdin unread (reading it would be one more process a round); the 29 bytes of `input` fit in the pipe, and a pipe closed early is ignored by `communicate`."""
|
||||
shim = tmp_path / "shim"
|
||||
shim.mkdir(exist_ok=True)
|
||||
count = str(tmp_path / (name + "-calls"))
|
||||
stderr_line = "ERROR: No matching distribution found for invisible-playwright==9.9.9"
|
||||
last = plan[-1]
|
||||
if _WINDOWS:
|
||||
lines = ["@echo off", "setlocal"]
|
||||
if len(plan) > 1:
|
||||
lines += ['set "n=0"', 'if exist "%s" for /f "usebackq delims=" %%%%a in ("%s") do set /a n+=1' % (count, count)]
|
||||
lines.append('>>"%s" echo x' % count)
|
||||
lines.append('set "what=%s"' % last)
|
||||
lines += ['if "%%n%%"=="%d" set "what=%s"' % (i, c) for i, c in enumerate(plan[:-1])]
|
||||
if load:
|
||||
lines.append("ping -n %d 127.0.0.1 >nul" % (int(-(-load // 1)) + 1))
|
||||
lines.append('if "%what%"=="n" >&2 echo ' + stderr_line)
|
||||
if linger:
|
||||
lines.append("ping -n %d 127.0.0.1 >nul" % (int(-(-linger // 1)) + 1))
|
||||
lines += ['if "%%what%%"=="h" exit /b %d' % _HUNG, 'if "%what%"=="n" exit /b 1', "exit /b 0"]
|
||||
path = shim / (name + ".cmd")
|
||||
path.write_text("\r\n".join(lines) + "\r\n", encoding="ascii", newline="")
|
||||
else:
|
||||
q = shlex.quote(count)
|
||||
lines = ["#!/bin/sh", "n=0", 'if [ -f %s ]; then while read -r _l; do n=$((n + 1)); done < %s; fi' % (q, q), "echo x >> " + q]
|
||||
if name == "uv":
|
||||
lines.append("while read -r _l; do :; done")
|
||||
lines.append("case $n in")
|
||||
lines += [" %d) what=%s;;" % (i, c) for i, c in enumerate(plan[:-1])]
|
||||
lines += [" *) what=%s;;" % last, "esac"]
|
||||
if load:
|
||||
lines.append("sleep %r" % load)
|
||||
lines.append('if [ "$what" = n ]; then echo %s >&2; fi' % shlex.quote(stderr_line))
|
||||
if linger:
|
||||
lines += ['exec 1>&- 2>&-', "sleep %r" % linger]
|
||||
lines += ['case $what in h) exit %d;; n) exit 1;; esac' % _HUNG, "exit 0"]
|
||||
path = shim / name
|
||||
path.write_text("\n".join(lines) + "\n", encoding="ascii", newline="")
|
||||
path.chmod(0o755)
|
||||
|
||||
|
||||
# The wait asks `sys.executable -m pip ...` and `sys.executable -m uv ...` (the script of the step, unchanged); in this test the two commands start the shims of
|
||||
# the folder instead, whatever else is on the machine. A command of any other form is an error here: the test must not run the real pip.
|
||||
_THROUGH_THE_SHIMS = """
|
||||
_clocked_run = subprocess.run
|
||||
|
||||
|
||||
def _through_the_shims(command, *args, **kwargs):
|
||||
if len(command) < 3 or command[0] != sys.executable or command[1] != "-m" or command[2] not in ("pip", "uv"):
|
||||
raise AssertionError("the wait runs a command this test has no shim for: %%r" %% (command,))
|
||||
return _clocked_run([os.path.join(%r, command[2] + %r)] + list(command[3:]), *args, **kwargs)
|
||||
|
||||
|
||||
subprocess.run = _through_the_shims
|
||||
"""
|
||||
|
||||
|
||||
def _run_the_wait(tmp_path, pip="y", uv="y", *, seconds=3.0, poll=0.05, call_seconds=None, load=0.0, linger=0.0):
|
||||
"""Run the script of the step in a project named ``invisible-playwright`` 9.9.9, with a ``pip`` and a ``uv`` that answer as their plans say.
|
||||
Its fake clock is the judge of the deadline: past 10 times INDEX_WAIT_SECONDS of fake time the next sleep raises "it does not read its deadline"
|
||||
(the child exits nonzero and its message is the failure here); no real time limit decides, `pytest.mark.timeout` only bounds a hang.
|
||||
Returns (completed process, pip calls, uv calls)."""
|
||||
# The tree declares 0.99.0 and the ledger pull request records 9.9.9 (what the step before the wait computes): the wait is about the latter.
|
||||
(tmp_path / "pyproject.toml").write_text('[project]\nname = "invisible-playwright"\nversion = "0.99.0"\n', encoding="utf-8")
|
||||
_tool(tmp_path, "pip", pip, load, linger)
|
||||
_tool(tmp_path, "uv", uv, load, linger)
|
||||
env = dict(os.environ, PYTHONPATH=str(tmp_path / "shim"), INDEX_WAIT_SECONDS=str(seconds), INDEX_WAIT_POLL=str(poll), INVPW_E2E_VERSION="9.9.9")
|
||||
env = dict(os.environ, INDEX_WAIT_SECONDS=str(seconds), INDEX_WAIT_POLL=str(poll), INVPW_E2E_VERSION="9.9.9")
|
||||
if call_seconds is not None:
|
||||
env["INDEX_WAIT_CALL_SECONDS"] = str(call_seconds)
|
||||
try:
|
||||
r = subprocess.run([sys.executable, "-c", _FAKE_CLOCK + _wait_script()], cwd=tmp_path, env=env, capture_output=True, text=True, timeout=60)
|
||||
except subprocess.TimeoutExpired:
|
||||
pytest.fail("the wait did not end within 60 s with INDEX_WAIT_SECONDS=%s: it does not read its deadline" % seconds)
|
||||
prefix = _FAKE_CLOCK + "_LIMIT[0] = _now[0] + 10 * %r\n" % seconds + _THROUGH_THE_SHIMS % (str(tmp_path / "shim"), ".cmd" if _WINDOWS else "")
|
||||
r = subprocess.run([sys.executable, "-c", prefix + _wait_script()], cwd=tmp_path, env=env, capture_output=True, text=True)
|
||||
if "it does not read its deadline" in r.stderr:
|
||||
pytest.fail("the wait did not end within 10 times INDEX_WAIT_SECONDS=%s of fake time: %s" % (seconds, r.stderr.strip().splitlines()[-1]))
|
||||
|
||||
def calls(name):
|
||||
f = tmp_path / (name + "-calls")
|
||||
return int(f.read_text()) if f.exists() else 0
|
||||
return len(f.read_text().splitlines()) if f.exists() else 0
|
||||
return r, calls("pip"), calls("uv")
|
||||
|
||||
|
||||
@@ -198,17 +249,19 @@ def test_children_not_yet_reaped_when_their_pipes_close_do_not_cut_the_rounds_sh
|
||||
|
||||
|
||||
def test_the_wait_ends_in_an_error_that_names_the_missing_version_when_the_index_never_has_it(tmp_path):
|
||||
r, pip_calls, _ = _run_the_wait(tmp_path, pip="n", uv="n", seconds=1.0)
|
||||
r, pip_calls, uv_calls = _run_the_wait(tmp_path, pip="n", uv="n", seconds=1.0)
|
||||
assert r.returncode == 1, "a forgotten publish must fail the job here: " + r.stdout + r.stderr
|
||||
assert "::error::the index does not have invisible-playwright 9.9.9 yet" in r.stdout
|
||||
assert "minutes" in r.stdout and "pip said: ERROR: No matching distribution" in r.stdout and "0 of 3 rounds" in r.stdout
|
||||
assert pip_calls >= 2
|
||||
assert (pip_calls, uv_calls) == (22, 0), "the fake clock fixes the rounds (1.0 s at 0.05 s a poll) and pip alone is asked: pip %d, uv %d" % (pip_calls, uv_calls)
|
||||
|
||||
|
||||
def test_pip_yes_and_uv_never_is_an_error_naming_uv(tmp_path):
|
||||
r, _, uv_calls = _run_the_wait(tmp_path, pip="y", uv="n", seconds=1.0)
|
||||
r, pip_calls, uv_calls = _run_the_wait(tmp_path, pip="y", uv="n", seconds=1.0)
|
||||
assert r.returncode == 1 and "uv said:" in r.stdout, r.stdout + r.stderr
|
||||
assert uv_calls >= 2
|
||||
assert (pip_calls, uv_calls) == (22, 22), "the fake clock fixes the rounds (1.0 s at 0.05 s a poll): pip %d, uv %d" % (pip_calls, uv_calls)
|
||||
|
||||
|
||||
def test_a_call_that_does_not_answer_is_a_no_and_does_not_stop_the_wait(tmp_path):
|
||||
|
||||
@@ -250,3 +250,54 @@ def test_no_page_of_the_walk_links_to_the_pages_that_hold_load():
|
||||
assert "slowl" not in _get(a + path), path
|
||||
finally:
|
||||
stop()
|
||||
|
||||
|
||||
class ClosingContext:
|
||||
"""A context whose pages send their pagehide requests (a beacon and a keep-alive POST each) after close() has returned: they reach the site
|
||||
when the walk first waits (`time.sleep` of profile_p4), the moment a real server gets them is after close() and before the walk's next stage."""
|
||||
|
||||
def __init__(self, site, urls):
|
||||
self.site, self.pages, self.closed = site, [Page(url=u) for u in urls], False
|
||||
|
||||
def set_default_timeout(self, ms):
|
||||
pass
|
||||
|
||||
def set_default_navigation_timeout(self, ms):
|
||||
pass
|
||||
|
||||
def new_page(self):
|
||||
return self.pages[0]
|
||||
|
||||
def close(self):
|
||||
self.closed = True
|
||||
|
||||
def arrive(self):
|
||||
for page in self.pages:
|
||||
if "noise=0" not in page.url:
|
||||
self.site.record(0, "POST", "/beacon", {"t": ["pagehide"], "n": ["1"]})
|
||||
self.site.record(0, "POST", "/beacon", {"t": ["pagehide"], "n": ["2"]})
|
||||
|
||||
|
||||
@pytest.mark.parametrize("urls, sent", [([A + "/?x=1"], 2), ([A + "/", O + "/partner/1"], 4), ([A + "/?noise=0"], 0)])
|
||||
def test_the_walk_returns_once_the_site_has_the_requests_its_last_pages_send_as_the_context_closes_them(site, monkeypatch, urls, sent):
|
||||
"""Run 47209890618 (Windows, network oracle, seed 2): the pagehide beacon of the last page reached the lab after the walk had returned, in "end" and not
|
||||
in step 17. The walk waits for the event (the requests at the site), never for a time: a page without noise sends none and is not waited for."""
|
||||
import time as real_time
|
||||
|
||||
context = ClosingContext(site, urls)
|
||||
waits = []
|
||||
|
||||
def sleep(seconds):
|
||||
if not waits:
|
||||
context.arrive()
|
||||
waits.append(seconds)
|
||||
real_time.sleep(0)
|
||||
|
||||
monkeypatch.setattr(profile_p4, "time", SimpleNamespace(sleep=sleep, monotonic=real_time.monotonic))
|
||||
monkeypatch.setattr(profile_p4, "install_route", lambda context: None)
|
||||
monkeypatch.setattr(profile_p4, "Tracer", lambda *a, **k: None)
|
||||
monkeypatch.setattr(profile_p4, "run_round", lambda *a, **k: [])
|
||||
profile_p4.drive(SimpleNamespace(new_context=lambda: context), A, O)
|
||||
assert context.closed
|
||||
assert profile_p4.pagehide_requests() == sent, "the walk returned with %d of the %d pagehide requests of its last pages at the site" % (profile_p4.pagehide_requests(), sent)
|
||||
assert bool(waits) == bool(sent), "a walk whose last pages send nothing waited %d time(s)" % len(waits)
|
||||
@@ -70,6 +70,7 @@ from typing import Any, Dict, Iterator, List, Optional, Tuple
|
||||
|
||||
import pytest
|
||||
from _fission_frames import Sites, wait_frame
|
||||
import _retail_window_formula as formula
|
||||
from _waits import wait_until
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
@@ -700,3 +701,31 @@ def test_the_screen_origin_and_the_work_area_origin_read_zero(firefox_binary, ca
|
||||
seen = page.evaluate("() => ({left: screen.left, top: screen.top, availLeft: screen.availLeft, availTop: screen.availTop})")
|
||||
for key in ("left", "top", "availLeft", "availTop"):
|
||||
assert seen[key] == 0, "%s: screen.%s reads %r, retail Firefox 159.0 on Windows reads 0 (whole reading: %r)" % (case, key, seen[key], seen)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("case", sorted(formula.BIG_CASES))
|
||||
def test_a_persona_larger_than_any_runner_reads_the_retail_maximized_window(firefox_binary, case):
|
||||
"""A persona whose screen (2560x1440, scale 1.0 and 1.25) is larger than the screen of every runner reads the maximized window retail reads on such a display.
|
||||
|
||||
No retail capture exists at that size, so the expected numbers are ONE formula (``tests/_retail_window_formula.py``) of the persona's work area, which the page reads
|
||||
(``screen.availWidth``, ``screen.availHeight``), and of the retail border and chrome of the same scale, read from the 1920x1080 captures (``ci/retail-window-formula.json``); the formula gives
|
||||
the 1920x1080 captures' own numbers exactly (``tests/test_the_retail_window_formula_reproduces_the_1920x1080_captures.py``). The declared maximized window covers the host's work area on both axes
|
||||
here, which Windows answers with the host's own rectangle (``(-8, -8)`` and the host's work area plus a border) unless the engine writes the declared one: the page would read the runner's
|
||||
screen, and the test is red on every runner. Linux and Windows run the same assertions."""
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
dpr, panel = formula.BIG_CASES[case]
|
||||
frame = formula.load()["scales"][str(dpr)]
|
||||
pin = {"screen.width": panel[0], "screen.height": panel[1], "screen.dpr": dpr}
|
||||
points = iter(POINTS)
|
||||
with Sites() as s:
|
||||
s.route("A", "/page", PAGE)
|
||||
with InvisiblePlaywright(seed=42, pin=pin, binary_path=firefox_binary, headless=True, humanize=False) as browser:
|
||||
page = browser.new_page()
|
||||
page.goto(s.url("A", "/page"), wait_until="load", timeout=30000)
|
||||
maximized = _stable(page, None)
|
||||
event = _event_offset(page, next(points))
|
||||
avail = page.evaluate("() => [screen.availWidth, screen.availHeight]")
|
||||
expected = formula.expected_window(avail, dpr, frame["border"], frame["ui"])
|
||||
assert (maximized["scw"], maximized["sch"]) == (round(panel[0] / dpr), round(panel[1] / dpr)), "%s: the page reads screen %rx%r: %r" % (case, maximized["scw"], maximized["sch"], maximized)
|
||||
_check_reading("maximized (%s, work area %r)" % (case, avail), maximized, event, expected, dpr)
|
||||
@@ -1,68 +1,33 @@
|
||||
"""The parent reads the bundle of fonts from fontconfig's cache and does not scan it again (e2e, Linux, from firefox-66).
|
||||
"""The engine writes and reads no fontconfig cache (e2e, Linux, from firefox-72; the file keeps the name and the test ids of the warm-cache test it was).
|
||||
|
||||
Why Linux only: fontconfig exists only there. On Windows the parent rebuilds a font from the path a text run carries with DirectWrite,
|
||||
which opens the file by its path and keeps no index of a folder; there is nothing to scan and nothing to cache, and this test has no
|
||||
Windows form (the row of ``ci/required-suites.json`` says so: ``linux_only``).
|
||||
Retired after the release of the 72: ``tests/test_the_host_fontconfig_rules_do_not_reach_the_text_pixels_linux_e2e.py`` (the rules of a user do not reach the pixels
|
||||
of the text) and ``tests/test_no_fontconfig_file_of_the_host_is_opened_and_the_screenshot_draws_the_bundle_linux_e2e.py`` (no fontconfig file of the host is opened, the screenshot draws the bundle with the caches poisoned) replace it, and
|
||||
its entry in ``ci/retired-tests.json`` goes to main then. Until then it asserts the same principle on the simplest case, two launches with the same cache folder.
|
||||
|
||||
What the engine does. A screenshot sends each font of a text run to the parent as a path and a face index, and the parent turns it into
|
||||
a font again with fontconfig (``UnscaledFontFontconfig::CreateFromFontDescriptor``). For fontconfig to know the files of the bundle the
|
||||
parent gives it the folder ``<GRE>/fonts`` with ``FcConfigAppFontAddDir`` (``gfxFcPlatformFontList::ActivateBundledFonts``, which the
|
||||
shared font list of the parent calls first). On a COLD cache fontconfig opens and scans every file of the folder (about 121) and writes a
|
||||
cache under ``$XDG_CACHE_HOME/fontconfig``. On a WARM cache it must read that cache (a ``*.cache-*`` file) and NOT open the files again for
|
||||
the scan: it is the difference between a start that reads 121 fonts and a start that reads one file.
|
||||
Why Linux only: fontconfig exists only there. On Windows the parent rebuilds a font from the path a text run carries with DirectWrite, which opens the file by
|
||||
its path and keeps no index of a folder; there is nothing to scan and nothing to cache, and this test has no Windows form (the row of
|
||||
``ci/required-suites.json`` says so: ``linux_only``).
|
||||
|
||||
The measurement. Two launches of the same binary with the same ``XDG_CACHE_HOME``, a new folder of the test: the first is cold, the second
|
||||
warm. Each runs under ``strace -f -ttt`` (the stand-in of ``tests/_strace_stand_in.py``) that traces the opens of the browser. The environment reaches the browser as it does for a user: the test sets
|
||||
``XDG_CACHE_HOME`` in its own environment, and the core composes the engine's environment from it (``build_launch_env``: it removes the
|
||||
host's ``MOZ_*``, ``LANG``, ``TZ`` and the toolkit families, and nothing else); that the variable did arrive is shown by the cache that is
|
||||
written under it.
|
||||
What the engine does. It runs fontconfig on its own empty configuration: no ``fonts.conf``, no rule, no cache folder. It does not show ``<GRE>/fonts`` to
|
||||
fontconfig (the core declares ``gfx.bundled-fonts.activate=0`` on Linux), so nothing scans the folder and nothing writes a cache of it, and a screenshot takes the
|
||||
file and the face of each text run from the bundle's manifest. The engine neither writes nor reads a fontconfig cache, on a cold folder or a warm one.
|
||||
|
||||
Scan or drawing: the criterion. FreeType also opens a file of the bundle (``FT_New_Face`` from the path) when a text run is DRAWN, in the
|
||||
parent for the screenshot and in the content process for the page: those opens are not a scan and they happen in the warm launch too. The
|
||||
scan is made by the parent while it builds the font list, before there is a page. So the test counts only what the PARENT process opens
|
||||
between the start of the browser and the moment the wrapper has returned the launched browser, before any page is opened (``new_page``
|
||||
is not yet called). The point is a position in the strace log (its size when the launch returns), not a time: the log is written line by
|
||||
line, and everything the parent did to build its font list is before it. The opens after it (the page with every family of the
|
||||
screenshot test, and the screenshot) are measured as well and written to the evidence, as ``after_startup``, but the assertion does not
|
||||
read them.
|
||||
The measurement. Two launches of the same binary with the same ``XDG_CACHE_HOME`` and the same ``HOME``, both new folders of the test (the test sets them in
|
||||
its own environment, and the core composes the engine's environment from it; that they arrived is read from ``/proc/<pid>/environ`` of the parent). Each runs
|
||||
under ``strace -f`` (the stand-in of ``tests/_strace_stand_in.py``) and draws a page with every family of the screenshot test and takes a screenshot. The test asserts,
|
||||
for each launch:
|
||||
|
||||
Why "all or none" and not "none that the cold one opened". Even on a warm cache the parent opens a few files of the bundle before the
|
||||
first page, to USE them (the face blob of a font of its own interface is opened and mapped); those files are also in the cold set, so a
|
||||
test that asks for an empty intersection would be red for a good engine. What a scan is, is different: fontconfig scans a folder as a
|
||||
whole (``FcDirCacheScan`` opens every file of it) or reads the cache of the folder and opens none for the scan. So the test asks about
|
||||
the whole folder, as the disk lists it (no number written by hand):
|
||||
* no fontconfig cache file (``<md5>-<arch>.cache-<n>``, and the ``.NEW`` and ``.TMP-*`` it is written through) is under ``XDG_CACHE_HOME`` or ``HOME`` when the
|
||||
launch has ended: nothing was written, so the second launch finds nothing the first left;
|
||||
* no process of the browser OPENED such a file, in any folder, whatever the result of the open (an open of ``<md5>-le64.cache-9`` that is refused is a look for a
|
||||
cache all the same).
|
||||
|
||||
* the validity of the measurement: the cold parent opened EVERY font file of ``<GRE>/fonts`` in the window, and fontconfig wrote its
|
||||
cache under ``$XDG_CACHE_HOME/fontconfig``; otherwise the window does not see the scan and the test says it cannot judge;
|
||||
* the assertion, the only one that judges: in the same window the warm parent does NOT open every font file of the folder, and it
|
||||
opens a ``*.cache-*`` file under ``$XDG_CACHE_HOME/fontconfig``.
|
||||
The launch is valid only when the strace log has lines and the parent's environment carries the two folders: otherwise a clean result would say nothing. An open is
|
||||
counted whatever its result (strace splits a call that another thread interrupts in "PID openat(... <unfinished ...>" and "PID <... openat resumed>) = -1 ENOENT";
|
||||
an unfinished line with no resumed line is counted too, since the look happened).
|
||||
|
||||
The files of the folder that are not fonts (a ``.list``, a README) are left out of the list, explicitly: a font is a file whose name ends
|
||||
in one of ``FONT_EXTENSIONS`` (what fontconfig reads through FreeType); the evidence names the files that were left out. The files the
|
||||
warm parent opened are in the evidence, by name. No threshold: a set that is not the whole folder, and a file that is read.
|
||||
|
||||
Evidence, whatever the verdict: when ``RUNNER_TEMP`` is set the test writes ``result.json`` and, for each launch, the opens of the bundle
|
||||
by the parent with their time, under ``$RUNNER_TEMP/invpw-evidence/fontconfig-cache/``. For the cold and the warm launch (and for a
|
||||
third, "before", see below): the interval in seconds between the first and the last open of a file of ``<GRE>/fonts`` by the parent, how
|
||||
many opens, how many distinct files, the name and size of each file of fontconfig's cache, the ``VmRSS`` of the parent after
|
||||
``about:blank`` and after a page with every family of the screenshot test (drawn and screenshotted).
|
||||
|
||||
The third launch, "before", is evidence only: the engine with ``gfx.bundled-fonts.activate`` = 0 never shows the folder to fontconfig (the
|
||||
pref is Mozilla's, ``mirror: once``, read at start; ``ActivateBundledFonts`` is under ``!= 0``), which is what the parent did before the
|
||||
correction. The core does not declare that pref anywhere, so the caller's ``extra_prefs`` (applied last, ``_apply_caller_overlay``) is
|
||||
the only place that says it. If that launch fails, its error is in the evidence and nothing else changes.
|
||||
|
||||
What is a cache "of the bundle", and what is an open that happened. fontconfig names the cache of a folder by the md5 of the folder's
|
||||
path (``<md5>-le64.cache-9``), so the cache of the bundle is the file whose name starts with the md5 of ``<GRE>/fonts`` (and, in the same
|
||||
launch, with the name fontconfig itself prints for that folder, ``FC_DEBUG=16``); a ``*.cache-*`` file of a system folder
|
||||
(``/usr/share/fonts``...) is a different cache and proves nothing about the bundle. An open counts only when its result is on the log:
|
||||
strace splits a call that another thread interrupts in "PID openat(... <unfinished ...>" and "PID <... openat resumed>) = -1 ENOENT", the
|
||||
result is on the second line, and an unfinished line with no resumed line has no result and is not counted either way.
|
||||
|
||||
The evidence of a launch (when ``RUNNER_TEMP`` is set) also holds what fontconfig says: the browser runs with ``FC_DEBUG=16`` (what it
|
||||
does with caches: the folders it examines, the caches it finds valid, the writes), strace saves the writes to the descriptors 1 and 2
|
||||
(``fc-debug-<launch>.txt``), and ``trace-<launch>.tsv`` has every open of a ``*.cache-*`` file or of a ``CACHEDIR.TAG`` by any process, in any
|
||||
folder, and every line that names the bundle's folder or the cache folder: where fontconfig found a valid cache is on it.
|
||||
Evidence, whatever the verdict: when ``RUNNER_TEMP`` is set the test writes ``result.json`` under ``$RUNNER_TEMP/invpw-evidence/fontconfig-cache/``: for each launch, the
|
||||
environment of the parent, what is under the two folders, and every open of a cache file with the role of its process.
|
||||
|
||||
Run: pytest tests/test_the_parent_reads_the_bundle_from_fontconfig_s_cache_linux_e2e.py -m e2e -v
|
||||
"""
|
||||
@@ -83,6 +48,7 @@ import pytest
|
||||
|
||||
from _waits import wait_until
|
||||
from test_a_screenshot_draws_the_text_of_the_bundled_fonts_as_the_content_does_e2e import EVIDENCE_FOLDER, FAMILIES
|
||||
from test_no_fontconfig_file_of_the_host_is_opened_and_the_screenshot_draws_the_bundle_linux_e2e import _CACHE_FILE, OPEN_CALLS, paths_of_calls
|
||||
from _strace_stand_in import (
|
||||
_detached, _group_members, _group_of, _kill_group, _LINE, _require_strace_can_trace, _RESUMED, _roles, _stand_in, _wait_for_exit)
|
||||
|
||||
@@ -91,21 +57,11 @@ pytestmark = [
|
||||
pytest.mark.skipif(not sys.platform.startswith("linux"), reason="fontconfig is the Linux font system"),
|
||||
]
|
||||
|
||||
#: Opens, and what is needed to tell the parent from a content process (``_roles`` reads the execve and the clones).
|
||||
TRACE = "execve,clone,clone3,fork,vfork,openat,openat2,write"
|
||||
|
||||
#: What fontconfig prints with ``FC_DEBUG=16`` goes to the descriptor 1 (the core reads it as the browser's output, and keeps 200 lines): the
|
||||
#: strace log also holds the ``write`` calls, and ``_fc_debug_text`` keeps those to the descriptors 1 and 2. NOT ``--trace-fds=1,2``: it
|
||||
#: filters EVERY traced call by descriptor, so the execve, clone and openat lines (which the parent's identity and the opens are read
|
||||
#: from) are gone and the test saw no parent (candidate run 44749623531).
|
||||
FC_DEBUG = "16"
|
||||
#: What is traced: the opens (what the test judges), the writes (``_fc_debug_text`` reads the descriptors 1 and 2), and the execve and clones (the role of a process).
|
||||
TRACE = "execve,clone,clone3,fork,vfork,open,openat,openat2,write"
|
||||
|
||||
SEED = 21
|
||||
|
||||
#: What counts as a font of the bundle in the folder ``<GRE>/fonts``: the extensions of the files fontconfig reads through FreeType. Any
|
||||
#: other file of the folder (a ``.list``, a README) is not a font and is left out of the list, and the evidence says which ones.
|
||||
FONT_EXTENSIONS = (".ttf", ".ttc", ".otf", ".otc", ".pfb", ".pfa", ".pcf", ".pcf.gz", ".bdf", ".woff", ".woff2", ".pfr", ".fon", ".fnt")
|
||||
|
||||
#: ``strace -f -ttt``: "PID EPOCH call(...". ``_LINE`` and ``_roles`` read "PID call(...", so the epoch is taken off first and kept apart.
|
||||
_STAMPED = re.compile(r"^(\d+)\s+(\d+\.\d+)\s+(.*)$")
|
||||
_QUOTED = re.compile(r'"([^"]*)"')
|
||||
@@ -132,13 +88,6 @@ def _evidence_dir():
|
||||
return Path(base) / EVIDENCE_FOLDER / "fontconfig-cache" if base else None
|
||||
|
||||
|
||||
def _vmrss_kb(pid: int) -> int:
|
||||
for line in Path("/proc/%d/status" % pid).read_text().splitlines():
|
||||
if line.startswith("VmRSS:"):
|
||||
return int(line.split()[1])
|
||||
raise AssertionError("no VmRSS in /proc/%d/status" % pid)
|
||||
|
||||
|
||||
def _read(log: Path, real: str, boundary: int = None):
|
||||
"""``(lines, times, role, argv_of, start)`` of a strace log: the lines without their epoch, the epoch of each, the role of a pid,
|
||||
the execve of each, and the index of the first line that is NOT in the window of the start (``boundary`` is the size of the log
|
||||
@@ -242,17 +191,6 @@ def _fc_debug_text(lines, role) -> str:
|
||||
return "\n".join(out)
|
||||
|
||||
|
||||
def _summary(opens):
|
||||
made = [o for o in opens if o["ok"]]
|
||||
stamps = [o["t"] for o in made if o["t"] is not None]
|
||||
return {
|
||||
"opens": len(made),
|
||||
"distinct_files": len({o["path"] for o in made}),
|
||||
"refused_opens": len(opens) - len(made),
|
||||
"first_to_last_s": round(max(stamps) - min(stamps), 6) if stamps else None,
|
||||
}
|
||||
|
||||
|
||||
def _environ_of(pid: int, name: str):
|
||||
"""The value of ``name`` in the environment the process ``pid`` was started with (``/proc/<pid>/environ``); None when it has none or
|
||||
the file cannot be read."""
|
||||
@@ -266,116 +204,48 @@ def _environ_of(pid: int, name: str):
|
||||
return None
|
||||
|
||||
|
||||
def _fontconfig_cache(xdg: Path):
|
||||
folder = xdg / "fontconfig"
|
||||
if not folder.is_dir():
|
||||
return []
|
||||
return sorted(({"name": f.name, "bytes": f.stat().st_size} for f in folder.iterdir() if f.is_file()), key=lambda f: f["name"])
|
||||
def _cache_files_under(*folders: Path) -> list:
|
||||
"""The fontconfig cache files (``*.cache-<n>``, ``.NEW``, ``.TMP-*``) anywhere under the folders, as the disk lists them."""
|
||||
found = []
|
||||
for folder in folders:
|
||||
for root, _dirs, files in os.walk(folder):
|
||||
found.extend(os.path.join(root, name) for name in files if _CACHE_FILE.search(name))
|
||||
return sorted(found)
|
||||
|
||||
|
||||
def _the_folder(gre_fonts: str):
|
||||
"""``(fonts, left_out)``: the names of the files of the folder as the DISK lists them, split by ``FONT_EXTENSIONS``."""
|
||||
names = sorted(e.name for e in os.scandir(gre_fonts) if e.is_file()) if os.path.isdir(gre_fonts) else []
|
||||
fonts = [n for n in names if n.lower().endswith(FONT_EXTENSIONS)]
|
||||
return fonts, [n for n in names if n not in fonts]
|
||||
|
||||
|
||||
def _launch(firefox_binary, work: Path, xdg: Path, extra_prefs=None):
|
||||
"""One launch of the binary under strace, with ``XDG_CACHE_HOME`` = ``xdg`` in the environment of the test. Returns what the log and
|
||||
/proc say; the browser is gone when it returns."""
|
||||
def _launch(firefox_binary, work: Path, xdg: Path, home: Path):
|
||||
"""One launch of the binary under strace, with ``XDG_CACHE_HOME`` = ``xdg`` and ``HOME`` = ``home`` in the environment of the test. Returns what the log, /proc and the
|
||||
disk say; the browser is gone when it returns."""
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
work.mkdir(parents=True)
|
||||
log, pidfile = work / "strace.log", work / "stand-in.pid"
|
||||
stand_in = _stand_in(firefox_binary, work / "engine", log, pidfile, syscalls=TRACE, timestamps=True)
|
||||
stand_in = _stand_in(firefox_binary, work / "engine", log, pidfile, syscalls=TRACE)
|
||||
real = os.path.realpath(firefox_binary)
|
||||
gre_fonts = os.path.join(os.path.dirname(real), "fonts")
|
||||
rss, boundary, pid, environ_xdg = {}, None, None, None
|
||||
pid, environ = None, {}
|
||||
try:
|
||||
with InvisiblePlaywright(seed=SEED, binary_path=stand_in, headless=True, extra_prefs=extra_prefs) as browser:
|
||||
# The launch has returned: the parent has built its font list. No page has been opened yet.
|
||||
boundary = log.stat().st_size
|
||||
_lines, _times, _role, argv_of, _start = _read(log, real, boundary)
|
||||
with InvisiblePlaywright(seed=SEED, binary_path=stand_in, headless=True) as browser:
|
||||
_lines, _times, _role, argv_of, _start = _read(log, real)
|
||||
pid = _parent_pid(argv_of, real)
|
||||
environ_xdg = _environ_of(pid, "XDG_CACHE_HOME")
|
||||
environ = {name: _environ_of(pid, name) for name in ("XDG_CACHE_HOME", "HOME")}
|
||||
page = browser.new_page()
|
||||
rss["after_about_blank_kb"] = _vmrss_kb(pid)
|
||||
page.set_content(_page_with_every_family())
|
||||
assert page.evaluate("() => document.body.getBoundingClientRect().width") > 0
|
||||
page.screenshot()
|
||||
rss["after_every_family_kb"] = _vmrss_kb(pid)
|
||||
finally:
|
||||
_kill_group(pidfile)
|
||||
|
||||
lines, times, role, _argv_of, start = _read(log, real, boundary)
|
||||
under = sorted({gre_fonts, os.path.realpath(gre_fonts)})
|
||||
results = _results_of_unfinished(lines)
|
||||
scan = _opens_of_the_parent(lines, times, role, 0, start, under, results)
|
||||
later = _opens_of_the_parent(lines, times, role, start, len(lines), under, results)
|
||||
fc_debug = _fc_debug_text(lines, role)
|
||||
prefixes = _bundle_cache_prefixes(under, fc_debug)
|
||||
fonts, left_out = _the_folder(gre_fonts)
|
||||
opened = sorted({os.path.basename(o["path"]) for o in scan if o["ok"]})
|
||||
cache_dir = str(xdg / "fontconfig")
|
||||
# Evidence for a launch whose cache is missing: every line of the log, by ANY process, that names the bundle's folder, the cache
|
||||
# folder or a ``.uuid``, with the role of the process and the window it is in (the opens above count only the parent's, and only
|
||||
# in the window). The raw lines say who scanned (or did not), and where fontconfig wrote.
|
||||
trace = []
|
||||
for i, line in enumerate(lines):
|
||||
if any(u in line for u in under) or cache_dir in line or "/.uuid" in line:
|
||||
m = _LINE.match(line) or re.match(r"^(\d+)\s", line)
|
||||
who = role(int(m.group(1))) if m else "?"
|
||||
trace.append("%s\t%s\t%s\t%s" % (times[i], "startup" if i < start else "later", who, line[:400]))
|
||||
# The reads of the cache of the BUNDLE (not of a system folder), by the parent in the window: under the cache folder, and anywhere.
|
||||
cache_reads = [o for o in _opens_of_the_parent(lines, times, role, 0, start, [cache_dir], results)
|
||||
if o["ok"] and _is_a_cache_of(o["path"], prefixes)]
|
||||
anywhere = []
|
||||
for i, line in enumerate(lines[:start]):
|
||||
m = _LINE.match(line)
|
||||
if m and m.group(2) in ("openat", "openat2") and role(int(m.group(1))) == "parent":
|
||||
quoted = _QUOTED.findall(m.group(3))
|
||||
if quoted and _is_a_cache_of(quoted[0], prefixes) and (_open_result(lines, i, results) or -1) >= 0:
|
||||
anywhere.append(quoted[0])
|
||||
# Every open of a cache file or of a CACHEDIR.TAG by any process, in any folder, with its result: where fontconfig found a valid cache.
|
||||
cache_opens = []
|
||||
for i, line in enumerate(lines):
|
||||
m = _LINE.match(line)
|
||||
if m and m.group(2) in ("openat", "openat2"):
|
||||
quoted = _QUOTED.findall(m.group(3))
|
||||
if quoted and (".cache-" in quoted[0] or "CACHEDIR.TAG" in quoted[0]):
|
||||
result = _open_result(lines, i, results)
|
||||
cache_opens.append("%s\t%s\t%s\t%s\t%s" % (
|
||||
times[i], "startup" if i < start else "later", role(int(m.group(1))),
|
||||
"no-result" if result is None else ("ok" if result >= 0 else "refused"), quoted[0]))
|
||||
trace = cache_opens + trace
|
||||
lines, _times, role, _argv_of, _start = _read(log, real)
|
||||
opened = [dict(call, role=role(call["pid"])) for call in paths_of_calls(lines, OPEN_CALLS) if _CACHE_FILE.search(os.path.basename(call["path"]))]
|
||||
return {
|
||||
"parent_pid": pid,
|
||||
"parent_environ_xdg_cache_home": environ_xdg,
|
||||
"startup": _summary(scan),
|
||||
"after_startup": _summary(later),
|
||||
"cache_files_read_at_startup": sorted({o["path"] for o in cache_reads}),
|
||||
"bundle_cache_read_anywhere_at_startup": sorted(set(anywhere)),
|
||||
"bundle_cache_names": sorted(prefixes),
|
||||
"bundle_cache_written": [f for f in _fontconfig_cache(xdg) if _is_a_cache_of(f["name"], prefixes)],
|
||||
"fc_debug_about_the_bundle": [l for l in fc_debug.splitlines() if any(u in l for u in under)],
|
||||
"_fc_debug": fc_debug,
|
||||
"fontconfig_cache": _fontconfig_cache(xdg),
|
||||
"vmrss_kb": rss,
|
||||
"bundle_font_files": len(fonts),
|
||||
"files_left_out_as_not_fonts": left_out,
|
||||
"font_files_opened_at_startup": len([n for n in opened if n in fonts]),
|
||||
"font_files_not_opened_at_startup": [n for n in fonts if n not in opened],
|
||||
"files_opened_at_startup": opened,
|
||||
"_scan_opens": scan,
|
||||
"_later_opens": later,
|
||||
"_trace": trace,
|
||||
"parent_environ": environ,
|
||||
"log_lines": len(lines),
|
||||
"cache_files_under_the_two_folders": _cache_files_under(xdg, home),
|
||||
"cache_file_opens": opened,
|
||||
}
|
||||
|
||||
|
||||
def _public(measure: dict) -> dict:
|
||||
return {k: v for k, v in measure.items() if not k.startswith("_")}
|
||||
|
||||
|
||||
@pytest.mark.timeout(120, method="thread")
|
||||
def test_the_stand_in_stays_in_the_engine_s_place_and_its_group_is_killed_whole(tmp_path):
|
||||
"""The tool, without a browser. A fake engine (a script that starts a child and waits for it) is launched through the stand-in
|
||||
@@ -421,71 +291,46 @@ def test_the_stand_in_stays_in_the_engine_s_place_and_its_group_is_killed_whole(
|
||||
|
||||
|
||||
@pytest.mark.timeout(900, method="thread")
|
||||
def test_the_warm_parent_reads_the_bundle_from_fontconfig_cache_and_does_not_scan_it(firefox_binary, engine_at_least, tmp_path, monkeypatch):
|
||||
engine_at_least("firefox-66")
|
||||
def test_the_warm_parent_reads_the_bundle_from_fontconfig_cache_and_does_not_scan_it(firefox_binary, tmp_path, monkeypatch):
|
||||
"""The id is the one of the warm-cache test this file was; what it asserts is the 72's behaviour (see the docstring of the module)."""
|
||||
if shutil.which("strace") is None:
|
||||
pytest.fail("needs strace (apt install strace): without it nothing is measured", pytrace=False)
|
||||
_require_strace_can_trace(tmp_path)
|
||||
|
||||
xdg = tmp_path / "xdg-cache"
|
||||
xdg, home = tmp_path / "xdg-cache", tmp_path / "home"
|
||||
xdg.mkdir()
|
||||
home.mkdir()
|
||||
monkeypatch.setenv("XDG_CACHE_HOME", str(xdg))
|
||||
monkeypatch.setenv("FC_DEBUG", FC_DEBUG) # it only prints; the core passes it to the browser as it passes XDG_CACHE_HOME
|
||||
monkeypatch.setenv("HOME", str(home))
|
||||
for variable in ("FONTCONFIG_FILE", "FONTCONFIG_PATH"):
|
||||
monkeypatch.delenv(variable, raising=False)
|
||||
|
||||
cold = _launch(firefox_binary, tmp_path / "cold", xdg)
|
||||
cold_cache = cold["fontconfig_cache"]
|
||||
warm = _launch(firefox_binary, tmp_path / "warm", xdg)
|
||||
first = _launch(firefox_binary, tmp_path / "first", xdg, home)
|
||||
second = _launch(firefox_binary, tmp_path / "second", xdg, home)
|
||||
launches = {"first": first, "second": second}
|
||||
|
||||
# "Before": the folder is never shown to fontconfig. Its own cache folder, so that it is not warmed by the others.
|
||||
before_xdg = tmp_path / "xdg-cache-before"
|
||||
before_xdg.mkdir()
|
||||
monkeypatch.setenv("XDG_CACHE_HOME", str(before_xdg))
|
||||
try:
|
||||
before = _launch(firefox_binary, tmp_path / "before", before_xdg, extra_prefs={"gfx.bundled-fonts.activate": 0})
|
||||
except Exception as err: # evidence only: a launch that fails is written down, it does not change the verdict
|
||||
before = {"error": "%s: %s" % (type(err).__name__, str(err)[:600])}
|
||||
|
||||
result = {
|
||||
"test": "the-parent-reads-the-bundle-from-fontconfig-cache",
|
||||
"platform": sys.platform,
|
||||
"seed": SEED,
|
||||
"xdg_cache_home": str(xdg),
|
||||
"criterion": ("window = what the PARENT opens before any page is opened (the strace log up to its size when the launch returned; "
|
||||
"the opens after it are drawing and are in after_startup). Valid: the cold parent opened every font file of "
|
||||
"<GRE>/fonts and fontconfig wrote its cache. Verdict: the warm parent does not open every font file of the folder "
|
||||
"and opens a *.cache-* file. Font files = the folder as the disk lists it, by FONT_EXTENSIONS"),
|
||||
"cold": _public(cold),
|
||||
"warm": _public(warm),
|
||||
"before_gfx_bundled_fonts_activate_0": _public(before) if "error" not in before else before,
|
||||
}
|
||||
where = _evidence_dir()
|
||||
if where is not None:
|
||||
where.mkdir(parents=True, exist_ok=True)
|
||||
(where / "result.json").write_text(json.dumps(result, indent=1, sort_keys=True) + "\n", encoding="utf-8")
|
||||
for name, measure in (("cold", cold), ("warm", warm), ("before", before)):
|
||||
if "_scan_opens" in measure:
|
||||
rows = ["%s\t%s\t%s" % (o["t"], "ok" if o["ok"] else "refused", o["path"])
|
||||
for o in measure["_scan_opens"] + measure["_later_opens"]]
|
||||
(where / ("bundle-opens-%s.tsv" % name)).write_text("\n".join(rows) + "\n", encoding="utf-8")
|
||||
(where / ("trace-%s.tsv" % name)).write_text("\n".join(measure["_trace"]) + "\n", encoding="utf-8")
|
||||
(where / ("fc-debug-%s.txt" % name)).write_text(measure["_fc_debug"] + "\n", encoding="utf-8")
|
||||
try:
|
||||
where.mkdir(parents=True, exist_ok=True)
|
||||
(where / "result.json").write_text(json.dumps(
|
||||
{"test": "the-engine-writes-and-reads-no-fontconfig-cache", "platform": sys.platform, "seed": SEED,
|
||||
"xdg_cache_home": str(xdg), "home": str(home), "launches": launches}, indent=1, sort_keys=True) + "\n", encoding="utf-8")
|
||||
except Exception as exc: # a record never changes the outcome
|
||||
print("the record could not be written:", repr(exc))
|
||||
|
||||
# The measurement is valid or the test says it cannot judge.
|
||||
assert cold["bundle_cache_written"], (
|
||||
"the cold launch wrote no cache of the bundle under XDG_CACHE_HOME=%s (there: %s; the names of a cache of the bundle: %s). "
|
||||
"XDG_CACHE_HOME in the parent's environment: %s. Cache of the bundle opened by the parent before a page, in any folder: %s. "
|
||||
"What fontconfig printed about the folder of the bundle (FC_DEBUG=16): %s. The window: %s. Nothing for a warm launch to read."
|
||||
% (xdg, [f["name"] for f in cold_cache] or "nothing", cold["bundle_cache_names"], cold["parent_environ_xdg_cache_home"],
|
||||
cold["bundle_cache_read_anywhere_at_startup"] or "none", cold["fc_debug_about_the_bundle"] or "nothing (or FC_DEBUG not saved)",
|
||||
cold["startup"]))
|
||||
assert not cold["font_files_not_opened_at_startup"] and cold["bundle_font_files"], (
|
||||
"the parent of the cold launch did not open every font file of <GRE>/fonts (%d of %d) before a page was opened: the window does "
|
||||
"not see the scan; the test cannot judge. Not opened: %s"
|
||||
% (cold["font_files_opened_at_startup"], cold["bundle_font_files"], cold["font_files_not_opened_at_startup"][:5]))
|
||||
|
||||
scanned_again = not warm["font_files_not_opened_at_startup"]
|
||||
assert not scanned_again and warm["cache_files_read_at_startup"], (
|
||||
"the warm parent %s. Cold: %s. Warm: %s. Cache under %s: cold %s, warm %s."
|
||||
% ("opened every one of the %d font files of <GRE>/fonts before a page: it scanned the folder again"
|
||||
% warm["bundle_font_files"] if scanned_again else "read no *.cache-* file of fontconfig at its start",
|
||||
result["cold"]["startup"], result["warm"]["startup"], xdg / "fontconfig", cold_cache, warm["fontconfig_cache"]))
|
||||
# The measurement is valid or the test says it cannot judge: the browser was traced, and the two folders reached its parent.
|
||||
for name, launch in launches.items():
|
||||
assert launch["log_lines"] > 0, "%s launch: strace wrote nothing, the browser was not traced" % name
|
||||
assert launch["parent_environ"] == {"XDG_CACHE_HOME": str(xdg), "HOME": str(home)}, (
|
||||
"%s launch: the parent's environment carries %r, not the folders of the test (XDG_CACHE_HOME=%s, HOME=%s): a clean result would say nothing"
|
||||
% (name, launch["parent_environ"], xdg, home))
|
||||
# The assertions: nothing written, nothing opened, on either launch.
|
||||
for name, launch in launches.items():
|
||||
assert not launch["cache_files_under_the_two_folders"], (
|
||||
"%s launch: fontconfig cache files were written under XDG_CACHE_HOME or HOME: %s"
|
||||
% (name, launch["cache_files_under_the_two_folders"][:6]))
|
||||
assert not launch["cache_file_opens"], (
|
||||
"%s launch: %d open(s) of a fontconfig cache file by the browser, by role %s: %s"
|
||||
% (name, len(launch["cache_file_opens"]), sorted({o["role"] for o in launch["cache_file_opens"]}),
|
||||
[(o["role"], o["call"], o["path"], o["result"]) for o in launch["cache_file_opens"][:6]]))
|
||||
@@ -0,0 +1,120 @@
|
||||
"""The retail width of a password field comes from the capture by a script, and the committed file is what that script writes: nothing is typed.
|
||||
|
||||
``tests/test_a_password_field_is_as_wide_as_on_retail_windows_e2e.py`` compares the width a page reads on a password field of our engine with what RETAIL Firefox 159 on Windows read in the same page.
|
||||
Its number is read from ``ci/retail-password-mask.json``, which ``scripts/extract_retail_password_mask.py`` writes from the capture. The wrapper's CI has no capture, so, with no browser and no capture:
|
||||
|
||||
1. the extraction is run on a small capture made here (the shape of a ``result.json`` and of ``meta.json``, with a known width): it gives that width, the mask, the sha256 of the files read and the browser;
|
||||
2. known-bad captures are refused, never filled in: a ``result.json`` that is not the file ``meta.json`` lists, a page that is not the page of the capture, a result with an error, a result with no ``arial16``
|
||||
reading, a password field whose own box and series box disagree, a verdict that does not name U+25CF alone, a capture that is not a Windows one;
|
||||
3. the committed file has what the e2e test reads: the browser (version, build id, installer, ``firefox.exe`` and ``xul.dll`` sha256), the run, the page's sha256 (equal to the sha256 of the page of
|
||||
the test), and the reading of ``arial16`` with its mask U+25CF; its width is a positive whole number of pixels;
|
||||
4. the e2e test holds no retail number of its own: it reads the file, and types no width.
|
||||
|
||||
Known-bad: a typed width in the e2e test, a page that is not the capture's. Green: the state of the repository.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import copy
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict
|
||||
|
||||
import pytest
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(ROOT / "scripts"))
|
||||
|
||||
import extract_retail_password_mask as ex # noqa: E402
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
E2E = ROOT / "tests" / "test_a_password_field_is_as_wide_as_on_retail_windows_e2e.py"
|
||||
PAGE = ROOT / "tests" / "data" / "password_mask_page.html"
|
||||
|
||||
|
||||
def _result(width: int = 400) -> Dict[str, Any]:
|
||||
"""A result.json of the page with a known width for 40 characters of the mask U+25CF."""
|
||||
font = {"password": {"40": {"scrollWidth": width, "scrollWidth_main": width, "clientWidth": 20}, "per_char": width / 40},
|
||||
"refs": {"U+25CF": {"text_input": {"40": {"scrollWidth": width}}}, "*": {"text_input": {"40": {"scrollWidth": width - 100}}}},
|
||||
"verdict": {"by_text_input_scrollWidth": ["U+25CF"]}}
|
||||
return {"format": "password-mask/1", "n": 40, "env": {"platform": "Win32", "devicePixelRatio": 1}, "fonts": {"arial16": font, "default16": copy.deepcopy(font)}}
|
||||
|
||||
|
||||
def _capture(tmp_path: Path, result: Dict[str, Any] = None, *, listed_sha: str = None, page_sha: str = None) -> Path:
|
||||
folder = tmp_path / "captures" / "firefox-159.0" / "windows-server-2025" / "password-mask" / "2026-12-02"
|
||||
folder.mkdir(parents=True)
|
||||
path = folder / "result.json"
|
||||
path.write_text(json.dumps(result or _result()), encoding="utf-8")
|
||||
meta = {"files": {"result.json": {"sha256": listed_sha or hashlib.sha256(path.read_bytes()).hexdigest()}}, "page": {"sha256": page_sha or ex.sha256_of(PAGE)},
|
||||
"firefox_version": "159.0", "build_id": "20261022150525", "source_run": {"repo": "example/core", "run_id": 1},
|
||||
"host": {"runner_image": "windows-2025", "os_version": "10.0.26100", "os_ubr": "1"},
|
||||
"binaries": {"installer_sha256": "ab" * 32, "firefox_exe_sha256": "cd" * 32, "xul_dll_sha256": "ef" * 32}}
|
||||
(folder / "meta.json").write_text(json.dumps(meta), encoding="utf-8")
|
||||
return folder
|
||||
|
||||
|
||||
def _refused(tmp_path: Path, fragment: str, **kw) -> None:
|
||||
with pytest.raises(ex.ExtractError) as info:
|
||||
ex.build(_capture(tmp_path, **kw), "abc123")
|
||||
assert fragment in str(info.value), str(info.value)
|
||||
|
||||
|
||||
def test_the_extraction_gives_the_width_of_the_capture_with_the_sha256_of_the_files_read(tmp_path):
|
||||
data = ex.build(_capture(tmp_path, _result(400)), "abc123")
|
||||
assert data["cases"]["arial16"] == {"password_scrollWidth": 400, "mask": "U+25CF", "devicePixelRatio": 1, "platform": "Win32"}
|
||||
assert data["capture"]["retail_captures_commit"] == "abc123" and data["capture"]["browser"]["build_id"] == "20261022150525"
|
||||
assert data["page"]["sha256"] == ex.sha256_of(PAGE) and [f["path"] for f in data["files"]] == ["result.json", "meta.json"]
|
||||
|
||||
|
||||
def test_a_result_that_is_not_the_file_the_capture_listed_is_refused(tmp_path):
|
||||
_refused(tmp_path, "not the file the capture recorded", listed_sha="0" * 64)
|
||||
|
||||
|
||||
def test_a_page_that_is_not_the_page_of_the_capture_is_refused(tmp_path):
|
||||
_refused(tmp_path, "the test would not read the page retail read", page_sha="0" * 64)
|
||||
|
||||
|
||||
def test_a_result_with_an_error_or_without_the_reading_is_refused(tmp_path):
|
||||
_refused(tmp_path, "recorded an error", result={"format": "password-mask/1", "error": "boom"})
|
||||
no_font = _result()
|
||||
del no_font["fonts"]["arial16"]
|
||||
_refused(tmp_path / "b", "no retail value, none invented", result=no_font)
|
||||
|
||||
|
||||
def test_a_password_field_whose_boxes_disagree_or_whose_verdict_is_not_the_windows_mask_is_refused(tmp_path):
|
||||
disagree = _result()
|
||||
disagree["fonts"]["arial16"]["password"]["40"]["scrollWidth_main"] = 1
|
||||
_refused(tmp_path, "in its own box", result=disagree)
|
||||
star = _result()
|
||||
star["fonts"]["arial16"]["verdict"]["by_text_input_scrollWidth"] = ["*"]
|
||||
_refused(tmp_path / "b", "not the mask character of Windows", result=star)
|
||||
narrow = _result()
|
||||
narrow["fonts"]["arial16"]["refs"]["U+25CF"]["text_input"]["40"]["scrollWidth"] = 300
|
||||
_refused(tmp_path / "c", "not the mask character of Windows", result=narrow)
|
||||
|
||||
|
||||
def test_a_capture_that_is_not_a_windows_one_is_refused(tmp_path):
|
||||
linux = _result()
|
||||
linux["env"]["platform"] = "Linux x86_64"
|
||||
_refused(tmp_path, "not a Windows capture", result=linux)
|
||||
|
||||
|
||||
def test_the_committed_file_has_what_the_e2e_test_reads():
|
||||
data = json.loads((ROOT / "ci" / "retail-password-mask.json").read_text(encoding="utf-8"))
|
||||
assert data["page"]["sha256"] == ex.sha256_of(PAGE), "the page of the test is not the page of the capture"
|
||||
browser = data["capture"]["browser"]
|
||||
assert browser["firefox_version"] == "159.0" and all(re.fullmatch(r"[0-9a-f]{64}", browser[k]) for k in ("installer_sha256", "firefox_exe_sha256", "xul_dll_sha256")), browser
|
||||
assert re.fullmatch(r"[0-9a-f]{40}", data["capture"]["retail_captures_commit"]) and "/actions/runs/" in data["capture"]["run"]
|
||||
case = data["cases"]["arial16"]
|
||||
assert data["n"] == 40 and case["mask"] == "U+25CF" and case["platform"] == "Win32" and case["devicePixelRatio"] == 1, case
|
||||
assert isinstance(case["password_scrollWidth"], int) and case["password_scrollWidth"] > 0, case
|
||||
|
||||
|
||||
def test_the_e2e_test_holds_no_retail_number_of_its_own():
|
||||
source = E2E.read_text(encoding="utf-8")
|
||||
assert "retail-password-mask.json" in source, "the e2e test does not read ci/retail-password-mask.json"
|
||||
typed = re.findall(r"==\s*\d{3}\b|=\s*\d{3}\s*$", source, re.M)
|
||||
assert not typed, "a width is typed in the e2e test: %r" % typed
|
||||
+514
@@ -0,0 +1,514 @@
|
||||
"""The retail numbers of the popup move/resize test come from the captures by a script, and the committed file is what that script writes: nothing is typed.
|
||||
|
||||
Mozilla's ``LoadPersistentWindowState`` (AppWindow.cpp:2322-2350) gives a popup the stored spec of the main window when the XUL store has the entry, and leaves it its own spec when it has not. A real user's
|
||||
profile has the entry; a NEW profile has none until something maximizes, resizes or activates the main window. The FIRST popup of a new profile is one device pixel narrower at 150% (inner 499, outer 514, against 500
|
||||
and 515), and in some runs one device pixel shorter at 125% (inner 399). That is the state of a new profile, not of a user's, so every phase of
|
||||
``tests/test_a_popup_moves_and_resizes_as_declared_e2e.py``, the first popup included, expects the numbers of the STORED state, read from ``ci/retail-popup-move-resize.json``, which
|
||||
``scripts/extract_retail_popup_move_resize.py`` writes and ``scripts/retail_popup_formula.py`` (the formula with the stored spec) must reproduce for EVERY popup captured while the store held the entry. The wrapper's CI has
|
||||
no capture, so, with no browser and no capture:
|
||||
|
||||
1. the extraction of the rounds is run on a small capture made here (several rounds, the two launches, the four display cases, known values): it gives those values and the sha256 of every file read;
|
||||
2. known-bad captures are refused, never filled in: two rounds that disagree, two launches that disagree, a moment that is missing, positions that do not follow the order of the moves, one round only,
|
||||
a display case asked at another scale, another browser;
|
||||
3. the extraction of the ``popup-move-to`` capture is run on a small capture made here (four launches, four display cases, a synthetic browser whose first popup is narrower at 1.5): every phase is given as the first and
|
||||
as a later popup, with the launches it came from; known-bad captures are refused (a hash that is not the meta.json's, a launch with no throwaway popup, a popup left open, two popups of one position that disagree...);
|
||||
4. the formula is checked on known retail values (the fresh and the stored spec at the four scales) and applied to cells: a popup of the stored state that the stored-spec formula does not reproduce (a first popup of a
|
||||
new profile among them), a popup of a profile seen with no entry that the fresh-spec formula does not reproduce, make the extraction refuse; the second session of a profile and the popup-move-to capture are read into cells
|
||||
with the state of the store each popup had;
|
||||
5. a reading of the old rounds that is not what the stored state reads is an anomaly the extraction fails on;
|
||||
6. the committed file has every case and phase in the stored state, the formula's numbers and frame, the run ids and the sha256 of every raw.json, the new-profile state recorded as a note with the run ids and the
|
||||
cells the fresh spec does or does not reproduce, and the formula applied to the committed frame gives the committed expectations;
|
||||
7. the e2e test holds no retail number of its own and expects the stored state in every phase, the first popup included.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict
|
||||
|
||||
import pytest
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(ROOT / "scripts"))
|
||||
|
||||
import extract_retail_popup_move_resize as ex # noqa: E402
|
||||
import retail_popup_formula as rpf # noqa: E402
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
E2E = ROOT / "tests" / "test_a_popup_moves_and_resizes_as_declared_e2e.py"
|
||||
ROUNDS = ["2026-01-01-window-geometry-r1", "2026-01-02-window-geometry-r2"]
|
||||
|
||||
|
||||
def _moment(inner_w: int, screen) -> Dict[str, Any]:
|
||||
return {"innerWidth": inner_w, "innerHeight": 400, "outerWidth": 515, "outerHeight": 478, "screenX": screen[0], "screenY": screen[1], "availLeft": 0, "availWidth": 1280}
|
||||
|
||||
|
||||
def _raw(scale: float, *, resized_width: int = 501, build_id: str = "1", features: str = "width=500,height=400", skip: str = "", positions=None) -> Dict[str, Any]:
|
||||
at = positions or {"initial": (3, 3), "resized": (3, 3), "moved": (13, 13), "moved_to": (764, 0)}
|
||||
widths = {"initial": 500, "resized": resized_width, "moved": resized_width, "moved_to": resized_width}
|
||||
moments = {name: _moment(widths[name], at[name]) for name in ex.MOMENTS if name != skip}
|
||||
return {"dpr_asked": scale, "firefox_version": "159.0", "build_id": build_id, "installer_sha256": "cd" * 32, "steps": {"popup_move_resize": {"features": features, "moments": moments}}}
|
||||
|
||||
|
||||
def _capture(tmp_path: Path, rounds=ROUNDS, changes: Dict[Any, Any] = None) -> Path:
|
||||
"""``changes`` maps ``(round index, dpr folder, launch)`` to the keyword arguments of that raw.json; the key ``None`` applies to all."""
|
||||
changes = changes or {}
|
||||
captures = tmp_path / "captures"
|
||||
for index, round_name in enumerate(rounds):
|
||||
for dpr_dir, panel, scale in ex.DISPLAYS:
|
||||
for launch in ("a", "b"):
|
||||
kwargs = dict(changes.get(None, {}))
|
||||
kwargs.update(changes.get((index, dpr_dir, launch), {}))
|
||||
target = captures / ex.BROWSER_DIR / round_name / dpr_dir / panel / launch
|
||||
target.mkdir(parents=True)
|
||||
(target / "raw.json").write_text(json.dumps(_raw(kwargs.pop("scale", scale), **kwargs)), encoding="utf-8")
|
||||
return captures
|
||||
|
||||
|
||||
def test_the_extraction_gives_the_agreed_readings_with_the_sha256_of_every_file_read(tmp_path):
|
||||
data = ex.build(_capture(tmp_path), ROUNDS, "abc123")
|
||||
assert sorted(data["cases"]) == ["1600x1200-dpr2.0", "1920x1080-dpr1.0", "1920x1080-dpr1.25", "1920x1080-dpr1.5"]
|
||||
case = data["cases"]["1920x1080-dpr1.5"]
|
||||
assert case["initial"]["inner"] == [500, 400] and case["resized"]["inner"] == [501, 400] and case["moved"]["screen"] == [13, 13] and case["moved_to"]["screen"] == [764, 0]
|
||||
assert len(data["files"]) == len(ROUNDS) * 4 * 2 and all(re.fullmatch(r"[0-9a-f]{64}", f["sha256"]) for f in data["files"])
|
||||
assert data["capture"]["rounds"] == ROUNDS and data["capture"]["browser"]["build_id"] == "1"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("what, changes, rounds, message", [
|
||||
("two rounds that disagree", {(1, "dpr1.5", "a"): {"resized_width": 500}}, ROUNDS, "reads"),
|
||||
("two launches that disagree", {(0, "dpr2", "b"): {"resized_width": 502}}, ROUNDS, "reads"),
|
||||
("a moment that is missing", {(0, "dpr1", "a"): {"skip": "resized"}}, ROUNDS, "no retail value, none invented"),
|
||||
("positions out of the order of the moves", {None: {"positions": {"initial": (3, 3), "resized": (9, 9), "moved": (13, 13), "moved_to": (764, 0)}}}, ROUNDS, "do not follow the order"),
|
||||
("one round only", {}, ROUNDS[:1], "at least two rounds"),
|
||||
("a display case asked at another scale", {(0, "dpr1.25", "a"): {"scale": 1.5}}, ROUNDS, "asks scale"),
|
||||
("another browser", {(1, "dpr1", "b"): {"build_id": "2"}}, ROUNDS, "not the same browser"),
|
||||
("a popup opened with other features", {(0, "dpr1", "a"): {"features": "popup"}}, ROUNDS, "was opened with"),
|
||||
])
|
||||
def test_a_capture_that_does_not_give_a_value_is_refused_not_filled_in(tmp_path, what, changes, rounds, message):
|
||||
with pytest.raises(ex.ExtractError, match=message):
|
||||
ex.build(_capture(tmp_path, rounds=rounds, changes=changes), rounds, "abc123")
|
||||
|
||||
|
||||
def _committed() -> Dict[str, Any]:
|
||||
return json.loads(ex.DATA_PATH.read_text(encoding="utf-8"))
|
||||
|
||||
|
||||
CASES = ["1600x1200-dpr2.0", "1920x1080-dpr1.0", "1920x1080-dpr1.25", "1920x1080-dpr1.5"]
|
||||
POSITIONS = ["first", "later"]
|
||||
|
||||
|
||||
def test_the_committed_file_has_every_phase_in_the_stored_state_with_its_provenance():
|
||||
data = _committed()
|
||||
assert sorted(data["cases"]) == CASES
|
||||
for case, phases in data["cases"].items():
|
||||
assert list(phases) == ex.MOVE_TO_PHASES, "%s: the phases are %r" % (case, list(phases))
|
||||
for phase, moments in phases.items():
|
||||
assert list(moments) == list(ex.MOVE_TO_MOMENTS[phase]), "%s %s: the moments are %r (no position: the stored state is the only expectation)" % (case, phase, list(moments))
|
||||
for name, reading in moments.items():
|
||||
assert sorted(reading) == ["avail", "inner", "outer", "screen"], "%s %s %s: %r" % (case, phase, name, reading)
|
||||
capture = data["capture"]
|
||||
assert capture["run_id"].isdigit() and capture["retail_captures_commit"] and capture["launches"] == ex.MOVE_TO_LAUNCHES
|
||||
assert capture["browser"]["firefox_version"] == "159.0" and capture["browser"]["build_id"] and re.fullmatch(r"[0-9a-f]{64}", capture["browser"]["installer_sha256"])
|
||||
assert sorted(capture["binaries_sha256"]) == ["firefox.exe", "xul.dll"] and all(re.fullmatch(r"[0-9a-f]{64}", v) for v in capture["binaries_sha256"].values())
|
||||
assert len(data["files"]) == 4 * len(ex.MOVE_TO_LAUNCHES) * 2 + 4 and all(re.fullmatch(r"[0-9a-f]{64}", f["sha256"]) for f in data["files"])
|
||||
for case, phases in data["sources"].items():
|
||||
for phase, launches in phases.items():
|
||||
assert launches and not any(s.endswith("#1") for s in launches), "%s %s: the expectations come from popups after the first of a launch: %r" % (case, phase, launches)
|
||||
check = data["rounds_cross_check"]
|
||||
assert len(check["capture"]["rounds"]) >= 2 and check["capture"]["retail_captures_commit"] and len(check["files"]) == len(check["capture"]["rounds"]) * 4 * 2
|
||||
assert check["reproduced_by"] == {case: "stored" for case in CASES}, check["reproduced_by"]
|
||||
|
||||
|
||||
def test_the_stored_state_at_scale_1_5_is_500_inside_and_515_outside_and_resizeBy_takes_it_to_501():
|
||||
"""At a real 150% a popup opened with the main window's entry in the store reads 500 inside and 515 outside, resizeBy(0, 0) takes it to 501 and moveTo(99999, 0) stops it at 765: the
|
||||
numbers every phase of the test expects, the first popup included. The first popup of a new profile (499, 514, 766) is not among the expectations."""
|
||||
cases = _committed()["cases"]
|
||||
now = cases["1920x1080-dpr1.5"]
|
||||
resize = now["resize_by_zero"]
|
||||
assert resize["initial"]["inner"] == [500, 400] and resize["resized"]["inner"] == [501, 400] and resize["initial"]["outer"] == resize["resized"]["outer"] == [515, 478], resize
|
||||
assert now["move_to_far_right"]["moved_to"]["screen"] == [765, 0], now["move_to_far_right"]
|
||||
for case in ("1920x1080-dpr1.0", "1920x1080-dpr1.25", "1600x1200-dpr2.0"):
|
||||
reading = cases[case]["resize_by_zero"]
|
||||
assert reading["resized"]["inner"] == reading["initial"]["inner"] == [500, 400] and reading["resized"]["outer"] == reading["initial"]["outer"], (case, reading)
|
||||
for case, phases in cases.items():
|
||||
assert all(v["initial"]["inner"] == [500, 400] for p, v in phases.items() if p == "resize_by_zero") and 499 not in [m["inner"][0] for v in phases.values() for m in v.values()], (case, phases)
|
||||
|
||||
|
||||
def test_the_first_popup_of_a_new_profile_is_a_recorded_note_with_the_runs_not_an_expectation():
|
||||
"""The first popup of a profile whose store has no main-window entry reads a fresh window's numbers (inner 499 and outer 514 at 1.5; inner height 399 at 1.25 in some runs): they are recorded with the
|
||||
run ids and the state of the store, and the formula with the fresh spec reproduces them."""
|
||||
data = _committed()
|
||||
note = data["new_profile_state"]
|
||||
assert "New-profile state" in note["about"]
|
||||
assert {run["run_id"] for run in note["runs"]} == {"46833539990", "46832090474", "46980413884"}, note["runs"]
|
||||
recorded = [c for c in note["cells"] if c["entry_recorded"] is False]
|
||||
assert sorted(c["case"] for c in recorded) == ["1600x1200-dpr2.0", "1920x1080-dpr1.25", "1920x1080-dpr1.5"], recorded
|
||||
assert all(c["fresh_spec_reproduces"] for c in recorded), "a first popup seen with no entry in the store is a fresh window: the fresh-spec formula reproduces it"
|
||||
assert all(c["entry_recorded"] in (None, False) for c in note["cells"])
|
||||
assert all(c["fresh_spec_reproduces"] or c["stored_spec_reproduces"] for c in note["cells"])
|
||||
not_fresh = sorted(c["cell"] for c in note["cells"] if not c["fresh_spec_reproduces"])
|
||||
assert not_fresh and all(c.startswith("2026-12-02-b ") for c in not_fresh), "only the first popups of run 46833539990 read the stored numbers: %r" % not_fresh
|
||||
first = note["first_popup_readings_of_the_extracted_run"]["1920x1080-dpr1.5"]["resize_by_zero"]
|
||||
assert first["initial"]["inner"] == [499, 400] and first["initial"]["outer"] == [514, 478], first
|
||||
|
||||
|
||||
def test_the_committed_expectations_are_what_the_formula_gives_with_the_stored_spec():
|
||||
"""The formula applied to the committed frame and work area gives the committed readings: the file is the formula's, and nothing in it was chosen."""
|
||||
data = _committed()
|
||||
formula = data["stored_spec_formula"]
|
||||
assert formula["checked"]["cells_checked"] >= 100 and sorted(formula["cases"]) == CASES
|
||||
states = {}
|
||||
for source, by_state in formula["checked"]["cells_by_source_and_state"].items():
|
||||
for state, count in by_state.items():
|
||||
states[state] = states.get(state, 0) + count
|
||||
assert states.get("stored", 0) > 80 and states.get("new-profile") == 3, states
|
||||
for case, entry in formula["cases"].items():
|
||||
frame = rpf.Frame(**entry["frame"])
|
||||
sizes = rpf.popup_sizes(entry["scale"], tuple(entry["avail_css"]), frame, rpf.STORED)
|
||||
assert sizes == entry["sizes"], case
|
||||
for phase, moments in data["cases"][case].items():
|
||||
for name in ("initial", "resized"):
|
||||
if name in moments:
|
||||
want = rpf.expected_for_moment(sizes, name)
|
||||
assert moments[name]["inner"] == [want["w"]["inner"], want["h"]["inner"]] and moments[name]["outer"] == [want["w"]["outer"], want["h"]["outer"]], (case, phase, name)
|
||||
|
||||
|
||||
def test_the_move_resize_test_reads_the_file_and_types_no_retail_table():
|
||||
source = E2E.read_text(encoding="utf-8")
|
||||
assert "retail-popup-move-resize.json" in source, "the test does not read ci/retail-popup-move-resize.json"
|
||||
assert not re.search(r"^RETAIL\b", source, re.M), "a RETAIL table is typed in the move/resize test"
|
||||
assert not re.search(r"\(\(\d+, \d+\), \(\d+, \d+\), \d+\)", source), "a tuple of retail positions is typed in the move/resize test"
|
||||
|
||||
|
||||
def test_every_phase_of_the_move_resize_test_expects_the_stored_state_the_first_popup_included():
|
||||
"""Phase 1 opens the FIRST popup of its browser, and a real user's profile holds the main window's entry (AppWindow.cpp:2322-2350), so no phase reads the first-popup numbers of a new profile."""
|
||||
source = E2E.read_text(encoding="utf-8")
|
||||
assert re.search(r'MOMENTS = \{case: phases\["resize_by_zero"\] for case, phases in _RETAIL\["cases"\]\.items\(\)\}', source), "phase 1 does not read the stored state"
|
||||
assert re.search(r'MOVE_TO = \{case: phases\["move_to_far_right"\] for case, phases in _RETAIL\["cases"\]\.items\(\)\}', source), "phase 3 does not read the stored state"
|
||||
assert '["first"]' not in source and '["later"]' not in source and "new_profile_state" not in source, "the test reads a position of the capture"
|
||||
body = source[source.index("def test_a_popup_moves_and_resizes_as_declared"):]
|
||||
order = [body.index(call) for call in ("_phase_resize_by_zero(", "_phase_move_by(", "_phase_move_to_the_far_right(")]
|
||||
assert order == sorted(order) and body.count("_phase_") == 3 and body.index("new_page()") < order[0] and body.count("_open(") == 0, "the order or the number of popups of the test changed"
|
||||
|
||||
|
||||
# ---- the capture ``popup-move-to`` (format ``retail-popup-move-to/1``): four launches, every phase as the first popup of a browser and as a later popup ----
|
||||
|
||||
import hashlib # noqa: E402
|
||||
from typing import Callable, Optional # noqa: E402
|
||||
|
||||
MOVE_TO_RUN = "4600000000001"
|
||||
BINARIES = {"firefox.exe": "ab" * 32, "xul.dll": "ef" * 32}
|
||||
|
||||
|
||||
def _values(scale: float, position: str) -> Dict[str, Any]:
|
||||
"""What the synthetic browser reads: at 1.5 the first popup is a device pixel narrower (inner 499, outer 514, the clamp stops at 766) and a later one grows to 501 after resizeBy(0, 0)."""
|
||||
narrow = scale == 1.5 and position == "first"
|
||||
return {"iw": 499 if narrow else 500, "ow": 514 if narrow else 515, "resized_iw": 499 if narrow else (501 if scale == 1.5 else 500), "moved_to_x": 766 if narrow else 765}
|
||||
|
||||
|
||||
def _mt_moment(v: Dict[str, Any], name: str, screen) -> Dict[str, Any]:
|
||||
return {"availL": 0, "availW": 1280, "ih": 400, "iw": v["resized_iw"] if name == "resized" else v["iw"], "oh": 478, "ow": v["ow"], "settled": True, "sx": screen[0], "sy": screen[1]}
|
||||
|
||||
|
||||
def _mt_step(phase: str, ordinal: int, scale: float, *, closed: bool = True, features: str = "width=500,height=400", skip: str = "", calls=None, moved=(13, 13), x_shift: int = 0) -> Dict[str, Any]:
|
||||
v = _values(scale, "first" if ordinal == 1 else "later")
|
||||
at = {"initial": (3, 3), "resized": (3, 3), "moved": moved, "moved_to": (v["moved_to_x"] + x_shift, 0)}
|
||||
moments = {name: _mt_moment(v, name, at[name]) for name in ex.MOVE_TO_MOMENTS[phase] if name != skip}
|
||||
return {"features": features, "calls": calls if calls is not None else dict(ex.MOVE_TO_CALLS[phase]), "closed": closed, "ordinal": ordinal, "moments": moments}
|
||||
|
||||
|
||||
def _mt_raw(scale: float, launch: str, build_id: str = "1", fmt: str = "retail-popup-move-to/1", error=None, phases=None, steps: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
|
||||
plan = ex.MOVE_TO_LAUNCHES[launch]
|
||||
made = {"phase_" + phase: _mt_step(phase, ordinal, scale) for ordinal, phase in enumerate(plan, 1)}
|
||||
made.update(steps or {})
|
||||
return {"build_id": build_id, "dpr_asked": scale, "error": error, "firefox_version": "159.0", "format": fmt, "installer_sha256": "cd" * 32, "launch": launch,
|
||||
"phases_planned": phases if phases is not None else list(plan), "steps": made}
|
||||
|
||||
|
||||
def _mt_capture(tmp_path: Path, change: Optional[Callable[[str, str, Dict[str, Any]], None]] = None, meta_wrong: str = "", run_build: str = "1", binaries=None, scales=None, skip_file=None) -> Path:
|
||||
"""``change(dpr folder, launch, raw)`` may edit a raw.json before it is written (its sha256 goes in the meta.json after the change)."""
|
||||
folder = tmp_path / "popup-move-to" / "2026-01-03"
|
||||
folder.mkdir(parents=True)
|
||||
for dpr_dir, panel, scale in ex.DISPLAYS:
|
||||
hashes = {}
|
||||
for launch in ex.MOVE_TO_LAUNCHES:
|
||||
raw = _mt_raw((scales or {}).get(dpr_dir, scale), launch)
|
||||
if change:
|
||||
change(dpr_dir, launch, raw)
|
||||
if skip_file == (dpr_dir, launch):
|
||||
continue
|
||||
target = folder / dpr_dir / panel / launch
|
||||
target.mkdir(parents=True)
|
||||
body = json.dumps(raw).encode("utf-8")
|
||||
(target / "raw.json").write_bytes(body)
|
||||
hashes["%s/%s/raw.json" % (panel, launch)] = hashlib.sha256(body).hexdigest()
|
||||
if meta_wrong == dpr_dir:
|
||||
hashes["%s/a/raw.json" % panel] = "00" * 32
|
||||
meta = {"format": "retail-popup-move-to-meta/1", "build_id": "1", "firefox_version": "159.0", "installer_sha256": "cd" * 32, "raw_sha256": hashes}
|
||||
(folder / dpr_dir / "meta.json").write_text(json.dumps(meta), encoding="utf-8")
|
||||
run_info = {"binaries": {name: {"bytes": 1, "sha256": sha} for name, sha in (binaries or BINARIES).items()}, "build": {"build_id": run_build}}
|
||||
(folder / "run-info.json").write_text(json.dumps(run_info), encoding="utf-8")
|
||||
return folder
|
||||
|
||||
|
||||
def test_the_move_to_extraction_reads_every_phase_as_the_first_and_as_a_later_popup_and_records_the_run_the_build_and_the_binaries(tmp_path):
|
||||
data = ex.build_move_to(_mt_capture(tmp_path), MOVE_TO_RUN, "abc123")
|
||||
assert sorted(data["cases"]) == CASES
|
||||
case = data["cases"]["1920x1080-dpr1.5"]
|
||||
assert list(case) == ex.MOVE_TO_PHASES and all(list(p) == POSITIONS for p in case.values())
|
||||
first, later = case["resize_by_zero"]["first"], case["resize_by_zero"]["later"]
|
||||
assert first["initial"]["inner"] == first["resized"]["inner"] == [499, 400] and first["initial"]["outer"] == [514, 478], first
|
||||
assert later["initial"]["inner"] == [500, 400] and later["resized"]["inner"] == [501, 400] and later["initial"]["outer"] == [515, 478], later
|
||||
assert case["move_to_far_right"]["first"]["moved_to"]["screen"] == [766, 0] and case["move_to_far_right"]["later"]["moved_to"]["screen"] == [765, 0]
|
||||
assert case["move_to_far_right"]["later"]["moved"]["screen"] == [13, 13] and case["move_by"]["first"]["moved"]["screen"] == [13, 13]
|
||||
assert data["cases"]["1920x1080-dpr1.25"]["resize_by_zero"]["first"] == data["cases"]["1920x1080-dpr1.25"]["resize_by_zero"]["later"]
|
||||
assert data["sources"]["1920x1080-dpr1.5"] == {
|
||||
"resize_by_zero": {"first": ["a#1"], "later": ["c#2"]},
|
||||
"move_by": {"first": ["d#1"], "later": ["a#2", "c#3"]},
|
||||
"move_to_far_right": {"first": ["b#1"], "later": ["a#3", "c#4"]},
|
||||
}
|
||||
assert len(data["files"]) == 4 * 4 and all(re.fullmatch(r"[0-9a-f]{64}", f["sha256"]) for f in data["files"])
|
||||
capture = data["capture"]
|
||||
assert capture["run_id"] == MOVE_TO_RUN and capture["retail_captures_commit"] == "abc123" and capture["browser"]["build_id"] == "1" and capture["launches"] == ex.MOVE_TO_LAUNCHES
|
||||
assert capture["binaries_sha256"] == BINARIES
|
||||
|
||||
|
||||
def _edit(launch: str, edit: Callable[[Dict[str, Any]], None], dpr: str = "dpr1.5"):
|
||||
return lambda d, l, raw: edit(raw) if (d, l) == (dpr, launch) else None
|
||||
|
||||
|
||||
@pytest.mark.parametrize("what, kwargs, message", [
|
||||
("a raw.json that is not what its meta.json hashed", {"meta_wrong": "dpr1.25"}, "its meta.json says"),
|
||||
("a build the run-info does not name", {"run_build": "2"}, "names the build"),
|
||||
("no sha256 of xul.dll", {"binaries": {"firefox.exe": "ab" * 32}}, "lacks the sha256"),
|
||||
("a scale asked as another", {"scales": {"dpr1.25": 1.5}}, "asks scale"),
|
||||
("a launch that is missing", {"skip_file": ("dpr2", "d")}, "missing"),
|
||||
("another format", {"change": _edit("a", lambda r: r.update(format="retail-popup-move-resize/9"), "dpr1")}, "has the format"),
|
||||
("a launch that is another launch", {"change": _edit("c", lambda r: r.update(launch="a"), "dpr1")}, "is launch"),
|
||||
("a launch with no throwaway popup first", {"change": _edit("c", lambda r: r.update(phases_planned=["resize_by_zero", "move_by", "move_to_far_right"]), "dpr2")}, "not the one this launch is for"),
|
||||
("a step that is another popup of the browser", {"change": _edit("c", lambda r: r["steps"]["phase_resize_by_zero"].update(ordinal=1))}, "is popup number"),
|
||||
("a step that is missing", {"change": _edit("b", lambda r: r["steps"].pop("phase_move_to_far_right"))}, "is missing: no retail value"),
|
||||
("a moment that is missing", {"change": _edit("a", lambda r: r["steps"]["phase_move_by"]["moments"].pop("moved"))}, "no retail value, none invented"),
|
||||
("positions out of the order of the moves", {"change": _edit("d", lambda r: r["steps"]["phase_move_by"]["moments"]["moved"].update(sx=3, sy=3))}, "do not follow the order"),
|
||||
("a resize that moved the window", {"change": _edit("a", lambda r: r["steps"]["phase_resize_by_zero"]["moments"]["resized"].update(sx=9))}, "do not follow the order"),
|
||||
("other features", {"change": _edit("a", lambda r: r["steps"]["phase_move_by"].update(features="popup"), "dpr1")}, "was opened with"),
|
||||
("other calls", {"change": _edit("a", lambda r: r["steps"]["phase_move_by"].update(calls={"moved": "window.moveBy(1, 1)"}), "dpr1")}, "the calls are"),
|
||||
("a popup left open", {"change": _edit("c", lambda r: r["steps"]["phase_throwaway"].update(closed=False))}, "was not closed"),
|
||||
("a run that ended with an error", {"change": _edit("a", lambda r: r.update(error="boom"), "dpr1")}, "ends with the error"),
|
||||
("two later popups of one phase that disagree", {"change": _edit("c", lambda r: r["steps"]["phase_move_to_far_right"]["moments"]["moved_to"].update(sx=764))}, "popups of one position must agree"),
|
||||
("two later popups of one phase that disagree in size", {"change": _edit("c", lambda r: r["steps"]["phase_move_by"]["moments"]["moved"].update(iw=499), "dpr2")}, "popups of one position must agree"),
|
||||
])
|
||||
def test_a_move_to_capture_that_does_not_give_a_value_is_refused_not_filled_in(tmp_path, what, kwargs, message):
|
||||
folder = _mt_capture(tmp_path, **kwargs)
|
||||
with pytest.raises(ex.ExtractError, match=message):
|
||||
ex.build_move_to(folder, MOVE_TO_RUN, "abc123")
|
||||
|
||||
|
||||
def _rounds_reading(resized_width: int) -> Dict[str, Any]:
|
||||
return {"cases": {case: {"initial": {"inner": [500, 400], "outer": [515, 478], "screen": [3, 3], "avail": [0, 1280]},
|
||||
"resized": {"inner": [resized_width, 400], "outer": [515, 478], "screen": [3, 3], "avail": [0, 1280]}} for case in ("1920x1080-dpr1.5",)}}
|
||||
|
||||
|
||||
def test_the_501_of_the_old_rounds_is_what_the_stored_state_reads(tmp_path):
|
||||
cases = ex.stored_state_of(ex.build_move_to(_mt_capture(tmp_path), MOVE_TO_RUN, "abc123"))
|
||||
assert ex.cross_check(_rounds_reading(501), cases) == {"1920x1080-dpr1.5": "stored"}
|
||||
|
||||
|
||||
def test_a_reading_of_the_old_rounds_that_is_not_the_stored_state_is_an_anomaly_not_a_choice(tmp_path):
|
||||
cases = ex.stored_state_of(ex.build_move_to(_mt_capture(tmp_path), MOVE_TO_RUN, "abc123"))
|
||||
with pytest.raises(ex.ExtractError, match="the stored state of the popup-move-to capture reads"):
|
||||
ex.cross_check(_rounds_reading(502), cases)
|
||||
with pytest.raises(ex.ExtractError, match="the stored state of the popup-move-to capture reads"):
|
||||
ex.cross_check(_rounds_reading(499), cases)
|
||||
|
||||
|
||||
def test_the_expectations_of_the_stored_state_are_the_later_popups_never_the_first(tmp_path):
|
||||
data = ex.build_move_to(_mt_capture(tmp_path), MOVE_TO_RUN, "abc123")
|
||||
stored = ex.stored_state_of(data)
|
||||
assert stored["1920x1080-dpr1.5"]["resize_by_zero"]["initial"]["inner"] == [500, 400] and stored["1920x1080-dpr1.5"]["move_to_far_right"]["moved_to"]["screen"] == [765, 0]
|
||||
assert stored["1920x1080-dpr1.5"]["resize_by_zero"] == data["cases"]["1920x1080-dpr1.5"]["resize_by_zero"]["later"]
|
||||
assert stored["1920x1080-dpr1.5"]["resize_by_zero"] != data["cases"]["1920x1080-dpr1.5"]["resize_by_zero"]["first"]
|
||||
|
||||
|
||||
# ---- the formula with the stored spec, applied to every popup captured while the store held the main window's entry ----
|
||||
|
||||
AVAIL = {1.0: (1920, 1032), 1.25: (1536, 816), 1.5: (1280, 672), 2.0: (800, 552)}
|
||||
|
||||
|
||||
def _frames_from_rounds_sample() -> Dict[float, "rpf.Frame"]:
|
||||
"""The frames the rounds of the capture gave (border, client origin, chrome), read by ``frame_of_popup`` from the numbers of a retail round."""
|
||||
return {1.0: rpf.Frame(8, 31, 72), 1.25: rpf.Frame(9, 38, 89), 1.5: rpf.Frame(11, 45, 106), 2.0: rpf.Frame(13, 58, 140)}
|
||||
|
||||
|
||||
def _sizes(scale: float, spec: str) -> Dict[str, Dict[str, int]]:
|
||||
return rpf.popup_sizes(scale, AVAIL[scale], _frames_from_rounds_sample()[scale], spec)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("scale, spec, window, inner, outer", [
|
||||
(1.5, "fresh", (771, 717), (499, 400), (514, 478)),
|
||||
(1.5, "stored", (772, 717), (500, 400), (515, 478)),
|
||||
(1.25, "fresh", (643, 597), (500, 399), (514, 478)),
|
||||
(1.25, "stored", (643, 598), (500, 400), (514, 478)),
|
||||
(1.0, "fresh", (516, 480), (500, 400), (516, 480)),
|
||||
(1.0, "stored", (516, 480), (500, 400), (516, 480)),
|
||||
(2.0, "fresh", (1026, 952), (500, 400), (513, 476)),
|
||||
(2.0, "stored", (1026, 952), (500, 400), (513, 476)),
|
||||
])
|
||||
def test_the_formula_gives_what_retail_read_with_the_fresh_and_with_the_stored_spec(scale, spec, window, inner, outer):
|
||||
"""Known values of the capture (runs 46832090474, 46833539990 and 46980413884: window rect, inner and outer of a popup opened with ``width=500,height=400``): a typed oracle for the formula, not for the test."""
|
||||
got = _sizes(scale, spec)
|
||||
assert (got["w"]["window"], got["h"]["window"]) == window and (got["w"]["inner"], got["h"]["inner"]) == inner and (got["w"]["outer"], got["h"]["outer"]) == outer, got
|
||||
|
||||
|
||||
def test_resizeBy_zero_takes_the_stored_popup_at_1_5_to_501_and_leaves_the_fresh_one_at_499():
|
||||
stored, fresh = _sizes(1.5, "stored"), _sizes(1.5, "fresh")
|
||||
assert (stored["w"]["resized_inner"], stored["w"]["resized_outer"], stored["w"]["resized_window"]) == (501, 515, 773)
|
||||
assert (fresh["w"]["resized_inner"], fresh["w"]["resized_outer"], fresh["w"]["resized_window"]) == (499, 514, 771)
|
||||
|
||||
|
||||
def _cell(scale: float, spec: str, state: str, entry=None, name: str = "a#1 resize_by_zero", case: str = "1920x1080-dpr1.5", source: str = "2026-01-01") -> Dict[str, Any]:
|
||||
"""A cell of the formula's own numbers (what a capture would read): the plumbing is tested here, the values above."""
|
||||
sizes = _sizes(scale, spec)
|
||||
moments = {m: rpf.expected_for_moment(sizes, m) for m in ("initial", "resized")}
|
||||
return {"case": case, "source": source, "run": "1", "scale": scale, "avail": AVAIL[scale], "cell": "%s %s" % (source, name), "state": state, "entry_recorded": entry, "moments": moments}
|
||||
|
||||
|
||||
def test_the_formula_with_the_stored_spec_reproduces_every_stored_cell_and_the_new_profile_cells_are_only_noted():
|
||||
cells = [_cell(1.5, "stored", ex.STATE_STORED), _cell(1.25, "stored", ex.STATE_STORED, True),
|
||||
_cell(1.5, "fresh", ex.STATE_NEW_PROFILE, False), _cell(1.5, "fresh", ex.STATE_UNRECORDED_FIRST), _cell(1.25, "stored", ex.STATE_UNRECORDED_FIRST)]
|
||||
summary, notes = ex.check_cells(cells, _frames_from_rounds_sample())
|
||||
assert summary["cells_checked"] == 5
|
||||
assert [n["cell"] for n in notes] == [c["cell"] for c in cells[2:]], "only the first popups are noted, and the stored ones are not"
|
||||
assert [(n["fresh_spec_reproduces"], n["stored_spec_reproduces"]) for n in notes] == [(True, False), (True, False), (False, True)]
|
||||
|
||||
|
||||
def test_a_first_popup_of_a_new_profile_among_the_stored_cells_makes_the_extraction_refuse():
|
||||
"""The old file took the first popup as the expectation (inner 499 at 1.5): the stored-spec formula does not reproduce it, so it cannot be among the cells of the stored state."""
|
||||
with pytest.raises(ex.ExtractError, match="does not reproduce 1 captured popups"):
|
||||
ex.check_cells([_cell(1.5, "stored", ex.STATE_STORED), _cell(1.5, "fresh", ex.STATE_STORED)], _frames_from_rounds_sample())
|
||||
|
||||
|
||||
def test_one_device_pixel_of_a_stored_cell_makes_the_extraction_refuse_and_names_the_cell():
|
||||
cell = _cell(1.5, "stored", ex.STATE_STORED, name="c#2 resize_by_zero")
|
||||
cell["moments"]["resized"]["w"]["window"] += 1
|
||||
with pytest.raises(ex.ExtractError, match="c#2 resize_by_zero"):
|
||||
ex.check_cells([cell], _frames_from_rounds_sample())
|
||||
|
||||
|
||||
def test_a_popup_seen_with_no_entry_in_the_store_that_the_fresh_spec_does_not_reproduce_makes_the_extraction_refuse():
|
||||
with pytest.raises(ex.ExtractError, match="does not reproduce 1 captured popups"):
|
||||
ex.check_cells([_cell(1.5, "stored", ex.STATE_NEW_PROFILE, False)], _frames_from_rounds_sample())
|
||||
|
||||
|
||||
def test_a_first_popup_that_neither_spec_reproduces_makes_the_extraction_refuse():
|
||||
cell = _cell(1.5, "fresh", ex.STATE_UNRECORDED_FIRST)
|
||||
cell["moments"]["initial"]["w"]["inner"] = 498
|
||||
with pytest.raises(ex.ExtractError, match="does not reproduce 1 captured popups"):
|
||||
ex.check_cells([cell], _frames_from_rounds_sample())
|
||||
|
||||
|
||||
def test_the_frame_of_a_popup_is_read_from_the_capture_not_typed():
|
||||
raw = {"steps": {"maximized": {"native": {"window_rect": [-11, -11, 1931, 1019]}},
|
||||
"popup": {"features": "width=500,height=400", "content": {"early": {"load": {"mozInnerScreenY": 73.33333587646484, "screenY": 3}}},
|
||||
"native": {"client_origin": [15, 49], "window_rect": [4, 4, 776, 721]}}}}
|
||||
assert ex.frame_of_popup(raw, 1.5, "sample") == rpf.Frame(11, 45, 106)
|
||||
raw["steps"]["popup"]["features"] = "popup"
|
||||
with pytest.raises(ex.ExtractError, match="was opened with"):
|
||||
ex.frame_of_popup(raw, 1.5, "sample")
|
||||
|
||||
|
||||
# ---- the popups of a second session of a profile and of a popup-move-to capture, read into cells with the state of the store ----
|
||||
|
||||
|
||||
def _native(window) -> Dict[str, Any]:
|
||||
return {"window_rect": [4, 4, 4 + window[0], 4 + window[1]]}
|
||||
|
||||
|
||||
def _ss_moment(scale: float, spec: str, name: str) -> Dict[str, Any]:
|
||||
m = rpf.expected_for_moment(_sizes(scale, spec), name)
|
||||
return {"iw": m["w"]["inner"], "ih": m["h"]["inner"], "ow": m["w"]["outer"], "oh": m["h"]["outer"], "native": _native((m["w"]["window"], m["h"]["window"]))}
|
||||
|
||||
|
||||
def _ss_capture(tmp_path: Path, entry_first: bool = False, wrong_hash: bool = False, wrong_format: bool = False) -> Path:
|
||||
"""A second session at 1.5 (a synthetic one: the first popup has no entry in the store and reads the fresh numbers, the second and third have it), and at scale 1 with the entry from the first popup on."""
|
||||
folder = tmp_path / "popup-move-to-second-session" / "2026-01-04"
|
||||
folder.mkdir(parents=True)
|
||||
for dpr_dir, panel, scale in ex.DISPLAYS:
|
||||
steps = {"maximized": {"content": {"availWidth": AVAIL[scale][0], "availHeight": AVAIL[scale][1]}}}
|
||||
for ordinal, phase in enumerate(ex.MOVE_TO_LAUNCHES["a"], 1):
|
||||
entry = ordinal > 1 or entry_first or scale in (1.0, 2.0)
|
||||
spec = "stored" if entry else "fresh"
|
||||
moments = {name: _ss_moment(scale, spec, name) for name in ("initial", "resized") if name == "initial" or phase == "resize_by_zero"}
|
||||
steps["phase_" + phase] = {"ordinal": ordinal, "moments": moments,
|
||||
"store_before": {"memory": {"width": "1168" if entry else None}, "disk": {"entry": None}}}
|
||||
raw = {"format": "retail-popup-second-session/1" if not wrong_format else "x/1", "error": None, "dpr_asked": scale, "phases_planned": list(ex.MOVE_TO_LAUNCHES["a"]), "session2": {"steps": steps}}
|
||||
target = folder / dpr_dir / panel / "second-session"
|
||||
target.mkdir(parents=True)
|
||||
body = json.dumps(raw).encode("utf-8")
|
||||
(target / "raw.json").write_bytes(body)
|
||||
digest = "00" * 32 if wrong_hash and dpr_dir == "dpr1.5" else hashlib.sha256(body).hexdigest()
|
||||
(folder / dpr_dir / "meta.json").write_text(json.dumps({"raw_sha256": {"%s/second-session/raw.json" % panel: digest}}), encoding="utf-8")
|
||||
return folder
|
||||
|
||||
|
||||
def test_the_second_session_gives_every_popup_with_the_state_of_the_store_it_was_opened_in(tmp_path):
|
||||
cells, files = ex.second_session_cells(_ss_capture(tmp_path), "46980413884")
|
||||
assert len(cells) == 4 * 3 and len(files) == 4 and all(re.fullmatch(r"[0-9a-f]{64}", f["sha256"]) for f in files)
|
||||
states = {(c["case"], c["cell"].split(" ")[-2]): (c["state"], c["entry_recorded"]) for c in cells}
|
||||
assert states[("1920x1080-dpr1.5", "second-session#1")] == ("new-profile", False)
|
||||
assert states[("1920x1080-dpr1.5", "second-session#2")] == ("stored", True) and states[("1920x1080-dpr1.5", "second-session#3")] == ("stored", True)
|
||||
assert states[("1920x1080-dpr1.0", "second-session#1")] == ("stored", True), "at scale 1 the entry was there from session 1"
|
||||
assert all(c["source"] == "second-session/2026-01-04" and c["run"] == "46980413884" for c in cells)
|
||||
summary, notes = ex.check_cells(cells, _frames_from_rounds_sample())
|
||||
assert summary["cells_checked"] == 12 and [(n["case"], n["entry_recorded"]) for n in notes] == [("1920x1080-dpr1.25", False), ("1920x1080-dpr1.5", False)]
|
||||
|
||||
|
||||
def test_a_second_session_whose_first_popup_had_the_entry_but_read_the_fresh_numbers_is_refused(tmp_path):
|
||||
"""A popup opened with the entry present is of the stored state: if it reads the fresh numbers the formula (and so the premise of the file) is wrong, and nothing is written."""
|
||||
folder = _ss_capture(tmp_path)
|
||||
path = folder / "dpr1.5" / "1920x1080" / "second-session" / "raw.json"
|
||||
raw = json.loads(path.read_text(encoding="utf-8"))
|
||||
raw["session2"]["steps"]["phase_resize_by_zero"]["store_before"]["memory"]["width"] = "1168"
|
||||
body = json.dumps(raw).encode("utf-8")
|
||||
path.write_bytes(body)
|
||||
(folder / "dpr1.5" / "meta.json").write_text(json.dumps({"raw_sha256": {"1920x1080/second-session/raw.json": hashlib.sha256(body).hexdigest()}}), encoding="utf-8")
|
||||
cells, _ = ex.second_session_cells(folder, "1")
|
||||
with pytest.raises(ex.ExtractError, match="does not reproduce 1 captured popups"):
|
||||
ex.check_cells(cells, _frames_from_rounds_sample())
|
||||
|
||||
|
||||
@pytest.mark.parametrize("what, kwargs, message", [
|
||||
("a raw.json that is not what its meta.json hashed", {"wrong_hash": True}, "its meta.json says"),
|
||||
("another format", {"wrong_format": True}, "has the format"),
|
||||
])
|
||||
def test_a_second_session_that_is_not_what_it_says_is_refused(tmp_path, what, kwargs, message):
|
||||
with pytest.raises(ex.ExtractError, match=message):
|
||||
ex.second_session_cells(_ss_capture(tmp_path, **kwargs), "1")
|
||||
|
||||
|
||||
def test_the_move_to_cells_give_the_first_popup_of_a_launch_as_a_store_not_recorded_state_and_the_others_as_stored(tmp_path):
|
||||
folder = _mt_capture(tmp_path)
|
||||
for dpr_dir, panel, scale in ex.DISPLAYS:
|
||||
for launch in ex.MOVE_TO_LAUNCHES:
|
||||
path = folder / dpr_dir / panel / launch / "raw.json"
|
||||
raw = json.loads(path.read_text(encoding="utf-8"))
|
||||
raw["steps"]["maximized"] = {"content": {"availWidth": AVAIL[scale][0], "availHeight": AVAIL[scale][1]}}
|
||||
for step in raw["steps"].values():
|
||||
for moment in step.get("moments", {}).values():
|
||||
moment["native"] = _native((771, 717))
|
||||
path.write_text(json.dumps(raw), encoding="utf-8")
|
||||
meta = json.loads((folder / dpr_dir / "meta.json").read_text(encoding="utf-8"))
|
||||
meta["raw_sha256"] = {"%s/%s/raw.json" % (panel, launch): hashlib.sha256((folder / dpr_dir / panel / launch / "raw.json").read_bytes()).hexdigest() for launch in ex.MOVE_TO_LAUNCHES}
|
||||
(folder / dpr_dir / "meta.json").write_text(json.dumps(meta), encoding="utf-8")
|
||||
cells, files = ex.move_to_cells(folder, MOVE_TO_RUN)
|
||||
by_cell = {c["cell"]: c["state"] for c in cells if c["case"] == "1920x1080-dpr1.5"}
|
||||
assert by_cell == {
|
||||
"2026-01-03 a#1 resize_by_zero": "first-popup-store-not-recorded", "2026-01-03 a#2 move_by": "stored", "2026-01-03 a#3 move_to_far_right": "stored",
|
||||
"2026-01-03 b#1 move_to_far_right": "first-popup-store-not-recorded",
|
||||
"2026-01-03 c#1 throwaway": "first-popup-store-not-recorded", "2026-01-03 c#2 resize_by_zero": "stored", "2026-01-03 c#3 move_by": "stored", "2026-01-03 c#4 move_to_far_right": "stored",
|
||||
"2026-01-03 d#1 move_by": "first-popup-store-not-recorded"}
|
||||
assert len(files) == 16 and all(f["path"].startswith("popup-move-to/2026-01-03/") for f in files)
|
||||
assert all(c["entry_recorded"] is None for c in cells)
|
||||
@@ -0,0 +1,129 @@
|
||||
"""The retail numbers of the popup test come from the capture by a script, and the committed file is what that script writes: nothing is typed.
|
||||
|
||||
``tests/test_a_popup_reads_the_retail_sizes_of_a_maximized_main_window_e2e.py`` once carried a table typed by hand, with a wrong value in it (outer width 514 at scale 1.5, which is the
|
||||
value of 1.25; retail read 515). Its numbers are now read from ``ci/retail-popup-sizes.json``, which ``scripts/extract_retail_popup_sizes.py`` writes from the retail capture. The wrapper's CI
|
||||
has no capture, so, with no browser and no capture:
|
||||
|
||||
1. the extraction is run on a small capture made here (the shape of a raw.json and of the CSV, with known values): it gives those values, from launch ``a``, with the sha256 of every file read;
|
||||
2. known-bad captures are refused, never filled in: a feature string the capture has no variant for, two launches that disagree, a display case asked at another scale, a CSV row that
|
||||
disagrees with ``popup_sizes``, a capture with no CSV row;
|
||||
3. the committed file has what the e2e test reads: the four display cases, each with the eight feature strings, every reading with its four values, the round, the run, the browser (version,
|
||||
build id, installer sha256) and the sha256 of the eight raw.json files and of the CSV; the value that was typed wrong (scale 1.5, ``width=500,height=400``, outer) is the capture's;
|
||||
4. the e2e test holds no retail number of its own: it reads the file, and defines none of the tables the old test typed.
|
||||
|
||||
Known-bad: the old table (outer 514x478 at scale 1.5) against the committed file. Green: the state of the repository.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import copy
|
||||
import csv
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict
|
||||
|
||||
import pytest
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(ROOT / "scripts"))
|
||||
|
||||
import extract_retail_popup_sizes as ex # noqa: E402
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
E2E = ROOT / "tests" / "test_a_popup_reads_the_retail_sizes_of_a_maximized_main_window_e2e.py"
|
||||
ROUND = "2026-12-01-window-geometry-r12"
|
||||
|
||||
|
||||
def _variant(features: str, inner, outer, screen, vv) -> Dict[str, Any]:
|
||||
return {"features": features, "at_1s": {"innerWidth": inner[0], "innerHeight": inner[1], "outerWidth": outer[0], "outerHeight": outer[1], "screenX": screen[0], "screenY": screen[1]},
|
||||
"early": {"load": {"visualViewportHeight": vv}}}
|
||||
|
||||
|
||||
def _raw(scale: float, launch: str, shift: int = 0) -> Dict[str, Any]:
|
||||
"""A raw.json with the step popup_sizes, a variant per feature string; ``shift`` moves every outer width (a launch that disagrees)."""
|
||||
variants = {}
|
||||
for index, features in enumerate(ex.FEATURES):
|
||||
variants["v%d" % index] = _variant(features, (100 + index, 200 + index), (110 + index + shift, 280 + index), (index, 2 * index), 200.5 + index)
|
||||
variants["empty"] = _variant("", (1, 2), (3, 4), (5, 6), 7)
|
||||
return {"dpr_asked": scale, "launch": launch, "firefox_version": "159.0", "build_id": "20261022150525", "installer_sha256": "ab" * 32, "steps": {"popup_sizes": {"variants": variants}}}
|
||||
|
||||
|
||||
def _capture(tmp_path: Path, *, drop: str = "", disagree: bool = False, scale_of: Dict[str, float] = None, csv_outer: int = None, csv_rows: bool = True) -> Path:
|
||||
captures = tmp_path / "captures"
|
||||
root = captures / ex.BROWSER_DIR / ROUND
|
||||
for dpr_dir, panel, scale in ex.DISPLAYS:
|
||||
for launch in ("a", "b"):
|
||||
raw = _raw((scale_of or {}).get(dpr_dir, scale), launch, shift=1 if (disagree and launch == "b" and dpr_dir == "dpr1.5") else 0)
|
||||
if drop and dpr_dir == "dpr1":
|
||||
raw["steps"]["popup_sizes"]["variants"] = {k: v for k, v in raw["steps"]["popup_sizes"]["variants"].items() if v["features"] != drop}
|
||||
target = root / dpr_dir / panel / launch
|
||||
target.mkdir(parents=True)
|
||||
(target / "raw.json").write_text(json.dumps(raw), encoding="utf-8")
|
||||
with (captures / ex.CSV_NAME).open("w", encoding="utf-8", newline="") as handle:
|
||||
writer = csv.writer(handle)
|
||||
writer.writerow(["path", "dpr_asked", "launch", "step", "features", "innerWidth", "innerHeight", "outerWidth", "outerHeight", "screenX", "screenY"])
|
||||
if csv_rows:
|
||||
for dpr_dir, panel, scale in ex.DISPLAYS:
|
||||
writer.writerow(["%s/%s/%s/a/raw.json" % (ROUND, dpr_dir, panel), scale, "a", "popup", "width=500,height=400", 100, 200, 110 if csv_outer is None else csv_outer, 280, 0, 0])
|
||||
return captures
|
||||
|
||||
|
||||
def test_the_extraction_gives_the_values_of_launch_a_with_the_sha256_of_every_file_read(tmp_path):
|
||||
data = ex.build(_capture(tmp_path), ROUND, "https://example.invalid/run", "abc123")
|
||||
assert sorted(data["cases"]) == ["1600x1200-dpr2.0", "1920x1080-dpr1.0", "1920x1080-dpr1.25", "1920x1080-dpr1.5"]
|
||||
assert data["cases"]["1920x1080-dpr1.5"]["width=500,height=400"] == {"inner": [100, 200], "outer": [110, 280], "screen": [0, 0], "vv_height": 200.5}
|
||||
assert data["cases"]["1920x1080-dpr1.5"]["popup"] == {"inner": [101, 201], "outer": [111, 281], "screen": [1, 2], "vv_height": 201.5}
|
||||
assert "" not in data["cases"]["1920x1080-dpr1.5"], "the tab (no features) is not a popup"
|
||||
assert [f["path"] for f in data["files"]] == ["%s/%s/%s/raw.json" % (d, p, launch) for d, p, _ in ex.DISPLAYS for launch in "ab"]
|
||||
assert all(re.fullmatch(r"[0-9a-f]{64}", f["sha256"]) for f in data["files"]) and re.fullmatch(r"[0-9a-f]{64}", data["csv_checked"]["sha256"])
|
||||
assert data["capture"]["browser"] == {"firefox_version": "159.0", "build_id": "20261022150525", "installer_sha256": "ab" * 32}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("what, kwargs, message", [
|
||||
("a feature string the capture has no variant for", {"drop": "left=5000,top=5000"}, "no retail value, none invented"),
|
||||
("two launches that disagree", {"disagree": True}, "launch a reads"),
|
||||
("a display case asked at another scale", {"scale_of": {"dpr1.25": 1.5}}, "asks scale"),
|
||||
("a CSV row that disagrees with popup_sizes", {"csv_outer": 999}, "in the CSV and"),
|
||||
("a CSV with no popup row", {"csv_rows": False}, "has no popup row"),
|
||||
])
|
||||
def test_a_capture_that_does_not_give_a_value_is_refused_not_filled_in(tmp_path, what, kwargs, message):
|
||||
with pytest.raises(ex.ExtractError, match=message):
|
||||
ex.build(_capture(tmp_path, **kwargs), ROUND, "https://example.invalid/run", "abc123")
|
||||
|
||||
|
||||
def _committed() -> Dict[str, Any]:
|
||||
return json.loads(ex.DATA_PATH.read_text(encoding="utf-8"))
|
||||
|
||||
|
||||
def test_the_committed_file_has_every_case_and_feature_string_with_its_provenance():
|
||||
data = _committed()
|
||||
assert sorted(data["cases"]) == ["1600x1200-dpr2.0", "1920x1080-dpr1.0", "1920x1080-dpr1.25", "1920x1080-dpr1.5"]
|
||||
for case, features in data["cases"].items():
|
||||
assert sorted(features) == sorted(ex.FEATURES), "%s: the feature strings are %r" % (case, sorted(features))
|
||||
for name, reading in features.items():
|
||||
assert sorted(reading) == ["inner", "outer", "screen", "vv_height"], "%s %r: %r" % (case, name, reading)
|
||||
capture = data["capture"]
|
||||
assert re.fullmatch(r"20\d\d-\d\d-\d\d-window-geometry-r\d+", capture["round"]) and capture["run"].startswith("https://github.com/") and capture["retail_captures_commit"]
|
||||
assert capture["browser"]["firefox_version"] == "159.0" and capture["browser"]["build_id"] and re.fullmatch(r"[0-9a-f]{64}", capture["browser"]["installer_sha256"])
|
||||
assert [f["path"] for f in data["files"]] == ["%s/%s/%s/raw.json" % (d, p, launch) for d, p, _ in ex.DISPLAYS for launch in "ab"]
|
||||
assert all(re.fullmatch(r"[0-9a-f]{64}", f["sha256"]) for f in data["files"]) and re.fullmatch(r"[0-9a-f]{64}", data["csv_checked"]["sha256"])
|
||||
|
||||
|
||||
def test_the_value_that_was_typed_wrong_is_the_captures_in_the_committed_file():
|
||||
"""Outer width at scale 1.5 for ``width=500,height=400``: the old table said 514 (the value of 1.25); retail read 515 in every round of the CSV (rows 26, 74, 122 and the later ones)."""
|
||||
cases = _committed()["cases"]
|
||||
assert cases["1920x1080-dpr1.5"]["width=500,height=400"]["outer"] == [515, 478], cases["1920x1080-dpr1.5"]["width=500,height=400"]
|
||||
assert cases["1920x1080-dpr1.25"]["width=500,height=400"]["outer"] == [514, 478], cases["1920x1080-dpr1.25"]["width=500,height=400"]
|
||||
old_table = copy.deepcopy(cases)
|
||||
old_table["1920x1080-dpr1.5"]["width=500,height=400"]["outer"] = [514, 478]
|
||||
assert old_table != cases, "the known-bad table (514x478 at 1.5) must differ from the capture's"
|
||||
|
||||
|
||||
def test_the_popup_test_reads_the_file_and_types_no_retail_table():
|
||||
source = E2E.read_text(encoding="utf-8")
|
||||
assert "retail-popup-sizes.json" in source, "the popup test does not read ci/retail-popup-sizes.json"
|
||||
typed = re.findall(r"^(?:SIZED|POPUP_ONLY|WIDTH_ONLY|HEIGHT_ONLY|SMALL|MEDIUM|NEAR|FAR)\s*=\s*(?:_table|_placed)\((?!\")", source, re.M)
|
||||
assert not typed, "a retail table is typed in the popup test: %r" % typed
|
||||
assert not re.search(r"\(\(\d+, \d+\), \(\d+, \d+\)", source), "a tuple of retail sizes is typed in the popup test"
|
||||
@@ -0,0 +1,154 @@
|
||||
"""The maximized window of a persona larger than any runner is ONE formula of the retail frame, and that formula gives the retail captures at 1920x1080 exactly.
|
||||
|
||||
No retail capture exists at 2560x1440 (the runners' display driver offers no such mode), so the e2e cases at 2560x1440 (scale 1.0 and 1.25) compute what a page reads with
|
||||
``tests/_retail_window_formula.py``: the persona's work area (read by the page), the retail border and chrome of the same scale and the popup frame (read from the 1920x1080 captures by
|
||||
``scripts/extract_retail_window_formula.py`` into ``ci/retail-window-formula.json``). With no browser and no capture:
|
||||
|
||||
1. the committed file carries, per scale, the capture's own 1920x1080 window and popup, and the formula applied to that capture's work area gives them EXACTLY: this is the proof of the formula;
|
||||
2. the extraction is run on a small capture made here and gives the values of launch ``a`` with the sha256 of every file read; a capture the formula does not reproduce, two launches that
|
||||
disagree and a window that is not the work area plus a border are refused;
|
||||
3. the same function, on the 2560x1440 work area, gives the numbers a window of that screen has (the border and the chrome are the same bar at both screens);
|
||||
4. the two e2e tests compute the expected values with the formula and type no retail number of the 2560x1440 cases.
|
||||
|
||||
Known-bad: a formula without the border (the host's rectangle is the work area, not the work area plus a border) fails the proof of 1. Green: the state of the repository.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict
|
||||
|
||||
import pytest
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(ROOT / "scripts"))
|
||||
sys.path.insert(0, str(ROOT / "tests"))
|
||||
|
||||
import _retail_window_formula as formula # noqa: E402
|
||||
import extract_retail_window_formula as ex # noqa: E402
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
ROUND = "2026-12-01-window-geometry-r12"
|
||||
MAXIMIZED_E2E = ROOT / "tests" / "test_the_maximized_window_frames_and_popups_read_retail_e2e.py"
|
||||
POPUP_E2E = ROOT / "tests" / "test_a_popup_reads_the_retail_sizes_of_a_maximized_main_window_e2e.py"
|
||||
|
||||
|
||||
def _raw(scale: float, launch: str, *, border: int, ui: int, avail, rect_extra: int = 0, outer_shift: int = 0) -> Dict[str, Any]:
|
||||
"""A raw.json of the shape the extraction reads, with the numbers the formula gives for ``avail`` (so that a good capture is reproduced)."""
|
||||
window = formula.expected_window(avail, scale, border, ui)
|
||||
w, h = formula.device(avail, scale)
|
||||
popup_frame = (14, 78)
|
||||
sized = {"innerWidth": 500, "innerHeight": 400, "outerWidth": 500 + popup_frame[0], "outerHeight": 400 + popup_frame[1], "screenX": 3, "screenY": 3}
|
||||
unsized = {"innerWidth": window["ow"] - popup_frame[0], "innerHeight": window["oh"] - popup_frame[1], "outerWidth": window["ow"], "outerHeight": window["oh"],
|
||||
"screenX": window["sx"], "screenY": window["sy"]}
|
||||
variants = {"v0": {"features": formula.SIZED, "at_1s": sized, "early": {"load": {"visualViewportHeight": 400}}},
|
||||
"v1": {"features": "popup", "at_1s": unsized, "early": {"load": {"visualViewportHeight": 1}}}}
|
||||
content = {"outerWidth": window["ow"] + outer_shift, "outerHeight": window["oh"], "innerWidth": window["iw"], "innerHeight": window["ih"], "screenX": window["sx"], "screenY": window["sy"],
|
||||
"mozInnerScreenX": 0, "mozInnerScreenY": window["my"], "probe": {"screen": {"availWidth": avail[0], "availHeight": avail[1]}}}
|
||||
native = {"window_rect": [-border, -border, w + border + rect_extra, h + border], "work_rect": [0, 0, w, h]}
|
||||
return {"dpr_asked": scale, "launch": launch, "firefox_version": "159.0", "build_id": "20261022150525", "installer_sha256": "ab" * 32,
|
||||
"steps": {"maximized": {"content": content, "native": native}, "popup_sizes": {"variants": variants}}}
|
||||
|
||||
|
||||
AVAIL = {1.0: (1920, 1032), 1.25: (1536, 816)}
|
||||
FRAME = {1.0: (8, 85), 1.25: (9, 106)}
|
||||
|
||||
|
||||
def _capture(tmp_path: Path, *, disagree: bool = False, rect_extra: int = 0, wrong_ui: bool = False) -> Path:
|
||||
captures = tmp_path / "captures"
|
||||
root = captures / ex.popup.BROWSER_DIR / ROUND
|
||||
for dpr_dir, panel, scale in ex.DISPLAYS:
|
||||
for launch in ("a", "b"):
|
||||
border, ui = FRAME[scale]
|
||||
raw = _raw(scale, launch, border=border, ui=ui, avail=AVAIL[scale], rect_extra=rect_extra, outer_shift=1 if (disagree and launch == "b") else 0)
|
||||
if wrong_ui:
|
||||
raw["steps"]["maximized"]["content"]["innerHeight"] += 7 # a window the formula does not give
|
||||
target = root / dpr_dir / panel / launch
|
||||
target.mkdir(parents=True)
|
||||
(target / "raw.json").write_text(json.dumps(raw), encoding="utf-8")
|
||||
return captures
|
||||
|
||||
|
||||
def _committed() -> Dict[str, Any]:
|
||||
return json.loads(formula.DATA_PATH.read_text(encoding="utf-8"))
|
||||
|
||||
|
||||
@pytest.mark.parametrize("scale", ["1.0", "1.25"])
|
||||
def test_the_formula_applied_to_the_work_area_of_the_capture_gives_the_capture_exactly(scale):
|
||||
"""The proof of the formula, from the committed file: the 1920x1080 window and popup of retail, reproduced from the work area, the border and the chrome."""
|
||||
entry = _committed()["scales"][scale]
|
||||
case = entry["capture_case"]
|
||||
got = formula.expected_window(case["avail_css"], float(scale), entry["border"], entry["ui"])
|
||||
for key, want in case["observed"].items():
|
||||
assert got[key] == pytest.approx(want, abs=0.001), "scale %s: the formula gives %s %r, the capture reads %r" % (scale, key, got[key], want)
|
||||
popup = formula.expected_popup("popup", got, tuple(entry["popup_frame"]), float(scale), case["avail_css"])
|
||||
for key in ("inner", "outer", "screen"):
|
||||
assert list(popup[key]) == case["popup_observed"][key], "scale %s: the formula gives the popup %s %r, the capture reads %r" % (scale, key, popup[key], case["popup_observed"][key])
|
||||
sized = formula.expected_popup(formula.SIZED, got, tuple(entry["popup_frame"]), float(scale), case["avail_css"])
|
||||
assert sized["inner"] == (500, 400)
|
||||
assert sized["outer"] == (500 + entry["popup_frame"][0], 400 + entry["popup_frame"][1])
|
||||
|
||||
|
||||
@pytest.mark.parametrize("scale, inner, outer", [(1.0, (500, 400), (516, 480)), (1.25, (500, 399), (514, 478))])
|
||||
def test_a_sized_popup_of_the_2560_persona_is_mozillas_delta_sizing_not_the_size_asked(scale, inner, outer):
|
||||
"""``width=500,height=400`` at 2560x1440: Mozilla sizes the popup from the content of the window it is born with, read as whole CSS pixels (AppWindow.cpp:2086-2088,
|
||||
SizeShellToWithLimit). At 1.25 the stored window is 1250 device pixels tall, its content 1152 (921.6 CSS, read as 922, back as 1153), so the window ends at 597 and the page reads
|
||||
500x399, outer 514x478: what the engine gave in run 47209890618 (Windows and Linux). The old formula said 500x400, the size asked, whatever the window."""
|
||||
avail = (round(2560 / scale), round((1440 - 48 * scale) / scale)) # the taskbar is 48 CSS pixels: (2048, 1104) at 1.25, the work area run 47209890618 read
|
||||
sized = formula.expected_popup(formula.SIZED, {}, (0, 0), scale, avail)
|
||||
assert (sized["inner"], sized["outer"]) == (inner, outer)
|
||||
|
||||
|
||||
def test_a_formula_without_the_border_is_not_the_capture():
|
||||
"""Known-bad: the host's rectangle (the work area, no border) is what the engine once gave; it is not what the capture reads."""
|
||||
entry = _committed()["scales"]["1.0"]
|
||||
case = entry["capture_case"]
|
||||
bad = formula.expected_window(case["avail_css"], 1.0, 0, entry["ui"])
|
||||
assert bad["ow"] != case["observed"]["ow"] and bad["sx"] != case["observed"]["sx"]
|
||||
|
||||
|
||||
def test_the_committed_file_has_the_provenance_and_the_two_scales():
|
||||
data = _committed()
|
||||
assert sorted(data["scales"]) == ["1.0", "1.25"]
|
||||
capture = data["capture"]
|
||||
assert re.fullmatch(r"20\d\d-\d\d-\d\d-window-geometry-r\d+", capture["round"]) and capture["run"].startswith("https://github.com/") and capture["retail_captures_commit"]
|
||||
assert capture["browser"]["firefox_version"] == "159.0" and re.fullmatch(r"[0-9a-f]{64}", capture["browser"]["installer_sha256"])
|
||||
assert [f["path"] for f in data["files"]] == ["%s/%s/%s/raw.json" % (d, p, launch) for d, p, _ in ex.DISPLAYS for launch in "ab"]
|
||||
assert all(re.fullmatch(r"[0-9a-f]{64}", f["sha256"]) for f in data["files"])
|
||||
|
||||
|
||||
def test_the_formula_on_the_2560x1440_work_area_gives_a_window_of_that_screen():
|
||||
"""Both screens go through the same function: at 2560 wide the outer width is the work area plus two borders, whatever the host."""
|
||||
out = formula.expected_window((2560, 1392), 1.0, 8, 85)
|
||||
assert (out["ow"], out["oh"], out["iw"], out["ih"], out["sx"], out["sy"], out["my"]) == (2576, 1408, 2560, 1307, -8, -8, 85)
|
||||
out = formula.expected_window((2048, 1126), 1.25, 9, 106)
|
||||
assert (out["ow"], out["iw"], out["sx"]) == (2062, 2048, -7)
|
||||
|
||||
|
||||
def test_the_extraction_gives_the_values_of_launch_a_with_the_sha256_of_every_file_read(tmp_path):
|
||||
data = ex.build(_capture(tmp_path), ROUND, "https://example.invalid/run", "abc123")
|
||||
assert sorted(data["scales"]) == ["1.0", "1.25"]
|
||||
assert (data["scales"]["1.25"]["border"], data["scales"]["1.25"]["ui"], data["scales"]["1.25"]["popup_frame"]) == (9, 106, [14, 78])
|
||||
assert (data["scales"]["1.0"]["border"], data["scales"]["1.0"]["ui"]) == (8, 85)
|
||||
assert all(re.fullmatch(r"[0-9a-f]{64}", f["sha256"]) for f in data["files"]) and len(data["files"]) == 4
|
||||
|
||||
|
||||
@pytest.mark.parametrize("what, kwargs, message", [
|
||||
("a window the formula does not give", {"wrong_ui": True}, "not a formula of the frame"),
|
||||
("two launches that disagree", {"disagree": True}, "launch a reads"),
|
||||
("a window that is not the work area plus a border", {"rect_extra": 3}, "inflated by one border"),
|
||||
])
|
||||
def test_a_capture_the_formula_does_not_reproduce_is_refused_not_filled_in(tmp_path, what, kwargs, message):
|
||||
with pytest.raises(ex.ExtractError, match=message):
|
||||
ex.build(_capture(tmp_path, **kwargs), ROUND, "https://example.invalid/run", "abc123")
|
||||
|
||||
|
||||
def test_the_two_e2e_tests_compute_the_expected_values_with_the_formula_and_type_none():
|
||||
for path in (MAXIMIZED_E2E, POPUP_E2E):
|
||||
source = path.read_text(encoding="utf-8")
|
||||
assert "import _retail_window_formula as formula" in source and "formula.expected_window(" in source, "%s does not compute the 2560x1440 numbers with the formula" % path.name
|
||||
assert "BROKEN CONTROL" not in source and "retail-window-geometry-2560x1440" not in source, "%s reads a capture that does not exist" % path.name
|
||||
assert not re.search(r"\b(2576|1408|2062)\b", source), "%s types a number of the 2560x1440 window" % path.name
|
||||
@@ -0,0 +1,228 @@
|
||||
"""The retail window of a twin gets the CONTENT area of ours, not its outer size: the select and tooltip twins no longer end BROKEN CONTROL for a frame that differs.
|
||||
|
||||
Ours is launched as a real window with the frame of a Windows window that the engine declares; the retail window has the frame of its own system and display. The twin used to ask the retail window
|
||||
the OUTER size of ours, which gives the same content area only when the two frames are equal (candidate run 46711902888, legs ``wrapper.e2e.stock_twin.select`` and ``.tooltip``, both systems):
|
||||
|
||||
* Linux, case 1920x1080-dpr1.0: "the retail window was asked the outer size of ours [1936, 1040] and answers outer [1936, 1040] and inner [1936, 1040]; ours has inner [1920, 1032]" (Xvfb has
|
||||
no window manager, so the retail frame is 0 and ours is 16x8);
|
||||
* Windows, case 1600x1200-dpr2.0: asked outer [813, 565], retail answers inner [805, 561]; ours has inner [800, 558.5] (retail's frame is 8x4 CSS pixels at 96 DPI with only the scale pref raised, the
|
||||
one ours declares is 13x6.5).
|
||||
|
||||
``run_retail_twin`` now sizes the retail window by the content area of ours plus the frame the retail window shows, and compares the inner sizes as before. No browser: a fake retail window with a frame
|
||||
of its own answers the sizes it is asked, and the chrome of ours is a fake with the sizes of the two cases above.
|
||||
|
||||
Known-bad input: the old code (the retail window asked ours' outer size) with each of the two frames; green: the same window asked the content area plus its own frame. The control is as strict as it
|
||||
was: a window that cannot get the content area of ours (a minimum size, the screen) is still BROKEN CONTROL, and so is one that does not take the size it was asked.
|
||||
|
||||
The frame is read in exact device pixels (candidate run 46792115974): ``outerWidth`` and ``outerHeight`` are whole CSS pixels (nsGlobalWindowOuter::GetOuterSize rounds,
|
||||
nsGlobalWindowOuter.cpp:3573) and ``innerWidth`` and ``innerHeight`` are fractional, so the frame as outer less inner is wrong by up to half a CSS pixel, and a content area of an odd number of
|
||||
device pixels at a scale of 2 (558.5 CSS = 1117 device) has no outer size that reads back as asked (Linux dpr2.0: asked outer [800, 558.5], answers outer [800, 559] and inner [800, 558.5] = ours).
|
||||
``size_by_content`` now sets the retail window to ours' inner size plus its frame in device pixels (``RetailSession.set_inner_size``); the hard control is the equality of the inner sizes, and the outer
|
||||
size the window reads back is not a condition. An inner size that differs is still BROKEN CONTROL (Linux dpr1.25 and dpr1.5: the frame from the whole outer less the fractional inner made the
|
||||
retail inner 0.4 and 0.33 CSS pixels smaller than ours).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
import json
|
||||
import math
|
||||
|
||||
import pytest
|
||||
|
||||
import _retail_reference
|
||||
from _stock_twin import BrokenControl
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
#: Cases: scale, outer and inner size of ours (CSS pixels of the chrome), the frame of the retail window in DEVICE pixels.
|
||||
CASES = {
|
||||
"linux 1920x1080-dpr1.0": ("1920x1080-dpr1.0", 1.0, [1936, 1040], [1920, 1032], [0, 0]),
|
||||
"windows 1600x1200-dpr2.0": ("1600x1200-dpr2.0", 2.0, [813, 565], [800, 558.5], [16, 8]),
|
||||
"equal frames": ("1920x1080-dpr1.0", 1.0, [1936, 1040], [1920, 1032], [16, 8]),
|
||||
"linux dpr2.0 odd device height": ("1600x1200-dpr2.0", 2.0, [800, 559], [800, 558.5], [0, 0]),
|
||||
"windows dpr1.25 fractional inner": ("1920x1080-dpr1.25", 1.25, [1549, 830], [1548.8, 828.8], [16, 8]),
|
||||
}
|
||||
|
||||
|
||||
def _round(value):
|
||||
return int(math.floor(value + 0.5))
|
||||
|
||||
|
||||
class FakeRetailWindow:
|
||||
"""What the retail window answers: its frame is in device pixels, it takes the outer size it is asked in device pixels (down to ``minimum`` device pixels), reads the outer size back in WHOLE CSS
|
||||
pixels (as ``outerWidth`` does) and the inner size in CSS pixels as the device pixels over the scale (as ``innerWidth`` does)."""
|
||||
|
||||
def __init__(self, scale, frame, minimum=(0, 0)):
|
||||
self.scale, self.frame, self.minimum, self.asked = scale, frame, minimum, []
|
||||
|
||||
def set_inner_size(self, inner):
|
||||
asked = [_round(inner[i] * self.scale) + self.frame[i] for i in range(2)]
|
||||
self.asked.append(asked)
|
||||
device = [max(asked[i], self.minimum[i]) for i in range(2)]
|
||||
return {"outer": [_round(device[i] / self.scale) for i in range(2)], "inner": [(device[i] - self.frame[i]) / self.scale for i in range(2)],
|
||||
"frame_device": self.frame, "asked_outer_device": asked, "asked_outer": [asked[i] / self.scale for i in range(2)]}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def twin(monkeypatch):
|
||||
"""``run_retail_twin`` with no browser behind it: ours is a fake window of the sizes given, the retail window the fake above; returns the function that runs a case."""
|
||||
state = {}
|
||||
|
||||
class FakeChrome:
|
||||
def __init__(self, page):
|
||||
pass
|
||||
|
||||
def close(self):
|
||||
pass
|
||||
|
||||
class FakeBrowser:
|
||||
def new_page(self):
|
||||
return object()
|
||||
|
||||
@contextlib.contextmanager
|
||||
def launch_case(binary, case, **kwargs):
|
||||
yield FakeBrowser()
|
||||
|
||||
class FakeSession:
|
||||
def __init__(self, executable, dpr):
|
||||
pass
|
||||
|
||||
def __enter__(self):
|
||||
return state["window"]
|
||||
|
||||
def __exit__(self, *exc):
|
||||
return False
|
||||
|
||||
monkeypatch.setattr(_retail_reference, "retail_executable", lambda: "retail")
|
||||
monkeypatch.setattr(_retail_reference, "launch_case", launch_case)
|
||||
monkeypatch.setattr(_retail_reference, "Chrome", FakeChrome)
|
||||
monkeypatch.setattr(_retail_reference, "PlaywrightDriver", lambda page, chrome: object())
|
||||
monkeypatch.setattr(_retail_reference, "RetailSession", FakeSession)
|
||||
monkeypatch.setattr(_retail_reference, "RetailDriver", lambda session: object())
|
||||
|
||||
def run(case, outer, inner, window):
|
||||
state["window"] = window
|
||||
return _retail_reference.run_retail_twin(case, "not-launched", lambda driver: {"scales": {"chrome_outer": outer, "chrome_inner": inner}})
|
||||
|
||||
return run
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name", sorted(CASES))
|
||||
def test_the_retail_window_gets_the_content_area_of_ours_whatever_its_frame(twin, name):
|
||||
case, scale, outer, inner, frame = CASES[name]
|
||||
window = FakeRetailWindow(scale, frame)
|
||||
retail, ours = twin(case, outer, inner, window)
|
||||
assert ours["scales"]["chrome_inner"] == inner
|
||||
last = window.asked[-1]
|
||||
assert [last[i] - frame[i] for i in range(2)] == [_round(inner[i] * scale) for i in range(2)], (
|
||||
"%s: the retail window was last asked %r device pixels, which with its frame %r is not the content area of ours %r (asks: %r)" % (name, last, frame, inner, window.asked))
|
||||
assert retail["scales"]["window_asked_outer"] == [last[0] / scale, last[1] / scale]
|
||||
|
||||
|
||||
def test_equal_frames_ask_the_content_area_of_ours_once(twin):
|
||||
case, scale, outer, inner, frame = CASES["equal frames"]
|
||||
window = FakeRetailWindow(scale, frame)
|
||||
twin(case, outer, inner, window)
|
||||
assert len(window.asked) == 1
|
||||
|
||||
|
||||
def test_an_odd_number_of_device_pixels_is_not_a_broken_control_for_the_outer_size_it_reads_back(twin):
|
||||
"""Linux dpr2.0, candidate run 46792115974: ours has inner height 558.5 CSS = 1117 device pixels; the retail window answers outer 559 (whole CSS pixels) and inner 558.5 = ours. The outer
|
||||
size it reads back differs from the one asked (558.5) and that is not a finding or a broken control: the inner sizes are equal."""
|
||||
case, scale, outer, inner, frame = CASES["linux dpr2.0 odd device height"]
|
||||
window = FakeRetailWindow(scale, frame)
|
||||
answer = window.set_inner_size(inner)
|
||||
window.asked.clear()
|
||||
assert answer["outer"] == [800, 559] and answer["asked_outer"] == [800, 558.5] and answer["inner"] == inner
|
||||
retail, _ = twin(case, outer, inner, window)
|
||||
assert retail["scales"]["window_asked_outer"] == [800, 558.5]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name", ["linux 1920x1080-dpr1.0", "windows 1600x1200-dpr2.0"])
|
||||
def test_a_window_that_cannot_get_the_content_area_of_ours_is_still_a_broken_control(twin, name):
|
||||
"""The window has a minimum size above what the content area needs: its inner size stays above the one of ours, as strict as before."""
|
||||
case, scale, outer, inner, frame = CASES[name]
|
||||
window = FakeRetailWindow(scale, frame, minimum=(_round(outer[0] * scale) + 40, _round(outer[1] * scale) + 40))
|
||||
with pytest.raises(BrokenControl) as raised:
|
||||
twin(case, outer, inner, window)
|
||||
assert "BROKEN CONTROL" in str(raised.value) and "ours has inner %r" % (inner,) in str(raised.value)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name,delta", [("windows dpr1.25 fractional inner", [0.4, 0]), ("linux dpr2.0 odd device height", [0, 0.33]), ("linux 1920x1080-dpr1.0", [1, 0])])
|
||||
def test_a_window_whose_inner_size_differs_from_ours_is_a_broken_control(twin, name, delta):
|
||||
"""Linux dpr1.25 and dpr1.5 of the candidate run: the retail inner was 0.4 and 0.33 CSS pixels smaller than ours. The inner size is the hard control, whatever the outer size reads back."""
|
||||
class Drifting(FakeRetailWindow):
|
||||
def set_inner_size(self, inner):
|
||||
got = super().set_inner_size(inner)
|
||||
got["inner"] = [got["inner"][i] - delta[i] for i in range(2)]
|
||||
return got
|
||||
|
||||
case, scale, outer, inner, frame = CASES[name]
|
||||
with pytest.raises(BrokenControl) as raised:
|
||||
twin(case, outer, inner, Drifting(scale, frame))
|
||||
assert "ours has inner %r" % (inner,) in str(raised.value)
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------------------------------------------ how the real session sets a size
|
||||
|
||||
class Recorder:
|
||||
"""The Marionette calls of a ``RetailSession`` that is not started: what it sends for a size, and the sizes the chrome answers."""
|
||||
|
||||
def __init__(self, session):
|
||||
self.calls = []
|
||||
session.call = self.call
|
||||
self.outer = None
|
||||
|
||||
def call(self, context, command, params):
|
||||
self.calls.append((context, command, params))
|
||||
if command == "WebDriver:ExecuteScript" and "setSize" in params["script"]:
|
||||
self.outer = list(params["args"])
|
||||
elif command == "WebDriver:SetWindowRect":
|
||||
self.outer = [params["width"], params["height"]]
|
||||
elif command == "WebDriver:ExecuteScript":
|
||||
return {"value": json.dumps({"outer": self.outer, "inner": self.outer})}
|
||||
return {"value": None}
|
||||
|
||||
|
||||
def test_a_whole_size_goes_through_marionette_and_a_fraction_through_the_chrome_in_device_pixels():
|
||||
session = _retail_reference.RetailSession("retail", 2.0)
|
||||
recorder = Recorder(session)
|
||||
session.set_window_size((808, 562))
|
||||
assert recorder.calls[0][1] == "WebDriver:SetWindowRect" and recorder.calls[0][2] == {"x": 0, "y": 0, "width": 808, "height": 562}
|
||||
session.set_window_size((808, 562.5))
|
||||
context, command, params = [c for c in recorder.calls if c[1] == "WebDriver:ExecuteScript" and "setSize" in c[2]["script"]][0]
|
||||
assert context == "chrome" and params["args"] == [808, 562.5]
|
||||
assert "Math.round(height * scale)" in params["script"] and "nsIBaseWindow" in params["script"]
|
||||
|
||||
|
||||
class ContentRecorder:
|
||||
"""The Marionette calls of a ``RetailSession`` that is not started, for ``set_inner_size``: the chrome script that sizes the window (``getSize``) and the one that reads it back."""
|
||||
|
||||
def __init__(self, session, scale, frame):
|
||||
self.calls, self.scale, self.frame = [], scale, frame
|
||||
self.device = [0, 0]
|
||||
session.call = self.call
|
||||
|
||||
def call(self, context, command, params):
|
||||
self.calls.append((context, command, params))
|
||||
if command == "WebDriver:ExecuteScript" and "getSize" in params["script"]:
|
||||
want = [_round(params["args"][i] * self.scale) for i in range(2)]
|
||||
self.device = [want[i] + self.frame[i] for i in range(2)]
|
||||
return {"value": json.dumps({"frame": self.frame, "asked": self.device, "scale": self.scale})}
|
||||
if command == "WebDriver:ExecuteScript":
|
||||
return {"value": json.dumps({"outer": [_round(self.device[i] / self.scale) for i in range(2)], "inner": [(self.device[i] - self.frame[i]) / self.scale for i in range(2)]})}
|
||||
return {"value": None}
|
||||
|
||||
|
||||
def test_the_frame_is_read_and_the_size_set_in_device_pixels_in_one_chrome_script():
|
||||
session = _retail_reference.RetailSession("retail", 2.0)
|
||||
recorder = ContentRecorder(session, 2.0, [16, 8])
|
||||
got = session.set_inner_size((800, 558.5))
|
||||
scripts = [c for c in recorder.calls if c[1] == "WebDriver:ExecuteScript" and "getSize" in c[2]["script"]]
|
||||
assert len(scripts) == 1
|
||||
context, _, params = scripts[0]
|
||||
script = params["script"]
|
||||
assert context == "chrome" and params["args"] == [800, 558.5]
|
||||
assert "nsIBaseWindow" in script and "getSize(" in script and "setSize(" in script and "innerHeight * scale" in script and "frame[1]" in script
|
||||
assert got["inner"] == [800, 558.5] and got["outer"] == [808, 563]
|
||||
assert got["frame_device"] == [16, 8] and got["asked_outer_device"] == [1616, 1125] and got["asked_outer"] == [808, 562.5]
|
||||
@@ -0,0 +1,133 @@
|
||||
"""The criterion of the fontconfig e2e: which opens are a look at the host's fontconfig, and when the poisoned cache is in force, on fake strace lines.
|
||||
|
||||
The e2e (tests/test_no_fontconfig_file_of_the_host_is_opened_and_the_screenshot_draws_the_bundle_linux_e2e.py) asks that no process of the browser opens a path
|
||||
under /etc/fonts, a ``fonts.conf`` or a ``*.cache-*`` file, and that the screenshot draws the bundle with the host's caches poisoned. Its verdict is only as good as
|
||||
what it counts as an open and as a poison that is really in force; both are pure functions of the log and of what ``fc-list`` said, tried here with no browser:
|
||||
an open that is refused or unfinished still counts, a relative path takes the folder of its descriptor, a stat is evidence and not an open, and a cache that still lists
|
||||
the face (or lists nothing) is no poison.
|
||||
"""
|
||||
import importlib.util
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
TESTS = Path(__file__).resolve().parents[1]
|
||||
E2E = TESTS / "test_no_fontconfig_file_of_the_host_is_opened_and_the_screenshot_draws_the_bundle_linux_e2e.py"
|
||||
BINARY = "/engine/firefox"
|
||||
BUNDLE = "/opt/invisible-playwright/firefox-72_160.0_20261201000000/fonts"
|
||||
MD5 = "0123456789abcdef0123456789abcdef"
|
||||
|
||||
|
||||
def _module():
|
||||
sys.path.insert(0, str(TESTS))
|
||||
try:
|
||||
spec = importlib.util.spec_from_file_location("fontconfig_host_files_e2e", E2E)
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
sys.modules["fontconfig_host_files_e2e"] = module
|
||||
spec.loader.exec_module(module)
|
||||
finally:
|
||||
sys.path.remove(str(TESTS))
|
||||
return module
|
||||
|
||||
|
||||
def _lines(*calls):
|
||||
"""A strace log of a parent (pid 100) that starts a content process (pid 200), with the calls, as the test reads it (``-f -y``)."""
|
||||
return ['100 execve("%s", ["%s"], 0x0) = 0' % (BINARY, BINARY),
|
||||
'100 clone3({flags=CLONE_VM}, 88) = 200',
|
||||
'200 execve("%s", ["%s", "-contentproc"], 0x0) = 0' % (BINARY, BINARY)] + list(calls)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("path", [
|
||||
"/etc/fonts/fonts.conf", "/etc/fonts/conf.d/10-hinting-slight.conf", "/etc/fonts", "/etc/fonts/../fonts/conf.d",
|
||||
"/tmp/hd/.config/fontconfig/fonts.conf", BUNDLE + "/fonts.conf", "/fonts.conf",
|
||||
"/var/cache/fontconfig/" + MD5 + "-le64.cache-9", "/tmp/hd/.fontconfig/" + MD5 + "-le64.cache-9",
|
||||
"/tmp/hd/.cache/fontconfig/" + MD5 + "-le64.cache-9.NEW", "/tmp/hd/.cache/fontconfig/" + MD5 + "-le64.cache-9.TMP-YhscHU",
|
||||
])
|
||||
def test_a_path_of_the_host_s_fontconfig_is_named(path):
|
||||
assert _module().is_a_fontconfig_file_of_the_host(path) is True
|
||||
|
||||
|
||||
@pytest.mark.parametrize("path", [
|
||||
BUNDLE + "/arial.ttf", BUNDLE + "/msgothic5_32.ttc", "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", "/etc/fontsrc", "/etc/fonts.conf.bak",
|
||||
"/tmp/hd/.cache/fontconfig", "/tmp/hd/.cache/mozilla/startupCache/startupCache.8.little", "/proc/self/maps",
|
||||
])
|
||||
def test_a_path_that_is_not_the_host_s_fontconfig_is_left_alone(path):
|
||||
assert _module().is_a_fontconfig_file_of_the_host(path) is False
|
||||
|
||||
|
||||
def test_an_open_counts_whatever_its_result_and_an_unfinished_one_has_the_result_of_its_resumed_line():
|
||||
module = _module()
|
||||
lines = _lines(
|
||||
'100 openat(AT_FDCWD</>, "/etc/fonts/fonts.conf", O_RDONLY <unfinished ...>',
|
||||
'101 getpid() = 101',
|
||||
'100 <... openat resumed>) = -1 ENOENT (No such file or directory)',
|
||||
'100 openat(AT_FDCWD</>, "/etc/fonts/conf.d", O_RDONLY|O_DIRECTORY) = 7</etc/fonts/conf.d>',
|
||||
'100 openat(AT_FDCWD</>, "/etc/fonts/other.conf", O_RDONLY <unfinished ...>')
|
||||
opens = module.paths_of_calls(lines, module.OPEN_CALLS)
|
||||
assert [(o["path"], o["result"]) for o in opens] == [("/etc/fonts/fonts.conf", -1), ("/etc/fonts/conf.d", 7), ("/etc/fonts/other.conf", None)]
|
||||
|
||||
|
||||
def test_a_relative_path_takes_the_folder_strace_prints_for_its_descriptor():
|
||||
module = _module()
|
||||
lines = _lines('100 openat(5</etc/fonts/conf.d>, "10-hinting-slight.conf", O_RDONLY) = 6</etc/fonts/conf.d/10-hinting-slight.conf>',
|
||||
'100 openat(AT_FDCWD</tmp/hd>, "x/y.cache-9", O_RDONLY) = 8',
|
||||
'100 open("/etc/fonts/fonts.conf", O_RDONLY) = 9')
|
||||
assert [o["path"] for o in module.paths_of_calls(lines, module.OPEN_CALLS)] == [
|
||||
"/etc/fonts/conf.d/10-hinting-slight.conf", "/tmp/hd/x/y.cache-9", "/etc/fonts/fonts.conf"]
|
||||
|
||||
|
||||
def test_the_opens_of_every_process_are_judged_with_the_role_of_each():
|
||||
lines = _lines(
|
||||
'100 openat(AT_FDCWD</>, "/etc/fonts/fonts.conf", O_RDONLY) = 5',
|
||||
'200 openat(AT_FDCWD</>, "/var/cache/fontconfig/%s-le64.cache-9", O_RDONLY) = -1 ENOENT (No such file or directory)' % MD5,
|
||||
'300 openat(AT_FDCWD</>, "/tmp/hd/.fontconfig/%s-le64.cache-9", O_RDONLY) = 6' % MD5,
|
||||
'100 openat(AT_FDCWD</>, "%s/arial.ttf", O_RDONLY) = 7' % BUNDLE)
|
||||
looks = _module().host_fontconfig_looks(lines, BINARY)
|
||||
assert [(o["role"], o["path"].rsplit("/", 1)[1]) for o in looks["opens"]] == [
|
||||
("parent", "fonts.conf"), ("content", MD5 + "-le64.cache-9"), ("other", MD5 + "-le64.cache-9")]
|
||||
assert looks["other"] == []
|
||||
|
||||
|
||||
def test_a_stat_is_evidence_and_not_an_open_and_a_quiet_log_has_no_look():
|
||||
module = _module()
|
||||
lines = _lines('100 newfstatat(AT_FDCWD</>, "/etc/fonts/fonts.conf", {st_mode=S_IFREG|0644}, 0) = 0',
|
||||
'100 access("/etc/fonts/fonts.conf", R_OK) = 0',
|
||||
'100 readlink("/etc/fonts/conf.d/x.conf", 0x7ff, 4096) = -1 EINVAL (Invalid argument)')
|
||||
looks = module.host_fontconfig_looks(lines, BINARY)
|
||||
assert looks["opens"] == [] and [o["call"] for o in looks["other"]] == ["newfstatat", "access", "readlink"]
|
||||
assert module.host_fontconfig_looks(_lines('100 openat(AT_FDCWD</>, "%s/arial.ttf", O_RDONLY) = 7' % BUNDLE), BINARY) == {"opens": [], "other": []}
|
||||
|
||||
|
||||
def test_the_poison_is_written_for_the_real_folder_from_the_copy_into_one_cache_folder():
|
||||
module = _module()
|
||||
text = module.poison_config(BUNDLE, "/tmp/copy", "/tmp/hd/.fontconfig")
|
||||
assert '<remap-dir as-path="%s">/tmp/copy</remap-dir>' % BUNDLE in text and "<cachedir>/tmp/hd/.fontconfig</cachedir>" in text
|
||||
assert text.count("<dir>") == 0 and text.count("<cachedir>") == 1
|
||||
reader = module.reader_config(BUNDLE, "/tmp/hd/.fontconfig")
|
||||
assert "<dir>%s</dir>" % BUNDLE in reader and "<cachedir>/tmp/hd/.fontconfig</cachedir>" in reader
|
||||
|
||||
|
||||
def _poison(**over):
|
||||
cache = {"cache_folder": "/h/.fontconfig", "cache_files": [MD5 + "-le64.cache-9"],
|
||||
"listed_files": [BUNDLE + "/arial.ttf", BUNDLE + "/simsun.ttc"]}
|
||||
one = dict(cache, **over)
|
||||
return {"real_folder": BUNDLE, "md5_of_the_real_folder": MD5, "caches": {"home": dict(one), "xdg": dict(one)}}
|
||||
|
||||
|
||||
def test_a_poison_that_is_in_force_has_a_cache_for_the_real_folder_that_lacks_the_face():
|
||||
assert _module()._poison_problems(_poison()) == []
|
||||
|
||||
|
||||
@pytest.mark.parametrize("over, why", [
|
||||
({"listed_files": [BUNDLE + "/arial.ttf", BUNDLE + "/msgothic5_32.ttc"]}, "lists msgothic5_32.ttc"),
|
||||
({"listed_files": []}, "lists no font"),
|
||||
({"listed_files": ["/tmp/copy/arial.ttf"]}, "outside the real folder"),
|
||||
({"cache_files": ["ffffffffffffffffffffffffffffffff-le64.cache-9"]}, "no cache named for the real folder"),
|
||||
({"cache_files": []}, "no cache named for the real folder"),
|
||||
])
|
||||
def test_a_cache_that_is_no_poison_is_named_with_its_reason(over, why):
|
||||
problems = _module()._poison_problems(_poison(**over))
|
||||
assert len(problems) == 2 and all(why in p for p in problems)
|
||||
Reference in new issue
Block a user