| Index: test/cctest/test-api.cc
|
| diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
|
| index 447cd261ce9daba049a74c8cb4797641f2a246fb..914c0dc382fa175c684da9d808c44e4458b10c5b 100644
|
| --- a/test/cctest/test-api.cc
|
| +++ b/test/cctest/test-api.cc
|
| @@ -20491,6 +20491,94 @@ TEST(CallCompletedCallbackTwoExceptions) {
|
| }
|
|
|
|
|
| +static void ExternalMicrotaskOne(v8::Isolate* isolate) {
|
| + v8::HandleScope scope(isolate);
|
| + CompileRun("ext1Calls++;");
|
| +}
|
| +
|
| +
|
| +
|
| +static void ExternalMicrotaskTwo(v8::Isolate* isolate) {
|
| + v8::HandleScope scope(isolate);
|
| + CompileRun("ext2Calls++;");
|
| +}
|
| +
|
| +
|
| +TEST(EnqueueExternalMicrotask) {
|
| + LocalContext env;
|
| + v8::HandleScope scope(env->GetIsolate());
|
| + CompileRun(
|
| + "var ext1Calls = 0;"
|
| + "var ext2Calls = 0;");
|
| + CompileRun("1+1;");
|
| + CHECK_EQ(0, CompileRun("ext1Calls")->Int32Value());
|
| + CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value());
|
| +
|
| + v8::V8::EnqueueExternalMicrotask(env->GetIsolate(), ExternalMicrotaskOne);
|
| + CompileRun("1+1;");
|
| + CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value());
|
| + CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value());
|
| +
|
| + v8::V8::EnqueueExternalMicrotask(env->GetIsolate(), ExternalMicrotaskOne);
|
| + v8::V8::EnqueueExternalMicrotask(env->GetIsolate(), ExternalMicrotaskTwo);
|
| + CompileRun("1+1;");
|
| + CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
|
| + CHECK_EQ(1, CompileRun("ext2Calls")->Int32Value());
|
| +
|
| + v8::V8::EnqueueExternalMicrotask(env->GetIsolate(), ExternalMicrotaskTwo);
|
| + CompileRun("1+1;");
|
| + CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
|
| + CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value());
|
| +
|
| + CompileRun("1+1;");
|
| + CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
|
| + CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value());
|
| +}
|
| +
|
| +
|
| +TEST(SetAutorunMicrotasks) {
|
| + LocalContext env;
|
| + v8::HandleScope scope(env->GetIsolate());
|
| + CompileRun(
|
| + "var ext1Calls = 0;"
|
| + "var ext2Calls = 0;");
|
| + CompileRun("1+1;");
|
| + CHECK_EQ(0, CompileRun("ext1Calls")->Int32Value());
|
| + CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value());
|
| +
|
| + v8::V8::EnqueueExternalMicrotask(env->GetIsolate(), ExternalMicrotaskOne);
|
| + CompileRun("1+1;");
|
| + CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value());
|
| + CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value());
|
| +
|
| + V8::SetAutorunMicrotasks(env->GetIsolate(), false);
|
| + v8::V8::EnqueueExternalMicrotask(env->GetIsolate(), ExternalMicrotaskOne);
|
| + v8::V8::EnqueueExternalMicrotask(env->GetIsolate(), ExternalMicrotaskTwo);
|
| + CompileRun("1+1;");
|
| + CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value());
|
| + CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value());
|
| +
|
| + V8::RunMicrotasks(env->GetIsolate());
|
| + CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
|
| + CHECK_EQ(1, CompileRun("ext2Calls")->Int32Value());
|
| +
|
| + v8::V8::EnqueueExternalMicrotask(env->GetIsolate(), ExternalMicrotaskTwo);
|
| + CompileRun("1+1;");
|
| + CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
|
| + CHECK_EQ(1, CompileRun("ext2Calls")->Int32Value());
|
| +
|
| + V8::RunMicrotasks(env->GetIsolate());
|
| + CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
|
| + CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value());
|
| +
|
| + V8::SetAutorunMicrotasks(env->GetIsolate(), true);
|
| + v8::V8::EnqueueExternalMicrotask(env->GetIsolate(), ExternalMicrotaskTwo);
|
| + CompileRun("1+1;");
|
| + CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
|
| + CHECK_EQ(3, CompileRun("ext2Calls")->Int32Value());
|
| +}
|
| +
|
| +
|
| static int probes_counter = 0;
|
| static int misses_counter = 0;
|
| static int updates_counter = 0;
|
|
|