tests: a session of the trapped e2e ends before the next test starts, so the sender of its shutdown pings is not counted by the one after

close() returns when the browser has exited; the sender of the shutdown pings lives on for about half a second and asks the resolver of the machine for the telemetry host. In a session without a proxy of the launch that is allowed, and the next parameter of test_nothing_leaves_but_the_proxy_e2e.py, with a resolver trap of its own, counted those questions as its own (seen with the kernel's tools: 50-66 ms after it began).

Every session of the e2e files that run a resolver trap or a watcher of direct connections is now an EndingPlaywright (tests/_session_end.py): its __exit__ waits for the launch's reaper (wait_reaped, 30 s as a safety net) and for the session's processes to be gone, and fails, saying which are left, when the reaper does not finish. A unit test with no browser puts a stand-in process under a session token as the core registers the engine's tree: with the plain class it is alive when the close returns, with the new one the exit returns after the reaper has ended it. Another reads the files of the four trapped suites and fails on a session made with the plain class.

wrapper.unit.all.* min_tests: 1921 -> 1929 (Linux), 1922 -> 1930 (Windows).
This commit is contained in:
feder-cr committed 2026-11-16 10:27:19 +01:00
1 parent 6b64ae5379
commit ddc98493a2
8 files changed
+271 -18

No files matched your search

+2 -2
View File
@@ -12,6 +12,6 @@
{"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": 3, "exact": true, "tests": ["tests/test_software_compositing_is_declared_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."},
{"id": "wrapper.unit.compositing", "giro": "G1", "os": ["linux", "windows"], "min_tests": 19, "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."},
{"id": "wrapper.unit.all.linux", "giro": "G1", "os": ["linux"], "min_tests": 1921, "exact": true, "tests": ["tests", "--deselect=tests/test_version_is_not_taken.py::test_the_declared_version_is_not_already_published", "--deselect=tests/test_version_is_not_taken.py::test_the_check_can_tell_a_taken_version_from_a_free_one", "--deselect=tests/test_version_is_not_taken.py::test_the_check_can_tell_a_shipped_change_from_one_that_does_not_ship", "--deselect=tests/test_version_is_not_taken.py::test_the_diff_half_sees_a_release_that_did_move_the_package", "--deselect=tests/test_fork.py::test_the_injected_sources_have_balanced_quotes", "--deselect=tests/test_juggler_transport.py::test_the_workbench_inventory_and_the_package_cannot_DRIFT", "--deselect=tests/test_seal_binary_path.py::test_real_stock_firefox_via_binary_path_is_refused", "--deselect=tests/test_prefs_composition_arm.py::test_a_hidden_desktop_brings_its_two_sandbox_keys_and_nothing_hides_by_pref", "--deselect=tests/test_reaper.py::test_the_tree_dies_when_this_process_is_KILLED_not_merely_closed"], "marker": "not slow and not e2e", "needs_root": false, "windows_twin": "wrapper.unit.all.windows", "note": "The whole unit suite of the wrapper (what tests.yml runs: -m 'not slow and not e2e') with the core of the candidate, which tests.yml does not use until the pin moves. It holds the files of wrapper.unit.udp, wrapper.unit.page and wrapper.unit.compositing too: the overlap is on purpose. Deselected because they depend on the environment and a skip is red: test_the_declared_version_is_not_already_published (asks the package index, a network call); test_the_check_can_tell_a_taken_version_from_a_free_one (asks the package index, a network call); test_the_check_can_tell_a_shipped_change_from_one_that_does_not_ship (asks the package index, a network call); test_the_diff_half_sees_a_release_that_did_move_the_package (asks the package index, a network call); test_the_injected_sources_have_balanced_quotes (needs a driver bundle tree (INVPW_DRIVER_TREE)); test_the_workbench_inventory_and_the_package_cannot_DRIFT (needs the workbench next to the checkout); test_real_stock_firefox_via_binary_path_is_refused (needs a bundled stock Firefox); test_a_hidden_desktop_brings_its_two_sandbox_keys_and_nothing_hides_by_pref (the hidden desktop is a Windows path); test_the_tree_dies_when_this_process_is_KILLED_not_merely_closed (job objects are a Windows mechanism). min_tests counted with the judge's selector."},
{"id": "wrapper.unit.all.windows", "giro": "G1", "os": ["windows"], "min_tests": 1922, "exact": true, "tests": ["tests", "--deselect=tests/test_version_is_not_taken.py::test_the_declared_version_is_not_already_published", "--deselect=tests/test_version_is_not_taken.py::test_the_check_can_tell_a_taken_version_from_a_free_one", "--deselect=tests/test_version_is_not_taken.py::test_the_check_can_tell_a_shipped_change_from_one_that_does_not_ship", "--deselect=tests/test_version_is_not_taken.py::test_the_diff_half_sees_a_release_that_did_move_the_package", "--deselect=tests/test_fork.py::test_the_injected_sources_have_balanced_quotes", "--deselect=tests/test_juggler_transport.py::test_the_workbench_inventory_and_the_package_cannot_DRIFT", "--deselect=tests/test_seal_binary_path.py::test_real_stock_firefox_via_binary_path_is_refused", "--deselect=tests/test_juggler_posix_pipe.py::test_the_spawn_keeps_the_two_hardwired_descriptors"], "marker": "not slow and not e2e", "needs_root": false, "linux_twin": "wrapper.unit.all.linux", "note": "The whole unit suite of the wrapper (what tests.yml runs: -m 'not slow and not e2e') with the core of the candidate, which tests.yml does not use until the pin moves. It holds the files of wrapper.unit.udp, wrapper.unit.page and wrapper.unit.compositing too: the overlap is on purpose. Deselected because they depend on the environment and a skip is red: test_the_declared_version_is_not_already_published (asks the package index, a network call); test_the_check_can_tell_a_taken_version_from_a_free_one (asks the package index, a network call); test_the_check_can_tell_a_shipped_change_from_one_that_does_not_ship (asks the package index, a network call); test_the_diff_half_sees_a_release_that_did_move_the_package (asks the package index, a network call); test_the_injected_sources_have_balanced_quotes (needs a driver bundle tree (INVPW_DRIVER_TREE)); test_the_workbench_inventory_and_the_package_cannot_DRIFT (needs the workbench next to the checkout); test_real_stock_firefox_via_binary_path_is_refused (needs a bundled stock Firefox); test_the_spawn_keeps_the_two_hardwired_descriptors (the POSIX leg does not execute on Windows). min_tests counted with the judge's selector."}
{"id": "wrapper.unit.all.linux", "giro": "G1", "os": ["linux"], "min_tests": 1929, "exact": true, "tests": ["tests", "--deselect=tests/test_version_is_not_taken.py::test_the_declared_version_is_not_already_published", "--deselect=tests/test_version_is_not_taken.py::test_the_check_can_tell_a_taken_version_from_a_free_one", "--deselect=tests/test_version_is_not_taken.py::test_the_check_can_tell_a_shipped_change_from_one_that_does_not_ship", "--deselect=tests/test_version_is_not_taken.py::test_the_diff_half_sees_a_release_that_did_move_the_package", "--deselect=tests/test_fork.py::test_the_injected_sources_have_balanced_quotes", "--deselect=tests/test_juggler_transport.py::test_the_workbench_inventory_and_the_package_cannot_DRIFT", "--deselect=tests/test_seal_binary_path.py::test_real_stock_firefox_via_binary_path_is_refused", "--deselect=tests/test_prefs_composition_arm.py::test_a_hidden_desktop_brings_its_two_sandbox_keys_and_nothing_hides_by_pref", "--deselect=tests/test_reaper.py::test_the_tree_dies_when_this_process_is_KILLED_not_merely_closed"], "marker": "not slow and not e2e", "needs_root": false, "windows_twin": "wrapper.unit.all.windows", "note": "The whole unit suite of the wrapper (what tests.yml runs: -m 'not slow and not e2e') with the core of the candidate, which tests.yml does not use until the pin moves. It holds the files of wrapper.unit.udp, wrapper.unit.page and wrapper.unit.compositing too: the overlap is on purpose. Deselected because they depend on the environment and a skip is red: test_the_declared_version_is_not_already_published (asks the package index, a network call); test_the_check_can_tell_a_taken_version_from_a_free_one (asks the package index, a network call); test_the_check_can_tell_a_shipped_change_from_one_that_does_not_ship (asks the package index, a network call); test_the_diff_half_sees_a_release_that_did_move_the_package (asks the package index, a network call); test_the_injected_sources_have_balanced_quotes (needs a driver bundle tree (INVPW_DRIVER_TREE)); test_the_workbench_inventory_and_the_package_cannot_DRIFT (needs the workbench next to the checkout); test_real_stock_firefox_via_binary_path_is_refused (needs a bundled stock Firefox); test_a_hidden_desktop_brings_its_two_sandbox_keys_and_nothing_hides_by_pref (the hidden desktop is a Windows path); test_the_tree_dies_when_this_process_is_KILLED_not_merely_closed (job objects are a Windows mechanism). min_tests counted with the judge's selector."},
{"id": "wrapper.unit.all.windows", "giro": "G1", "os": ["windows"], "min_tests": 1930, "exact": true, "tests": ["tests", "--deselect=tests/test_version_is_not_taken.py::test_the_declared_version_is_not_already_published", "--deselect=tests/test_version_is_not_taken.py::test_the_check_can_tell_a_taken_version_from_a_free_one", "--deselect=tests/test_version_is_not_taken.py::test_the_check_can_tell_a_shipped_change_from_one_that_does_not_ship", "--deselect=tests/test_version_is_not_taken.py::test_the_diff_half_sees_a_release_that_did_move_the_package", "--deselect=tests/test_fork.py::test_the_injected_sources_have_balanced_quotes", "--deselect=tests/test_juggler_transport.py::test_the_workbench_inventory_and_the_package_cannot_DRIFT", "--deselect=tests/test_seal_binary_path.py::test_real_stock_firefox_via_binary_path_is_refused", "--deselect=tests/test_juggler_posix_pipe.py::test_the_spawn_keeps_the_two_hardwired_descriptors"], "marker": "not slow and not e2e", "needs_root": false, "linux_twin": "wrapper.unit.all.linux", "note": "The whole unit suite of the wrapper (what tests.yml runs: -m 'not slow and not e2e') with the core of the candidate, which tests.yml does not use until the pin moves. It holds the files of wrapper.unit.udp, wrapper.unit.page and wrapper.unit.compositing too: the overlap is on purpose. Deselected because they depend on the environment and a skip is red: test_the_declared_version_is_not_already_published (asks the package index, a network call); test_the_check_can_tell_a_taken_version_from_a_free_one (asks the package index, a network call); test_the_check_can_tell_a_shipped_change_from_one_that_does_not_ship (asks the package index, a network call); test_the_diff_half_sees_a_release_that_did_move_the_package (asks the package index, a network call); test_the_injected_sources_have_balanced_quotes (needs a driver bundle tree (INVPW_DRIVER_TREE)); test_the_workbench_inventory_and_the_package_cannot_DRIFT (needs the workbench next to the checkout); test_real_stock_firefox_via_binary_path_is_refused (needs a bundled stock Firefox); test_the_spawn_keeps_the_two_hardwired_descriptors (the POSIX leg does not execute on Windows). min_tests counted with the judge's selector."}
]
+76
View File
@@ -0,0 +1,76 @@
"""The end of a session, for the e2e that count what a browser asks or connects to: the next test starts when this one's browser is gone.
⛔ THE KNOWN-BAD INPUT: `close()` returns when the BROWSER has exited (invisible-core's reaper), while the sender of the shutdown pings
(`firefox --backgroundtask pingsender`) lives on for about half a second and asks the resolver of the machine for the telemetry host. The
sessions without a proxy of the launch (`context_only`) may do that, and the test after them is a parametrized neighbour with a resolver trap
(or a watcher of direct connections) of its own, started within milliseconds: it counted the question of the session before as its own, and five
runs of `test_nothing_leaves_but_the_proxy_e2e.py` were red for a browser that was not theirs (measured by the kernel: the questions arrived 50-66
ms after the next test began).
So a session of those tests ENDS before the test lets go of its place: `EndingPlaywright` is an `InvisiblePlaywright` whose `__exit__` waits for the
launch's reaper (`wait_reaped(token)`: the sender is finished or ended, the launch released, the session's directories gone) and for the session's
processes to be gone (`wait_until_gone`). The 30 s are a safety net, never a measure: the wait ends when the reaper does. A reaper that does not
finish within them FAILS the test, with the processes that are left: going on in silence would put the next test back in the same room.
Every session of the e2e files that run a resolver trap or a watcher is made with this class (`tests/test_every_trapped_session_ends_before_the_next_test.py`
reads those files and fails on one that is not).
"""
from __future__ import annotations
import pytest
from invisible_core.process import SessionToken, find_processes, wait_until_gone
from invisible_playwright import InvisiblePlaywright
from invisible_playwright._juggler._reaped import wait_reaped
#: How long a session may take to end after its close, in seconds. A safety net: the wait ends when the reaper does.
SAFETY_NET_S = 30.0
def ensure_ended(token, *, timeout: float = SAFETY_NET_S) -> None:
"""Waits until what follows the close of the session ``token`` is over: the reaper has finished and nothing carries the token.
Fails the test, with the reason, when it is not over within ``timeout`` seconds. An empty token (a session that never launched) is nothing to wait for."""
token = SessionToken(getattr(token, "value", token))
if not token:
return
if not wait_reaped(token, timeout=timeout):
pytest.fail(
"the session %r did not end within %s s of its close: the reaper of its launch has not finished (processes of the session still "
"alive: %s). The next test would start with this one's processes alive and count what they ask." % (
token, timeout, _left(token)), pytrace=False)
if not wait_until_gone(token, timeout=timeout):
pytest.fail(
"the reaper of the session %r finished and processes of the session are still alive after %s s: %s" % (
token, timeout, _left(token)), pytrace=False)
def _left(token) -> list:
"""(pid, name) of what still carries the token, for a message."""
left = []
for proc in find_processes(token):
try:
left.append((proc.pid, proc.name()))
except Exception:
left.append((getattr(proc, "pid", None), "?"))
return left
class EndingPlaywright(InvisiblePlaywright):
"""An `InvisiblePlaywright` whose close returns when the session has ENDED, not when its browser has exited."""
#: The token of the launch, kept at its start: the teardown empties the session's own.
_end_token = SessionToken()
def __enter__(self):
try:
return super().__enter__()
finally:
self._end_token = SessionToken(self._session_token.value)
def __exit__(self, *exc):
try:
return super().__exit__(*exc)
finally:
token, self._end_token = self._end_token, SessionToken()
ensure_ended(token)
@@ -0,0 +1,176 @@
"""A session of the e2e that count what a browser asks ends before the test lets go of its place: the sender of the shutdown pings is gone.
⛔ THE KNOWN-BAD INPUT (measured with the kernel's own tools): `close()` returns when the browser has exited, and the sender of the
shutdown pings (`firefox --backgroundtask pingsender`) of the session lives on for about half a second, asking the resolver of the machine
for the telemetry host. The test after it (the next parameter of `test_nothing_leaves_but_the_proxy_e2e.py`, with a resolver trap of its own)
counted those questions as its own: 50-66 ms after it began. So the fixture that closes the session waits for the launch's reaper
(`EndingPlaywright`, `tests/_session_end.py`).
No browser here: a stand-in process of the session (registered under the session's token as the core registers the engine's tree) is alive
when the close returns, as the sender is, and the reaper of the launch ends it once its grace is over. Before: the close returned at once
and the process was alive. Now: the session's exit returns when the reaper has ended it, and fails, saying so, when the reaper does not
finish in time.
"""
from __future__ import annotations
import json
import os
import re
import subprocess
import sys
import threading
from pathlib import Path
from types import SimpleNamespace
import pytest
from invisible_core.process import EngineTree, SessionToken, guard_for, reap_session, register_tree
from invisible_playwright import InvisiblePlaywright
from invisible_playwright._juggler import _reaped
import _session_end
from _session_end import EndingPlaywright, ensure_ended
pytestmark = pytest.mark.unit
ROOT = Path(__file__).resolve().parent.parent
#: The suites whose tests run a resolver trap or a watcher of direct connections: every session they make ends before the next test starts.
TRAPPED_SUITES = ("wrapper.e2e.doh", "wrapper.e2e.context.egress", "wrapper.e2e.context.sink", "wrapper.e2e.realness")
class _Reaper(threading.Thread):
"""The reaper of a launch as the core's: once its grace is over it ends the session's tree, runs the steps handed to `then`, and has finished."""
def __init__(self, token, grace_over):
super().__init__(daemon=True)
self._token = token
self._grace_over = grace_over
self._lock = threading.Lock()
self._steps = []
self.finished = False
def then(self, step):
with self._lock:
if not self.finished:
self._steps.append(step)
return
step()
def run(self):
self._grace_over.wait(60)
reap_session(self._token, timeout=5.0)
with self._lock:
steps, self._steps = self._steps, []
for step in steps:
step()
with self._lock:
self.finished = True
class _TheSessionBefore:
"""A session of the test before, without a browser: its `__enter__` starts the stand-in of the sender (registered under the session's token as
the core registers the engine's tree) and its `__exit__` does what the close of the launcher does when the browser has exited: it hands the
launch to a reaper, which ends the stand-in after its grace, and returns at once."""
def __init__(self, monkeypatch, grace_over):
self.grace_over = grace_over
self.process = None
self.reaper = None
self.token = None
monkeypatch.setattr(InvisiblePlaywright, "__enter__", lambda session: self._enter(session))
monkeypatch.setattr(InvisiblePlaywright, "__exit__", lambda session, *exc: self._exit(session, *exc))
def _enter(self, session):
session._session_token = SessionToken.mint()
self.token = SessionToken(session._session_token.value)
self.process = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(60)"])
register_tree(self.token, EngineTree(self.process.pid))
return object()
def _exit(self, session, *exc):
conn = SimpleNamespace(close=lambda: None, reaper=_Reaper(self.token, self.grace_over))
self.reaper = conn.reaper
_reaped.SessionRemoval(lambda: None, self.token.value).close(conn)
conn.reaper.start()
_reaped.final_reap(guard_for(), self.token)
session._session_token = SessionToken()
def clean_up(self):
self.grace_over.set()
if self.reaper is not None:
self.reaper.join(10)
if self.process is not None:
self.process.kill()
self.process.wait(10)
if self.token is not None:
_reaped._reapers.pop(self.token.value, None)
@pytest.fixture
def the_session_before(monkeypatch):
session = _TheSessionBefore(monkeypatch, threading.Event())
try:
yield session
finally:
session.clean_up()
def _a_session(cls):
return cls(seed=7, binary_path=os.devnull, headless=True)
def test_without_the_wait_the_process_of_the_session_before_is_alive_when_the_close_returns(the_session_before):
"""The old fixtures: the close returned, and the process of the session before was still there, to ask its questions of the next test."""
with _a_session(InvisiblePlaywright):
pass
assert the_session_before.process.poll() is None, "the stand-in left before the close returned: it does not reproduce the sender"
assert not the_session_before.reaper.finished
def test_the_exit_of_a_session_returns_when_the_reaper_has_ended_the_process_of_the_session_before(the_session_before):
"""The new fixtures: the exit waits for the reaper (its grace is over 0.3 s after the close), and nothing of the session is alive when it returns."""
timer = threading.Timer(0.3, the_session_before.grace_over.set)
timer.daemon = True
timer.start()
try:
with _a_session(EndingPlaywright):
pass
finally:
timer.cancel()
assert the_session_before.reaper.finished, "the exit returned before the reaper of the launch had finished"
assert the_session_before.process.poll() is not None, "the exit returned with the process of the session before alive"
def test_a_reaper_that_does_not_finish_fails_the_session_with_the_reason(the_session_before, monkeypatch):
"""Not in silence: the next test would start with the process of this one alive."""
monkeypatch.setattr(_session_end, "ensure_ended", lambda token: ensure_ended(token, timeout=0.3))
with pytest.raises(pytest.fail.Exception) as failure:
with _a_session(EndingPlaywright):
pass
message = str(failure.value)
assert "did not end within 0.3 s of its close" in message and "the reaper of its launch has not finished" in message, message
assert the_session_before.process.poll() is None
def test_a_token_that_never_launched_is_nothing_to_wait_for():
ensure_ended(SessionToken(), timeout=0.1)
ensure_ended("", timeout=0.1)
def _tests_of(suite):
suites = json.loads((ROOT / "ci" / "required-suites.json").read_text(encoding="utf-8"))
entry = next(s for s in suites if s["id"] == suite)
return sorted({ROOT / t.split("::")[0] for t in entry["tests"]})
@pytest.mark.parametrize("suite", TRAPPED_SUITES)
def test_every_session_of_the_trapped_suites_is_an_ending_one(suite):
"""A session made with the plain class would let the next test start while its sender is alive: the files of these suites make theirs with `EndingPlaywright`."""
plain = []
for path in _tests_of(suite):
assert path.is_file(), path
for number, line in enumerate(path.read_text(encoding="utf-8").splitlines(), 1):
if re.search(r"(?<![A-Za-z_])InvisiblePlaywright\(", line) and not line.lstrip().startswith("#"):
plain.append("%s:%d" % (path.name, number))
assert plain == [], "a session that does not wait for its end: %s" % plain
+3 -2
View File
@@ -76,6 +76,7 @@ from pathlib import Path
import pytest
from invisible_core import SessionGeo, decide_session_locale
from _session_end import EndingPlaywright
from invisible_playwright import InvisiblePlaywright
import _doh_servers as ds
@@ -120,7 +121,7 @@ def _hermetic_session(monkeypatch):
# --------------------------------------------------------------------------------------------------------- helpers
def _launch(binary, proxy, **kwargs):
# headless=True: a headed browser on a virtual display the wrapper starts itself, as in every other e2e (a runner has no screen).
return InvisiblePlaywright(seed=42, binary_path=binary, proxy=proxy, extra_prefs=dict(PREFS), **{"headless": True, **kwargs})
return EndingPlaywright(seed=42, binary_path=binary, proxy=proxy, extra_prefs=dict(PREFS), **{"headless": True, **kwargs})
def _page_in(browser, proxy=None):
@@ -405,7 +406,7 @@ def test_a_session_without_a_proxy_resolves_with_the_system_resolver(firefox_bin
if why:
pytest.fail(why)
name = "page-d.test" if trapped else "localhost"
session = InvisiblePlaywright(seed=42, binary_path=firefox_binary, proxy=None, headless=True)
session = EndingPlaywright(seed=42, binary_path=firefox_binary, proxy=None, headless=True)
session._timezone, session._locale = GEO.timezone, GEO.locale
prefs = session._build_prefs()
assert prefs.get("network.trr.mode") != 3, "a session without a proxy turned TRR on: %s" % prefs.get("network.trr.mode")
+3 -3
View File
@@ -68,10 +68,10 @@ SHORT_NEGATIVE_CACHE = {"network.dnsNegativeCacheExpiration": 1, "network.dnsNeg
def _launch_with_a_short_negative_cache(binary):
"""A session without a launch proxy (the proxy is the context's) whose DNS negative cache is 1 s."""
from invisible_playwright import InvisiblePlaywright
from _session_end import EndingPlaywright
from test_doh_through_the_proxy_e2e import PREFS
return InvisiblePlaywright(seed=42, binary_path=binary, proxy=None, extra_prefs={**PREFS, **SHORT_NEGATIVE_CACHE},
headless=True)
return EndingPlaywright(seed=42, binary_path=binary, proxy=None, extra_prefs={**PREFS, **SHORT_NEGATIVE_CACHE},
headless=True)
def _navigate(context, url, timeout_ms):
@@ -85,10 +85,10 @@ def tcp_only_proxy(doh, gateway, request):
def _launch(binary, proxy):
"""Like the DoH e2e's `_launch`, with the baseline's mDNS host candidates declared as the realness test does."""
from invisible_playwright import InvisiblePlaywright
from _session_end import EndingPlaywright
return InvisiblePlaywright(seed=42, binary_path=binary, proxy=proxy, headless=True,
extra_prefs={**PREFS, "media.peerconnection.ice.obfuscate_host_addresses": True})
return EndingPlaywright(seed=42, binary_path=binary, proxy=proxy, headless=True,
extra_prefs={**PREFS, "media.peerconnection.ice.obfuscate_host_addresses": True})
# ============================================================================================================ tests
@@ -65,7 +65,7 @@ from typing import Callable, Dict, Optional
import pytest
from invisible_playwright import InvisiblePlaywright
from _session_end import EndingPlaywright
# The fixtures and the helpers of the DoH e2e (imported, not copied): the hermetic session (autouse) and the page in a context. `gateway`, `pages`,
# `trap` and `watcher` are in conftest.py.
@@ -357,8 +357,8 @@ def engine_log(tmp_path, monkeypatch):
def _launch(binary, proxy=None):
"""The session of the lab: NO proxy unless given (the default context is the machine's own network), the DoH provider of the FakeDoh."""
return InvisiblePlaywright(seed=42, binary_path=binary, proxy=proxy, headless=True,
extra_prefs={**PREFS, **LAB_PREFS})
return EndingPlaywright(seed=42, binary_path=binary, proxy=proxy, headless=True,
extra_prefs={**PREFS, **LAB_PREFS})
def _the_proxy_of(case: Case, doh, gateway):
@@ -633,8 +633,8 @@ def ocsp_responder(lab):
def _launch_trusting(binary, profile):
"""A persistent session on ``profile`` (the lab CA is in its NSS database), with NO proxy: its default context is the machine's own network
and ``context.browser.new_context(proxy=...)`` makes the contexts that have one. No ``ignore_https_errors`` anywhere."""
return InvisiblePlaywright(seed=42, binary_path=binary, headless=True, profile_dir=profile,
extra_prefs={**PREFS, **LAB_PREFS, **OCSP_PREFS})
return EndingPlaywright(seed=42, binary_path=binary, headless=True, profile_dir=profile,
extra_prefs={**PREFS, **LAB_PREFS, **OCSP_PREFS})
def _trusting_profile(binary, tmp_path, ca: LabCa):
@@ -32,7 +32,7 @@ from pathlib import Path
import pytest
from invisible_playwright import InvisiblePlaywright
from _session_end import EndingPlaywright
import _realness_support as rs
import _trap_policy
@@ -81,8 +81,8 @@ def _truth_of(exit_ip):
def _launch(binary, gateway, **extra):
return InvisiblePlaywright(seed=42, headless=True, binary_path=binary, proxy=gateway.proxy,
udp_stun_servers=measure_servers(gateway), extra_prefs=dict(PREFS), **extra)
return EndingPlaywright(seed=42, headless=True, binary_path=binary, proxy=gateway.proxy,
udp_stun_servers=measure_servers(gateway), extra_prefs=dict(PREFS), **extra)
@pytest.fixture(scope="module", params=list(rs.EXITS), ids=list(rs.EXITS))