mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 19:25:01 +00:00
JSB - Remove use of CefRegisterExtension and change Promise creator to an anon function
Use CefV8Context::Eval to create the promise using an anonymous function Attempt to resolve #2432 (though it actually seems upgrading to a newer version resolves the underlying problem)
This commit is contained in:
@@ -23,16 +23,23 @@ namespace CefSharp
|
||||
auto context = CefV8Context::GetCurrentContext();
|
||||
auto browser = context->GetBrowser();
|
||||
|
||||
auto promiseCreator = context->GetGlobal()->GetValue(CefAppUnmanagedWrapper::kPromiseCreatorFunction);
|
||||
|
||||
CefRefPtr<CefV8Value> promiseData;
|
||||
CefRefPtr<CefV8Exception> promiseException;
|
||||
//this will create a promise and give us the reject/resolve functions {p: Promise, res: resolve(), rej: reject()}
|
||||
auto promiseData = promiseCreator->ExecuteFunctionWithContext(context, nullptr, CefV8ValueList());
|
||||
|
||||
//when refreshing the browser this is sometimes null, in this case return true and log message
|
||||
//https://github.com/cefsharp/CefSharp/pull/2446
|
||||
if (!context->Eval(CefAppUnmanagedWrapper::kPromiseCreatorScript, CefString(), 0, promiseData, promiseException))
|
||||
{
|
||||
LOG(WARNING) << "JavascriptAsyncMethodHandler::Execute promiseData returned exception: " + promiseException->GetMessage().ToString();
|
||||
|
||||
exception = promiseException->GetMessage();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//when refreshing the browser this is sometimes null, in this case return true and log message
|
||||
//https://github.com/cefsharp/CefSharp/pull/2446
|
||||
if (promiseData == NULL)
|
||||
{
|
||||
LOG(WARNING) << "JavascriptAsyncMethodHandler::Execute promiseData returned NULL";
|
||||
LOG(WARNING) << "JavascriptAsyncMethodHandler::Execute promiseData returned NULL";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user