Compare commits

...
Author SHA1 Message Date
feder-cr 829364cf45 tests: the host's fontconfig reaches neither the text pixels nor the screenshot, and no fontconfig file of the host is opened (Linux e2e)
- test_the_host_fontconfig_rules_do_not_reach_the_text_pixels_linux_e2e.py: rules in the user's own fontconfig config (rgba none and bgr, lcdfilter none, embeddedbitmap off, autohint, hintfull without antialias, a strong system-ui prepend) leave the pixel hashes of the opaque and the default canvas, and system-ui's family and widths, as they are with no rule; fc-match proves each rule is in force.
- test_no_fontconfig_file_of_the_host_is_opened_and_the_screenshot_draws_the_bundle_linux_e2e.py: with poisoned caches in HOME and XDG_CACHE_HOME, no browser process opens /etc/fonts, a fonts.conf or a fontconfig cache, and the screenshot of a bundled face equals the content's drawing.
- test_the_parent_reads_the_bundle_from_fontconfig_s_cache_linux_e2e.py keeps its ids and asserts the 72's engine: no fontconfig cache is written or read. It retires after the 72's release.
2026-12-01 11:02:24 +01:00
7 changed files with 1075 additions and 240 deletions

No files matched your search

+4 -4
View File
@@ -16,13 +16,13 @@
{"id": "wrapper.e2e.stock_twin.select", "giro": "G2", "os": ["linux", "windows"], "min_tests": 4, "exact": true, "tests": ["tests/test_a_select_dropdown_opens_at_its_element_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 the select dropdown (4 scales), measured from chrome scope against RETAIL Firefox 159 driven by Marionette alone, headed (the leg sets INVPW_RETAIL_FIREFOX to its firefox.exe), the reference first and ours second; the verdict is 'the same as the reference' (tests/_stock_twin.py, tests/_retail_reference.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.stock_twin.tooltip", "giro": "G2", "os": ["linux", "windows"], "min_tests": 4, "exact": true, "tests": ["tests/test_a_tooltip_opens_at_the_pointer_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 the tooltip (4 scales), measured from chrome scope against RETAIL Firefox 159 driven by Marionette alone, headed (the leg sets INVPW_RETAIL_FIREFOX to its firefox.exe), the reference first and ours second; the verdict is 'the same as the reference' (tests/_stock_twin.py, tests/_retail_reference.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.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.e2e.fontconfig", "giro": "G2", "os": ["linux"], "min_tests": 9, "exact": true, "tests": ["tests/test_no_fontconfig_file_of_the_host_is_opened_and_the_screenshot_draws_the_bundle_linux_e2e.py", "tests/test_the_host_fontconfig_rules_do_not_reach_the_text_pixels_linux_e2e.py", "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 engine runs it on its own empty configuration, and the rules of a user and the files of the host are what these tests try to make reach it. On Windows DirectWrite draws the text from the path of the font, with no rule of a user and no configuration or cache of fonts to read, so these tests have no Windows counterpart.", "note": "7 = (1-3) the fontconfig rules of a user do not reach the pixels of the text a page reads: seven launches of one seed, each with its own user fonts.conf ($XDG_CONFIG_HOME/fontconfig/fonts.conf, as a real user's rules enter; not FONTCONFIG_FILE, which the core strips): nothing; rgba=none with lcdfilter=lcdnone; rgba=bgr; embeddedbitmap=false; autohint=true; hintstyle=hintfull with antialias=false; a strong prepend rule on system-ui. fc-match, in the same environment, must show each rule in force (a launch that measures nothing is red). Three tests: every rule in force and its XDG_CONFIG_HOME in the engine's environment; the hashes of the pixels of getImageData (an opaque canvas and the default one, Arial, SimSun, MS Gothic at 9-16 px) equal to those of the launch with nothing; the computed family and the widths of system-ui equal. (4-7) no fontconfig file of the host is opened and the screenshot draws the bundle: the stand-in that runs the engine under strace stays in the engine's place (a fake engine with a child, no browser); the caches $HOME/.fontconfig and $XDG_CACHE_HOME/fontconfig hold a valid cache of the bundle that lacks msgothic5_32.ttc (fc-list proves it); under strace no process opens a path under /etc/fonts, a fonts.conf or a *.cache-* file; the screenshot of Japanese text in MS PGothic equals the content's own drawing. Needs strace, fc-cache, fc-list and fc-match on the runner: without them the tests are red, not skipped. Evidence in RUNNER_TEMP/invpw-evidence/fontconfig-rules and fontconfig-host-files. Also in the row until the 72 is released: the old file of the warm-cache test (2 tests, same ids), rewritten to assert the 72's behaviour: the stand-in, and two launches with the same XDG_CACHE_HOME and HOME under strace write no fontconfig cache file (*.cache-*, .NEW, .TMP-*) and no process opens one. E1 and E2 replace it; its retirement entry goes to main after the release of the 72."},
{"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": 4461, "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_popup_under_the_declared_viewport_is_not_pinned.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_an_expired_popupshown_wait_fails_the_e2e_test_that_launched_the_browser.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.pLine truncated
{"id": "wrapper.unit.all.windows", "giro": "G1", "os": ["windows"], "min_tests": 4473, "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_popup_under_the_declared_viewport_is_not_pinned.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_an_expired_popupshown_wait_fails_the_e2e_test_that_launched_the_browser.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_eveLine truncated
{"id": "wrapper.unit.all.linux", "giro": "G1", "os": ["linux"], "min_tests": 4486, "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_popup_under_the_declared_viewport_is_not_pinned.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_an_expired_popupshown_wait_fails_the_e2e_test_that_launched_the_browser.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.pLine truncated
{"id": "wrapper.unit.all.windows", "giro": "G1", "os": ["windows"], "min_tests": 4498, "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_popup_under_the_declared_viewport_is_not_pinned.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_an_expired_popupshown_wait_fails_the_e2e_test_that_launched_the_browser.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_eveLine 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": 450, "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_press_on_an_open_select_follows_windows_rollup_e2e.py", "tests/test_a_request_says_what_it_is_e2e.py", "tests/test_a_select_dropdown_stays_open_after_the_release_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_no_popup_is_left_when_a_page_closes_e2e.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 brLine truncated
{"id": "wrapper.e2e.suite.linux.2", "giro": "G2", "os": ["linux"], "min_tests": 457, "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_press_on_an_open_select_follows_windows_rollup_e2e.py", "tests/test_a_request_says_what_it_is_e2e.py", "tests/test_a_select_dropdown_stays_open_after_the_release_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_no_fontconfig_file_of_the_host_is_opened_and_the_screenshot_draws_the_bundle_linux_e2e.py", "tests/test_no_popup_is_left_when_a_page_closes_e2e.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_host_fontconfig_rules_do_not_reach_the_text_pixels_linux_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 filLine truncated
{"id": "wrapper.e2e.suite.linux.3", "giro": "G2", "os": ["linux"], "min_tests": 367, "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_file_chooser_reaches_every_client_e2e.py", "tests/test_a_frame_reads_only_declared_origins_while_it_loads_e2e.py", "tests/test_a_goto_to_a_refused_port_ends_with_its_reason_e2e.py", "tests/test_a_handle_action_walks_like_a_selector_action_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_moves_and_resizes_as_declared_e2e.py", "tests/test_a_popup_of_a_link_reaches_the_client_e2e.py", "tests/test_a_popup_reads_the_retail_sizes_of_a_maximized_main_window_e2e.py", "tests/test_a_regional_indicator_pair_measures_the_same_first_and_after_other_families_e2e.py", "tests/test_an_element_handle_serves_every_method_of_the_client_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_exslt_date_time_through_an_imported_stylesheet_is_in_the_declared_zone_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_input_reaches_the_top_and_a_frame_of_another_site_at_every_scale_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_maximized_window_frames_and_popups_read_retail_e2e.py", "tests/test_the_parent_methods_of_the_window_origin_are_not_exposed_to_a_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).", "run": "suite_run"},
{"id": "wrapper.e2e.suite.windows.1", "giro": "G2", "os": ["windows"], "min_tests": 332, "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_screenshot_honours_its_scale_e2e.py", "tests/test_a_screenshot_refuses_what_would_touch_the_page_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"], "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).", "runner_image": {"windows": "windows-2022"}, "run": "suite_run"},
{"id": "wrapper.e2e.suite.windows.2", "giro": "G2", "os": ["windows"], "min_tests": 321, "exact": true, "tests": ["tests/test_a_file_chooser_reaches_every_client_e2e.py", "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_press_on_an_open_select_follows_windows_rollup_e2e.py", "tests/test_a_regional_indicator_pair_measures_the_same_first_and_after_other_families_e2e.py", "tests/test_a_select_dropdown_stays_open_after_the_release_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_element_handle_serves_every_method_of_the_client_e2e.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_no_popup_is_left_when_a_page_closes_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 teLine truncated
+1 -1
View File
@@ -1,7 +1,7 @@
"""The strace stand-in of the Linux font tests: the engine's directory as links, whose executable runs the real one under ``strace`` in the
engine's place (same pid, same process group), and what reads its log (who is the parent and who a content process) and cleans its group.
Used by tests/test_the_parent_reads_the_bundle_from_fontconfig_s_cache_linux_e2e.py. No test of its own, no browser."""
Used by tests/test_the_parent_reads_the_bundle_from_fontconfig_s_cache_linux_e2e.py and tests/test_no_fontconfig_file_of_the_host_is_opened_and_the_screenshot_draws_the_bundle_linux_e2e.py. No test of its own, no browser."""
from __future__ import annotations
import os
@@ -0,0 +1,406 @@
"""No fontconfig file of the host is opened, and the screenshot draws the bundle even when the host's caches are poisoned (e2e, Linux).
Why Linux only: fontconfig exists only there. On Windows the parent rebuilds a font from the path a text run carries with DirectWrite, which opens the
file by its path and has no configuration and no cache of fonts to read; this test has no Windows form (the row of ``ci/required-suites.json`` says so:
``linux_only``).
It replaces the test of the warm cache (``test_the_parent_reads_the_bundle_from_fontconfig_s_cache_linux_e2e.py``), which asked that a second launch read
fontconfig's cache of the bundle. The engine no longer has that behaviour, on purpose: it runs fontconfig on its own empty configuration. It reads no
``fonts.conf``, no rule, no cache folder and no GTK or Xft font option, it does not show ``<GRE>/fonts`` to fontconfig (the core declares
``gfx.bundled-fonts.activate=0`` on Linux), and the screenshot takes the file and the face of each text run from the bundle's manifest. So the host's
fontconfig can neither decide a face nor be asked.
What the test does, in one launch under strace (the stand-in of ``tests/_strace_stand_in.py``: the engine's folder as links, whose executable runs the real
one under ``strace -f`` in its place):
(a) POISONS the caches first. Fontconfig names the cache of a folder by the md5 of its path and trusts it while the folder's mtime is the one the cache
recorded. The test makes a copy of the engine's fonts folder (links to the files) WITHOUT one ``.ttc`` (``msgothic5_32.ttc``: MS Gothic, MS PGothic,
MS UI Gothic), gives the copy the mtime of the real folder, and has ``fc-cache`` write the cache of the copy AS IF it were the real folder
(``<remap-dir as-path=...>``: the cache is named for the real path and lists the real path), once into ``$HOME/.fontconfig`` and once into
``$XDG_CACHE_HOME/fontconfig`` of the test, the two folders an old engine reads. A cache valid for the real folder that does not list that face. The
test then asks fontconfig itself (``fc-list``, with the real folder and one cache folder) and fails if the face is listed or the real folder is
not what it lists: a poison that is not in force would let every assertion below pass for the wrong reason;
(b) asserts that NO process of the browser (the parent, the content processes, any other) OPENS a path under ``/etc/fonts``, a file called
``fonts.conf``, or a fontconfig cache file (``*.cache-*``, also the ``.NEW`` and ``.TMP-*`` it is written through), whatever the result of the open:
an open that is refused (no such file) is a look at the host's configuration all the same. The other calls that look at a path
(stat, access, readlink) are written to the evidence and not judged;
(c) takes a screenshot of Japanese text in a bundled face (MS PGothic, which is face 2 of the ``.ttc`` the poison lacks) and asserts it equals the content's
own drawing, as ``tests/test_a_screenshot_draws_the_text_of_the_bundled_fonts_as_the_content_does_e2e.py`` does: the same text as HTML (the parent
rebuilds it for the screenshot) and as a canvas the content drew, in the same screenshot, equal byte by byte.
Red on the old engine: it opens ``/etc/fonts/fonts.conf`` (and the caches) at ``FcInit``, and with the poisoned cache the parent asks fontconfig which file is the
face of the text run, which does not list it: it draws another file's outlines (a font of the host), so the two boxes differ. Green on the engine that runs
fontconfig on its own empty configuration.
The environment reaches the browser as it does for a user: the test sets ``HOME`` and ``XDG_CACHE_HOME`` in its own environment (and ``XDG_CONFIG_HOME`` to a
folder with nothing in it), and the core composes the engine's environment from it. ``FONTCONFIG_FILE`` and ``FONTCONFIG_PATH`` of the runner are taken off.
Evidence, whatever the verdict: when ``RUNNER_TEMP`` is set the test writes ``result.json`` (the poison, what fontconfig says of it, every open of a
forbidden path with the role of its process, every other forbidden look, the boxes of the screenshot) and the screenshot under
``$RUNNER_TEMP/invpw-evidence/fontconfig-host-files/``.
Run: pytest tests/test_no_fontconfig_file_of_the_host_is_opened_and_the_screenshot_draws_the_bundle_linux_e2e.py -m e2e -v
"""
from __future__ import annotations
import hashlib
import json
import os
import posixpath
import re
import shutil
import subprocess
import sys
import time
from pathlib import Path
import pytest
import _page_bytes as pb
from _waits import wait_until
from _strace_stand_in import (
_detached, _group_members, _group_of, _kill_group, _LINE, _require_strace_can_trace, _RESUMED, _roles, _stand_in, _SYSCALLS, _wait_for_exit)
from test_a_screenshot_draws_the_text_of_the_bundled_fonts_as_the_content_does_e2e import (
BLOCK_H, BLOCK_W, EVIDENCE_FOLDER, PIN, VIEWPORT, _dark, _integer_box, _page)
pytestmark = [
pytest.mark.e2e,
pytest.mark.skipif(not sys.platform.startswith("linux"), reason="fontconfig is the Linux font system"),
]
SEED = 21
#: The face of the screenshot: MS PGothic is face 2 of msgothic5_32.ttc (face 0 is MS Gothic), the file the poison lacks.
FAMILY = "MS PGothic"
MISSING_FACE_FILE = "msgothic5_32.ttc"
#: What is traced: the opens (what the test judges), the other calls that look at a path (evidence), and the clones and the execve (the role of a process).
TRACE = _SYSCALLS + ",openat2"
OPEN_CALLS = ("open", "openat", "openat2")
_LOOK_CALLS = ("stat", "lstat", "newfstatat", "statx", "access", "faccessat", "faccessat2", "readlink")
#: Calls whose first argument is a directory descriptor (``-y`` prints its path: ``3</etc/fonts/conf.d>``, ``AT_FDCWD</cwd>``).
_AT_CALLS = ("openat", "openat2", "newfstatat", "statx", "faccessat", "faccessat2")
_QUOTED_FIRST = re.compile(r'^"((?:[^"\\]|\\.)*)"')
_AT_ARGS = re.compile(r'^([^,"]*),\s*"((?:[^"\\]|\\.)*)"')
_RETURN = re.compile(r"\)\s+=\s+(-?\d+)")
#: A fontconfig cache file: ``<md5 or uuid>-<arch>.cache-<n>``, and what it is written through (``.NEW``, ``.TMP-xxxxxx``).
_CACHE_FILE = re.compile(r"\.cache-\d+(\.|$)")
#: The folders an old engine reads a cache from, besides ``/var/cache/fontconfig``: the legacy ``~/.fontconfig`` and ``$XDG_CACHE_HOME/fontconfig``.
POISONED_FOLDERS = ("home", "xdg")
# --------------------------------------------------------------------------------------------------------------------------------------
# What the log says (pure: unit-tested without a browser, tests/unit/test_fontconfig_cache_criterion.py)
# --------------------------------------------------------------------------------------------------------------------------------------
def is_a_fontconfig_file_of_the_host(path: str) -> bool:
"""A path the engine must never open: under ``/etc/fonts``, a file called ``fonts.conf`` (anywhere: a user's, the system's, a bundle's), or a
fontconfig cache file (``*.cache-<n>`` and what it is written through)."""
folder = posixpath.normpath(path)
base = posixpath.basename(folder)
return folder == "/etc/fonts" or folder.startswith("/etc/fonts/") or base == "fonts.conf" or _CACHE_FILE.search(base) is not None
def _full_path(dirfd: str, path: str) -> str:
"""The path a call names: absolute as it is; a relative one with the folder ``-y`` printed for its descriptor (``3</etc/fonts/conf.d>``)."""
if path.startswith("/"):
return posixpath.normpath(path)
folder = re.search(r"<(.*)>", dirfd)
return posixpath.normpath(posixpath.join(folder.group(1), path)) if folder else path
def _results_of_unfinished(lines) -> dict:
"""``{index of an unfinished call: its result}``: strace -f writes a call that another thread interrupts as "PID openat(...<unfinished ...>" and gives
the result on the next line of that pid, "PID <... openat resumed>) = -1 ENOENT". An unfinished line with no resumed line has no entry."""
pending, results = {}, {}
for i, line in enumerate(lines):
m = _LINE.match(line)
if m and "<unfinished ...>" in m.group(3):
pending[(int(m.group(1)), m.group(2))] = i
continue
r = _RESUMED.match(line)
if r and (int(r.group(1)), r.group(2)) in pending:
result = _RETURN.search(r.group(3))
if result:
results[pending.pop((int(r.group(1)), r.group(2)))] = int(result.group(1))
return results
def paths_of_calls(lines, calls) -> list:
"""``[{"line", "pid", "call", "path", "result"}]``: every call of ``calls`` on the log, with the path it names, whatever its result (``None`` when the log
has none: an unfinished call with no resumed line). A call that names a path through a descriptor with no printed folder keeps the relative path."""
results = _results_of_unfinished(lines)
found = []
for i, line in enumerate(lines):
m = _LINE.match(line)
if not m or m.group(2) not in calls:
continue
call, rest = m.group(2), m.group(3)
if call in _AT_CALLS:
args = _AT_ARGS.match(rest)
path = _full_path(args.group(1), args.group(2)) if args else None
else:
args = _QUOTED_FIRST.match(rest)
path = posixpath.normpath(args.group(1)) if args else None
if path is None:
continue
result = _RETURN.search(rest)
found.append({"line": i, "pid": int(m.group(1)), "call": call, "path": path,
"result": int(result.group(1)) if result else results.get(i)})
return found
def host_fontconfig_looks(lines, real: str) -> dict:
"""``{"opens": [...], "other": [...]}``: the opens of a fontconfig file of the host by any process of the browser, and (evidence, not judged) the stat,
access and readlink calls on one. Each has the role of its process (``parent``, ``content`` or ``other``)."""
role, _argv = _roles(lines, real)
out = {"opens": [], "other": []}
for key, calls in (("opens", OPEN_CALLS), ("other", _LOOK_CALLS)):
for call in paths_of_calls(lines, calls):
if is_a_fontconfig_file_of_the_host(call["path"]):
out[key].append(dict(call, role=role(call["pid"])))
return out
def poison_config(as_path: str, copy: str, cache_dir: str) -> str:
"""The configuration ``fc-cache`` reads to write the poison: scan ``copy`` AS IF it were ``as_path`` (the cache is named for ``as_path`` and lists
its path), into ``cache_dir`` only, and nothing else (no system folder, no rule)."""
return ('<?xml version="1.0"?>\n<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">\n<fontconfig>\n'
' <remap-dir as-path="%s">%s</remap-dir>\n <cachedir>%s</cachedir>\n</fontconfig>\n' % (as_path, copy, cache_dir))
def reader_config(folder: str, cache_dir: str) -> str:
"""The configuration that asks fontconfig what the cache holds for ``folder``: the folder and one cache folder, nothing else."""
return ('<?xml version="1.0"?>\n<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">\n<fontconfig>\n'
' <dir>%s</dir>\n <cachedir>%s</cachedir>\n</fontconfig>\n' % (folder, cache_dir))
# --------------------------------------------------------------------------------------------------------------------------------------
# The test's own steps
# --------------------------------------------------------------------------------------------------------------------------------------
def _evidence_dir():
base = os.environ.get("RUNNER_TEMP")
return Path(base) / EVIDENCE_FOLDER / "fontconfig-host-files" if base else None
def _tool_env(conf: Path, home: Path) -> dict:
"""The environment of ``fc-cache`` and ``fc-list``: the test's own, with this one configuration and nothing of the variables the core strips."""
env = {k: v for k, v in os.environ.items() if not k.startswith(("FONTCONFIG_", "FC_"))}
env["FONTCONFIG_FILE"] = str(conf)
env["HOME"] = str(home)
return env
def _run(argv, env) -> str:
done = subprocess.run(argv, env=env, capture_output=True, text=True, timeout=300)
assert done.returncode == 0, "%s failed (%d): %s" % (" ".join(argv), done.returncode, (done.stderr or done.stdout)[-800:])
return done.stdout
def _poison(work: Path, gre_fonts: str, home: Path, xdg_cache: Path) -> dict:
"""Write the poisoned cache of the real fonts folder into ``home/.fontconfig`` and ``xdg_cache/fontconfig``; -> what was written and what fontconfig says
of each (the files it lists for the real folder, read back by ``fc-list`` from that cache folder alone)."""
copy = work / "fonts-without-one-ttc"
copy.mkdir()
entries = sorted((e for e in os.scandir(gre_fonts) if e.is_file()), key=lambda e: e.name)
assert any(e.name == MISSING_FACE_FILE for e in entries), "<GRE>/fonts has no %s: the poison has nothing to lack" % MISSING_FACE_FILE
for entry in entries:
if entry.name != MISSING_FACE_FILE:
(copy / entry.name).symlink_to(entry.path)
stat = os.stat(gre_fonts)
# The cache is valid while the folder's mtime is the one it recorded (the package gives the folder 1767225600): the copy gets the real folder's own, in
# nanoseconds, after the links, which moved it.
os.utime(copy, ns=(stat.st_atime_ns, stat.st_mtime_ns))
md5 = hashlib.md5(gre_fonts.rstrip("/").encode()).hexdigest()
caches = {"home": home / ".fontconfig", "xdg": xdg_cache / "fontconfig"}
said = {}
for name, folder in caches.items():
folder.mkdir(parents=True, exist_ok=True)
conf = work / ("poison-%s.conf" % name)
conf.write_text(poison_config(gre_fonts, str(copy), str(folder)), encoding="utf-8")
_run(["fc-cache", "-f", "-v"], _tool_env(conf, home))
reader = work / ("reader-%s.conf" % name)
reader.write_text(reader_config(gre_fonts, str(folder)), encoding="utf-8")
listed = sorted(line for line in _run(["fc-list", "-f", "%{file}\\n"], _tool_env(reader, home)).splitlines() if line.strip())
said[name] = {
"cache_folder": str(folder),
"cache_files": sorted(f.name for f in folder.iterdir() if f.is_file()),
"listed_files": sorted(set(listed)),
}
return {"copy": str(copy), "real_folder": gre_fonts, "md5_of_the_real_folder": md5, "mtime_ns": stat.st_mtime_ns,
"font_files_in_the_real_folder": [e.name for e in entries], "caches": said}
def _poison_problems(poison: dict) -> list:
"""Why the poison is not in force (empty when it is): a cache that fontconfig does not read for the real folder, or that still lists the face, is no poison."""
problems = []
real = poison["real_folder"]
for name, said in poison["caches"].items():
mine = [f for f in said["cache_files"] if f.startswith(poison["md5_of_the_real_folder"]) and _CACHE_FILE.search(f)]
if not mine:
problems.append("%s: no cache named for the real folder (%s-*.cache-*) in %s (it holds %s)"
% (name, poison["md5_of_the_real_folder"], said["cache_folder"], said["cache_files"]))
listed = said["listed_files"]
if not listed:
problems.append("%s: fontconfig lists no font for the real folder %s with this cache" % (name, real))
elif any(posixpath.dirname(f) != real for f in listed):
problems.append("%s: fontconfig lists files outside the real folder: %s" % (name, [f for f in listed if posixpath.dirname(f) != real][:3]))
if any(posixpath.basename(f) == MISSING_FACE_FILE for f in listed):
problems.append("%s: fontconfig lists %s for the real folder: the cache is not the poisoned one (the folder was scanned again)" % (name, MISSING_FACE_FILE))
return problems
@pytest.fixture(scope="module")
def launch(firefox_binary, tmp_path_factory):
"""The one launch under strace, with the caches poisoned: -> {poison, looks, measured, whole, dom, cv, ...}; the record is written before any assertion."""
for tool in ("strace", "fc-cache", "fc-list"):
if shutil.which(tool) is None:
pytest.fail("needs %s (apt install strace fontconfig): without it nothing is measured" % tool, pytrace=False)
work = tmp_path_factory.mktemp("fcfiles")
_require_strace_can_trace(work)
from invisible_playwright import InvisiblePlaywright
real = os.path.realpath(firefox_binary)
gre_fonts = os.path.join(os.path.dirname(real), "fonts")
home, xdg_cache, xdg_config = work / "home", work / "xdg-cache", work / "xdg-config"
for folder in (home, xdg_cache, xdg_config):
folder.mkdir()
out = {"poison": _poison(work, gre_fonts, home, xdg_cache)}
run = work / "run"
run.mkdir()
log, pidfile = run / "strace.log", run / "stand-in.pid"
stand_in = _stand_in(firefox_binary, run / "engine", log, pidfile, syscalls=TRACE, fd_paths=True)
shot, measured = None, None
try:
with pytest.MonkeyPatch.context() as patch:
patch.setenv("HOME", str(home))
patch.setenv("XDG_CACHE_HOME", str(xdg_cache))
patch.setenv("XDG_CONFIG_HOME", str(xdg_config))
for variable in ("FONTCONFIG_FILE", "FONTCONFIG_PATH"):
patch.delenv(variable, raising=False)
with InvisiblePlaywright(seed=SEED, binary_path=stand_in, headless=True, pin=PIN) as browser:
page = browser.new_context(viewport=VIEWPORT).new_page()
page.set_content(_page())
page.evaluate("fam => { window.DONE = false; window.ERR = null;"
" draw(fam).then(r => { window.R = r; window.DONE = true; },"
" e => { window.ERR = String(e); window.DONE = true; }); }", FAMILY)
page.wait_for_function("window.DONE === true", timeout=60_000)
out["page_error"] = page.evaluate("window.ERR")
measured = page.evaluate("window.R")
shot = page.screenshot(type="png")
finally:
_kill_group(pidfile)
lines = log.read_text(encoding="utf-8", errors="replace").splitlines()
out["log_lines"] = len(lines)
out["looks"] = host_fontconfig_looks(lines, real)
out["measured"], out["shot"] = measured, shot
if shot is not None and measured is not None:
whole = pb.unfiltered(shot)
out["whole"] = {"w": whole["w"], "h": whole["h"]}
out["dom"] = _integer_box("DOM", measured["dom"])
out["cv"] = _integer_box("canvas", measured["cv"])
out["dom_img"] = pb.crop(whole, out["dom"]["x"], out["dom"]["y"], out["dom"]["width"], out["dom"]["height"])
out["cv_img"] = pb.crop(whole, out["cv"]["x"], out["cv"]["y"], out["cv"]["width"], out["cv"]["height"])
out["diff"] = pb.pixels_differ(out["dom_img"], out["cv_img"])
where = _evidence_dir()
if where is not None:
try:
where.mkdir(parents=True, exist_ok=True)
record = {k: v for k, v in out.items() if k not in ("shot", "dom_img", "cv_img")}
(where / "result.json").write_text(json.dumps(record, indent=1, sort_keys=True, default=str) + "\n", encoding="utf-8")
if shot is not None:
(where / "page.png").write_bytes(shot)
except Exception as exc: # a record never changes the outcome
print("the record could not be written:", repr(exc))
return out
# --------------------------------------------------------------------------------------------------------------------------------------
# The tests
# --------------------------------------------------------------------------------------------------------------------------------------
@pytest.mark.timeout(120, method="thread")
def test_the_stand_in_stays_in_the_engine_s_place_and_its_group_is_killed_whole(tmp_path):
"""The tool, without a browser. A fake engine (a script that starts a child and waits for it) is launched through the stand-in
as the core launches the engine: the leader of a process group of its own (``_detached``). Once the fake engine says its child
runs (a signal file, no pause), the process the launcher holds must be alive and be the fake engine's parent, strace: with the
stand-in that exec'd ``setsid``, setsid forked (its caller led a group), its parent exited 0 at once, and the core saw the engine
exit during startup (candidate 44161687675, job 134356188701). The group the cleanup kills is the launcher's, it holds strace and
the fake engine's child, and nothing of it is left afterwards."""
if shutil.which("strace") is None:
pytest.fail("needs strace (apt install strace): without it the stand-in cannot be tried", pytrace=False)
_require_strace_can_trace(tmp_path)
real = tmp_path / "real" / "firefox"
real.parent.mkdir()
# The signal, written whole (a rename) once the child runs: the child's pid and the fake engine's parent, the process strace is.
signal_file = tmp_path / "started"
real.write_text('#!/bin/sh\nsleep 300 &\necho "$! $PPID" > %s.tmp && mv %s.tmp %s\nwait\n' % (signal_file, signal_file, signal_file))
real.chmod(0o755)
log, pidfile = tmp_path / "strace.log", tmp_path / "stand-in.pid"
stand_in = _stand_in(str(real), tmp_path / "engine", log, pidfile)
proc = _detached([stand_in], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
try:
started = wait_until(signal_file.exists, 30, lambda: time.sleep(0.05))
child, engine_parent = (int(word) for word in signal_file.read_text().split()) if started else (None, None)
exited_with = proc.poll()
pgid = _group_of(pidfile)
members = _group_members(pgid) if pgid is not None else []
comms = sorted(Path("/proc/%d/comm" % p).read_text().strip() for p in members if Path("/proc/%d/comm" % p).exists())
killed = _kill_group(pidfile)
proc.wait(timeout=30)
left = _wait_for_exit(pgid) if pgid is not None else []
finally:
_kill_group(pidfile)
if proc.poll() is None:
proc.kill()
proc.wait(timeout=30)
assert started, "the fake engine did not start its child under the stand-in"
assert exited_with is None and engine_parent == proc.pid, (
"the process the launcher holds (pid %d, exited with %s) is not the one that runs the engine (its parent is %s): the launcher would "
"see the engine gone" % (proc.pid, exited_with, engine_parent))
assert pgid == proc.pid and pgid != os.getpgrp(), "the group is not the one the launcher gave (group %s, pid %d)" % (pgid, proc.pid)
assert "strace" in comms and child in members, "the group holds %s (%s), not strace and the child %s" % (members, comms, child)
assert killed == pgid and not left, "after the kill of group %s: killed %s, left %s" % (pgid, killed, left)
@pytest.mark.timeout(900, method="thread")
def test_the_caches_of_the_host_hold_a_valid_cache_of_the_bundle_that_lacks_a_face(launch):
"""The precondition of the two below, in fontconfig's own words: without it a clean log and an equal screenshot would prove nothing."""
problems = _poison_problems(launch["poison"])
assert not problems, "the poison is not in force, so the test measures nothing: %s" % "; ".join(problems)
@pytest.mark.timeout(900, method="thread")
def test_no_process_of_the_browser_opens_a_fontconfig_file_of_the_host(launch):
problems = _poison_problems(launch["poison"])
assert not problems, "the poison is not in force, so the test measures nothing: %s" % "; ".join(problems)
assert launch["log_lines"] > 0, "strace wrote nothing: the browser was not traced"
opens = launch["looks"]["opens"]
assert not opens, (
"%d open(s) of a fontconfig file of the host by the browser (under /etc/fonts, a fonts.conf, or a *.cache-* cache), by role: %s. The first ones: %s. "
"Looks that are not opens (stat, access, readlink), not judged: %d"
% (len(opens), sorted({o["role"] for o in opens}),
[(o["role"], o["call"], o["path"], o["result"]) for o in opens[:8]], len(launch["looks"]["other"])))
@pytest.mark.timeout(900, method="thread")
def test_the_screenshot_of_japanese_text_in_a_bundled_face_is_the_content_s_drawing_with_the_caches_poisoned(launch):
problems = _poison_problems(launch["poison"])
assert not problems, "the poison is not in force, so the test measures nothing: %s" % "; ".join(problems)
assert launch["page_error"] is None, "the page could not draw the two blocks: %s" % launch["page_error"]
measured, whole, dom, cv = launch["measured"], launch["whole"], launch["dom"], launch["cv"]
assert measured["dpr"] == 1, "the device pixel ratio is %r, not 1: the boxes would be resampled" % measured["dpr"]
assert (dom["width"], dom["height"]) == (cv["width"], cv["height"]) == (BLOCK_W, BLOCK_H), (dom, cv)
assert measured["lines"] == 6, "the block has %r lines, not 6" % measured["lines"]
assert (whole["w"], whole["h"]) == (VIEWPORT["width"], VIEWPORT["height"]), (
"the screenshot is %dx%d for a viewport of %dx%d: the boxes are not where the page measured them"
% (whole["w"], whole["h"], VIEWPORT["width"], VIEWPORT["height"]))
dom_img, cv_img, diff = launch["dom_img"], launch["cv_img"], launch["diff"]
# a box with no text in it would be equal to another box with no text in it
assert _dark(dom_img) > 0, "the DOM box of %s is blank: the screenshot has no text there" % FAMILY
assert _dark(cv_img) > 0, "the canvas box of %s is blank: the SVG image drew no text" % FAMILY
assert dom_img["data"] == cv_img["data"], (
"%s: the text the screenshot rebuilt in the parent (the DOM box) is not the text the content drew (the canvas box): %d of %d pixels differ, the first at %r, "
"inside the box %r. With the caches of the host poisoned (a valid cache of the bundle without %s), the parent drew the face from another file."
% (FAMILY, diff["pixels"], BLOCK_W * BLOCK_H, diff["first"], diff["box"], MISSING_FACE_FILE))
+5 -1
View File
@@ -87,6 +87,10 @@ EXCLUDED = {
(("windows",), "the GLX probe (gfxtest glx) is a child process of Firefox on GTK; Windows reads the adapter in the parent and has no such process"),
"tests/test_the_parent_reads_the_bundle_from_fontconfig_s_cache_linux_e2e.py":
(("windows",), "wrapper.e2e.fontconfig is linux_only: fontconfig exists only on Linux (DirectWrite opens a font from its path)"),
"tests/test_no_fontconfig_file_of_the_host_is_opened_and_the_screenshot_draws_the_bundle_linux_e2e.py":
(("windows",), "wrapper.e2e.fontconfig is linux_only: fontconfig exists only on Linux (DirectWrite opens a font from its path)"),
"tests/test_the_host_fontconfig_rules_do_not_reach_the_text_pixels_linux_e2e.py":
(("windows",), "wrapper.e2e.fontconfig is linux_only: fontconfig exists only on Linux (DirectWrite draws the text with no rule of a user)"),
"tests/test_webgl_draws_on_the_engine_s_own_gl_e2e.py::test_webgl_draws_on_the_engine_s_own_gl":
(("windows",), "skips on Windows: the engine's own GL is Linux's"),
"tests/test_webgl_draws_on_the_engine_s_own_gl_e2e.py::test_every_declared_extension_answers_as_on_windows":
@@ -99,7 +103,7 @@ EXCLUDED = {
(("windows",), "skips on Windows: the Linux text path"),
}
#: Changed by hand, together with the list above: an exclusion is a test the candidate does not run, and it may not be added in silence.
EXCLUDED_COUNT = 25
EXCLUDED_COUNT = 27
@functools.lru_cache(maxsize=None)
@@ -0,0 +1,447 @@
"""The fontconfig rules of the user do not change a pixel of the text a page reads (e2e, Linux, a gate test that asserts the principle: same seed, same bytes).
Why Linux only: fontconfig exists only there. On Windows DirectWrite draws the text, with no rule of a user in between, so this test has no
Windows form (the row of ``ci/required-suites.json`` says so: ``linux_only``).
The question. The engine draws a face with the parameters of its fontconfig pattern: ``rgba``, ``lcdfilter``, ``autohint``, ``embeddedbitmap``,
``hintstyle`` and ``antialias``. On a machine, those are rules of a user (``~/.config/fontconfig``) or of the system (``/etc/fonts``), and the page
reads their effect (``getImageData`` of a canvas with text). A value a page reads must not depend on the machine. The engine runs fontconfig on its
own empty configuration: it reads no ``fonts.conf``, no rule, no cache folder and no GTK or Xft option, so every rule below must change nothing.
How a rule enters. As a real user's does: through the user's own configuration, ``$XDG_CONFIG_HOME/fontconfig/fonts.conf`` (the system
``fonts.conf`` includes it through ``conf.d/50-user.conf``), set in the environment of the test. Not through ``FONTCONFIG_FILE``: the core removes
``FONTCONFIG_*`` and ``FC_*`` from the environment of the engine, so a rule given that way would never arrive, and a test built on it would be green
for the wrong reason. ``XDG_CONFIG_HOME`` is not removed, and the test reads ``/proc/<pid>/environ`` of the engine's processes to show it did arrive.
What is drawn. One local page (http://127.0.0.1, a secure context, so ``crypto.subtle`` answers) draws ``fillText`` with the same seed in every launch:
* on two canvases per row: (a) OPAQUE, ``getContext('2d', {alpha: false})``, white fill first (Skia turns subpixel anti-aliasing on only for an
opaque canvas: ``SetPermitSubpixelAA(IsOpaque)``, which is where ``rgba`` and ``lcdfilter`` show); (b) the DEFAULT one, white fill first too,
so that the only difference between the two is the opacity of the canvas;
* with fonts of the engine's bundle (the manifest of the core: ``tests/_font_names.py``): Arial (Latin), SimSun and MS Gothic (CJK). The two CJK
faces are the ones of the bundle that ship embedded bitmaps on a retail Windows (SimSun at 12 to 16 px, MS Gothic at its small sizes), so they
are where ``embeddedbitmap`` can show; Arial and its outlines are the control that has none;
* at 9, 11, 12, 13 and 16 px, one row per (font, size) and canvas.
Each row returns the sha256 of the ``getImageData`` bytes, the number of pixels with R != G or G != B (subpixel anti-aliasing: grayscale text has
none), the number of pixels that are not white (the text is there) and the width ``measureText`` gives.
Seven launches, one engine, one seed, each with its own user ``fonts.conf``:
1. nothing: a ``fonts.conf`` with no rule (the rules of the machine, whatever they are);
2. ``rgba=none`` and ``lcdfilter=lcdnone`` (the runner's own rules say rgba=rgb: this is the other side of it);
3. ``rgba=bgr``;
4. ``embeddedbitmap=false``;
5. ``autohint=true``;
6. ``hintstyle=hintfull`` and ``antialias=false`` (the two the engine declares: a rule of a user must not move them either);
7. a rule that really moves ``system-ui`` inside fontconfig: ``<match target="pattern">`` on the family ``system-ui``, ``<edit name="family"
mode="prepend_first" binding="strong">`` of a face every runner has (the engine builds exactly such a pattern for a generic family:
FC_FAMILY = "system-ui", FC_SCALABLE, FC_LANG, then ``FcConfigSubstitute`` and ``FcFontSort``).
Each is a separate configuration. Before each engine starts, ``fc-match`` runs in the same environment (the same ``XDG_CONFIG_HOME``) and says whether
the rule is in force; a launch whose rule is not in force measures nothing and the test says so, and fails: a launch that measures nothing is not a pass
(the raw lines are in ``result.json``). Why the system-ui rule did not take in the measurement of the old engine (run 45078210028): ``fc-match
system-ui`` PARSES its argument as a fontconfig name, in which ``-`` starts the size (``family-size``), so fontconfig matched the family ``system``
and the rule on ``system-ui`` never fired. The test asks ``fc-match`` for ``system\\-ui`` (the hyphen escaped), which is the family the engine builds.
The assertions:
* every launch has its rule in force in fontconfig itself and its ``XDG_CONFIG_HOME`` in the environment of an engine process, and every
row drew text (a blank canvas would equal any other);
* every launch gives the same pixel hashes as launch 1, row by row, for the opaque canvas and for the default one;
* with the rule on ``system-ui``, a page reads the same computed ``font-family`` and the same widths (canvas and layout, Latin and CJK) as in launch 1.
Red on the old engine (run 45078210028: ``rgba=none`` with ``lcdfilter=none`` changed 11 of 15 opaque rows, and ``embeddedbitmap=false`` changed 8 of 15
rows on both canvases): the rules reach the face through the host's configuration. Green on the engine that runs fontconfig on its own empty one.
Evidence, whatever the verdict: when ``RUNNER_TEMP`` is set the test writes ``result.json`` under ``$RUNNER_TEMP/invpw-evidence/fontconfig-rules/``: per
launch, the configuration, the hashes and subpixel counts by row, the reads of ``system-ui``, what ``fc-match`` says and the environment seen in the engine's
processes. A table is printed (launch by canvas: same or different from launch 1, subpixel pixels in total). A failure to write it never changes the outcome.
Run: pytest tests/test_the_host_fontconfig_rules_do_not_reach_the_text_pixels_linux_e2e.py -m e2e -v -s
"""
from __future__ import annotations
import http.server
import json
import os
import shutil
import socketserver
import subprocess
import sys
import threading
from pathlib import Path
import pytest
from test_a_screenshot_draws_the_text_of_the_bundled_fonts_as_the_content_does_e2e import EVIDENCE_FOLDER
pytestmark = [
pytest.mark.e2e,
pytest.mark.skipif(not sys.platform.startswith("linux"), reason="fontconfig is the Linux font system"),
]
SEED = 21
#: (font, text, why). The text of each is in the writing the face draws.
FONTS = [
("Arial", "Hamburgefonstiv 0123456789 éèàü", "Latin outlines: the control, no embedded bitmaps"),
("SimSun", "中文汉字测试 ABC abc 0123", "CJK, embedded bitmaps at 12-16 px on a retail Windows"),
("MS Gothic", "日本語のテキスト ABC abc アイウエオ", "CJK, embedded bitmaps at its small sizes"),
]
SIZES = [9, 11, 12, 13, 16]
CANVASES = ["opaque", "default"]
#: A face a runner has, whose family differs from the one fontconfig answers to ``system-ui`` by default (a sans): the rule of the last launch
#: puts it first.
HOST_FACE_CANDIDATES = [
("/usr/share/fonts/truetype/dejavu/DejaVuSerif.ttf", "DejaVu Serif"),
("/usr/share/fonts/truetype/liberation/LiberationSerif-Regular.ttf", "Liberation Serif"),
]
#: name of the launch -> the rules, ``(property, kind, value)``. The user's ``fonts.conf`` of a launch holds them and nothing else.
LAUNCHES = [
("1_nothing", []),
("2_rgba_none_lcdnone", [("rgba", "const", "none"), ("lcdfilter", "const", "lcdnone")]),
("3_rgba_bgr", [("rgba", "const", "bgr")]),
("4_embeddedbitmap_off", [("embeddedbitmap", "bool", "false")]),
("5_autohint", [("autohint", "bool", "true")]),
("6_hintfull_antialias_off", [("hintstyle", "const", "hintfull"), ("antialias", "bool", "false")]),
("7_system_ui_prepend", []),
]
SYSTEM_UI_LAUNCH = "7_system_ui_prepend"
BASE_LAUNCH = "1_nothing"
#: The pattern the engine builds for a generic family (``gfxFcPlatformFontList::FindGenericFamilies``: FC_FAMILY = the generic name, FC_SCALABLE true,
#: FC_LANG = the sample language), written as ``fc-match`` reads a name: the hyphen of ``system-ui`` is escaped, or it starts the size.
ENGINE_PATTERN = "system\\-ui:scalable=true:lang=en"
PROPERTIES = ("rgba", "lcdfilter", "autohint", "embeddedbitmap", "hintstyle", "antialias")
#: What ``fc-match -f '%{property}'`` prints for the configuration of each launch: the integers are fontconfig's own constants (FC_RGBA_BGR 2,
#: FC_RGBA_NONE 5, FC_LCD_NONE 0, FC_HINT_FULL 3), a boolean prints True or False. The raw ``fc-match -v`` lines of every launch are in result.json
#: beside them. A value that is not the one written here still counts as the rule in force when it is DIFFERENT from what launch 1 prints for the
#: same property (the form is uncertain, the move is not); both are recorded.
EXPECTED_FC = {
"2_rgba_none_lcdnone": {"rgba": "5", "lcdfilter": "0"},
"3_rgba_bgr": {"rgba": "2"},
"4_embeddedbitmap_off": {"embeddedbitmap": "False"},
"5_autohint": {"autohint": "True"},
"6_hintfull_antialias_off": {"hintstyle": "3", "antialias": "False"},
}
#: Draws every row. ``args`` = [fonts, sizes]. Returns [{canvas, font, size, sha256, subpixel, ink, width, fallback_width}].
ROWS_JS = """async (args) => {
const [fonts, sizes] = args;
const hex = (buf) => Array.from(new Uint8Array(buf)).map(b => b.toString(16).padStart(2, '0')).join('');
const fnv = (bytes) => { let h = 0x811c9dc5; for (let i = 0; i < bytes.length; i++) { h ^= bytes[i]; h = Math.imul(h, 0x01000193) >>> 0; } return 'fnv:' + h.toString(16); };
const out = [];
for (const kind of ['opaque', 'default']) {
for (const [family, text] of fonts) {
for (const size of sizes) {
const c = document.createElement('canvas'); c.width = 400; c.height = size * 2 + 12;
const x = kind === 'opaque' ? c.getContext('2d', {alpha: false}) : c.getContext('2d');
x.fillStyle = '#fff'; x.fillRect(0, 0, c.width, c.height);
x.fillStyle = '#000'; x.textBaseline = 'alphabetic';
x.font = size + 'px "' + family + '"';
x.fillText(text, 4, size + 4);
const width = x.measureText(text).width;
x.font = size + 'px "NoSuchFamilyForTheFallback"';
const fallback_width = x.measureText(text).width;
const data = x.getImageData(0, 0, c.width, c.height).data;
let subpixel = 0, ink = 0;
for (let i = 0; i < data.length; i += 4) {
if (data[i] !== data[i + 1] || data[i + 1] !== data[i + 2]) subpixel++;
if (data[i] !== 255 || data[i + 1] !== 255 || data[i + 2] !== 255) ink++;
}
const sha256 = (window.crypto && crypto.subtle) ? hex(await crypto.subtle.digest('SHA-256', data)) : fnv(data);
out.push({canvas: kind, font: family, size, sha256, subpixel, ink, width, fallback_width});
}
}
}
return out;
}"""
#: What a page reads of ``system-ui``.
SYSTEM_UI_JS = """() => {
const latin = 'Hamburgefonstiv 0123456789', cjk = '\\u4e2d';
const span = (text) => { const s = document.createElement('span'); s.style.cssText = 'position:absolute;left:-9999px;white-space:pre;font:16px system-ui'; s.textContent = text; document.body.appendChild(s); return s; };
const a = span(latin), b = span(cjk);
const x = document.createElement('canvas').getContext('2d');
x.font = '16px system-ui';
const out = {
computed_font_family: getComputedStyle(a).fontFamily,
canvas_font: x.font,
canvas_width_latin: x.measureText(latin).width,
canvas_width_cjk: x.measureText(cjk).width,
dom_width_latin: a.getBoundingClientRect().width,
dom_width_cjk: b.getBoundingClientRect().width,
};
a.remove(); b.remove();
return out;
}"""
_PAGE = b"<!doctype html><meta charset=utf-8><title>fcrules</title><body style='margin:0;background:#fff'>"
class _Handler(http.server.BaseHTTPRequestHandler):
def do_GET(self): # noqa: N802
self.send_response(200)
self.send_header("Content-Type", "text/html; charset=utf-8")
self.send_header("Content-Length", str(len(_PAGE)))
self.end_headers()
self.wfile.write(_PAGE)
def log_message(self, *args, **kwargs):
pass
class _Server(socketserver.ThreadingTCPServer):
allow_reuse_address = True
daemon_threads = True
def _evidence_dir():
base = os.environ.get("RUNNER_TEMP")
return Path(base) / EVIDENCE_FOLDER / "fontconfig-rules" if base else None
def _config_text(name: str, rules, host_family: str) -> str:
"""The user's ``fonts.conf`` of a launch: its rules and nothing else (the system ``fonts.conf`` includes it)."""
parts = ['<?xml version="1.0"?>', '<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">', "<fontconfig>"]
if name == SYSTEM_UI_LAUNCH:
# STRONG, and first: the face comes before ``system-ui`` and before every family the rules of the system add behind it.
parts.append(' <match target="pattern">')
parts.append(' <test qual="any" name="family"><string>system-ui</string></test>')
parts.append(' <edit name="family" mode="prepend_first" binding="strong"><string>%s</string></edit>' % host_family)
parts.append(" </match>")
for target in ("pattern", "font"):
if rules:
parts.append(' <match target="%s">' % target)
for prop, kind, value in rules:
parts.append(' <edit name="%s" mode="assign"><%s>%s</%s></edit>' % (prop, kind, value, kind))
parts.append(" </match>")
parts.append("</fontconfig>")
return "\n".join(parts) + "\n"
def _fc_env(xdg_config_home: Path) -> dict:
"""The environment ``fc-match`` runs in: the test's own, with the user's configuration folder of THIS launch, and without the variables the core strips."""
env = {k: v for k, v in os.environ.items() if not k.startswith(("FONTCONFIG_", "FC_"))}
env["XDG_CONFIG_HOME"] = str(xdg_config_home)
return env
def _fc_match(env: dict, pattern: str, fmt: str) -> str:
done = subprocess.run(["fc-match", "-f", fmt, pattern], env=env, capture_output=True, text=True, timeout=60)
return done.stdout.strip()
def _what_fontconfig_says(xdg_config_home: Path) -> dict:
"""What fontconfig itself says in the environment of this launch (the host tool, not the browser): the value of each property, the raw ``fc-match -v``
lines of them, and the family it answers to ``system-ui`` (the pattern the engine builds)."""
out = {}
env = _fc_env(xdg_config_home)
try:
for key in PROPERTIES:
out[key] = _fc_match(env, "sans", "%%{%s}" % key)
verbose = subprocess.run(["fc-match", "-v", "sans"], env=env, capture_output=True, text=True, timeout=60).stdout
out["raw"] = [line.strip() for line in verbose.splitlines() if line.strip().split(":", 1)[0] in PROPERTIES + ("hinting",)]
out["system-ui_engine_pattern_family"] = _fc_match(env, ENGINE_PATTERN, "%{family}")
out["system-ui_engine_pattern_asked"] = _fc_match(env, ENGINE_PATTERN, "%{pattern}")[:300]
out["sans_family"] = _fc_match(env, "sans", "%{family}")
except Exception as exc: # recorded; the precondition below then names it
out["error"] = repr(exc)
return out
def _rule_in_force(name: str, said: dict, base_said: dict, host_family: str) -> dict:
"""The precondition of a launch, decided BEFORE its engine starts: does fontconfig, in the environment of this launch, apply the rule? A launch whose
rule is not in force measures nothing (it would equal launch 1 whatever the engine does)."""
problems, notes = [], []
if "error" in said:
problems.append("fc-match could not be run: %s" % said["error"])
for prop, want in EXPECTED_FC.get(name, {}).items():
got = said.get(prop)
if got == want:
continue
if got and got != base_said.get(prop):
notes.append("%s prints %r, not %r, and it is not what launch 1 prints (%r): the form is uncertain, the move is not"
% (prop, got, want, base_said.get(prop)))
else:
problems.append("%s: fc-match prints %r (launch 1 prints %r), the rule wants %r" % (prop, got, base_said.get(prop), want))
if name == SYSTEM_UI_LAUNCH:
got = said.get("system-ui_engine_pattern_family", "")
if not got.startswith(host_family):
problems.append("fc-match %s answers %r (launch 1: %r), the rule wants %r"
% (ENGINE_PATTERN, got, base_said.get("system-ui_engine_pattern_family"), host_family))
if got and got == base_said.get("system-ui_engine_pattern_family"):
problems.append("fc-match %s answers %r, the same as with no rule: the rule moved nothing" % (ENGINE_PATTERN, got))
return {"ok": not problems, "problems": problems, "notes": notes}
def _engine_environ(binary: str, xdg_config_home: Path) -> dict:
"""``XDG_CONFIG_HOME`` and any ``FONTCONFIG_*`` in the environment of every process of the engine (``/proc/<pid>/environ``): the rule reaches the
engine only if the first is there with this launch's folder, and the core removes the second."""
seen = {"processes": 0, "with_the_config_home": 0, "fontconfig_variables": []}
try:
real = os.path.realpath(binary)
for entry in os.scandir("/proc"):
if not entry.name.isdigit():
continue
try:
argv0 = Path(entry.path, "cmdline").read_bytes().split(b"\0")[0].decode("utf-8", "replace")
if os.path.realpath(argv0) != real:
continue
env = dict(item.partition(b"=")[::2] for item in Path(entry.path, "environ").read_bytes().split(b"\0") if item)
except OSError:
continue
seen["processes"] += 1
if env.get(b"XDG_CONFIG_HOME", b"").decode("utf-8", "replace") == str(xdg_config_home):
seen["with_the_config_home"] += 1
seen["fontconfig_variables"] += sorted(k.decode("utf-8", "replace") for k in env if k.startswith((b"FONTCONFIG_", b"FC_")))
except Exception as exc:
seen["error"] = repr(exc)
return seen
def _launch(binary: str, xdg_config_home: Path, url: str) -> dict:
from invisible_playwright import InvisiblePlaywright
result = {"xdg_config_home": str(xdg_config_home)}
# The variable of THIS launch, in the environment of the process: the wrapper composes the engine's environment from it. A FONTCONFIG_FILE or
# FONTCONFIG_PATH of the runner is taken off: with one of them, the system ``fonts.conf`` would not be read and the user's file would not either.
with pytest.MonkeyPatch.context() as patch:
patch.setenv("XDG_CONFIG_HOME", str(xdg_config_home))
for variable in ("FONTCONFIG_FILE", "FONTCONFIG_PATH"):
patch.delenv(variable, raising=False)
with InvisiblePlaywright(seed=SEED, binary_path=binary, headless=True) as browser:
page = browser.new_context().new_page()
page.goto(url, timeout=30_000)
result["rows"] = page.evaluate(ROWS_JS, [[[f, t] for f, t, _w in FONTS], SIZES])
result["system_ui"] = page.evaluate(SYSTEM_UI_JS)
result["engine_environ"] = _engine_environ(binary, xdg_config_home)
return result
def _by_row(rows) -> dict:
return {(r["canvas"], r["font"], r["size"]): r for r in rows}
def _compare(results: dict, base: str) -> dict:
"""{launch: {canvas: [rows that differ from the base launch]}}."""
ref = _by_row(results[base]["rows"])
out = {}
for name, res in results.items():
mine = _by_row(res["rows"])
out[name] = {canvas: sorted("%s %dpx" % (k[1], k[2]) for k, row in mine.items()
if k[0] == canvas and row["sha256"] != ref[k]["sha256"]) for canvas in CANVASES}
return out
def _table(results: dict, base: str) -> str:
diff = _compare(results, base)
lines = ["", "launch x canvas -> vs %s (rows that differ / rows), subpixel pixels in total" % base]
for name, res in results.items():
cells = []
for canvas in CANVASES:
total = sum(r["subpixel"] for r in res["rows"] if r["canvas"] == canvas)
rows = sum(1 for r in res["rows"] if r["canvas"] == canvas)
d = diff[name][canvas]
cells.append("%s: %s (%d/%d), subpixel %d" % (canvas, "same" if not d else "DIFFERENT", len(d), rows, total))
lines.append(" %-26s %s" % (name, " | ".join(cells)))
for name in results:
for canvas in CANVASES:
if diff[name][canvas]:
lines.append(" %s %s differs in: %s" % (name, canvas, ", ".join(diff[name][canvas])))
lines.append("system-ui reads:")
for name in (base, SYSTEM_UI_LAUNCH):
if name in results:
lines.append(" %-26s %s" % (name, json.dumps(results[name]["system_ui"], sort_keys=True)))
return "\n".join(lines)
@pytest.fixture(scope="module")
def launches(firefox_binary, tmp_path_factory):
"""Every launch, once per module. -> {name: result}; the record is written before the assertions run."""
for tool in ("fc-match",):
if shutil.which(tool) is None:
pytest.fail("needs %s (apt install fontconfig): without it no rule can be shown to be in force" % tool, pytrace=False)
work = tmp_path_factory.mktemp("fcrules")
face, host_family = next(((p, f) for p, f in HOST_FACE_CANDIDATES if os.path.exists(p)), (None, None))
assert face, "no host face to put first for the system-ui launch: none of %r exists on this runner" % [p for p, _f in HOST_FACE_CANDIDATES]
server = _Server(("127.0.0.1", 0), _Handler)
threading.Thread(target=server.serve_forever, daemon=True).start()
url = "http://127.0.0.1:%d/" % server.server_address[1]
results, fc = {}, {}
try:
for name, rules in LAUNCHES:
xdg = work / name / "xdg-config"
(xdg / "fontconfig").mkdir(parents=True)
conf = xdg / "fontconfig" / "fonts.conf"
conf.write_text(_config_text(name, rules, host_family), encoding="utf-8")
# Before the engine starts: fontconfig in THIS environment. Its answer says whether the launch measures anything.
fc[name] = _what_fontconfig_says(xdg)
precondition = _rule_in_force(name, fc[name], fc.get(BASE_LAUNCH, fc[name]), host_family)
results[name] = _launch(firefox_binary, xdg, url)
results[name]["config"] = conf.read_text(encoding="utf-8")
results[name]["fc_match"] = fc[name]
results[name]["precondition"] = precondition
finally:
server.shutdown()
server.server_close()
try:
record = {
"seed": SEED, "host_face": face, "host_family": host_family, "fonts": [f for f, _t, _w in FONTS], "sizes": SIZES,
"launches": results, "differences_vs_1": _compare(results, BASE_LAUNCH) if BASE_LAUNCH in results else None,
}
where = _evidence_dir()
if where is not None:
where.mkdir(parents=True, exist_ok=True)
(where / "result.json").write_text(json.dumps(record, indent=1, sort_keys=True), encoding="utf-8")
if BASE_LAUNCH in results:
print(_table(results, BASE_LAUNCH))
print("XDG_CONFIG_HOME seen in the engine's processes:",
{n: (r.get("engine_environ") or {}).get("with_the_config_home") for n, r in results.items()})
except Exception as exc: # a record never changes the outcome
print("the record could not be written:", repr(exc))
return results
def _every_launch_measures_something(launches):
"""The first assertion of every test: a launch whose rule fontconfig does not apply, or whose rule did not reach the engine, measures nothing,
and the comparison would say "equal"."""
assert set(launches) == {n for n, _r in LAUNCHES}, "not every launch ran: %s" % sorted(launches)
for name, _rules in LAUNCHES:
pre = launches[name]["precondition"]
assert pre["ok"], "launch %s measures nothing: fontconfig does not apply its rule: %s (it said: %r)" % (
name, "; ".join(pre["problems"]), launches[name]["fc_match"])
seen = launches[name]["engine_environ"]
assert seen.get("processes"), "launch %s: no process of the engine was seen in /proc (%r): the environment it ran in is not known" % (name, seen)
assert seen["with_the_config_home"] > 0, (
"launch %s measures nothing: XDG_CONFIG_HOME of the launch did not reach the engine (%r), so its rule could not be read" % (name, seen))
@pytest.mark.timeout(900, method="thread")
def test_every_launch_has_its_rule_in_force_in_fontconfig_itself_and_in_the_engine_s_environment(launches):
"""Without this the equalities below would say nothing: a configuration fontconfig ignores is equal to any other."""
_every_launch_measures_something(launches)
@pytest.mark.timeout(900, method="thread")
def test_the_fontconfig_rules_of_the_user_do_not_move_a_pixel_of_the_text_a_page_reads(launches):
_every_launch_measures_something(launches)
# The comparison is not empty: every row drew text.
blank = [(n, k) for n, res in launches.items() for k, r in _by_row(res["rows"]).items() if r["ink"] == 0]
assert not blank, "rows with no text drawn (a blank canvas equals any other): %r" % blank[:6]
diff = _compare(launches, BASE_LAUNCH)
moved = {n: d for n, d in diff.items() if n != BASE_LAUNCH and any(d.values())}
assert not moved, (
"the fontconfig rules of the user change the pixels of the text a page reads (rows that differ from launch 1, by launch and canvas): %s"
% json.dumps(moved, sort_keys=True))
@pytest.mark.timeout(900, method="thread")
def test_a_rule_of_the_user_on_system_ui_does_not_choose_the_face_a_page_reads(launches):
_every_launch_measures_something(launches)
first, other = launches[BASE_LAUNCH]["system_ui"], launches[SYSTEM_UI_LAUNCH]["system_ui"]
assert first == other, (
"a fontconfig rule on system-ui reaches what a page reads of it: launch 1 read %s, launch %s read %s"
% (json.dumps(first, sort_keys=True), SYSTEM_UI_LAUNCH, json.dumps(other, sort_keys=True)))
@@ -1,68 +1,33 @@
"""The parent reads the bundle of fonts from fontconfig's cache and does not scan it again (e2e, Linux, from firefox-66).
"""The engine writes and reads no fontconfig cache (e2e, Linux, from firefox-72; the file keeps the name and the test ids of the warm-cache test it was).
Why Linux only: fontconfig exists only there. On Windows the parent rebuilds a font from the path a text run carries with DirectWrite,
which opens the file by its path and keeps no index of a folder; there is nothing to scan and nothing to cache, and this test has no
Windows form (the row of ``ci/required-suites.json`` says so: ``linux_only``).
Retired after the release of the 72: ``tests/test_the_host_fontconfig_rules_do_not_reach_the_text_pixels_linux_e2e.py`` (the rules of a user do not reach the pixels
of the text) and ``tests/test_no_fontconfig_file_of_the_host_is_opened_and_the_screenshot_draws_the_bundle_linux_e2e.py`` (no fontconfig file of the host is opened, the screenshot draws the bundle with the caches poisoned) replace it, and
its entry in ``ci/retired-tests.json`` goes to main then. Until then it asserts the same principle on the simplest case, two launches with the same cache folder.
What the engine does. A screenshot sends each font of a text run to the parent as a path and a face index, and the parent turns it into
a font again with fontconfig (``UnscaledFontFontconfig::CreateFromFontDescriptor``). For fontconfig to know the files of the bundle the
parent gives it the folder ``<GRE>/fonts`` with ``FcConfigAppFontAddDir`` (``gfxFcPlatformFontList::ActivateBundledFonts``, which the
shared font list of the parent calls first). On a COLD cache fontconfig opens and scans every file of the folder (about 121) and writes a
cache under ``$XDG_CACHE_HOME/fontconfig``. On a WARM cache it must read that cache (a ``*.cache-*`` file) and NOT open the files again for
the scan: it is the difference between a start that reads 121 fonts and a start that reads one file.
Why Linux only: fontconfig exists only there. On Windows the parent rebuilds a font from the path a text run carries with DirectWrite, which opens the file by
its path and keeps no index of a folder; there is nothing to scan and nothing to cache, and this test has no Windows form (the row of
``ci/required-suites.json`` says so: ``linux_only``).
The measurement. Two launches of the same binary with the same ``XDG_CACHE_HOME``, a new folder of the test: the first is cold, the second
warm. Each runs under ``strace -f -ttt`` (the stand-in of ``tests/_strace_stand_in.py``) that traces the opens of the browser. The environment reaches the browser as it does for a user: the test sets
``XDG_CACHE_HOME`` in its own environment, and the core composes the engine's environment from it (``build_launch_env``: it removes the
host's ``MOZ_*``, ``LANG``, ``TZ`` and the toolkit families, and nothing else); that the variable did arrive is shown by the cache that is
written under it.
What the engine does. It runs fontconfig on its own empty configuration: no ``fonts.conf``, no rule, no cache folder. It does not show ``<GRE>/fonts`` to
fontconfig (the core declares ``gfx.bundled-fonts.activate=0`` on Linux), so nothing scans the folder and nothing writes a cache of it, and a screenshot takes the
file and the face of each text run from the bundle's manifest. The engine neither writes nor reads a fontconfig cache, on a cold folder or a warm one.
Scan or drawing: the criterion. FreeType also opens a file of the bundle (``FT_New_Face`` from the path) when a text run is DRAWN, in the
parent for the screenshot and in the content process for the page: those opens are not a scan and they happen in the warm launch too. The
scan is made by the parent while it builds the font list, before there is a page. So the test counts only what the PARENT process opens
between the start of the browser and the moment the wrapper has returned the launched browser, before any page is opened (``new_page``
is not yet called). The point is a position in the strace log (its size when the launch returns), not a time: the log is written line by
line, and everything the parent did to build its font list is before it. The opens after it (the page with every family of the
screenshot test, and the screenshot) are measured as well and written to the evidence, as ``after_startup``, but the assertion does not
read them.
The measurement. Two launches of the same binary with the same ``XDG_CACHE_HOME`` and the same ``HOME``, both new folders of the test (the test sets them in
its own environment, and the core composes the engine's environment from it; that they arrived is read from ``/proc/<pid>/environ`` of the parent). Each runs
under ``strace -f`` (the stand-in of ``tests/_strace_stand_in.py``) and draws a page with every family of the screenshot test and takes a screenshot. The test asserts,
for each launch:
Why "all or none" and not "none that the cold one opened". Even on a warm cache the parent opens a few files of the bundle before the
first page, to USE them (the face blob of a font of its own interface is opened and mapped); those files are also in the cold set, so a
test that asks for an empty intersection would be red for a good engine. What a scan is, is different: fontconfig scans a folder as a
whole (``FcDirCacheScan`` opens every file of it) or reads the cache of the folder and opens none for the scan. So the test asks about
the whole folder, as the disk lists it (no number written by hand):
* no fontconfig cache file (``<md5>-<arch>.cache-<n>``, and the ``.NEW`` and ``.TMP-*`` it is written through) is under ``XDG_CACHE_HOME`` or ``HOME`` when the
launch has ended: nothing was written, so the second launch finds nothing the first left;
* no process of the browser OPENED such a file, in any folder, whatever the result of the open (an open of ``<md5>-le64.cache-9`` that is refused is a look for a
cache all the same).
* the validity of the measurement: the cold parent opened EVERY font file of ``<GRE>/fonts`` in the window, and fontconfig wrote its
cache under ``$XDG_CACHE_HOME/fontconfig``; otherwise the window does not see the scan and the test says it cannot judge;
* the assertion, the only one that judges: in the same window the warm parent does NOT open every font file of the folder, and it
opens a ``*.cache-*`` file under ``$XDG_CACHE_HOME/fontconfig``.
The launch is valid only when the strace log has lines and the parent's environment carries the two folders: otherwise a clean result would say nothing. An open is
counted whatever its result (strace splits a call that another thread interrupts in "PID openat(... <unfinished ...>" and "PID <... openat resumed>) = -1 ENOENT";
an unfinished line with no resumed line is counted too, since the look happened).
The files of the folder that are not fonts (a ``.list``, a README) are left out of the list, explicitly: a font is a file whose name ends
in one of ``FONT_EXTENSIONS`` (what fontconfig reads through FreeType); the evidence names the files that were left out. The files the
warm parent opened are in the evidence, by name. No threshold: a set that is not the whole folder, and a file that is read.
Evidence, whatever the verdict: when ``RUNNER_TEMP`` is set the test writes ``result.json`` and, for each launch, the opens of the bundle
by the parent with their time, under ``$RUNNER_TEMP/invpw-evidence/fontconfig-cache/``. For the cold and the warm launch (and for a
third, "before", see below): the interval in seconds between the first and the last open of a file of ``<GRE>/fonts`` by the parent, how
many opens, how many distinct files, the name and size of each file of fontconfig's cache, the ``VmRSS`` of the parent after
``about:blank`` and after a page with every family of the screenshot test (drawn and screenshotted).
The third launch, "before", is evidence only: the engine with ``gfx.bundled-fonts.activate`` = 0 never shows the folder to fontconfig (the
pref is Mozilla's, ``mirror: once``, read at start; ``ActivateBundledFonts`` is under ``!= 0``), which is what the parent did before the
correction. The core does not declare that pref anywhere, so the caller's ``extra_prefs`` (applied last, ``_apply_caller_overlay``) is
the only place that says it. If that launch fails, its error is in the evidence and nothing else changes.
What is a cache "of the bundle", and what is an open that happened. fontconfig names the cache of a folder by the md5 of the folder's
path (``<md5>-le64.cache-9``), so the cache of the bundle is the file whose name starts with the md5 of ``<GRE>/fonts`` (and, in the same
launch, with the name fontconfig itself prints for that folder, ``FC_DEBUG=16``); a ``*.cache-*`` file of a system folder
(``/usr/share/fonts``...) is a different cache and proves nothing about the bundle. An open counts only when its result is on the log:
strace splits a call that another thread interrupts in "PID openat(... <unfinished ...>" and "PID <... openat resumed>) = -1 ENOENT", the
result is on the second line, and an unfinished line with no resumed line has no result and is not counted either way.
The evidence of a launch (when ``RUNNER_TEMP`` is set) also holds what fontconfig says: the browser runs with ``FC_DEBUG=16`` (what it
does with caches: the folders it examines, the caches it finds valid, the writes), strace saves the writes to the descriptors 1 and 2
(``fc-debug-<launch>.txt``), and ``trace-<launch>.tsv`` has every open of a ``*.cache-*`` file or of a ``CACHEDIR.TAG`` by any process, in any
folder, and every line that names the bundle's folder or the cache folder: where fontconfig found a valid cache is on it.
Evidence, whatever the verdict: when ``RUNNER_TEMP`` is set the test writes ``result.json`` under ``$RUNNER_TEMP/invpw-evidence/fontconfig-cache/``: for each launch, the
environment of the parent, what is under the two folders, and every open of a cache file with the role of its process.
Run: pytest tests/test_the_parent_reads_the_bundle_from_fontconfig_s_cache_linux_e2e.py -m e2e -v
"""
@@ -83,6 +48,7 @@ import pytest
from _waits import wait_until
from test_a_screenshot_draws_the_text_of_the_bundled_fonts_as_the_content_does_e2e import EVIDENCE_FOLDER, FAMILIES
from test_no_fontconfig_file_of_the_host_is_opened_and_the_screenshot_draws_the_bundle_linux_e2e import _CACHE_FILE, OPEN_CALLS, paths_of_calls
from _strace_stand_in import (
_detached, _group_members, _group_of, _kill_group, _LINE, _require_strace_can_trace, _RESUMED, _roles, _stand_in, _wait_for_exit)
@@ -91,21 +57,11 @@ pytestmark = [
pytest.mark.skipif(not sys.platform.startswith("linux"), reason="fontconfig is the Linux font system"),
]
#: Opens, and what is needed to tell the parent from a content process (``_roles`` reads the execve and the clones).
TRACE = "execve,clone,clone3,fork,vfork,openat,openat2,write"
#: What fontconfig prints with ``FC_DEBUG=16`` goes to the descriptor 1 (the core reads it as the browser's output, and keeps 200 lines): the
#: strace log also holds the ``write`` calls, and ``_fc_debug_text`` keeps those to the descriptors 1 and 2. NOT ``--trace-fds=1,2``: it
#: filters EVERY traced call by descriptor, so the execve, clone and openat lines (which the parent's identity and the opens are read
#: from) are gone and the test saw no parent (candidate run 44749623531).
FC_DEBUG = "16"
#: What is traced: the opens (what the test judges), the writes (``_fc_debug_text`` reads the descriptors 1 and 2), and the execve and clones (the role of a process).
TRACE = "execve,clone,clone3,fork,vfork,open,openat,openat2,write"
SEED = 21
#: What counts as a font of the bundle in the folder ``<GRE>/fonts``: the extensions of the files fontconfig reads through FreeType. Any
#: other file of the folder (a ``.list``, a README) is not a font and is left out of the list, and the evidence says which ones.
FONT_EXTENSIONS = (".ttf", ".ttc", ".otf", ".otc", ".pfb", ".pfa", ".pcf", ".pcf.gz", ".bdf", ".woff", ".woff2", ".pfr", ".fon", ".fnt")
#: ``strace -f -ttt``: "PID EPOCH call(...". ``_LINE`` and ``_roles`` read "PID call(...", so the epoch is taken off first and kept apart.
_STAMPED = re.compile(r"^(\d+)\s+(\d+\.\d+)\s+(.*)$")
_QUOTED = re.compile(r'"([^"]*)"')
@@ -132,13 +88,6 @@ def _evidence_dir():
return Path(base) / EVIDENCE_FOLDER / "fontconfig-cache" if base else None
def _vmrss_kb(pid: int) -> int:
for line in Path("/proc/%d/status" % pid).read_text().splitlines():
if line.startswith("VmRSS:"):
return int(line.split()[1])
raise AssertionError("no VmRSS in /proc/%d/status" % pid)
def _read(log: Path, real: str, boundary: int = None):
"""``(lines, times, role, argv_of, start)`` of a strace log: the lines without their epoch, the epoch of each, the role of a pid,
the execve of each, and the index of the first line that is NOT in the window of the start (``boundary`` is the size of the log
@@ -242,17 +191,6 @@ def _fc_debug_text(lines, role) -> str:
return "\n".join(out)
def _summary(opens):
made = [o for o in opens if o["ok"]]
stamps = [o["t"] for o in made if o["t"] is not None]
return {
"opens": len(made),
"distinct_files": len({o["path"] for o in made}),
"refused_opens": len(opens) - len(made),
"first_to_last_s": round(max(stamps) - min(stamps), 6) if stamps else None,
}
def _environ_of(pid: int, name: str):
"""The value of ``name`` in the environment the process ``pid`` was started with (``/proc/<pid>/environ``); None when it has none or
the file cannot be read."""
@@ -266,116 +204,48 @@ def _environ_of(pid: int, name: str):
return None
def _fontconfig_cache(xdg: Path):
folder = xdg / "fontconfig"
if not folder.is_dir():
return []
return sorted(({"name": f.name, "bytes": f.stat().st_size} for f in folder.iterdir() if f.is_file()), key=lambda f: f["name"])
def _cache_files_under(*folders: Path) -> list:
"""The fontconfig cache files (``*.cache-<n>``, ``.NEW``, ``.TMP-*``) anywhere under the folders, as the disk lists them."""
found = []
for folder in folders:
for root, _dirs, files in os.walk(folder):
found.extend(os.path.join(root, name) for name in files if _CACHE_FILE.search(name))
return sorted(found)
def _the_folder(gre_fonts: str):
"""``(fonts, left_out)``: the names of the files of the folder as the DISK lists them, split by ``FONT_EXTENSIONS``."""
names = sorted(e.name for e in os.scandir(gre_fonts) if e.is_file()) if os.path.isdir(gre_fonts) else []
fonts = [n for n in names if n.lower().endswith(FONT_EXTENSIONS)]
return fonts, [n for n in names if n not in fonts]
def _launch(firefox_binary, work: Path, xdg: Path, extra_prefs=None):
"""One launch of the binary under strace, with ``XDG_CACHE_HOME`` = ``xdg`` in the environment of the test. Returns what the log and
/proc say; the browser is gone when it returns."""
def _launch(firefox_binary, work: Path, xdg: Path, home: Path):
"""One launch of the binary under strace, with ``XDG_CACHE_HOME`` = ``xdg`` and ``HOME`` = ``home`` in the environment of the test. Returns what the log, /proc and the
disk say; the browser is gone when it returns."""
from invisible_playwright import InvisiblePlaywright
work.mkdir(parents=True)
log, pidfile = work / "strace.log", work / "stand-in.pid"
stand_in = _stand_in(firefox_binary, work / "engine", log, pidfile, syscalls=TRACE, timestamps=True)
stand_in = _stand_in(firefox_binary, work / "engine", log, pidfile, syscalls=TRACE)
real = os.path.realpath(firefox_binary)
gre_fonts = os.path.join(os.path.dirname(real), "fonts")
rss, boundary, pid, environ_xdg = {}, None, None, None
pid, environ = None, {}
try:
with InvisiblePlaywright(seed=SEED, binary_path=stand_in, headless=True, extra_prefs=extra_prefs) as browser:
# The launch has returned: the parent has built its font list. No page has been opened yet.
boundary = log.stat().st_size
_lines, _times, _role, argv_of, _start = _read(log, real, boundary)
with InvisiblePlaywright(seed=SEED, binary_path=stand_in, headless=True) as browser:
_lines, _times, _role, argv_of, _start = _read(log, real)
pid = _parent_pid(argv_of, real)
environ_xdg = _environ_of(pid, "XDG_CACHE_HOME")
environ = {name: _environ_of(pid, name) for name in ("XDG_CACHE_HOME", "HOME")}
page = browser.new_page()
rss["after_about_blank_kb"] = _vmrss_kb(pid)
page.set_content(_page_with_every_family())
assert page.evaluate("() => document.body.getBoundingClientRect().width") > 0
page.screenshot()
rss["after_every_family_kb"] = _vmrss_kb(pid)
finally:
_kill_group(pidfile)
lines, times, role, _argv_of, start = _read(log, real, boundary)
under = sorted({gre_fonts, os.path.realpath(gre_fonts)})
results = _results_of_unfinished(lines)
scan = _opens_of_the_parent(lines, times, role, 0, start, under, results)
later = _opens_of_the_parent(lines, times, role, start, len(lines), under, results)
fc_debug = _fc_debug_text(lines, role)
prefixes = _bundle_cache_prefixes(under, fc_debug)
fonts, left_out = _the_folder(gre_fonts)
opened = sorted({os.path.basename(o["path"]) for o in scan if o["ok"]})
cache_dir = str(xdg / "fontconfig")
# Evidence for a launch whose cache is missing: every line of the log, by ANY process, that names the bundle's folder, the cache
# folder or a ``.uuid``, with the role of the process and the window it is in (the opens above count only the parent's, and only
# in the window). The raw lines say who scanned (or did not), and where fontconfig wrote.
trace = []
for i, line in enumerate(lines):
if any(u in line for u in under) or cache_dir in line or "/.uuid" in line:
m = _LINE.match(line) or re.match(r"^(\d+)\s", line)
who = role(int(m.group(1))) if m else "?"
trace.append("%s\t%s\t%s\t%s" % (times[i], "startup" if i < start else "later", who, line[:400]))
# The reads of the cache of the BUNDLE (not of a system folder), by the parent in the window: under the cache folder, and anywhere.
cache_reads = [o for o in _opens_of_the_parent(lines, times, role, 0, start, [cache_dir], results)
if o["ok"] and _is_a_cache_of(o["path"], prefixes)]
anywhere = []
for i, line in enumerate(lines[:start]):
m = _LINE.match(line)
if m and m.group(2) in ("openat", "openat2") and role(int(m.group(1))) == "parent":
quoted = _QUOTED.findall(m.group(3))
if quoted and _is_a_cache_of(quoted[0], prefixes) and (_open_result(lines, i, results) or -1) >= 0:
anywhere.append(quoted[0])
# Every open of a cache file or of a CACHEDIR.TAG by any process, in any folder, with its result: where fontconfig found a valid cache.
cache_opens = []
for i, line in enumerate(lines):
m = _LINE.match(line)
if m and m.group(2) in ("openat", "openat2"):
quoted = _QUOTED.findall(m.group(3))
if quoted and (".cache-" in quoted[0] or "CACHEDIR.TAG" in quoted[0]):
result = _open_result(lines, i, results)
cache_opens.append("%s\t%s\t%s\t%s\t%s" % (
times[i], "startup" if i < start else "later", role(int(m.group(1))),
"no-result" if result is None else ("ok" if result >= 0 else "refused"), quoted[0]))
trace = cache_opens + trace
lines, _times, role, _argv_of, _start = _read(log, real)
opened = [dict(call, role=role(call["pid"])) for call in paths_of_calls(lines, OPEN_CALLS) if _CACHE_FILE.search(os.path.basename(call["path"]))]
return {
"parent_pid": pid,
"parent_environ_xdg_cache_home": environ_xdg,
"startup": _summary(scan),
"after_startup": _summary(later),
"cache_files_read_at_startup": sorted({o["path"] for o in cache_reads}),
"bundle_cache_read_anywhere_at_startup": sorted(set(anywhere)),
"bundle_cache_names": sorted(prefixes),
"bundle_cache_written": [f for f in _fontconfig_cache(xdg) if _is_a_cache_of(f["name"], prefixes)],
"fc_debug_about_the_bundle": [l for l in fc_debug.splitlines() if any(u in l for u in under)],
"_fc_debug": fc_debug,
"fontconfig_cache": _fontconfig_cache(xdg),
"vmrss_kb": rss,
"bundle_font_files": len(fonts),
"files_left_out_as_not_fonts": left_out,
"font_files_opened_at_startup": len([n for n in opened if n in fonts]),
"font_files_not_opened_at_startup": [n for n in fonts if n not in opened],
"files_opened_at_startup": opened,
"_scan_opens": scan,
"_later_opens": later,
"_trace": trace,
"parent_environ": environ,
"log_lines": len(lines),
"cache_files_under_the_two_folders": _cache_files_under(xdg, home),
"cache_file_opens": opened,
}
def _public(measure: dict) -> dict:
return {k: v for k, v in measure.items() if not k.startswith("_")}
@pytest.mark.timeout(120, method="thread")
def test_the_stand_in_stays_in_the_engine_s_place_and_its_group_is_killed_whole(tmp_path):
"""The tool, without a browser. A fake engine (a script that starts a child and waits for it) is launched through the stand-in
@@ -421,71 +291,46 @@ def test_the_stand_in_stays_in_the_engine_s_place_and_its_group_is_killed_whole(
@pytest.mark.timeout(900, method="thread")
def test_the_warm_parent_reads_the_bundle_from_fontconfig_cache_and_does_not_scan_it(firefox_binary, engine_at_least, tmp_path, monkeypatch):
engine_at_least("firefox-66")
def test_the_warm_parent_reads_the_bundle_from_fontconfig_cache_and_does_not_scan_it(firefox_binary, tmp_path, monkeypatch):
"""The id is the one of the warm-cache test this file was; what it asserts is the 72's behaviour (see the docstring of the module)."""
if shutil.which("strace") is None:
pytest.fail("needs strace (apt install strace): without it nothing is measured", pytrace=False)
_require_strace_can_trace(tmp_path)
xdg = tmp_path / "xdg-cache"
xdg, home = tmp_path / "xdg-cache", tmp_path / "home"
xdg.mkdir()
home.mkdir()
monkeypatch.setenv("XDG_CACHE_HOME", str(xdg))
monkeypatch.setenv("FC_DEBUG", FC_DEBUG) # it only prints; the core passes it to the browser as it passes XDG_CACHE_HOME
monkeypatch.setenv("HOME", str(home))
for variable in ("FONTCONFIG_FILE", "FONTCONFIG_PATH"):
monkeypatch.delenv(variable, raising=False)
cold = _launch(firefox_binary, tmp_path / "cold", xdg)
cold_cache = cold["fontconfig_cache"]
warm = _launch(firefox_binary, tmp_path / "warm", xdg)
first = _launch(firefox_binary, tmp_path / "first", xdg, home)
second = _launch(firefox_binary, tmp_path / "second", xdg, home)
launches = {"first": first, "second": second}
# "Before": the folder is never shown to fontconfig. Its own cache folder, so that it is not warmed by the others.
before_xdg = tmp_path / "xdg-cache-before"
before_xdg.mkdir()
monkeypatch.setenv("XDG_CACHE_HOME", str(before_xdg))
try:
before = _launch(firefox_binary, tmp_path / "before", before_xdg, extra_prefs={"gfx.bundled-fonts.activate": 0})
except Exception as err: # evidence only: a launch that fails is written down, it does not change the verdict
before = {"error": "%s: %s" % (type(err).__name__, str(err)[:600])}
result = {
"test": "the-parent-reads-the-bundle-from-fontconfig-cache",
"platform": sys.platform,
"seed": SEED,
"xdg_cache_home": str(xdg),
"criterion": ("window = what the PARENT opens before any page is opened (the strace log up to its size when the launch returned; "
"the opens after it are drawing and are in after_startup). Valid: the cold parent opened every font file of "
"<GRE>/fonts and fontconfig wrote its cache. Verdict: the warm parent does not open every font file of the folder "
"and opens a *.cache-* file. Font files = the folder as the disk lists it, by FONT_EXTENSIONS"),
"cold": _public(cold),
"warm": _public(warm),
"before_gfx_bundled_fonts_activate_0": _public(before) if "error" not in before else before,
}
where = _evidence_dir()
if where is not None:
where.mkdir(parents=True, exist_ok=True)
(where / "result.json").write_text(json.dumps(result, indent=1, sort_keys=True) + "\n", encoding="utf-8")
for name, measure in (("cold", cold), ("warm", warm), ("before", before)):
if "_scan_opens" in measure:
rows = ["%s\t%s\t%s" % (o["t"], "ok" if o["ok"] else "refused", o["path"])
for o in measure["_scan_opens"] + measure["_later_opens"]]
(where / ("bundle-opens-%s.tsv" % name)).write_text("\n".join(rows) + "\n", encoding="utf-8")
(where / ("trace-%s.tsv" % name)).write_text("\n".join(measure["_trace"]) + "\n", encoding="utf-8")
(where / ("fc-debug-%s.txt" % name)).write_text(measure["_fc_debug"] + "\n", encoding="utf-8")
try:
where.mkdir(parents=True, exist_ok=True)
(where / "result.json").write_text(json.dumps(
{"test": "the-engine-writes-and-reads-no-fontconfig-cache", "platform": sys.platform, "seed": SEED,
"xdg_cache_home": str(xdg), "home": str(home), "launches": launches}, indent=1, sort_keys=True) + "\n", encoding="utf-8")
except Exception as exc: # a record never changes the outcome
print("the record could not be written:", repr(exc))
# The measurement is valid or the test says it cannot judge.
assert cold["bundle_cache_written"], (
"the cold launch wrote no cache of the bundle under XDG_CACHE_HOME=%s (there: %s; the names of a cache of the bundle: %s). "
"XDG_CACHE_HOME in the parent's environment: %s. Cache of the bundle opened by the parent before a page, in any folder: %s. "
"What fontconfig printed about the folder of the bundle (FC_DEBUG=16): %s. The window: %s. Nothing for a warm launch to read."
% (xdg, [f["name"] for f in cold_cache] or "nothing", cold["bundle_cache_names"], cold["parent_environ_xdg_cache_home"],
cold["bundle_cache_read_anywhere_at_startup"] or "none", cold["fc_debug_about_the_bundle"] or "nothing (or FC_DEBUG not saved)",
cold["startup"]))
assert not cold["font_files_not_opened_at_startup"] and cold["bundle_font_files"], (
"the parent of the cold launch did not open every font file of <GRE>/fonts (%d of %d) before a page was opened: the window does "
"not see the scan; the test cannot judge. Not opened: %s"
% (cold["font_files_opened_at_startup"], cold["bundle_font_files"], cold["font_files_not_opened_at_startup"][:5]))
scanned_again = not warm["font_files_not_opened_at_startup"]
assert not scanned_again and warm["cache_files_read_at_startup"], (
"the warm parent %s. Cold: %s. Warm: %s. Cache under %s: cold %s, warm %s."
% ("opened every one of the %d font files of <GRE>/fonts before a page: it scanned the folder again"
% warm["bundle_font_files"] if scanned_again else "read no *.cache-* file of fontconfig at its start",
result["cold"]["startup"], result["warm"]["startup"], xdg / "fontconfig", cold_cache, warm["fontconfig_cache"]))
# The measurement is valid or the test says it cannot judge: the browser was traced, and the two folders reached its parent.
for name, launch in launches.items():
assert launch["log_lines"] > 0, "%s launch: strace wrote nothing, the browser was not traced" % name
assert launch["parent_environ"] == {"XDG_CACHE_HOME": str(xdg), "HOME": str(home)}, (
"%s launch: the parent's environment carries %r, not the folders of the test (XDG_CACHE_HOME=%s, HOME=%s): a clean result would say nothing"
% (name, launch["parent_environ"], xdg, home))
# The assertions: nothing written, nothing opened, on either launch.
for name, launch in launches.items():
assert not launch["cache_files_under_the_two_folders"], (
"%s launch: fontconfig cache files were written under XDG_CACHE_HOME or HOME: %s"
% (name, launch["cache_files_under_the_two_folders"][:6]))
assert not launch["cache_file_opens"], (
"%s launch: %d open(s) of a fontconfig cache file by the browser, by role %s: %s"
% (name, len(launch["cache_file_opens"]), sorted({o["role"] for o in launch["cache_file_opens"]}),
[(o["role"], o["call"], o["path"], o["result"]) for o in launch["cache_file_opens"][:6]]))
@@ -0,0 +1,133 @@
"""The criterion of the fontconfig e2e: which opens are a look at the host's fontconfig, and when the poisoned cache is in force, on fake strace lines.
The e2e (tests/test_no_fontconfig_file_of_the_host_is_opened_and_the_screenshot_draws_the_bundle_linux_e2e.py) asks that no process of the browser opens a path
under /etc/fonts, a ``fonts.conf`` or a ``*.cache-*`` file, and that the screenshot draws the bundle with the host's caches poisoned. Its verdict is only as good as
what it counts as an open and as a poison that is really in force; both are pure functions of the log and of what ``fc-list`` said, tried here with no browser:
an open that is refused or unfinished still counts, a relative path takes the folder of its descriptor, a stat is evidence and not an open, and a cache that still lists
the face (or lists nothing) is no poison.
"""
import importlib.util
import sys
from pathlib import Path
import pytest
pytestmark = pytest.mark.unit
TESTS = Path(__file__).resolve().parents[1]
E2E = TESTS / "test_no_fontconfig_file_of_the_host_is_opened_and_the_screenshot_draws_the_bundle_linux_e2e.py"
BINARY = "/engine/firefox"
BUNDLE = "/opt/invisible-playwright/firefox-72_160.0_20261201000000/fonts"
MD5 = "0123456789abcdef0123456789abcdef"
def _module():
sys.path.insert(0, str(TESTS))
try:
spec = importlib.util.spec_from_file_location("fontconfig_host_files_e2e", E2E)
module = importlib.util.module_from_spec(spec)
sys.modules["fontconfig_host_files_e2e"] = module
spec.loader.exec_module(module)
finally:
sys.path.remove(str(TESTS))
return module
def _lines(*calls):
"""A strace log of a parent (pid 100) that starts a content process (pid 200), with the calls, as the test reads it (``-f -y``)."""
return ['100 execve("%s", ["%s"], 0x0) = 0' % (BINARY, BINARY),
'100 clone3({flags=CLONE_VM}, 88) = 200',
'200 execve("%s", ["%s", "-contentproc"], 0x0) = 0' % (BINARY, BINARY)] + list(calls)
@pytest.mark.parametrize("path", [
"/etc/fonts/fonts.conf", "/etc/fonts/conf.d/10-hinting-slight.conf", "/etc/fonts", "/etc/fonts/../fonts/conf.d",
"/tmp/hd/.config/fontconfig/fonts.conf", BUNDLE + "/fonts.conf", "/fonts.conf",
"/var/cache/fontconfig/" + MD5 + "-le64.cache-9", "/tmp/hd/.fontconfig/" + MD5 + "-le64.cache-9",
"/tmp/hd/.cache/fontconfig/" + MD5 + "-le64.cache-9.NEW", "/tmp/hd/.cache/fontconfig/" + MD5 + "-le64.cache-9.TMP-YhscHU",
])
def test_a_path_of_the_host_s_fontconfig_is_named(path):
assert _module().is_a_fontconfig_file_of_the_host(path) is True
@pytest.mark.parametrize("path", [
BUNDLE + "/arial.ttf", BUNDLE + "/msgothic5_32.ttc", "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", "/etc/fontsrc", "/etc/fonts.conf.bak",
"/tmp/hd/.cache/fontconfig", "/tmp/hd/.cache/mozilla/startupCache/startupCache.8.little", "/proc/self/maps",
])
def test_a_path_that_is_not_the_host_s_fontconfig_is_left_alone(path):
assert _module().is_a_fontconfig_file_of_the_host(path) is False
def test_an_open_counts_whatever_its_result_and_an_unfinished_one_has_the_result_of_its_resumed_line():
module = _module()
lines = _lines(
'100 openat(AT_FDCWD</>, "/etc/fonts/fonts.conf", O_RDONLY <unfinished ...>',
'101 getpid() = 101',
'100 <... openat resumed>) = -1 ENOENT (No such file or directory)',
'100 openat(AT_FDCWD</>, "/etc/fonts/conf.d", O_RDONLY|O_DIRECTORY) = 7</etc/fonts/conf.d>',
'100 openat(AT_FDCWD</>, "/etc/fonts/other.conf", O_RDONLY <unfinished ...>')
opens = module.paths_of_calls(lines, module.OPEN_CALLS)
assert [(o["path"], o["result"]) for o in opens] == [("/etc/fonts/fonts.conf", -1), ("/etc/fonts/conf.d", 7), ("/etc/fonts/other.conf", None)]
def test_a_relative_path_takes_the_folder_strace_prints_for_its_descriptor():
module = _module()
lines = _lines('100 openat(5</etc/fonts/conf.d>, "10-hinting-slight.conf", O_RDONLY) = 6</etc/fonts/conf.d/10-hinting-slight.conf>',
'100 openat(AT_FDCWD</tmp/hd>, "x/y.cache-9", O_RDONLY) = 8',
'100 open("/etc/fonts/fonts.conf", O_RDONLY) = 9')
assert [o["path"] for o in module.paths_of_calls(lines, module.OPEN_CALLS)] == [
"/etc/fonts/conf.d/10-hinting-slight.conf", "/tmp/hd/x/y.cache-9", "/etc/fonts/fonts.conf"]
def test_the_opens_of_every_process_are_judged_with_the_role_of_each():
lines = _lines(
'100 openat(AT_FDCWD</>, "/etc/fonts/fonts.conf", O_RDONLY) = 5',
'200 openat(AT_FDCWD</>, "/var/cache/fontconfig/%s-le64.cache-9", O_RDONLY) = -1 ENOENT (No such file or directory)' % MD5,
'300 openat(AT_FDCWD</>, "/tmp/hd/.fontconfig/%s-le64.cache-9", O_RDONLY) = 6' % MD5,
'100 openat(AT_FDCWD</>, "%s/arial.ttf", O_RDONLY) = 7' % BUNDLE)
looks = _module().host_fontconfig_looks(lines, BINARY)
assert [(o["role"], o["path"].rsplit("/", 1)[1]) for o in looks["opens"]] == [
("parent", "fonts.conf"), ("content", MD5 + "-le64.cache-9"), ("other", MD5 + "-le64.cache-9")]
assert looks["other"] == []
def test_a_stat_is_evidence_and_not_an_open_and_a_quiet_log_has_no_look():
module = _module()
lines = _lines('100 newfstatat(AT_FDCWD</>, "/etc/fonts/fonts.conf", {st_mode=S_IFREG|0644}, 0) = 0',
'100 access("/etc/fonts/fonts.conf", R_OK) = 0',
'100 readlink("/etc/fonts/conf.d/x.conf", 0x7ff, 4096) = -1 EINVAL (Invalid argument)')
looks = module.host_fontconfig_looks(lines, BINARY)
assert looks["opens"] == [] and [o["call"] for o in looks["other"]] == ["newfstatat", "access", "readlink"]
assert module.host_fontconfig_looks(_lines('100 openat(AT_FDCWD</>, "%s/arial.ttf", O_RDONLY) = 7' % BUNDLE), BINARY) == {"opens": [], "other": []}
def test_the_poison_is_written_for_the_real_folder_from_the_copy_into_one_cache_folder():
module = _module()
text = module.poison_config(BUNDLE, "/tmp/copy", "/tmp/hd/.fontconfig")
assert '<remap-dir as-path="%s">/tmp/copy</remap-dir>' % BUNDLE in text and "<cachedir>/tmp/hd/.fontconfig</cachedir>" in text
assert text.count("<dir>") == 0 and text.count("<cachedir>") == 1
reader = module.reader_config(BUNDLE, "/tmp/hd/.fontconfig")
assert "<dir>%s</dir>" % BUNDLE in reader and "<cachedir>/tmp/hd/.fontconfig</cachedir>" in reader
def _poison(**over):
cache = {"cache_folder": "/h/.fontconfig", "cache_files": [MD5 + "-le64.cache-9"],
"listed_files": [BUNDLE + "/arial.ttf", BUNDLE + "/simsun.ttc"]}
one = dict(cache, **over)
return {"real_folder": BUNDLE, "md5_of_the_real_folder": MD5, "caches": {"home": dict(one), "xdg": dict(one)}}
def test_a_poison_that_is_in_force_has_a_cache_for_the_real_folder_that_lacks_the_face():
assert _module()._poison_problems(_poison()) == []
@pytest.mark.parametrize("over, why", [
({"listed_files": [BUNDLE + "/arial.ttf", BUNDLE + "/msgothic5_32.ttc"]}, "lists msgothic5_32.ttc"),
({"listed_files": []}, "lists no font"),
({"listed_files": ["/tmp/copy/arial.ttf"]}, "outside the real folder"),
({"cache_files": ["ffffffffffffffffffffffffffffffff-le64.cache-9"]}, "no cache named for the real folder"),
({"cache_files": []}, "no cache named for the real folder"),
])
def test_a_cache_that_is_no_poison_is_named_with_its_reason(over, why):
problems = _module()._poison_problems(_poison(**over))
assert len(problems) == 2 and all(why in p for p in problems)