diff --git a/third_party/blink/renderer/core/exported/web_view_impl.cc b/third_party/blink/renderer/core/exported/web_view_impl.cc index 066406e37b41c..4d3d24332374b 100644 --- a/third_party/blink/renderer/core/exported/web_view_impl.cc +++ b/third_party/blink/renderer/core/exported/web_view_impl.cc @@ -1061,7 +1061,13 @@ WebPagePopupImpl* WebViewImpl::OpenPagePopup(PagePopupClient* client) { // This guarantees there is never more than 1 PagePopup active at a time. CancelPagePopup(); - DCHECK(!page_popup_); + // CancelPagePopup() can synchronously run author script (e.g. via + // HTMLSelectElement::PopupDidCancel -> change event), which may re-enter + // OpenPagePopup() and set |page_popup_|. The single-popup invariant is + // load-bearing for ClosePagePopup()/CleanupPagePopup() lifetime management, + // so enforce it in release builds to avoid an orphaned WebPagePopupImpl + // being freed while a PagePopupClient still holds a bare PagePopup* to it. + CHECK(!page_popup_); LocalFrame* opener_frame = client->OwnerElement().GetDocument().GetFrame(); WebLocalFrameImpl* web_opener_frame =