tests: a select twin that fails says where it clicked and what the geometry was, and every case leaves its numbers
The steps of the select twin said "the dropdown did not open after a click on the select of the frame document" and nothing about the click, so a red case at one display scale could not be told from a wrong point, a wrong scale or a window that moved. Now, for each select, every failure of the steps carries: the click point (CSS, and the point the driver sent with its unit and its device point), the scales record, the select's box in its own document and the frame element's box in the top document, mozInnerScreenX/Y of the top and of the frame, and the popup's state after the click, at the deadline and at a second look. The verdict of the twin prints both browsers' records whole. The same record is written for every case, red or green, to $RUNNER_TEMP/invpw-evidence/popup-diagnostics/<case>-<browser>.json, the folder the jobs upload, so a green run leaves the numbers to compare with a red one. A read of the diagnosis that fails is recorded in the record and never replaces the finding. The drivers keep the point they sent (last_click), and the retail driver reads a frame through Marionette and is back in the top document when the read ends or fails. Regression test (13 tests, no browser, a fake driver): red on the old files (11 of the 13 fail on the old steps and drivers, the module of the record does not exist). In the two unit rows: 4237 -> 4250 on Linux, 4249 -> 4262 on Windows (collect-only on the row's files, not OS-specific).
This commit is contained in:
1 parent
a7f84eded4
commit
e0e620e8d5
5 files changed
+533
-32
No files matched your search
@@ -18,8 +18,8 @@
|
||||
{"id": "wrapper.e2e.stock_twin.intersection", "giro": "G2", "os": ["linux", "windows"], "min_tests": 8, "exact": true, "tests": ["tests/test_intersection_and_lazy_loading_in_a_frame_of_another_site_e2e.py"], "marker": "e2e", "needs_root": false, "note": "Split from the row wrapper.e2e.stock_twin, which ran past the 25-minute limit of a leg: one file, one leg. The twin of what the IntersectionObserver of a scrolled frame of another site reads (8 steps, 4 scales) and of when a lazy frame is requested (4 distances, 4 scales): the same steps first on Playwright's own Firefox (stock_firefox), headed, driven by the stock Playwright client, and second on ours; the verdict is 'the same as the reference' (tests/_stock_twin.py). Each record keeps the page's and the chrome's devicePixelRatio and the real scale of the screen. The file is in no whole-suite row: the references are installed only for this row's legs.", "stock_firefox": true},
|
||||
{"id": "wrapper.e2e.fontconfig", "giro": "G2", "os": ["linux"], "min_tests": 2, "exact": true, "tests": ["tests/test_the_parent_reads_the_bundle_from_fontconfig_s_cache_linux_e2e.py"], "marker": "e2e", "needs_root": false, "linux_only": "Fontconfig exists only on Linux: the parent of the engine shows <GRE>/fonts to it (FcConfigAppFontAddDir) to rebuild a font from a path and a face index. On Windows DirectWrite opens the file from its path, with no folder to scan and no cache to read, so this test has no Windows counterpart.", "note": "2 = (1) the stand-in that runs the engine under strace stays in the engine's place, as the core launches it (the leader of a process group of its own): a fake engine with a child, no browser; the process the launcher holds lives as long as the fake engine, and the group killed holds strace and the child (the stand-in that exec'd setsid forked and exited 0 at once: candidate 44161687675); (2) the warm launch of the parent reads the bundle from fontconfig's cache and does not scan it again (from firefox-66, engine_at_least). Two launches under strace with the same XDG_CACHE_HOME of the test, the first cold and the second warm: the cold parent opens every font file of <GRE>/fonts (the folder as the disk lists it) before any page and fontconfig writes its cache; the warm parent does not open every one of them, and it opens a *.cache-* file of fontconfig (a few files are opened to be used, so the verdict asks about the whole folder, as a scan does). Scan and drawing are told apart by position: only what the parent opens before the first page counts (the opens that draw are written as after_startup). Evidence in RUNNER_TEMP/invpw-evidence/fontconfig-cache: the interval and the number of opens of the bundle, the names of the files of the bundle each launch opened before the first page, the size of the cache file, the VmRSS of the parent after about:blank and after a page with every family, and a third launch with gfx.bundled-fonts.activate=0 (the behaviour before), which is evidence only. Needs strace on the runner: without it both are red, not skipped. No threshold."},
|
||||
{"id": "wrapper.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": 4237, "exact": true, "tests": ["tests/test_a_162_message_is_read_like_a_161_one.py", "tests/test_a_click_makes_one_mousemove_at_its_point.py", "tests/test_a_closed_context_leaves_nothing_in_the_registry.py", "tests/test_a_closed_page_says_nothing.py", "tests/test_a_closed_pipe_is_a_closed_target.py", "tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py", "tests/test_a_context_proxy_carries_its_measured_udp_exit.py", "tests/test_a_context_route_disables_the_cache.py", "tests/test_a_detached_frame_answers_detached.py", "tests/test_a_dialog_is_a_protocol_object.py", "tests/test_a_dialog_is_answered_after_a_pause.py", "tests/test_a_download_finished_before_it_was_announced_is_finished.py", "tests/test_a_failed_expect_carries_its_call_log.py", "tests/test_a_failed_generation_of_the_security_state_keeps_its_evidence.py", "tests/test_a_failed_launch_stops_the_display.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_file_chooser_is_never_dropped_in_silence.py", "tests/test_a_frame_tap_needs_a_context_with_touch.py", "tests/test_a_gil_free_thread_dump_kills_a_busy_process_and_the_stack_watchdog_does_not.py", "tests/test_a_handle_action_walks_like_a_selector_action.py", "tests/test_a_launch_asks_nobody_on_the_internet_where_it_leaves_from.py", "tests/test_a_launch_gives_the_core_its_engine_for_the_security_state.py", "tests/test_a_launch_has_one_deadline.py", "tests/test_a_launch_without_a_session_gets_one.py", "tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py", "tests/test_a_marionette_session_is_asked_after_the_first_window.py", "tests/test_a_module_that_leaves_a_browser_open_fails.py", "tests/test_a_new_page_waits_for_the_engine.py", "tests/test_a_non_finite_number_crosses_the_wire_as_a_tag.py", "tests/test_a_page_closed_before_its_announcement_is_not_announced.py", "tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py", "tests/test_a_path_leaves_as_one_stroke.py", "tests/test_a_port_number_is_held_until_it_is_used.py", "tests/test_a_read_whose_probe_ran_out_is_the_callers_timeout.py", "tests/test_a_request_and_a_response_are_light.py", "tests/test_a_request_says_what_it_is.py", "tests/test_a_screenshot_refuses_what_would_touch_the_page.py", "tests/test_a_screenshot_sends_its_scale_to_the_engine.py", "tests/test_a_session_ends_before_the_next_test_starts.py", "tests/test_a_streamed_upload_is_staged_in_the_session.py", "tests/test_a_stroke_is_judged_by_its_shape_not_its_length.py", "tests/test_a_test_that_is_not_e2e_never_leaves_the_machine.py", "tests/test_a_unit_test_does_not_read_the_seal_of_the_job.py", "tests/test_ab_host.py", "tests/test_ab_host_aa_stable.py", "tests/test_ab_network.py", "tests/test_ab_network_turn_credential.py", "tests/test_ab_network_turn_deallocation.py", "tests/test_ab_network_webrtc_evidence.py", "tests/test_ab_oracle.py", "tests/test_ab_oracle_declared_differences.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_element_handle_serves_every_method_of_the_client.py", "tests/test_an_expect_reads_its_value_once.py", "tests/test_async_api.py", "tests/test_browser_output_is_drained.py", "tests/test_ci_downloads_are_authenticated.py", "tests/test_ci_drive_gate_goes_through_the_core.py", "tests/test_ci_host_gate.py", "tests/test_ci_host_gate_ab.py", "tests/test_ci_lab_geoip.py", "tests/test_ci_lab_geoip_verify.py", "tests/test_ci_lab_intermediates.py", "tests/test_ci_lab_security_state.py", "tests/test_ci_linux_legs_read_no_mirror.py", "tests/test_ci_poison_host.py", "tests/test_ci_published_set.py", "tests/test_ci_real_geoip_check.py", "tests/test_ci_real_geoip_exit_code.py", "tests/test_ci_runs_once_per_commit.py", "tests/test_ci_suite_run.py", "tests/test_ci_verdict.py", "tests/test_ci_windows_temp_is_on_d.py", "tests/test_ci_workflows_build_the_geoip_database.py", "tests/test_ci_workflows_set_the_intermediates_list.py", "tests/test_ci_workflows_set_the_security_state.py", "tests/test_cli.py", "tests/test_click_rhythm.py", "tests/test_connect_does_not_start_threads_on_the_loop.py", "tests/test_context_locale_is_a_list.py", "tests/test_core_pin.py", "tests/test_cpu_by_type_window.py", "tests/test_cross_origin_iframe.py", "tests/test_cursor_dispatch.py", "tests/test_cursor_wiring.py", "tests/test_docs_name_the_mcp_repo_as_it_is.py", "tests/test_doh_session_prefs_unit.py", "tests/test_drag_motion.py", "tests/test_e2e_hermetic.py", "tests/test_element_handle_actions.py", "tests/test_every_action_is_pinned_by_commit_sha.py", "tests/test_every_argument_reaches_the_page_as_playwright_sends_it.py", "tests/test_every_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_a_twin_asks_for_is_routed.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_every_refusal_is_declared.py", "tests/tLine truncated
|
||||
{"id": "wrapper.unit.all.windows", "giro": "G1", "os": ["windows"], "min_tests": 4249, "exact": true, "tests": ["tests/test_a_162_message_is_read_like_a_161_one.py", "tests/test_a_click_makes_one_mousemove_at_its_point.py", "tests/test_a_closed_context_leaves_nothing_in_the_registry.py", "tests/test_a_closed_page_says_nothing.py", "tests/test_a_closed_pipe_is_a_closed_target.py", "tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py", "tests/test_a_context_proxy_carries_its_measured_udp_exit.py", "tests/test_a_context_route_disables_the_cache.py", "tests/test_a_detached_frame_answers_detached.py", "tests/test_a_dialog_is_a_protocol_object.py", "tests/test_a_dialog_is_answered_after_a_pause.py", "tests/test_a_download_finished_before_it_was_announced_is_finished.py", "tests/test_a_failed_expect_carries_its_call_log.py", "tests/test_a_failed_generation_of_the_security_state_keeps_its_evidence.py", "tests/test_a_failed_launch_stops_the_display.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_file_chooser_is_never_dropped_in_silence.py", "tests/test_a_frame_tap_needs_a_context_with_touch.py", "tests/test_a_gil_free_thread_dump_kills_a_busy_process_and_the_stack_watchdog_does_not.py", "tests/test_a_handle_action_walks_like_a_selector_action.py", "tests/test_a_launch_asks_nobody_on_the_internet_where_it_leaves_from.py", "tests/test_a_launch_gives_the_core_its_engine_for_the_security_state.py", "tests/test_a_launch_has_one_deadline.py", "tests/test_a_launch_without_a_session_gets_one.py", "tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py", "tests/test_a_marionette_session_is_asked_after_the_first_window.py", "tests/test_a_module_that_leaves_a_browser_open_fails.py", "tests/test_a_new_page_waits_for_the_engine.py", "tests/test_a_non_finite_number_crosses_the_wire_as_a_tag.py", "tests/test_a_page_closed_before_its_announcement_is_not_announced.py", "tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py", "tests/test_a_path_leaves_as_one_stroke.py", "tests/test_a_port_number_is_held_until_it_is_used.py", "tests/test_a_read_whose_probe_ran_out_is_the_callers_timeout.py", "tests/test_a_request_and_a_response_are_light.py", "tests/test_a_request_says_what_it_is.py", "tests/test_a_screenshot_refuses_what_would_touch_the_page.py", "tests/test_a_screenshot_sends_its_scale_to_the_engine.py", "tests/test_a_session_ends_before_the_next_test_starts.py", "tests/test_a_streamed_upload_is_staged_in_the_session.py", "tests/test_a_stroke_is_judged_by_its_shape_not_its_length.py", "tests/test_a_test_that_is_not_e2e_never_leaves_the_machine.py", "tests/test_a_unit_test_does_not_read_the_seal_of_the_job.py", "tests/test_ab_host.py", "tests/test_ab_host_aa_stable.py", "tests/test_ab_network.py", "tests/test_ab_network_turn_credential.py", "tests/test_ab_network_turn_deallocation.py", "tests/test_ab_network_webrtc_evidence.py", "tests/test_ab_oracle.py", "tests/test_ab_oracle_declared_differences.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_element_handle_serves_every_method_of_the_client.py", "tests/test_an_expect_reads_its_value_once.py", "tests/test_async_api.py", "tests/test_browser_output_is_drained.py", "tests/test_ci_downloads_are_authenticated.py", "tests/test_ci_drive_gate_goes_through_the_core.py", "tests/test_ci_host_gate.py", "tests/test_ci_host_gate_ab.py", "tests/test_ci_lab_geoip.py", "tests/test_ci_lab_geoip_verify.py", "tests/test_ci_lab_intermediates.py", "tests/test_ci_lab_security_state.py", "tests/test_ci_linux_legs_read_no_mirror.py", "tests/test_ci_poison_host.py", "tests/test_ci_published_set.py", "tests/test_ci_real_geoip_check.py", "tests/test_ci_real_geoip_exit_code.py", "tests/test_ci_runs_once_per_commit.py", "tests/test_ci_suite_run.py", "tests/test_ci_verdict.py", "tests/test_ci_windows_temp_is_on_d.py", "tests/test_ci_workflows_build_the_geoip_database.py", "tests/test_ci_workflows_set_the_intermediates_list.py", "tests/test_ci_workflows_set_the_security_state.py", "tests/test_cli.py", "tests/test_click_rhythm.py", "tests/test_connect_does_not_start_threads_on_the_loop.py", "tests/test_context_locale_is_a_list.py", "tests/test_core_pin.py", "tests/test_cpu_by_type_window.py", "tests/test_cross_origin_iframe.py", "tests/test_cursor_dispatch.py", "tests/test_cursor_wiring.py", "tests/test_docs_name_the_mcp_repo_as_it_is.py", "tests/test_doh_session_prefs_unit.py", "tests/test_drag_motion.py", "tests/test_e2e_hermetic.py", "tests/test_element_handle_actions.py", "tests/test_every_action_is_pinned_by_commit_sha.py", "tests/test_every_argument_reaches_the_page_as_playwright_sends_it.py", "tests/test_every_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_a_twin_asks_for_is_routed.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_every_pytest_process_clears_the_gp_Line truncated
|
||||
{"id": "wrapper.unit.all.linux", "giro": "G1", "os": ["linux"], "min_tests": 4250, "exact": true, "tests": ["tests/test_a_162_message_is_read_like_a_161_one.py", "tests/test_a_click_makes_one_mousemove_at_its_point.py", "tests/test_a_closed_context_leaves_nothing_in_the_registry.py", "tests/test_a_closed_page_says_nothing.py", "tests/test_a_closed_pipe_is_a_closed_target.py", "tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py", "tests/test_a_context_proxy_carries_its_measured_udp_exit.py", "tests/test_a_context_route_disables_the_cache.py", "tests/test_a_detached_frame_answers_detached.py", "tests/test_a_dialog_is_a_protocol_object.py", "tests/test_a_dialog_is_answered_after_a_pause.py", "tests/test_a_download_finished_before_it_was_announced_is_finished.py", "tests/test_a_failed_expect_carries_its_call_log.py", "tests/test_a_failed_generation_of_the_security_state_keeps_its_evidence.py", "tests/test_a_failed_launch_stops_the_display.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_file_chooser_is_never_dropped_in_silence.py", "tests/test_a_frame_tap_needs_a_context_with_touch.py", "tests/test_a_gil_free_thread_dump_kills_a_busy_process_and_the_stack_watchdog_does_not.py", "tests/test_a_handle_action_walks_like_a_selector_action.py", "tests/test_a_launch_asks_nobody_on_the_internet_where_it_leaves_from.py", "tests/test_a_launch_gives_the_core_its_engine_for_the_security_state.py", "tests/test_a_launch_has_one_deadline.py", "tests/test_a_launch_without_a_session_gets_one.py", "tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py", "tests/test_a_marionette_session_is_asked_after_the_first_window.py", "tests/test_a_module_that_leaves_a_browser_open_fails.py", "tests/test_a_new_page_waits_for_the_engine.py", "tests/test_a_non_finite_number_crosses_the_wire_as_a_tag.py", "tests/test_a_page_closed_before_its_announcement_is_not_announced.py", "tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py", "tests/test_a_path_leaves_as_one_stroke.py", "tests/test_a_port_number_is_held_until_it_is_used.py", "tests/test_a_read_whose_probe_ran_out_is_the_callers_timeout.py", "tests/test_a_request_and_a_response_are_light.py", "tests/test_a_request_says_what_it_is.py", "tests/test_a_screenshot_refuses_what_would_touch_the_page.py", "tests/test_a_screenshot_sends_its_scale_to_the_engine.py", "tests/test_a_session_ends_before_the_next_test_starts.py", "tests/test_a_streamed_upload_is_staged_in_the_session.py", "tests/test_a_stroke_is_judged_by_its_shape_not_its_length.py", "tests/test_a_test_that_is_not_e2e_never_leaves_the_machine.py", "tests/test_a_unit_test_does_not_read_the_seal_of_the_job.py", "tests/test_ab_host.py", "tests/test_ab_host_aa_stable.py", "tests/test_ab_network.py", "tests/test_ab_network_turn_credential.py", "tests/test_ab_network_turn_deallocation.py", "tests/test_ab_network_webrtc_evidence.py", "tests/test_ab_oracle.py", "tests/test_ab_oracle_declared_differences.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_element_handle_serves_every_method_of_the_client.py", "tests/test_an_expect_reads_its_value_once.py", "tests/test_async_api.py", "tests/test_browser_output_is_drained.py", "tests/test_ci_downloads_are_authenticated.py", "tests/test_ci_drive_gate_goes_through_the_core.py", "tests/test_ci_host_gate.py", "tests/test_ci_host_gate_ab.py", "tests/test_ci_lab_geoip.py", "tests/test_ci_lab_geoip_verify.py", "tests/test_ci_lab_intermediates.py", "tests/test_ci_lab_security_state.py", "tests/test_ci_linux_legs_read_no_mirror.py", "tests/test_ci_poison_host.py", "tests/test_ci_published_set.py", "tests/test_ci_real_geoip_check.py", "tests/test_ci_real_geoip_exit_code.py", "tests/test_ci_runs_once_per_commit.py", "tests/test_ci_suite_run.py", "tests/test_ci_verdict.py", "tests/test_ci_windows_temp_is_on_d.py", "tests/test_ci_workflows_build_the_geoip_database.py", "tests/test_ci_workflows_set_the_intermediates_list.py", "tests/test_ci_workflows_set_the_security_state.py", "tests/test_cli.py", "tests/test_click_rhythm.py", "tests/test_connect_does_not_start_threads_on_the_loop.py", "tests/test_context_locale_is_a_list.py", "tests/test_core_pin.py", "tests/test_cpu_by_type_window.py", "tests/test_cross_origin_iframe.py", "tests/test_cursor_dispatch.py", "tests/test_cursor_wiring.py", "tests/test_docs_name_the_mcp_repo_as_it_is.py", "tests/test_doh_session_prefs_unit.py", "tests/test_drag_motion.py", "tests/test_e2e_hermetic.py", "tests/test_element_handle_actions.py", "tests/test_every_action_is_pinned_by_commit_sha.py", "tests/test_every_argument_reaches_the_page_as_playwright_sends_it.py", "tests/test_every_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_a_twin_asks_for_is_routed.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_every_refusal_is_declared.py", "tests/tLine truncated
|
||||
{"id": "wrapper.unit.all.windows", "giro": "G1", "os": ["windows"], "min_tests": 4262, "exact": true, "tests": ["tests/test_a_162_message_is_read_like_a_161_one.py", "tests/test_a_click_makes_one_mousemove_at_its_point.py", "tests/test_a_closed_context_leaves_nothing_in_the_registry.py", "tests/test_a_closed_page_says_nothing.py", "tests/test_a_closed_pipe_is_a_closed_target.py", "tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py", "tests/test_a_context_proxy_carries_its_measured_udp_exit.py", "tests/test_a_context_route_disables_the_cache.py", "tests/test_a_detached_frame_answers_detached.py", "tests/test_a_dialog_is_a_protocol_object.py", "tests/test_a_dialog_is_answered_after_a_pause.py", "tests/test_a_download_finished_before_it_was_announced_is_finished.py", "tests/test_a_failed_expect_carries_its_call_log.py", "tests/test_a_failed_generation_of_the_security_state_keeps_its_evidence.py", "tests/test_a_failed_launch_stops_the_display.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_file_chooser_is_never_dropped_in_silence.py", "tests/test_a_frame_tap_needs_a_context_with_touch.py", "tests/test_a_gil_free_thread_dump_kills_a_busy_process_and_the_stack_watchdog_does_not.py", "tests/test_a_handle_action_walks_like_a_selector_action.py", "tests/test_a_launch_asks_nobody_on_the_internet_where_it_leaves_from.py", "tests/test_a_launch_gives_the_core_its_engine_for_the_security_state.py", "tests/test_a_launch_has_one_deadline.py", "tests/test_a_launch_without_a_session_gets_one.py", "tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py", "tests/test_a_marionette_session_is_asked_after_the_first_window.py", "tests/test_a_module_that_leaves_a_browser_open_fails.py", "tests/test_a_new_page_waits_for_the_engine.py", "tests/test_a_non_finite_number_crosses_the_wire_as_a_tag.py", "tests/test_a_page_closed_before_its_announcement_is_not_announced.py", "tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py", "tests/test_a_path_leaves_as_one_stroke.py", "tests/test_a_port_number_is_held_until_it_is_used.py", "tests/test_a_read_whose_probe_ran_out_is_the_callers_timeout.py", "tests/test_a_request_and_a_response_are_light.py", "tests/test_a_request_says_what_it_is.py", "tests/test_a_screenshot_refuses_what_would_touch_the_page.py", "tests/test_a_screenshot_sends_its_scale_to_the_engine.py", "tests/test_a_session_ends_before_the_next_test_starts.py", "tests/test_a_streamed_upload_is_staged_in_the_session.py", "tests/test_a_stroke_is_judged_by_its_shape_not_its_length.py", "tests/test_a_test_that_is_not_e2e_never_leaves_the_machine.py", "tests/test_a_unit_test_does_not_read_the_seal_of_the_job.py", "tests/test_ab_host.py", "tests/test_ab_host_aa_stable.py", "tests/test_ab_network.py", "tests/test_ab_network_turn_credential.py", "tests/test_ab_network_turn_deallocation.py", "tests/test_ab_network_webrtc_evidence.py", "tests/test_ab_oracle.py", "tests/test_ab_oracle_declared_differences.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_element_handle_serves_every_method_of_the_client.py", "tests/test_an_expect_reads_its_value_once.py", "tests/test_async_api.py", "tests/test_browser_output_is_drained.py", "tests/test_ci_downloads_are_authenticated.py", "tests/test_ci_drive_gate_goes_through_the_core.py", "tests/test_ci_host_gate.py", "tests/test_ci_host_gate_ab.py", "tests/test_ci_lab_geoip.py", "tests/test_ci_lab_geoip_verify.py", "tests/test_ci_lab_intermediates.py", "tests/test_ci_lab_security_state.py", "tests/test_ci_linux_legs_read_no_mirror.py", "tests/test_ci_poison_host.py", "tests/test_ci_published_set.py", "tests/test_ci_real_geoip_check.py", "tests/test_ci_real_geoip_exit_code.py", "tests/test_ci_runs_once_per_commit.py", "tests/test_ci_suite_run.py", "tests/test_ci_verdict.py", "tests/test_ci_windows_temp_is_on_d.py", "tests/test_ci_workflows_build_the_geoip_database.py", "tests/test_ci_workflows_set_the_intermediates_list.py", "tests/test_ci_workflows_set_the_security_state.py", "tests/test_cli.py", "tests/test_click_rhythm.py", "tests/test_connect_does_not_start_threads_on_the_loop.py", "tests/test_context_locale_is_a_list.py", "tests/test_core_pin.py", "tests/test_cpu_by_type_window.py", "tests/test_cross_origin_iframe.py", "tests/test_cursor_dispatch.py", "tests/test_cursor_wiring.py", "tests/test_docs_name_the_mcp_repo_as_it_is.py", "tests/test_doh_session_prefs_unit.py", "tests/test_drag_motion.py", "tests/test_e2e_hermetic.py", "tests/test_element_handle_actions.py", "tests/test_every_action_is_pinned_by_commit_sha.py", "tests/test_every_argument_reaches_the_page_as_playwright_sends_it.py", "tests/test_every_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_a_twin_asks_for_is_routed.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_every_pytest_process_clears_the_gp_Line truncated
|
||||
{"id": "wrapper.e2e.securitystate", "giro": "G2", "os": ["linux", "windows"], "min_tests": 4, "exact": true, "tests": ["tests/test_security_state_engine_e2e.py"], "marker": "e2e", "needs_root": false, "note": "The security state the core declares, against the engine: the engine launched directly in its generate mode makes what it is given (the contract's result, security_state/ with the bytes of the full filter and of the delta, the core's own validation of it); a normal launch declares no pref of the mode and re-imports nothing; a certificate that Mozilla's CRLite test data say is revoked in a delta is refused at the first navigation (SEC_ERROR_REVOKED_CERTIFICATE) while a valid one loads, and the revoked one loads when the ready directory has no data; a ready directory with no or an empty security_state/ starts. Certificates made on the run (a fresh root trusted in cert9.db by the engine's own xpcshell, Mozilla's default test key as the key of CN=int), servers on loopback, no network. Red on firefox-67 (no generate mode).", "core_dumps": "invpw-cores"},
|
||||
{"id": "wrapper.e2e.suite.linux.1", "giro": "G2", "os": ["linux"], "min_tests": 447, "exact": true, "tests": ["tests/test_a_closed_browser_leaves_the_others_alone_e2e.py", "tests/test_a_context_that_ends_leaves_no_process_e2e.py", "tests/test_a_cors_preflight_is_not_a_request_of_the_page_e2e.py", "tests/test_a_declared_webgl_extension_survives_its_use_e2e.py", "tests/test_a_granted_permission_is_the_one_the_page_asks_for_e2e.py", "tests/test_a_held_ice_port_blinds_the_loopback_checks_e2e.py", "tests/test_a_launch_without_a_session_gets_one_e2e.py", "tests/test_a_left_documents_body_is_evicted_e2e.py", "tests/test_a_mouse_click_makes_one_mousemove_on_its_point_e2e.py", "tests/test_a_page_over_ipv6_gathers_on_a_machine_declared_without_it_e2e.py", "tests/test_a_popup_is_reported_when_the_engine_says_it_is_ready_as_playwright_does_e2e.py", "tests/test_a_screenshot_draws_the_text_of_the_bundled_fonts_as_the_content_does_e2e.py", "tests/test_a_screenshot_honours_its_scale_e2e.py", "tests/test_a_screenshot_refuses_what_would_touch_the_page_e2e.py", "tests/test_a_served_browser_answers_a_plain_client_e2e.py", "tests/test_a_tiny_download_on_a_served_browser_is_saved_e2e.py", "tests/test_a_turn_name_over_tcp_goes_through_the_proxy_of_the_context_e2e.py", "tests/test_accept_language_on_the_wire_e2e.py", "tests/test_browser_output_is_drained.py", "tests/test_click_rhythm.py", "tests/test_closing_one_of_four_browsers_does_not_hold_the_loop_e2e.py", "tests/test_control_a_selects_all_in_a_field_e2e.py", "tests/test_cross_origin_iframe.py", "tests/test_declared_host_network_e2e.py", "tests/test_detectors_e2e.py", "tests/test_e2e.py", "tests/test_element_handle_actions.py", "tests/test_element_screenshot_e2e.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_file_chooser.py", "tests/test_fingerprint_surface.py", "tests/test_fission_frames_history_and_processes_e2e.py", "tests/test_fission_frames_workers_storage_and_special_frames_e2e.py", "tests/test_frames_outlive_the_back_forward_cache_e2e.py", "tests/test_goto_networkidle_after_spa_e2e.py", "tests/test_goto_script_redirect_e2e.py", "tests/test_hidden_display_linux.py", "tests/test_ice_names_by_the_context_proxy_e2e.py::test_the_ice_name_of_a_context_goes_by_the_proxy_of_that_context", "tests/test_ignore_https_errors_e2e.py", "tests/test_injected_node_surface.py", "tests/test_juggler_connection.py", "tests/test_juggler_posix_pipe.py", "tests/test_juggler_transport.py", "tests/test_navigation_across_processes_e2e.py", "tests/test_navigation_response.py", "tests/test_networkidle_reaches_the_client_e2e.py", "tests/test_oop_frame_element.py", "tests/test_oop_frame_geometry.py", "tests/test_page_number_follows_the_call.py", "tests/test_persistent_profile_keeps_state.py", "tests/test_pointer_position.py", "tests/test_popups_reach_the_client_e2e.py", "tests/test_preload_newtab_turns_the_privileged_about_process_off_e2e.py", "tests/test_realness_behind_a_declared_exit_e2e.py", "tests/test_resolver_race_e2e.py", "tests/test_route_header_order_e2e.py", "tests/test_same_document_goto_e2e.py", "tests/test_screencast.py", "tests/test_screencast_stop_e2e.py", "tests/test_screenshot_looks_where_you_are.py", "tests/test_security_state_engine_e2e.py", "tests/test_service_worker.py", "tests/test_service_worker_controller_e2e.py", "tests/test_set_offline_e2e.py", "tests/test_shadow_trusted_input.py", "tests/test_strict_and_force.py", "tests/test_the_callers_code_is_not_counted_e2e.py", "tests/test_the_device_enumeration_takes_the_declared_time_e2e.py", "tests/test_the_engine_is_born_in_the_job_e2e.py::test_a_launch_scans_no_process_of_the_machine", "tests/test_the_engine_is_born_in_the_job_e2e.py::test_after_close_no_process_of_the_session_is_left", "tests/test_the_hosts_file_of_the_host_is_never_read_e2e.py", "tests/test_trial_does_not_act.py", "tests/test_turn_over_tcp_is_tried_for_real_e2e.py", "tests/test_ua_widget_not_selectable.py", "tests/test_voices_e2e.py", "tests/test_wait_for_function.py", "tests/test_webgl_draws_on_the_engine_s_own_gl_e2e.py", "tests/test_webgl_noise_active.py", "tests/test_webrtc_realness.py::test_a_gateway_that_is_far_away_still_gives_the_page_a_srflx_born_through_its_relay", "tests/test_webrtc_realness.py::test_a_gather_after_the_page_loaded_through_the_gateway_costs_only_the_road_to_the_server", "tests/test_webrtc_realness.py::test_a_host_with_ipv6_addresses_gathers_through_an_ipv4_relay", "tests/test_webrtc_realness.py::test_a_proxy_that_does_not_relay_udp_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_a_proxy_whose_relay_never_answers_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_a_proxy_whose_udp_leaves_from_another_address_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_not_blocked_behind_tcp_only_socks", "tests/test_webrtc_realness.py::test_the_first_candidate_of_a_gather_does_not_wait_for_a_gateway_that_is_far_away", "tests/test_webrtc_realness.py::test_the_turn_over_tcp_of_a_context_goes_throuLine truncated
|
||||
{"id": "wrapper.e2e.suite.linux.2", "giro": "G2", "os": ["linux"], "min_tests": 414, "exact": true, "tests": ["tests/test_a_click_waits_for_the_navigation_it_plans_e2e.py", "tests/test_a_context_init_script_runs_once_e2e.py", "tests/test_a_drag_keeps_its_buttons_pressed_e2e.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_goto_to_a_response_with_no_document_ends_e2e.py", "tests/test_a_keepalive_request_reaches_the_client_e2e.py", "tests/test_a_latin_letter_on_a_cyrillic_persona_e2e.py", "tests/test_a_page_cannot_probe_the_juggler_e2e.py", "tests/test_a_page_that_moves_on_e2e.py", "tests/test_a_pointer_event_is_handled_before_the_call_returns_e2e.py", "tests/test_a_request_says_what_it_is_e2e.py", "tests/test_a_worker_comes_back_with_its_page_from_the_cache_e2e.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_isolated_page_and_the_next_e2e.py", "tests/test_bypass_csp_e2e.py", "tests/test_caller_world_handles_e2e.py", "tests/test_canvas_reads_as_drawn.py", "tests/test_canvas_render_stealth.py", "tests/test_context_locale_e2e.py", "tests/test_context_proxy_only_resolves_by_doh_e2e.py", "tests/test_doh_through_the_proxy_e2e.py", "tests/test_doh_under_stress_e2e.py", "tests/test_download_is_intercepted_e2e.py", "tests/test_drag_motion.py", "tests/test_expose_binding_e2e.py", "tests/test_fakeweb_p4_e2e.py", "tests/test_fingerprint_consistency.py", "tests/test_fission_frames_dialogs_downloads_popups_e2e.py", "tests/test_fission_frames_route_and_bindings_e2e.py", "tests/test_fission_identity_parity_e2e.py", "tests/test_fission_iframe_crash_e2e.py", "tests/test_fission_strategy1_bench.py", "tests/test_goto_to_the_same_url_e2e.py", "tests/test_http3_through_the_proxy_e2e.py", "tests/test_input_is_born_before_the_page_sees_it_e2e.py", "tests/test_juggler_actions.py", "tests/test_juggler_event_listeners.py", "tests/test_juggler_injected.py::test_a_javascript_that_THROWS_arrives_as_an_error_not_as_None", "tests/test_juggler_injected.py::test_actionability_DISTINGUISHES_instead_of_always_saying_yes", "tests/test_juggler_injected.py::test_reads_that_make_no_sense_are_REJECTED", "tests/test_juggler_injected.py::test_states_DISCRIMINATE_instead_of_always_saying_true", "tests/test_juggler_injected.py::test_the_DOM_READING_group", "tests/test_juggler_injected.py::test_the_selector_engines_respond", "tests/test_juggler_injected.py::test_the_text_reads", "tests/test_juggler_lifecycle_e2e.py", "tests/test_key_delay_reaches_the_keyboard.py", "tests/test_keyboard_rhythm.py", "tests/test_long_session_e2e.py", "tests/test_mouse.py", "tests/test_mouse_events_keep_their_values_e2e.py", "tests/test_new_page_defaults.py", "tests/test_popup_destinations_e2e.py", "tests/test_popup_pages.py", "tests/test_proxy_http_auth_e2e.py", "tests/test_proxy_reaches_the_browser.py", "tests/test_proxy_socks_auth_e2e.py", "tests/test_requestless_navigation.py", "tests/test_route_abort_code.py", "tests/test_route_e2e.py", "tests/test_route_post_data_e2e.py", "tests/test_route_sends_a_navigation_elsewhere_e2e.py", "tests/test_route_superseded_e2e.py", "tests/test_same_document_navigation.py", "tests/test_screenshot_of_text_returns_linux_e2e.py", "tests/test_scroll_into_view.py", "tests/test_scroll_only_if_needed_e2e.py", "tests/test_service_workers_blocked.py", "tests/test_set_input_files_payloads.py", "tests/test_software_compositing_is_declared_e2e.py", "tests/test_the_association_is_ready_when_the_peerconnection_is_born_e2e.py", "tests/test_the_callers_code_runs_once_e2e.py", "tests/test_the_close_returns_when_the_browser_has_exited_e2e.py", "tests/test_the_favicon_stays_out_of_sight_e2e.py", "tests/test_the_font_list_is_the_bundle_e2e.py", "tests/test_the_parent_reads_the_bundle_from_fontconfig_s_cache_linux_e2e.py", "tests/test_the_scheme_is_the_personas_e2e.py", "tests/test_the_whole_udp_chain_by_name_e2e.py::test_a_turn_srflx_by_name_arrives_through_the_relay_when_the_exit_of_the_lab_is_loopback", "tests/test_typing_a_character_without_a_key_e2e.py", "tests/test_wait_for_timeout.py", "tests/test_web_fonts_of_closed_contexts_e2e.py"], "marker": "e2e", "needs_root": false, "windows_twin": "wrapper.e2e.suite.windows.2", "note": "Part 2 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 2 rows of linux are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 564 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapLine truncated
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
"""What a popup twin records about each element it clicks, so that a red run says what the click and the geometry were, and a green run leaves the numbers to compare.
|
||||
|
||||
A twin that clicks an element and waits for a popup (the select dropdown) used to say "the dropdown did not open" and nothing about the click: where it was sent, at which scale, what the
|
||||
element's box was in its document and in the window, and what the popup was doing. This module is what the twin keeps for each element, and writes:
|
||||
|
||||
* ``click``: the point in CSS pixels, and the point the driver sent (the unit it is in and the device point it makes: CSS times the scale the driver knows);
|
||||
* ``scales``: the record of ``Driver.scales()`` (the page's and the chrome's ``devicePixelRatio`` and the real scale of the screen), once per browser;
|
||||
* ``select_rect``: ``getBoundingClientRect`` of the element inside its own document, and, for an element of a frame, ``iframe_rect``: the frame element's box in the top document;
|
||||
* ``mozInnerScreen``: ``window.mozInnerScreenX/Y`` of the top document and, for a frame, of the frame's document;
|
||||
* ``popup``: the state after the click (the first look), the last look of the wait (at the deadline) and, when the popup did not reach the state, a second look (the select test: a short wait on the same condition, so that a popup that comes late is seen to come late).
|
||||
|
||||
A read that fails is recorded in ``errors`` and never raised: the diagnosis must not replace the finding. The record is in the message of the failure and, on a runner (``RUNNER_TEMP`` set), in
|
||||
``$RUNNER_TEMP/invpw-evidence/popup-diagnostics/<case>-<browser>.json``, the folder every e2e job uploads (see ``_watchdog_log``), whatever the result.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, Mapping, Optional, Sequence
|
||||
|
||||
from _watchdog_log import EVIDENCE_FOLDER
|
||||
|
||||
#: The folder of this evidence inside ``$RUNNER_TEMP/invpw-evidence``.
|
||||
SUBFOLDER = "popup-diagnostics"
|
||||
|
||||
#: The top document: the element's box, the frame element's box, the window's place on the screen. Both ids are given by the page of the twin.
|
||||
TOP_GEOMETRY_JS = """(() => {
|
||||
const box = id => { const e = document.getElementById(id); if (!e) { return null; } const b = e.getBoundingClientRect(); return {x: b.x, y: b.y, w: b.width, h: b.height}; };
|
||||
return {select: box(%(select)s), iframe: box(%(iframe)s), mozInnerScreen: [window.mozInnerScreenX, window.mozInnerScreenY], scroll: [window.scrollX, window.scrollY]};
|
||||
})()"""
|
||||
|
||||
#: The document of a frame: the element's box inside it and its own place on the screen.
|
||||
FRAME_GEOMETRY_JS = """(() => {
|
||||
const e = document.getElementById(%(select)s); const b = e ? e.getBoundingClientRect() : null;
|
||||
return {select: b && {x: b.x, y: b.y, w: b.width, h: b.height}, mozInnerScreen: [window.mozInnerScreenX, window.mozInnerScreenY], scroll: [window.scrollX, window.scrollY]};
|
||||
})()"""
|
||||
|
||||
|
||||
def _failed(exc: BaseException) -> str:
|
||||
return "%s: %s" % (type(exc).__name__, str(exc)[:300])
|
||||
|
||||
|
||||
def look_at_geometry(driver: Any, in_frame: bool, select_id: str = "s", frame_id: str = "f") -> Dict[str, Any]:
|
||||
"""The boxes and the window's place for one element, read before the click. ``driver.eval`` reads the top document, ``driver.eval_in_frame`` the frame's.
|
||||
A read that fails leaves its field out and says why in ``errors``."""
|
||||
ids = {"select": json.dumps(select_id), "iframe": json.dumps(frame_id)}
|
||||
out: Dict[str, Any] = {"errors": {}}
|
||||
top: Optional[Dict[str, Any]] = None
|
||||
try:
|
||||
top = driver.eval(TOP_GEOMETRY_JS % ids)
|
||||
except Exception as exc: # noqa: BLE001 the diagnosis never replaces the finding
|
||||
out["errors"]["top_document"] = _failed(exc)
|
||||
top = top or {}
|
||||
out["mozInnerScreen"] = {"top": top.get("mozInnerScreen")}
|
||||
if not in_frame:
|
||||
out["select_rect"] = top.get("select")
|
||||
out["iframe_rect"] = None
|
||||
else:
|
||||
out["iframe_rect"] = top.get("iframe")
|
||||
try:
|
||||
inner = driver.eval_in_frame(FRAME_GEOMETRY_JS % ids)
|
||||
out["select_rect"] = inner.get("select")
|
||||
out["mozInnerScreen"]["frame"] = inner.get("mozInnerScreen")
|
||||
except Exception as exc: # noqa: BLE001
|
||||
out["errors"]["frame_document"] = _failed(exc)
|
||||
out["select_rect"] = None
|
||||
out["mozInnerScreen"]["frame"] = None
|
||||
if not out["errors"]:
|
||||
del out["errors"]
|
||||
return out
|
||||
|
||||
|
||||
def click_record(driver: Any, css: Sequence[float]) -> Dict[str, Any]:
|
||||
"""The click as asked (CSS pixels) and as the driver sent it (``driver.last_click``: the point, its unit, the device point), as the driver wrote it."""
|
||||
return {"css": list(css), "sent": getattr(driver, "last_click", None)}
|
||||
|
||||
|
||||
class Diagnostics:
|
||||
"""The record of one browser on one case: its scales and one entry per element."""
|
||||
|
||||
def __init__(self, case: str, browser: str) -> None:
|
||||
self.case, self.browser = case, browser
|
||||
self.scales: Optional[Dict[str, Any]] = None
|
||||
self.entries: Dict[str, Dict[str, Any]] = {}
|
||||
self.save_error: Optional[str] = None
|
||||
|
||||
def entry(self, name: str) -> Dict[str, Any]:
|
||||
return self.entries.setdefault(name, {})
|
||||
|
||||
def record(self) -> Dict[str, Any]:
|
||||
return {"case": self.case, "browser": self.browser, "scales": self.scales, "elements": self.entries}
|
||||
|
||||
def message(self, headline: str, name: str) -> str:
|
||||
"""``headline``, then everything known about the element ``name`` and the scales, as one JSON line a reader can paste."""
|
||||
body = {"case": self.case, "browser": self.browser, "element": name, "scales": self.scales, **self.entries.get(name, {})}
|
||||
return "%s\n diagnostics: %s" % (headline, json.dumps(body, sort_keys=True))
|
||||
|
||||
def path(self, environ: Mapping[str, str]) -> Optional[Path]:
|
||||
runner = environ.get("RUNNER_TEMP")
|
||||
if not runner:
|
||||
return None
|
||||
return Path(runner) / EVIDENCE_FOLDER / SUBFOLDER / ("%s-%s.json" % (self.case, self.browser))
|
||||
|
||||
def save(self, environ: Optional[Mapping[str, str]] = None) -> Optional[Path]:
|
||||
"""Writes the record where the jobs upload it; None off a runner. A failed write is kept in ``save_error`` and never raised: this runs while a finding may be on its way up."""
|
||||
path = self.path(os.environ if environ is None else environ)
|
||||
if path is None:
|
||||
return None
|
||||
try:
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text(json.dumps(self.record(), indent=1, sort_keys=True) + "\n", encoding="utf-8")
|
||||
except OSError as exc:
|
||||
self.save_error = _failed(exc)
|
||||
return None
|
||||
return path
|
||||
@@ -72,6 +72,10 @@ class Driver:
|
||||
"""What a twin does with a page, on any browser. ``chrome.script(js, args)`` is chrome scope through Marionette."""
|
||||
|
||||
chrome: Any
|
||||
#: Which browser this is, in the names of a record and of its evidence file.
|
||||
kind = "driver"
|
||||
#: The last ``click``, as the driver sent it: ``{"point": [x, y], "unit": ..., "device": [x, y]}`` (None before the first click).
|
||||
last_click: Optional[Dict[str, Any]] = None
|
||||
|
||||
def goto(self, url: str) -> None:
|
||||
raise NotImplementedError
|
||||
@@ -80,6 +84,10 @@ class Driver:
|
||||
"""The value of a JavaScript expression in the top document (a JSON-able value)."""
|
||||
raise NotImplementedError
|
||||
|
||||
def eval_in_frame(self, expression: str) -> Any:
|
||||
"""The value of a JavaScript expression in the document of the first frame of the top document (a JSON-able value)."""
|
||||
raise NotImplementedError
|
||||
|
||||
def move(self, x: float, y: float, steps: int = 1) -> None:
|
||||
raise NotImplementedError
|
||||
|
||||
@@ -99,6 +107,8 @@ class Driver:
|
||||
class PlaywrightDriver(Driver):
|
||||
"""Ours: a page of the wrapper's client, and the chrome of the engine through Marionette."""
|
||||
|
||||
kind = "ours"
|
||||
|
||||
def __init__(self, page, chrome: Chrome) -> None:
|
||||
self.page, self.chrome = page, chrome
|
||||
|
||||
@@ -108,10 +118,21 @@ class PlaywrightDriver(Driver):
|
||||
def eval(self, expression: str) -> Any:
|
||||
return self.page.evaluate("() => (%s)" % expression)
|
||||
|
||||
def eval_in_frame(self, expression: str) -> Any:
|
||||
frames = [frame for frame in self.page.frames if frame != self.page.main_frame]
|
||||
return frames[0].evaluate("() => (%s)" % expression)
|
||||
|
||||
def move(self, x: float, y: float, steps: int = 1) -> None:
|
||||
self.page.mouse.move(x, y, steps=steps)
|
||||
|
||||
def click(self, x: float, y: float) -> None:
|
||||
# the client sends the point in CSS pixels of the page; the device point is that times the page's (declared) scale
|
||||
try:
|
||||
scale = self.page.evaluate("() => window.devicePixelRatio")
|
||||
device: Optional[list] = [x * scale, y * scale]
|
||||
except Exception: # noqa: BLE001 a record of the click never stops the click
|
||||
device = None
|
||||
self.last_click = {"point": [x, y], "unit": "CSS pixels of the page, as page.mouse.click sends them", "device": device}
|
||||
self.page.mouse.click(x, y)
|
||||
|
||||
def wait_for_timeout(self, ms: int) -> None:
|
||||
@@ -135,7 +156,7 @@ const win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
const b = win.gBrowser.selectedBrowser.getBoundingClientRect();
|
||||
win.focus();
|
||||
win.synthesizeMouseEvent(type, b.left + x, b.top + y, {button, clickCount: clicks, modifiers: 0, inputSource: 1}, {ignoreRootScrollFrame: false, isDOMEventSynthesized: true});
|
||||
return JSON.stringify({ok: true});
|
||||
return JSON.stringify({ok: true, at: [b.left + x, b.top + y], dpr: win.devicePixelRatio});
|
||||
"""
|
||||
|
||||
|
||||
@@ -222,6 +243,8 @@ class RetailSession:
|
||||
|
||||
|
||||
class RetailDriver(Driver):
|
||||
kind = "retail"
|
||||
|
||||
def __init__(self, session: RetailSession) -> None:
|
||||
self.session = session
|
||||
self.chrome = RetailChrome(session)
|
||||
@@ -234,8 +257,18 @@ class RetailDriver(Driver):
|
||||
value = self.session.call("content", "WebDriver:ExecuteScript", {"script": "return JSON.stringify(%s);" % expression, "args": []})["value"]
|
||||
return json.loads(value) if value is not None else None
|
||||
|
||||
def _send(self, kind: str, x: float, y: float, button: int = 0, clicks: int = 0) -> None:
|
||||
self.chrome.script(SEND_JS, (kind, x, y, button, clicks))
|
||||
def eval_in_frame(self, expression: str) -> Any:
|
||||
"""Through Marionette: the first frame element becomes the context of the script, and the top document is the context again when the read ends."""
|
||||
found = self.session.call("content", "WebDriver:FindElement", {"using": "css selector", "value": "iframe"})["value"]
|
||||
self.session.call("content", "WebDriver:SwitchToFrame", {"id": found})
|
||||
try:
|
||||
value = self.session.call("content", "WebDriver:ExecuteScript", {"script": "return JSON.stringify(%s);" % expression, "args": []})["value"]
|
||||
finally:
|
||||
self.session.call("content", "WebDriver:SwitchToParentFrame", {})
|
||||
return json.loads(value) if value is not None else None
|
||||
|
||||
def _send(self, kind: str, x: float, y: float, button: int = 0, clicks: int = 0) -> Dict[str, Any]:
|
||||
return self.chrome.script(SEND_JS, (kind, x, y, button, clicks))
|
||||
|
||||
def move(self, x: float, y: float, steps: int = 1) -> None:
|
||||
# the pointer comes to the point in ``steps`` moves from the last one it made (a move to the point it is on makes no event, as on every browser)
|
||||
@@ -246,8 +279,12 @@ class RetailDriver(Driver):
|
||||
|
||||
def click(self, x: float, y: float) -> None:
|
||||
self.move(x, y)
|
||||
self._send("mousedown", x, y, 0, 1)
|
||||
down = self._send("mousedown", x, y, 0, 1)
|
||||
self._send("mouseup", x, y, 0, 1)
|
||||
# the point goes to the window's widget in CSS pixels of the chrome (the content area's place added); the device point is that times the chrome's scale
|
||||
at, scale = down.get("at"), down.get("dpr")
|
||||
self.last_click = {"point": at, "unit": "CSS pixels of the chrome window, as Window.synthesizeMouseEvent takes them",
|
||||
"device": [at[0] * scale, at[1] * scale] if at and scale else None}
|
||||
|
||||
def wait_for_timeout(self, ms: int) -> None:
|
||||
time.sleep(ms / 1000.0)
|
||||
|
||||
@@ -27,6 +27,11 @@ THE RECORD: for each browser, the rectangles, and the scales: the page's ``devic
|
||||
not the chrome's puts the element at the wrong place by their ratio: the record also keeps ``dx_scaled`` and ``dy_scaled``, against the element scaled by page ratio over chrome ratio, so a red twin
|
||||
shows whether a scale mismatch between the page's CSS pixels and the chrome's is what moves the popup.
|
||||
|
||||
THE DIAGNOSIS (``_popup_evidence``): for each select, every failure of the steps and the verdict of the twin carry the click (CSS point, and the point the driver sent with its unit and its device point),
|
||||
the scales, the select's box in its own document and, for the frame, the frame element's box in the top document, ``mozInnerScreenX/Y`` of the top and of the frame, and the popup's state after the click, at
|
||||
the deadline and at a second look (a short wait on the same condition). The same record is written for every case, green or red, to ``$RUNNER_TEMP/invpw-evidence/popup-diagnostics/<case>-<browser>.json`` (the folder every job uploads), so
|
||||
a green run leaves the numbers to compare with a red one. Without browsers: ``test_the_select_twin_says_what_it_clicked_and_where.py``.
|
||||
|
||||
The engine that answers these values is not released yet: this test is red on an engine that declares the window origin without the map of the popups, on purpose.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
@@ -35,6 +40,7 @@ from typing import Any, Dict
|
||||
|
||||
import pytest
|
||||
from _fission_frames import Sites
|
||||
from _popup_evidence import Diagnostics, click_record, look_at_geometry
|
||||
from _retail_reference import Driver, run_retail_twin
|
||||
from _stock_twin import both, differences
|
||||
from _window_origin import CASES, DEADLINE_S, wait_for
|
||||
@@ -51,6 +57,9 @@ FRAME = """<!doctype html><meta charset=utf-8><title>select in a frame</title>
|
||||
<style>html,body{margin:0;padding:0}select{position:absolute;box-sizing:border-box;width:160px;height:28px;margin:0;left:40px;top:20px}</style>
|
||||
<body><select id=s><option>one</option><option>two</option><option>three</option></select>"""
|
||||
|
||||
#: How long the second look at a popup that missed its deadline lasts (a diagnosis, after the verdict).
|
||||
SECOND_LOOK_S = 2
|
||||
|
||||
#: The selects' rectangles in the top document's viewport, CSS pixels, as the CSS above gives them: x, y, width, height.
|
||||
SELECTS = {"top": {"x": 30, "y": 20, "w": 160, "h": 28}, "frame": {"x": 30 + 40, "y": 120 + 20, "w": 160, "h": 28}}
|
||||
|
||||
@@ -82,15 +91,30 @@ return JSON.stringify({state: popup.state});
|
||||
|
||||
|
||||
def _wait_state(driver: Driver, state: str) -> Dict[str, Any]:
|
||||
"""The popup's state once it is ``state`` (open or closed), polled; the last reading at the deadline."""
|
||||
seen: Dict[str, Any] = {}
|
||||
"""The popup's state once it is ``state`` (open or closed), polled. ``state`` is the last reading (at the deadline when it never came), ``after_click`` the first one."""
|
||||
reads: list = []
|
||||
|
||||
def look() -> bool:
|
||||
seen.update(driver.chrome.script(POPUP_STATE_JS))
|
||||
return seen["state"] == state
|
||||
reads.append(driver.chrome.script(POPUP_STATE_JS))
|
||||
return reads[-1]["state"] == state
|
||||
|
||||
wait_for(driver, look, DEADLINE_S)
|
||||
return seen
|
||||
return {"state": reads[-1]["state"], "after_click": reads[0], "at_deadline": reads[-1], "looks": len(reads)}
|
||||
|
||||
|
||||
def _second_look(driver: Driver, state: str) -> Dict[str, Any]:
|
||||
"""After a deadline that was missed: the same condition once more for ``SECOND_LOOK_S``, to say whether the popup came late (``reached``) and what it was when it did not. A diagnosis: the verdict is already red."""
|
||||
reads: list = []
|
||||
|
||||
def look() -> bool:
|
||||
try:
|
||||
reads.append(driver.chrome.script(POPUP_STATE_JS))
|
||||
except Exception as exc: # noqa: BLE001 the diagnosis never replaces the finding
|
||||
reads.append({"state": "unreadable: %s: %s" % (type(exc).__name__, str(exc)[:200])})
|
||||
return reads[-1]["state"] == state
|
||||
|
||||
reached = wait_for(driver, look, SECOND_LOOK_S)
|
||||
return {"state": reads[-1]["state"], "reached": reached, "looks": len(reads)}
|
||||
|
||||
|
||||
def _measure(driver: Driver, rect: Dict[str, float]) -> Dict[str, Any]:
|
||||
@@ -117,20 +141,49 @@ def _relation(read: Dict[str, Any], page_dpr: float) -> Dict[str, Any]:
|
||||
"dx_scaled": round((popup["left"] - scaled_left) * chrome_dpr, 3), "dy_scaled": round((popup["top"] - scaled_bottom) * chrome_dpr, 3)}
|
||||
|
||||
|
||||
def _steps(sites, driver: Driver) -> Dict[str, Any]:
|
||||
"""What one browser does: click each select, read the popup against its element, close it. {"scales": ..., "measured": {top, frame}}."""
|
||||
driver.goto(sites.url("A", "/page"))
|
||||
scales = driver.scales()
|
||||
measured: Dict[str, Any] = {}
|
||||
for name, rect in SELECTS.items():
|
||||
driver.click(rect["x"] + rect["w"] / 2, rect["y"] + rect["h"] / 2)
|
||||
opened = _wait_state(driver, "open")
|
||||
assert opened["state"] == "open", "the dropdown did not open after a click on the select of the %s document (popup state %r)" % (name, opened)
|
||||
measured[name] = _relation(_measure(driver, rect), scales["page"]["devicePixelRatio"])
|
||||
driver.chrome.script(CLOSE_JS)
|
||||
closed = _wait_state(driver, "closed")
|
||||
assert closed["state"] == "closed", "the dropdown of the %s document did not close (popup state %r)" % (name, closed)
|
||||
return {"scales": scales, "measured": measured}
|
||||
def _steps(sites, driver: Driver, case: str = "unknown") -> Dict[str, Any]:
|
||||
"""What one browser does: click each select, read the popup against its element, close it. {"scales": ..., "measured": {top, frame}, "diagnostics": the record of each select}.
|
||||
|
||||
Every failure here carries the record of the select it is about (``Diagnostics.message``), and the record is saved whatever the result."""
|
||||
diagnostics = Diagnostics(case, driver.kind)
|
||||
try:
|
||||
driver.goto(sites.url("A", "/page"))
|
||||
scales = driver.scales()
|
||||
diagnostics.scales = scales
|
||||
measured: Dict[str, Any] = {}
|
||||
for name, rect in SELECTS.items():
|
||||
entry = diagnostics.entry(name)
|
||||
entry.update(look_at_geometry(driver, in_frame=name == "frame"))
|
||||
point = (rect["x"] + rect["w"] / 2, rect["y"] + rect["h"] / 2)
|
||||
driver.click(*point)
|
||||
entry["click"] = click_record(driver, point)
|
||||
opened = _wait_state(driver, "open")
|
||||
entry["popup"] = {"after_click": opened["after_click"], "at_deadline": opened["at_deadline"], "looks": opened["looks"]}
|
||||
if opened["state"] != "open":
|
||||
entry["popup"]["second_look"] = _second_look(driver, "open")
|
||||
raise AssertionError(diagnostics.message("the dropdown did not open after a click on the select of the %s document (popup state %r)" % (name, opened["state"]), name))
|
||||
measured[name] = _relation(_measure(driver, rect), scales["page"]["devicePixelRatio"])
|
||||
entry["relation"] = measured[name]
|
||||
driver.chrome.script(CLOSE_JS)
|
||||
closed = _wait_state(driver, "closed")
|
||||
entry["popup"]["closed"] = closed["at_deadline"]
|
||||
if closed["state"] != "closed":
|
||||
entry["popup"]["second_look"] = _second_look(driver, "closed")
|
||||
raise AssertionError(diagnostics.message("the dropdown of the %s document did not close (popup state %r)" % (name, closed["state"]), name))
|
||||
finally:
|
||||
diagnostics.save()
|
||||
return {"scales": scales, "measured": measured, "diagnostics": diagnostics.entries}
|
||||
|
||||
|
||||
def _verdict(case: str, retail: Dict[str, Any], ours: Dict[str, Any]) -> str:
|
||||
"""The message of a twin that differs: where the two relations differ, then both records whole (the scales and the diagnostics of each select are in them). Empty when equal."""
|
||||
# one device pixel of the chrome: the popup's position is rounded once, the element's once
|
||||
relation = lambda record: {name: {key: value[key] for key in ("dx", "dy", "dx_scaled", "dy_scaled")} for name, value in record["measured"].items()} # noqa: E731
|
||||
differing = differences(relation(retail), relation(ours), {"dx": 1.0, "dy": 1.0, "dx_scaled": 1.0, "dy_scaled": 1.0}, "measured")
|
||||
if not differing:
|
||||
return ""
|
||||
return ("%s: the dropdown of ours is not where retail's is against its element (dx, dy in device pixels of each chrome, both measured against the element's real rectangle):\n %s%s"
|
||||
% (case, "\n ".join(differing), both(case, retail, ours, "retail")))
|
||||
|
||||
|
||||
@pytest.mark.parametrize("case", sorted(CASES))
|
||||
@@ -139,10 +192,6 @@ def test_a_select_dropdown_opens_at_its_element_as_on_retail(firefox_binary, mon
|
||||
with Sites() as sites:
|
||||
sites.route("A", "/page", lambda handler: TOP % sites.url("B", "/select"))
|
||||
sites.route("B", "/select", FRAME)
|
||||
retail, ours = run_retail_twin(case, firefox_binary, lambda driver: _steps(sites, driver))
|
||||
# one device pixel of the chrome: the popup's position is rounded once, the element's once
|
||||
relation = lambda record: {name: {key: value[key] for key in ("dx", "dy", "dx_scaled", "dy_scaled")} for name, value in record["measured"].items()} # noqa: E731
|
||||
differing = differences(relation(retail), relation(ours), {"dx": 1.0, "dy": 1.0, "dx_scaled": 1.0, "dy_scaled": 1.0}, "measured")
|
||||
assert not differing, (
|
||||
"%s: the dropdown of ours is not where retail's is against its element (dx, dy in device pixels of each chrome, both measured against the element's real rectangle):\n %s%s"
|
||||
% (case, "\n ".join(differing), both(case, retail, ours, "retail")))
|
||||
retail, ours = run_retail_twin(case, firefox_binary, lambda driver: _steps(sites, driver, case))
|
||||
message = _verdict(case, retail, ours)
|
||||
assert not message, message
|
||||
@@ -0,0 +1,299 @@
|
||||
"""The select twin says, for each select it clicks, where the click went and what the geometry was, and leaves the same numbers for a run that passes. No browser: a fake driver.
|
||||
|
||||
``tests/test_a_select_dropdown_opens_at_its_element_e2e.py`` asserted "the dropdown did not open after a click on the select of the frame document" and recorded nothing about the click, so a red
|
||||
run at one display scale could not be told from a wrong point, a wrong scale or a window that moved. Now every failure of the steps carries, for that select: the click point (CSS, and the point the
|
||||
driver sent with its unit and its device point), the scales record, the select's box in its own document and, for the frame, the frame element's box in the top document, ``mozInnerScreenX/Y`` of the top
|
||||
and the frame, and the popup's state after the click, at the deadline and at a second look; the verdict of the twin prints both browsers' records whole; and the record is written, red or green, to
|
||||
``$RUNNER_TEMP/invpw-evidence/popup-diagnostics/<case>-<browser>.json``.
|
||||
|
||||
Known-bad input: the old steps (a message with the popup state and nothing else, no record, no file) and the old drivers (no ``last_click``, no frame read): every test below reads a field that they do not have.
|
||||
Green: the fields, their values from the fake browser, the file of a run that passed, a read that fails (recorded, and the finding stays the dropdown's), and the drivers' own records of a click.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, Tuple
|
||||
|
||||
import pytest
|
||||
|
||||
import _popup_evidence
|
||||
import _retail_reference
|
||||
import test_a_select_dropdown_opens_at_its_element_e2e as select_twin
|
||||
from _waits import wait_until
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
CASE = "1920x1080-dpr1.5"
|
||||
SCALE = 1.5
|
||||
SELECT_BOX = {"x": 30.0, "y": 20.0, "w": 160.0, "h": 28.0}
|
||||
FRAME_SELECT_BOX = {"x": 40.0, "y": 20.0, "w": 160.0, "h": 28.0}
|
||||
IFRAME_BOX = {"x": 30.0, "y": 120.0, "w": 420.0, "h": 200.0}
|
||||
TOP_INNER = [8.0, 72.5]
|
||||
FRAME_INNER = [38.0, 192.5]
|
||||
|
||||
|
||||
class FakeChrome:
|
||||
def __init__(self, driver: "FakeDriver") -> None:
|
||||
self.driver = driver
|
||||
|
||||
def script(self, script: str, args: Tuple[Any, ...] = ()) -> Dict[str, Any]:
|
||||
d = self.driver
|
||||
if script == select_twin.CLOSE_JS:
|
||||
d.popup = "closed"
|
||||
return {"state": "closed"}
|
||||
if script == select_twin.POPUP_STATE_JS:
|
||||
return {"state": d.popup}
|
||||
if script == select_twin.MEASURE_JS:
|
||||
rect = args[0]
|
||||
left, bottom = rect["x"] + 5.0, rect["y"] + rect["h"]
|
||||
return {"state": d.popup, "element": {"left": left, "top": rect["y"], "right": left + rect["w"], "bottom": bottom},
|
||||
"popup": {"left": left + d.shift, "top": bottom, "right": left + 100, "bottom": bottom + 80}, "dpr": SCALE}
|
||||
raise AssertionError("a chrome script the fake does not know: %r" % script[:60])
|
||||
|
||||
|
||||
class FakeDriver:
|
||||
"""A browser that opens the dropdown of the selects named in ``opens`` and answers the reads of the twin with fixed numbers."""
|
||||
|
||||
def __init__(self, kind: str = "ours", opens=("top", "frame"), shift: float = 0.0, frame_fails: bool = False) -> None:
|
||||
self.kind, self.opens, self.shift, self.frame_fails = kind, set(opens), shift, frame_fails
|
||||
self.now = 0.0
|
||||
self.popup = "closed"
|
||||
self.last_click = None
|
||||
self.chrome = FakeChrome(self)
|
||||
|
||||
def goto(self, url: str) -> None:
|
||||
pass
|
||||
|
||||
def scales(self) -> Dict[str, Any]:
|
||||
return {"page": {"devicePixelRatio": SCALE, "inner": [1280, 720], "screen": [1280, 720]}, "chrome_devicePixelRatio": SCALE,
|
||||
"real_screen_contentsScaleFactor": 1.0, "real_screen_defaultCSSScaleFactor": SCALE, "real_displayDPI": 144.0}
|
||||
|
||||
def eval(self, expression: str) -> Any:
|
||||
return {"select": SELECT_BOX, "iframe": IFRAME_BOX, "mozInnerScreen": TOP_INNER, "scroll": [0, 0]}
|
||||
|
||||
def eval_in_frame(self, expression: str) -> Any:
|
||||
if self.frame_fails:
|
||||
raise RuntimeError("the frame is gone")
|
||||
return {"select": FRAME_SELECT_BOX, "mozInnerScreen": FRAME_INNER, "scroll": [0, 0]}
|
||||
|
||||
def click(self, x: float, y: float) -> None:
|
||||
self.last_click = {"point": [x, y], "unit": "CSS pixels of the page, as page.mouse.click sends them", "device": [x * SCALE, y * SCALE]}
|
||||
name = "top" if y < 100 else "frame"
|
||||
if name in self.opens:
|
||||
self.popup = "open"
|
||||
|
||||
def wait_for_timeout(self, ms: int) -> None:
|
||||
self.now += ms / 1000.0
|
||||
|
||||
|
||||
class NoSites:
|
||||
def url(self, site: str, path: str = "") -> str:
|
||||
return "http://%s%s" % (site, path)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def fake_clock(monkeypatch):
|
||||
"""The deadline of the twin runs on the fake driver's own clock: the time it waits is the time the driver was told to pass."""
|
||||
monkeypatch.setattr(select_twin, "wait_for", lambda driver, condition, seconds=select_twin.DEADLINE_S: wait_until(condition, seconds, lambda: driver.wait_for_timeout(100), lambda: driver.now))
|
||||
|
||||
|
||||
def _diagnostics_of(message: str) -> Dict[str, Any]:
|
||||
head, _, line = message.partition("\n diagnostics: ")
|
||||
assert line, "the message has no diagnostics line: %r" % message
|
||||
return json.loads(line.splitlines()[0])
|
||||
|
||||
|
||||
def test_a_dropdown_that_does_not_open_in_the_frame_says_the_click_the_scales_the_boxes_and_the_popup(monkeypatch):
|
||||
monkeypatch.delenv("RUNNER_TEMP", raising=False)
|
||||
driver = FakeDriver(opens=("top",))
|
||||
with pytest.raises(AssertionError) as red:
|
||||
select_twin._steps(NoSites(), driver, CASE)
|
||||
text = str(red.value)
|
||||
assert "the dropdown did not open after a click on the select of the frame document" in text
|
||||
record = _diagnostics_of(text)
|
||||
assert record["element"] == "frame" and record["case"] == CASE and record["browser"] == "ours"
|
||||
click = record["click"]
|
||||
assert click["css"] == [150.0, 154.0], "the click the twin asked, in CSS pixels of the top document: the middle of the frame's select"
|
||||
assert click["sent"] == {"point": [150.0, 154.0], "unit": "CSS pixels of the page, as page.mouse.click sends them", "device": [225.0, 231.0]}
|
||||
assert record["scales"]["page"]["devicePixelRatio"] == SCALE and record["scales"]["chrome_devicePixelRatio"] == SCALE
|
||||
assert record["scales"]["real_screen_contentsScaleFactor"] == 1.0 and record["scales"]["real_displayDPI"] == 144.0
|
||||
assert record["select_rect"] == FRAME_SELECT_BOX, "the select's box in the document of the frame"
|
||||
assert record["iframe_rect"] == IFRAME_BOX, "the frame element's box in the top document"
|
||||
assert record["mozInnerScreen"] == {"top": TOP_INNER, "frame": FRAME_INNER}
|
||||
popup = record["popup"]
|
||||
assert popup["after_click"] == {"state": "closed"} and popup["at_deadline"] == {"state": "closed"}
|
||||
assert popup["second_look"]["state"] == "closed" and popup["second_look"]["reached"] is False and popup["second_look"]["looks"] > 1
|
||||
assert popup["looks"] > 1, "the deadline was waited for, not one look"
|
||||
|
||||
|
||||
def test_a_dropdown_that_does_not_open_in_the_top_document_says_the_same_for_the_top_select(monkeypatch):
|
||||
monkeypatch.delenv("RUNNER_TEMP", raising=False)
|
||||
with pytest.raises(AssertionError) as red:
|
||||
select_twin._steps(NoSites(), FakeDriver(opens=()), CASE)
|
||||
record = _diagnostics_of(str(red.value))
|
||||
assert record["element"] == "top" and record["click"]["css"] == [110.0, 34.0]
|
||||
assert record["select_rect"] == SELECT_BOX and record["iframe_rect"] is None
|
||||
assert record["mozInnerScreen"] == {"top": TOP_INNER}
|
||||
assert record["popup"]["second_look"]["state"] == "closed"
|
||||
|
||||
|
||||
def test_a_popup_that_opens_late_shows_in_the_second_look_and_the_verdict_stays_red(monkeypatch):
|
||||
"""The second look is a diagnosis: a popup that is open by then says it opened after the deadline, and the steps are still red."""
|
||||
monkeypatch.delenv("RUNNER_TEMP", raising=False)
|
||||
driver = FakeDriver(opens=())
|
||||
late = driver.wait_for_timeout
|
||||
driver.wait_for_timeout = lambda ms: (late(ms), setattr(driver, "popup", "open") if driver.now > select_twin.DEADLINE_S + 0.05 else None)[0]
|
||||
with pytest.raises(AssertionError) as red:
|
||||
select_twin._steps(NoSites(), driver, CASE)
|
||||
popup = _diagnostics_of(str(red.value))["popup"]
|
||||
assert popup["at_deadline"] == {"state": "closed"} and popup["second_look"]["state"] == "open" and popup["second_look"]["reached"] is True
|
||||
|
||||
|
||||
def test_a_run_that_passes_writes_the_same_record_to_the_evidence_folder_of_the_jobs(tmp_path, monkeypatch):
|
||||
monkeypatch.setenv("RUNNER_TEMP", str(tmp_path))
|
||||
result = select_twin._steps(NoSites(), FakeDriver(shift=2.0), CASE)
|
||||
path = tmp_path / "invpw-evidence" / "popup-diagnostics" / ("%s-ours.json" % CASE)
|
||||
assert path.is_file(), "the record is written whatever the result: %s" % sorted(str(p) for p in tmp_path.rglob("*"))
|
||||
saved = json.loads(path.read_text(encoding="utf-8"))
|
||||
assert saved["case"] == CASE and saved["browser"] == "ours" and saved["scales"]["page"]["devicePixelRatio"] == SCALE
|
||||
assert sorted(saved["elements"]) == ["frame", "top"]
|
||||
for name in ("top", "frame"):
|
||||
entry = saved["elements"][name]
|
||||
assert {"click", "select_rect", "iframe_rect", "mozInnerScreen", "popup", "relation"} <= set(entry), sorted(entry)
|
||||
assert entry["popup"]["after_click"] == {"state": "open"} and entry["popup"]["closed"] == {"state": "closed"}
|
||||
assert entry["relation"]["dx"] == 3.0, "the number to compare with a red run: 2 CSS pixels of the chrome at scale 1.5"
|
||||
assert saved["elements"]["frame"]["mozInnerScreen"]["frame"] == FRAME_INNER
|
||||
assert result["diagnostics"] == saved["elements"], "the twin's record carries the same entries the file does"
|
||||
|
||||
|
||||
def test_a_failed_run_writes_the_file_too_with_what_was_known_when_it_stopped(tmp_path, monkeypatch):
|
||||
monkeypatch.setenv("RUNNER_TEMP", str(tmp_path))
|
||||
with pytest.raises(AssertionError):
|
||||
select_twin._steps(NoSites(), FakeDriver(opens=("top",)), CASE)
|
||||
saved = json.loads((tmp_path / "invpw-evidence" / "popup-diagnostics" / ("%s-ours.json" % CASE)).read_text(encoding="utf-8"))
|
||||
assert "relation" in saved["elements"]["top"] and "relation" not in saved["elements"]["frame"]
|
||||
assert saved["elements"]["frame"]["popup"]["second_look"]["state"] == "closed"
|
||||
|
||||
|
||||
def test_off_a_runner_nothing_is_written(tmp_path, monkeypatch):
|
||||
monkeypatch.delenv("RUNNER_TEMP", raising=False)
|
||||
diagnostics = _popup_evidence.Diagnostics(CASE, "ours")
|
||||
assert diagnostics.save() is None and diagnostics.save_error is None
|
||||
|
||||
|
||||
def test_a_read_that_fails_is_recorded_and_the_finding_is_still_the_dropdown(monkeypatch):
|
||||
monkeypatch.delenv("RUNNER_TEMP", raising=False)
|
||||
with pytest.raises(AssertionError) as red:
|
||||
select_twin._steps(NoSites(), FakeDriver(opens=("top",), frame_fails=True), CASE)
|
||||
text = str(red.value)
|
||||
assert text.startswith("the dropdown did not open after a click on the select of the frame document")
|
||||
record = _diagnostics_of(text)
|
||||
assert "frame_document" in record["errors"] and "the frame is gone" in record["errors"]["frame_document"]
|
||||
assert record["select_rect"] is None and record["iframe_rect"] == IFRAME_BOX and record["click"]["css"] == [150.0, 154.0]
|
||||
|
||||
|
||||
def test_a_write_that_fails_does_not_replace_the_finding(tmp_path, monkeypatch):
|
||||
blocker = tmp_path / "blocked"
|
||||
blocker.write_text("a file where the folder should be", encoding="utf-8")
|
||||
monkeypatch.setenv("RUNNER_TEMP", str(blocker))
|
||||
with pytest.raises(AssertionError) as red:
|
||||
select_twin._steps(NoSites(), FakeDriver(opens=()), CASE)
|
||||
assert "the dropdown did not open" in str(red.value)
|
||||
|
||||
|
||||
def test_the_verdict_of_a_twin_that_differs_prints_the_click_and_the_geometry_of_both_browsers(monkeypatch):
|
||||
monkeypatch.delenv("RUNNER_TEMP", raising=False)
|
||||
retail = select_twin._steps(NoSites(), FakeDriver(kind="retail", shift=0.0), CASE)
|
||||
ours = select_twin._steps(NoSites(), FakeDriver(kind="ours", shift=10.0), CASE)
|
||||
message = select_twin._verdict(CASE, retail, ours)
|
||||
assert message.startswith(CASE) and "measured.top.dx" in message and "measured.frame.dx" in message
|
||||
for field in ("diagnostics", "click", "sent", "device", "select_rect", "iframe_rect", "mozInnerScreen", "after_click", "at_deadline", "scales", "real_screen_contentsScaleFactor"):
|
||||
assert message.count('"%s"' % field) >= 2, "%s is not in both records of the verdict" % field
|
||||
assert select_twin._verdict(CASE, retail, retail) == ""
|
||||
|
||||
|
||||
# ---- the drivers' own record of a click ----------------------------------------------------------------------------------------------
|
||||
|
||||
class FakePage:
|
||||
def __init__(self) -> None:
|
||||
self.calls = []
|
||||
self.main_frame = "main"
|
||||
self.frames = ["main", _FakeFrame()]
|
||||
self.mouse = self
|
||||
|
||||
def evaluate(self, script: str) -> Any:
|
||||
return SCALE
|
||||
|
||||
def click(self, x: float, y: float) -> None:
|
||||
self.calls.append(("click", x, y))
|
||||
|
||||
|
||||
class _FakeFrame:
|
||||
def evaluate(self, script: str) -> Any:
|
||||
return {"in": "the first frame", "script": script}
|
||||
|
||||
def __eq__(self, other: Any) -> bool:
|
||||
return self is other
|
||||
|
||||
|
||||
def test_our_driver_records_the_point_it_sends_and_the_device_point_it_makes():
|
||||
page = FakePage()
|
||||
driver = _retail_reference.PlaywrightDriver(page, chrome=None)
|
||||
driver.click(110.0, 34.0)
|
||||
assert page.calls == [("click", 110.0, 34.0)]
|
||||
assert driver.last_click == {"point": [110.0, 34.0], "unit": "CSS pixels of the page, as page.mouse.click sends them", "device": [165.0, 51.0]}
|
||||
assert driver.kind == "ours" and driver.eval_in_frame("1")["in"] == "the first frame"
|
||||
|
||||
|
||||
class FakeSession:
|
||||
"""The Marionette session of the retail driver, as a list of the calls it was given."""
|
||||
|
||||
def __init__(self, fail_in_frame: bool = False) -> None:
|
||||
self.calls = []
|
||||
self.fail_in_frame = fail_in_frame
|
||||
self.in_frame = False
|
||||
|
||||
def call(self, context: str, command: str, params: Dict[str, Any]) -> Any:
|
||||
self.calls.append(command)
|
||||
if command == "WebDriver:FindElement":
|
||||
return {"value": {"element-6066-11e4-a52e-4f735466cecf": "abc"}}
|
||||
if command == "WebDriver:SwitchToFrame":
|
||||
self.in_frame = True
|
||||
return {"value": None}
|
||||
if command == "WebDriver:SwitchToParentFrame":
|
||||
self.in_frame = False
|
||||
return {"value": None}
|
||||
if command == "WebDriver:ExecuteScript":
|
||||
if "synthesizeMouseEvent" in params["script"]:
|
||||
return {"value": json.dumps({"ok": True, "at": [110.0, 134.0], "dpr": SCALE})}
|
||||
if self.fail_in_frame:
|
||||
raise RuntimeError("the script failed")
|
||||
return {"value": json.dumps({"frame": self.in_frame})}
|
||||
return {"value": None}
|
||||
|
||||
|
||||
def test_the_retail_driver_records_the_point_it_sent_to_the_widget_and_its_device_point():
|
||||
driver = _retail_reference.RetailDriver(FakeSession())
|
||||
driver.click(110.0, 34.0)
|
||||
assert driver.last_click == {"point": [110.0, 134.0], "unit": "CSS pixels of the chrome window, as Window.synthesizeMouseEvent takes them", "device": [165.0, 201.0]}
|
||||
assert driver.kind == "retail"
|
||||
|
||||
|
||||
def test_the_retail_driver_reads_the_frame_and_is_back_in_the_top_document_even_when_the_read_fails():
|
||||
session = FakeSession()
|
||||
driver = _retail_reference.RetailDriver(session)
|
||||
assert driver.eval_in_frame("1") == {"frame": True}
|
||||
assert session.calls == ["WebDriver:FindElement", "WebDriver:SwitchToFrame", "WebDriver:ExecuteScript", "WebDriver:SwitchToParentFrame"] and not session.in_frame
|
||||
failing = FakeSession(fail_in_frame=True)
|
||||
with pytest.raises(RuntimeError):
|
||||
_retail_reference.RetailDriver(failing).eval_in_frame("1")
|
||||
assert not failing.in_frame, "a failed read left the session inside the frame: the next read of the top document would be the frame's"
|
||||
|
||||
|
||||
def test_the_evidence_folder_is_the_one_every_job_uploads():
|
||||
import _watchdog_log
|
||||
|
||||
assert _popup_evidence.EVIDENCE_FOLDER == _watchdog_log.EVIDENCE_FOLDER
|
||||
diagnostics = _popup_evidence.Diagnostics(CASE, "retail")
|
||||
assert diagnostics.path({"RUNNER_TEMP": "/runner/tmp"}) == Path("/runner/tmp") / "invpw-evidence" / "popup-diagnostics" / ("%s-retail.json" % CASE)
|
||||
Reference in new issue
Block a user