Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Side by Side Diff: test/cctest/test-api.cc

Issue 1920813002: [api] Introduce MicrotasksScope::IsRunningMicrotasks (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/isolate.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 20867 matching lines...) Expand 10 before | Expand all | Expand 10 after
20878 20878
20879 TEST(CallCompletedCallbackTwoExceptions) { 20879 TEST(CallCompletedCallbackTwoExceptions) {
20880 LocalContext env; 20880 LocalContext env;
20881 v8::HandleScope scope(env->GetIsolate()); 20881 v8::HandleScope scope(env->GetIsolate());
20882 env->GetIsolate()->AddCallCompletedCallback(CallCompletedCallbackException); 20882 env->GetIsolate()->AddCallCompletedCallback(CallCompletedCallbackException);
20883 CompileRun("throw 'first exception';"); 20883 CompileRun("throw 'first exception';");
20884 } 20884 }
20885 20885
20886 20886
20887 static void MicrotaskOne(const v8::FunctionCallbackInfo<Value>& info) { 20887 static void MicrotaskOne(const v8::FunctionCallbackInfo<Value>& info) {
20888 CHECK(v8::MicrotasksScope::IsRunningMicrotasks(info.GetIsolate()));
20888 v8::HandleScope scope(info.GetIsolate()); 20889 v8::HandleScope scope(info.GetIsolate());
20889 v8::MicrotasksScope microtasks(info.GetIsolate(), 20890 v8::MicrotasksScope microtasks(info.GetIsolate(),
20890 v8::MicrotasksScope::kDoNotRunMicrotasks); 20891 v8::MicrotasksScope::kDoNotRunMicrotasks);
20891 CompileRun("ext1Calls++;"); 20892 CompileRun("ext1Calls++;");
20892 } 20893 }
20893 20894
20894 20895
20895 static void MicrotaskTwo(const v8::FunctionCallbackInfo<Value>& info) { 20896 static void MicrotaskTwo(const v8::FunctionCallbackInfo<Value>& info) {
20897 CHECK(v8::MicrotasksScope::IsRunningMicrotasks(info.GetIsolate()));
20896 v8::HandleScope scope(info.GetIsolate()); 20898 v8::HandleScope scope(info.GetIsolate());
20897 v8::MicrotasksScope microtasks(info.GetIsolate(), 20899 v8::MicrotasksScope microtasks(info.GetIsolate(),
20898 v8::MicrotasksScope::kDoNotRunMicrotasks); 20900 v8::MicrotasksScope::kDoNotRunMicrotasks);
20899 CompileRun("ext2Calls++;"); 20901 CompileRun("ext2Calls++;");
20900 } 20902 }
20901 20903
20902 20904
20903 void* g_passed_to_three = NULL; 20905 void* g_passed_to_three = NULL;
20904 20906
20905 20907
20906 static void MicrotaskThree(void* data) { 20908 static void MicrotaskThree(void* data) {
20907 g_passed_to_three = data; 20909 g_passed_to_three = data;
20908 } 20910 }
20909 20911
20910 20912
20911 TEST(EnqueueMicrotask) { 20913 TEST(EnqueueMicrotask) {
20912 LocalContext env; 20914 LocalContext env;
20913 v8::HandleScope scope(env->GetIsolate()); 20915 v8::HandleScope scope(env->GetIsolate());
20916 CHECK(!v8::MicrotasksScope::IsRunningMicrotasks(env->GetIsolate()));
20914 CompileRun( 20917 CompileRun(
20915 "var ext1Calls = 0;" 20918 "var ext1Calls = 0;"
20916 "var ext2Calls = 0;"); 20919 "var ext2Calls = 0;");
20917 CompileRun("1+1;"); 20920 CompileRun("1+1;");
20918 CHECK_EQ(0, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust()); 20921 CHECK_EQ(0, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
20919 CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust()); 20922 CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());
20920 20923
20921 env->GetIsolate()->EnqueueMicrotask( 20924 env->GetIsolate()->EnqueueMicrotask(
20922 Function::New(env.local(), MicrotaskOne).ToLocalChecked()); 20925 Function::New(env.local(), MicrotaskOne).ToLocalChecked());
20923 CompileRun("1+1;"); 20926 CompileRun("1+1;");
(...skipping 4043 matching lines...) Expand 10 before | Expand all | Expand 10 after
24967 } 24970 }
24968 24971
24969 TEST(PrivateForApiIsNumber) { 24972 TEST(PrivateForApiIsNumber) {
24970 LocalContext context; 24973 LocalContext context;
24971 v8::Isolate* isolate = CcTest::isolate(); 24974 v8::Isolate* isolate = CcTest::isolate();
24972 v8::HandleScope scope(isolate); 24975 v8::HandleScope scope(isolate);
24973 24976
24974 // Shouldn't crash. 24977 // Shouldn't crash.
24975 v8::Private::ForApi(isolate, v8_str("42")); 24978 v8::Private::ForApi(isolate, v8_str("42"));
24976 } 24979 }
OLDNEW
« no previous file with comments | « src/isolate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698