diff --git a/content/browser/screen_orientation/screen_orientation_browsertest.cc b/content/browser/screen_orientation/screen_orientation_browsertest.cc index 2d14955607369..c48475563d761 100644 --- a/content/browser/screen_orientation/screen_orientation_browsertest.cc +++ b/content/browser/screen_orientation/screen_orientation_browsertest.cc @@ -535,4 +535,102 @@ IN_PROC_BROWSER_TEST_F(ScreenOrientationLockForPrerenderBrowserTest, EXPECT_EQ(0, delegate.unlock_count()); } +// Regression test for a use-after-free in WidgetBase::UpdateSurfaceAndScreenInfo +// when a synchronous `orientationchange` event handler detaches the local-root +// frame whose WidgetBase is currently processing the visual property update. +// +// The legacy `orientationchange` event (RuntimeEnabledFeatures::OrientationEvent) +// is dispatched synchronously from WidgetBase::UpdateSurfaceAndScreenInfo via +// client_->OrientationChanged(). It is enabled by default on Android. This test +// enables it explicitly so the synchronous dispatch path is exercised on all +// platforms. +// +// Frame topology (with site isolation): +// a.com (outer, local root W1 in process P_A) +// +-- b.com (remote in P_A, local root in P_B) +// +-- a.com (inner, local root W2 in process P_A) +// +// When W2 receives an orientation change, it synchronously dispatches the +// `orientationchange` event on the inner a.com window. The handler reaches into +// outer a.com via window.top (same-origin) and removes the b.com