Fix ExecuteJavaScript failure with null CefRenderProcessHandler (see issue #2421)

When CefApp::GetRenderProcessHandler returned null
CefRenderFrameObserver::DidCreateScriptContext was returning early (not
calling CefFrameImpl::OnContextCreated) and consequently queued actions
such as JavaScript were never executed.
This commit is contained in:
Marshall Greenblatt 2021-08-18 17:55:03 -04:00
parent b4ab321a79
commit cfdec92624
1 changed files with 9 additions and 9 deletions

View File

@ -126,11 +126,10 @@ void CefRenderFrameObserver::DidCreateScriptContext(
CefRefPtr<CefApp> application = CefAppManager::Get()->GetApplication();
if (application)
handler = application->GetRenderProcessHandler();
if (!handler)
return;
CefRefPtr<CefFrameImpl> framePtr = browserPtr->GetWebFrameImpl(frame);
if (handler) {
v8::Isolate* isolate = blink::MainThreadIsolate();
v8::HandleScope handle_scope(isolate);
v8::Context::Scope scope(context);
@ -140,6 +139,7 @@ void CefRenderFrameObserver::DidCreateScriptContext(
CefRefPtr<CefV8Context> contextPtr(new CefV8ContextImpl(isolate, context));
handler->OnContextCreated(browserPtr.get(), framePtr.get(), contextPtr);
}
// Do this last, in case the client callback modified the window object.
framePtr->OnContextCreated();