Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
90bdf625d0 | ||
|
|
2c5cd5ea79 | ||
|
|
877027f9f4 | ||
|
|
0e48424da8 | ||
|
|
43e1b355a3 | ||
|
|
ebfd0fa573 | ||
|
|
b699439355 | ||
|
|
7031c911c7 | ||
|
|
464e0b132b |
No files matched your search
@@ -0,0 +1,34 @@
|
||||
# A one-job question for the e2e arrangement: can a GitHub Windows runner's screen be made larger than the browser window the e2e open
|
||||
# (1936x1048 for a 1920x1080 identity), so that the OS cursor can be parked outside it? The runner's screen is 1024x768 by default.
|
||||
# It runs on a push to its own branch only and is green whatever it finds; the log is the answer.
|
||||
name: runner resolution hunt
|
||||
on:
|
||||
push:
|
||||
branches: [hunt/runner-resolution]
|
||||
permissions:
|
||||
contents: read
|
||||
concurrency:
|
||||
group: runner-resolution-hunt-${{ github.run_id }}
|
||||
jobs:
|
||||
resolution:
|
||||
name: resolution (${{ matrix.image }})
|
||||
runs-on: ${{ matrix.image }}
|
||||
timeout-minutes: 10
|
||||
strategy:
|
||||
fail-fast: false
|
||||
max-parallel: 2
|
||||
matrix:
|
||||
image: [windows-2022, windows-latest]
|
||||
steps:
|
||||
- name: Before, the modes, and each requested resolution read back
|
||||
shell: pwsh
|
||||
run: |
|
||||
Add-Type -AssemblyName System.Windows.Forms
|
||||
function Show($label) { $b = [System.Windows.Forms.SystemInformation]::VirtualScreen; $p = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds; "${label}: virtual $($b.Width)x$($b.Height) at $($b.X),$($b.Y); primary $($p.Width)x$($p.Height)" }
|
||||
Show "before"
|
||||
Get-Command Set-DisplayResolution -ErrorAction SilentlyContinue | Format-List Name, Source, Version
|
||||
Get-CimInstance Win32_VideoController | Format-List Name, CurrentHorizontalResolution, CurrentVerticalResolution, VideoModeDescription
|
||||
foreach ($r in @(@(2560,1440), @(1920,1080), @(2560,1600), @(3840,2160))) {
|
||||
try { Set-DisplayResolution -Width $r[0] -Height $r[1] -Force -ErrorAction Stop; Start-Sleep -Seconds 2; Show "after $($r[0])x$($r[1])" }
|
||||
catch { "set $($r[0])x$($r[1]) failed: $($_.Exception.Message)" }
|
||||
}
|
||||
@@ -14,8 +14,8 @@
|
||||
{"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.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.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": 3719, "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_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_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_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_sends_its_scale_to_the_engine.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_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_oracle.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_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_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_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_held_request_of_the_journey_starts_after_the_load.py", "tests/test_every_order_of_the_events_of_a_popup_gives_one_page_event.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_every_refusal_is_declared.py", "tests/test_every_route_command_is_answered_may_fail.py", "tests/test_every_suite_runs_on_linux_and_windows.py", "tests/test_every_wire_method_is_served_or_refused.py", "tests/test_expose_binding_refusal.py", "tests/test_fakeweb_p4_report.py", "tests/test_fakeweb_stock_unsettled.py", "tests/test_fission_identity_parity_e2e.py", "tests/test_fixtures_name_why_the_package_is_missing.py", "tests/test_fork.py", "tests/test_frame_dispatch.py", "tests/test_geoip_used.py", "tests/test_glean_ready.py", "tests/test_goto_follows_the_base_url.py", "tests/test_hook_wiring.py", "tests/test_imports.py", "tests/test_intLine truncated
|
||||
{"id": "wrapper.unit.all.windows", "giro": "G1", "os": ["windows"], "min_tests": 3720, "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_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_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_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_sends_its_scale_to_the_engine.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_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_oracle.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_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_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_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_held_request_of_the_journey_starts_after_the_load.py", "tests/test_every_order_of_the_events_of_a_popup_gives_one_page_event.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_every_refusal_is_declared.py", "tests/test_every_route_command_is_answered_may_fail.py", "tests/test_every_suite_runs_on_linux_and_windows.py", "tests/test_every_wire_method_is_served_or_refused.py", "tests/test_expose_binding_refusal.py", "tests/test_fakeweb_p4_report.py", "tests/test_fakeweb_stock_unsettled.py", "tests/test_fission_identity_parity_e2e.py", "tests/test_fixtures_name_why_the_package_is_missing.py", "tests/test_fork.py", "tests/test_frame_dispatch.py", "tests/test_geoip_used.py", "tests/test_glean_ready.py", "tests/test_goto_follows_the_base_url.py", "tests/test_hook_wiring.py", "tests/test_imports.py", "tests/testLine truncated
|
||||
{"id": "wrapper.unit.all.linux", "giro": "G1", "os": ["linux"], "min_tests": 3757, "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_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_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_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_sends_its_scale_to_the_engine.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_oracle.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_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_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_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_held_request_of_the_journey_starts_after_the_load.py", "tests/test_every_order_of_the_events_of_a_popup_gives_one_page_event.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_every_refusal_is_declared.py", "tests/test_every_route_command_is_answered_may_fail.py", "tests/test_every_suite_runs_on_linux_and_windows.py", "tests/test_every_wire_method_is_served_or_refused.py", "tests/test_expose_binding_refusal.py", "tests/test_fakeweb_p4_report.py", "tests/test_fakeweb_stock_unsettled.py", "tests/test_fission_identity_parity_e2e.py", "tests/test_fixtures_name_why_the_package_is_missing.py", "tests/test_fork.py", "tests/test_frame_dispatch.py", "tests/test_geoip_used.py", "tests/test_glean_ready.py", "tests/test_goto_follows_the_base_url.py", "tesLine truncated
|
||||
{"id": "wrapper.unit.all.windows", "giro": "G1", "os": ["windows"], "min_tests": 3761, "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_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_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_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_sends_its_scale_to_the_engine.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_oracle.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_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_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_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_held_request_of_the_journey_starts_after_the_load.py", "tests/test_every_order_of_the_events_of_a_popup_gives_one_page_event.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_every_refusal_is_declared.py", "tests/test_every_route_command_is_answered_may_fail.py", "tests/test_every_suite_runs_on_linux_and_windows.py", "tests/test_every_wire_method_is_served_or_refused.py", "tests/test_expose_binding_refusal.py", "tests/test_fakeweb_p4_report.py", "tests/test_fakeweb_stock_unsettled.py", "tests/test_fission_identity_parity_e2e.py", "tests/test_fixtures_name_why_the_package_is_missing.py", "tests/test_fork.py", "tests/test_frame_dispatch.py", "tests/test_geoip_used.py", "tests/test_glean_ready.py", "tests/test_goto_follows_the_base_url.py", Line 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": 415, "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_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_through_the_proxy_of_that_context", "tests/test_webrtc_realness.py::test_Line truncated
|
||||
{"id": "wrapper.e2e.suite.linux.2", "giro": "G2", "os": ["linux"], "min_tests": 414, "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_request_says_what_it_is_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_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 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 wrapLine truncated
|
||||
|
||||
@@ -0,0 +1,228 @@
|
||||
"""A test that is not e2e never leaves the machine: every connection, datagram and name lookup it makes goes to this host or is refused.
|
||||
|
||||
The markers say it already (pyproject.toml: ``unit`` is "no network", ``integration`` is "no network"), and nothing enforced it:
|
||||
``tests/unit/test_config_public.py`` composed the default prefs with no declared exit, the core asked api.ipify.org and icanhazip.com
|
||||
where it leaves from, and the test failed on a machine whose network refused them. A test cannot fail for the reasons of a third party.
|
||||
|
||||
:func:`install` patches the four doors of the standard library that every client in the process goes through (``socket.socket.connect``,
|
||||
``connect_ex`` and ``sendto``, and ``socket.getaddrinfo``): a destination on this host passes, anything else is refused with
|
||||
:class:`LeftTheMachine` (a ``ConnectionRefusedError``, so the code under test sees what an offline machine shows it) AND recorded, so the test
|
||||
fails at its teardown even when the code under test swallowed the refusal. The record names the test, the door and the destination.
|
||||
|
||||
asyncio has doors of its own, and on Windows they skip the four above: the Proactor loop connects with ``ConnectEx`` and sends datagrams with
|
||||
``WSASendTo`` (``_overlapped``), never through ``socket.socket``. So the guard also patches the loop methods every asyncio client goes through, for
|
||||
both loop kinds: ``BaseEventLoop.create_connection`` and ``create_datagram_endpoint`` (``remote_addr``), ``sock_connect`` and ``sock_sendto`` of the
|
||||
selector and of the Proactor loop, and the Proactor datagram transport's ``sendto``.
|
||||
|
||||
What it cannot see, on any system: a socket made from ``_socket`` directly or used through ``_overlapped`` by hand (no library of this project
|
||||
does), native code in the same process, and a child process (a subprocess has its own interpreter: the e2e are where a browser runs).
|
||||
|
||||
On this host: a loopback address (127/8, ::1), the unspecified address (0.0.0.0, ::, which a connect reaches on this host), a name that is
|
||||
``localhost`` or ends in ``.localhost``, and an AF_UNIX path. The documentation ranges (192.0.2/24, 198.51.100/24, 203.0.113/24, 2001:db8::/32)
|
||||
pass too: they are never routed, and the lab gives one of them to an interface of this host (the exit of the lab, tests/_lab_egress.py).
|
||||
And the address this host sends from (its default route's, tests/_host_address.py): a relay of the tests that leaves from the address of the
|
||||
host is on this host, and a datagram to it never leaves the machine.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import ipaddress
|
||||
import socket
|
||||
import threading
|
||||
from typing import Any, List, Optional, Sequence, Tuple
|
||||
|
||||
_DOCUMENTATION = tuple(ipaddress.ip_network(n) for n in ("192.0.2.0/24", "198.51.100.0/24", "203.0.113.0/24", "2001:db8::/32"))
|
||||
|
||||
RULE = ("a test that is not e2e never leaves the machine (pyproject.toml markers: unit and integration are 'no network'): "
|
||||
"a test cannot fail for the reasons of a third party")
|
||||
FIX = ("declare the value the code would ask the network for (timezone=, locale=, proxy= with a local gateway), use a server of the tests "
|
||||
"on loopback (tests/_servers.py, the local_egress_echo fixture), or mark the test e2e if it is one")
|
||||
|
||||
|
||||
#: The ONE file whose job is to ask a third party, and the hosts it may ask. Nothing else is declared, and a new entry is a decision, not a fix.
|
||||
#: ``tests/test_version_is_not_taken.py`` is the version gate of a pull request: it asks the index whether the version the change proposes
|
||||
#: is already published, which only the index can answer. It is skipped unless ``IPW_CHECK_VERSION`` is set, which only the ``version`` job
|
||||
#: of tests.yml does. Its host is allowed for its name lookup and for the addresses that lookup answered, nothing else.
|
||||
DECLARED_THIRD_PARTIES = {
|
||||
"tests/test_version_is_not_taken.py": ("pypi.org",),
|
||||
}
|
||||
|
||||
|
||||
class LeftTheMachine(ConnectionRefusedError):
|
||||
"""A destination outside this host, refused by the guard of the tests."""
|
||||
|
||||
|
||||
def own_addresses() -> Tuple[str, ...]:
|
||||
"""The addresses this host sends from, IPv4 and IPv6 (the source its default route picks). A UDP connect sends no packet; a family with
|
||||
no route has none. Read BEFORE the doors are patched."""
|
||||
found = []
|
||||
for family, probe in ((socket.AF_INET, ("192.0.2.1", 9)), (socket.AF_INET6, ("2001:db8::1", 9))):
|
||||
try:
|
||||
with socket.socket(family, socket.SOCK_DGRAM) as s:
|
||||
s.connect(probe)
|
||||
found.append(s.getsockname()[0].split("%", 1)[0])
|
||||
except OSError:
|
||||
pass
|
||||
return tuple(found)
|
||||
|
||||
|
||||
def is_on_this_host(host: Any, own: Sequence[str] = ()) -> bool:
|
||||
"""Whether ``host`` (an address, a name, or None) is on this host, the way the guard decides it; ``own`` are the addresses of this host
|
||||
(:func:`own_addresses`)."""
|
||||
if host is None:
|
||||
return True
|
||||
if isinstance(host, bytes):
|
||||
host = host.decode("ascii", "replace")
|
||||
host = str(host).strip("[]").split("%", 1)[0]
|
||||
if host == "" or host.lower() == "localhost" or host.lower().endswith(".localhost"):
|
||||
return True
|
||||
try:
|
||||
address = ipaddress.ip_address(host)
|
||||
except ValueError:
|
||||
return False # a name: resolving it is already a question to the network
|
||||
if getattr(address, "ipv4_mapped", None) is not None:
|
||||
address = address.ipv4_mapped
|
||||
return (address.is_loopback or address.is_unspecified or any(address in net for net in _DOCUMENTATION)
|
||||
or any(address == ipaddress.ip_address(mine) for mine in own))
|
||||
|
||||
|
||||
def _destination(address: Any, own: Sequence[str] = ()) -> Optional[str]:
|
||||
"""``host:port`` of a socket address that leaves the machine, or None when it does not (AF_UNIX paths and this host)."""
|
||||
if not isinstance(address, tuple) or not address:
|
||||
return None # an AF_UNIX path or an abstract name: this host
|
||||
host = address[0]
|
||||
if is_on_this_host(host, own):
|
||||
return None
|
||||
return "%s:%s" % (host, address[1] if len(address) > 1 else "?")
|
||||
|
||||
|
||||
class Guard:
|
||||
"""The record of one test: what it tried outside the machine. Thread-safe: a client thread of the test is recorded too."""
|
||||
|
||||
def __init__(self, test: str) -> None:
|
||||
self.test = test
|
||||
self.attempts: List[str] = []
|
||||
self._lock = threading.Lock()
|
||||
|
||||
def refuse(self, door: str, destination: str) -> LeftTheMachine:
|
||||
sentence = "%s %s" % (door, destination)
|
||||
with self._lock:
|
||||
if sentence not in self.attempts:
|
||||
self.attempts.append(sentence)
|
||||
return LeftTheMachine("WHERE: %s. WHAT: %s, outside this host, refused. FIX: %s. RULE: %s." % (self.test, sentence, FIX, RULE))
|
||||
|
||||
def verdict(self) -> Optional[str]:
|
||||
"""The failure of the test, or None when it stayed on this host."""
|
||||
if not self.attempts:
|
||||
return None
|
||||
return ("WHERE: %s. WHAT: the test tried to leave the machine: %s (each was refused). FIX: %s. RULE: %s."
|
||||
% (self.test, "; ".join(self.attempts), FIX, RULE))
|
||||
|
||||
|
||||
def install(monkeypatch: Any, test: str) -> Guard:
|
||||
"""Patch the four doors for the duration of ``monkeypatch``; return the record of ``test``."""
|
||||
guard = Guard(test)
|
||||
declared_hosts = DECLARED_THIRD_PARTIES.get(test.split("::", 1)[0].replace("\\", "/"), ())
|
||||
answered = set() # the addresses a lookup of a declared host answered: a connection to them is that host
|
||||
own = tuple(own_addresses())
|
||||
|
||||
def mine():
|
||||
return own + tuple(answered)
|
||||
connect, connect_ex, sendto, getaddrinfo = (socket.socket.connect, socket.socket.connect_ex, socket.socket.sendto,
|
||||
socket.getaddrinfo)
|
||||
|
||||
def guarded_connect(self, address):
|
||||
where = _destination(address, mine())
|
||||
if where is not None:
|
||||
raise guard.refuse("connect to", where)
|
||||
return connect(self, address)
|
||||
|
||||
def guarded_connect_ex(self, address):
|
||||
where = _destination(address, mine())
|
||||
if where is not None:
|
||||
raise guard.refuse("connect to", where)
|
||||
return connect_ex(self, address)
|
||||
|
||||
def guarded_sendto(self, data, *rest):
|
||||
where = _destination(rest[-1] if rest else None, mine())
|
||||
if where is not None:
|
||||
raise guard.refuse("datagram to", where)
|
||||
return sendto(self, data, *rest)
|
||||
|
||||
def guarded_getaddrinfo(host, *args, **kwargs):
|
||||
if isinstance(host, str) and host.lower() in declared_hosts:
|
||||
found = getaddrinfo(host, *args, **kwargs)
|
||||
answered.update(info[4][0] for info in found)
|
||||
return found
|
||||
if not is_on_this_host(host, mine()):
|
||||
raise guard.refuse("name lookup of", str(host))
|
||||
return getaddrinfo(host, *args, **kwargs)
|
||||
|
||||
_install_asyncio(monkeypatch, guard, mine)
|
||||
monkeypatch.setattr(socket.socket, "connect", guarded_connect)
|
||||
monkeypatch.setattr(socket.socket, "connect_ex", guarded_connect_ex)
|
||||
monkeypatch.setattr(socket.socket, "sendto", guarded_sendto)
|
||||
monkeypatch.setattr(socket, "getaddrinfo", guarded_getaddrinfo)
|
||||
return guard
|
||||
|
||||
|
||||
def _install_asyncio(monkeypatch: Any, guard: Guard, mine: Any) -> None:
|
||||
"""The asyncio doors (module docstring), for the selector loop and, where it exists, the Proactor loop."""
|
||||
import asyncio.base_events as base_events
|
||||
import asyncio.selector_events as selector_events
|
||||
|
||||
loops = [selector_events.BaseSelectorEventLoop]
|
||||
datagram_transports = []
|
||||
try:
|
||||
import asyncio.proactor_events as proactor_events
|
||||
loops.append(proactor_events.BaseProactorEventLoop)
|
||||
datagram_transports.append(proactor_events._ProactorDatagramTransport)
|
||||
except ImportError: # pragma: no cover - the module exists on every system; its loop runs only on Windows
|
||||
pass
|
||||
|
||||
create_connection = base_events.BaseEventLoop.create_connection
|
||||
create_datagram_endpoint = base_events.BaseEventLoop.create_datagram_endpoint
|
||||
|
||||
async def guarded_create_connection(self, protocol_factory, host=None, port=None, *args, **kwargs):
|
||||
if host is not None and kwargs.get("sock") is None and not is_on_this_host(host, mine()):
|
||||
raise guard.refuse("asyncio connect to", "%s:%s" % (host, port))
|
||||
return await create_connection(self, protocol_factory, host, port, *args, **kwargs)
|
||||
|
||||
async def guarded_create_datagram_endpoint(self, protocol_factory, local_addr=None, remote_addr=None, **kwargs):
|
||||
where = _destination(remote_addr, mine())
|
||||
if where is not None:
|
||||
raise guard.refuse("asyncio datagram endpoint to", where)
|
||||
return await create_datagram_endpoint(self, protocol_factory, local_addr=local_addr, remote_addr=remote_addr, **kwargs)
|
||||
|
||||
monkeypatch.setattr(base_events.BaseEventLoop, "create_connection", guarded_create_connection)
|
||||
monkeypatch.setattr(base_events.BaseEventLoop, "create_datagram_endpoint", guarded_create_datagram_endpoint)
|
||||
|
||||
for loop in loops:
|
||||
sock_connect, sock_sendto = loop.sock_connect, loop.sock_sendto
|
||||
|
||||
def make(sock_connect=sock_connect, sock_sendto=sock_sendto):
|
||||
async def guarded_sock_connect(self, sock, address):
|
||||
where = _destination(address, mine())
|
||||
if where is not None:
|
||||
raise guard.refuse("asyncio connect to", where)
|
||||
return await sock_connect(self, sock, address)
|
||||
|
||||
async def guarded_sock_sendto(self, sock, data, address):
|
||||
where = _destination(address, mine())
|
||||
if where is not None:
|
||||
raise guard.refuse("asyncio datagram to", where)
|
||||
return await sock_sendto(self, sock, data, address)
|
||||
return guarded_sock_connect, guarded_sock_sendto
|
||||
|
||||
guarded_sock_connect, guarded_sock_sendto = make()
|
||||
monkeypatch.setattr(loop, "sock_connect", guarded_sock_connect)
|
||||
monkeypatch.setattr(loop, "sock_sendto", guarded_sock_sendto)
|
||||
|
||||
for transport in datagram_transports:
|
||||
def make_sendto(sendto=transport.sendto):
|
||||
def guarded_sendto(self, data, addr=None):
|
||||
where = _destination(addr, mine())
|
||||
if where is not None:
|
||||
raise guard.refuse("asyncio datagram to", where)
|
||||
return sendto(self, data, addr)
|
||||
return guarded_sendto
|
||||
monkeypatch.setattr(transport, "sendto", make_sendto())
|
||||
@@ -177,6 +177,22 @@ def _offline_session_geo(request, monkeypatch):
|
||||
monkeypatch.setattr(_session, "session_geo", lambda *_a, **_k: geo)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _a_test_that_is_not_e2e_never_leaves_the_machine(request, monkeypatch):
|
||||
"""Outside the e2e, every connection, datagram and name lookup goes to this host or is refused, and the test fails naming each
|
||||
destination it tried (tests/_no_network.py), even when the code under test swallowed the refusal."""
|
||||
if request.node.get_closest_marker("e2e") is not None:
|
||||
yield
|
||||
return
|
||||
import _no_network
|
||||
|
||||
guard = _no_network.install(monkeypatch, request.node.nodeid)
|
||||
yield
|
||||
failure = guard.verdict()
|
||||
if failure:
|
||||
pytest.fail(failure, pytrace=False)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _what_the_core_declares_for_a_proxy_is_recorded(monkeypatch):
|
||||
"""The core keeps no UDP verdict in memory, so a test that wants to know what the launch declared reads it where it is
|
||||
@@ -254,6 +270,36 @@ def _no_test_asks_the_world_where_it_leaves_from():
|
||||
pytest.fail("the question of the exit went toward the internet: " + "; ".join(asked), pytrace=False)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def lab_exit(monkeypatch, tmp_path):
|
||||
"""The exit of the lab and its GeoIP database, declared for one test that is not e2e (``tests/_lab_egress.py``, as the e2e have it).
|
||||
|
||||
With no proxy the core asks where this machine leaves from once per composition (``prepare_session_geo``: zone, language and position
|
||||
come from the exit, even when the zone is given), and a test that is not e2e never leaves the machine (``tests/_no_network.py``). A test
|
||||
that composes prefs or a session through the core takes this fixture."""
|
||||
import _lab_egress
|
||||
|
||||
return _lab_egress.install(monkeypatch, tmp_path / "lab-geoip")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def declared_engine(monkeypatch, tmp_path):
|
||||
"""An engine executable declared for one test that is not e2e, instead of the one the core resolves.
|
||||
|
||||
Without ``binary_path=`` the launch resolves the engine through ``ensure_binary`` (``_engine.resolve_executable``): with an engine in
|
||||
the cache of the machine it answers at once, and with none it asks GitHub's release index and downloads the archive. So a unit test that
|
||||
composes a launch passed on a machine that had run ``fetch`` and went to the internet on a fresh runner, and a test that is not e2e
|
||||
never leaves the machine (``tests/_no_network.py``). The file is never run: the tests that take this fixture stop at the environment,
|
||||
the arguments or a fake ``launch``. Returns its path."""
|
||||
from invisible_playwright import _engine
|
||||
|
||||
executable = tmp_path / "declared-engine" / ("firefox.exe" if sys.platform == "win32" else "firefox")
|
||||
executable.parent.mkdir(parents=True)
|
||||
executable.write_bytes(b"")
|
||||
monkeypatch.setattr(_engine, "ensure_binary", lambda *a, **k: executable)
|
||||
return executable
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def local_egress_echo(monkeypatch):
|
||||
"""The REAL discovery of the exit, for the test that must prove it, against an echo service of its own on loopback: the three services of the
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
{"file": "test_a_popup_of_a_link_reaches_the_client_e2e.py", "scope": "_router.route", "rule": "sleep", "nth": 1, "kind": "stimulus", "reason": "Slowness on purpose: this test server, relay or client answers late as the input of the test, and the product waits for it under a deadline; nothing here judges the machine."},
|
||||
{"file": "test_a_proxy_that_cannot_carry_udp_leaks_nothing_direct_e2e.py", "scope": "<module>._PROBE_JS", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "A timer of the test's own page is the stimulus (the thing appears later); the product waits for it with a deadline and the verdict does not read when it fired."},
|
||||
{"file": "test_a_turn_name_over_tcp_goes_through_the_proxy_of_the_context_e2e.py", "scope": "<module>.TURN_PORT", "rule": "port", "nth": 1, "kind": "virtual-port", "reason": "A port number that nothing binds: the gateway of the test answers for the name or address by itself, so no worker can collide on it."},
|
||||
{"file": "test_a_worker_comes_back_with_its_page_from_the_cache_e2e.py", "scope": "_go_back_and_record", "rule": "sleep", "nth": 1, "kind": "instrument", "reason": "Runs only after go_back has already raised: the pause dates a restore that lands after the wait, for the evidence of the red run; the error is raised unchanged and the pause decides nothing."},
|
||||
{"file": "test_caller_world_handles_e2e.py", "scope": "test_a_node_that_appears_later_ends_the_wait", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "A timer of the test's own page is the stimulus (the thing appears later); the product waits for it with a deadline and the verdict does not read when it fired."},
|
||||
{"file": "test_caller_world_handles_e2e.py", "scope": "test_a_wait_for_function_object_handle_reads_in_the_page_world", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "A timer of the test's own page is the stimulus (the thing appears later); the product waits for it with a deadline and the verdict does not read when it fired."},
|
||||
{"file": "test_declared_host_network_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."},
|
||||
|
||||
@@ -0,0 +1,234 @@
|
||||
"""The guard of tests/_no_network.py: a destination on this host passes, anything else is refused and recorded, and the record fails the test.
|
||||
|
||||
Each case installs its own guard on top of the one the conftest gives every test that is not e2e; the inner guard refuses first, so nothing
|
||||
reaches the outer one and nothing leaves the machine: a refused connect never sends a packet.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import socket
|
||||
import threading
|
||||
|
||||
import pytest
|
||||
|
||||
import _no_network
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
OUTSIDE = ("1.1.1.1", 443) # never contacted: the guard refuses before the system call
|
||||
|
||||
|
||||
@pytest.mark.parametrize("host", ["127.0.0.1", "127.8.9.10", "::1", "0.0.0.0", "::", "localhost", "LocalHost", "a.localhost", None, "",
|
||||
"198.51.100.9", "192.0.2.1", "203.0.113.7", "2001:db8::1", "::ffff:127.0.0.1", "[::1]"])
|
||||
def test_this_host_is_this_host(host):
|
||||
assert _no_network.is_on_this_host(host)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("host", ["1.1.1.1", "8.8.8.8", "10.0.0.1", "192.168.1.1", "2606:4700::1111", "api.ipify.org", "example.com",
|
||||
b"icanhazip.com", "::ffff:8.8.8.8", "fe80::1%lo"])
|
||||
def test_outside_is_outside(host):
|
||||
assert not _no_network.is_on_this_host(host)
|
||||
|
||||
|
||||
def test_a_connect_outside_is_refused_named_and_fails_the_test(monkeypatch):
|
||||
guard = _no_network.install(monkeypatch, "tests/test_x.py::test_y")
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
with pytest.raises(ConnectionRefusedError) as refused:
|
||||
s.connect(OUTSIDE)
|
||||
message = str(refused.value)
|
||||
for part in ("WHERE: tests/test_x.py::test_y", "WHAT: connect to 1.1.1.1:443", "FIX:", "RULE:"):
|
||||
assert part in message, message
|
||||
assert guard.verdict() is not None and "connect to 1.1.1.1:443" in guard.verdict()
|
||||
|
||||
|
||||
def test_a_refusal_the_code_swallowed_still_fails_the_test(monkeypatch):
|
||||
"""The code under test may catch the refusal and carry on (an offline fallback): the record is what fails the test."""
|
||||
guard = _no_network.install(monkeypatch, "t")
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
try:
|
||||
s.connect_ex(OUTSIDE)
|
||||
except OSError:
|
||||
pass
|
||||
assert guard.verdict() is not None
|
||||
|
||||
|
||||
def test_a_datagram_and_a_name_lookup_outside_are_refused(monkeypatch):
|
||||
guard = _no_network.install(monkeypatch, "t")
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
|
||||
with pytest.raises(ConnectionRefusedError):
|
||||
s.sendto(b"x", ("8.8.8.8", 53))
|
||||
with pytest.raises(ConnectionRefusedError):
|
||||
socket.getaddrinfo("api.ipify.org", 443)
|
||||
with pytest.raises(ConnectionRefusedError):
|
||||
socket.create_connection(("icanhazip.com", 443), timeout=1)
|
||||
assert guard.attempts == ["datagram to 8.8.8.8:53", "name lookup of api.ipify.org", "name lookup of icanhazip.com"]
|
||||
|
||||
|
||||
def test_a_client_thread_of_the_test_is_recorded(monkeypatch):
|
||||
guard = _no_network.install(monkeypatch, "t")
|
||||
|
||||
def client():
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
try:
|
||||
s.connect(OUTSIDE)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
worker = threading.Thread(target=client)
|
||||
worker.start()
|
||||
worker.join(10)
|
||||
assert guard.attempts == ["connect to 1.1.1.1:443"]
|
||||
|
||||
|
||||
def test_this_host_passes_and_leaves_no_record(monkeypatch):
|
||||
"""The control: a server on loopback is reached through the same doors, by address and by name, and the test stays green."""
|
||||
guard = _no_network.install(monkeypatch, "t")
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as server:
|
||||
server.bind(("127.0.0.1", 0))
|
||||
server.listen(1)
|
||||
port = server.getsockname()[1]
|
||||
with socket.create_connection(("localhost", port), timeout=5) as client:
|
||||
accepted, _ = server.accept()
|
||||
accepted.close()
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as other:
|
||||
assert other.connect_ex(("127.0.0.1", port)) == 0
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as receiver, socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sender:
|
||||
receiver.bind(("127.0.0.1", 0))
|
||||
sender.sendto(b"x", receiver.getsockname())
|
||||
assert guard.verdict() is None
|
||||
|
||||
|
||||
def test_the_address_this_host_sends_from_is_this_host(monkeypatch):
|
||||
"""A relay of the tests that leaves from the address of the host (tests/_host_address.py) is on this host: a datagram to it stays here."""
|
||||
own = _no_network.own_addresses()
|
||||
if not own:
|
||||
pytest.skip("this host has no default route, so no address of its own beside loopback")
|
||||
guard = _no_network.install(monkeypatch, "t")
|
||||
with socket.socket(socket.AF_INET if ":" not in own[0] else socket.AF_INET6, socket.SOCK_DGRAM) as receiver:
|
||||
receiver.bind((own[0], 0))
|
||||
with socket.socket(receiver.family, socket.SOCK_DGRAM) as sender:
|
||||
sender.sendto(b"x", receiver.getsockname()[:2])
|
||||
assert guard.verdict() is None
|
||||
assert all(_no_network.is_on_this_host(a, own) for a in own)
|
||||
|
||||
|
||||
# The asyncio doors, for every loop kind this system has: the selector loop everywhere, and on Windows the Proactor loop too (the default
|
||||
# there), which connects with ConnectEx and sends with WSASendTo, never through socket.socket: the unit tier of the round runs on both systems.
|
||||
import asyncio # noqa: E402
|
||||
import sys # noqa: E402
|
||||
|
||||
LOOPS = ["selector"] + (["proactor"] if sys.platform == "win32" else [])
|
||||
|
||||
|
||||
def _run(kind, coroutine_function):
|
||||
loop = asyncio.SelectorEventLoop() if kind == "selector" else asyncio.ProactorEventLoop()
|
||||
try:
|
||||
return loop.run_until_complete(coroutine_function())
|
||||
finally:
|
||||
loop.close()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("kind", LOOPS)
|
||||
def test_an_asyncio_connection_to_a_numeric_address_outside_is_refused(monkeypatch, kind):
|
||||
guard = _no_network.install(monkeypatch, "t")
|
||||
|
||||
async def go():
|
||||
with pytest.raises(ConnectionRefusedError):
|
||||
await asyncio.open_connection(*OUTSIDE)
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
s.setblocking(False)
|
||||
with pytest.raises(ConnectionRefusedError):
|
||||
await asyncio.get_running_loop().sock_connect(s, OUTSIDE)
|
||||
|
||||
_run(kind, go)
|
||||
assert guard.attempts == ["asyncio connect to 1.1.1.1:443"], guard.attempts
|
||||
|
||||
|
||||
@pytest.mark.parametrize("kind", LOOPS)
|
||||
def test_an_asyncio_datagram_outside_is_refused(monkeypatch, kind):
|
||||
guard = _no_network.install(monkeypatch, "t")
|
||||
|
||||
async def go():
|
||||
loop = asyncio.get_running_loop()
|
||||
with pytest.raises(ConnectionRefusedError):
|
||||
await loop.create_datagram_endpoint(asyncio.DatagramProtocol, remote_addr=("8.8.8.8", 53))
|
||||
transport, _ = await loop.create_datagram_endpoint(asyncio.DatagramProtocol, local_addr=("127.0.0.1", 0))
|
||||
try:
|
||||
# the selector transport hands a refused send to its protocol (error_received) instead of raising it: the record is what counts
|
||||
try:
|
||||
transport.sendto(b"x", ("8.8.4.4", 53))
|
||||
except ConnectionRefusedError:
|
||||
pass
|
||||
finally:
|
||||
transport.close()
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
|
||||
s.setblocking(False)
|
||||
with pytest.raises(ConnectionRefusedError):
|
||||
await loop.sock_sendto(s, b"x", ("8.8.8.8", 5353))
|
||||
|
||||
_run(kind, go)
|
||||
assert guard.attempts == ["asyncio datagram endpoint to 8.8.8.8:53", "asyncio datagram to 8.8.4.4:53", "asyncio datagram to 8.8.8.8:5353"] \
|
||||
or guard.attempts == ["asyncio datagram endpoint to 8.8.8.8:53", "datagram to 8.8.4.4:53", "asyncio datagram to 8.8.8.8:5353"], guard.attempts
|
||||
|
||||
|
||||
@pytest.mark.parametrize("kind", LOOPS)
|
||||
def test_asyncio_on_this_host_passes(monkeypatch, kind):
|
||||
"""The control: a server on loopback, reached through asyncio by address and a datagram to a loopback receiver, leave no record."""
|
||||
guard = _no_network.install(monkeypatch, "t")
|
||||
|
||||
async def go():
|
||||
loop = asyncio.get_running_loop()
|
||||
server = await asyncio.start_server(lambda r, w: w.close(), "127.0.0.1", 0)
|
||||
port = server.sockets[0].getsockname()[1]
|
||||
reader, writer = await asyncio.open_connection("127.0.0.1", port)
|
||||
writer.close()
|
||||
server.close()
|
||||
await server.wait_closed()
|
||||
receiver, _ = await loop.create_datagram_endpoint(asyncio.DatagramProtocol, local_addr=("127.0.0.1", 0))
|
||||
sender, _ = await loop.create_datagram_endpoint(asyncio.DatagramProtocol, remote_addr=receiver.get_extra_info("sockname"))
|
||||
sender.sendto(b"x")
|
||||
sender.close()
|
||||
receiver.close()
|
||||
|
||||
_run(kind, go)
|
||||
assert guard.verdict() is None
|
||||
|
||||
|
||||
# The one declared third party: the version gate asks the index. Faked below the guard, so nothing leaves the machine here either.
|
||||
INDEX_ADDRESS = "8.8.4.4" # stands for the index: faked, never contacted
|
||||
|
||||
|
||||
def _fake_index(monkeypatch):
|
||||
"""The system lookup answers the index's address for pypi.org, and the system connect records instead of connecting."""
|
||||
reached = []
|
||||
monkeypatch.setattr(socket, "getaddrinfo", lambda host, port, *a, **k: [(socket.AF_INET, socket.SOCK_STREAM, 6, "", (INDEX_ADDRESS, port))])
|
||||
monkeypatch.setattr(socket.socket, "connect", lambda self, address: reached.append(address))
|
||||
return reached
|
||||
|
||||
|
||||
def test_the_version_gate_may_ask_the_index_and_only_the_index(monkeypatch):
|
||||
reached = _fake_index(monkeypatch)
|
||||
guard = _no_network.install(monkeypatch, "tests/test_version_is_not_taken.py::test_the_declared_version_is_not_already_published")
|
||||
(family, kind, proto, _name, address), = socket.getaddrinfo("pypi.org", 443)
|
||||
with socket.socket(family, kind) as s:
|
||||
s.connect(address)
|
||||
assert [a for a in reached if a[1] == 443] == [(INDEX_ADDRESS, 443)] # (the guard's own probe of this host's address is recorded too)
|
||||
with pytest.raises(ConnectionRefusedError):
|
||||
socket.getaddrinfo("files.example.net", 443)
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s, pytest.raises(ConnectionRefusedError):
|
||||
s.connect(OUTSIDE)
|
||||
assert guard.attempts == ["name lookup of files.example.net", "connect to 1.1.1.1:443"]
|
||||
|
||||
|
||||
def test_no_other_file_may_ask_the_index(monkeypatch):
|
||||
reached = _fake_index(monkeypatch)
|
||||
guard = _no_network.install(monkeypatch, "tests/test_x.py::test_y")
|
||||
with pytest.raises(ConnectionRefusedError):
|
||||
socket.getaddrinfo("pypi.org", 443)
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s, pytest.raises(ConnectionRefusedError):
|
||||
s.connect((INDEX_ADDRESS, 443))
|
||||
assert [a for a in reached if a[1] == 443] == [] and guard.attempts == ["name lookup of pypi.org", "connect to %s:443" % INDEX_ADDRESS]
|
||||
|
||||
|
||||
def test_the_declared_third_parties_are_the_version_gate_alone():
|
||||
"""A new entry is a decision: this test changes with it, in the same diff, where a reviewer sees it."""
|
||||
assert _no_network.DECLARED_THIRD_PARTIES == {"tests/test_version_is_not_taken.py": ("pypi.org",)}
|
||||
@@ -29,6 +29,7 @@ from http.server import BaseHTTPRequestHandler
|
||||
import pytest
|
||||
|
||||
from _bfcache_evidence import decide_outcome, read_after_go_back, wait_cacheable
|
||||
from _evidence_on_failure import FailureEvidence
|
||||
from _servers import LocalServer
|
||||
|
||||
STRATEGY_1 = {
|
||||
@@ -160,13 +161,30 @@ def _ask(page, where):
|
||||
return target.evaluate("window.__ask()")
|
||||
|
||||
|
||||
#: The engine's own log of the session history and the back-forward cache, kept with the evidence of a red run (one file per process): whether
|
||||
#: the restore happened, in which process, and what the parent did with the history entry. Run 45691494388 (job 139520127265) saw go_back
|
||||
#: end with "no new navigation on frame mainframe-11 in 30s" for top/other-site/goto and kept nothing to say whether the engine restored the
|
||||
#: page. A diagnostic no page reads.
|
||||
BFCACHE_LOG = "timestamp,SHIPBFCache:5,nsSHistory:5,SessionHistory:4,BCWebProgress:4,DocumentChannel:4,BrowsingContext:4"
|
||||
|
||||
|
||||
@pytest.mark.e2e
|
||||
@pytest.mark.parametrize("how", ["goto", "location"])
|
||||
@pytest.mark.parametrize("away", ["same-site", "other-site"])
|
||||
@pytest.mark.parametrize("where", ["top", "oop-frame"])
|
||||
def test_a_worker_leaves_with_its_page_for_the_cache_and_comes_back_the_same(firefox_binary, sites, events, where,
|
||||
away, how, engine_at_least):
|
||||
"""When it fails it saves, under ``invpw-evidence/worker-back-from-the-cache-<where>-<away>-<how>/``, the Juggler wire, the engine trace,
|
||||
the engine log BFCACHE_LOG and ``after-go-back.jsonl`` (what the page said when go_back raised, and 2 s later)."""
|
||||
engine_at_least("firefox-62")
|
||||
reads = _Reads()
|
||||
with FailureEvidence("worker-back-from-the-cache-%s-%s-%s" % (where, away, how)) as evidence:
|
||||
evidence.note_records("after-go-back", reads)
|
||||
evidence.arm(moz_log=BFCACHE_LOG)
|
||||
_the_case(firefox_binary, sites, events, where, away, how, reads)
|
||||
|
||||
|
||||
def _the_case(firefox_binary, sites, events, where, away, how, reads):
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
with InvisiblePlaywright(seed=42, binary_path=firefox_binary, humanize=False,
|
||||
@@ -206,7 +224,7 @@ def test_a_worker_leaves_with_its_page_for_the_cache_and_comes_back_the_same(fir
|
||||
|
||||
# 3. back from the cache: the same worker, told once, after the restored document's contexts are cleared
|
||||
back = len(events)
|
||||
page.go_back(wait_until="load")
|
||||
_go_back_and_record(page, reads)
|
||||
# What it knows is written down BEFORE anything is asserted. A goto is started by the PARENT and Firefox may refuse the cache for it,
|
||||
# to the same site or to another (measured: the navigation's own channel is still in the old document's loadgroup when the parent
|
||||
# checks: SHIPBFCache log, CanonicalBrowsingContext::AllowedInBFCache); then the document is built again and the contract is the one
|
||||
@@ -276,3 +294,34 @@ def _assert_a_new_page_with_a_new_worker(page, events, where, old, back):
|
||||
elif m == "Page.workerDestroyed":
|
||||
live.pop(p["workerId"], None)
|
||||
assert list(live) == [new[0]], "live workers after the page was built again: %r" % list(live.values())
|
||||
|
||||
|
||||
class _Reads:
|
||||
"""What the page says right after a go_back that raised, and once more later (``FailureEvidence.note_records`` shape)."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.lock = threading.Lock()
|
||||
self.records = []
|
||||
|
||||
def read(self, page, when):
|
||||
record = {"when": when, "t": time.time(), "client_url": page.url}
|
||||
try:
|
||||
record.update(page.evaluate(
|
||||
"() => ({url: location.href, shown: window.__shown || null, history: history.length,"
|
||||
" type: (performance.getEntriesByType('navigation')[0] || {}).type || null, state: document.readyState})"))
|
||||
except Exception as problem: # the page may be gone or changing: that is what is being recorded
|
||||
record["read_error"] = "%s: %s" % (type(problem).__name__, problem)
|
||||
with self.lock:
|
||||
self.records.append(record)
|
||||
|
||||
|
||||
def _go_back_and_record(page, reads):
|
||||
"""``page.go_back(wait_until="load")``; when it raises, what the page says then and after a short pause is recorded first (the error is raised
|
||||
unchanged: the pause only dates a restore that lands after the wait, it decides nothing)."""
|
||||
try:
|
||||
page.go_back(wait_until="load")
|
||||
except Exception:
|
||||
reads.read(page, "right after the go_back raised")
|
||||
page.wait_for_timeout(2000)
|
||||
reads.read(page, "2 s later")
|
||||
raise
|
||||
@@ -85,7 +85,7 @@ def test_async_default_context_kwargs_match_sync():
|
||||
|
||||
# ── parity with the sync launcher, driven rather than declared ───────────────
|
||||
|
||||
def test_the_async_api_stamps_the_session_token_into_the_browser_env():
|
||||
def test_the_async_api_stamps_the_session_token_into_the_browser_env(declared_engine):
|
||||
"""The gap that shipped a "fixed" leak to half the users.
|
||||
|
||||
The Windows process-leak fix went into 0.4.0 and was described as fixed. It
|
||||
|
||||
@@ -174,7 +174,7 @@ def no_geo_lookup(monkeypatch):
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_enter_with_profile_dir_calls_launch_persistent_context(tmp_path, monkeypatch, no_geo_lookup):
|
||||
def test_enter_with_profile_dir_calls_launch_persistent_context(tmp_path, monkeypatch, no_geo_lookup, declared_engine):
|
||||
"""When profile_dir is set, __enter__ must call
|
||||
`firefox.launch_persistent_context(user_data_dir=...)` and NOT
|
||||
`firefox.launch(...)`. This is the structural test that the persistent
|
||||
@@ -217,7 +217,7 @@ def test_enter_with_profile_dir_calls_launch_persistent_context(tmp_path, monkey
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_enter_without_profile_dir_calls_launch_not_persistent(tmp_path, monkeypatch, no_geo_lookup):
|
||||
def test_enter_without_profile_dir_calls_launch_not_persistent(tmp_path, monkeypatch, no_geo_lookup, declared_engine):
|
||||
"""Default path: profile_dir=None → firefox.launch, not
|
||||
launch_persistent_context. Sentinel that the non-persistent flow
|
||||
isn't accidentally rerouted."""
|
||||
@@ -246,7 +246,7 @@ def test_enter_without_profile_dir_calls_launch_not_persistent(tmp_path, monkeyp
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_persistent_context_user_data_dir_is_created_if_missing(tmp_path, monkeypatch, no_geo_lookup):
|
||||
def test_persistent_context_user_data_dir_is_created_if_missing(tmp_path, monkeypatch, no_geo_lookup, declared_engine):
|
||||
"""First-run scenario: the directory the user names doesn't exist yet.
|
||||
__enter__ must mkdir -p it (Playwright won't, and would crash with
|
||||
'user_data_dir does not exist')."""
|
||||
@@ -269,7 +269,7 @@ def test_persistent_context_user_data_dir_is_created_if_missing(tmp_path, monkey
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_teardown_closes_persistent_context(tmp_path, monkeypatch, no_geo_lookup):
|
||||
def test_teardown_closes_persistent_context(tmp_path, monkeypatch, no_geo_lookup, declared_engine):
|
||||
"""The teardown must close the persistent context. Forgetting this
|
||||
leaves Firefox + Playwright running until the parent process exits,
|
||||
which on long-running tools (job orchestrators, MCP servers) leaks
|
||||
|
||||
@@ -108,7 +108,7 @@ def test_default_context_viewport_follows_a_pinned_taskbar():
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_default_context_screen_matches_profile():
|
||||
def test_default_context_screen_matches_profile(lab_exit):
|
||||
ip = InvisiblePlaywright(seed=42)
|
||||
kw = ip._default_context_kwargs()
|
||||
p = ip._profile
|
||||
@@ -125,7 +125,7 @@ def test_default_context_screen_matches_profile():
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_default_context_color_scheme_follows_dark_theme():
|
||||
def test_default_context_color_scheme_follows_dark_theme(lab_exit):
|
||||
"""The theme follows ``dark_theme``, but through the DECLARATION.
|
||||
|
||||
Previously the wrapper passed ``color_scheme`` to Playwright, which translated it
|
||||
@@ -186,14 +186,14 @@ def test_default_context_with_no_language_asked_is_en_us():
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_build_env_carries_the_declared_network():
|
||||
def test_build_env_carries_the_declared_network(declared_engine):
|
||||
from invisible_core import network_to_declare
|
||||
env = InvisiblePlaywright(seed=42)._build_env({})
|
||||
assert env["STEALTHFOX_WEBRTC_NETWORK"] == network_to_declare(42)
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_build_env_caller_env_override_wins(monkeypatch):
|
||||
def test_build_env_caller_env_override_wins(monkeypatch, declared_engine):
|
||||
monkeypatch.setenv("STEALTHFOX_WEBRTC_NETWORK", "v4=198.51.100.5;v6=1")
|
||||
env = InvisiblePlaywright(seed=42)._build_env({})
|
||||
assert env["STEALTHFOX_WEBRTC_NETWORK"] == "v4=198.51.100.5;v6=1" # caller wins
|
||||
@@ -223,7 +223,7 @@ def test_build_env_drops_the_variables_the_display_names_absent():
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_build_env_never_injects_font_env():
|
||||
def test_build_env_never_injects_font_env(declared_engine):
|
||||
# The patched binary is self-contained for fonts (always bundle-only; the
|
||||
# exposed set IS the bundle, system-ui + generics baked in C++). The wrapper
|
||||
# must NOT inject any STEALTHFOX_FONTLIST/SYSTEMUI env - even if legacy font
|
||||
@@ -238,7 +238,7 @@ def test_build_env_never_injects_font_env():
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_build_env_no_font_keys_when_absent():
|
||||
def test_build_env_no_font_keys_when_absent(declared_engine):
|
||||
ip = InvisiblePlaywright(seed=42)
|
||||
env = ip._build_env({})
|
||||
assert "STEALTHFOX_FONTLIST" not in env
|
||||
|
||||
@@ -46,7 +46,7 @@ DELIBERATE_VS_PUBLIC_API = {
|
||||
}
|
||||
|
||||
|
||||
def test_the_wrapper_composes_what_the_public_api_composes():
|
||||
def test_the_wrapper_composes_what_the_public_api_composes(lab_exit):
|
||||
profile = generate_profile(SEED)
|
||||
mine = build_prefs(profile=profile, locale=LOCALE, timezone=TZ,
|
||||
extra_prefs=None, virtual_display=False,
|
||||
|
||||
@@ -87,7 +87,7 @@ def slow(monkeypatch):
|
||||
return vd
|
||||
|
||||
|
||||
def test_a_second_browser_is_served_while_the_first_starts_its_display(slow):
|
||||
def test_a_second_browser_is_served_while_the_first_starts_its_display(slow, declared_engine):
|
||||
"""While the first browser's display start is in progress (blocked until the
|
||||
test lets it return), the loop answers a second browser. If the start ran on
|
||||
the loop, the loop would stand still inside it and the second browser could
|
||||
|
||||
@@ -16,7 +16,7 @@ from invisible_playwright import ensure_binary, get_default_stealth_prefs
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
def test_public_import_matches_direct_import():
|
||||
def test_public_import_matches_direct_import(lab_exit):
|
||||
"""The wrapper's re-export IS the core's function, not a copy of it."""
|
||||
from invisible_core.config import get_default_stealth_prefs as _core
|
||||
|
||||
|
||||
Reference in new issue
Block a user