Files
cthulhu/tests/native_test_session.py
Storm Dragon 89686fa029 Refresh browser tests and recover Firefox tab announcements
Bring the fragmented-line browser fixture into agreement with current browse
navigation. Rich editors are read through their text descendants, so Down from
the preceding heading must read "Review the code." directly. Remove the stale
empty editor-control stop while retaining forward and reverse line navigation,
character and word movement, Read All, and inline Braille-routing assertions.

Fix Firefox's missing announcement when creating a second tab. Firefox can emit
selection events before the new tab enters its accessible child list, causing
the native selected-child lookup to return nothing. Use the subsequent
child-added event only when its target is a live, freshly selected browser-chrome
tab with the emitting tab list as its direct parent. Keep document-authored tabs
and unselected background additions excluded, retain foreground filtering and
tab-identity deduplication, and release native references on the GLib owner.

Normalize child-added origin suffixes such as :system before event dispatch,
preserving the original native type in diagnostics. Rename the shared mutation
normalizer to reflect its expanded scope and update its callers, including the
Pidgin insertion check. Extend the normalization regression to cover child
additions and reject unrelated event names. Firefox keeps its normal animations
and all existing tab-announcement and address-editing assertions.

Make private-session teardown tolerate the document portal's asynchronous FUSE
unmount after D-Bus exits. Retry only ENOTCONN and EBUSY cleanup failures for at
most five seconds. Keep unrelated errors and persistent mount failures visible.
Add regressions for transient teardown, preservation of a failing child's exit
status, unrelated cleanup errors, and the cleanup deadline. Runtime directories
and accessibility buses remain private, with no init-system dependency.

Update browser verification notes and the parity ledger with the fixes, evidence,
regression risks, and concrete live acceptance procedures.

Validation:
- All 33 Chromium browser proofs passed in the final combined run.
- Firefox baseline and tab checks passed repeatedly with normal animations.
- All eight private-session isolation and cleanup regressions passed.
- AT-SPI, app, and review package race suites passed during development; focused
  race regressions passed again after the final event-normalization change.
- Go vet passed for internal/atspi, internal/app, and internal/review.
- A separate reader binary built successfully.
- Parity-ledger validation passed for 75 rows; git diff --check passed.
2026-11-03 02:38:59 -05:00

57 lines
2.3 KiB
Python

#!/usr/bin/env python3
# Copyright (c) 2026 Storm Dragon
# Authors: Storm Dragon, Angus Kola
# SPDX-License-Identifier: GPL-3.0-or-later
"""Launch native tests with disposable runtime sockets and private D-Bus."""
import errno
import os
import subprocess
import sys
import tempfile
import time
def run_private_session(command, *, env, **kwargs):
"""Keep activated services away from the desktop's runtime sockets."""
if not command or command[0] not in ("dbus-run-session", "xvfb-run"):
raise ValueError("Start the private session with xvfb-run or dbus-run-session")
if "dbus-run-session" not in command:
raise ValueError("A private session requires dbus-run-session")
if "xvfb-run" in command and command.index("xvfb-run") > command.index("dbus-run-session"):
raise ValueError("Start Xvfb before D-Bus so activated services inherit the private display")
# Keep this path short: AT-SPI falls back from named sockets if its
# generated socket path is 100 bytes or longer.
runtime = tempfile.TemporaryDirectory(prefix="cth-run-", dir="/tmp")
try:
sessionEnv = dict(env, XDG_RUNTIME_DIR=runtime.name)
for name in ("DBUS_SESSION_BUS_ADDRESS", "DBUS_STARTER_ADDRESS", "DBUS_STARTER_BUS_TYPE",
"AT_SPI_BUS_ADDRESS", "WAYLAND_DISPLAY"):
sessionEnv.pop(name, None)
return subprocess.run(command, env=sessionEnv, **kwargs)
finally:
# Activated document portals tear down their FUSE mount after D-Bus
# exits. Wait for that teardown instead of hiding a test's result with
# a transient disconnected-mount error, or ignoring cleanup failures.
deadline = time.monotonic() + 5
while True:
try:
runtime.cleanup()
break
except OSError as error:
if error.errno not in (errno.ENOTCONN, errno.EBUSY) or time.monotonic() >= deadline:
raise
time.sleep(0.05)
def main():
if len(sys.argv) < 2:
sys.exit("Usage: native_test_session.py COMMAND [ARG ...]")
result = run_private_session(
["xvfb-run", "-a", "dbus-run-session", "--", *sys.argv[1:]], env=os.environ)
return result.returncode
if __name__ == "__main__":
sys.exit(main())