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

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

Issue 12494012: new style of property/function callbacks (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: account for apiparameteroperand changes Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « src/x64/stub-cache-x64.cc ('k') | tools/gyp/v8.gyp » ('j') | 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 789 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 v8::HandleScope scope(env->GetIsolate()); 800 v8::HandleScope scope(env->GetIsolate());
801 v8::Handle<v8::Object> global = env->Global(); 801 v8::Handle<v8::Object> global = env->Global();
802 global->Set(v8_str("pi"), v8_num(3.1415926)); 802 global->Set(v8_str("pi"), v8_num(3.1415926));
803 Local<Value> pi = global->Get(v8_str("pi")); 803 Local<Value> pi = global->Get(v8_str("pi"));
804 CHECK_EQ(3.1415926, pi->NumberValue()); 804 CHECK_EQ(3.1415926, pi->NumberValue());
805 } 805 }
806 806
807 807
808 static v8::Handle<Value> handle_call(const v8::Arguments& args) { 808 static v8::Handle<Value> handle_call(const v8::Arguments& args) {
809 ApiTestFuzzer::Fuzz(); 809 ApiTestFuzzer::Fuzz();
810 args.GetReturnValue().Set(v8_str("bad value"));
810 return v8_num(102); 811 return v8_num(102);
811 } 812 }
812 813
814 static v8::Handle<Value> handle_call_indirect(const v8::Arguments& args) {
815 ApiTestFuzzer::Fuzz();
816 args.GetReturnValue().Set(v8_str("bad value"));
817 args.GetReturnValue().Set(v8_num(102));
818 return v8::Handle<Value>();
819 }
820
821 static void handle_callback(const v8::FunctionCallbackInfo<Value>& info) {
822 ApiTestFuzzer::Fuzz();
823 info.GetReturnValue().Set(v8_str("bad value"));
824 info.GetReturnValue().Set(v8_num(102));
825 }
826
813 827
814 static v8::Handle<Value> construct_call(const v8::Arguments& args) { 828 static v8::Handle<Value> construct_call(const v8::Arguments& args) {
815 ApiTestFuzzer::Fuzz(); 829 ApiTestFuzzer::Fuzz();
816 args.This()->Set(v8_str("x"), v8_num(1)); 830 args.This()->Set(v8_str("x"), v8_num(1));
817 args.This()->Set(v8_str("y"), v8_num(2)); 831 args.This()->Set(v8_str("y"), v8_num(2));
832 args.GetReturnValue().Set(v8_str("bad value"));
818 return args.This(); 833 return args.This();
819 } 834 }
820 835
821 static v8::Handle<Value> Return239(Local<String> name, const AccessorInfo&) { 836 static v8::Handle<Value> construct_call_indirect(const v8::Arguments& args) {
822 ApiTestFuzzer::Fuzz(); 837 ApiTestFuzzer::Fuzz();
838 args.This()->Set(v8_str("x"), v8_num(1));
839 args.This()->Set(v8_str("y"), v8_num(2));
840 args.GetReturnValue().Set(v8_str("bad value"));
841 args.GetReturnValue().Set(args.This());
842 return v8::Handle<Value>();
843 }
844
845 static void construct_callback(
846 const v8::FunctionCallbackInfo<Value>& info) {
847 ApiTestFuzzer::Fuzz();
848 info.This()->Set(v8_str("x"), v8_num(1));
849 info.This()->Set(v8_str("y"), v8_num(2));
850 info.GetReturnValue().Set(v8_str("bad value"));
851 info.GetReturnValue().Set(info.This());
852 }
853
854
855 static v8::Handle<Value> Return239(
856 Local<String> name, const AccessorInfo& info) {
857 ApiTestFuzzer::Fuzz();
858 info.GetReturnValue().Set(v8_str("bad value"));
823 return v8_num(239); 859 return v8_num(239);
824 } 860 }
825 861
862 static v8::Handle<Value> Return239Indirect(
863 Local<String> name, const AccessorInfo& info) {
864 ApiTestFuzzer::Fuzz();
865 Handle<Value> value = v8_num(239);
866 info.GetReturnValue().Set(v8_str("bad value"));
867 info.GetReturnValue().Set(value);
868 return v8::Handle<Value>();
869 }
826 870
827 THREADED_TEST(FunctionTemplate) { 871 static void Return239Callback(
828 LocalContext env; 872 Local<String> name, const v8::PropertyCallbackInfo<Value>& info) {
829 v8::HandleScope scope(env->GetIsolate()); 873 ApiTestFuzzer::Fuzz();
874 info.GetReturnValue().Set(v8_str("bad value"));
875 info.GetReturnValue().Set(v8_num(239));
876 }
877
878
879 template<typename Handler>
880 static void TestFunctionTemplateInitializer(LocalContext* env,
881 Handler handler) {
882 // Test constructor calls.
830 { 883 {
831 Local<v8::FunctionTemplate> fun_templ = 884 Local<v8::FunctionTemplate> fun_templ =
832 v8::FunctionTemplate::New(handle_call); 885 v8::FunctionTemplate::New(handler);
833 Local<Function> fun = fun_templ->GetFunction(); 886 Local<Function> fun = fun_templ->GetFunction();
834 env->Global()->Set(v8_str("obj"), fun); 887 (*env)->Global()->Set(v8_str("obj"), fun);
835 Local<Script> script = v8_compile("obj()"); 888 Local<Script> script = v8_compile("obj()");
836 CHECK_EQ(102, script->Run()->Int32Value()); 889 CHECK_EQ(102, script->Run()->Int32Value());
837 } 890 }
838 // Use SetCallHandler to initialize a function template, should work like the 891 // Use SetCallHandler to initialize a function template, should work like the
839 // previous one. 892 // previous one.
840 { 893 {
841 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 894 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
842 fun_templ->SetCallHandler(handle_call); 895 fun_templ->SetCallHandler(handler);
843 Local<Function> fun = fun_templ->GetFunction(); 896 Local<Function> fun = fun_templ->GetFunction();
844 env->Global()->Set(v8_str("obj"), fun); 897 (*env)->Global()->Set(v8_str("obj"), fun);
845 Local<Script> script = v8_compile("obj()"); 898 Local<Script> script = v8_compile("obj()");
846 CHECK_EQ(102, script->Run()->Int32Value()); 899 CHECK_EQ(102, script->Run()->Int32Value());
847 } 900 }
848 // Test constructor calls.
849 {
850 Local<v8::FunctionTemplate> fun_templ =
851 v8::FunctionTemplate::New(construct_call);
852 fun_templ->SetClassName(v8_str("funky"));
853 fun_templ->InstanceTemplate()->SetAccessor(v8_str("m"), Return239);
854 Local<Function> fun = fun_templ->GetFunction();
855 env->Global()->Set(v8_str("obj"), fun);
856 Local<Script> script = v8_compile("var s = new obj(); s.x");
857 CHECK_EQ(1, script->Run()->Int32Value());
858
859 Local<Value> result = v8_compile("(new obj()).toString()")->Run();
860 CHECK_EQ(v8_str("[object funky]"), result);
861
862 result = v8_compile("(new obj()).m")->Run();
863 CHECK_EQ(239, result->Int32Value());
864 }
865 } 901 }
866 902
867 903
904 template<typename Constructor, typename Accessor>
905 static void TestFunctionTemplateAccessor(LocalContext* env,
906 Constructor constructor,
907 Accessor accessor) {
908 Local<v8::FunctionTemplate> fun_templ =
909 v8::FunctionTemplate::New(construct_call);
910 fun_templ->SetClassName(v8_str("funky"));
911 fun_templ->InstanceTemplate()->SetAccessor(v8_str("m"), accessor);
912 Local<Function> fun = fun_templ->GetFunction();
913 (*env)->Global()->Set(v8_str("obj"), fun);
914 Local<Script> script = v8_compile("var s = new obj(); s.x");
915 CHECK_EQ(1, script->Run()->Int32Value());
916 Local<Value> result = v8_compile("(new obj()).toString()")->Run();
917 CHECK_EQ(v8_str("[object funky]"), result);
918 result = v8_compile("(new obj()).m")->Run();
919 CHECK_EQ(239, result->Int32Value());
920 }
921
922
923 THREADED_TEST(FunctionTemplate) {
924 LocalContext env;
925 v8::HandleScope scope(env->GetIsolate());
926
927 TestFunctionTemplateInitializer(&env, handle_call);
928 TestFunctionTemplateInitializer(&env, handle_call_indirect);
929 TestFunctionTemplateInitializer(&env, handle_callback);
930
931 TestFunctionTemplateAccessor(&env, construct_call, Return239);
932 TestFunctionTemplateAccessor(&env,
933 construct_call_indirect,
934 Return239Indirect);
935 TestFunctionTemplateAccessor(&env, construct_callback, Return239Callback);
936 }
937
938
868 THREADED_TEST(FunctionTemplateSetLength) { 939 THREADED_TEST(FunctionTemplateSetLength) {
869 LocalContext env; 940 LocalContext env;
870 v8::HandleScope scope(env->GetIsolate()); 941 v8::HandleScope scope(env->GetIsolate());
871 { 942 {
872 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New( 943 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(
873 handle_call, Handle<v8::Value>(), Handle<v8::Signature>(), 23); 944 handle_call, Handle<v8::Value>(), Handle<v8::Signature>(), 23);
874 Local<Function> fun = fun_templ->GetFunction(); 945 Local<Function> fun = fun_templ->GetFunction();
875 env->Global()->Set(v8_str("obj"), fun); 946 env->Global()->Set(v8_str("obj"), fun);
876 Local<Script> script = v8_compile("obj.length"); 947 Local<Script> script = v8_compile("obj.length");
877 CHECK_EQ(23, script->Run()->Int32Value()); 948 CHECK_EQ(23, script->Run()->Int32Value());
(...skipping 3764 matching lines...) Expand 10 before | Expand all | Expand 10 after
4642 CHECK_EQ(v8_num(4), Handle<Value>(*xValue)); 4713 CHECK_EQ(v8_num(4), Handle<Value>(*xValue));
4643 xValue.Dispose(context->GetIsolate()); 4714 xValue.Dispose(context->GetIsolate());
4644 xValue = v8::Persistent<Value>(); 4715 xValue = v8::Persistent<Value>();
4645 } 4716 }
4646 } 4717 }
4647 4718
4648 4719
4649 THREADED_TEST(NoAccessors) { 4720 THREADED_TEST(NoAccessors) {
4650 v8::HandleScope scope(v8::Isolate::GetCurrent()); 4721 v8::HandleScope scope(v8::Isolate::GetCurrent());
4651 Local<ObjectTemplate> templ = ObjectTemplate::New(); 4722 Local<ObjectTemplate> templ = ObjectTemplate::New();
4652 templ->SetAccessor(v8_str("x"), NULL, NULL, v8_str("donut")); 4723 templ->SetAccessor(v8_str("x"),
4724 static_cast<v8::AccessorGetter>(NULL),
4725 NULL,
4726 v8_str("donut"));
4653 LocalContext context; 4727 LocalContext context;
4654 context->Global()->Set(v8_str("obj"), templ->NewInstance()); 4728 context->Global()->Set(v8_str("obj"), templ->NewInstance());
4655 Local<Script> script = Script::Compile(v8_str("obj.x = 4; obj.x")); 4729 Local<Script> script = Script::Compile(v8_str("obj.x = 4; obj.x"));
4656 for (int i = 0; i < 10; i++) { 4730 for (int i = 0; i < 10; i++) {
4657 script->Run(); 4731 script->Run();
4658 } 4732 }
4659 } 4733 }
4660 4734
4661 4735
4662 static v8::Handle<Value> XPropertyGetter(Local<String> property, 4736 static v8::Handle<Value> XPropertyGetter(Local<String> property,
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
5301 LocalContext env1; 5375 LocalContext env1;
5302 Local<Script> script1 = Script::Compile(source); 5376 Local<Script> script1 = Script::Compile(source);
5303 CHECK_EQ(8901.0, script1->Run()->NumberValue()); 5377 CHECK_EQ(8901.0, script1->Run()->NumberValue());
5304 } 5378 }
5305 5379
5306 5380
5307 THREADED_TEST(UndetectableObject) { 5381 THREADED_TEST(UndetectableObject) {
5308 LocalContext env; 5382 LocalContext env;
5309 v8::HandleScope scope(env->GetIsolate()); 5383 v8::HandleScope scope(env->GetIsolate());
5310 5384
5311 Local<v8::FunctionTemplate> desc = 5385 Local<v8::FunctionTemplate> desc = v8::FunctionTemplate::New();
5312 v8::FunctionTemplate::New(0, v8::Handle<Value>());
5313 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable 5386 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable
5314 5387
5315 Local<v8::Object> obj = desc->GetFunction()->NewInstance(); 5388 Local<v8::Object> obj = desc->GetFunction()->NewInstance();
5316 env->Global()->Set(v8_str("undetectable"), obj); 5389 env->Global()->Set(v8_str("undetectable"), obj);
5317 5390
5318 ExpectString("undetectable.toString()", "[object Object]"); 5391 ExpectString("undetectable.toString()", "[object Object]");
5319 ExpectString("typeof undetectable", "undefined"); 5392 ExpectString("typeof undetectable", "undefined");
5320 ExpectString("typeof(undetectable)", "undefined"); 5393 ExpectString("typeof(undetectable)", "undefined");
5321 ExpectBoolean("typeof undetectable == 'undefined'", true); 5394 ExpectBoolean("typeof undetectable == 'undefined'", true);
5322 ExpectBoolean("typeof undetectable == 'object'", false); 5395 ExpectBoolean("typeof undetectable == 'object'", false);
(...skipping 22 matching lines...) Expand all
5345 ExpectBoolean("undetectable===undefined", false); 5418 ExpectBoolean("undetectable===undefined", false);
5346 ExpectBoolean("undefined===undetectable", false); 5419 ExpectBoolean("undefined===undetectable", false);
5347 ExpectBoolean("undetectable===undetectable", true); 5420 ExpectBoolean("undetectable===undetectable", true);
5348 } 5421 }
5349 5422
5350 5423
5351 THREADED_TEST(VoidLiteral) { 5424 THREADED_TEST(VoidLiteral) {
5352 LocalContext env; 5425 LocalContext env;
5353 v8::HandleScope scope(env->GetIsolate()); 5426 v8::HandleScope scope(env->GetIsolate());
5354 5427
5355 Local<v8::FunctionTemplate> desc = 5428 Local<v8::FunctionTemplate> desc = v8::FunctionTemplate::New();
5356 v8::FunctionTemplate::New(0, v8::Handle<Value>());
5357 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable 5429 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable
5358 5430
5359 Local<v8::Object> obj = desc->GetFunction()->NewInstance(); 5431 Local<v8::Object> obj = desc->GetFunction()->NewInstance();
5360 env->Global()->Set(v8_str("undetectable"), obj); 5432 env->Global()->Set(v8_str("undetectable"), obj);
5361 5433
5362 ExpectBoolean("undefined == void 0", true); 5434 ExpectBoolean("undefined == void 0", true);
5363 ExpectBoolean("undetectable == void 0", true); 5435 ExpectBoolean("undetectable == void 0", true);
5364 ExpectBoolean("null == void 0", true); 5436 ExpectBoolean("null == void 0", true);
5365 ExpectBoolean("undefined === void 0", true); 5437 ExpectBoolean("undefined === void 0", true);
5366 ExpectBoolean("undetectable === void 0", false); 5438 ExpectBoolean("undetectable === void 0", false);
(...skipping 22 matching lines...) Expand all
5389 " }" 5461 " }"
5390 "})()", 5462 "})()",
5391 "ReferenceError: x is not defined"); 5463 "ReferenceError: x is not defined");
5392 } 5464 }
5393 5465
5394 5466
5395 THREADED_TEST(ExtensibleOnUndetectable) { 5467 THREADED_TEST(ExtensibleOnUndetectable) {
5396 LocalContext env; 5468 LocalContext env;
5397 v8::HandleScope scope(env->GetIsolate()); 5469 v8::HandleScope scope(env->GetIsolate());
5398 5470
5399 Local<v8::FunctionTemplate> desc = 5471 Local<v8::FunctionTemplate> desc = v8::FunctionTemplate::New();
5400 v8::FunctionTemplate::New(0, v8::Handle<Value>());
5401 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable 5472 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable
5402 5473
5403 Local<v8::Object> obj = desc->GetFunction()->NewInstance(); 5474 Local<v8::Object> obj = desc->GetFunction()->NewInstance();
5404 env->Global()->Set(v8_str("undetectable"), obj); 5475 env->Global()->Set(v8_str("undetectable"), obj);
5405 5476
5406 Local<String> source = v8_str("undetectable.x = 42;" 5477 Local<String> source = v8_str("undetectable.x = 42;"
5407 "undetectable.x"); 5478 "undetectable.x");
5408 5479
5409 Local<Script> script = Script::Compile(source); 5480 Local<Script> script = Script::Compile(source);
5410 5481
(...skipping 5079 matching lines...) Expand 10 before | Expand all | Expand 10 after
10490 "function f() {" 10561 "function f() {"
10491 " for (var i = 1; i <= 5; i++) {" 10562 " for (var i = 1; i <= 5; i++) {"
10492 " try { nativeobject.callback(); } catch (e) { result += e; }" 10563 " try { nativeobject.callback(); } catch (e) { result += e; }"
10493 " }" 10564 " }"
10494 "}" 10565 "}"
10495 "f(); result;"); 10566 "f(); result;");
10496 CHECK_EQ(v8_str("ggggg"), result); 10567 CHECK_EQ(v8_str("ggggg"), result);
10497 } 10568 }
10498 10569
10499 10570
10500 v8::Handle<v8::Value> DirectGetterCallback(Local<String> name, 10571 static Handle<Value> DoDirectGetter() {
10501 const v8::AccessorInfo& info) {
10502 if (++p_getter_count % 3 == 0) { 10572 if (++p_getter_count % 3 == 0) {
10503 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); 10573 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
10504 GenerateSomeGarbage(); 10574 GenerateSomeGarbage();
10505 } 10575 }
10576 return v8_str("Direct Getter Result");
10577 }
10578
10579 static void CheckReturnValue(v8::ReturnValue<v8::Value> rv) {
10580 i::Object** o = *reinterpret_cast<i::Object***>(&rv);
10581 CHECK((*o)->IsTheHole() || (*o)->IsUndefined());
10582 }
10583
10584 static v8::Handle<v8::Value> DirectGetter(Local<String> name,
10585 const v8::AccessorInfo& info) {
10586 CheckReturnValue(info.GetReturnValue());
10587 info.GetReturnValue().Set(v8_str("Garbage"));
10588 return DoDirectGetter();
10589 }
10590
10591 static v8::Handle<v8::Value> DirectGetterIndirect(
10592 Local<String> name,
10593 const v8::AccessorInfo& info) {
10594 CheckReturnValue(info.GetReturnValue());
10595 info.GetReturnValue().Set(DoDirectGetter());
10506 return v8::Handle<v8::Value>(); 10596 return v8::Handle<v8::Value>();
10507 } 10597 }
10508 10598
10599 static void DirectGetterCallback(
10600 Local<String> name,
10601 const v8::PropertyCallbackInfo<v8::Value>& info) {
10602 CheckReturnValue(info.GetReturnValue());
10603 info.GetReturnValue().Set(DoDirectGetter());
10604 }
10509 10605
10510 THREADED_TEST(LoadICFastApi_DirectCall_GCMoveStub) { 10606
10607 template<typename Accessor>
10608 static void LoadICFastApi_DirectCall_GCMoveStub(Accessor accessor) {
10511 LocalContext context; 10609 LocalContext context;
10512 v8::HandleScope scope(context->GetIsolate()); 10610 v8::HandleScope scope(context->GetIsolate());
10513 v8::Handle<v8::ObjectTemplate> obj = v8::ObjectTemplate::New(); 10611 v8::Handle<v8::ObjectTemplate> obj = v8::ObjectTemplate::New();
10514 obj->SetAccessor(v8_str("p1"), DirectGetterCallback); 10612 obj->SetAccessor(v8_str("p1"), accessor);
10515 context->Global()->Set(v8_str("o1"), obj->NewInstance()); 10613 context->Global()->Set(v8_str("o1"), obj->NewInstance());
10516 p_getter_count = 0; 10614 p_getter_count = 0;
10517 CompileRun( 10615 v8::Handle<v8::Value> result = CompileRun(
10518 "function f() {" 10616 "function f() {"
10519 " for (var i = 0; i < 30; i++) o1.p1;" 10617 " for (var i = 0; i < 30; i++) o1.p1;"
10618 " return o1.p1"
10520 "}" 10619 "}"
10521 "f();"); 10620 "f();");
10522 CHECK_EQ(30, p_getter_count); 10621 CHECK_EQ(v8_str("Direct Getter Result"), result);
10622 CHECK_EQ(31, p_getter_count);
10623 }
10624
10625 THREADED_TEST(LoadICFastApi_DirectCall_GCMoveStub) {
10626 LoadICFastApi_DirectCall_GCMoveStub(DirectGetterIndirect);
10627 LoadICFastApi_DirectCall_GCMoveStub(DirectGetterCallback);
10628 LoadICFastApi_DirectCall_GCMoveStub(DirectGetter);
10523 } 10629 }
10524 10630
10525 10631
10526 v8::Handle<v8::Value> ThrowingDirectGetterCallback( 10632 v8::Handle<v8::Value> ThrowingDirectGetterCallback(
10527 Local<String> name, const v8::AccessorInfo& info) { 10633 Local<String> name, const v8::AccessorInfo& info) {
10528 return v8::ThrowException(v8_str("g")); 10634 return v8::ThrowException(v8_str("g"));
10529 } 10635 }
10530 10636
10531 10637
10532 THREADED_TEST(LoadICFastApi_DirectCall_Throw) { 10638 THREADED_TEST(LoadICFastApi_DirectCall_Throw) {
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
11191 "};" 11297 "};"
11192 "f();"); 11298 "f();");
11193 CHECK_EQ(true, value->BooleanValue()); 11299 CHECK_EQ(true, value->BooleanValue());
11194 } 11300 }
11195 11301
11196 11302
11197 // Test that we ignore null interceptors. 11303 // Test that we ignore null interceptors.
11198 THREADED_TEST(NullNamedInterceptor) { 11304 THREADED_TEST(NullNamedInterceptor) {
11199 v8::HandleScope scope(v8::Isolate::GetCurrent()); 11305 v8::HandleScope scope(v8::Isolate::GetCurrent());
11200 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); 11306 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
11201 templ->SetNamedPropertyHandler(0); 11307 templ->SetNamedPropertyHandler(static_cast<v8::NamedPropertyGetter>(0));
11202 LocalContext context; 11308 LocalContext context;
11203 templ->Set("x", v8_num(42)); 11309 templ->Set("x", v8_num(42));
11204 v8::Handle<v8::Object> obj = templ->NewInstance(); 11310 v8::Handle<v8::Object> obj = templ->NewInstance();
11205 context->Global()->Set(v8_str("obj"), obj); 11311 context->Global()->Set(v8_str("obj"), obj);
11206 v8::Handle<Value> value = CompileRun("obj.x"); 11312 v8::Handle<Value> value = CompileRun("obj.x");
11207 CHECK(value->IsInt32()); 11313 CHECK(value->IsInt32());
11208 CHECK_EQ(42, value->Int32Value()); 11314 CHECK_EQ(42, value->Int32Value());
11209 } 11315 }
11210 11316
11211 11317
11212 // Test that we ignore null interceptors. 11318 // Test that we ignore null interceptors.
11213 THREADED_TEST(NullIndexedInterceptor) { 11319 THREADED_TEST(NullIndexedInterceptor) {
11214 v8::HandleScope scope(v8::Isolate::GetCurrent()); 11320 v8::HandleScope scope(v8::Isolate::GetCurrent());
11215 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); 11321 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
11216 templ->SetIndexedPropertyHandler(0); 11322 templ->SetIndexedPropertyHandler(static_cast<v8::IndexedPropertyGetter>(0));
11217 LocalContext context; 11323 LocalContext context;
11218 templ->Set("42", v8_num(42)); 11324 templ->Set("42", v8_num(42));
11219 v8::Handle<v8::Object> obj = templ->NewInstance(); 11325 v8::Handle<v8::Object> obj = templ->NewInstance();
11220 context->Global()->Set(v8_str("obj"), obj); 11326 context->Global()->Set(v8_str("obj"), obj);
11221 v8::Handle<Value> value = CompileRun("obj[42]"); 11327 v8::Handle<Value> value = CompileRun("obj[42]");
11222 CHECK(value->IsInt32()); 11328 CHECK(value->IsInt32());
11223 CHECK_EQ(42, value->Int32Value()); 11329 CHECK_EQ(42, value->Int32Value());
11224 } 11330 }
11225 11331
11226 11332
(...skipping 7755 matching lines...) Expand 10 before | Expand all | Expand 10 after
18982 i::Semaphore* sem_; 19088 i::Semaphore* sem_;
18983 volatile int sem_value_; 19089 volatile int sem_value_;
18984 }; 19090 };
18985 19091
18986 19092
18987 THREADED_TEST(SemaphoreInterruption) { 19093 THREADED_TEST(SemaphoreInterruption) {
18988 ThreadInterruptTest().RunTest(); 19094 ThreadInterruptTest().RunTest();
18989 } 19095 }
18990 19096
18991 #endif // WIN32 19097 #endif // WIN32
OLDNEW
« no previous file with comments | « src/x64/stub-cache-x64.cc ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698