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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { | 373 Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { |
374 ApiTestFuzzer::Fuzz(); | 374 ApiTestFuzzer::Fuzz(); |
375 } | 375 } |
376 | 376 |
377 void InterceptorHasOwnPropertyGetterGC( | 377 void InterceptorHasOwnPropertyGetterGC( |
378 Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { | 378 Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { |
379 ApiTestFuzzer::Fuzz(); | 379 ApiTestFuzzer::Fuzz(); |
380 CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask); | 380 CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask); |
381 } | 381 } |
382 | 382 |
383 } // namespace | |
384 | |
385 int query_counter_int = 0; | 383 int query_counter_int = 0; |
386 | 384 |
387 namespace { | |
388 void QueryCallback(Local<Name> property, | 385 void QueryCallback(Local<Name> property, |
389 const v8::PropertyCallbackInfo<v8::Integer>& info) { | 386 const v8::PropertyCallbackInfo<v8::Integer>& info) { |
390 query_counter_int++; | 387 query_counter_int++; |
391 } | 388 } |
392 | 389 |
393 } // namespace | 390 } // namespace |
394 | 391 |
395 // Examples that show when the query callback is triggered. | 392 // Examples that show when the query callback is triggered. |
396 THREADED_TEST(QueryInterceptor) { | 393 THREADED_TEST(QueryInterceptor) { |
397 v8::HandleScope scope(CcTest::isolate()); | 394 v8::HandleScope scope(CcTest::isolate()); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 | 469 |
473 v8_compile("Object.defineProperty(obj, 'enum', {value: 42});") | 470 v8_compile("Object.defineProperty(obj, 'enum', {value: 42});") |
474 ->Run(env.local()) | 471 ->Run(env.local()) |
475 .ToLocalChecked(); | 472 .ToLocalChecked(); |
476 CHECK_EQ(query_counter_int, 8); | 473 CHECK_EQ(query_counter_int, 8); |
477 | 474 |
478 v8_compile("Object.isFrozen('obj.x');")->Run(env.local()).ToLocalChecked(); | 475 v8_compile("Object.isFrozen('obj.x');")->Run(env.local()).ToLocalChecked(); |
479 CHECK_EQ(query_counter_int, 8); | 476 CHECK_EQ(query_counter_int, 8); |
480 } | 477 } |
481 | 478 |
| 479 namespace { |
| 480 |
482 bool get_was_called = false; | 481 bool get_was_called = false; |
483 bool set_was_called = false; | 482 bool set_was_called = false; |
484 | 483 |
485 int set_was_called_counter = 0; | 484 int set_was_called_counter = 0; |
486 | 485 |
487 namespace { | |
488 void GetterCallback(Local<Name> property, | 486 void GetterCallback(Local<Name> property, |
489 const v8::PropertyCallbackInfo<v8::Value>& info) { | 487 const v8::PropertyCallbackInfo<v8::Value>& info) { |
490 get_was_called = true; | 488 get_was_called = true; |
491 } | 489 } |
492 | 490 |
493 void SetterCallback(Local<Name> property, Local<Value> value, | 491 void SetterCallback(Local<Name> property, Local<Value> value, |
494 const v8::PropertyCallbackInfo<v8::Value>& info) { | 492 const v8::PropertyCallbackInfo<v8::Value>& info) { |
495 set_was_called = true; | 493 set_was_called = true; |
496 set_was_called_counter++; | 494 set_was_called_counter++; |
497 } | 495 } |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 set_was_called = false; | 601 set_was_called = false; |
604 | 602 |
605 // Redeclare function that is read-only. | 603 // Redeclare function that is read-only. |
606 code = v8_str("function x() {return 43;};"); | 604 code = v8_str("function x() {return 43;};"); |
607 CHECK(v8::Script::Compile(ctx, code).ToLocalChecked()->Run(ctx).IsEmpty()); | 605 CHECK(v8::Script::Compile(ctx, code).ToLocalChecked()->Run(ctx).IsEmpty()); |
608 CHECK(try_catch.HasCaught()); | 606 CHECK(try_catch.HasCaught()); |
609 | 607 |
610 CHECK_EQ(set_was_called, false); | 608 CHECK_EQ(set_was_called, false); |
611 } | 609 } |
612 | 610 |
| 611 |
| 612 namespace { |
| 613 |
613 bool get_was_called_in_order = false; | 614 bool get_was_called_in_order = false; |
614 bool define_was_called_in_order = false; | 615 bool define_was_called_in_order = false; |
615 | 616 |
616 namespace { | |
617 | |
618 void GetterCallbackOrder(Local<Name> property, | 617 void GetterCallbackOrder(Local<Name> property, |
619 const v8::PropertyCallbackInfo<v8::Value>& info) { | 618 const v8::PropertyCallbackInfo<v8::Value>& info) { |
620 get_was_called_in_order = true; | 619 get_was_called_in_order = true; |
621 CHECK_EQ(define_was_called_in_order, true); | 620 CHECK_EQ(define_was_called_in_order, true); |
622 info.GetReturnValue().Set(property); | 621 info.GetReturnValue().Set(property); |
623 } | 622 } |
624 | 623 |
625 void DefinerCallbackOrder(Local<Name> property, | 624 void DefinerCallbackOrder(Local<Name> property, |
626 const v8::PropertyDescriptor& desc, | 625 const v8::PropertyDescriptor& desc, |
627 const v8::PropertyCallbackInfo<v8::Value>& info) { | 626 const v8::PropertyCallbackInfo<v8::Value>& info) { |
(...skipping 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1965 "var desc = Object.getOwnPropertyDescriptor(obj, 'x');" | 1964 "var desc = Object.getOwnPropertyDescriptor(obj, 'x');" |
1966 "desc.value;"; | 1965 "desc.value;"; |
1967 CHECK_EQ(42, v8_compile(code) | 1966 CHECK_EQ(42, v8_compile(code) |
1968 ->Run(env.local()) | 1967 ->Run(env.local()) |
1969 .ToLocalChecked() | 1968 .ToLocalChecked() |
1970 ->Int32Value(env.local()) | 1969 ->Int32Value(env.local()) |
1971 .FromJust()); | 1970 .FromJust()); |
1972 } | 1971 } |
1973 } | 1972 } |
1974 | 1973 |
| 1974 namespace { |
1975 int echo_indexed_call_count = 0; | 1975 int echo_indexed_call_count = 0; |
1976 | 1976 } // namespace |
1977 | 1977 |
1978 static void EchoIndexedProperty( | 1978 static void EchoIndexedProperty( |
1979 uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info) { | 1979 uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info) { |
1980 ApiTestFuzzer::Fuzz(); | 1980 ApiTestFuzzer::Fuzz(); |
1981 CHECK(v8_num(637) | 1981 CHECK(v8_num(637) |
1982 ->Equals(info.GetIsolate()->GetCurrentContext(), info.Data()) | 1982 ->Equals(info.GetIsolate()->GetCurrentContext(), info.Data()) |
1983 .FromJust()); | 1983 .FromJust()); |
1984 echo_indexed_call_count++; | 1984 echo_indexed_call_count++; |
1985 info.GetReturnValue().Set(v8_num(index)); | 1985 info.GetReturnValue().Set(v8_num(index)); |
1986 } | 1986 } |
(...skipping 2925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4912 ->Set(env.local(), v8_str("Fun"), | 4912 ->Set(env.local(), v8_str("Fun"), |
4913 fun_templ->GetFunction(env.local()).ToLocalChecked()) | 4913 fun_templ->GetFunction(env.local()).ToLocalChecked()) |
4914 .FromJust()); | 4914 .FromJust()); |
4915 | 4915 |
4916 CompileRun( | 4916 CompileRun( |
4917 "var f = new Fun();" | 4917 "var f = new Fun();" |
4918 "Number.prototype.__proto__ = f;" | 4918 "Number.prototype.__proto__ = f;" |
4919 "var a = 42;" | 4919 "var a = 42;" |
4920 "for (var i = 0; i<3; i++) { a.foo; }"); | 4920 "for (var i = 0; i<3; i++) { a.foo; }"); |
4921 } | 4921 } |
OLD | NEW |