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

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

Issue 6499013: Add access check when Object.keys is called on the global js proxy (fixes iss... (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 5599 matching lines...) Expand 10 before | Expand all | Expand 10 after
5610 "return true;})()"); 5610 "return true;})()");
5611 CHECK(value->IsTrue()); 5611 CHECK(value->IsTrue());
5612 5612
5613 context1->Exit(); 5613 context1->Exit();
5614 context0->Exit(); 5614 context0->Exit();
5615 context1.Dispose(); 5615 context1.Dispose();
5616 context0.Dispose(); 5616 context0.Dispose();
5617 } 5617 }
5618 5618
5619 5619
5620 // This is a regression test for issue 1154.
5621 TEST(AccessControlObjectKeys) {
5622 v8::HandleScope handle_scope;
5623 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
5624
5625 global_template->SetAccessCheckCallbacks(NamedAccessBlocker,
5626 IndexedAccessBlocker);
5627
5628 // Add an accessor that is not accessible by cross-domain JS code.
5629 global_template->SetAccessor(v8_str("blocked_prop"),
5630 UnreachableGetter, UnreachableSetter,
5631 v8::Handle<Value>(),
5632 v8::DEFAULT);
5633
5634 // Create an environment
5635 v8::Persistent<Context> context0 = Context::New(NULL, global_template);
5636 context0->Enter();
5637
5638 v8::Handle<v8::Object> global0 = context0->Global();
5639
5640 v8::Persistent<Context> context1 = Context::New();
5641 context1->Enter();
5642 v8::Handle<v8::Object> global1 = context1->Global();
5643 global1->Set(v8_str("other"), global0);
5644
5645 ExpectTrue("Object.keys(other).indexOf('blocked_prop') == -1");
5646 }
5647
5648
5620 static bool GetOwnPropertyNamesNamedBlocker(Local<v8::Object> global, 5649 static bool GetOwnPropertyNamesNamedBlocker(Local<v8::Object> global,
5621 Local<Value> name, 5650 Local<Value> name,
5622 v8::AccessType type, 5651 v8::AccessType type,
5623 Local<Value> data) { 5652 Local<Value> data) {
5624 return false; 5653 return false;
5625 } 5654 }
5626 5655
5627 5656
5628 static bool GetOwnPropertyNamesIndexedBlocker(Local<v8::Object> global, 5657 static bool GetOwnPropertyNamesIndexedBlocker(Local<v8::Object> global,
5629 uint32_t key, 5658 uint32_t key,
(...skipping 7054 matching lines...) Expand 10 before | Expand all | Expand 10 after
12684 v8::Handle<v8::Function> define_property = 12713 v8::Handle<v8::Function> define_property =
12685 CompileRun("(function() {" 12714 CompileRun("(function() {"
12686 " Object.defineProperty(" 12715 " Object.defineProperty("
12687 " this," 12716 " this,"
12688 " 1," 12717 " 1,"
12689 " { configurable: true, enumerable: true, value: 3 });" 12718 " { configurable: true, enumerable: true, value: 3 });"
12690 "})").As<Function>(); 12719 "})").As<Function>();
12691 context->DetachGlobal(); 12720 context->DetachGlobal();
12692 define_property->Call(proxy, 0, NULL); 12721 define_property->Call(proxy, 0, NULL);
12693 } 12722 }
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