tests: steady e2e of the characterization round (download without options, shutdown ping, dom iterables, windows TEMP)

- test_a_context_without_download_options_is_left_to_firefox: Firefox's own save no longer runs the download reputation check; the time until the file landed is recorded (not judged)
- test_the_shutdown_ping...: the sender is given 120 s (_profile.SENDER_GRACE) and the session's safety net follows, so the verdict waits for it to end by itself
- test_dom_iterables_from_evaluate_e2e: one browser per case
- e2e.yml: TEMP and TMP on D:\a\_temp in the Windows jobs, as the engine series' gate
This commit is contained in:
feder-cr committed 2026-11-22 10:19:58 +01:00
1 parent ac5a519244
commit 766961dcdb
4 files changed
+40 -6

No files matched your search

+10
View File
@@ -324,6 +324,11 @@ jobs:
if: needs.core-on-index.outputs.available == 'true'
runs-on: windows-latest
timeout-minutes: 20
# TEMP and TMP on D:\a\_temp (the runner's temp folder): the Firefox profiles land in TEMP and on C: they saturate the disk (queue up to 144,
# latencies up to 4 s, parent main thread still 40-60 s). On the job, not in a step: `runner.temp` is not readable in a job's `env`.
env:
TEMP: 'D:\a\_temp'
TMP: 'D:\a\_temp'
# `run:` blocks are PowerShell on Windows unless said otherwise (e2e-hunt.yml had a ParserError on its first launch there).
defaults:
run:
@@ -362,6 +367,11 @@ jobs:
if: needs.core-on-index.outputs.available == 'true' && inputs.only != 'windows-control-a'
runs-on: windows-2022
timeout-minutes: 40
# TEMP and TMP on D:\a\_temp (the runner's temp folder): the Firefox profiles land in TEMP and on C: they saturate the disk (queue up to 144,
# latencies up to 4 s, parent main thread still 40-60 s). On the job, not in a step: `runner.temp` is not readable in a job's `env`.
env:
TEMP: 'D:\a\_temp'
TMP: 'D:\a\_temp'
strategy:
fail-fast: false
matrix:
@@ -82,8 +82,9 @@ def site():
srv.server_close()
@pytest.fixture(scope="module")
@pytest.fixture
def browser(firefox_binary):
# One browser per case: a crash in one case reddens that case only, not the ones after it.
from invisible_playwright import InvisiblePlaywright
with InvisiblePlaywright(seed=4321, binary_path=firefox_binary,
+13 -5
View File
@@ -41,7 +41,7 @@ import threading
import pytest
from _waits import wait_until
from _waits import wait_until, watch
BODY = b"invisible download body\n" * 64
@@ -247,7 +247,7 @@ def test_a_canceled_download_reports_once_as_canceled(firefox_binary, held_site)
@pytest.mark.e2e
def test_a_context_without_download_options_is_left_to_firefox(firefox_binary, served, tmp_path):
def test_a_context_without_download_options_is_left_to_firefox(firefox_binary, served, tmp_path, record_property):
"""The negative control of the interception: the same context, the same link, the same file.
With its options the download is taken (announced, saved in the wrapper's directory). After
@@ -257,9 +257,14 @@ def test_a_context_without_download_options_is_left_to_firefox(firefox_binary, s
where = tmp_path / "firefox"
where.mkdir()
# Firefox's own path asks `ApplicationReputation` about a finished download before the saved file takes its name (`.bin` is a binary
# type), and that work is on the url-classifier, not on the download: on the runners this test took ~12 s or ~87 s for the same bytes.
# This test is about WHERE the file goes, so the check is not part of it: with these prefs Firefox saves what it was given.
prefs = {"browser.download.folderList": 2,
"browser.download.dir": str(where),
"browser.download.useDownloadDir": True}
"browser.download.useDownloadDir": True,
"browser.safebrowsing.downloads.enabled": False,
"browser.safebrowsing.malware.enabled": False}
with InvisiblePlaywright(seed=4242, binary_path=firefox_binary, headless=True,
extra_prefs=prefs) as browser:
context = browser.new_context(accept_downloads=True)
@@ -290,8 +295,11 @@ def test_a_context_without_download_options_is_left_to_firefox(firefox_binary, s
# so the click does not wait for it; the end of the test waits on the CONDITION, the file in Firefox's directory.
page.click("#dl", no_wait_after=True, timeout=30_000)
landed = where / "report.bin"
assert wait_until(lambda: landed.exists() and landed.read_bytes() == BODY, 120,
pump=lambda: page.wait_for_timeout(100)), os.listdir(str(where))
landing = watch(lambda: landed.exists() and landed.read_bytes() == BODY, bool, 120,
pump=lambda: page.wait_for_timeout(100))
# not a verdict: how long Firefox's own save took, so a slow run says whether it was the save or the close that was slow
record_property("seconds_until_the_file_landed", "%.1f" % landing.took)
assert landing.ok, os.listdir(str(where))
assert len(_of(events, "Browser.downloadCreated")) == 1, "the engine took a download of a context with no options"
assert len(_of(events, "Browser.downloadFinished")) == 1, events
@@ -33,8 +33,10 @@ import threading
import pytest
import _session_end
from _session_end import EndingPlaywright
from _waits import wait_until
from invisible_core.juggler import _profile
pytestmark = pytest.mark.e2e
@@ -42,6 +44,19 @@ SERVER = "toolkit.telemetry.server"
UPLOAD = "datareporting.healthreport.uploadEnabled"
BACKGROUND_TASK_AGENT = "pingsender/2.0"
#: What the sender is given to end by itself: far beyond a cold start on a loaded runner (the core's own is `_profile.SENDER_GRACE`, 10 s,
#: and the reaper ends the sender once it is over, so a slow sender would lose its ping and the verdict would judge the machine).
SENDER_GRACE = 120.0
@pytest.fixture(autouse=True)
def the_sender_ends_by_itself(monkeypatch):
"""The verdict waits for the sender to end by itself. `_profile.SENDER_GRACE` is read at the call (`Connection.close` and
`SessionFiles.remove` name it through the module), so the patch takes effect; the wait ends when the sender does, never on the time. The
session's own safety net (`ensure_ended`) goes up with it, since it would otherwise end the wait at 30 s."""
monkeypatch.setattr(_profile, "SENDER_GRACE", SENDER_GRACE)
monkeypatch.setitem(_session_end.ensure_ended.__kwdefaults__, "timeout", SENDER_GRACE + 30.0)
class Endpoint:
"""A telemetry endpoint on 127.0.0.1 (a port the OS gives) that records every request and answers 200."""