fix: crash calling Fetch.continueResponse with WebContentsView (#47442)

fix: crash calling Fetch.continueResponse with WebContentsView

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
trop[bot] 2025-06-11 16:28:41 -05:00 committed by GitHub
commit 55557dd3a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -81,7 +81,11 @@ void Debugger::DispatchProtocolMessage(DevToolsAgentHost* agent_host,
void Debugger::RenderFrameHostChanged(content::RenderFrameHost* old_rfh,
content::RenderFrameHost* new_rfh) {
if (agent_host_) {
// ConnectWebContents uses the primary main frame of the webContents,
// so if the new_rfh is not the primary main frame, we don't want to
// reconnect otherwise we'll end up trying to reconnect to a RenderFrameHost
// that already has a DevToolsAgentHost associated with it.
if (agent_host_ && new_rfh->IsInPrimaryMainFrame()) {
agent_host_->DisconnectWebContents();
auto* web_contents = content::WebContents::FromRenderFrameHost(new_rfh);
agent_host_->ConnectWebContents(web_contents);