Fix crash when creating JS popup with no URL (issue #2330)

This commit is contained in:
Marshall Greenblatt
2017-12-21 14:57:42 -05:00
parent cd33baaff6
commit 49a64fa360
2 changed files with 120 additions and 16 deletions

View File

@@ -2712,10 +2712,10 @@ void CefBrowserHostImpl::DidFinishNavigation(
content::NavigationHandle* navigation_handle) {
const net::Error error_code = navigation_handle->GetNetErrorCode();
// With PlzNavigate the RenderFrameHost will only be nullptr if the
// provisional load fails, in which case |error_code| will be ERR_ABORTED.
DCHECK(navigation_handle->GetRenderFrameHost() ||
error_code == net::ERR_ABORTED);
// Skip calls where the navigation has not yet committed and there is no
// error code. For example, when creating a browser without loading a URL.
if (!navigation_handle->HasCommitted() && error_code == net::OK)
return;
const int64 frame_id =
navigation_handle->GetRenderFrameHost()
@@ -2731,7 +2731,9 @@ void CefBrowserHostImpl::DidFinishNavigation(
base::string16(), url);
if (error_code == net::OK) {
// The navigation has been committed.
// The navigation has been committed and there is no error.
DCHECK(navigation_handle->HasCommitted());
// Don't call OnLoadStart for same page navigations (fragments,
// history state).
if (!navigation_handle->IsSameDocument())
@@ -2740,21 +2742,21 @@ void CefBrowserHostImpl::DidFinishNavigation(
if (is_main_frame)
OnAddressChange(frame, url);
} else {
// The navigation failed before commit. Originates from
// The navigation failed with an error. This may happen before commit
// (e.g. network error) or after commit (e.g. response filter error).
// If the error happened before commit then this call will originate from
// RenderFrameHostImpl::OnDidFailProvisionalLoadWithError.
// OnLoadStart/OnLoadEnd will not be called.
OnLoadError(frame, navigation_handle->GetURL(), error_code);
}
if (!web_contents())
return;
CefBrowserContext* context =
static_cast<CefBrowserContext*>(web_contents()->GetBrowserContext());
if (!context)
return;
context->AddVisitedURLs(navigation_handle->GetRedirectChain());
if (web_contents()) {
CefBrowserContext* context =
static_cast<CefBrowserContext*>(web_contents()->GetBrowserContext());
if (context) {
context->AddVisitedURLs(navigation_handle->GetRedirectChain());
}
}
}
void CefBrowserHostImpl::DocumentAvailableInMainFrame() {