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>
194 lines
7.5 KiB
Python
Executable File
194 lines
7.5 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""End-to-end check of the helper's browser bridge.
|
|
|
|
Runs inside live_session.sh's private session and display, with the Electron
|
|
fixture already started in WINEPREFIX. Registers a fake Cthulhu reader on the
|
|
session bus, starts wine-access.exe, and checks that the helper publishes the
|
|
Chromium window, that legacy announcements stop for it, that a killed
|
|
publisher is restarted, and that nothing is left behind when the helper exits.
|
|
|
|
Usage: helper_integration.py BUILD_DIR
|
|
"""
|
|
|
|
import os
|
|
import signal
|
|
import subprocess
|
|
import sys
|
|
import threading
|
|
import time
|
|
from pathlib import Path
|
|
|
|
import gi
|
|
|
|
gi.require_version("Atspi", "2.0")
|
|
from gi.repository import Atspi, Gio, GLib # noqa: E402
|
|
|
|
BUS_NAME = "org.stormux.Cthulhu1.Service"
|
|
OBJECT_PATH = "/" + BUS_NAME.replace(".", "/")
|
|
TITLE = "Wine Access Electron Test"
|
|
|
|
failures = 0
|
|
presented = []
|
|
helperLines = []
|
|
|
|
|
|
def check(name, condition, detail=""):
|
|
global failures
|
|
if condition:
|
|
print(f"PASS: {name}", flush=True)
|
|
else:
|
|
failures += 1
|
|
print(f"FAIL: {name} {detail}", flush=True)
|
|
|
|
|
|
def pump(seconds):
|
|
context = GLib.MainContext.default()
|
|
deadline = time.monotonic() + seconds
|
|
while time.monotonic() < deadline:
|
|
while context.pending():
|
|
context.iteration(False)
|
|
time.sleep(0.01)
|
|
|
|
|
|
def wait_until(predicate, seconds):
|
|
deadline = time.monotonic() + seconds
|
|
while time.monotonic() < deadline:
|
|
if predicate():
|
|
return True
|
|
pump(0.1)
|
|
return predicate()
|
|
|
|
|
|
def register_reader():
|
|
xml = '<node><interface name="' + BUS_NAME + '"><method name="PresentAccessibleEvent">'
|
|
for index, kind in enumerate(["s"] * 7 + ["i", "i", "s"]):
|
|
xml += f'<arg name="arg{index}" type="{kind}" direction="in"/>'
|
|
xml += '<arg type="b" direction="out"/></method>'
|
|
for method, inputs in (("SpeakText", "sb"), ("CancelSpeech", "")):
|
|
xml += '<method name="' + method + '">'
|
|
xml += "".join('<arg type="' + kind + '" direction="in"/>' for kind in inputs)
|
|
xml += '<arg type="b" direction="out"/></method>'
|
|
xml += "</interface></node>"
|
|
|
|
def record(connection, sender, path, interface, method, parameters, invocation):
|
|
if method == "PresentAccessibleEvent":
|
|
presented.append(parameters.unpack())
|
|
invocation.return_value(GLib.Variant("(b)", (True,)))
|
|
|
|
connection = Gio.bus_get_sync(Gio.BusType.SESSION, None)
|
|
connection.register_object(OBJECT_PATH, Gio.DBusNodeInfo.new_for_xml(xml).interfaces[0], record, None, None)
|
|
connection.call_sync("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "RequestName",
|
|
GLib.Variant("(su)", (BUS_NAME, 0)), None, Gio.DBusCallFlags.NONE, 1000, None)
|
|
return connection
|
|
|
|
|
|
def find(accessible, role, name=None, depth=0):
|
|
if accessible is None or depth > 60:
|
|
return None
|
|
try:
|
|
if accessible.get_role_name() == role and (name is None or (accessible.get_name() or "").startswith(name)):
|
|
return accessible
|
|
count = accessible.get_child_count()
|
|
except Exception:
|
|
return None
|
|
for index in range(count):
|
|
try:
|
|
found = find(accessible.get_child_at_index(index), role, name, depth + 1)
|
|
except Exception:
|
|
found = None
|
|
if found is not None:
|
|
return found
|
|
return None
|
|
|
|
|
|
def published_application():
|
|
desktop = Atspi.get_desktop(0)
|
|
for index in range(desktop.get_child_count()):
|
|
application = desktop.get_child_at_index(index)
|
|
if application is not None and application.get_name() == "electron":
|
|
return application
|
|
return None
|
|
|
|
|
|
def process_pids(matches):
|
|
pids = []
|
|
for entry in Path("/proc").iterdir():
|
|
if not entry.name.isdigit():
|
|
continue
|
|
try:
|
|
commandLine = (entry / "cmdline").read_bytes().split(b"\0")
|
|
except OSError:
|
|
continue
|
|
if commandLine and matches(commandLine):
|
|
pids.append(int(entry.name))
|
|
return pids
|
|
|
|
|
|
def publisher_pids():
|
|
return process_pids(lambda arguments: arguments[0].endswith(b"wine-access-browser-publisher"))
|
|
|
|
|
|
def worker_pids():
|
|
return process_pids(lambda arguments: any(argument.lower().endswith(b"wine-access-browser-worker.exe")
|
|
for argument in arguments))
|
|
|
|
|
|
def main():
|
|
build = Path(sys.argv[1]).resolve()
|
|
readerConnection = register_reader() # releasing it would drop the reader's bus name
|
|
helper = subprocess.Popen([str(build / "wine-access.exe"), "--no-controller"], stderr=subprocess.PIPE,
|
|
env=os.environ.copy())
|
|
threading.Thread(target=lambda: [helperLines.append(line.decode(errors="replace").rstrip())
|
|
for line in helper.stderr], daemon=True).start()
|
|
try:
|
|
check("helper reports the browser bridge active",
|
|
wait_until(lambda: any('"browser_bridge":true' in line for line in helperLines), 30),
|
|
str(helperLines[-5:]))
|
|
subprocess.run(["xdotool", "search", "--name", TITLE, "windowactivate", "--sync"], capture_output=True)
|
|
published = wait_until(lambda: any("published; legacy announcements retired" in line
|
|
for line in helperLines), 60)
|
|
check("helper starts a publisher that publishes", published, str(helperLines[-5:]))
|
|
application = None
|
|
if published:
|
|
wait_until(lambda: published_application() is not None, 20)
|
|
application = published_application()
|
|
check("electron application appears on the accessibility bus", application is not None)
|
|
entry = find(application, "entry", "User name") if application else None
|
|
check("the page's text field is published", entry is not None)
|
|
if entry is not None:
|
|
Atspi.Component.grab_focus(entry)
|
|
pump(1.5)
|
|
presented.clear()
|
|
subprocess.run(["xdotool", "search", "--name", TITLE, "windowfocus", "--sync"], capture_output=True)
|
|
subprocess.run(["xdotool", "type", "--delay", "100", "abc"], capture_output=True)
|
|
pump(2.5)
|
|
text = Atspi.Text.get_text(entry, 0, -1)
|
|
check("typing reached the published field", text == "abc", repr(text))
|
|
check("no legacy announcements while typing in the published window", not presented,
|
|
str(presented[:3]))
|
|
|
|
before = publisher_pids()
|
|
check("exactly one publisher is running", len(before) == 1, str(before))
|
|
if before:
|
|
os.kill(before[0], signal.SIGKILL)
|
|
restarted = wait_until(lambda: any(pid not in before for pid in publisher_pids()), 30) and \
|
|
wait_until(lambda: sum("published; legacy announcements retired" in line for line in helperLines) >= 2,
|
|
60)
|
|
check("a killed publisher is restarted and publishes again", restarted, str(helperLines[-5:]))
|
|
finally:
|
|
helper.send_signal(signal.SIGTERM)
|
|
try:
|
|
helper.wait(timeout=15)
|
|
except subprocess.TimeoutExpired:
|
|
helper.kill()
|
|
helper.wait()
|
|
check("no publisher survives the helper", wait_until(lambda: not publisher_pids(), 10), str(publisher_pids()))
|
|
check("no worker survives the helper", wait_until(lambda: not worker_pids(), 10), str(worker_pids()))
|
|
readerConnection.close_sync(None)
|
|
print("\n".join(line for line in helperLines if "browser" in line), flush=True)
|
|
return 1 if failures else 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|