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

Unified Diff: test/cctest/test-api.cc

Issue 18794003: Test case for missing access checks in object observe. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 8d9b32b05c889fbb14c562ac82705e7620e98134..f01ee34af7126fd6a227e897dcf04b51cdcfeb13 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -19787,4 +19787,39 @@ TEST(JSONStringifyAccessCheck) {
}
+TEST(Bug2778) {
+ // Check that Object.observe includes access check.
+ i::FLAG_harmony_observation = true;
+ v8::V8::Initialize();
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
+ // Create an ObjectTemplate for global objects and install access
+ // check callbacks that will block access.
+ v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
+ global_template->SetAccessCheckCallbacks(NamedAccessAlwaysBlocked,
+ IndexAccessAlwaysBlocked);
+
+ // Create a context and set an x property on it's global object.
+ LocalContext outer_context(NULL, global_template);
+ v8::Handle<v8::Object> outer_global = outer_context->Global();
+ outer_global->Set(v8_str("x"), v8_num(42));
+
+ // Enter a new context.
+ v8::Handle<v8::Context> inner_context = v8::Context::New(isolate);
+ { v8::Context::Scope inner(inner_context);
+ v8::Handle<v8::Object> inner_global = inner_context->Global();
+ inner_global->Set(v8_str("other"), outer_global);
+ v8::Handle<v8::FunctionTemplate> unreachable =
+ v8::FunctionTemplate::New(UnreachableCallback);
+ inner_global->Set(v8_str("unreachable"), unreachable->GetFunction());
+ ExpectUndefined("other.x"); // Verify that access checks are in place.
+ CompileRun("Object.observe(other, unreachable);"); // Install observer.
+ }
+
+ ExpectInt32("x", 42);
+ // This must not be observable by the observer set up in the inner context.
+ CompileRun("var a = 123;");
+}
+
+
#endif // WIN32
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698