diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index c63728f12f6488e79d864af81c0637ef58d2dd40..28198a0dc3d8a9d39416120976f62b29959f96b0 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -4198,6 +4198,16 @@ void WebContentsImpl::ShowCreatedWindow(RenderFrameHostImpl* opener, if (!owned_created || !owned_created->contents) return; + if (active_file_chooser_) { + // Do not allow opening a new window or tab while a file select is active + // file chooser to avoid user confusion over which tab triggered the file + // chooser. + opener->AddMessageToConsole( + blink::mojom::ConsoleMessageLevel::kWarning, + "window.open blocked due to active file chooser."); + return; + } + WebContentsImpl* created = owned_created->contents.get(); // This uses the delegate for the WebContents where the window was created