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

119 lines
5.5 KiB
Python
Executable File

#!/usr/bin/env python3
"""Compare a native Chromium AT-SPI dump with a Wine Access publisher dump.
Usage: compare_dumps.py NATIVE.txt PUBLISHER.txt [--baseline chromium|electron42]
Exits 0 when the dumps match after the documented allowed differences, 1
otherwise, printing a unified diff of what remains.
"""
import argparse
import difflib
import re
import sys
# Differences that are real and expected, applied to the native side so it
# reads as the Wine side would. Each rule documents its reason.
ATTRIBUTE_LINE = re.compile(r'^(\s*attrs: )"(.*)" len=\d+$')
ROLE_LINE = re.compile(r'^(\s*- )(\S.*?)( name=.*)$')
# Lines that identify the run rather than the tree.
ignoredPrefixes = ("application:",)
def attribute_line(indent, attributes):
joined = ";".join(attributes)
return f'{indent}"{joined}" len={len(joined)}'
def normalize(lines, baseline):
result = list(lines)
for index, line in enumerate(result):
match = ATTRIBUTE_LINE.match(line)
if not match:
continue
attributes = match.group(2).split(";")
# Chromium's views frame class is platform-specific.
attributes = ["class:WinFrameView" if item == "class:NativeFrameView" else item for item in attributes]
# Electron 42's Chromium exposes an unnamed <form> as a section with no
# xml-roles; Chromium 156 (Electron 45 under Wine) and 158 expose a
# form. Only the node whose own attributes say tag:form is changed.
if baseline == "electron42" and "tag:form" in attributes and "xml-roles:form" not in attributes:
roleIndex = next((candidate for candidate in range(index - 1, max(index - 4, -1), -1)
if ROLE_LINE.match(result[candidate])), None)
roleMatch = ROLE_LINE.match(result[roleIndex]) if roleIndex is not None else None
if roleMatch and roleMatch.group(2) == "section":
result[roleIndex] = f"{roleMatch.group(1)}form{roleMatch.group(3)}"
attributes = sorted(attributes + ["xml-roles:form"])
result[index] = attribute_line(match.group(1), attributes)
return [line for line in result if not line.startswith(ignoredPrefixes)]
BOUNDARY_LINE = re.compile(r"^(\s*(?:words|sentences|lines|paragraphs): )(.*)$")
TEXT_LINE = re.compile(r'^\s*text: n=\d+ "(.*)" len=(\d+) caret=-?\d+$')
def allow_rounded_emoji_words(nativeLines, publisherLines):
"""Native Chromium reports a word ending inside a surrogate pair (next to
an emoji) as "start--1"; the publisher rounds the end up to the next whole
character. Accept exactly that: the publisher's segment must start where
native's does and end immediately after a supplementary-plane character
of the object's own text."""
if len(nativeLines) != len(publisherLines):
return
text = None
for index, (nativeLine, publisherLine) in enumerate(zip(nativeLines, publisherLines)):
textMatch = TEXT_LINE.match(publisherLine)
if textMatch:
# Undo the dump's display substitutions, then only trust untruncated
# text (the dump truncates after 100 characters).
content = textMatch.group(1).replace("[obj]", "\ufffc").replace("\\n", "\n")
text = content if len(content) == int(textMatch.group(2)) else None
continue
nativeMatch = BOUNDARY_LINE.match(nativeLine)
publisherMatch = BOUNDARY_LINE.match(publisherLine)
if not nativeMatch or not publisherMatch or nativeMatch.group(1) != publisherMatch.group(1) or text is None:
continue
nativeTokens = nativeMatch.group(2).split()
publisherTokens = publisherMatch.group(2).split()
if len(nativeTokens) != len(publisherTokens):
continue
for position, (nativeToken, publisherToken) in enumerate(zip(nativeTokens, publisherTokens)):
start = re.fullmatch(r"(\d+)--1", nativeToken)
rounded = re.fullmatch(r"(\d+)-(\d+)", publisherToken)
if not start or not rounded or start.group(1) != rounded.group(1):
continue
end = int(rounded.group(2))
if int(rounded.group(1)) < end <= len(text) and ord(text[end - 1]) > 0xFFFF:
nativeTokens[position] = publisherToken
nativeLines[index] = nativeMatch.group(1) + " ".join(nativeTokens)
def main():
parser = argparse.ArgumentParser()
parser.add_argument("native")
parser.add_argument("publisher")
parser.add_argument("--baseline", choices=["chromium", "electron42"], default="chromium")
options = parser.parse_args()
with open(options.native, encoding="utf-8") as nativeFile:
nativeLines = normalize(nativeFile.read().splitlines(), options.baseline)
with open(options.publisher, encoding="utf-8") as publisherFile:
publisherLines = normalize(publisherFile.read().splitlines(), "none")
if not nativeLines or not publisherLines or not nativeLines[-1].startswith("nodes="):
print("A dump is empty or incomplete")
return 1
allow_rounded_emoji_words(nativeLines, publisherLines)
difference = list(difflib.unified_diff(nativeLines, publisherLines, "native", "publisher", lineterm=""))
if difference:
print("\n".join(difference))
print(f"MISMATCH: {sum(1 for line in difference if line.startswith('-') and not line.startswith('---'))} "
f"native lines differ")
return 1
print(f"MATCH ({options.baseline} baseline, {nativeLines[-1]}, allowed differences applied)")
return 0
if __name__ == "__main__":
sys.exit(main())