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

Unified Diff: test/cctest/test-object-observe.cc

Issue 251583005: Add a test that JSGlobalProxy properly causes Object.observe to trigger access check callbacks (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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-object-observe.cc
diff --git a/test/cctest/test-object-observe.cc b/test/cctest/test-object-observe.cc
index a8cbaf6ea75a49902e63bd75607fdc8860c62ca2..0ade6aa04f9395c152f8c10e3416461a90b4a4c1 100644
--- a/test/cctest/test-object-observe.cc
+++ b/test/cctest/test-object-observe.cc
@@ -712,6 +712,46 @@ TEST(AccessCheckDisallowApiModifications) {
}
+static bool NamedAccessAlwaysDisallowed(Local<Object>, Local<Value>, AccessType,
+ Local<Value>) {
+ return false;
+}
+
+
+static bool IndexedAccessAlwaysDisallowed(Local<Object>, uint32_t, AccessType,
+ Local<Value>) {
+ return false;
+}
+
+
+TEST(AccessCheckedGlobalProxy) {
+ HandleScope scope(CcTest::isolate());
+ Handle<ObjectTemplate> global_template =
+ ObjectTemplate::New(CcTest::isolate());
+ global_template->SetAccessCheckCallbacks(NamedAccessAlwaysDisallowed,
+ IndexedAccessAlwaysDisallowed);
+ Handle<Context> context =
+ Context::New(CcTest::isolate(), NULL, global_template);
+ Handle<Object> global_proxy = context->Global();
+ {
+ LocalContext context2(CcTest::isolate());
+ context2->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "global"),
+ global_proxy);
+ CompileRun("var records = null;"
+ "var observer = function(r) { records = r };"
+ "Object.observe(global, observer);");
+
+ {
+ Context::Scope context_scope(context);
+ CompileRun("foo = 42");
+ CHECK_EQ(42, CompileRun("foo")->Int32Value());
+ }
+ CHECK(CompileRun("records")->IsNull());
+ CHECK(CompileRun("global.foo")->IsUndefined());
+ }
+}
+
+
TEST(HiddenPropertiesLeakage) {
HandleScope scope(CcTest::isolate());
LocalContext context(CcTest::isolate());
« 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