diff --git a/shell/platform/windows/flutter_window.cc b/shell/platform/windows/flutter_window.cc index e5fbc89403644..6dba8cadc368b 100644 --- a/shell/platform/windows/flutter_window.cc +++ b/shell/platform/windows/flutter_window.cc @@ -279,6 +279,10 @@ bool FlutterWindow::OnBitmapSurfaceUpdated(const void* allocation, } gfx::NativeViewAccessible FlutterWindow::GetNativeViewAccessible() { + if (binding_handler_delegate_ == nullptr) { + return nullptr; + } + return binding_handler_delegate_->GetNativeViewAccessible(); } diff --git a/shell/platform/windows/flutter_window_unittests.cc b/shell/platform/windows/flutter_window_unittests.cc index a4dd8bc611b7c..e8ec2820666b1 100644 --- a/shell/platform/windows/flutter_window_unittests.cc +++ b/shell/platform/windows/flutter_window_unittests.cc @@ -272,6 +272,15 @@ TEST(FlutterWindowTest, OnThemeChange) { win32window.InjectWindowMessage(WM_THEMECHANGED, 0, 0); } +// The window should return no root accessibility node if +// it isn't attached to a view. +// Regression test for https://github.com/flutter/flutter/issues/129791 +TEST(FlutterWindowTest, AccessibilityNodeWithoutView) { + MockFlutterWindow win32window; + + EXPECT_EQ(win32window.GetNativeViewAccessible(), nullptr); +} + TEST(FlutterWindowTest, InitialAccessibilityFeatures) { MockFlutterWindow win32window; MockWindowBindingHandlerDelegate delegate;