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 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 HandleScope scope(CcTest::isolate()); | 651 HandleScope scope(CcTest::isolate()); |
652 LocalContext context2(CcTest::isolate()); | 652 LocalContext context2(CcTest::isolate()); |
653 context2->SetSecurityToken(foo); | 653 context2->SetSecurityToken(foo); |
654 context2->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "obj"), | 654 context2->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "obj"), |
655 object); | 655 object); |
656 CompileRun("function observer() {};" | 656 CompileRun("function observer() {};" |
657 "Object.observe(obj, observer, ['foo', 'bar', 'baz']);" | 657 "Object.observe(obj, observer, ['foo', 'bar', 'baz']);" |
658 "Object.unobserve(obj, observer);"); | 658 "Object.unobserve(obj, observer);"); |
659 } | 659 } |
660 | 660 |
661 v8::V8::ContextDisposedNotification(); | 661 CcTest::isolate()->ContextDisposedNotification(); |
662 CheckSurvivingGlobalObjectsCount(1); | 662 CheckSurvivingGlobalObjectsCount(1); |
663 } | 663 } |
664 | 664 |
665 | 665 |
666 TEST(DontLeakContextOnGetNotifier) { | 666 TEST(DontLeakContextOnGetNotifier) { |
667 HandleScope scope(CcTest::isolate()); | 667 HandleScope scope(CcTest::isolate()); |
668 Handle<Value> foo = String::NewFromUtf8(CcTest::isolate(), "foo"); | 668 Handle<Value> foo = String::NewFromUtf8(CcTest::isolate(), "foo"); |
669 LocalContext context(CcTest::isolate()); | 669 LocalContext context(CcTest::isolate()); |
670 context->SetSecurityToken(foo); | 670 context->SetSecurityToken(foo); |
671 CompileRun("var obj = {};"); | 671 CompileRun("var obj = {};"); |
672 Handle<Value> object = CompileRun("obj"); | 672 Handle<Value> object = CompileRun("obj"); |
673 { | 673 { |
674 HandleScope scope(CcTest::isolate()); | 674 HandleScope scope(CcTest::isolate()); |
675 LocalContext context2(CcTest::isolate()); | 675 LocalContext context2(CcTest::isolate()); |
676 context2->SetSecurityToken(foo); | 676 context2->SetSecurityToken(foo); |
677 context2->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "obj"), | 677 context2->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "obj"), |
678 object); | 678 object); |
679 CompileRun("Object.getNotifier(obj);"); | 679 CompileRun("Object.getNotifier(obj);"); |
680 } | 680 } |
681 | 681 |
682 v8::V8::ContextDisposedNotification(); | 682 CcTest::isolate()->ContextDisposedNotification(); |
683 CheckSurvivingGlobalObjectsCount(1); | 683 CheckSurvivingGlobalObjectsCount(1); |
684 } | 684 } |
685 | 685 |
686 | 686 |
687 TEST(DontLeakContextOnNotifierPerformChange) { | 687 TEST(DontLeakContextOnNotifierPerformChange) { |
688 HandleScope scope(CcTest::isolate()); | 688 HandleScope scope(CcTest::isolate()); |
689 Handle<Value> foo = String::NewFromUtf8(CcTest::isolate(), "foo"); | 689 Handle<Value> foo = String::NewFromUtf8(CcTest::isolate(), "foo"); |
690 LocalContext context(CcTest::isolate()); | 690 LocalContext context(CcTest::isolate()); |
691 context->SetSecurityToken(foo); | 691 context->SetSecurityToken(foo); |
692 CompileRun("var obj = {};"); | 692 CompileRun("var obj = {};"); |
693 Handle<Value> object = CompileRun("obj"); | 693 Handle<Value> object = CompileRun("obj"); |
694 Handle<Value> notifier = CompileRun("Object.getNotifier(obj)"); | 694 Handle<Value> notifier = CompileRun("Object.getNotifier(obj)"); |
695 { | 695 { |
696 HandleScope scope(CcTest::isolate()); | 696 HandleScope scope(CcTest::isolate()); |
697 LocalContext context2(CcTest::isolate()); | 697 LocalContext context2(CcTest::isolate()); |
698 context2->SetSecurityToken(foo); | 698 context2->SetSecurityToken(foo); |
699 context2->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "obj"), | 699 context2->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "obj"), |
700 object); | 700 object); |
701 context2->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "notifier"), | 701 context2->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "notifier"), |
702 notifier); | 702 notifier); |
703 CompileRun("var obj2 = {};" | 703 CompileRun("var obj2 = {};" |
704 "var notifier2 = Object.getNotifier(obj2);" | 704 "var notifier2 = Object.getNotifier(obj2);" |
705 "notifier2.performChange.call(" | 705 "notifier2.performChange.call(" |
706 "notifier, 'foo', function(){})"); | 706 "notifier, 'foo', function(){})"); |
707 } | 707 } |
708 | 708 |
709 v8::V8::ContextDisposedNotification(); | 709 CcTest::isolate()->ContextDisposedNotification(); |
710 CheckSurvivingGlobalObjectsCount(1); | 710 CheckSurvivingGlobalObjectsCount(1); |
711 } | 711 } |
OLD | NEW |