#include #include #include namespace { using v8::Context; using v8::Function; using v8::FunctionTemplate; using v8::Isolate; using v8::Local; using v8::MaybeLocal; using v8::NewStringType; using v8::Object; using v8::Script; using v8::String; using v8::Value; inline void MakeBufferInNewContext( const v8::FunctionCallbackInfo& args) { Isolate* isolate = args.GetIsolate(); Local context = Context::New(isolate); Context::Scope context_scope(context); // This should throw an exception, rather than actually do anything. MaybeLocal buf = node::Buffer::Copy(isolate, "foo", 3); assert(buf.IsEmpty()); } inline void RunInNewContext( const v8::FunctionCallbackInfo& args) { Isolate* isolate = args.GetIsolate(); Local context = Context::New(isolate); Context::Scope context_scope(context); context->Global()->Set( context, String::NewFromUtf8(isolate, "data", NewStringType::kNormal) .ToLocalChecked(), args[1]).FromJust(); assert(args[0]->IsString()); // source code Local