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

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

Issue 3526008: Add a check that accessors set to instance template work even if we have a custom call handler. (Closed)
Patch Set: Addressing Mads' comments Created 10 years, 2 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 | « no previous file | 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 2007-2009 the V8 project authors. All rights reserved. 1 // Copyright 2007-2009 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 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 } 759 }
760 760
761 761
762 static v8::Handle<Value> construct_call(const v8::Arguments& args) { 762 static v8::Handle<Value> construct_call(const v8::Arguments& args) {
763 ApiTestFuzzer::Fuzz(); 763 ApiTestFuzzer::Fuzz();
764 args.This()->Set(v8_str("x"), v8_num(1)); 764 args.This()->Set(v8_str("x"), v8_num(1));
765 args.This()->Set(v8_str("y"), v8_num(2)); 765 args.This()->Set(v8_str("y"), v8_num(2));
766 return args.This(); 766 return args.This();
767 } 767 }
768 768
769 static v8::Handle<Value> Return239(Local<String> name, const AccessorInfo&) {
770 ApiTestFuzzer::Fuzz();
771 return v8_num(239);
772 }
773
774
769 THREADED_TEST(FunctionTemplate) { 775 THREADED_TEST(FunctionTemplate) {
770 v8::HandleScope scope; 776 v8::HandleScope scope;
771 LocalContext env; 777 LocalContext env;
772 { 778 {
773 Local<v8::FunctionTemplate> fun_templ = 779 Local<v8::FunctionTemplate> fun_templ =
774 v8::FunctionTemplate::New(handle_call); 780 v8::FunctionTemplate::New(handle_call);
775 Local<Function> fun = fun_templ->GetFunction(); 781 Local<Function> fun = fun_templ->GetFunction();
776 env->Global()->Set(v8_str("obj"), fun); 782 env->Global()->Set(v8_str("obj"), fun);
777 Local<Script> script = v8_compile("obj()"); 783 Local<Script> script = v8_compile("obj()");
778 CHECK_EQ(102, script->Run()->Int32Value()); 784 CHECK_EQ(102, script->Run()->Int32Value());
779 } 785 }
780 // Use SetCallHandler to initialize a function template, should work like the 786 // Use SetCallHandler to initialize a function template, should work like the
781 // previous one. 787 // previous one.
782 { 788 {
783 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 789 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
784 fun_templ->SetCallHandler(handle_call); 790 fun_templ->SetCallHandler(handle_call);
785 Local<Function> fun = fun_templ->GetFunction(); 791 Local<Function> fun = fun_templ->GetFunction();
786 env->Global()->Set(v8_str("obj"), fun); 792 env->Global()->Set(v8_str("obj"), fun);
787 Local<Script> script = v8_compile("obj()"); 793 Local<Script> script = v8_compile("obj()");
788 CHECK_EQ(102, script->Run()->Int32Value()); 794 CHECK_EQ(102, script->Run()->Int32Value());
789 } 795 }
790 // Test constructor calls. 796 // Test constructor calls.
791 { 797 {
792 Local<v8::FunctionTemplate> fun_templ = 798 Local<v8::FunctionTemplate> fun_templ =
793 v8::FunctionTemplate::New(construct_call); 799 v8::FunctionTemplate::New(construct_call);
794 fun_templ->SetClassName(v8_str("funky")); 800 fun_templ->SetClassName(v8_str("funky"));
801 fun_templ->InstanceTemplate()->SetAccessor(v8_str("m"), Return239);
795 Local<Function> fun = fun_templ->GetFunction(); 802 Local<Function> fun = fun_templ->GetFunction();
796 env->Global()->Set(v8_str("obj"), fun); 803 env->Global()->Set(v8_str("obj"), fun);
797 Local<Script> script = v8_compile("var s = new obj(); s.x"); 804 Local<Script> script = v8_compile("var s = new obj(); s.x");
798 CHECK_EQ(1, script->Run()->Int32Value()); 805 CHECK_EQ(1, script->Run()->Int32Value());
799 806
800 Local<Value> result = v8_compile("(new obj()).toString()")->Run(); 807 Local<Value> result = v8_compile("(new obj()).toString()")->Run();
801 CHECK_EQ(v8_str("[object funky]"), result); 808 CHECK_EQ(v8_str("[object funky]"), result);
809
810 result = v8_compile("(new obj()).m")->Run();
811 CHECK_EQ(239, result->Int32Value());
802 } 812 }
803 } 813 }
804 814
805 815
806 THREADED_TEST(FindInstanceInPrototypeChain) { 816 THREADED_TEST(FindInstanceInPrototypeChain) {
807 v8::HandleScope scope; 817 v8::HandleScope scope;
808 LocalContext env; 818 LocalContext env;
809 819
810 Local<v8::FunctionTemplate> base = v8::FunctionTemplate::New(); 820 Local<v8::FunctionTemplate> base = v8::FunctionTemplate::New();
811 Local<v8::FunctionTemplate> derived = v8::FunctionTemplate::New(); 821 Local<v8::FunctionTemplate> derived = v8::FunctionTemplate::New();
(...skipping 5690 matching lines...) Expand 10 before | Expand all | Expand 10 after
6502 "this.y = 42;" // Assign on a global. 6512 "this.y = 42;" // Assign on a global.
6503 "var result = 0;" 6513 "var result = 0;"
6504 "for (var i = 0; i < 10; i++) {" 6514 "for (var i = 0; i < 10; i++) {"
6505 " result += o.y;" 6515 " result += o.y;"
6506 "}" 6516 "}"
6507 "result;", 6517 "result;",
6508 42 * 10); 6518 42 * 10);
6509 } 6519 }
6510 6520
6511 6521
6512 static v8::Handle<Value> Return239(Local<String> name, const AccessorInfo&) {
6513 ApiTestFuzzer::Fuzz();
6514 return v8_num(239);
6515 }
6516
6517
6518 static void SetOnThis(Local<String> name, 6522 static void SetOnThis(Local<String> name,
6519 Local<Value> value, 6523 Local<Value> value,
6520 const AccessorInfo& info) { 6524 const AccessorInfo& info) {
6521 info.This()->ForceSet(name, value); 6525 info.This()->ForceSet(name, value);
6522 } 6526 }
6523 6527
6524 6528
6525 THREADED_TEST(InterceptorLoadICWithCallbackOnHolder) { 6529 THREADED_TEST(InterceptorLoadICWithCallbackOnHolder) {
6526 v8::HandleScope scope; 6530 v8::HandleScope scope;
6527 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); 6531 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
(...skipping 4948 matching lines...) Expand 10 before | Expand all | Expand 10 after
11476 11480
11477 { 11481 {
11478 // Change the Boolean.prototype in the second context and check 11482 // Change the Boolean.prototype in the second context and check
11479 // that the right function gets called. 11483 // that the right function gets called.
11480 v8::HandleScope scope; 11484 v8::HandleScope scope;
11481 LocalContext context2; 11485 LocalContext context2;
11482 CompileRun("Boolean.prototype.toString = function() { return \"\"; }"); 11486 CompileRun("Boolean.prototype.toString = function() { return \"\"; }");
11483 ExpectString(code, ""); 11487 ExpectString(code, "");
11484 } 11488 }
11485 } 11489 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698