Index: test/cctest/test-api.cc |
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc |
index 484ce9f7201d4c5909a705280e70ebd9d7af1784..f4e8fe8e4bd36b6f4f934c962ce4f28a4100ffca 100644 |
--- a/test/cctest/test-api.cc |
+++ b/test/cctest/test-api.cc |
@@ -20790,20 +20790,34 @@ THREADED_TEST(ForeignFunctionReceiver) { |
uint8_t callback_fired = 0; |
+uint8_t before_call_entered_callback_count1 = 0; |
+uint8_t before_call_entered_callback_count2 = 0; |
-void CallCompletedCallback1() { |
+void CallCompletedCallback1(v8::Isolate*) { |
v8::base::OS::Print("Firing callback 1.\n"); |
callback_fired ^= 1; // Toggle first bit. |
} |
-void CallCompletedCallback2() { |
+void CallCompletedCallback2(v8::Isolate*) { |
v8::base::OS::Print("Firing callback 2.\n"); |
callback_fired ^= 2; // Toggle second bit. |
} |
+void BeforeCallEnteredCallback1(v8::Isolate*) { |
+ v8::base::OS::Print("Firing before call entered callback 1.\n"); |
+ before_call_entered_callback_count1++; |
+} |
+ |
+ |
+void BeforeCallEnteredCallback2(v8::Isolate*) { |
+ v8::base::OS::Print("Firing before call entered callback 2.\n"); |
+ before_call_entered_callback_count2++; |
+} |
+ |
+ |
void RecursiveCall(const v8::FunctionCallbackInfo<v8::Value>& args) { |
int32_t level = |
args[0]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromJust(); |
@@ -20836,36 +20850,54 @@ TEST(CallCompletedCallback) { |
env->GetIsolate()->AddCallCompletedCallback(CallCompletedCallback1); |
env->GetIsolate()->AddCallCompletedCallback(CallCompletedCallback1); |
env->GetIsolate()->AddCallCompletedCallback(CallCompletedCallback2); |
+ env->GetIsolate()->AddBeforeCallEnteredCallback(BeforeCallEnteredCallback1); |
+ env->GetIsolate()->AddBeforeCallEnteredCallback(BeforeCallEnteredCallback2); |
+ env->GetIsolate()->AddBeforeCallEnteredCallback(BeforeCallEnteredCallback1); |
v8::base::OS::Print("--- Script (1) ---\n"); |
+ callback_fired = 0; |
+ before_call_entered_callback_count1 = 0; |
+ before_call_entered_callback_count2 = 0; |
Local<Script> script = |
v8::Script::Compile(env.local(), v8_str("recursion(0)")).ToLocalChecked(); |
script->Run(env.local()).ToLocalChecked(); |
CHECK_EQ(3, callback_fired); |
+ CHECK_EQ(4, before_call_entered_callback_count1); |
+ CHECK_EQ(4, before_call_entered_callback_count2); |
v8::base::OS::Print("\n--- Script (2) ---\n"); |
callback_fired = 0; |
+ before_call_entered_callback_count1 = 0; |
+ before_call_entered_callback_count2 = 0; |
env->GetIsolate()->RemoveCallCompletedCallback(CallCompletedCallback1); |
+ env->GetIsolate()->RemoveBeforeCallEnteredCallback( |
+ BeforeCallEnteredCallback1); |
script->Run(env.local()).ToLocalChecked(); |
CHECK_EQ(2, callback_fired); |
+ CHECK_EQ(0, before_call_entered_callback_count1); |
+ CHECK_EQ(4, before_call_entered_callback_count2); |
v8::base::OS::Print("\n--- Function ---\n"); |
callback_fired = 0; |
+ before_call_entered_callback_count1 = 0; |
+ before_call_entered_callback_count2 = 0; |
Local<Function> recursive_function = Local<Function>::Cast( |
env->Global()->Get(env.local(), v8_str("recursion")).ToLocalChecked()); |
v8::Local<Value> args[] = {v8_num(0)}; |
recursive_function->Call(env.local(), env->Global(), 1, args) |
.ToLocalChecked(); |
CHECK_EQ(2, callback_fired); |
+ CHECK_EQ(0, before_call_entered_callback_count1); |
+ CHECK_EQ(4, before_call_entered_callback_count2); |
} |
-void CallCompletedCallbackNoException() { |
+void CallCompletedCallbackNoException(v8::Isolate*) { |
v8::HandleScope scope(CcTest::isolate()); |
CompileRun("1+1;"); |
} |
-void CallCompletedCallbackException() { |
+void CallCompletedCallbackException(v8::Isolate*) { |
v8::HandleScope scope(CcTest::isolate()); |
CompileRun("throw 'second exception';"); |
} |