| OLD | NEW |
| 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 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 code = v8_str("x = function() {return 44;}; x();"); | 561 code = v8_str("x = function() {return 44;}; x();"); |
| 562 CHECK_EQ(44, v8::Script::Compile(ctx, code) | 562 CHECK_EQ(44, v8::Script::Compile(ctx, code) |
| 563 .ToLocalChecked() | 563 .ToLocalChecked() |
| 564 ->Run(ctx) | 564 ->Run(ctx) |
| 565 .ToLocalChecked() | 565 .ToLocalChecked() |
| 566 ->Int32Value(ctx) | 566 ->Int32Value(ctx) |
| 567 .FromJust()); | 567 .FromJust()); |
| 568 CHECK_EQ(set_was_called_counter, 3); | 568 CHECK_EQ(set_was_called_counter, 3); |
| 569 } | 569 } |
| 570 | 570 |
| 571 namespace { |
| 572 void QueryCallbackSetDontDelete( |
| 573 Local<Name> property, const v8::PropertyCallbackInfo<v8::Integer>& info) { |
| 574 info.GetReturnValue().Set(v8::PropertyAttribute::DontDelete); |
| 575 } |
| 576 |
| 577 } // namespace |
| 578 |
| 579 // Regression for a Node.js test that fails in debug mode. |
| 580 THREADED_TEST(InterceptorFunctionRedeclareWithQueryCallback) { |
| 581 v8::HandleScope scope(CcTest::isolate()); |
| 582 LocalContext env; |
| 583 v8::Local<v8::FunctionTemplate> templ = |
| 584 v8::FunctionTemplate::New(CcTest::isolate()); |
| 585 |
| 586 v8::Local<ObjectTemplate> object_template = templ->InstanceTemplate(); |
| 587 object_template->SetHandler(v8::NamedPropertyHandlerConfiguration( |
| 588 nullptr, nullptr, QueryCallbackSetDontDelete)); |
| 589 v8::Local<v8::Context> ctx = |
| 590 v8::Context::New(CcTest::isolate(), nullptr, object_template); |
| 591 |
| 592 // Declare and redeclare function. |
| 593 v8::Local<v8::String> code = v8_str( |
| 594 "function x() {return 42;};" |
| 595 "function x() {return 43;};"); |
| 596 v8::Script::Compile(ctx, code).ToLocalChecked()->Run(ctx).ToLocalChecked(); |
| 597 } |
| 598 |
| 571 // Check that function re-declarations throw if they are read-only. | 599 // Check that function re-declarations throw if they are read-only. |
| 572 THREADED_TEST(SetterCallbackFunctionDeclarationInterceptorThrow) { | 600 THREADED_TEST(SetterCallbackFunctionDeclarationInterceptorThrow) { |
| 573 v8::HandleScope scope(CcTest::isolate()); | 601 v8::HandleScope scope(CcTest::isolate()); |
| 574 LocalContext env; | 602 LocalContext env; |
| 575 v8::Local<v8::FunctionTemplate> templ = | 603 v8::Local<v8::FunctionTemplate> templ = |
| 576 v8::FunctionTemplate::New(CcTest::isolate()); | 604 v8::FunctionTemplate::New(CcTest::isolate()); |
| 577 | 605 |
| 578 v8::Local<ObjectTemplate> object_template = templ->InstanceTemplate(); | 606 v8::Local<ObjectTemplate> object_template = templ->InstanceTemplate(); |
| 579 object_template->SetHandler( | 607 object_template->SetHandler( |
| 580 v8::NamedPropertyHandlerConfiguration(nullptr, SetterCallback)); | 608 v8::NamedPropertyHandlerConfiguration(nullptr, SetterCallback)); |
| (...skipping 4336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4917 ->Set(env.local(), v8_str("Fun"), | 4945 ->Set(env.local(), v8_str("Fun"), |
| 4918 fun_templ->GetFunction(env.local()).ToLocalChecked()) | 4946 fun_templ->GetFunction(env.local()).ToLocalChecked()) |
| 4919 .FromJust()); | 4947 .FromJust()); |
| 4920 | 4948 |
| 4921 CompileRun( | 4949 CompileRun( |
| 4922 "var f = new Fun();" | 4950 "var f = new Fun();" |
| 4923 "Number.prototype.__proto__ = f;" | 4951 "Number.prototype.__proto__ = f;" |
| 4924 "var a = 42;" | 4952 "var a = 42;" |
| 4925 "for (var i = 0; i<3; i++) { a.foo; }"); | 4953 "for (var i = 0; i<3; i++) { a.foo; }"); |
| 4926 } | 4954 } |
| OLD | NEW |