Add notification for aborted popups (fixes #3776)

Pass a new |popup_id| parameter to OnBeforePopup and call a new
OnBeforePopupAborted callback if the popup is aborted before
OnAfterCreated is called for the popup browser. Add new
CefBrowserHost::GetBrowserByIdentifier and GetOpenerIdentifier
methods to assist with retrieval of associated browsers.

In cefclient, clean up state when a popup is aborted and close
any associated popup browsers when the opener browser is closed.
This also works when running with `--use-default-popup`.
This commit is contained in:
Marshall Greenblatt
2024-11-08 19:05:04 -05:00
parent b660522983
commit e513077eac
45 changed files with 773 additions and 109 deletions

View File

@@ -412,6 +412,11 @@ struct FrameStatus {
EXPECT_FALSE(browser->IsValid()) << func;
}
const auto browser_id = browser->GetIdentifier();
EXPECT_GT(browser_id, 0) << func;
auto get_browser = CefBrowserHost::GetBrowserByIdentifier(browser_id);
EXPECT_TRUE(get_browser && get_browser->IsSame(browser)) << func;
// Note that this might not be the same main frame as us when navigating
// cross-origin, because the new main frame object is assigned to the
// browser before the CefFrameHandler callbacks related to main frame change
@@ -1641,6 +1646,7 @@ class ParentOrderMainTestHandler : public OrderMainTestHandler {
bool OnBeforePopup(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
int popup_id,
const CefString& target_url,
const CefString& target_frame_name,
CefLifeSpanHandler::WindowOpenDisposition target_disposition,