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

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

Issue 2674103002: [runtime] Skip feedback vector configuration. (Closed)
Patch Set: Add regression test. Created 3 years, 10 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/runtime/runtime-scopes.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 6
7 #include "test/cctest/test-api.h" 7 #include "test/cctest/test-api.h"
8 8
9 #include "include/v8-util.h" 9 #include "include/v8-util.h"
10 #include "src/api.h" 10 #include "src/api.h"
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 const v8::PropertyCallbackInfo<v8::Value>& info) { 488 const v8::PropertyCallbackInfo<v8::Value>& info) {
489 get_was_called = true; 489 get_was_called = true;
490 } 490 }
491 491
492 void SetterCallback(Local<Name> property, Local<Value> value, 492 void SetterCallback(Local<Name> property, Local<Value> value,
493 const v8::PropertyCallbackInfo<v8::Value>& info) { 493 const v8::PropertyCallbackInfo<v8::Value>& info) {
494 set_was_called = true; 494 set_was_called = true;
495 set_was_called_counter++; 495 set_was_called_counter++;
496 } 496 }
497 497
498 void InterceptingSetterCallback(
499 Local<Name> property, Local<Value> value,
500 const v8::PropertyCallbackInfo<v8::Value>& info) {
501 info.GetReturnValue().Set(value);
502 }
503
498 } // namespace 504 } // namespace
499 505
500 // Check that get callback is called in defineProperty with accessor descriptor. 506 // Check that get callback is called in defineProperty with accessor descriptor.
501 THREADED_TEST(DefinerCallbackAccessorInterceptor) { 507 THREADED_TEST(DefinerCallbackAccessorInterceptor) {
502 v8::HandleScope scope(CcTest::isolate()); 508 v8::HandleScope scope(CcTest::isolate());
503 v8::Local<v8::FunctionTemplate> templ = 509 v8::Local<v8::FunctionTemplate> templ =
504 v8::FunctionTemplate::New(CcTest::isolate()); 510 v8::FunctionTemplate::New(CcTest::isolate());
505 templ->InstanceTemplate()->SetHandler( 511 templ->InstanceTemplate()->SetHandler(
506 v8::NamedPropertyHandlerConfiguration(GetterCallback, SetterCallback)); 512 v8::NamedPropertyHandlerConfiguration(GetterCallback, SetterCallback));
507 LocalContext env; 513 LocalContext env;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 v8::Local<v8::Context> ctx = 595 v8::Local<v8::Context> ctx =
590 v8::Context::New(CcTest::isolate(), nullptr, object_template); 596 v8::Context::New(CcTest::isolate(), nullptr, object_template);
591 597
592 // Declare and redeclare function. 598 // Declare and redeclare function.
593 v8::Local<v8::String> code = v8_str( 599 v8::Local<v8::String> code = v8_str(
594 "function x() {return 42;};" 600 "function x() {return 42;};"
595 "function x() {return 43;};"); 601 "function x() {return 43;};");
596 v8::Script::Compile(ctx, code).ToLocalChecked()->Run(ctx).ToLocalChecked(); 602 v8::Script::Compile(ctx, code).ToLocalChecked()->Run(ctx).ToLocalChecked();
597 } 603 }
598 604
605 // Regression test for chromium bug 656648.
606 // Do not crash on non-masking, intercepting setter callbacks.
607 THREADED_TEST(NonMaskingInterceptor) {
608 v8::HandleScope scope(CcTest::isolate());
609 LocalContext env;
610 v8::Local<v8::FunctionTemplate> templ =
611 v8::FunctionTemplate::New(CcTest::isolate());
612
613 v8::Local<ObjectTemplate> object_template = templ->InstanceTemplate();
614 object_template->SetHandler(v8::NamedPropertyHandlerConfiguration(
615 nullptr, InterceptingSetterCallback, nullptr, nullptr, nullptr,
616 Local<Value>(), v8::PropertyHandlerFlags::kNonMasking));
617 v8::Local<v8::Context> ctx =
618 v8::Context::New(CcTest::isolate(), nullptr, object_template);
619
620 v8::Local<v8::String> code = v8_str("function x() {return 43;};");
621 v8::Script::Compile(ctx, code).ToLocalChecked()->Run(ctx).ToLocalChecked();
622 }
623
599 // Check that function re-declarations throw if they are read-only. 624 // Check that function re-declarations throw if they are read-only.
600 THREADED_TEST(SetterCallbackFunctionDeclarationInterceptorThrow) { 625 THREADED_TEST(SetterCallbackFunctionDeclarationInterceptorThrow) {
601 v8::HandleScope scope(CcTest::isolate()); 626 v8::HandleScope scope(CcTest::isolate());
602 LocalContext env; 627 LocalContext env;
603 v8::Local<v8::FunctionTemplate> templ = 628 v8::Local<v8::FunctionTemplate> templ =
604 v8::FunctionTemplate::New(CcTest::isolate()); 629 v8::FunctionTemplate::New(CcTest::isolate());
605 630
606 v8::Local<ObjectTemplate> object_template = templ->InstanceTemplate(); 631 v8::Local<ObjectTemplate> object_template = templ->InstanceTemplate();
607 object_template->SetHandler( 632 object_template->SetHandler(
608 v8::NamedPropertyHandlerConfiguration(nullptr, SetterCallback)); 633 v8::NamedPropertyHandlerConfiguration(nullptr, SetterCallback));
(...skipping 4336 matching lines...) Expand 10 before | Expand all | Expand 10 after
4945 ->Set(env.local(), v8_str("Fun"), 4970 ->Set(env.local(), v8_str("Fun"),
4946 fun_templ->GetFunction(env.local()).ToLocalChecked()) 4971 fun_templ->GetFunction(env.local()).ToLocalChecked())
4947 .FromJust()); 4972 .FromJust());
4948 4973
4949 CompileRun( 4974 CompileRun(
4950 "var f = new Fun();" 4975 "var f = new Fun();"
4951 "Number.prototype.__proto__ = f;" 4976 "Number.prototype.__proto__ = f;"
4952 "var a = 42;" 4977 "var a = 42;"
4953 "for (var i = 0; i<3; i++) { a.foo; }"); 4978 "for (var i = 0; i<3; i++) { a.foo; }");
4954 } 4979 }
OLDNEW
« no previous file with comments | « src/runtime/runtime-scopes.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698