From a4eb213a042877e7586d71ce74454de1726cb219 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Mon, 19 Jan 2026 15:02:51 +0100 Subject: [PATCH] fix: restore AXDocument accessibility attribute for representedFilename on macOS (#49418) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Starting from Chromium 134.0.6989.0 (Electron 35.0.0-beta.5), the NativeWidgetMacNSWindow class overrides accessibilityDocument to return the web content URL from the accessibility tree, but doesn't fall back to NSWindow's default behavior when that URL is empty. This broke Electron's setRepresentedFilename() API - the file path was still set on the NSWindow, but no longer exposed via the AXDocument accessibility attribute that screen readers use. This fix adds an accessibilityDocument override in ElectronNSWindow that checks representedFilename first, falling back to Chromium's behavior for web content URLs. Fixes: https://github.com/electron/electron/issues/XXXXX Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Daniel Gräfe --- shell/browser/ui/cocoa/electron_ns_window.mm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/shell/browser/ui/cocoa/electron_ns_window.mm b/shell/browser/ui/cocoa/electron_ns_window.mm index 7156fa9864..9e83e6b02d 100644 --- a/shell/browser/ui/cocoa/electron_ns_window.mm +++ b/shell/browser/ui/cocoa/electron_ns_window.mm @@ -285,6 +285,19 @@ void SwizzleSwipeWithEvent(NSView* view, SEL swiz_selector) { return base::SysUTF8ToNSString(shell_ ? shell_->GetTitle() : ""); } +- (NSString*)accessibilityDocument { + // Prefer representedFilename set via Electron's setRepresentedFilename API. + // This works around a Chromium change (https://crrev.com/c/6187085) where + // NativeWidgetMacNSWindow's accessibilityDocument override doesn't fall back + // to NSWindow's default behavior of returning the representedFilename. + NSString* representedFilename = [self representedFilename]; + if (representedFilename.length > 0) { + return [[NSURL fileURLWithPath:representedFilename] absoluteString]; + } + // Fall back to Chromium's implementation for web content URLs. + return [super accessibilityDocument]; +} + - (BOOL)canBecomeMainWindow { return !self.disableKeyOrMainWindow; }