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 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 context2->Global() | 797 context2->Global() |
798 ->Set(v8::Isolate::GetCurrent()->GetCurrentContext(), v8_str("obj"), | 798 ->Set(v8::Isolate::GetCurrent()->GetCurrentContext(), v8_str("obj"), |
799 object) | 799 object) |
800 .FromJust(); | 800 .FromJust(); |
801 CompileRun("function observer() {};" | 801 CompileRun("function observer() {};" |
802 "Object.observe(obj, observer, ['foo', 'bar', 'baz']);" | 802 "Object.observe(obj, observer, ['foo', 'bar', 'baz']);" |
803 "Object.unobserve(obj, observer);"); | 803 "Object.unobserve(obj, observer);"); |
804 } | 804 } |
805 | 805 |
806 CcTest::isolate()->ContextDisposedNotification(); | 806 CcTest::isolate()->ContextDisposedNotification(); |
807 CheckSurvivingGlobalObjectsCount(1); | 807 CheckSurvivingGlobalObjectsCount(0); |
808 } | 808 } |
809 | 809 |
810 | 810 |
811 TEST(DontLeakContextOnGetNotifier) { | 811 TEST(DontLeakContextOnGetNotifier) { |
812 HandleScope scope(CcTest::isolate()); | 812 HandleScope scope(CcTest::isolate()); |
813 Local<Value> foo = v8_str("foo"); | 813 Local<Value> foo = v8_str("foo"); |
814 LocalContext context(CcTest::isolate()); | 814 LocalContext context(CcTest::isolate()); |
815 context->SetSecurityToken(foo); | 815 context->SetSecurityToken(foo); |
816 CompileRun("var obj = {};"); | 816 CompileRun("var obj = {};"); |
817 Local<Value> object = CompileRun("obj"); | 817 Local<Value> object = CompileRun("obj"); |
818 { | 818 { |
819 HandleScope scope(CcTest::isolate()); | 819 HandleScope scope(CcTest::isolate()); |
820 LocalContext context2(CcTest::isolate()); | 820 LocalContext context2(CcTest::isolate()); |
821 context2->SetSecurityToken(foo); | 821 context2->SetSecurityToken(foo); |
822 context2->Global() | 822 context2->Global() |
823 ->Set(v8::Isolate::GetCurrent()->GetCurrentContext(), v8_str("obj"), | 823 ->Set(v8::Isolate::GetCurrent()->GetCurrentContext(), v8_str("obj"), |
824 object) | 824 object) |
825 .FromJust(); | 825 .FromJust(); |
826 CompileRun("Object.getNotifier(obj);"); | 826 CompileRun("Object.getNotifier(obj);"); |
827 } | 827 } |
828 | 828 |
829 CcTest::isolate()->ContextDisposedNotification(); | 829 CcTest::isolate()->ContextDisposedNotification(); |
830 CheckSurvivingGlobalObjectsCount(1); | 830 CheckSurvivingGlobalObjectsCount(0); |
831 } | 831 } |
832 | 832 |
833 | 833 |
834 TEST(DontLeakContextOnNotifierPerformChange) { | 834 TEST(DontLeakContextOnNotifierPerformChange) { |
835 HandleScope scope(CcTest::isolate()); | 835 HandleScope scope(CcTest::isolate()); |
836 Local<Value> foo = v8_str("foo"); | 836 Local<Value> foo = v8_str("foo"); |
837 LocalContext context(CcTest::isolate()); | 837 LocalContext context(CcTest::isolate()); |
838 context->SetSecurityToken(foo); | 838 context->SetSecurityToken(foo); |
839 CompileRun("var obj = {};"); | 839 CompileRun("var obj = {};"); |
840 Local<Value> object = CompileRun("obj"); | 840 Local<Value> object = CompileRun("obj"); |
(...skipping 10 matching lines...) Expand all Loading... |
851 ->Set(v8::Isolate::GetCurrent()->GetCurrentContext(), | 851 ->Set(v8::Isolate::GetCurrent()->GetCurrentContext(), |
852 v8_str("notifier"), notifier) | 852 v8_str("notifier"), notifier) |
853 .FromJust(); | 853 .FromJust(); |
854 CompileRun("var obj2 = {};" | 854 CompileRun("var obj2 = {};" |
855 "var notifier2 = Object.getNotifier(obj2);" | 855 "var notifier2 = Object.getNotifier(obj2);" |
856 "notifier2.performChange.call(" | 856 "notifier2.performChange.call(" |
857 "notifier, 'foo', function(){})"); | 857 "notifier, 'foo', function(){})"); |
858 } | 858 } |
859 | 859 |
860 CcTest::isolate()->ContextDisposedNotification(); | 860 CcTest::isolate()->ContextDisposedNotification(); |
861 CheckSurvivingGlobalObjectsCount(1); | 861 CheckSurvivingGlobalObjectsCount(0); |
862 } | 862 } |
863 | 863 |
864 | 864 |
865 static void ObserverCallback(const FunctionCallbackInfo<Value>& args) { | 865 static void ObserverCallback(const FunctionCallbackInfo<Value>& args) { |
866 *static_cast<int*>(Local<External>::Cast(args.Data())->Value()) = | 866 *static_cast<int*>(Local<External>::Cast(args.Data())->Value()) = |
867 Local<Array>::Cast(args[0])->Length(); | 867 Local<Array>::Cast(args[0])->Length(); |
868 } | 868 } |
869 | 869 |
870 | 870 |
871 TEST(ObjectObserveCallsCppFunction) { | 871 TEST(ObjectObserveCallsCppFunction) { |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1037 v8::Isolate::GetCurrent()->GetCurrentContext()) | 1037 v8::Isolate::GetCurrent()->GetCurrentContext()) |
1038 .ToLocalChecked(); | 1038 .ToLocalChecked(); |
1039 env->Global() | 1039 env->Global() |
1040 ->Set(v8::Isolate::GetCurrent()->GetCurrentContext(), v8_str("obj"), | 1040 ->Set(v8::Isolate::GetCurrent()->GetCurrentContext(), v8_str("obj"), |
1041 new_instance) | 1041 new_instance) |
1042 .FromJust(); | 1042 .FromJust(); |
1043 v8::TryCatch try_catch(isolate); | 1043 v8::TryCatch try_catch(isolate); |
1044 CompileRun("Object.getNotifier(obj)"); | 1044 CompileRun("Object.getNotifier(obj)"); |
1045 CHECK(try_catch.HasCaught()); | 1045 CHECK(try_catch.HasCaught()); |
1046 } | 1046 } |
OLD | NEW |