| OLD | NEW |
| 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 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 LocalContext context2(CcTest::isolate()); | 704 LocalContext context2(CcTest::isolate()); |
| 705 context2->SetSecurityToken(foo); | 705 context2->SetSecurityToken(foo); |
| 706 context2->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "obj"), | 706 context2->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "obj"), |
| 707 object); | 707 object); |
| 708 CompileRun("function observer() {};" | 708 CompileRun("function observer() {};" |
| 709 "Object.observe(obj, observer, ['foo', 'bar', 'baz']);" | 709 "Object.observe(obj, observer, ['foo', 'bar', 'baz']);" |
| 710 "Object.unobserve(obj, observer);"); | 710 "Object.unobserve(obj, observer);"); |
| 711 } | 711 } |
| 712 | 712 |
| 713 CcTest::isolate()->ContextDisposedNotification(); | 713 CcTest::isolate()->ContextDisposedNotification(); |
| 714 CheckSurvivingGlobalObjectsCount(1); | 714 CheckSurvivingGlobalObjectsCount(2); |
| 715 } | 715 } |
| 716 | 716 |
| 717 | 717 |
| 718 TEST(DontLeakContextOnGetNotifier) { | 718 TEST(DontLeakContextOnGetNotifier) { |
| 719 HandleScope scope(CcTest::isolate()); | 719 HandleScope scope(CcTest::isolate()); |
| 720 Handle<Value> foo = String::NewFromUtf8(CcTest::isolate(), "foo"); | 720 Handle<Value> foo = String::NewFromUtf8(CcTest::isolate(), "foo"); |
| 721 LocalContext context(CcTest::isolate()); | 721 LocalContext context(CcTest::isolate()); |
| 722 context->SetSecurityToken(foo); | 722 context->SetSecurityToken(foo); |
| 723 CompileRun("var obj = {};"); | 723 CompileRun("var obj = {};"); |
| 724 Handle<Value> object = CompileRun("obj"); | 724 Handle<Value> object = CompileRun("obj"); |
| 725 { | 725 { |
| 726 HandleScope scope(CcTest::isolate()); | 726 HandleScope scope(CcTest::isolate()); |
| 727 LocalContext context2(CcTest::isolate()); | 727 LocalContext context2(CcTest::isolate()); |
| 728 context2->SetSecurityToken(foo); | 728 context2->SetSecurityToken(foo); |
| 729 context2->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "obj"), | 729 context2->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "obj"), |
| 730 object); | 730 object); |
| 731 CompileRun("Object.getNotifier(obj);"); | 731 CompileRun("Object.getNotifier(obj);"); |
| 732 } | 732 } |
| 733 | 733 |
| 734 CcTest::isolate()->ContextDisposedNotification(); | 734 CcTest::isolate()->ContextDisposedNotification(); |
| 735 CheckSurvivingGlobalObjectsCount(1); | 735 CheckSurvivingGlobalObjectsCount(2); |
| 736 } | 736 } |
| 737 | 737 |
| 738 | 738 |
| 739 TEST(DontLeakContextOnNotifierPerformChange) { | 739 TEST(DontLeakContextOnNotifierPerformChange) { |
| 740 HandleScope scope(CcTest::isolate()); | 740 HandleScope scope(CcTest::isolate()); |
| 741 Handle<Value> foo = String::NewFromUtf8(CcTest::isolate(), "foo"); | 741 Handle<Value> foo = String::NewFromUtf8(CcTest::isolate(), "foo"); |
| 742 LocalContext context(CcTest::isolate()); | 742 LocalContext context(CcTest::isolate()); |
| 743 context->SetSecurityToken(foo); | 743 context->SetSecurityToken(foo); |
| 744 CompileRun("var obj = {};"); | 744 CompileRun("var obj = {};"); |
| 745 Handle<Value> object = CompileRun("obj"); | 745 Handle<Value> object = CompileRun("obj"); |
| 746 Handle<Value> notifier = CompileRun("Object.getNotifier(obj)"); | 746 Handle<Value> notifier = CompileRun("Object.getNotifier(obj)"); |
| 747 { | 747 { |
| 748 HandleScope scope(CcTest::isolate()); | 748 HandleScope scope(CcTest::isolate()); |
| 749 LocalContext context2(CcTest::isolate()); | 749 LocalContext context2(CcTest::isolate()); |
| 750 context2->SetSecurityToken(foo); | 750 context2->SetSecurityToken(foo); |
| 751 context2->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "obj"), | 751 context2->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "obj"), |
| 752 object); | 752 object); |
| 753 context2->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "notifier"), | 753 context2->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "notifier"), |
| 754 notifier); | 754 notifier); |
| 755 CompileRun("var obj2 = {};" | 755 CompileRun("var obj2 = {};" |
| 756 "var notifier2 = Object.getNotifier(obj2);" | 756 "var notifier2 = Object.getNotifier(obj2);" |
| 757 "notifier2.performChange.call(" | 757 "notifier2.performChange.call(" |
| 758 "notifier, 'foo', function(){})"); | 758 "notifier, 'foo', function(){})"); |
| 759 } | 759 } |
| 760 | 760 |
| 761 CcTest::isolate()->ContextDisposedNotification(); | 761 CcTest::isolate()->ContextDisposedNotification(); |
| 762 CheckSurvivingGlobalObjectsCount(1); | 762 CheckSurvivingGlobalObjectsCount(2); |
| 763 } | 763 } |
| 764 | 764 |
| 765 | 765 |
| 766 static void ObserverCallback(const FunctionCallbackInfo<Value>& args) { | 766 static void ObserverCallback(const FunctionCallbackInfo<Value>& args) { |
| 767 *static_cast<int*>(Handle<External>::Cast(args.Data())->Value()) = | 767 *static_cast<int*>(Handle<External>::Cast(args.Data())->Value()) = |
| 768 Handle<Array>::Cast(args[0])->Length(); | 768 Handle<Array>::Cast(args[0])->Length(); |
| 769 } | 769 } |
| 770 | 770 |
| 771 | 771 |
| 772 TEST(ObjectObserveCallsCppFunction) { | 772 TEST(ObjectObserveCallsCppFunction) { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 878 i::Isolate* isolate = CcTest::i_isolate(); | 878 i::Isolate* isolate = CcTest::i_isolate(); |
| 879 i::HandleScope scope(isolate); | 879 i::HandleScope scope(isolate); |
| 880 LocalContext env; | 880 LocalContext env; |
| 881 int use_counts[v8::Isolate::kUseCounterFeatureCount] = {}; | 881 int use_counts[v8::Isolate::kUseCounterFeatureCount] = {}; |
| 882 global_use_counts = use_counts; | 882 global_use_counts = use_counts; |
| 883 CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback); | 883 CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback); |
| 884 CompileRun("var obj = {}"); | 884 CompileRun("var obj = {}"); |
| 885 CompileRun("Object.getNotifier(obj)"); | 885 CompileRun("Object.getNotifier(obj)"); |
| 886 CHECK_EQ(1, use_counts[v8::Isolate::kObjectObserve]); | 886 CHECK_EQ(1, use_counts[v8::Isolate::kObjectObserve]); |
| 887 } | 887 } |
| OLD | NEW |