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