node/test/addons/make-callback-recurse/binding.cc
Trevor Norris ab6fe5998a test: add addons test for MakeCallback
Make sure that calling MakeCallback multiple times within the same stack
does not allow the nextTickQueue or MicrotaskQueue to be processed in
any more than the first MakeCallback call.

Check that domains enter/exit poperly with multiple MakeCallback calls
and that errors are handled as expected

PR-URL: https://github.com/nodejs/node/pull/4507
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2016-02-12 14:03:34 -07:00

32 lines
684 B
C++

#include "node.h"
#include "v8.h"
#include "../../../src/util.h"
using v8::Function;
using v8::FunctionCallbackInfo;
using v8::Isolate;
using v8::Local;
using v8::Object;
using v8::Value;
namespace {
void MakeCallback(const FunctionCallbackInfo<Value>& args) {
CHECK(args[0]->IsObject());
CHECK(args[1]->IsFunction());
Isolate* isolate = args.GetIsolate();
Local<Object> recv = args[0].As<Object>();
Local<Function> method = args[1].As<Function>();
node::MakeCallback(isolate, recv, method, 0, nullptr);
}
void Initialize(Local<Object> target) {
NODE_SET_METHOD(target, "makeCallback", MakeCallback);
}
} // namespace anonymous
NODE_MODULE(binding, Initialize)