During OnWebKitInitialized(), I set up the following code based on: https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md#markdown-header-functions-and-extensions
- Code: Select all
class JSHandler : public CefV8Handler
{
//snip implementation
};
const char* const DoLinkExtension_Name = "v8/external";
const char* const DoLinkExtension =
"var external;"
"if (!external)"
" external = {};"
"(function() {"
" external.DoLink = function(linkinfo) {"
" native function DoLink();"
" return DoLink(linkinfo);"
" };"
"})();";
CefRefPtr<CefV8Handler> handler = new JSHandler();
CefRegisterExtension(DoLinkExtension_Name, DoLinkExtension, handler);
However, during startup, the render process crashes inside V8 with the following stack trace:
- Code: Select all
libcef.dll!blink::reportFatalErrorInMainThread(const char * location, const char * message) Line 100 C++
libcef.dll!v8::DecodeSmiToAligned(v8::internal::Object * value, const char *) Line 973 C++
libcef.dll!blink::getInternalField<blink::ScriptWrappable,1>(v8::Local<v8::Object> wrapper) Line 224 C++
libcef.dll!blink::DOMWindowV8Internal::externalAttributeGetter(const v8::PropertyCallbackInfo<v8::Value> & info) Line 972 C++
libcef.dll!blink::DOMWindowV8Internal::externalAttributeGetterCallback(v8::Local<v8::Name> __formal, const v8::PropertyCallbackInfo<v8::Value> & info) Line 988 C++
libcef.dll!v8::internal::PropertyCallbackArguments::Call(void (v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value> &) * f, v8::internal::Handle<v8::internal::Name> name) Line 32 C++
libcef.dll!v8::internal::Object::GetPropertyWithAccessor(v8::internal::LookupIterator * it) Line 1353 C++
libcef.dll!v8::internal::Object::GetProperty(v8::internal::LookupIterator * it) Line 998 C++
libcef.dll!v8::internal::LoadIC::Load(v8::internal::Handle<v8::internal::Object> object, v8::internal::Handle<v8::internal::Name> name) Line 636 C++
libcef.dll!v8::internal::LoadGlobalIC::Load(v8::internal::Handle<v8::internal::Name> name) Line 678 C++
libcef.dll!v8::internal::__RT_impl_Runtime_LoadGlobalIC_Miss(v8::internal::Arguments args, v8::internal::Isolate * isolate) Line 2319 C++
libcef.dll!v8::internal::Runtime_LoadGlobalIC_Miss(int args_length, v8::internal::Object * * args_object, v8::internal::Isolate * isolate) Line 2300 C++
location = "v8::Object::GetAlignedPointerFromInternalField()"
message = "Not a Smi";
changing the DoLinkExtension above to use var "myExternal" instead of "external" eliminates the crash.