diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -9715,7 +9715,16 @@ // This supports sites using cross-screen window management capabilities to // retain fullscreen and place a window on another screen. + + // ForSecurityDropFullscreen calls ExitFullscreen on other WebContents, which + // can spin a nested message loop (e.g. ::SetWindowPos on Windows). During + // this nested loop, this WebContents can be destroyed (e.g. via + // window.close() from a fullscreenchange handler). Guard with a WeakPtr. + base::WeakPtr weak_this = weak_factory_.GetWeakPtr(); ForSecurityDropFullscreen(display_id).RunAndReset(); + if (!weak_this) { + return; + } delegate_->SetContentsBounds(this, bounds); }