Files
Storm DragonandClaude Opus 5.5 9c1fc644ba Add browser accessibility for Chromium windows
Chromium-based Windows applications under Wine (Electron, CEF) exposed only
what the legacy MSAA path could announce, one event at a time. The helper now
starts a publisher for each Chromium window: a PE worker reads the page
through MSAA and IAccessible2 inside the prefix, and a native ATK publisher
presents it on the accessibility bus as toolkit Chromium, matching native
Linux Chromium, so the reader's own browser support handles browse mode,
structural navigation, forms, tables and live regions. Once a window is
published, legacy announcements for it stop, so nothing is spoken twice; if
the publisher fails, the window returns to the legacy path and the helper
retries with backoff. Publishers follow the helper's lifetime.

The publisher marks itself with WINE_ACCESS_BROWSER_PUBLISHER=1 and gives each
frame a wine-access-x11-window attribute so readers can verify window
ownership. Password text, values and boundaries never leave the worker.
Design, mapping rules and verification are in docs/browser.md; the
IAccessible2 IDL is vendored in third_party/ia2.

Checked: xvfb-run ctest (all 10, including the new
browser-publisher-snapshot comparison with native Chromium 158 and Electron
42), menu_integration.py with the menu and edit fixtures, the Orca extension
unit tests, and tests/browser/live_checks.sh against Electron 45: worker
protocol, helper lifecycle (publish, no legacy announcements while typing,
restart, no orphans), and live tree, text boundaries and AT-SPI event
sequence matching native Chromium. A live test with Cthulhu on Electron 45
read the fixture page correctly.

Remaining live checks: Orca with the extension, Firefox, WebView2, 32-bit
browsers, iframes, and window switching under other window managers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-02 23:15:21 -05:00

107 lines
4.6 KiB
Bash
Executable File

#!/bin/bash
# Live browser bridge checks against the Electron fixture app, on a private
# display and accessibility bus, never touching the user's session.
# Usage: live_session.sh MODE BUILD_DIR OUTPUT_DIR [PREFIX]
# MODE worker ia2 worker protocol checks (worker_driver.py)
# helper the helper starts, supervises and retires publishers
# (helper_integration.py)
# wine publisher + worker under Wine: tree dump and event scenario
# native native Linux Chromium reference: tree dump and event scenario
# PREFIX Wine prefix with Electron installed (worker and wine modes)
# Environment:
# WINE_ACCESS_BROWSER_TEST_ELECTRON Windows path of electron.exe in PREFIX
# (default C:\electron\v45\electron.exe)
# WINE_ACCESS_BROWSER_TEST_CHROMIUM native Chromium command (default chromium)
# WINE_ACCESS_BROWSER_TRACE=1 log every worker message (wine mode)
# Writes OUTPUT_DIR/<mode>.tree.txt, <mode>.events.txt, <mode>.txt and logs.
set -u
if [[ $# -lt 3 ]]; then
echo "Usage: $0 worker|wine|native BUILD_DIR OUTPUT_DIR [PREFIX]"
exit 2
fi
sessionMode="$1"
buildDir="$(realpath "$2")"
outputDir="$(realpath -m "$3")"
winePrefix="${4:-}"
testDir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
electron="${WINE_ACCESS_BROWSER_TEST_ELECTRON:-C:\\electron\\v45\\electron.exe}"
chromiumCommand="${WINE_ACCESS_BROWSER_TEST_CHROMIUM:-chromium}"
case "$sessionMode" in
worker | wine | helper)
if [[ -z "$winePrefix" || ! -d "$winePrefix/drive_c" ]]; then
echo "$sessionMode mode needs a Wine prefix with Electron installed"
exit 2
fi
;;
native) ;;
*)
echo "Unknown mode: $sessionMode"
exit 2
;;
esac
mkdir -p "$outputDir"
workDir="$(mktemp -d)"
# Chromium's helper processes can still be writing the profile at exit.
trap 'rm -rf "$workDir" 2> /dev/null || { sleep 2; rm -rf "$workDir"; }' EXIT
# The fixture app lives in the prefix so Electron can load it by Windows path.
appWindowsPath='C:\wine-access-browser-test'
if [[ -n "$winePrefix" ]]; then
mkdir -p "$winePrefix/drive_c/wine-access-browser-test"
cp "$testDir/fixture-app/"* "$winePrefix/drive_c/wine-access-browser-test/"
export WINEPREFIX="$winePrefix"
fi
export WINEDEBUG=-all
# Keep test Wine processes away from a live reader's Wine manager (Cthulhu and
# the Orca extension each skip processes carrying their own marker).
export CTHULHU_WINE_ACCESS_MANAGED=1 ORCA_WINE_ACCESS_MANAGED=1
export sessionMode buildDir outputDir testDir electron chromiumCommand appWindowsPath workDir
# shellcheck disable=SC2016 # expanded by the inner shell
timeout 300 "$testDir/private_session.sh" xvfb-run -a bash -c '
title="Wine Access Electron Test"
worker="$buildDir/wine-access-browser-worker.exe"
if [[ "$sessionMode" == native ]]; then
"$chromiumCommand" --user-data-dir="$workDir/profile" --no-first-run --no-default-browser-check \
--force-renderer-accessibility "file://$testDir/fixture-app/fixture.html" > "$workDir/browser.log" 2>&1 &
browserPid=$!
appName=chromium
else
wine "$electron" "$appWindowsPath" > "$workDir/browser.log" 2>&1 &
browserPid=$!
appName=electron
fi
if [[ "$sessionMode" == helper ]]; then
python3 -I "$testDir/helper_integration.py" "$buildDir" > "$outputDir/helper.txt" 2>&1
status=$?
elif [[ "$sessionMode" == worker ]]; then
cd "$workDir" || exit 1
python3 -I "$testDir/worker_driver.py" wine "$worker" --title "$title" > "$outputDir/worker.txt" 2>&1
status=$?
cp "$workDir/worker.stderr.log" "$outputDir/worker.stderr.log" 2> /dev/null
else
if [[ "$sessionMode" == wine ]]; then
WINE_ACCESS_BROWSER_TRACE="${WINE_ACCESS_BROWSER_TRACE:-}" \
"$buildDir/wine-access-browser-publisher" --worker wine "$worker" --title "$title" \
> "$outputDir/wine.publisher.log" 2>&1 &
publisherPid=$!
fi
python3 -I "$testDir/atspi_dump.py" --app-name "$appName" --boundaries --wait 60 \
> "$outputDir/$sessionMode.tree.txt" 2>&1
python3 -I "$testDir/live_driver.py" --app-name "$appName" --title "$title" \
--log "$outputDir/$sessionMode.events.txt" > "$outputDir/$sessionMode.txt" 2>&1
status=$?
[[ -n "${publisherPid:-}" ]] && kill "$publisherPid" 2> /dev/null
fi
kill "$browserPid" 2> /dev/null
wait "$browserPid" 2> /dev/null
[[ "$sessionMode" != native ]] && wineserver -k 2> /dev/null
exit "$status"
' > /dev/null 2>&1
sessionStatus=$?
[[ "$sessionMode" != native ]] && wineserver -k 2> /dev/null
echo "Live session $sessionMode exit status $sessionStatus; results in $outputDir"
exit "$sessionStatus"