Merge 891abbf5 into the integration for the candidates

This commit is contained in:
feder-cr committed 2026-11-23 01:17:08 +01:00
commit 6582f222ce
13 files changed
+2005 -79

No files matched your search

+4 -4
View File
@@ -14,14 +14,14 @@
{"id": "wrapper.e2e.fakeweb", "giro": "G2", "os": ["linux", "windows"], "min_tests": 4, "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), each judged against what stock Firefox does, as tests/fakeweb/pages.json declares it. 4 = 3 + 1. 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)."},
{"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": 3228, "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_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_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_network.py", "tests/test_ab_oracle.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.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_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_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_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_goto_follows_the_base_url.py", "tests/test_hook_wiring.py", "tests/test_imports.py", "tests/test_integration.py", "tests/test_juggler_event_buffer.py", "tests/test_juggler_event_listeners.py", "tests/test_juggler_injected.py", "tests/test_juggler_lives_in_the_core.py", "tests/test_juggler_posix_pipe.py", "tests/test_juggler_transport.py", "tests/test_key_delay_reaches_the_keyboard.py", "tests/test_keyboard_rhythm.py", "tests/test_launch_counters_run_on_github.py", "tests/test_launcher_config.py", "tests/test_launcher_helpers.py", "tests/test_motion_never_hides_a_programming_error.py", "tests/test_moving_pLine truncated
{"id": "wrapper.unit.all.windows", "giro": "G1", "os": ["windows"], "min_tests": 3229, "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_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_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_network.py", "tests/test_ab_oracle.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.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_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_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_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_goto_follows_the_base_url.py", "tests/test_hook_wiring.py", "tests/test_imports.py", "tests/test_integration.py", "tests/test_juggler_event_buffer.py", "tests/test_juggler_event_listeners.py", "tests/test_juggler_injected.py", "tests/test_juggler_lives_in_the_core.py", "tests/test_juggler_transport.py", "tests/test_key_delay_reaches_the_keyboard.py", "tests/test_keyboard_rhythm.py", "tests/test_launch_counters_run_on_github.py", "tests/test_launcher_config.py", "tests/test_launcher_helpers.py", "tests/test_motion_never_hides_a_programming_error.py", "tests/test_moving_page_model.py", "tests/test_navigLine truncated
{"id": "wrapper.unit.all.linux", "giro": "G1", "os": ["linux"], "min_tests": 3228, "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_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_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_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_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_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_goto_follows_the_base_url.py", "tests/test_hook_wiring.py", "tests/test_imports.py", "tests/test_integration.py", "tests/test_juggler_event_buffer.py", "tests/test_juggler_event_listeners.py", "tests/test_juggler_injected.py", "tests/test_juggler_lives_in_the_core.py", "tests/test_juggler_posix_pipe.py", "tests/test_juggler_transport.py", "tests/test_key_delay_reacLine truncated
{"id": "wrapper.unit.all.windows", "giro": "G1", "os": ["windows"], "min_tests": 3229, "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_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_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_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_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_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_goto_follows_the_base_url.py", "tests/test_hook_wiring.py", "tests/test_imports.py", "tests/test_integration.py", "tests/test_juggler_event_buffer.py", "tests/test_juggler_event_listeners.py", "tests/test_juggler_injected.py", "tests/test_juggler_lives_in_the_core.py", "tests/test_juggler_transport.py", "tests/test_key_delay_reaches_the_keyboard.py", "tests/tesLine 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)."},
{"id": "wrapper.e2e.suite.linux.1", "giro": "G2", "os": ["linux"], "min_tests": 377, "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_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_two_contexts_with_two_proxies_each_gets_the_srflx_ofLine truncated
{"id": "wrapper.e2e.suite.linux.2", "giro": "G2", "os": ["linux"], "min_tests": 411, "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
{"id": "wrapper.e2e.suite.linux.3", "giro": "G2", "os": ["linux"], "min_tests": 269, "exact": true, "tests": ["tests/test_a_click_in_an_iframe_lands_at_the_frames_own_screen_origin_e2e.py", "tests/test_a_context_language_is_the_accept_language_of_every_request_e2e.py", "tests/test_a_goto_to_a_refused_port_ends_with_its_reason_e2e.py", "tests/test_a_launch_and_a_context_timezone_reach_the_page_e2e.py", "tests/test_a_navigation_that_moved_is_told_by_the_engine_e2e.py", "tests/test_a_popup_of_a_link_reaches_the_client_e2e.py", "tests/test_a_regional_indicator_pair_measures_the_same_first_and_after_other_families_e2e.py", "tests/test_audio_context_values_are_declared_e2e.py", "tests/test_audio_noise_e2e.py", "tests/test_audio_sample_rate_is_declared_e2e.py", "tests/test_bundle_font_names_e2e.py", "tests/test_canvas_create_pattern_projection_e2e.py", "tests/test_canvas_measure_text_metrics_e2e.py", "tests/test_css_media_reads_the_declared_screen_and_pointer_e2e.py", "tests/test_dom_iterables_from_evaluate_e2e.py", "tests/test_every_argument_reaches_the_page_e2e.py", "tests/test_every_reader_of_a_webgl_canvas_agrees_e2e.py", "tests/test_fakeweb_p2_e2e.py", "tests/test_fission_frames_tree_input_and_pixels_e2e.py", "tests/test_focus_survives_os_deactivation_e2e.py", "tests/test_fullscreen_without_wm_e2e.py", "tests/test_geolocation_reads_nothing_of_the_host_windows_e2e.py", "tests/test_goto_and_every_way_it_is_stopped_e2e.py", "tests/test_hardware_values_are_declared_e2e.py", "tests/test_ipv6_literal_connect_e2e.py", "tests/test_moz_element_paints_a_webgl_canvas_as_drawn_e2e.py", "tests/test_native_line_endings_are_windows_e2e.py", "tests/test_nested_frame_actions.py", "tests/test_networkidle_through_a_served_browser_with_routes_e2e.py", "tests/test_nothing_leaves_but_the_proxy_e2e.py", "tests/test_nothing_of_a_context_leaves_but_through_its_proxy_e2e.py", "tests/test_page_element_atoms_run_in_a_sandbox_e2e.py", "tests/test_popup_geometry_is_the_declared_frame_e2e.py", "tests/test_script_cache_written_is_adopted_e2e.py", "tests/test_the_branding_a_page_loads_is_the_declared_archive_e2e.py", "tests/test_the_evaluated_code_has_no_debugger_name_e2e.py", "tests/test_the_host_gl_probe_runs_only_on_an_undeclared_engine_linux_e2e.py", "tests/test_the_launch_counter_is_one_plain_get_before_any_page_e2e.py", "tests/test_the_shutdown_ping_leaves_by_the_background_task_e2e.py", "tests/test_webgl_declared_parameters_e2e.py", "tests/test_webgl_shader_language_e2e.py", "tests/test_webgpu_adapter_is_declared_e2e.py", "tests/test_webgpu_canvas_readback_is_noised_e2e.py", "tests/test_webgpu_external_texture_e2e.py", "tests/test_window_occlusion_e2e.py"], "marker": "e2e", "needs_root": false, "windows_twin": "wrapper.e2e.suite.windows.3", "note": "Part 2 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 2 rows of linux are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 565 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapper.e2e.udp.exit and wrapper.e2e.udp.sandbox (root and user namespaces, their own rows), the files of the round after the publication (tests/_post_publication.py), and the tests that skip on linux (a skip is red in the verdict)."},
{"id": "wrapper.e2e.suite.linux.3", "giro": "G2", "os": ["linux"], "min_tests": 269, "exact": true, "tests": ["tests/test_a_click_in_an_iframe_lands_at_the_frames_own_screen_origin_e2e.py", "tests/test_a_context_language_is_the_accept_language_of_every_request_e2e.py", "tests/test_a_goto_to_a_refused_port_ends_with_its_reason_e2e.py", "tests/test_a_launch_and_a_context_timezone_reach_the_page_e2e.py", "tests/test_a_navigation_that_moved_is_told_by_the_engine_e2e.py", "tests/test_a_popup_of_a_link_reaches_the_client_e2e.py", "tests/test_a_regional_indicator_pair_measures_the_same_first_and_after_other_families_e2e.py", "tests/test_audio_context_values_are_declared_e2e.py", "tests/test_audio_noise_e2e.py", "tests/test_audio_sample_rate_is_declared_e2e.py", "tests/test_bundle_font_names_e2e.py", "tests/test_canvas_create_pattern_projection_e2e.py", "tests/test_canvas_measure_text_metrics_e2e.py", "tests/test_css_media_reads_the_declared_screen_and_pointer_e2e.py", "tests/test_dom_iterables_from_evaluate_e2e.py", "tests/test_every_argument_reaches_the_page_e2e.py", "tests/test_every_reader_of_a_webgl_canvas_agrees_e2e.py", "tests/test_fakeweb_p2_e2e.py", "tests/test_fission_frames_tree_input_and_pixels_e2e.py", "tests/test_focus_survives_os_deactivation_e2e.py", "tests/test_fullscreen_without_wm_e2e.py", "tests/test_geolocation_reads_nothing_of_the_host_windows_e2e.py", "tests/test_goto_and_every_way_it_is_stopped_e2e.py", "tests/test_hardware_values_are_declared_e2e.py", "tests/test_ipv6_literal_connect_e2e.py", "tests/test_moz_element_paints_a_webgl_canvas_as_drawn_e2e.py", "tests/test_native_line_endings_are_windows_e2e.py", "tests/test_nested_frame_actions.py", "tests/test_networkidle_through_a_served_browser_with_routes_e2e.py", "tests/test_nothing_leaves_but_the_proxy_e2e.py", "tests/test_nothing_of_a_context_leaves_but_through_its_proxy_e2e.py", "tests/test_page_element_atoms_run_in_a_sandbox_e2e.py", "tests/test_popup_geometry_is_the_declared_frame_e2e.py", "tests/test_script_cache_written_is_adopted_e2e.py", "tests/test_the_branding_a_page_loads_is_the_declared_archive_e2e.py", "tests/test_the_evaluated_code_has_no_debugger_name_e2e.py", "tests/test_the_host_gl_probe_runs_only_on_an_undeclared_engine_linux_e2e.py", "tests/test_the_launch_counter_is_one_plain_get_before_any_page_e2e.py", "tests/test_the_shutdown_ping_leaves_by_the_background_task_e2e.py", "tests/test_webgl_declared_parameters_e2e.py", "tests/test_webgl_shader_language_e2e.py", "tests/test_webgpu_adapter_is_declared_e2e.py", "tests/test_webgpu_canvas_readback_is_noised_e2e.py", "tests/test_webgpu_external_texture_e2e.py", "tests/test_window_occlusion_e2e.py", "tests/test_a_file_chooser_reaches_every_client_e2e.py", "tests/test_an_element_handle_serves_every_method_of_the_client_e2e.py"], "marker": "e2e", "needs_root": false, "windows_twin": "wrapper.e2e.suite.windows.3", "note": "Part 2 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 2 rows of linux are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 565 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapper.e2e.udp.exit and wrapper.e2e.udp.sandbox (root and user namespaces, their own rows), the files of the round after the publication (tests/_post_publication.py), and the tests that skip on linux (a skip is red in the verdict)."},
{"id": "wrapper.e2e.suite.windows.1", "giro": "G2", "os": ["windows"], "min_tests": 261, "exact": true, "tests": ["tests/test_a_click_waits_for_the_navigation_it_plans_e2e.py", "tests/test_a_closed_browser_leaves_the_others_alone_e2e.py", "tests/test_a_context_init_script_runs_once_e2e.py", "tests/test_a_goto_to_a_refused_port_ends_with_its_reason_e2e.py", "tests/test_a_granted_permission_is_the_one_the_page_asks_for_e2e.py", "tests/test_a_held_ice_port_blinds_the_loopback_checks_e2e.py", "tests/test_a_left_documents_body_is_evicted_e2e.py", "tests/test_a_page_cannot_probe_the_juggler_e2e.py", "tests/test_a_tiny_download_on_a_served_browser_is_saved_e2e.py", "tests/test_a_worker_comes_back_with_its_page_from_the_cache_e2e.py", "tests/test_browser_output_is_drained.py", "tests/test_canvas_create_pattern_projection_e2e.py", "tests/test_click_rhythm.py", "tests/test_closing_one_of_four_browsers_does_not_hold_the_loop_e2e.py", "tests/test_context_locale_e2e.py", "tests/test_context_proxy_only_resolves_by_doh_e2e.py", "tests/test_detectors_e2e.py", "tests/test_download_is_intercepted_e2e.py", "tests/test_e2e.py", "tests/test_element_handle_actions.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_every_reader_of_a_webgl_canvas_agrees_e2e.py", "tests/test_fission_identity_parity_e2e.py", "tests/test_fission_iframe_crash_e2e.py", "tests/test_focus_survives_os_deactivation_e2e.py", "tests/test_geolocation_reads_nothing_of_the_host_windows_e2e.py", "tests/test_goto_to_the_same_url_e2e.py", "tests/test_ignore_https_errors_e2e.py", "tests/test_juggler_actions.py", "tests/test_juggler_transport.py", "tests/test_keyboard_rhythm.py", "tests/test_moz_element_paints_a_webgl_canvas_as_drawn_e2e.py", "tests/test_nested_frame_actions.py", "tests/test_popups_reach_the_client_e2e.py", "tests/test_preload_newtab_turns_the_privileged_about_process_off_e2e.py", "tests/test_route_superseded_e2e.py", "tests/test_scroll_only_if_needed_e2e.py", "tests/test_security_state_engine_e2e.py", "tests/test_service_worker.py", "tests/test_service_workers_blocked.py", "tests/test_strict_and_force.py", "tests/test_the_engine_is_born_in_the_job_e2e.py", "tests/test_the_hosts_file_of_the_host_is_never_read_e2e.py", "tests/test_the_shutdown_ping_leaves_by_the_background_task_e2e.py", "tests/test_trial_does_not_act.py", "tests/test_ua_widget_not_selectable.py", "tests/test_webgpu_canvas_readback_is_noised_e2e.py", "tests/test_a_screenshot_honours_its_scale_e2e.py"], "marker": "e2e", "needs_root": false, "linux_twin": "wrapper.e2e.suite.linux.1", "note": "Part 1 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 4 rows of windows are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 609 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapper.e2e.udp.exit and wrapper.e2e.udp.sandbox (root and user namespaces, their own rows), the files of the round after the publication (tests/_post_publication.py), and the tests that skip on windows (a skip is red in the verdict)."},
{"id": "wrapper.e2e.suite.windows.2", "giro": "G2", "os": ["windows"], "min_tests": 246, "exact": true, "tests": ["tests/test_a_goto_to_a_response_with_no_document_ends_e2e.py", "tests/test_a_latin_letter_on_a_cyrillic_persona_e2e.py", "tests/test_a_navigation_that_moved_is_told_by_the_engine_e2e.py", "tests/test_a_regional_indicator_pair_measures_the_same_first_and_after_other_families_e2e.py", "tests/test_a_turn_name_over_tcp_goes_through_the_proxy_of_the_context_e2e.py", "tests/test_add_script_tag.py", "tests/test_an_isolated_page_and_the_next_e2e.py", "tests/test_audio_context_values_are_declared_e2e.py", "tests/test_bundle_font_names_e2e.py", "tests/test_caller_world_handles_e2e.py", "tests/test_canvas_reads_as_drawn.py", "tests/test_canvas_render_stealth.py", "tests/test_css_media_reads_the_declared_screen_and_pointer_e2e.py", "tests/test_declared_host_network_e2e.py", "tests/test_every_argument_reaches_the_page_e2e.py", "tests/test_expose_binding_e2e.py", "tests/test_fission_frames_dialogs_downloads_popups_e2e.py", "tests/test_fullscreen_without_wm_e2e.py", "tests/test_goto_networkidle_after_spa_e2e.py", "tests/test_goto_script_redirect_e2e.py", "tests/test_hidden_desktop.py", "tests/test_ice_names_by_the_context_proxy_e2e.py::test_the_ice_name_of_a_context_goes_by_the_proxy_of_that_context", "tests/test_juggler_lifecycle_e2e.py", "tests/test_key_delay_reaches_the_keyboard.py", "tests/test_long_session_e2e.py", "tests/test_mouse.py", "tests/test_native_line_endings_are_windows_e2e.py", "tests/test_navigation_across_processes_e2e.py", "tests/test_networkidle_reaches_the_client_e2e.py", "tests/test_nothing_leaves_but_the_proxy_e2e.py", "tests/test_nothing_of_a_context_leaves_but_through_its_proxy_e2e.py", "tests/test_oop_frame_geometry.py", "tests/test_proxy_socks_auth_e2e.py", "tests/test_resolver_race_e2e.py", "tests/test_route_e2e.py", "tests/test_screencast_stop_e2e.py", "tests/test_the_branding_a_page_loads_is_the_declared_archive_e2e.py", "tests/test_the_device_enumeration_takes_the_declared_time_e2e.py", "tests/test_the_evaluated_code_has_no_debugger_name_e2e.py", "tests/test_the_favicon_stays_out_of_sight_e2e.py", "tests/test_the_font_list_is_the_bundle_e2e.py", "tests/test_the_scheme_is_the_personas_e2e.py", "tests/test_the_whole_udp_chain_by_name_e2e.py::test_a_turn_srflx_by_name_arrives_through_the_relay_when_the_exit_of_the_lab_is_loopback", "tests/test_turn_over_tcp_is_tried_for_real_e2e.py", "tests/test_voices_e2e.py", "tests/test_wait_for_function.py", "tests/test_wait_for_timeout.py", "tests/test_web_fonts_of_closed_contexts_e2e.py", "tests/test_webrtc_realness.py::test_a_gateway_that_is_far_away_still_gives_the_page_a_srflx_born_through_its_relay", "tests/test_webrtc_realness.py::test_a_gather_after_the_page_loaded_through_the_gateway_costs_only_the_road_to_the_server", "tests/test_webrtc_realness.py::test_a_host_with_ipv6_addresses_gathers_through_an_ipv4_relay", "tests/test_webrtc_realness.py::test_a_proxy_that_does_not_relay_udp_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_a_proxy_whose_relay_never_answers_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_a_proxy_whose_udp_leaves_from_another_address_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_not_blocked_behind_tcp_only_socks", "tests/test_webrtc_realness.py::test_the_first_candidate_of_a_gather_does_not_wait_for_a_gateway_that_is_far_away", "tests/test_webrtc_realness.py::test_the_turn_over_tcp_of_a_context_goes_through_the_proxy_of_that_context", "tests/test_webrtc_realness.py::test_two_contexts_with_two_proxies_each_gets_the_srflx_of_its_own"], "marker": "e2e", "needs_root": false, "linux_twin": "wrapper.e2e.suite.linux.2", "note": "Part 2 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 4 rows of windows are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 610 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapper.e2e.udp.exit and wrapper.e2e.udp.sandbox (root and user namespaces, their own rows), the files of the round after the publication (tests/_post_publication.py), and the tests that skip on windows (a skip is red in the verdict)."},
{"id": "wrapper.e2e.suite.windows.2", "giro": "G2", "os": ["windows"], "min_tests": 246, "exact": true, "tests": ["tests/test_a_goto_to_a_response_with_no_document_ends_e2e.py", "tests/test_a_latin_letter_on_a_cyrillic_persona_e2e.py", "tests/test_a_navigation_that_moved_is_told_by_the_engine_e2e.py", "tests/test_a_regional_indicator_pair_measures_the_same_first_and_after_other_families_e2e.py", "tests/test_a_turn_name_over_tcp_goes_through_the_proxy_of_the_context_e2e.py", "tests/test_add_script_tag.py", "tests/test_an_isolated_page_and_the_next_e2e.py", "tests/test_audio_context_values_are_declared_e2e.py", "tests/test_bundle_font_names_e2e.py", "tests/test_caller_world_handles_e2e.py", "tests/test_canvas_reads_as_drawn.py", "tests/test_canvas_render_stealth.py", "tests/test_css_media_reads_the_declared_screen_and_pointer_e2e.py", "tests/test_declared_host_network_e2e.py", "tests/test_every_argument_reaches_the_page_e2e.py", "tests/test_expose_binding_e2e.py", "tests/test_fission_frames_dialogs_downloads_popups_e2e.py", "tests/test_fullscreen_without_wm_e2e.py", "tests/test_goto_networkidle_after_spa_e2e.py", "tests/test_goto_script_redirect_e2e.py", "tests/test_hidden_desktop.py", "tests/test_ice_names_by_the_context_proxy_e2e.py::test_the_ice_name_of_a_context_goes_by_the_proxy_of_that_context", "tests/test_juggler_lifecycle_e2e.py", "tests/test_key_delay_reaches_the_keyboard.py", "tests/test_long_session_e2e.py", "tests/test_mouse.py", "tests/test_native_line_endings_are_windows_e2e.py", "tests/test_navigation_across_processes_e2e.py", "tests/test_networkidle_reaches_the_client_e2e.py", "tests/test_nothing_leaves_but_the_proxy_e2e.py", "tests/test_nothing_of_a_context_leaves_but_through_its_proxy_e2e.py", "tests/test_oop_frame_geometry.py", "tests/test_proxy_socks_auth_e2e.py", "tests/test_resolver_race_e2e.py", "tests/test_route_e2e.py", "tests/test_screencast_stop_e2e.py", "tests/test_the_branding_a_page_loads_is_the_declared_archive_e2e.py", "tests/test_the_device_enumeration_takes_the_declared_time_e2e.py", "tests/test_the_evaluated_code_has_no_debugger_name_e2e.py", "tests/test_the_favicon_stays_out_of_sight_e2e.py", "tests/test_the_font_list_is_the_bundle_e2e.py", "tests/test_the_scheme_is_the_personas_e2e.py", "tests/test_the_whole_udp_chain_by_name_e2e.py::test_a_turn_srflx_by_name_arrives_through_the_relay_when_the_exit_of_the_lab_is_loopback", "tests/test_turn_over_tcp_is_tried_for_real_e2e.py", "tests/test_voices_e2e.py", "tests/test_wait_for_function.py", "tests/test_wait_for_timeout.py", "tests/test_web_fonts_of_closed_contexts_e2e.py", "tests/test_webrtc_realness.py::test_a_gateway_that_is_far_away_still_gives_the_page_a_srflx_born_through_its_relay", "tests/test_webrtc_realness.py::test_a_gather_after_the_page_loaded_through_the_gateway_costs_only_the_road_to_the_server", "tests/test_webrtc_realness.py::test_a_host_with_ipv6_addresses_gathers_through_an_ipv4_relay", "tests/test_webrtc_realness.py::test_a_proxy_that_does_not_relay_udp_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_a_proxy_whose_relay_never_answers_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_a_proxy_whose_udp_leaves_from_another_address_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_not_blocked_behind_tcp_only_socks", "tests/test_webrtc_realness.py::test_the_first_candidate_of_a_gather_does_not_wait_for_a_gateway_that_is_far_away", "tests/test_webrtc_realness.py::test_the_turn_over_tcp_of_a_context_goes_through_the_proxy_of_that_context", "tests/test_webrtc_realness.py::test_two_contexts_with_two_proxies_each_gets_the_srflx_of_its_own", "tests/test_a_file_chooser_reaches_every_client_e2e.py", "tests/test_an_element_handle_serves_every_method_of_the_client_e2e.py"], "marker": "e2e", "needs_root": false, "linux_twin": "wrapper.e2e.suite.linux.2", "note": "Part 2 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 4 rows of windows are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 610 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapper.e2e.udp.exit and wrapper.e2e.udp.sandbox (root and user namespaces, their own rows), the files of the round after the publication (tests/_post_publication.py), and the tests that skip on windows (a skip is red in the verdict)."},
{"id": "wrapper.e2e.suite.windows.3", "giro": "G2", "os": ["windows"], "min_tests": 273, "exact": true, "tests": ["tests/test_a_click_in_an_iframe_lands_at_the_frames_own_screen_origin_e2e.py", "tests/test_a_context_that_ends_leaves_no_process_e2e.py", "tests/test_a_cors_preflight_is_not_a_request_of_the_page_e2e.py", "tests/test_a_launch_without_a_session_gets_one_e2e.py", "tests/test_a_mouse_click_makes_one_mousemove_on_its_point_e2e.py", "tests/test_a_page_over_ipv6_gathers_on_a_machine_declared_without_it_e2e.py", "tests/test_a_served_browser_answers_a_plain_client_e2e.py", "tests/test_actions_without_a_point.py", "tests/test_audio_noise_e2e.py", "tests/test_audio_sample_rate_is_declared_e2e.py", "tests/test_bypass_csp_e2e.py", "tests/test_control_a_selects_all_in_a_field_e2e.py", "tests/test_cross_origin_iframe.py", "tests/test_dom_iterables_from_evaluate_e2e.py", "tests/test_drag_motion.py", "tests/test_element_screenshot_e2e.py", "tests/test_fakeweb_p4_e2e.py", "tests/test_fingerprint_consistency.py", "tests/test_first_launch_from_a_new_path.py", "tests/test_fission_frames_history_and_processes_e2e.py", "tests/test_fission_frames_workers_storage_and_special_frames_e2e.py", "tests/test_fission_strategy1_bench.py", "tests/test_goto_and_every_way_it_is_stopped_e2e.py", "tests/test_http3_through_the_proxy_e2e.py", "tests/test_input_is_born_before_the_page_sees_it_e2e.py", "tests/test_ipv6_literal_connect_e2e.py", "tests/test_networkidle_through_a_served_browser_with_routes_e2e.py", "tests/test_page_number_follows_the_call.py", "tests/test_persistent_profile_keeps_state.py", "tests/test_pointer_position.py", "tests/test_popup_destinations_e2e.py", "tests/test_popup_pages.py", "tests/test_proxy_http_auth_e2e.py", "tests/test_requestless_navigation.py", "tests/test_route_abort_code.py", "tests/test_route_post_data_e2e.py", "tests/test_same_document_navigation.py", "tests/test_screencast.py", "tests/test_screenshot_looks_where_you_are.py", "tests/test_service_worker_controller_e2e.py", "tests/test_set_input_files_payloads.py", "tests/test_set_offline_e2e.py", "tests/test_the_callers_code_is_not_counted_e2e.py", "tests/test_the_callers_code_runs_once_e2e.py", "tests/test_the_close_returns_when_the_browser_has_exited_e2e.py", "tests/test_the_launch_counter_is_one_plain_get_before_any_page_e2e.py", "tests/test_webgl_declared_parameters_e2e.py", "tests/test_webgl_shader_language_e2e.py", "tests/test_webgpu_adapter_is_declared_e2e.py", "tests/test_webgpu_external_texture_e2e.py"], "marker": "e2e", "needs_root": false, "linux_twin": "wrapper.e2e.suite.linux.1", "note": "Part 3 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 4 rows of windows are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 610 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapper.e2e.udp.exit and wrapper.e2e.udp.sandbox (root and user namespaces, their own rows), the files of the round after the publication (tests/_post_publication.py), and the tests that skip on windows (a skip is red in the verdict)."},
{"id": "wrapper.e2e.suite.windows.4", "giro": "G2", "os": ["windows"], "min_tests": 270, "exact": true, "tests": ["tests/test_a_context_language_is_the_accept_language_of_every_request_e2e.py", "tests/test_a_declared_webgl_extension_survives_its_use_e2e.py", "tests/test_a_drag_keeps_its_buttons_pressed_e2e.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_keepalive_request_reaches_the_client_e2e.py", "tests/test_a_launch_and_a_context_timezone_reach_the_page_e2e.py", "tests/test_a_page_that_moves_on_e2e.py", "tests/test_a_pointer_event_is_handled_before_the_call_returns_e2e.py", "tests/test_a_popup_is_reported_when_the_engine_says_it_is_ready_as_playwright_does_e2e.py", "tests/test_a_popup_of_a_link_reaches_the_client_e2e.py", "tests/test_a_request_says_what_it_is_e2e.py", "tests/test_a_screenshot_draws_the_text_of_the_bundled_fonts_as_the_content_does_e2e.py", "tests/test_accept_language_on_the_wire_e2e.py", "tests/test_canvas_measure_text_metrics_e2e.py", "tests/test_doh_through_the_proxy_e2e.py", "tests/test_doh_under_stress_e2e.py", "tests/test_fakeweb_p2_e2e.py", "tests/test_file_chooser.py", "tests/test_fingerprint_surface.py", "tests/test_fission_frames_route_and_bindings_e2e.py", "tests/test_fission_frames_tree_input_and_pixels_e2e.py", "tests/test_frames_outlive_the_back_forward_cache_e2e.py", "tests/test_hardware_values_are_declared_e2e.py", "tests/test_injected_node_surface.py", "tests/test_juggler_connection.py", "tests/test_juggler_event_listeners.py", "tests/test_juggler_injected.py::test_a_javascript_that_THROWS_arrives_as_an_error_not_as_None", "tests/test_juggler_injected.py::test_actionability_DISTINGUISHES_instead_of_always_saying_yes", "tests/test_juggler_injected.py::test_reads_that_make_no_sense_are_REJECTED", "tests/test_juggler_injected.py::test_states_DISCRIMINATE_instead_of_always_saying_true", "tests/test_juggler_injected.py::test_the_DOM_READING_group", "tests/test_juggler_injected.py::test_the_selector_engines_respond", "tests/test_juggler_injected.py::test_the_text_reads", "tests/test_mouse_events_keep_their_values_e2e.py", "tests/test_navigation_response.py", "tests/test_new_page_defaults.py", "tests/test_oop_frame_element.py", "tests/test_page_element_atoms_run_in_a_sandbox_e2e.py", "tests/test_popup_geometry_is_the_declared_frame_e2e.py", "tests/test_proxy_reaches_the_browser.py", "tests/test_realness_behind_a_declared_exit_e2e.py", "tests/test_route_header_order_e2e.py", "tests/test_route_sends_a_navigation_elsewhere_e2e.py", "tests/test_same_document_goto_e2e.py", "tests/test_script_cache_written_is_adopted_e2e.py", "tests/test_scroll_into_view.py", "tests/test_shadow_trusted_input.py", "tests/test_software_compositing_is_declared_e2e.py", "tests/test_the_association_is_ready_when_the_peerconnection_is_born_e2e.py", "tests/test_typing_a_character_without_a_key_e2e.py", "tests/test_webgl_noise_active.py", "tests/test_window_occlusion_e2e.py"], "marker": "e2e", "needs_root": false, "linux_twin": "wrapper.e2e.suite.linux.2", "note": "Part 4 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 4 rows of windows are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 609 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapper.e2e.udp.exit and wrapper.e2e.udp.sandbox (root and user namespaces, their own rows), the files of the round after the publication (tests/_post_publication.py), and the tests that skip on windows (a skip is red in the verdict)."},
{"id": "wrapper.e2e.suite.windows.control_a", "giro": "G2", "os": ["windows"], "min_tests": 20, "exact": true, "tests": ["tests/test_control_a_selects_all_in_a_field_e2e.py"], "marker": "e2e", "needs_root": false, "linux_twin": "wrapper.e2e.suite.linux.1", "note": "The keyboard shortcut Control+A selects all in a field (5 ways to press it x an input and a textarea, in-process and served to the stock client), alone on its own Windows runner (windows-latest), as e2e.yml runs it on the published engine: the Windows keyboard of a real user is what it needs. The same file is in one of wrapper.e2e.suite.windows.1..4 and in wrapper.e2e.suite.linux.1."},
@@ -62,8 +62,6 @@ OUTSIDE = {
"clockRunFor": "clock",
"clockSetFixedTime": "clock",
"clockSetSystemTime": "clock",
# the streamed upload path - set_input_files with local paths works
"createTempFiles": "the streamed upload path - set_input_files with local paths works",
# recorder
"cancelPickLocator": "recorder",
"createSelectorForTest": "recorder",
@@ -103,7 +101,6 @@ OUTSIDE = {
"tracingStarted": "tracing",
"tracingStop": "tracing",
"tracingStopChunk": "tracing",
"write": "tracing",
"zip": "tracing",
# video annotations. ⛔ `screencastStart` and `screencastStop` are NOT
# here any more: since the engine's screencast came back (firefox-28) the
+6 -2
View File
@@ -43,8 +43,12 @@ locale, timezone), and `context_options_override=True` makes the server's win.
LIMITS OF THIS FIRST VERSION, said instead of hidden.
* `launchPersistentContext` and `profile_dir` are not served.
* `x-playwright-proxy` (exposeNetwork) is recorded, not honoured.
* Downloads, file choosers and other fused types follow the in-process
client's path and are not carried to a remote client.
* Downloads and other fused types follow the in-process client's path and
are not carried to a remote client. A file chooser is: the `fileChooser`
event reaches the client, and `set_files` with a path streams the file
(`createTempFiles`, `WritableStream`) into the session's upload area, where
it lives as long as its context and goes with it, or with a client that
drops in the middle of the copy (`_client_gone` closes the contexts it owns).
* `RemoteServer.process` is the core's handle for the browser process
(`Connection._process`, a private attribute of the core: pid / poll / wait).
* Page numbers (`pageNumber`, which the in-process client reserves) are drawn
+505 -51
View File
@@ -373,7 +373,7 @@ def _launch_environment(named) -> Dict[str, str]:
return {e["name"]: e["value"] for e in named}
def _upload_paths(server: "JugglerServer", params: Dict) -> list:
def _upload_paths(server: "JugglerServer", params: Dict, context: Optional["BrowserContextDispatcher"] = None) -> list:
"""The local paths a `setInputFiles` request stands for.
⛔ ONE READER, because there are two senders. The same request arrives at
@@ -394,21 +394,35 @@ def _upload_paths(server: "JugglerServer", params: Dict) -> list:
same engine command as a path, so the page receives it the way it
receives a file a user picked - and, as for a user's pick, Firefox derives
the file's type from its name; the payload's `mimeType` is not carried.
`streams` are the remote-connection path (`createTempFiles`), outside the
perimeter by decision; this client never sends them to a local server.
`streams` are what a client on a REMOTE connection (`connect`) sends for a
path: it copied each file into a `WritableStream` made by
`createTempFiles` (`BrowserContextDispatcher.op_create_temp_files`) and
names those streams here. Each one is a file of this session, already
closed, and goes through the engine like any other path.
⛔ A STREAM IS USABLE ONLY BY THE CONTEXT THAT MADE IT. `context` is the
one of the frame or the handle doing the `setInputFiles`; a stream that is
not its child is answered as the stock server answers a guid outside the
connection (`streams[i]: no object with guid <g>`), whether it belongs to
another context of the same client or to another client's. Without a
context no stream is usable.
⛔ A FOLDER IS REFUSED, BY NAME. The engine's `Page.setFileInputFiles`
takes files: handed the folder's path it took the TAB down (the next call
answered "cannot find session"), measured on firefox-34 and on the engine
after it. Read as an empty list, as before, the engine answered with an
exception naming neither the folder nor the reason. Both are worse than
saying it.
saying it. A folder over `connect` is `directoryStream` (and
`createTempFiles` with a `rootDirName`): the same sentence.
"""
directory = params.get("localDirectory")
if directory:
raise ProtocolException(
"set_input_files with a folder (%s) is not supported: the engine "
"takes files, so pass the files inside it instead" % directory)
raise _folder_refused(directory)
if params.get("directoryStream"):
raise _folder_refused("a folder streamed by the client")
streams = params.get("streams")
if streams:
return [_streamed_file(server, channel, context, "streams[%d]" % n) for n, channel in enumerate(streams)]
raw = params.get("localPaths") or params.get("files")
if raw:
return [entry.get("name") if isinstance(entry, dict) else entry
@@ -417,6 +431,59 @@ def _upload_paths(server: "JugglerServer", params: Dict) -> list:
for payload in params.get("payloads") or []]
def _folder_refused(what: str) -> ProtocolException:
"""The refusal of an upload of a folder, in the one sentence every door of it says."""
return ProtocolException(
"set_input_files with a folder (%s) is not supported: the engine "
"takes files, so pass the files inside it instead" % what)
def _streamed_file(server: "JugglerServer", channel: Any, context: Any, where: str) -> str:
"""The path of the file a `streams` entry of `setInputFiles` names: a `WritableStream` of `context` that the client closed.
The sentences are the stock server's (`_tChannelImplFromWire`, playwright 1.61.0 coreBundle.js:18308-18318): `<where>: no object with guid <g>`,
`<where>: object with guid <g> has type <t>, expected WritableStream`. A stream of another context is "no object": it is not in the scope the
request came from.
"""
guid = channel.get("guid") if isinstance(channel, dict) else None
if not isinstance(guid, str):
raise ProtocolException("%s: expected guid for WritableStream" % where)
stream = server._objects.get(guid)
if stream is None or (isinstance(stream, WritableStreamDispatcher) and (context is None or stream.parent is not context)):
raise ProtocolException("%s: no object with guid %s" % (where, guid))
if not isinstance(stream, WritableStreamDispatcher):
raise ProtocolException("%s: object with guid %s has type %s, expected WritableStream" % (where, guid, stream.TYPE))
if not stream.closed:
raise ProtocolException(
"the stream %s is not closed: the client has not finished copying the file, and the page would read half of it" % guid)
return stream.path
#: Names a Windows file system opens as a DEVICE, not a file (`CON`, `NUL`, `COM1`...), with or without an extension.
_WINDOWS_DEVICES = frozenset(["CON", "PRN", "AUX", "NUL"] + ["COM%d" % n for n in range(1, 10)] + ["LPT%d" % n for n in range(1, 10)])
_BACKSLASH, _NUL = chr(92), chr(0)
def _upload_file_name(name: Any) -> str:
"""The name a client gave a file it streams, if and only if it is ONE file name.
⛔ THE NAME IS WHAT A CLIENT CHOSE, and it is joined to a folder of this machine. `stage_upload` reduces a payload's name to its last component
and writes it; here the name is REFUSED when it is anything else, because a path that is not a bare name is a client that means something
other than "a file called this" (a folder, a way out of the call's folder), and writing it somewhere is the wrong answer to that.
"""
if not isinstance(name, str) or not name:
raise ProtocolException("a streamed file needs a name: the page reads it as File.name")
bad = (name in (".", "..") or "/" in name or _BACKSLASH in name or _NUL in name
or os.path.isabs(name) or os.path.splitdrive(name)[0] != "")
if os.name == "nt":
bad = (bad or ":" in name or name[-1] in ". "
or name.split(".")[0].rstrip(" ").upper() in _WINDOWS_DEVICES)
if bad:
raise ProtocolException(
"the name %r of a streamed file is not a file name: it must be one name, with no folder, no drive and no '..' in it" % name)
return name
#: The four numbers JSON cannot carry, as the engine names them in a
#: RemoteObject's `unserializableValue` (`juggler/content/Runtime.js`).
_UNSERIALIZABLE = {"NaN": float("nan"), "-0": -0.0,
@@ -462,6 +529,17 @@ _CALL = "(f, ...a) => f(...a)"
_READ = "o => o"
#: The receivers of `eval_on_selector_all`: one array, in the caller's world.
_ARRAY = "(...a) => a"
#: The queries of a selector with an ELEMENT as root, which the core's `InjectedScript.query_selector` and `query_selector_all` cannot be asked (they pass `document`):
#: the injected script's own `querySelector(parsed, root, strict)` and `querySelectorAll(parsed, root)`, the ones stock runs with `scope || document`
#: (`FrameSelectors.query`, `queryAll`). The list of a `querySelectorAll` is read once (`FrameDispatcher._all`) and released there.
_QUERY_IN = ("(injected, root, selector, strict) => injected.querySelector("
"injected.parseSelector(selector), root, strict) || null")
_QUERY_ALL_IN = ("(injected, root, selector) => injected.querySelectorAll("
"injected.parseSelector(selector), root)")
#: Playwright's own sentence for a node that is no longer in the document (`throwElementIsNotAttached`).
_NOT_ATTACHED = "Element is not attached to the DOM"
#: The waits between the turns of an action that retries, in seconds (`ElementHandle._retryAction`: 0, 20, 100, 100, then 500 ms for every turn after).
_RETRY_WAITS = (0.0, 0.02, 0.1, 0.1, 0.5)
def _object_lookup(dispatcher):
@@ -636,6 +714,26 @@ class ElementHandleDispatcher(Dispatcher):
"uncheck": "op_uncheck",
"selectOption": "op_select_option",
"setInputFiles": "op_set_input_files",
# What the client sends a handle and this table lacked, each through the
# path its sibling has: the Frame's queries with this element as root,
# the injected script's state of THIS node, the actions of THIS node,
# the caller's code with this element as its receiver.
"querySelector": "op_query_selector",
"querySelectorAll": "op_query_selector_all",
"evalOnSelector": "op_eval_on_selector",
"evalOnSelectorAll": "op_eval_on_selector_all",
"evaluateExpressionHandle": "op_evaluate_handle",
"isVisible": "op_is_visible",
"isHidden": "op_is_hidden",
"isEnabled": "op_is_enabled",
"isDisabled": "op_is_disabled",
"isChecked": "op_is_checked",
"isEditable": "op_is_editable",
"waitForElementState": "op_wait_for_element_state",
"dblclick": "op_dblclick",
"tap": "op_tap",
"selectText": "op_select_text",
"dispatchEvent": "op_dispatch_event",
}
def __init__(self, server, frame: "FrameDispatcher", object_id: str,
@@ -773,6 +871,93 @@ class ElementHandleDispatcher(Dispatcher):
return {"value": _serialize(self.frame._call_on_elements(
self.frame.frame_id, [self.object_id], params))}
def op_evaluate_handle(self, params: Dict) -> Any:
"""`handle.evaluate_handle(fn, arg)`: `fn(element, arg)` in the
caller's world, as `op_evaluate`, and a HANDLE of what it returned
(`_handle_from_caller`, as the frame's `evaluate_handle`)."""
if self.world == "caller":
remote = _run_callers_code(
self.injected, self.frame.frame_id, params, [self.object_id],
by_value=False, objects=_object_lookup(self))
else:
remote = self.frame._call_on_elements(
self.frame.frame_id, [self.object_id], params, by_value=False)
return {"handle": self.frame._handle_from_caller(remote).channel}
# ── the queries and the state of THIS element ───────────────────────────
#
# ⛔ THE FRAME'S, WITH THE ELEMENT AS ROOT. A selector asked of a handle is
# looked for inside it (stock: `selectors.query(selector, options, this)`),
# which is the Frame's own query with a root: one definition of how a
# selector is resolved, entering frames included.
def op_query_selector(self, params: Dict) -> Any:
return self.frame._query_selector(params, root=self.object_id)
def op_query_selector_all(self, params: Dict) -> Any:
return self.frame._query_selector_all(params, root=self.object_id)
def op_eval_on_selector(self, params: Dict) -> Any:
return self.frame._eval_on_selector(params, root=self.object_id)
def op_eval_on_selector_all(self, params: Dict) -> Any:
return self.frame._eval_on_selector_all(params, root=self.object_id)
def _state(self, state: str, *, if_detached: Optional[bool] = None) -> bool:
"""The state of THIS node, read once and not waited for (stock's
`Frame._elementState` with `:scope`). A node that is not in the
document has none: Playwright's own error, or `if_detached` for the
state that is only a "no" (`isVisible`)."""
try:
return self.injected.element_state(
self.frame.frame_id, self.object_id, state)
except EvaluationError as failure:
if "error:notconnected" not in str(failure):
raise
if if_detached is None:
raise ProtocolException(_NOT_ATTACHED) from failure
return if_detached
def op_is_visible(self, params: Dict) -> Any:
return {"value": self._state("visible", if_detached=False)}
def op_is_hidden(self, params: Dict) -> Any:
return {"value": not self._state("visible", if_detached=False)}
def op_is_enabled(self, params: Dict) -> Any:
return {"value": self._state("enabled")}
def op_is_disabled(self, params: Dict) -> Any:
return {"value": self._state("disabled")}
def op_is_checked(self, params: Dict) -> Any:
return {"value": self._state("checked")}
def op_is_editable(self, params: Dict) -> Any:
return {"value": self._state("editable")}
def op_wait_for_element_state(self, params: Dict) -> Any:
"""Wait until THIS node is in `state`: the injected script's own
actionability check, asked again after 0, 20, 100, 100 and then 500 ms
(stock's `ElementHandle.waitForElementState` through `_retryAction`).
A node that left the document is not waited for: it never will be, and
stock says so at once."""
state = params["state"]
deadline = Deadline(self.frame._timeout(params))
turn = 0
while True:
verdict = self.injected.element_states(
self.frame.frame_id, self.object_id, [state])
if verdict.get("ok"):
return None
if verdict.get("missing") == "error:notconnected":
raise ProtocolException(_NOT_ATTACHED)
if deadline.passed():
raise TimeoutError(
"Timeout %dms exceeded waiting for the element to be %s"
% (round(deadline.seconds * 1000), state))
time.sleep(deadline.slice(_RETRY_WAITS[min(turn, len(_RETRY_WAITS) - 1)]))
turn += 1
def op_text_content(self, params: Dict) -> Any:
return {"value": self.injected.text_content(
self.frame.frame_id, self.object_id)}
@@ -977,6 +1162,30 @@ class ElementHandleDispatcher(Dispatcher):
**self._act_args(params))
return None
def op_dblclick(self, params: Dict) -> Any:
pointer = self.frame._pointer(params)
# dblclick sets its own clickCount; the caller's is not a second one.
pointer.pop("clicks", None)
self.frame.actions.dblclick(
_HANDLE, position=self.frame._position(params), **pointer,
**self._act_args(params))
return None
def op_tap(self, params: Dict) -> Any:
self.frame.actions.tap(_HANDLE, position=self.frame._position(params),
**self._act_args(params))
return None
def op_select_text(self, params: Dict) -> Any:
self.frame.actions.select_text(_HANDLE, **self._act_args(params))
return None
def op_dispatch_event(self, params: Dict) -> Any:
self.frame.actions.dispatch_event(
_HANDLE, params["type"], self.frame._event_init(params),
**self._act_args(params))
return None
def op_check(self, params: Dict) -> Any:
self.frame.actions.check(_HANDLE, position=self.frame._position(params),
**self._act_args(params))
@@ -1032,7 +1241,7 @@ class ElementHandleDispatcher(Dispatcher):
upload, not two.
"""
self.frame.actions.set_input_files(
_HANDLE, _upload_paths(self.server, params),
_HANDLE, _upload_paths(self.server, params, self.frame.page.context),
**self._act_args(params))
return None
@@ -1248,14 +1457,70 @@ class FrameDispatcher(Dispatcher):
return {"value": self.injected.content(self.frame_id)}
def op_query_selector(self, params: Dict) -> Any:
frame_id, selector = self.enter_frames(params["selector"])
object_id = self.injected.query_selector(frame_id, selector)
return self._query_selector(params)
def _query_selector(self, params: Dict, root: Optional[str] = None) -> Any:
"""`querySelector`, of the frame (`root` None: the document) or of an
element handle (`root`: its objectId, so the match is looked for
inside it, as stock's `FrameSelectors.query` with `scope`)."""
frame_id, selector = self._enter(params["selector"], root)
object_id = self._first(frame_id, selector, self._scope(frame_id, root),
self._act_opts(params)["strict"])
if not object_id:
return {"element": None}
handle = ElementHandleDispatcher(
self.server, self.page.frame_for(frame_id), object_id)
return {"element": handle.channel}
def _enter(self, selector: str, root: Optional[str]):
"""`enter_frames`, with `root` the element the selector is looked for
in (None: the document, and the call is the one a frame has always made)."""
if root is None:
return self.enter_frames(selector)
return self.enter_frames(selector, root=root)
def _scope(self, frame_id: str, root: Optional[str]) -> Optional[str]:
"""The root a selector's last chunk runs in: the element when the
selector stayed in the element's frame, none once it entered another
(stock's `resolveFrameForSelector`: `if (frame !== this.frame) scope =
undefined`)."""
return root if frame_id == self.frame_id else None
def _first(self, frame_id: str, selector: str, root: Optional[str] = None,
strict: bool = False) -> Optional[str]:
"""The objectId of the first match of `selector` in `frame_id`'s world
(a node the caller must dispose), inside `root` when there is one and
in the document when there is not. THE ONE PLACE a selector is
resolved with an element as root."""
if root is None:
return self.injected.query_selector(frame_id, selector)
return self.injected.call(frame_id, _QUERY_IN, {"objectId": root},
selector, strict, by_value=False)
def _all(self, frame_id: str, selector: str,
root: Optional[str] = None) -> List[str]:
"""Every match of `selector`, as objectIds the caller must dispose;
inside `root` when there is one. The list that held them is released
here."""
if root is None:
return self.injected.query_selector_all(frame_id, selector)
found = self.injected.call(frame_id, _QUERY_ALL_IN, {"objectId": root},
selector, by_value=False)
try:
# ⛔ THE ARRAY IS READ ONCE, whatever its length: the core's own
# `query_selector_all` asks for the length and then for each place
# (N + 2 commands for N matches), and `properties` is the engine's
# `Runtime.getObjectProperties`, which lists the places of the array
# with the object of each node. The places are named "0", "1", ...
# and are put in numeric order here, so "10" never comes before "2".
places = self.injected.properties(
self.injected.context_id(frame_id), found)
indexed = sorted((int(place["name"]), place["value"].get("objectId"))
for place in places if place["name"].isdigit())
return [object_id for _, object_id in indexed if object_id]
finally:
self.injected.dispose(frame_id, found)
def _read(self, params: Dict, what: str, *args) -> Any:
"""A read of the element `params["selector"]` names, as Playwright's
`_callOnElementOnceMatches` makes it: wait, within the caller's
@@ -1385,9 +1650,13 @@ class FrameDispatcher(Dispatcher):
# ⛔ frame-crossing selectors
ENTER_FRAME = " >> internal:control=enter-frame >> "
def enter_frames(self, selector: str):
def enter_frames(self, selector: str, root: Optional[str] = None):
"""`(frame_id, tail)` for a selector that crosses into an iframe.
`root` is the element an element handle looks inside: the owner of the
FIRST frame is looked for in it, and nothing after (stock's
`scope: i === 0 ? scope : undefined`).
⛔ THE HOP IS SERVER-SIDE, and that is not an implementation detail:
the injected script lives in ONE document and cannot reach inside an
iframe's - that is the same-origin boundary, not a missing feature. So
@@ -1408,7 +1677,8 @@ class FrameDispatcher(Dispatcher):
head, _, tail = selector.partition(self.ENTER_FRAME)
if not tail:
return frame.frame_id, head
owner = frame.page.injected.query_selector(frame.frame_id, head)
owner = frame._first(frame.frame_id, head, root)
root = None
if not owner:
raise ProtocolException(
"the frame owner %r matched nothing, so there is nothing "
@@ -1658,13 +1928,17 @@ class FrameDispatcher(Dispatcher):
def op_set_input_files(self, params: Dict) -> Any:
frame_id, selector = self.enter_frames(params["selector"])
self.actions.set_input_files(selector,
_upload_paths(self.server, params),
_upload_paths(self.server, params, self.page.context),
timeout=self._timeout(params),
frame_id=frame_id,
**self._act_opts(params))
return None
def op_tap(self, params: Dict) -> Any:
# Stock's `Frame.tap` opens with this refusal (the handle's `tap` has none): without touch the page has no `ontouchstart` to hear it, so a tap that went on would answer success and do nothing.
if not self.page.context.options.get("hasTouch"):
raise ProtocolException(
"The page does not support tap. Use hasTouch context option to enable touch support.")
frame_id, selector = self.enter_frames(params["selector"])
self._by_hand(params, frame_id, selector,
lambda position, timeout: self.actions.tap(
@@ -1674,25 +1948,33 @@ class FrameDispatcher(Dispatcher):
def op_dispatch_event(self, params: Dict) -> Any:
frame_id, selector = self.enter_frames(params["selector"])
# ⛔ THE ARGUMENT ARRIVES IN PLAYWRIGHT'S SERIALISED ENVELOPE, not as
# a plain value: `{"value": {...}, "handles": []}`. Passing it through
# is rejected by Juggler's closed-world schema with `Found property
# "<root>.args[3].handles" - [] which is not described in this scheme`,
# and the message names a field the caller never wrote. Nothing to do
# with frames: it failed on the main frame too, and only an iframe test
# happened to exercise it.
# ⛔ A HANDLE IN THE INIT IS REFUSED, NOT SENT AS null: the event is built
# in the utility world by the core, where the handle's object does not
# exist (stock takes it to the page's own world).
refuse_handles(params.get("eventInit"), "dispatch_event's eventInit",
"the utility world, through the core")
self.actions.dispatch_event(
selector, params["type"],
_deserialize(params.get("eventInit")) or {},
selector, params["type"], self._event_init(params),
timeout=self._timeout(params), frame_id=frame_id,
**self._act_opts(params))
return None
@staticmethod
def _event_init(params: Dict) -> Dict:
"""The `eventInit` of a `dispatchEvent`, as the plain dictionary the
core builds the event from. THE ONE PLACE it is read, for a frame's
selector and for an element handle.
⛔ THE ARGUMENT ARRIVES IN PLAYWRIGHT'S SERIALISED ENVELOPE, not as a
plain value: `{"value": {...}, "handles": []}`. Passing it through is
rejected by Juggler's closed-world schema with `Found property
"<root>.args[3].handles" - [] which is not described in this scheme`,
and the message names a field the caller never wrote. Nothing to do
with frames: it failed on the main frame too, and only an iframe test
happened to exercise it.
⛔ A HANDLE IN THE INIT IS REFUSED, NOT SENT AS null: the event is built
in the utility world by the core, where the handle's object does not
exist (stock takes it to the page's own world)."""
refuse_handles(params.get("eventInit"), "dispatch_event's eventInit",
"the utility world, through the core")
return _deserialize(params.get("eventInit")) or {}
def op_drag_and_drop(self, params: Dict) -> Any:
self.actions.drag_and_drop(params["source"], params["target"],
timeout=self._timeout(params),
@@ -1758,7 +2040,8 @@ class FrameDispatcher(Dispatcher):
return {"element": handle.channel}
def _call_on_elements(self, frame_id: str, elements: List[str],
params: Dict, *, as_array: bool = False) -> Any:
params: Dict, *, as_array: bool = False,
by_value: bool = True) -> Any:
"""The caller's code on elements this server holds in the utility
world, run in the caller's world by `_run_callers_code` with the
elements as its receivers, or as ONE array of them (`as_array`, for
@@ -1774,7 +2057,11 @@ class FrameDispatcher(Dispatcher):
node, in the other world) and the copies are released after the call.
The caller's code is sent once ([B285]); finding the elements is this
package's read, made before it. The caller's code never sees this
package's script."""
package's script.
`by_value=False` answers the engine's RemoteObject of what the code
returned instead of its value, for `_handle_from_caller`
(`evaluate_handle` of an element handle)."""
context = self.injected.caller_context(frame_id)
adopted: List[str] = []
array: Optional[str] = None
@@ -1782,7 +2069,7 @@ class FrameDispatcher(Dispatcher):
for element in elements:
copy = self.injected.node_to_caller(frame_id, element)
if not copy:
raise ProtocolException("Element is not attached to the DOM")
raise ProtocolException(_NOT_ATTACHED)
adopted.append(copy)
receivers = adopted
if as_array:
@@ -1790,9 +2077,10 @@ class FrameDispatcher(Dispatcher):
context, _ARRAY, [{"objectId": a} for a in adopted],
by_value=False)["objectId"]
receivers = [array]
return _remote_value(_run_callers_code(
self.injected, frame_id, params, receivers, by_value=True,
objects=_object_lookup(self)))
remote = _run_callers_code(
self.injected, frame_id, params, receivers, by_value=by_value,
objects=_object_lookup(self))
return _remote_value(remote) if by_value else remote
finally:
if array:
self.injected.release(context, array)
@@ -2241,23 +2529,31 @@ class FrameDispatcher(Dispatcher):
return {"value": self.injected.count(frame_id, selector)}
def op_query_selector_all(self, params: Dict) -> Any:
frame_id, selector = self.enter_frames(params["selector"])
return self._query_selector_all(params)
def _query_selector_all(self, params: Dict, root: Optional[str] = None) -> Any:
frame_id, selector = self._enter(params["selector"], root)
target = self.page.frame_for(frame_id)
ids = self.injected.query_selector_all(frame_id, selector)
ids = self._all(frame_id, selector, self._scope(frame_id, root))
handles = [ElementHandleDispatcher(self.server, target, oid)
for oid in ids]
return {"elements": [h.channel for h in handles]}
def op_eval_on_selector(self, params: Dict) -> Any:
return self._eval_on_selector(params)
def _eval_on_selector(self, params: Dict, root: Optional[str] = None) -> Any:
"""`page.eval_on_selector`: ONE attempt, as Playwright's `$eval`. It
does not wait, and an element that is not there is an error; a frame
that navigates between the query and the call is `ContextDestroyed`,
which says so in Playwright's words."""
frame_id, selector = self.enter_frames(params["selector"])
object_id = self.injected.query_selector(frame_id, selector)
which says so in Playwright's words. With `root` (an element handle's
`eval_on_selector`) the match is looked for inside that element."""
frame_id, selector = self._enter(params["selector"], root)
object_id = self._first(frame_id, selector, self._scope(frame_id, root),
self._act_opts(params)["strict"])
if not object_id:
raise ProtocolException(
"failed to find element matching selector %r" % selector)
'Failed to find element matching selector "%s"' % params["selector"])
try:
return {"value": _serialize(self._call_on_elements(
frame_id, [object_id], params))}
@@ -2280,11 +2576,15 @@ class FrameDispatcher(Dispatcher):
return {"value": self.injected.read_all(frame_id, selector, what)}
def op_eval_on_selector_all(self, params: Dict) -> Any:
return self._eval_on_selector_all(params)
def _eval_on_selector_all(self, params: Dict, root: Optional[str] = None) -> Any:
"""`page.eval_on_selector_all`: the caller's function, sent ONCE. A
frame that navigates under it is `ContextDestroyed`, as Playwright
raises; sending it again ran it twice ([B285])."""
frame_id, selector = self.enter_frames(params["selector"])
ids = self.injected.query_selector_all(frame_id, selector)
raises; sending it again ran it twice ([B285]). With `root` the
matches are looked for inside that element."""
frame_id, selector = self._enter(params["selector"], root)
ids = self._all(frame_id, selector, self._scope(frame_id, root))
try:
return {"value": _serialize(self._call_on_elements(
frame_id, ids, params, as_array=True))}
@@ -3800,11 +4100,21 @@ class PageDispatcher(Dispatcher):
a field, which is the shape of thing that is right until the first
`<input multiple>`.
"""
def dropped(why: str) -> None:
# ⛔ A CHOOSER THAT CANNOT BE ANNOUNCED LEAVES A TRACE, whatever the reason. The client waits for an event nobody will send and ends on
# its own timeout, saying nothing of why; `handler_errors` is where this repository keeps a dropped event (the adoption of a
# target does the same), and the four exits below were bare `return`s: the only ones of this function that left nothing.
conn = self.conn
if len(conn.handler_errors) < 32:
conn.handler_errors.append("fileChooser: %s" % why)
try:
element = params.get("element") or {}
object_id = element.get("objectId")
context_id = params.get("executionContextId")
if not object_id or not context_id:
dropped("the engine's event names no %s: %r" % (
"element" if not object_id else "execution context", params))
return
frame_id = self.injected.frame_of_context(context_id)
if not frame_id:
@@ -3812,9 +4122,11 @@ class PageDispatcher(Dispatcher):
# the wrong frame's world answers about a different document.
# Saying nothing loses the event; saying the wrong thing loses
# the trust in every event.
dropped("execution context %s belongs to no frame this page knows" % context_id)
return
adopted = self.injected.adopt(frame_id, object_id)
if not adopted:
dropped("the input %s could not be adopted into frame %s" % (object_id, frame_id))
return
frame = self.frame_for(frame_id)
handle = ElementHandleDispatcher(self.server, frame, adopted,
@@ -3825,9 +4137,7 @@ class PageDispatcher(Dispatcher):
self.emit("fileChooser", {"element": handle.channel,
"isMultiple": multiple})
except Exception as failure:
conn = self.conn
if len(conn.handler_errors) < 32:
conn.handler_errors.append("fileChooser: %s" % failure)
dropped(str(failure))
def frame_for(self, frame_id: str) -> "FrameDispatcher":
"""The dispatcher for a frame of this page, made on first sight.
@@ -4654,6 +4964,71 @@ class StreamDispatcher(Dispatcher):
pass
class WritableStreamDispatcher(Dispatcher):
"""One file a remote client copies INTO this machine: what `set_input_files` with a path does over `connect`.
A stock client on a remote connection cannot hand the server a path (it is a path of ITS disk): `createTempFiles` made one of these per
file, the client sends the bytes in `write` chunks (base64) and ends with `close`, and the upload then names the stream
(`_upload_paths`, `streams`). The file is in the call's folder (`BrowserContextDispatcher.op_create_temp_files`), under the name
the client gave, and `close` sets its mtime to the client's `lastModifiedMs`, which is what the page reads as `File.lastModified`.
⛔ CLOSED IS FINAL. A `write` after `close`, or a second `close`, is refused by name: the file is what the page may already be reading, and
an `open(..., "wb")` again would empty it. The folder is NOT this object's to remove (a stream that the registry lets go of, by its
bucket's limit, must not take the file from an input that holds it): it closes the handle, and the context removes the folder.
"""
TYPE = "WritableStream"
METHODS = {"write": "op_write", "close": "op_close"}
def __init__(self, server, parent, path: str, last_modified_ms: Any) -> None:
self.path = path
self._last_modified_ms = last_modified_ms
self._io = threading.Lock()
self._state = "open"
self._file = open(path, "wb")
super().__init__(server, parent, {})
@property
def closed(self) -> bool:
return self._state == "closed"
def op_write(self, params: Dict) -> Any:
try:
chunk = base64.b64decode(params.get("binary") or "", validate=True)
except (ValueError, TypeError) as bad:
raise ProtocolException("a chunk of a streamed file is base64, and this one is not: %s" % bad)
with self._io:
if self._state != "open":
raise ProtocolException("the stream of %r is closed: a file is written once" % os.path.basename(self.path))
self._file.write(chunk)
return None
def op_close(self, params: Dict) -> Any:
with self._io:
if self._state != "open":
raise ProtocolException("the stream of %r is closed already" % os.path.basename(self.path))
self._file.close()
self._state = "closed"
if self._last_modified_ms is not None:
stamp = int(self._last_modified_ms) * 1_000_000
os.utime(self.path, ns=(stamp, stamp))
return None
def release_file(self) -> None:
"""Let go of the open handle, and of nothing else: a Windows folder cannot be removed while a file of it is open."""
with self._io:
if self._state == "open":
self._state = "abandoned"
try:
self._file.close()
except Exception:
pass
def released(self) -> None:
"""⛔ ALSO WHEN A PARENT'S DISPOSE FORGETS IT (a client that drops in the middle of the copy: its context closes and the stream goes with it)."""
self.release_file()
class ArtifactDispatcher(Dispatcher):
"""One download, as Playwright's server has it (`server/artifact.ts`).
@@ -4758,11 +5133,15 @@ class BrowserContextDispatcher(Dispatcher):
"setStorageState": "op_set_storage_state",
"setNetworkInterceptionPatterns": "op_set_interception",
"setWebSocketInterceptionPatterns": "op_set_ws_interception",
"createTempFiles": "op_create_temp_files",
}
def __init__(self, server, browser: "BrowserDispatcher", options: Dict,
context_id: Optional[str]) -> None:
self.browser = browser
#: The folders of this context's `createTempFiles` calls, removed when it ends (`released`).
self._upload_folders: List[str] = []
self._upload_folders_lock = threading.Lock()
self.options = options
#: `None` is the DEFAULT context - userContextId 0, the one whose
#: cookies and storage are the profile's. It is what a persistent
@@ -4860,6 +5239,61 @@ class BrowserContextDispatcher(Dispatcher):
forget = getattr(self.browser, "_forget_downloads_of", None)
if forget is not None:
forget(self.context_id)
self._remove_upload_folders()
def op_create_temp_files(self, params: Dict) -> Any:
"""The streams a client on a remote connection copies its files into (`set_input_files` with a path, over `connect`).
The answer is the stock server's (`BrowserContext.createTempFiles`, playwright 1.61.0): `writableStreams`, one per item and in the item's order,
and `rootDir` only when the client named a folder - which is refused here, as `set_input_files` refuses a folder everywhere.
⛔ ONE NEW FOLDER PER CALL, in the session's upload area (the one `stage_upload` uses), and one file per item in it, under the name the client
gave (the page reads it as `File.name`; a second call with the same name must not overwrite the first, which an input may still hold).
EVERY NAME IS CHECKED BEFORE ANYTHING IS MADE: a refused call leaves no folder.
⛔ THE FOLDER LIVES AS LONG AS THIS CONTEXT, not as long as the call: a page reads an uploaded file when it submits it, which can be minutes
after `set_input_files` returned. It goes in `released`, which every end of a context passes - its own `close`, and the close that
`RemoteEndpoint._client_gone` does for a client that dropped in the middle of a copy.
"""
if params.get("rootDirName"):
raise _folder_refused(params["rootDirName"])
items = params.get("items") or []
names = [_upload_file_name(item.get("name")) for item in items]
for n, name in enumerate(names):
if name in names[:n]:
raise ProtocolException(
"two files of one upload have the same name (%r): the page would read one of them twice" % name)
folder = tempfile.mkdtemp(dir=self.server.upload_root())
with self._upload_folders_lock:
self._upload_folders.append(folder)
streams: List[WritableStreamDispatcher] = []
try:
for name, item in zip(names, items):
streams.append(WritableStreamDispatcher(self.server, self, os.path.join(folder, name), item.get("lastModifiedMs")))
except Exception:
for stream in streams:
stream.release_file()
self._remove_upload_folders(folders=[folder])
raise
return {"writableStreams": [stream.channel for stream in streams]}
def _remove_upload_folders(self, folders: Optional[List[str]] = None) -> None:
"""Remove the folders of `createTempFiles` calls - all of them, or the ones named - after closing the files still open in them.
⛔ THE HANDLES FIRST: this runs before the registry lets go of the streams (`Dispatcher.dispose` calls the parent's `released` first), and a
Windows folder with an open file in it does not go. Closing all the context's streams is for the end of the context; a call that failed
half way closes its own (`op_create_temp_files`).
"""
with self._upload_folders_lock:
ending = folders is None
folders = list(self._upload_folders) if ending else folders
self._upload_folders = [f for f in self._upload_folders if f not in folders]
if ending:
for stream in self.server.descendants_of(self):
if isinstance(stream, WritableStreamDispatcher):
stream.release_file()
for folder in folders:
remove_profile(folder)
def op_context_init_script(self, params: Dict) -> Any:
"""The same, for every page of this context - present and future.
@@ -6476,16 +6910,36 @@ class JugglerServer(Server):
if not name:
raise ProtocolException(
"a file payload needs a name: the page reads it as File.name")
root = getattr(self, "_upload_root", None)
if root is None:
root = tempfile.mkdtemp(prefix="invisible_upload_")
self._upload_root = root
self.after_reapers(lambda: remove_profile(root))
path = os.path.join(tempfile.mkdtemp(dir=root), name)
path = os.path.join(tempfile.mkdtemp(dir=self.upload_root()), name)
with open(path, "wb") as out:
out.write(base64.b64decode(payload.get("buffer") or ""))
return path
#: Guards the making of the upload area: two uploads that arrive together on a new session must find ONE folder.
_upload_lock = threading.Lock()
def upload_root(self) -> str:
"""The folder this session stages every uploaded file in (a payload, a stream of `createTempFiles`), made on first use and removed with the session.
ONE AREA, ONE OWNER OF ITS END: `after_reapers` removes it when the session ends. What a context made inside it (the folder of a
`createTempFiles` call) it removes itself, when it closes (`BrowserContextDispatcher.released`).
"""
with self._upload_lock:
root = getattr(self, "_upload_root", None)
if root is None:
root = tempfile.mkdtemp(prefix="invisible_upload_")
self._upload_root = root
self.after_reapers(lambda: self._remove_upload_root(root))
return root
def _remove_upload_root(self, root: str) -> None:
"""The end of the session: the files a client was still copying are closed first (a Windows folder with an open file in it does not go)."""
with self._lock:
streams = [o for o in self._objects.values() if isinstance(o, WritableStreamDispatcher)]
for stream in streams:
stream.release_file()
remove_profile(root)
def handle_root(self, method: str, params: Dict) -> Any:
name = self.METHODS.get(method)
if name is None:
+2 -17
View File
@@ -4,23 +4,7 @@
{"channel": "BrowserContext", "method": "registerSelectorEngine", "reason": "The client's Selectors.register sends it to every BrowserContext; server.py serves it on FrameDispatcher only, and BrowserContextDispatcher.METHODS has no entry for it."},
{"channel": "BrowserContext", "method": "setExtraHTTPHeaders", "reason": "BrowserContextDispatcher.METHODS routes it to a handler that raises ProtocolException first, and perimeter.NOT_WIRED_YET names it: not written yet."},
{"channel": "BrowserContext", "method": "setTestIdAttributeName", "reason": "The client's Selectors.set_test_id_attribute sends it to every BrowserContext; server.py serves it on FrameDispatcher only, and BrowserContextDispatcher.METHODS has no entry for it."},
{"channel": "ElementHandle", "method": "dblclick", "reason": "ElementHandleDispatcher.METHODS has no entry for it and perimeter.py does not name it: the client's ElementHandle sends it and the server answers that it is a gap."},
{"channel": "ElementHandle", "method": "dispatchEvent", "reason": "ElementHandleDispatcher.METHODS has no entry for it and perimeter.py does not name it: the client's ElementHandle sends it and the server answers that it is a gap."},
{"channel": "ElementHandle", "method": "evalOnSelector", "reason": "ElementHandleDispatcher.METHODS has no entry for it and perimeter.py does not name it: the client's ElementHandle sends it and the server answers that it is a gap."},
{"channel": "ElementHandle", "method": "evalOnSelectorAll", "reason": "ElementHandleDispatcher.METHODS has no entry for it and perimeter.py does not name it: the client's ElementHandle sends it and the server answers that it is a gap."},
{"channel": "ElementHandle", "method": "evaluateExpressionHandle", "reason": "ElementHandleDispatcher.METHODS has no entry for it and perimeter.py does not name it: the client's ElementHandle sends it and the server answers that it is a gap."},
{"channel": "ElementHandle", "method": "isChecked", "reason": "ElementHandleDispatcher.METHODS has no entry for it and perimeter.py does not name it: the client's ElementHandle sends it and the server answers that it is a gap."},
{"channel": "ElementHandle", "method": "isDisabled", "reason": "ElementHandleDispatcher.METHODS has no entry for it and perimeter.py does not name it: the client's ElementHandle sends it and the server answers that it is a gap."},
{"channel": "ElementHandle", "method": "isEditable", "reason": "ElementHandleDispatcher.METHODS has no entry for it and perimeter.py does not name it: the client's ElementHandle sends it and the server answers that it is a gap."},
{"channel": "ElementHandle", "method": "isEnabled", "reason": "ElementHandleDispatcher.METHODS has no entry for it and perimeter.py does not name it: the client's ElementHandle sends it and the server answers that it is a gap."},
{"channel": "ElementHandle", "method": "isHidden", "reason": "ElementHandleDispatcher.METHODS has no entry for it and perimeter.py does not name it: the client's ElementHandle sends it and the server answers that it is a gap."},
{"channel": "ElementHandle", "method": "isVisible", "reason": "ElementHandleDispatcher.METHODS has no entry for it and perimeter.py does not name it: the client's ElementHandle sends it and the server answers that it is a gap."},
{"channel": "ElementHandle", "method": "querySelector", "reason": "ElementHandleDispatcher.METHODS has no entry for it and perimeter.py does not name it: the client's ElementHandle sends it and the server answers that it is a gap."},
{"channel": "ElementHandle", "method": "querySelectorAll", "reason": "ElementHandleDispatcher.METHODS has no entry for it and perimeter.py does not name it: the client's ElementHandle sends it and the server answers that it is a gap."},
{"channel": "ElementHandle", "method": "selectText", "reason": "ElementHandleDispatcher.METHODS has no entry for it and perimeter.py does not name it: the client's ElementHandle sends it and the server answers that it is a gap."},
{"channel": "ElementHandle", "method": "tap", "reason": "ElementHandleDispatcher.METHODS has no entry for it and perimeter.py does not name it: the client's ElementHandle sends it and the server answers that it is a gap."},
{"channel": "ElementHandle", "method": "waitForElementState", "reason": "ElementHandleDispatcher.METHODS has no entry for it and perimeter.py does not name it: the client's ElementHandle sends it and the server answers that it is a gap."},
{"channel": "ElementHandle", "method": "waitForSelector", "reason": "ElementHandleDispatcher.METHODS has no entry for it and perimeter.py does not name it: the client's ElementHandle sends it and the server answers that it is a gap."},
{"channel": "ElementHandle", "method": "waitForSelector", "reason": "ElementHandleDispatcher.METHODS has no entry for it: the wait for a selector INSIDE an element needs invisible_core's Actions.wait_for_selector (and the InjectedScript.query_selector it polls with) to take a root element, and both look in the document only; the client's ElementHandle sends it and the server answers that it is a gap."},
{"channel": "Page", "method": "setExtraHTTPHeaders", "reason": "PageDispatcher.METHODS has no entry for it; perimeter.NOT_WIRED_YET names it (not written yet), and the BrowserContext handler of the same name refuses."},
{"channel": "Page", "method": "setWebSocketInterceptionPatterns", "reason": "PageDispatcher.METHODS has no entry for it and perimeter.refusal does not name it; BrowserContextDispatcher refuses the same method (NO_ENGINE_COMMAND), so page.route_web_socket() answers 'a gap' instead of a decision."},
{"channel": "WebSocket", "method": "*", "reason": "The server never creates a WebSocket object (no dispatcher with that TYPE) and no refused method is its creator: the page 'websocket' event never fires."},
@@ -29,6 +13,7 @@
{"channel": "Worker", "method": "updateSubscription", "reason": "The server never creates a Worker object (no dispatcher with that TYPE): the console subscription of a worker cannot be reached."}
],
"partial": [
{"channel": "BrowserContext", "method": "createTempFiles", "detail": "two items with one name", "witness": "two files of one upload have the same name", "reason": "A wanted divergence: stock writes both items into one file of the call's folder, so the input would read one of them twice; refused with a clear error instead."},
{"channel": "BrowserContext", "method": "setStorageState", "detail": "per-origin localStorage", "witness": "set_storage_state() with per-origin localStorage is not", "reason": "Only the cookies of a storage state are restored; a state with origins is refused rather than half restored."},
{"channel": "Frame", "method": "expect", "detail": "to.have.property with an object", "witness": "expect('to.have.property') with an object, an array or a date", "reason": "The page's value is read from the utility world, in another realm than the expected value, so a structured comparison would always say it differs: refused; primitives are compared."},
{"channel": "Frame", "method": "expect", "detail": "to.match.aria", "witness": "expect('to.match.aria') is not implemented yet", "reason": "The expected template is YAML that Playwright's server parses into a tree and this server has no parser: _expect_probe refuses it by name."}
@@ -0,0 +1,83 @@
"""A file chooser the server cannot announce leaves a trace: it is never dropped in silence.
`PageDispatcher._announce_file_chooser` turns the engine's `Page.fileChooserOpened` into the client's `fileChooser`. Four of its exits are a bare
`return`: no objectId in the element, no executionContextId, a context that belongs to no known frame, a node the engine could not adopt. The
client then waits for an event nobody will send and dies on its own timeout, and nothing says why. Every other failure of the same function is
written to `conn.handler_errors` (the place the repository keeps a dropped event: the adoption of a target does the same), and so must these.
No browser: the method is run on a stand-in of the page with a stand-in of the injected script, and what a caller can observe is read:
`conn.handler_errors` (the trace) and the `fileChooser` events emitted (none, in every case here).
Known-bad input: the four bare `return`s -> `handler_errors` stays empty. The control (the adoption RAISING) is the one exit that already
leaves a trace, and proves that the observation reads the right place.
"""
from __future__ import annotations
from types import SimpleNamespace
import pytest
from invisible_playwright._juggler.server import PageDispatcher
pytestmark = pytest.mark.unit
CONTEXT = "ctx-1"
FRAME = "frame-1"
ELEMENT = {"objectId": "input-1"}
def _page(frame_of_context=FRAME, adopt=None, adopt_raises=None):
emitted = []
def adopt_in(frame_id, object_id):
if adopt_raises is not None:
raise adopt_raises
return adopt
injected = SimpleNamespace(frame_of_context=lambda context_id: frame_of_context, adopt=adopt_in)
page = SimpleNamespace(conn=SimpleNamespace(handler_errors=[]), injected=injected,
emit=lambda method, params=None: emitted.append((method, params)))
return page, emitted
def _announce(page, params):
PageDispatcher._announce_file_chooser(page, params)
def _traced(page):
return [e for e in page.conn.handler_errors if "fileChooser" in str(e)]
def test_a_chooser_without_an_object_id_leaves_a_trace():
page, emitted = _page()
_announce(page, {"element": {}, "executionContextId": CONTEXT})
assert emitted == []
assert _traced(page), "the chooser was dropped in silence: no objectId, and handler_errors is %r" % (page.conn.handler_errors,)
def test_a_chooser_without_an_execution_context_leaves_a_trace():
page, emitted = _page()
_announce(page, {"element": ELEMENT})
assert emitted == []
assert _traced(page), "the chooser was dropped in silence: no executionContextId, and handler_errors is %r" % (page.conn.handler_errors,)
def test_a_chooser_in_a_context_of_no_known_frame_leaves_a_trace():
page, emitted = _page(frame_of_context=None)
_announce(page, {"element": ELEMENT, "executionContextId": CONTEXT})
assert emitted == []
assert _traced(page), "the chooser was dropped in silence: context %s belongs to no frame, and handler_errors is %r" % (CONTEXT, page.conn.handler_errors)
def test_a_chooser_whose_node_cannot_be_adopted_leaves_a_trace():
page, emitted = _page(adopt=None)
_announce(page, {"element": ELEMENT, "executionContextId": CONTEXT})
assert emitted == []
assert _traced(page), "the chooser was dropped in silence: the adoption answered nothing, and handler_errors is %r" % (page.conn.handler_errors,)
def test_control_a_chooser_whose_adoption_raises_already_leaves_a_trace():
page, emitted = _page(adopt_raises=RuntimeError("no such context"))
_announce(page, {"element": ELEMENT, "executionContextId": CONTEXT})
assert emitted == []
assert _traced(page) == ["fileChooser: no such context"]
@@ -0,0 +1,275 @@
"""Which path loses the `filechooser` event: a matrix that tells the candidates apart.
A user with a STOCK Playwright client on a served browser reported that
`page.set_content("<input type=file>")`, a direct click on the input and `expect_file_chooser` never fires.
`tests/test_file_chooser.py` is in-process only and clicks a button whose script calls `input.click()`, so nothing
here says whether the event is lost by the client, by the served mode, by the order of the subscription and the click,
or whether the event comes and only the upload is refused. Each test below changes ONE thing and fails with a message
that says WHAT was lost:
LOST the `filechooser` event never reached the client within the deadline;
UPLOAD the event came and `set_files` failed (the error is in the message);
EMPTY `set_files` answered and the input holds no file.
Nothing is slept on: `expect_file_chooser(timeout=30_000)` waits on the event (the deadline of the whole suite), the
handler form waits with `wait_until` on a condition.
WHAT THE STOCK CLIENT SENDS OVER `connect` (playwright 1.61.0, `playwright/_impl/_set_input_files_helpers.py`,
`convert_input_files`):
* a PATH (str / Path): the branch `context._channel._connection.is_remote` (`connect` marks the connection remote)
streams the file: `createTempFiles` on the context, then `WritableStream.copy` per file, then `setInputFiles`
with `streams`. The server serves `createTempFiles` and the `WritableStream` it makes (`BrowserContextDispatcher.op_create_temp_files`,
`WritableStreamDispatcher`), and `_upload_paths` (`server.py`) reads the `streams` as the closed files of the session. Test 8 reads
what the page sees of such a file: its name, size, `lastModified` and bytes.
* an in-memory payload `{"name", "mimeType", "buffer"}`: the branch after the path one, no `createTempFiles`:
`setInputFiles` with `payloads` (base64), which `_upload_paths` stages as a file of the session.
Tests 3 to 7 say that the chooser is carried to a remote client and what its upload does; test 8 says what the page reads of a streamed file.
The red tests name the path that loses the event.
"""
from __future__ import annotations
import base64
import importlib
import os
import pytest
from _waits import wait_until
pytestmark = pytest.mark.e2e
DEADLINE_MS = 30_000
FILE_NAME = "chooser-probe.txt"
FILE_BYTES = b"hello chooser"
PAGE = "<!doctype html><title>t</title><input type=file>"
READ = "() => { const f = document.querySelector('input').files; return f.length ? [f[0].name, f[0].size] : null; }"
FRESH_PAGES = 5
MANY = "<!doctype html><title>t</title><input type=file multiple>"
#: What a page reads of each file: the name, the size, `lastModified` and the bytes (base64), the four things a site can compare with what the user picked.
READ_ALL = """async () => {
const out = [];
for (const f of document.querySelector('input').files) {
const bytes = new Uint8Array(await f.arrayBuffer());
let binary = '';
for (let i = 0; i < bytes.length; i += 8192) binary += String.fromCharCode.apply(null, bytes.subarray(i, i + 8192));
out.push({name: f.name, size: f.size, lastModified: f.lastModified, base64: btoa(binary)});
}
return out;
}"""
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
# What every test uses
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
@pytest.fixture
def probe_file(tmp_path):
path = tmp_path / FILE_NAME
path.write_bytes(FILE_BYTES)
return path
def _stock_playwright():
try: # the stock client (a pinned dev dependency), imported by name: the fork's guard forbids a static import
return importlib.import_module("playwright.sync_api").sync_playwright
except ImportError as exc:
pytest.fail("the stock Playwright client is missing (%s): install the wrapper with its dev extra" % exc, pytrace=False)
@pytest.fixture(scope="module")
def served(firefox_binary):
from invisible_playwright._juggler.remote import launch_server
server = launch_server(headless=True, binary_path=firefox_binary, locale="en-US", timezone="Europe/Rome")
try:
yield server
finally:
server.close()
@pytest.fixture
def stock_browser(served):
"""The stock client connected to the served browser, closed after the test (the served browser stays)."""
with _stock_playwright()() as p:
browser = p.firefox.connect(served.ws_endpoint)
try:
yield browser
finally:
browser.close()
@pytest.fixture
def in_process_browser(firefox_binary):
from invisible_playwright import InvisiblePlaywright
with InvisiblePlaywright(seed=4271, binary_path=firefox_binary, headless=True) as browser:
yield browser
def _lost(where):
pytest.fail("LOST: the `filechooser` event never reached the client within %d s (%s)" % (DEADLINE_MS // 1000, where), pytrace=False)
def _chooser_after(page, click, where):
"""Click, and wait on the event. A failure of the click is not a lost event, and says so."""
clicked = []
try:
with page.expect_file_chooser(timeout=DEADLINE_MS) as info:
click()
clicked.append(True)
except Exception as failure:
if not clicked:
pytest.fail("the click itself failed before any event could come (%s): %s: %s" % (where, type(failure).__name__, failure), pytrace=False)
_lost("%s; the wait said %s: %s" % (where, type(failure).__name__, failure))
return info.value
def _chooser_by_handler(page, click, where):
"""The `page.on("filechooser")` form: the handler is registered, then the click, then a wait on the condition."""
heard = []
def on_chooser(chooser): # a Python function: the client wraps the handler it is given, and a bound `list.append` has nowhere to hold the wrapper
heard.append(chooser)
page.on("filechooser", on_chooser)
click()
if not wait_until(lambda: heard, DEADLINE_MS // 1000, lambda: page.wait_for_timeout(100)):
_lost("%s, handler form" % where)
return heard[0]
def _upload(chooser, files, where):
try:
chooser.set_files(files, timeout=DEADLINE_MS)
except Exception as failure:
pytest.fail("UPLOAD: the event came and set_files failed (%s): %s: %s" % (where, type(failure).__name__, failure), pytrace=False)
def _the_input_holds_the_file(page, where):
held = page.evaluate(READ)
assert held is not None, "EMPTY: set_files answered (%s) and the input holds no file" % where
assert list(held) == [FILE_NAME, len(FILE_BYTES)], "WRONG FILE: the input holds %r (%s), expected %r" % (held, where, [FILE_NAME, len(FILE_BYTES)])
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
# 1-2. Our own client, in process: the control. Green here and red below puts the loss on the served path.
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
def test_1_in_process_a_direct_click_on_the_input_gives_a_chooser_that_uploads(in_process_browser, probe_file):
page = in_process_browser.new_page()
page.set_content(PAGE)
chooser = _chooser_after(page, lambda: page.click("input"), "in process, expect_file_chooser")
_upload(chooser, str(probe_file), "in process, a path")
_the_input_holds_the_file(page, "in process, a path")
def test_2_in_process_the_filechooser_handler_hears_a_direct_click_on_the_input(in_process_browser, probe_file):
page = in_process_browser.new_page()
page.set_content(PAGE)
chooser = _chooser_by_handler(page, lambda: page.click("input"), "in process")
_upload(chooser, str(probe_file), "in process, a path, handler form")
_the_input_holds_the_file(page, "in process, a path, handler form")
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
# 3-6. A served browser and a STOCK client.
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
def test_3_served_with_a_stock_client_expect_file_chooser_then_a_path_uploads(stock_browser, probe_file):
page = stock_browser.new_context().new_page()
page.set_content(PAGE)
chooser = _chooser_after(page, lambda: page.click("input"), "served + stock client, expect_file_chooser")
_upload(chooser, str(probe_file), "served + stock client, a path (createTempFiles)")
_the_input_holds_the_file(page, "served + stock client, a path")
def test_4_served_with_a_stock_client_the_filechooser_handler_hears_the_click(stock_browser, probe_file):
page = stock_browser.new_context().new_page()
page.set_content(PAGE)
chooser = _chooser_by_handler(page, lambda: page.click("input"), "served + stock client")
_upload(chooser, str(probe_file), "served + stock client, a path (createTempFiles), handler form")
_the_input_holds_the_file(page, "served + stock client, a path, handler form")
def test_5_served_with_a_stock_client_the_event_alone_comes_with_the_input_element(stock_browser):
"""The event and nothing else: no `set_files`. Red here is a lost EVENT; green here and red in test 3 is a refused UPLOAD."""
page = stock_browser.new_context().new_page()
page.set_content(PAGE)
chooser = _chooser_after(page, lambda: page.click("input"), "served + stock client, event only")
assert chooser.page is page, "the chooser belongs to another page"
described = chooser.element.evaluate("e => e.tagName + ':' + e.type")
assert described == "INPUT:file", "the chooser's element is %r, not the input" % described
assert chooser.is_multiple() is False, "the chooser says a single-file input takes several files"
def test_6a_served_with_a_stock_client_set_files_with_a_path_streams_through_create_temp_files(stock_browser, probe_file):
"""A path over `connect` is the streamed branch (`createTempFiles`), which the perimeter refuses: the message names what came back."""
page = stock_browser.new_context().new_page()
page.set_content(PAGE)
chooser = _chooser_after(page, lambda: page.click("input"), "served + stock client, path form")
_upload(chooser, str(probe_file), "served + stock client, a path: createTempFiles + streams")
_the_input_holds_the_file(page, "served + stock client, a path")
def test_6b_served_with_a_stock_client_set_files_with_an_in_memory_payload_avoids_create_temp_files(stock_browser):
"""A payload over `connect` is sent as `payloads` in `setInputFiles` (no `createTempFiles`): green here and red in 6a is the streamed path alone."""
page = stock_browser.new_context().new_page()
page.set_content(PAGE)
chooser = _chooser_after(page, lambda: page.click("input"), "served + stock client, payload form")
_upload(chooser, {"name": FILE_NAME, "mimeType": "text/plain", "buffer": FILE_BYTES}, "served + stock client, a payload")
_the_input_holds_the_file(page, "served + stock client, a payload")
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
# 7. The order of the subscription and the click, on a page born a moment before.
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
def _every_fresh_page_gets_its_chooser(new_page, where):
"""`updateSubscription` is sent with no reply and the server's workers run in no fixed order: on a page created a moment ago, the click
comes right behind the subscription. Each of the pages must hear its chooser; the one that did not is named."""
lost = []
for n in range(FRESH_PAGES):
context, page = new_page()
try:
page.set_content(PAGE)
clicked = []
try:
with page.expect_file_chooser(timeout=DEADLINE_MS):
page.click("input")
clicked.append(True)
except Exception as failure:
lost.append("page %d: %s (%s: %s)" % (n + 1, "event never came" if clicked else "the click failed", type(failure).__name__, failure))
finally:
context.close()
assert not lost, "LOST on %d of %d fresh pages (%s): %s" % (len(lost), FRESH_PAGES, where, "; ".join(lost))
def test_7a_served_with_a_stock_client_a_fresh_page_hears_its_chooser_on_the_first_click(stock_browser):
def new_page():
context = stock_browser.new_context()
return context, context.new_page()
_every_fresh_page_gets_its_chooser(new_page, "served + stock client")
def test_7b_in_process_a_fresh_page_hears_its_chooser_on_the_first_click(in_process_browser):
def new_page():
context = in_process_browser.new_context()
return context, context.new_page()
_every_fresh_page_gets_its_chooser(new_page, "in process")
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
# 8. What the page reads of a file that came over the stream: all of it, exactly.
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
def test_8_served_with_a_stock_client_a_streamed_file_reaches_the_page_with_its_name_size_mtime_and_bytes(stock_browser, tmp_path):
"""Two files over `createTempFiles`, each with an mtime set by the test: the page must read exactly what the client had on its disk - the name, the size, the
`lastModified` to the millisecond and every byte. The first is bigger than a chunk of the client's copy (64 KiB on Linux), so it travels in several `write`s."""
big, small = tmp_path / "alpha.bin", tmp_path / "beta.txt"
big_bytes = bytes(range(256)) * 800 + b"\x00\xff" * 37 # 204,874 bytes, every value, not a multiple of a chunk
small_bytes = bytes.fromhex("636166c3a920e29c932073747265616d0a") # "caf", e-acute, a check mark, "stream" and a newline: UTF-8 that is not ASCII
big.write_bytes(big_bytes)
small.write_bytes(small_bytes)
big_ms, small_ms = 1_600_000_123_456, 1_650_000_654_321
os.utime(big, ns=(big_ms * 1_000_000, big_ms * 1_000_000))
os.utime(small, ns=(small_ms * 1_000_000, small_ms * 1_000_000))
page = stock_browser.new_context().new_page()
page.set_content(MANY)
chooser = _chooser_after(page, lambda: page.click("input"), "served + stock client, two streamed files")
_upload(chooser, [str(big), str(small)], "served + stock client, two paths: createTempFiles + streams")
read = page.evaluate(READ_ALL)
seen = [(f["name"], f["size"], f["lastModified"]) for f in read]
assert seen == [("alpha.bin", len(big_bytes), big_ms), ("beta.txt", len(small_bytes), small_ms)], "the page read %r" % (seen,)
assert [base64.b64decode(f["base64"]) for f in read] == [big_bytes, small_bytes], "the bytes the page read are not the bytes of the file"
@@ -0,0 +1,65 @@
"""`Frame.tap` of a context without touch is refused with stock's sentence, before anything is looked up or sent.
Stock (driver bundle `coreBundle.js`, `Frame.tap`): `if (!this._page.browserContext._options.hasTouch) throw new Error("The page does not support tap. Use hasTouch context option
to enable touch support.")`: the first line of the method, before the selector is resolved. Until now the server went on to look the element up and send the tap, which the
page cannot hear without touch: it answered success and did nothing, the one outcome stock never gives. `ElementHandle.tap` has no such check in stock (its `_tap` goes straight
to the touchscreen) and is not changed.
"""
from __future__ import annotations
import threading
from types import SimpleNamespace
from unittest.mock import Mock
import pytest
from invisible_core.juggler.connection import EventListeners
from invisible_core.juggler.lifecycle import Lifecycle
from invisible_playwright._juggler.dispatcher import Dispatcher, ProtocolException
from invisible_playwright._juggler.server import FrameDispatcher, JugglerServer, PageDispatcher
pytestmark = pytest.mark.unit
STOCK = "The page does not support tap. Use hasTouch context option to enable touch support."
def _page(options):
server = JugglerServer()
server.attach(SimpleNamespace(emit_message=lambda message: None))
context = Dispatcher(server, None)
context.options = options
page = object.__new__(PageDispatcher)
page.context = context
page.lifecycle = Lifecycle(EventListeners(), "session")
page.injected = Mock()
page.actions = Mock()
page.send = Mock(return_value={})
page._frames = {}
page._told_attached = set()
page._frames_lock = threading.RLock()
page._announce_lock = threading.RLock()
page._announced = True
page._said_before_announcement = []
page._navigation_requests = {}
page._announced_closed = False
Dispatcher.__init__(page, server, context)
page.frame = FrameDispatcher(server, page, "main")
page.lifecycle._on_event("Page.frameAttached", {"frameId": "main", "parentFrameId": None})
return page
@pytest.mark.parametrize("options", [{}, {"hasTouch": False}])
def test_a_tap_of_a_context_without_touch_is_stocks_error(options):
"""Known-bad: the tap goes on to the actions and answers success."""
page = _page(options)
with pytest.raises(ProtocolException) as failure:
page.frame.call("tap", {"selector": "#b"})
assert str(failure.value) == STOCK
page.actions.tap.assert_not_called()
page.injected.assert_not_called()
def test_a_tap_of_a_context_with_touch_goes_on_to_the_actions():
page = _page({"hasTouch": True})
page.frame.call("tap", {"selector": "#b", "noWaitAfter": True})
page.actions.tap.assert_called_once()
@@ -0,0 +1,355 @@
"""A stock client over `connect` uploads a path as a stream, and the server stages it where a payload is staged.
THE WIRE (playwright 1.61.0, `_impl/_set_input_files_helpers.py`, the `is_remote` branch of `convert_input_files`): for a path the client does not send
`localPaths`. It asks the context for `createTempFiles` (`rootDirName` and `items[{name, lastModifiedMs}]`), gets one `WritableStream` per item, copies
the file into each one with `write{binary}` chunks and `close`, and then sends `setInputFiles{streams: [{guid}, ...]}`. The server refused the first call
("the streamed upload path - set_input_files with local paths works": the sentence was false), so a path upload over `connect` never worked.
What is checked here, with no browser (the real dispatchers over a scripted engine, the real served endpoint for who owns what):
* `createTempFiles` answers one `WritableStream` per item, in the session's upload area, ONE NEW FOLDER PER CALL (two calls with one name do not overwrite
each other), and the answer is what the stock server's is: `writableStreams` and no `rootDir` when no folder was named;
* a name is a BASENAME and nothing else: empty, `.`, `..`, a separator, an absolute path and a NUL are refused, by name, before anything is made - the name
is what a client chose and it must not choose where on this machine the bytes go; two items of one call with one name are refused (they would be one file);
* a folder (`rootDirName`) is refused with the sentence `_upload_paths` already says for `localDirectory`;
* `write` appends, `close` ends the file and sets its mtime from `lastModifiedMs`; a `write` after `close` and a second `close` are refused and reopen nothing;
* `_upload_paths` turns `streams` into the paths of the closed files, and refuses a stream still open;
* the call's folder is removed when its context closes, and when the client that made it drops in the middle of the copy (`RemoteEndpoint._client_gone`
closes the contexts it owns; the streams are its children, and the folder is the context's to remove) - and a context of ANOTHER client keeps its folder.
Known-bad input: on the code without `createTempFiles` every test fails at the first call.
"""
from __future__ import annotations
import base64
import itertools
import os
from types import SimpleNamespace
import pytest
from invisible_core.juggler.connection import EventListeners
from invisible_playwright._juggler import remote
from invisible_playwright._juggler.dispatcher import ProtocolException
from invisible_playwright._juggler.server import ElementHandleDispatcher, FrameDispatcher, LocalUtilsDispatcher, _upload_paths
from _browser_census import closes_with_the_test
pytestmark = pytest.mark.unit
MTIME_MS = 1_700_000_000_123
class _Engine(EventListeners):
"""The handful of commands a context needs to be made and removed."""
def __init__(self):
super().__init__()
closes_with_the_test(self)
self.removed = []
self._contexts = itertools.count(1)
def startup_send(self, method, params=None):
return {}
def post(self, method, params=None, session=None):
pass
def send(self, method, params=None, session=None, timeout=30):
if method == "Browser.createBrowserContext":
return {"browserContextId": "c%d" % next(self._contexts)}
if method == "Browser.removeBrowserContext":
self.removed.append(params)
return {}
@pytest.fixture
def served():
server = remote._SharedServer()
browser_type = remote.SharedBrowserType(server)
LocalUtilsDispatcher(server)
conn = _Engine()
browser = remote.SharedBrowserDispatcher(server, browser_type, conn, "firefox/1")
endpoint = remote.RemoteEndpoint(server, browser_type, browser)
yield endpoint
endpoint.close()
server.shutdown()
class _Loop:
"""The client's event loop, which the tests never run: what the server posts to a client is queued, and nobody reads it."""
def call_soon_threadsafe(self, call, *args):
call(*args)
def _client(endpoint):
return remote.RemoteClient(endpoint, None, _Loop(), {})
def _send(endpoint, client, guid, method, params=None):
"""One call, answered the way a worker answers it: with the client set."""
token = remote.CURRENT_CLIENT.set(client)
try:
return endpoint._dispatch(client, {"id": 1, "guid": guid, "method": method, "params": params or {}})
finally:
remote.CURRENT_CLIENT.reset(token)
def _context(endpoint, client):
answer = _send(endpoint, client, endpoint.browser.guid, "newContext", {})
return endpoint.server.object(answer["context"]["guid"])
def _temp_files(endpoint, client, context, items, root=None):
return _send(endpoint, client, context.guid, "createTempFiles", {"rootDirName": root, "items": items})
def _item(name, ms=MTIME_MS):
return {"name": name, "lastModifiedMs": ms}
def _chunk(data):
return {"binary": base64.b64encode(data).decode()}
def _the_element_uploads(endpoint, context, params):
"""What the ElementHandle's `setInputFiles` hands the engine for this request, on an element of a page of `context`: its paths."""
sent = []
actions = SimpleNamespace(set_input_files=lambda handle, paths, **kwargs: sent.append(paths))
element = SimpleNamespace(server=endpoint.server, frame=SimpleNamespace(page=SimpleNamespace(context=context), actions=actions),
_act_args=lambda p: {})
ElementHandleDispatcher.op_set_input_files(element, params)
return sent[0]
def _the_frame_uploads(endpoint, context, params):
"""The same for the Frame's `setInputFiles`, on a frame of a page of `context`."""
sent = []
actions = SimpleNamespace(set_input_files=lambda selector, paths, **kwargs: sent.append(paths))
frame = SimpleNamespace(server=endpoint.server, page=SimpleNamespace(context=context), actions=actions,
enter_frames=lambda selector: ("f1", selector), _timeout=lambda p: None, _act_opts=lambda p: {})
FrameDispatcher.op_set_input_files(frame, params)
return sent[0]
def _streams(endpoint, answer):
return [endpoint.server.object(channel["guid"]) for channel in answer["writableStreams"]]
def _copy(endpoint, client, stream, data):
_send(endpoint, client, stream.guid, "write", _chunk(data[:3]))
_send(endpoint, client, stream.guid, "write", _chunk(data[3:]))
_send(endpoint, client, stream.guid, "close")
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
# The answer
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
def test_create_temp_files_answers_one_writable_stream_per_item(served):
client = _client(served)
context = _context(served, client)
answer = _temp_files(served, client, context, [_item("a.txt"), _item("b.bin")])
assert set(answer) == {"writableStreams"}, "the stock server answers writableStreams and no rootDir for a call with no folder: %r" % (answer,)
streams = _streams(served, answer)
assert [s.TYPE for s in streams] == ["WritableStream", "WritableStream"]
assert [os.path.basename(s.path) for s in streams] == ["a.txt", "b.bin"]
assert all(os.path.isfile(s.path) for s in streams), "the files are made when the streams are"
def test_a_call_gets_a_folder_of_its_own_inside_the_session_upload_area(served):
client = _client(served)
context = _context(served, client)
first = _streams(served, _temp_files(served, client, context, [_item("same.txt")]))[0]
second = _streams(served, _temp_files(served, client, context, [_item("same.txt")]))[0]
assert first.path != second.path, "two calls with one name wrote one file"
assert os.path.dirname(first.path) != os.path.dirname(second.path)
root = served.server._upload_root
for stream in (first, second):
assert os.path.commonpath([stream.path, root]) == root, "the folder is outside the area `stage_upload` uses: %s" % stream.path
two = _streams(served, _temp_files(served, client, context, [_item("x"), _item("y")]))
assert os.path.dirname(two[0].path) == os.path.dirname(two[1].path), "the items of ONE call share the call's folder"
BAD_NAMES = ["", ".", "..", "a/b", "a\\b", "/abs", "C:\\abs", "../x", "..\\x", "x\x00y", None]
@pytest.mark.parametrize("name", BAD_NAMES, ids=[repr(n) for n in BAD_NAMES])
def test_a_name_that_is_not_a_basename_is_refused_and_nothing_is_made(served, name):
client = _client(served)
context = _context(served, client)
with pytest.raises(ProtocolException, match="name"):
_temp_files(served, client, context, [_item("fine.txt"), _item(name)])
root = getattr(served.server, "_upload_root", None)
assert root is None or os.listdir(root) == [], "a refused call left something in the upload area: %r" % (os.listdir(root),)
assert not [o for o in served.server._objects.values() if o.TYPE == "WritableStream"], "a refused call left a stream"
def test_two_items_with_one_name_in_one_call_are_refused(served):
client = _client(served)
context = _context(served, client)
with pytest.raises(ProtocolException, match="same name"):
_temp_files(served, client, context, [_item("x.txt"), _item("x.txt")])
def test_a_folder_is_refused_with_the_sentence_set_input_files_already_says(served):
client = _client(served)
context = _context(served, client)
with pytest.raises(ProtocolException, match="folder"):
_upload_paths(served.server, {"localDirectory": "C:/somewhere"})
with pytest.raises(ProtocolException) as refused:
_temp_files(served, client, context, [_item("a.txt")], root="somewhere")
try:
_upload_paths(served.server, {"localDirectory": "somewhere"})
except ProtocolException as expected:
same = str(expected).replace("somewhere", "")
assert str(refused.value).replace("somewhere", "") == same
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
# The stream
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
def test_write_appends_and_close_sets_the_mtime(served):
client = _client(served)
context = _context(served, client)
stream, = _streams(served, _temp_files(served, client, context, [_item("a.bin")]))
data = bytes(range(256)) * 3
_copy(served, client, stream, data)
with open(stream.path, "rb") as fh:
assert fh.read() == data
assert os.stat(stream.path).st_mtime_ns == MTIME_MS * 1_000_000, "the file's mtime is not the client's lastModifiedMs"
def test_a_write_after_close_and_a_second_close_are_refused_and_reopen_nothing(served):
client = _client(served)
context = _context(served, client)
stream, = _streams(served, _temp_files(served, client, context, [_item("a.bin")]))
_copy(served, client, stream, b"abcdef")
with pytest.raises(ProtocolException, match="closed"):
_send(served, client, stream.guid, "write", _chunk(b"more"))
with pytest.raises(ProtocolException, match="closed"):
_send(served, client, stream.guid, "close")
with open(stream.path, "rb") as fh:
assert fh.read() == b"abcdef", "a refused call changed the file"
def test_a_chunk_that_is_not_base64_is_refused(served):
client = _client(served)
context = _context(served, client)
stream, = _streams(served, _temp_files(served, client, context, [_item("a.bin")]))
with pytest.raises(ProtocolException, match="base64"):
_send(served, client, stream.guid, "write", {"binary": "***not base64***"})
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
# `setInputFiles{streams}`
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
def test_upload_paths_resolves_the_streams_to_the_closed_files(served):
client = _client(served)
context = _context(served, client)
streams = _streams(served, _temp_files(served, client, context, [_item("a.txt"), _item("b.txt")]))
for stream, data in zip(streams, (b"first", b"second")):
_copy(served, client, stream, data)
paths = _the_element_uploads(served, context, {"streams": [s.channel for s in streams]})
assert paths == [s.path for s in streams]
assert [os.path.basename(p) for p in paths] == ["a.txt", "b.txt"]
def test_upload_paths_refuses_a_stream_that_is_not_closed(served):
client = _client(served)
context = _context(served, client)
stream, = _streams(served, _temp_files(served, client, context, [_item("a.txt")]))
_send(served, client, stream.guid, "write", _chunk(b"half"))
with pytest.raises(ProtocolException, match="not closed"):
_the_element_uploads(served, context, {"streams": [stream.channel]})
def test_upload_paths_refuses_a_stream_nobody_made_with_the_stock_servers_sentence(served):
"""Stock (`dispatcher.ts`, `_tChannelImplFromWire`, coreBundle.js 18313): `<path>: no object with guid <guid>`, the path being `streams[<index>]`."""
context = _context(served, _client(served))
with pytest.raises(ProtocolException) as refused:
_the_element_uploads(served, context, {"streams": [{"guid": "writablestream@999"}]})
assert str(refused.value) == "streams[0]: no object with guid writablestream@999"
def test_upload_paths_refuses_a_directory_stream_by_the_same_sentence(served):
with pytest.raises(ProtocolException, match="folder"):
_upload_paths(served.server, {"directoryStream": {"guid": "writablestream@1"}})
def _closed_stream(served, client, context, name="a.txt", data=b"data"):
stream, = _streams(served, _temp_files(served, client, context, [_item(name)]))
_copy(served, client, stream, data)
return stream
def test_a_closed_stream_of_another_context_is_unknown_to_this_one(served):
"""A stream belongs to the context that made it: the stock server's streams are objects of one connection and one context's scope, and a guid outside them is `no object`."""
client = _client(served)
mine, other = _context(served, client), _context(served, client)
foreign = _closed_stream(served, client, other)
own = _closed_stream(served, client, mine, "own.txt")
with pytest.raises(ProtocolException) as refused:
_the_element_uploads(served, mine, {"streams": [own.channel, foreign.channel]})
assert str(refused.value) == "streams[1]: no object with guid %s" % foreign.guid
def test_a_closed_stream_of_another_client_is_unknown_to_this_one(served):
me, someone = _client(served), _client(served)
mine, theirs = _context(served, me), _context(served, someone)
foreign = _closed_stream(served, someone, theirs, "theirs.txt", b"not yours")
with pytest.raises(ProtocolException) as refused:
_the_element_uploads(served, mine, {"streams": [foreign.channel]})
assert str(refused.value) == "streams[0]: no object with guid %s" % foreign.guid
def test_an_own_stream_is_accepted_by_the_frame_door_and_a_foreign_one_is_not(served):
"""The Frame's `setInputFiles` (a selector) reads the request with the same helper as the element's."""
client = _client(served)
mine, other = _context(served, client), _context(served, client)
own, foreign = _closed_stream(served, client, mine, "own.txt"), _closed_stream(served, client, other, "foreign.txt")
assert _the_frame_uploads(served, mine, {"selector": "input", "streams": [own.channel]}) == [own.path]
with pytest.raises(ProtocolException) as refused:
_the_frame_uploads(served, mine, {"selector": "input", "streams": [foreign.channel]})
assert str(refused.value) == "streams[0]: no object with guid %s" % foreign.guid
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
# The cleanup
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
def _folders(streams):
return {os.path.dirname(s.path) for s in streams}
def test_the_folder_goes_when_its_context_closes(served):
client = _client(served)
context = _context(served, client)
streams = _streams(served, _temp_files(served, client, context, [_item("a.txt"), _item("b.txt")]))
_copy(served, client, streams[0], b"done")
_send(served, client, streams[1].guid, "write", _chunk(b"half")) # the second is still open
folders = _folders(streams)
assert all(os.path.isdir(f) for f in folders)
_send(served, client, context.guid, "close")
assert not any(os.path.exists(f) for f in folders), "the call's folder outlived its context"
assert not [o for o in served.server._objects.values() if o.TYPE == "WritableStream"], "a stream outlived its context"
def test_the_folder_goes_when_the_client_drops_in_the_middle_of_the_copy(served):
gone, staying = _client(served), _client(served)
lost_context, kept_context = _context(served, gone), _context(served, staying)
lost = _streams(served, _temp_files(served, gone, lost_context, [_item("a.txt")]))
kept = _streams(served, _temp_files(served, staying, kept_context, [_item("b.txt")]))
_send(served, gone, lost[0].guid, "write", _chunk(b"half of a file")) # and then the socket goes
_send(served, staying, kept[0].guid, "write", _chunk(b"another client"))
served._client_gone(gone)
assert not os.path.exists(os.path.dirname(lost[0].path)), "a dropped client left its upload folder behind"
assert os.path.isfile(kept[0].path), "the drop of one client removed another client's upload"
_send(served, staying, kept[0].guid, "close")
def test_the_session_end_removes_what_no_context_close_reached(served):
client = _client(served)
context = _context(served, client)
stream, = _streams(served, _temp_files(served, client, context, [_item("a.txt")]))
root = served.server._upload_root
served.server.shutdown()
assert not os.path.exists(root), "the upload area outlived the session"
@@ -0,0 +1,459 @@
"""An element handle answers every method the client sends it, with what Playwright's own server answers, through the paths the rest of the server already has.
THE CLIENT'S `ElementHandle` (`_pw/_impl/_element_handle.py`) SENDS 55 WIRE METHODS AND `ElementHandleDispatcher` HAD A ROW FOR 38. The other 17 were answered
"ElementHandle has no method 'x', and 'x' is INSIDE the perimeter this package covers - so this is a gap" (`Dispatcher.call`): `handle.query_selector`, the three
`is_*` of the state, `handle.dblclick()`, `handle.wait_for_element_state()`, `handle.evaluate_handle()`... all of them ordinary Playwright, and the first person to learn
it was a user whose script died. `test_every_wire_method_is_served_or_refused.py` found them and put them in a budget; this file is what takes them out.
What stock Playwright 1.61 does, read from the driver bundle (`coreBundle.js`, cited by function name):
* `ElementHandleDispatcher.querySelector` / `querySelectorAll` / `evalOnSelector` / `evalOnSelectorAll` run the SELECTOR with the element as ROOT
(`FrameSelectors.query` / `queryAll`: `injected.querySelector(info.parsed, scope || document, info.strict)`); the root applies to the first frame hop only
(`resolveFrameForSelector`: `scope: i === 0 ? scope : undefined`, and `if (frame !== this.frame) scope = undefined`). `evalOnSelector` that finds nothing is
`Failed to find element matching selector "<selector>"`.
* `isVisible` / `isHidden` / `isEnabled` / `isDisabled` / `isEditable` / `isChecked` are the Frame's, with the selector `:scope` and the handle as the root
(`Frame.isVisibleInternal`, `_elementState`): one read, no wait. A node that is not attached is `false` for visible (`isHidden` is its negation) and for the
four others `Element is not attached to the DOM` (`throwElementIsNotAttached`).
* `waitForElementState` is `ElementHandle.waitForElementState`: `checkElementStates(node, [state])` until it is met, retried after 0, 20, 100, 100, 500 ms
(`_retryAction`), `Element is not attached to the DOM` at once when the node is gone (`throwRetargetableDOMError`).
* `dblclick`, `tap`, `selectText` and `dispatchEvent` are `ElementHandle._dblclick` / `_tap` (`_retryPointerAction`), `selectText` (`_retryAction`) and
`Frame.dispatchEvent` with `:scope`: the action on THAT node, the same checks as the selector's.
* `evaluateExpressionHandle` is `JSHandleDispatcher.evaluateExpressionHandle`: `fn(element, arg)` in the page's world, and a HANDLE of what it returned
(`fromJSOrElementHandle`).
Here the server answers each through the path its sibling already has: the element-scoped actions (`op_click`'s: `Actions` with `element_id`, never a selector looked
up again, never the caller's handle disposed), the Frame's reads and queries with the element as root, `_call_on_elements` and `_handle_from_caller` for the caller's
code and the handle it makes. A second path for any of them would be a second fingerprint.
No browser here: the dispatchers run against an injected script and actions that record what they are asked. The browser half is
`test_an_element_handle_serves_every_method_of_the_client_e2e.py`.
"""
from __future__ import annotations
import threading
from types import SimpleNamespace
from unittest.mock import Mock
import pytest
from invisible_core.juggler.connection import EventListeners
from invisible_core.juggler.injected import EvaluationError
from invisible_core.juggler.keyboard import MODIFIER_MASK
from invisible_core.juggler.lifecycle import Lifecycle
from invisible_playwright._juggler.dispatcher import Dispatcher, ProtocolException
from invisible_playwright._juggler.server import (
ElementHandleDispatcher, FrameDispatcher, JugglerServer, PageDispatcher)
pytestmark = pytest.mark.unit
HANDLE = "<element handle>"
NOT_ATTACHED = "Element is not attached to the DOM"
#: The wire methods this file serves (the client's `ElementHandle` sends 17 that the table lacked; `waitForSelector` is the one still named in
#: `tests/gates/wire_method_debt.json`: the core's `Actions.wait_for_selector` has no root to scope it to).
SERVED = [
"querySelector", "querySelectorAll", "evalOnSelector", "evalOnSelectorAll", "evaluateExpressionHandle",
"isVisible", "isHidden", "isEnabled", "isDisabled", "isChecked", "isEditable", "waitForElementState",
"dblclick", "tap", "selectText", "dispatchEvent",
]
@pytest.fixture
def page():
server = JugglerServer()
server.attach(SimpleNamespace(emit_message=lambda message: None))
context = Dispatcher(server, None)
context.options = {}
page = object.__new__(PageDispatcher)
page.context = context
page.lifecycle = Lifecycle(EventListeners(), "session")
page.injected = Mock()
page.actions = Mock()
page.send = Mock(return_value={})
page._frames = {}
page._told_attached = set()
page._frames_lock = threading.RLock()
page._announce_lock = threading.RLock()
page._announced = True
page._said_before_announcement = []
page._navigation_requests = {}
page._announced_closed = False
Dispatcher.__init__(page, server, context)
page.frame = FrameDispatcher(server, page, "main")
for fid, parent in (("main", None), ("payment", "main")):
page.lifecycle._on_event("Page.frameAttached", {"frameId": fid, "parentFrameId": parent})
return page
@pytest.fixture
def element(page):
"""The handle the client holds: `el-1`, a node of the main frame's utility world."""
return ElementHandleDispatcher(page.server, page.frame, "el-1")
def handle_of(page, answer):
return page.server._objects[answer["guid"]]
def arg(value):
return {"value": value, "handles": []}
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
# The table
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
@pytest.mark.parametrize("method", SERVED)
def test_the_client_s_method_is_on_the_table_and_not_a_gap(method):
"""Known-bad: the method is not in `METHODS`, and `Dispatcher.call` answers that it is a gap."""
assert method in ElementHandleDispatcher.METHODS, "%s is sent by the client and the table has no row for it" % method
def test_a_call_of_the_client_is_not_answered_as_a_gap(element):
"""The sentence a user read: asked through `call()`, as the transport asks."""
try:
element.call("isVisible", {})
except ProtocolException as failure:
assert "gap" not in str(failure), str(failure)
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
# Queries rooted at the element
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
def test_query_selector_looks_inside_the_element_and_hands_back_a_handle_of_its_frame(page, element):
page.injected.call.return_value = "child-1"
answer = element.call("querySelector", {"selector": "span.x"})
call = page.injected.call.call_args
assert call.args[0] == "main" and call.args[2] == {"objectId": "el-1"} and call.args[3] == "span.x", call
assert call.kwargs["by_value"] is False
page.injected.query_selector.assert_not_called() # the document-rooted query is the Frame's, and would find a sibling's match
child = handle_of(page, answer["element"])
assert child.object_id == "child-1" and child.frame is page.frame and child.parent is page.frame
def test_query_selector_forwards_strict(page, element):
page.injected.call.return_value = "child-1"
element.call("querySelector", {"selector": "span", "strict": True})
assert page.injected.call.call_args.args[4] is True
element.call("querySelector", {"selector": "span"})
assert page.injected.call.call_args.args[4] is False
def test_query_selector_that_finds_nothing_answers_no_element(page, element):
page.injected.call.return_value = None
assert element.call("querySelector", {"selector": "span"}) == {"element": None}
def listed(*object_ids):
"""What `InjectedScript.properties` answers for an array of nodes: one property per place, the node as the RemoteObject the engine made of it."""
return [{"name": str(i), "value": {"type": "object", "subtype": "node", "objectId": oid}} for i, oid in enumerate(object_ids)]
def test_query_selector_all_looks_inside_the_element_and_hands_back_every_match(page, element):
page.injected.call.side_effect = ["list-1"]
page.injected.context_id.return_value = "utility-1"
page.injected.properties.return_value = listed("child-1", "child-2")
answer = element.call("querySelectorAll", {"selector": "li"})
first = page.injected.call.call_args_list[0]
assert first.args[0] == "main" and first.args[2] == {"objectId": "el-1"} and first.args[3] == "li", first
page.injected.query_selector_all.assert_not_called()
page.injected.properties.assert_called_once_with("utility-1", "list-1")
assert [handle_of(page, e).object_id for e in answer["elements"]] == ["child-1", "child-2"]
assert all(handle_of(page, e).frame is page.frame for e in answer["elements"])
page.injected.dispose.assert_called_once_with("main", "list-1") # the list that held them is not left in the page
def test_query_selector_all_with_no_match_answers_an_empty_list(page, element):
page.injected.call.side_effect = ["list-1"]
page.injected.properties.return_value = []
assert element.call("querySelectorAll", {"selector": "li"}) == {"elements": []}
page.injected.dispose.assert_called_once_with("main", "list-1")
@pytest.mark.parametrize("matches", [0, 1, 2, 25])
def test_the_list_of_a_rooted_query_is_read_in_one_command_whatever_its_length(page, element, matches):
"""The core's own `query_selector_all` asks for the length and then for each place, N + 2 commands; the rooted path reads the array once
(`Runtime.getObjectProperties`, which is the core's `properties`) after the query that made it: two commands, then the release of the list."""
page.injected.call.side_effect = ["list-1"]
page.injected.properties.return_value = listed(*["child-%d" % i for i in range(matches)])
answer = element.call("querySelectorAll", {"selector": "li"})
assert page.injected.call.call_count == 1, page.injected.call.call_args_list
assert page.injected.properties.call_count == 1
assert [handle_of(page, e).object_id for e in answer["elements"]] == ["child-%d" % i for i in range(matches)]
def test_the_matches_of_a_rooted_query_come_in_document_order_whatever_order_the_engine_lists_them(page, element):
page.injected.call.side_effect = ["list-1"]
shuffled = listed(*["child-%d" % i for i in range(12)])
page.injected.properties.return_value = [shuffled[i] for i in (10, 2, 0, 11, 1, 9, 3, 8, 4, 7, 5, 6)]
answer = element.call("querySelectorAll", {"selector": "li"})
assert [handle_of(page, e).object_id for e in answer["elements"]] == ["child-%d" % i for i in range(12)]
def test_a_rooted_list_is_released_even_when_it_cannot_be_read(page, element):
page.injected.call.side_effect = ["list-1"]
page.injected.properties.side_effect = RuntimeError("the world went away")
with pytest.raises(RuntimeError):
element.call("querySelectorAll", {"selector": "li"})
page.injected.dispose.assert_called_once_with("main", "list-1")
def test_the_element_is_the_root_of_the_first_frame_hop_only(page, element):
"""Stock: `scope: i === 0 ? scope : undefined`. The owner of the frame is looked for inside the element, and what is inside the frame is the frame's."""
page.injected.call.return_value = "owner-1"
page.send.return_value = {"contentFrameId": "payment"}
page.injected.query_selector.return_value = "inner-1"
answer = element.call("querySelector", {"selector": "iframe >> internal:control=enter-frame >> li"})
owner_query = page.injected.call.call_args_list[0]
assert owner_query.args[2] == {"objectId": "el-1"} and owner_query.args[3] == "iframe"
page.injected.query_selector.assert_called_once_with("payment", "li")
inner = handle_of(page, answer["element"])
assert inner.object_id == "inner-1" and inner.frame is page.frame_for("payment")
def test_eval_on_selector_runs_the_callers_code_on_the_match_inside_the_element(page, element):
page.injected.call.return_value = "child-1"
page.frame._call_on_elements = Mock(return_value=42)
params = {"selector": "span", "expression": "(e, n) => e.id + n", "isFunction": True, "arg": arg({"n": 1})}
assert element.call("evalOnSelector", params) == {"value": {"n": 42}}
assert page.injected.call.call_args.args[2] == {"objectId": "el-1"}
page.frame._call_on_elements.assert_called_once_with("main", ["child-1"], params)
page.injected.dispose.assert_called_once_with("main", "child-1")
def test_eval_on_selector_that_finds_nothing_says_what_stock_says(page, element):
page.injected.call.return_value = None
with pytest.raises(ProtocolException) as failure:
element.call("evalOnSelector", {"selector": "span.none", "expression": "e => e"})
assert str(failure.value) == 'Failed to find element matching selector "span.none"'
def test_eval_on_selector_all_runs_the_callers_code_on_the_matches_inside_the_element_as_one_array(page, element):
page.injected.call.side_effect = ["list-1"]
page.injected.properties.return_value = listed("child-1", "child-2")
page.frame._call_on_elements = Mock(return_value=2)
params = {"selector": "li", "expression": "els => els.length", "isFunction": True, "arg": arg({"v": "null"})}
assert element.call("evalOnSelectorAll", params) == {"value": {"n": 2}}
assert page.injected.call.call_args_list[0].args[2] == {"objectId": "el-1"}
page.frame._call_on_elements.assert_called_once_with("main", ["child-1", "child-2"], params, as_array=True)
disposed = [c.args for c in page.injected.dispose.call_args_list]
assert ("main", "child-1") in disposed and ("main", "child-2") in disposed and ("main", "list-1") in disposed
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
# The state of the element
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
@pytest.mark.parametrize("method, state", [
("isVisible", "visible"), ("isEnabled", "enabled"), ("isDisabled", "disabled"),
("isEditable", "editable"), ("isChecked", "checked")])
@pytest.mark.parametrize("answer", [True, False])
def test_a_state_is_read_of_this_node_and_answered_as_it_is(page, element, method, state, answer):
page.injected.element_state.return_value = answer
assert element.call(method, {}) == {"value": answer}
page.injected.element_state.assert_called_once_with("main", "el-1", state)
page.injected.read_match.assert_not_called() # the selector-rooted read is the Frame's: this is the handle's node
@pytest.mark.parametrize("visible", [True, False])
def test_is_hidden_is_the_negation_of_is_visible(page, element, visible):
page.injected.element_state.return_value = visible
assert element.call("isHidden", {}) == {"value": not visible}
page.injected.element_state.assert_called_once_with("main", "el-1", "visible")
def test_a_node_that_is_not_attached_is_not_visible_and_is_hidden(page, element):
page.injected.element_state.side_effect = EvaluationError("elementState(visible): error:notconnected")
assert element.call("isVisible", {}) == {"value": False}
assert element.call("isHidden", {}) == {"value": True}
@pytest.mark.parametrize("method", ["isEnabled", "isDisabled", "isEditable", "isChecked"])
def test_a_node_that_is_not_attached_has_no_such_state_and_the_error_is_stock_s(page, element, method):
page.injected.element_state.side_effect = EvaluationError("elementState(x): error:notconnected")
with pytest.raises(ProtocolException) as failure:
element.call(method, {})
assert str(failure.value) == NOT_ATTACHED
def test_a_failure_that_is_not_about_the_node_is_not_turned_into_not_attached(page, element):
page.injected.element_state.side_effect = EvaluationError("Not a checkbox or radio button")
with pytest.raises(EvaluationError, match="Not a checkbox"):
element.call("isChecked", {})
@pytest.mark.parametrize("state", ["visible", "hidden", "stable", "enabled", "disabled", "editable"])
def test_wait_for_element_state_asks_the_actionability_check_of_this_node(page, element, state):
page.injected.element_states.return_value = {"ok": True}
assert element.call("waitForElementState", {"state": state}) is None
page.injected.element_states.assert_called_once_with("main", "el-1", [state])
def test_wait_for_element_state_tries_again_until_the_state_is_met(page, element):
page.injected.element_states.side_effect = [
{"ok": False, "missing": "visible"}, {"ok": False, "missing": "visible"}, {"ok": True}]
assert element.call("waitForElementState", {"state": "visible", "timeout": 5000}) is None
assert page.injected.element_states.call_count == 3
def test_wait_for_element_state_on_a_node_that_left_the_document_fails_at_once_with_stock_s_error(page, element):
"""Stock: `throwRetargetableDOMError`. Known-bad: the node is retried until the timeout and the error is a timeout."""
page.injected.element_states.return_value = {"ok": False, "missing": "error:notconnected"}
with pytest.raises(ProtocolException) as failure:
element.call("waitForElementState", {"state": "visible", "timeout": 5000})
assert str(failure.value) == NOT_ATTACHED
assert page.injected.element_states.call_count == 1
#: What the injected script answers `checkElementStates(node, [state])` for a node that is not in the document, per state. Read from stock's `InjectedScript.elementState`
#: (`if (!element || !element.isConnected) { if (state === "hidden") return { matches: true, ... }; return { matches: false, received: "error:notconnected" } }`) and
#: `checkElementStates` (no `missingState` for a match, "error:notconnected" for the rest), and MEASURED on the core's own `injected.js` run on a detached node:
#: visible, enabled, disabled and editable answer `"error:notconnected"`; hidden answers nothing (met); stable answers nothing either, because a detached element
#: has a box that does not move (`retarget` does not lose it: only a text node without a parent does). The core's `element_states` turns them into these verdicts.
GONE = {"error:notconnected": {"ok": False, "missing": "error:notconnected"}, "met": {"ok": True}}
STATE_OF_A_NODE_OUT_OF_THE_DOCUMENT = {
"visible": "error:notconnected", "enabled": "error:notconnected", "disabled": "error:notconnected", "editable": "error:notconnected",
"hidden": "met", "stable": "met"}
@pytest.mark.parametrize("state", sorted(STATE_OF_A_NODE_OUT_OF_THE_DOCUMENT))
def test_wait_for_element_state_of_a_node_that_left_the_document_answers_as_stock_does_for_each_state(page, element, state, monkeypatch):
"""`hidden` is met at once (the node is not shown), `stable` is met (its box does not move), the four others are `Element is not attached to the DOM` at once:
one question asked, no pause between two, and the timeout is never the answer."""
page.injected.element_states.return_value = GONE[STATE_OF_A_NODE_OUT_OF_THE_DOCUMENT[state]]
paused = []
monkeypatch.setattr("invisible_playwright._juggler.server.time.sleep", paused.append)
params = {"state": state, "timeout": 5000}
if STATE_OF_A_NODE_OUT_OF_THE_DOCUMENT[state] == "met":
assert element.call("waitForElementState", params) is None
else:
with pytest.raises(ProtocolException) as failure:
element.call("waitForElementState", params)
assert str(failure.value) == NOT_ATTACHED
assert page.injected.element_states.call_count == 1
assert paused == []
def test_wait_for_element_state_that_is_never_met_ends_in_a_timeout(page, element):
page.injected.element_states.return_value = {"ok": False, "missing": "enabled"}
with pytest.raises(TimeoutError, match="Timeout 150ms exceeded"):
element.call("waitForElementState", {"state": "enabled", "timeout": 150})
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
# The gestures: the actions of the node, as `op_click`'s
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
def the_call(mock):
assert mock.call_count == 1, mock.call_args_list
return mock.call_args
def test_dblclick_is_the_actions_dblclick_on_this_node(page, element):
assert element.call("dblclick", {"position": {"x": 3, "y": 4}, "button": "right", "modifiers": ["Shift"],
"delay": 40, "timeout": 5000}) is None
call = the_call(page.actions.dblclick)
assert call.args == (HANDLE,)
assert call.kwargs == {"position": {"x": 3, "y": 4}, "button": 2, "modifiers": MODIFIER_MASK["Shift"], "delay_ms": 40,
"timeout": 5.0, "frame_id": "main", "element_id": "el-1",
"trial": False, "strict": False, "force": False}, call.kwargs
page.injected.query_selector.assert_not_called() # the node is not looked up again, and the caller's handle is not disposed
page.injected.dispose.assert_not_called()
def test_dblclick_carries_trial_and_force(page, element):
element.call("dblclick", {"trial": True, "force": True})
kwargs = the_call(page.actions.dblclick).kwargs
assert kwargs["trial"] is True and kwargs["force"] is True and kwargs["element_id"] == "el-1"
assert kwargs["timeout"] == 30.0 and kwargs["position"] is None
def test_tap_is_the_actions_tap_on_this_node(page, element):
assert element.call("tap", {"position": {"x": 1, "y": 2}, "timeout": 7000, "trial": True}) is None
call = the_call(page.actions.tap)
assert call.args == (HANDLE,)
assert call.kwargs == {"position": {"x": 1, "y": 2}, "timeout": 7.0, "frame_id": "main", "element_id": "el-1",
"trial": True, "strict": False, "force": False}, call.kwargs
def test_select_text_is_the_actions_select_text_on_this_node(page, element):
assert element.call("selectText", {"force": True, "timeout": 2000}) is None
call = the_call(page.actions.select_text)
assert call.args == (HANDLE,)
assert call.kwargs == {"timeout": 2.0, "frame_id": "main", "element_id": "el-1",
"trial": False, "strict": False, "force": True}, call.kwargs
def test_dispatch_event_is_the_actions_dispatch_event_on_this_node_with_the_init_decoded(page, element):
init = arg({"o": [{"k": "bubbles", "v": {"b": True}}, {"k": "detail", "v": {"n": 3}}]})
assert element.call("dispatchEvent", {"type": "click", "eventInit": init, "timeout": 4000}) is None
call = the_call(page.actions.dispatch_event)
assert call.args == (HANDLE, "click", {"bubbles": True, "detail": 3})
assert call.kwargs == {"timeout": 4.0, "frame_id": "main", "element_id": "el-1",
"trial": False, "strict": False, "force": False}, call.kwargs
def test_dispatch_event_with_no_init_dispatches_an_empty_one(page, element):
element.call("dispatchEvent", {"type": "focus", "eventInit": arg({"v": "undefined"})})
assert the_call(page.actions.dispatch_event).args == (HANDLE, "focus", {})
def test_a_handle_in_the_event_init_is_refused_by_name_as_the_frame_s_is(page, element):
other = ElementHandleDispatcher(page.server, page.frame, "el-2")
init = {"value": {"o": [{"k": "relatedTarget", "v": {"h": 0}}]}, "handles": [{"guid": other.guid}]}
with pytest.raises(ProtocolException, match="eventInit.*JSHandle|JSHandle.*eventInit"):
element.call("dispatchEvent", {"type": "click", "eventInit": init})
page.actions.dispatch_event.assert_not_called()
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
# The caller's code on the element, returning a handle
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
FUNCTION = {"type": "function", "objectId": "the-function"}
@pytest.fixture
def world(page):
"""The caller's world: the expression is a function, the elements cross as copies, and what the function returns is `result`."""
injected = page.injected
injected.caller_context.return_value = "world-1"
injected.evaluate_raw.return_value = dict(FUNCTION)
injected.node_to_caller.side_effect = lambda frame_id, node: "copy-" + node
injected.call_raw.return_value = {"objectId": "result-1", "type": "object"}
return injected
def calls_of_the_function(injected):
return [c for c in injected.call_raw.call_args_list if c.args[1] == "(f, ...a) => f(...a)"]
def test_evaluate_expression_handle_runs_the_function_on_this_element_and_hands_back_a_handle(page, element, world):
answer = element.call("evaluateExpressionHandle", {"expression": "(e, n) => ({id: e.id, n})", "isFunction": True, "arg": arg({"n": 1})})
(call,) = calls_of_the_function(world)
assert call.args[2] == [{"objectId": "the-function"}, {"objectId": "copy-el-1"}, {"value": 1}], call.args[2]
assert call.kwargs["by_value"] is False # a handle of the result, not its value
world.release.assert_any_call("world-1", "copy-el-1") # the copy of the node is released, the caller's handle is not
made = handle_of(page, answer["handle"])
assert made.object_id == "result-1" and made.world == "caller" and made.frame is page.frame
def test_evaluate_expression_handle_that_returns_a_node_hands_back_the_element(page, element, world):
world.call_raw.return_value = {"objectId": "node-9", "type": "object", "subtype": "node"}
world.adopt.return_value = "u-9"
answer = element.call("evaluateExpressionHandle", {"expression": "e => e.firstChild", "isFunction": True, "arg": arg({"v": "null"})})
world.adopt.assert_called_once_with("main", "node-9")
made = handle_of(page, answer["handle"])
assert made.object_id == "u-9" and made.world == "utility"
def test_evaluate_expression_handle_on_a_handle_of_the_callers_world_takes_the_object_itself(page, world):
"""A handle born in the caller's world (`evaluate_handle`'s result) is the receiver as it is: it is not carried anywhere."""
thing = ElementHandleDispatcher(page.server, page.frame, "obj-5", world="caller", node=False, context="world-1")
answer = thing.call("evaluateExpressionHandle", {"expression": "o => o.items", "isFunction": True, "arg": arg({"v": "null"})})
(call,) = calls_of_the_function(world)
assert call.args[2][:2] == [{"objectId": "the-function"}, {"objectId": "obj-5"}], call.args[2]
assert call.kwargs["by_value"] is False
world.node_to_caller.assert_not_called()
assert handle_of(page, answer["handle"]).object_id == "result-1"
def test_the_callers_code_of_evaluate_expression_handle_is_sent_once(page, element, world):
element.call("evaluateExpressionHandle", {"expression": "e => e", "isFunction": True, "arg": arg({"v": "null"})})
assert world.evaluate_raw.call_count == 1 and len(calls_of_the_function(world)) == 1
@@ -0,0 +1,250 @@
"""The handle of an element answers every method the client sends it, in a real browser, as Playwright 1.61 does.
The unit file next to it (`test_an_element_handle_serves_every_method_of_the_client.py`) pins what the server asks the engine and the actions; this one asks the
page what happened. Until the server had a row for them, `handle.query_selector(...)`, `handle.is_visible()`, `handle.dblclick()`, `handle.wait_for_element_state(...)`
and the rest of the 17 answered "ElementHandle has no method ... INSIDE the perimeter ... a gap", and the script died.
Each expectation is stock's, from the driver bundle (`coreBundle.js`, by function name): the queries run with the element as ROOT (`FrameSelectors.query`, `queryAll`),
the states are the Frame's with `:scope` and the handle (`Frame._elementState`, `isVisibleInternal`), `waitForElementState` is `ElementHandle.waitForElementState`
(`throwRetargetableDOMError`: `Element is not attached to the DOM`), the gestures are `_dblclick`, `_tap`, `selectText` and `Frame.dispatchEvent` on that node, and
`evaluateExpressionHandle` is `JSHandleDispatcher`'s. `wait_for_selector` of a handle is not here: the server still answers it as a gap (the core's
`Actions.wait_for_selector` has no root).
"""
from __future__ import annotations
import pytest
pytestmark = pytest.mark.e2e
PAGE = """<!doctype html>
<div id="box"><span class="x" id="s1">a</span><span class="x" id="s2">b</span><p id="p">text</p>
<iframe id="f" srcdoc="&lt;!doctype html&gt;&lt;div id='inner'&gt;in&lt;/div&gt;"></iframe></div>
<span class="x" id="outside">out</span>
<button id="go" type="button">go</button><button id="off" type="button" disabled>off</button>
<input id="chk" type="checkbox" checked><input id="unchk" type="checkbox">
<input id="ro" readonly value="v"><input id="txt" value="hello world">
<div id="hid" style="display:none">h</div><div id="gone">g</div>
<script>
window.seen = {click: 0, dblclick: 0, touchstart: 0, trusted: [], pings: []};
const go = document.getElementById('go');
go.addEventListener('click', e => { window.seen.click++; window.seen.trusted.push(e.isTrusted); });
go.addEventListener('dblclick', e => { window.seen.dblclick++; window.seen.trusted.push(e.isTrusted); });
go.addEventListener('touchstart', () => { window.seen.touchstart++; });
document.getElementById('box').addEventListener('ping', e => window.seen.pings.push([e.type, e.bubbles, e.isTrusted]));
</script>"""
@pytest.fixture(scope="module")
def browser(firefox_binary):
from invisible_playwright import InvisiblePlaywright
with InvisiblePlaywright(seed=42, binary_path=firefox_binary, humanize=False, headless=True) as browser:
yield browser
def _page(browser, **options):
page = browser.new_context(**options).new_page()
page.set_default_timeout(30000)
page.set_content(PAGE)
return page
@pytest.fixture
def page(browser):
page = _page(browser)
yield page
page.context.close()
def ids(elements):
return [e.get_attribute("id") for e in elements]
# --- the queries run inside the element -------------------------------------------------------------------------------------------------------------------
def test_query_selector_finds_inside_the_element_and_not_outside_it(page):
box = page.query_selector("#box")
assert box.query_selector(".x").get_attribute("id") == "s1"
assert box.query_selector("#outside") is None
def test_query_selector_enters_a_frame_inside_the_element(page):
box = page.query_selector("#box")
inner = box.query_selector("iframe >> internal:control=enter-frame >> #inner")
assert inner.text_content() == "in"
def test_query_selector_all_finds_every_match_inside_the_element_and_not_outside_it(page):
box = page.query_selector("#box")
assert ids(box.query_selector_all(".x")) == ["s1", "s2"]
assert box.query_selector_all("#outside") == []
def test_query_selector_all_inside_the_element_keeps_the_document_order_of_a_long_list(page):
"""A list longer than ten: read as one array, its places are 0, 1, ... 9, 10, ... and not '0', '1', '10', '11', ... '2'."""
page.evaluate("""() => {
const list = document.createElement('div'); list.id = 'long';
for (let i = 0; i < 25; i++) { const li = document.createElement('i'); li.id = 'n' + i; list.appendChild(li); }
document.body.appendChild(list);
}""")
found = page.query_selector("#long").query_selector_all("i")
assert ids(found) == ["n%d" % i for i in range(25)]
def test_eval_on_selector_runs_the_function_on_the_match_inside_the_element(page):
box = page.query_selector("#box")
assert box.eval_on_selector(".x", "(e, suffix) => e.id + suffix", "!") == "s1!"
def test_eval_on_selector_that_finds_nothing_says_what_stock_says(page):
from invisible_playwright.sync_api import Error
box = page.query_selector("#box")
with pytest.raises(Error, match='Failed to find element matching selector "#outside"'):
box.eval_on_selector("#outside", "e => e.id")
def test_eval_on_selector_all_runs_the_function_on_every_match_inside_the_element(page):
box = page.query_selector("#box")
assert box.eval_on_selector_all(".x", "(els, n) => els.map(e => e.id).concat([els.length + n])", 10) == ["s1", "s2", 12]
# --- the state of the element -----------------------------------------------------------------------------------------------------------------------------
def test_is_visible_and_is_hidden_read_this_element(page):
assert page.query_selector("#go").is_visible() is True
assert page.query_selector("#go").is_hidden() is False
assert page.query_selector("#hid").is_visible() is False
assert page.query_selector("#hid").is_hidden() is True
def test_is_enabled_and_is_disabled_read_this_element(page):
assert page.query_selector("#go").is_enabled() is True
assert page.query_selector("#go").is_disabled() is False
assert page.query_selector("#off").is_enabled() is False
assert page.query_selector("#off").is_disabled() is True
def test_is_checked_reads_this_element(page):
assert page.query_selector("#chk").is_checked() is True
assert page.query_selector("#unchk").is_checked() is False
def test_is_editable_reads_this_element(page):
assert page.query_selector("#txt").is_editable() is True
assert page.query_selector("#ro").is_editable() is False
def test_is_editable_of_an_element_that_cannot_be_edited_is_stocks_error(page):
# stock (injected `elementState`, "editable"): `getReadonly` answers "error" for a node that is not an <input>, <textarea>, <select> or
# [contenteditable] with a role that allows [aria-readonly], a disabled <button> among them, and that is thrown, not answered `false`.
from invisible_playwright.sync_api import Error
with pytest.raises(Error, match=r"Element is not an <input>, <textarea>, <select> or \[contenteditable\] and does not have a role allowing \[aria-readonly\]"):
page.query_selector("#off").is_editable()
def test_a_node_that_left_the_document_is_hidden_and_has_no_other_state(page):
from invisible_playwright.sync_api import Error
gone = page.query_selector("#gone")
page.evaluate("document.getElementById('gone').remove()")
assert gone.is_visible() is False
assert gone.is_hidden() is True
with pytest.raises(Error, match="Element is not attached to the DOM"):
gone.is_enabled()
with pytest.raises(Error, match="Element is not attached to the DOM"):
gone.wait_for_element_state("visible")
@pytest.mark.parametrize("state", ["hidden", "stable", "visible", "enabled", "disabled", "editable"])
def test_wait_for_element_state_of_a_node_removed_from_the_document_answers_as_stock_does_for_each_state(page, state):
"""Stock's `checkElementStates` on a node that is not connected: `hidden` is met at once, `stable` is met (the box of a removed node does not move), the four others are
`Element is not attached to the DOM`, at once and not after the timeout."""
from invisible_playwright.sync_api import Error
handle = page.query_selector("#gone")
page.evaluate("e => e.remove()", handle)
if state in ("hidden", "stable"):
handle.wait_for_element_state(state, timeout=30000)
else:
with pytest.raises(Error, match="Element is not attached to the DOM") as failure:
handle.wait_for_element_state(state, timeout=30000)
assert "Timeout" not in str(failure.value)
def test_wait_for_element_state_returns_when_the_state_is_met(page):
page.query_selector("#go").wait_for_element_state("visible")
page.query_selector("#go").wait_for_element_state("stable")
page.query_selector("#go").wait_for_element_state("enabled")
page.query_selector("#off").wait_for_element_state("disabled")
page.query_selector("#txt").wait_for_element_state("editable")
page.query_selector("#hid").wait_for_element_state("hidden")
def test_wait_for_element_state_waits_for_a_state_the_page_reaches(page):
page.evaluate("requestAnimationFrame(() => { document.getElementById('hid').style.display = 'block'; })")
page.query_selector("#hid").wait_for_element_state("visible")
assert page.query_selector("#hid").is_visible() is True
def test_wait_for_element_state_that_is_never_met_is_a_timeout(page):
from invisible_playwright.sync_api import TimeoutError as PlaywrightTimeout
with pytest.raises(PlaywrightTimeout):
page.query_selector("#hid").wait_for_element_state("visible", timeout=500)
# --- the gestures: on this node, as a person does them ----------------------------------------------------------------------------------------------------
def test_dblclick_double_clicks_this_element(page):
page.query_selector("#go").dblclick()
seen = page.evaluate("window.seen")
assert (seen["click"], seen["dblclick"]) == (2, 1)
assert all(seen["trusted"]), "a double click made by the server is a user's: %r" % seen["trusted"]
def test_a_page_tap_of_a_context_without_touch_is_stocks_error(page):
# stock's `Frame.tap` (not the handle's) refuses first, whatever the selector
from invisible_playwright.sync_api import Error
with pytest.raises(Error, match="The page does not support tap. Use hasTouch context option to enable touch support."):
page.tap("#go")
assert page.evaluate("window.seen.touchstart") == 0
def test_select_text_selects_the_text_of_this_element(page):
page.query_selector("#txt").select_text()
assert page.evaluate("[document.getElementById('txt').selectionStart, document.getElementById('txt').selectionEnd]") == [0, 11]
def test_dispatch_event_dispatches_on_this_element(page):
box = page.query_selector("#box")
box.dispatch_event("ping")
box.dispatch_event("ping", {"bubbles": False})
# stock `injectedScript.dispatchEvent`: an event of a type with no interface is `new Event(type, {bubbles, cancelable, composed, ...init})`, not a user's
assert page.evaluate("window.seen.pings") == [["ping", True, False], ["ping", False, False]]
def test_dispatch_event_of_a_click_reaches_the_listener(page):
page.query_selector("#go").dispatch_event("click")
assert page.evaluate("[window.seen.click, window.seen.trusted]") == [1, [False]]
def test_a_handle_in_the_event_init_is_refused_by_name(page):
from invisible_playwright.sync_api import Error
with pytest.raises(Error, match="eventInit.*JSHandle|JSHandle.*eventInit"):
page.query_selector("#box").dispatch_event("ping", {"relatedTarget": page.query_selector("#go")})
# --- the caller's code on the element, returning a handle -------------------------------------------------------------------------------------------------
def test_evaluate_handle_hands_back_a_handle_of_what_the_function_returned(page):
box = page.query_selector("#box")
made = box.evaluate_handle("(e, n) => ({kids: e.children.length + n, id: e.id})", 1)
assert made.json_value() == {"kids": 5, "id": "box"}
assert made.get_property("id").json_value() == "box"
def test_evaluate_handle_that_returns_a_node_hands_back_the_element(page):
box = page.query_selector("#box")
element = box.evaluate_handle("e => e.querySelector('#p')").as_element()
assert element is not None and element.text_content() == "text"
assert element.is_visible() is True
@@ -97,7 +97,6 @@ SERVER_ROOT = {"JugglerServer": "Root"}
#: The channels that exist in the client and are never created by the server, because the ONLY way to create them is a method the server refuses.
#: {channel: (the methods that create it)}. Each creator must be sent by the client, and every send of it must be DECLARED (checked below).
UNREACHABLE = {
"WritableStream": ("createTempFiles",), # `convert_input_files`, `_set_input_files_helpers.py` (a remote connection streams the files)
"CDPSession": ("newCDPSession", "newBrowserCDPSession"), # `BrowserContext.new_cdp_session`, `Browser.new_browser_cdp_session`
"WebSocketRoute": ("setWebSocketInterceptionPatterns",), # `BrowserContext.route_web_socket`, `Page.route_web_socket`
"JsonPipe": ("connect",), # `BrowserType.connect`, on LocalUtils (`pipe` of the answer)
+1 -1
View File
@@ -152,7 +152,7 @@ def build_page(clock, boxes, *, seed, number, budget, hits="all", draws=True,
messages = []
server.attach(SimpleNamespace(emit_message=messages.append))
context = Dispatcher(server, None)
context.options = {}
context.options = {"hasTouch": True} # the golden has a tap, and stock refuses one on a context without touch
conn = RecordingConnection(clock, boxes)
injected = FakeInjected(conn, boxes, hits)
actions = Actions(conn, "sess", Life(), injected, acts=PageActs(number),