tests: the fontconfig rules of the host enter through /etc/fonts/local.conf, since the core owns XDG_CONFIG_HOME

The test of the fontconfig rules (E1) injected each launch's rules through $XDG_CONFIG_HOME/fontconfig/fonts.conf and held the precondition that
XDG_CONFIG_HOME reached the engine (/proc/<pid>/environ). The core now points XDG_CONFIG_HOME and XDG_CONFIG_DIRS of the engine at empty folders of
its own, so that route no longer reaches the engine.

Now each launch writes its rules to /etc/fonts/local.conf with sudo (the e2e job runs on ubuntu-24.04 runners with passwordless sudo: e2e.yml
already uses it) and puts the original file back, or removes it if there was none, when the launch ends. The positive control stays: fc-match on
the host, in the environment of the test process, must obey each rule, or the launch fails. The engine-environment precondition is replaced by that
control. Every pixel assertion is unchanged: same launches, canvases, families, sizes and hashes compared with launch 1, plus the system-ui
assertion. Same three tests, same ids.

Why this is not a weakened test: the source of the test changed, not its bar. The test's route (the user's XDG config folder) is no longer a
route a host can use on the new engine, because the core owns that variable; the system-wide file is where a host can still put a rule, and the
test reads the same effect there. The check that the rule is in force in fontconfig itself is kept as the host control, and a rule fontconfig
does not apply still fails the launch.

The row note of ci/required-suites.json and the docstring of the host-files test say how it is now.
This commit is contained in:
feder-cr committed 2026-12-02 03:25:15 +01:00
1 parent a3e647bf2f
commit eb052e7439
3 files changed
+79 -62

No files matched your search

