Reviewers: Toon Verwaest,

Message:
Please take a look. This change depends on
https://codereview.chromium.org/18225006/

Description:
Test case for missing access checks in object observe.

BUG=v8:2778

Please review this at https://codereview.chromium.org/18794003/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M test/cctest/test-api.cc


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


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to