| 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 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 const RecordExpectation expected_records2[] = { | 705 const RecordExpectation expected_records2[] = { |
| 706 { instance, "add", "5", Handle<Value>() }, | 706 { instance, "add", "5", Handle<Value>() }, |
| 707 { instance, "add", "foo", Handle<Value>() } | 707 { instance, "add", "foo", Handle<Value>() } |
| 708 }; | 708 }; |
| 709 EXPECT_RECORDS(CompileRun("records2"), expected_records2); | 709 EXPECT_RECORDS(CompileRun("records2"), expected_records2); |
| 710 } | 710 } |
| 711 CHECK(CompileRun("records")->IsNull()); | 711 CHECK(CompileRun("records")->IsNull()); |
| 712 } | 712 } |
| 713 | 713 |
| 714 | 714 |
| 715 static bool NamedAccessAlwaysDisallowed(Local<Object>, Local<Value>, AccessType, |
| 716 Local<Value>) { |
| 717 return false; |
| 718 } |
| 719 |
| 720 |
| 721 static bool IndexedAccessAlwaysDisallowed(Local<Object>, uint32_t, AccessType, |
| 722 Local<Value>) { |
| 723 return false; |
| 724 } |
| 725 |
| 726 |
| 727 TEST(AccessCheckedGlobalProxy) { |
| 728 HandleScope scope(CcTest::isolate()); |
| 729 Handle<ObjectTemplate> global_template = |
| 730 ObjectTemplate::New(CcTest::isolate()); |
| 731 global_template->SetAccessCheckCallbacks(NamedAccessAlwaysDisallowed, |
| 732 IndexedAccessAlwaysDisallowed); |
| 733 Handle<Context> context = |
| 734 Context::New(CcTest::isolate(), NULL, global_template); |
| 735 Handle<Object> global_proxy = context->Global(); |
| 736 { |
| 737 LocalContext context2(CcTest::isolate()); |
| 738 context2->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "global"), |
| 739 global_proxy); |
| 740 CompileRun("var records = null;" |
| 741 "var observer = function(r) { records = r };" |
| 742 "Object.observe(global, observer);"); |
| 743 |
| 744 { |
| 745 Context::Scope context_scope(context); |
| 746 CompileRun("foo = 42"); |
| 747 CHECK_EQ(42, CompileRun("foo")->Int32Value()); |
| 748 } |
| 749 CHECK(CompileRun("records")->IsNull()); |
| 750 CHECK(CompileRun("global.foo")->IsUndefined()); |
| 751 } |
| 752 } |
| 753 |
| 754 |
| 715 TEST(HiddenPropertiesLeakage) { | 755 TEST(HiddenPropertiesLeakage) { |
| 716 HandleScope scope(CcTest::isolate()); | 756 HandleScope scope(CcTest::isolate()); |
| 717 LocalContext context(CcTest::isolate()); | 757 LocalContext context(CcTest::isolate()); |
| 718 CompileRun("var obj = {};" | 758 CompileRun("var obj = {};" |
| 719 "var records = null;" | 759 "var records = null;" |
| 720 "var observer = function(r) { records = r };" | 760 "var observer = function(r) { records = r };" |
| 721 "Object.observe(obj, observer);"); | 761 "Object.observe(obj, observer);"); |
| 722 Handle<Value> obj = | 762 Handle<Value> obj = |
| 723 context->Global()->Get(String::NewFromUtf8(CcTest::isolate(), "obj")); | 763 context->Global()->Get(String::NewFromUtf8(CcTest::isolate(), "obj")); |
| 724 Handle<Object>::Cast(obj) | 764 Handle<Object>::Cast(obj) |
| 725 ->SetHiddenValue(String::NewFromUtf8(CcTest::isolate(), "foo"), | 765 ->SetHiddenValue(String::NewFromUtf8(CcTest::isolate(), "foo"), |
| 726 Null(CcTest::isolate())); | 766 Null(CcTest::isolate())); |
| 727 CompileRun(""); // trigger delivery | 767 CompileRun(""); // trigger delivery |
| 728 CHECK(CompileRun("records")->IsNull()); | 768 CHECK(CompileRun("records")->IsNull()); |
| 729 } | 769 } |
| OLD | NEW |