+1 -1
View File
@@ -16,7 +16,7 @@
{"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": 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.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 system-wide rule file (/etc/fonts/local.conf, written with sudo before the launch and put back after it; not the environment, which the core owns: it strips FONTCONFIG_*, and points XDG_CONFIG_HOME and XDG_CONFIG_DIRS at empty folders): 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 in fc-match on the host; 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, fc-match and sudo without a password 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": 4529, "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_served_browser_keeps_the_udp_verdicts_of_its_proxies.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_fixture_a_test_pins_is_checked_out_byte_for_byte.py", Line truncated
{"id": "wrapper.unit.all.windows", "giro": "G1", "os": ["windows"], "min_tests": 4541, "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_served_browser_keeps_the_udp_verdicts_of_its_proxies.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_fixture_a_test_pins_is_checked_out_byte_for_byte.pLine truncated
@@ -33,7 +33,8 @@ face of the text run, which does not list it: it draws another file's outlines (
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.
folder with nothing in it; the core gives the engine empty configuration folders of its own, whatever the test sets), and the core composes the rest of 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
@@ -1,4 +1,4 @@
"""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).
"""The fontconfig rules of the host 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``).
@@ -8,10 +8,11 @@ The question. The engine draws a face with the parameters of its fontconfig patt
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.
How a rule enters. As the rule of a host does, system-wide: ``/etc/fonts/local.conf``, the file the system ``fonts.conf`` includes for the rules of the
administrator, written with ``sudo`` (the runner has it without a password) just before the launch and put back as it was (or removed, if there was
none) when the launch ends, whatever its outcome. Not through the environment: the core owns ``XDG_CONFIG_HOME`` and ``XDG_CONFIG_DIRS`` and points
both at empty folders of its own, and removes ``FONTCONFIG_*`` and ``FC_*``, so no variable the test sets can carry a rule to the engine, and a test
built on one would be green for the wrong reason. The files of the system are where a host can still put a rule, and where the engine must not read it.
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:
@@ -26,9 +27,9 @@ What is drawn. One local page (http://127.0.0.1, a secure context, so ``crypto.s
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``:
Seven launches, one engine, one seed, each with its own ``/etc/fonts/local.conf``:
1. nothing: a ``fonts.conf`` with no rule (the rules of the machine, whatever they are);
1. nothing: a ``local.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``;
@@ -38,15 +39,14 @@ Seven launches, one engine, one seed, each with its own user ``fonts.conf``:
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
Each is a separate configuration. The positive control: before each engine starts, ``fc-match`` runs on the HOST, in the environment of the test process
(less ``FONTCONFIG_*`` and ``FC_*``), 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 has its rule in force in fontconfig itself (the host control above), 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.
@@ -54,13 +54,15 @@ Red on the old engine (run 45078210028: ``rgba=none`` with ``lcdfilter=none`` ch
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.
launch, the configuration, the hashes and subpixel counts by row, the reads of ``system-ui``, what ``fc-match`` says and the ``FONTCONFIG_*`` / ``FC_*``
variables 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 contextlib
import http.server
import json
import os
@@ -98,7 +100,10 @@ HOST_FACE_CANDIDATES = [
("/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.
#: The system-wide file of the rules of a host; the system ``fonts.conf`` includes it.
LOCAL_CONF = Path("/etc/fonts/local.conf")
#: name of the launch -> the rules, ``(property, kind, value)``. The ``local.conf`` of a launch holds them and nothing else.
LAUNCHES = [
("1_nothing", []),
("2_rgba_none_lcdnone", [("rgba", "const", "none"), ("lcdfilter", "const", "lcdnone")]),
@@ -203,7 +208,7 @@ def _evidence_dir():
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)."""
"""The ``/etc/fonts/local.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.
@@ -221,11 +226,31 @@ def _config_text(name: str, rules, host_family: str) -> str:
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_env() -> dict:
"""The environment ``fc-match`` runs in: the test's own, without the variables the core strips."""
return {k: v for k, v in os.environ.items() if not k.startswith(("FONTCONFIG_", "FC_"))}
def _sudo(*argv: str, data: bytes | None = None) -> subprocess.CompletedProcess:
"""``sudo`` without a password prompt (``-n``): a runner without it fails here, loudly, and the test says so."""
return subprocess.run(["sudo", "-n", *argv], input=data, capture_output=True, timeout=60)
@contextlib.contextmanager
def _system_rule(text: str):
"""``/etc/fonts/local.conf`` holds ``text`` inside the block; on the way out, whatever happened, the file is what it was before (or is removed, if there
was none). A host that cannot be written to is a failure of the test, never a launch without its rule."""
original = LOCAL_CONF.read_bytes() if LOCAL_CONF.is_file() else None
try:
done = _sudo("tee", str(LOCAL_CONF), data=text.encode("utf-8"))
assert done.returncode == 0, "cannot write %s with sudo: %s" % (LOCAL_CONF, done.stderr.decode("utf-8", "replace").strip())
yield
finally:
if original is None:
done = _sudo("rm", "-f", str(LOCAL_CONF))
else:
done = _sudo("tee", str(LOCAL_CONF), data=original)
assert done.returncode == 0, "cannot put %s back with sudo: %s" % (LOCAL_CONF, done.stderr.decode("utf-8", "replace").strip())
def _fc_match(env: dict, pattern: str, fmt: str) -> str:
@@ -233,11 +258,11 @@ def _fc_match(env: dict, pattern: str, fmt: str) -> str:
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)."""
def _what_fontconfig_says() -> dict:
"""What fontconfig itself says on the host with the rule of this launch in place (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)
env = _fc_env()
try:
for key in PROPERTIES:
out[key] = _fc_match(env, "sans", "%%{%s}" % key)
@@ -252,7 +277,7 @@ def _what_fontconfig_says(xdg_config_home: Path) -> dict:
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
"""The precondition of a launch, decided BEFORE its engine starts: does fontconfig on the host 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:
@@ -276,10 +301,9 @@ def _rule_in_force(name: str, said: dict, base_said: dict, host_family: str) ->
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": []}
def _engine_environ(binary: str) -> dict:
"""Evidence only: the processes of the engine seen in ``/proc`` and any ``FONTCONFIG_*`` / ``FC_*`` in their environment (the core removes them)."""
seen = {"processes": 0, "fontconfig_variables": []}
try:
real = os.path.realpath(binary)
for entry in os.scandir("/proc"):
@@ -293,22 +317,19 @@ def _engine_environ(binary: str, xdg_config_home: Path) -> dict:
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:
def _launch(binary: str, 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.
result = {}
# A FONTCONFIG_FILE or FONTCONFIG_PATH of the runner is taken off: with one of them, the system ``fonts.conf`` would not be read, nor would the
# ``local.conf`` it includes.
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:
@@ -316,7 +337,7 @@ def _launch(binary: str, xdg_config_home: Path, url: str) -> dict:
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)
result["engine_environ"] = _engine_environ(binary)
return result
@@ -358,12 +379,13 @@ def _table(results: dict, base: str) -> str:
@pytest.fixture(scope="module")
def launches(firefox_binary, tmp_path_factory):
def launches(firefox_binary):
"""Every launch, once per module. -> {name: result}; the record is written before the assertions run."""
for tool in ("fc-match",):
for tool in ("fc-match", "sudo"):
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")
pytest.fail("needs %s (fontconfig, sudo): without it no rule can be put on the host and shown to be in force" % tool, pytrace=False)
if _sudo("true").returncode != 0:
pytest.fail("needs sudo without a password: a rule of the host is written to %s" % LOCAL_CONF, pytrace=False)
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]
@@ -373,15 +395,13 @@ def launches(firefox_binary, tmp_path_factory):
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")
config = _config_text(name, rules, host_family)
with _system_rule(config):
# Before the engine starts: fontconfig on the host with this rule in place. Its answer says whether the launch measures anything.
fc[name] = _what_fontconfig_says()
precondition = _rule_in_force(name, fc[name], fc.get(BASE_LAUNCH, fc[name]), host_family)
results[name] = _launch(firefox_binary, url)
results[name]["config"] = config
results[name]["fc_match"] = fc[name]
results[name]["precondition"] = precondition
finally:
@@ -398,30 +418,26 @@ def launches(firefox_binary, tmp_path_factory):
(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()})
print("FONTCONFIG_* / FC_* variables seen in the engine's processes:",
{n: (r.get("engine_environ") or {}).get("fontconfig_variables") 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"."""
"""The first assertion of every test: a launch whose rule fontconfig itself does not apply 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."""
"""Without this the equalities below would say nothing: a configuration fontconfig ignores is equal to any other. The rule is in force when ``fc-match``
on the host obeys it (the engine's environment is not the route: the core gives the engine empty folders of its own)."""
_every_launch_measures_something(launches)