Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: test/cctest/test-api.cc

Issue 6534019: Add access checks to Object.preventExtensions + add regression test for 1027.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. 1 // Copyright 2007-2009 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 5634 matching lines...) Expand 10 before | Expand all | Expand 10 after
5645 "return true;})()"); 5645 "return true;})()");
5646 CHECK(value->IsTrue()); 5646 CHECK(value->IsTrue());
5647 5647
5648 context1->Exit(); 5648 context1->Exit();
5649 context0->Exit(); 5649 context0->Exit();
5650 context1.Dispose(); 5650 context1.Dispose();
5651 context0.Dispose(); 5651 context0.Dispose();
5652 } 5652 }
5653 5653
5654 5654
5655 // This is a regression test for issue 1154. 5655 TEST(AccessControlES5) {
5656 TEST(AccessControlObjectKeys) {
5657 v8::HandleScope handle_scope; 5656 v8::HandleScope handle_scope;
5658 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); 5657 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
5659 5658
5660 global_template->SetAccessCheckCallbacks(NamedAccessBlocker, 5659 global_template->SetAccessCheckCallbacks(NamedAccessBlocker,
5661 IndexedAccessBlocker); 5660 IndexedAccessBlocker);
5662 5661
5663 // Add an accessor that is not accessible by cross-domain JS code. 5662 // Add an accessor that is not accessible by cross-domain JS code.
5664 global_template->SetAccessor(v8_str("blocked_prop"), 5663 global_template->SetAccessor(v8_str("blocked_prop"),
5665 UnreachableGetter, UnreachableSetter, 5664 UnreachableGetter, UnreachableSetter,
5666 v8::Handle<Value>(), 5665 v8::Handle<Value>(),
5667 v8::DEFAULT); 5666 v8::DEFAULT);
5668 5667
5669 // Create an environment 5668 // Create an environment
5670 v8::Persistent<Context> context0 = Context::New(NULL, global_template); 5669 v8::Persistent<Context> context0 = Context::New(NULL, global_template);
5671 context0->Enter(); 5670 context0->Enter();
5672 5671
5673 v8::Handle<v8::Object> global0 = context0->Global(); 5672 v8::Handle<v8::Object> global0 = context0->Global();
5674 5673
5675 v8::Persistent<Context> context1 = Context::New(); 5674 v8::Persistent<Context> context1 = Context::New();
5676 context1->Enter(); 5675 context1->Enter();
5677 v8::Handle<v8::Object> global1 = context1->Global(); 5676 v8::Handle<v8::Object> global1 = context1->Global();
5678 global1->Set(v8_str("other"), global0); 5677 global1->Set(v8_str("other"), global0);
5679 5678
5679 // Regression test for issue 1154.
5680 ExpectTrue("Object.keys(other).indexOf('blocked_prop') == -1"); 5680 ExpectTrue("Object.keys(other).indexOf('blocked_prop') == -1");
5681
5682 ExpectUndefined("other.blocked_prop");
5683
5684 // Regression test for issue 1027.
5685 CompileRun("Object.defineProperty(\n"
5686 " other, 'blocked_prop', {configurable: false})");
5687 ExpectUndefined("other.blocked_prop");
5688 ExpectUndefined(
5689 "Object.getOwnPropertyDescriptor(other, 'blocked_prop')");
5690
5691 // Regression test ofr issue 1171.
antonm 2011/02/18 10:31:10 nit: ofr => for
5692 ExpectTrue("Object.isExtensible(other)");
5693 CompileRun("Object.preventExtensions(other)");
5694 ExpectTrue("Object.isExtensible(other)");
5695
5696 // Object.seal and Object.freeze.
5697 CompileRun("Object.freeze(other)");
5698 ExpectTrue("Object.isExtensible(other)");
5699
5700 CompileRun("Object.seal(other)");
5701 ExpectTrue("Object.isExtensible(other)");
5681 } 5702 }
5682 5703
5683 5704
5684 static bool GetOwnPropertyNamesNamedBlocker(Local<v8::Object> global, 5705 static bool GetOwnPropertyNamesNamedBlocker(Local<v8::Object> global,
5685 Local<Value> name, 5706 Local<Value> name,
5686 v8::AccessType type, 5707 v8::AccessType type,
5687 Local<Value> data) { 5708 Local<Value> data) {
5688 return false; 5709 return false;
5689 } 5710 }
5690 5711
(...skipping 7075 matching lines...) Expand 10 before | Expand all | Expand 10 after
12766 v8::Handle<v8::Function> define_property = 12787 v8::Handle<v8::Function> define_property =
12767 CompileRun("(function() {" 12788 CompileRun("(function() {"
12768 " Object.defineProperty(" 12789 " Object.defineProperty("
12769 " this," 12790 " this,"
12770 " 1," 12791 " 1,"
12771 " { configurable: true, enumerable: true, value: 3 });" 12792 " { configurable: true, enumerable: true, value: 3 });"
12772 "})").As<Function>(); 12793 "})").As<Function>();
12773 context->DetachGlobal(); 12794 context->DetachGlobal();
12774 define_property->Call(proxy, 0, NULL); 12795 define_property->Call(proxy, 0, NULL);
12775 } 12796 }
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698