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

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

Issue 11802003: Add API for access checks on observed objects (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 11 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 | « src/runtime.cc ('k') | 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 821d153f3d21435061a782d06e4bcc17fb673bd9..04c552610be82575fc4f937a01125d32df7bdca3 100644
--- a/test/cctest/test-object-observe.cc
+++ b/test/cctest/test-object-observe.cc
@@ -219,6 +219,7 @@ TEST(ObjectHashTableGrowth) {
CHECK(CompileRun("ran")->BooleanValue());
}
+
TEST(GlobalObjectObservation) {
HarmonyIsolate isolate;
HandleScope scope;
@@ -397,3 +398,53 @@ TEST(HiddenPrototypeObservation) {
};
EXPECT_RECORDS(CompileRun("records"), expected_records3);
}
+
+
+static bool NamedAccessAlwaysAllowed(Local<Object> host, Local<Value> key,
+ AccessType type, Local<Value> data) {
+ return true;
+}
+
+static bool IndexedAccessAlwaysAllowed(Local<Object> host, uint32_t index,
+ AccessType type, Local<Value> data) {
+ return true;
+}
+
+static bool ObservationAlwaysDisallowed(Local<Object> host, Local<Value> data) {
+ return false;
+}
+
+TEST(ObserveWithAccessChecks) {
+ HarmonyIsolate isolate;
+ HandleScope scope;
+ LocalContext context;
+ Handle<ObjectTemplate> tmpl = ObjectTemplate::New();
+ tmpl->SetAccessCheckCallbacks(NamedAccessAlwaysAllowed,
+ IndexedAccessAlwaysAllowed,
+ ObservationAlwaysDisallowed);
+ Handle<Object> instance = tmpl->NewInstance();
+ context->Global()->Set(String::New("obj"), instance);
+ TryCatch try_catch;
+ CompileRun("var records = null;"
+ "Object.observe(obj, function(r) { records = r });");
+ CHECK(try_catch.HasCaught());
+ CompileRun("obj.foo = 'bar'");
+ CHECK(CompileRun("records")->IsNull());
+}
+
+TEST(ObserveWithAccessChecksDeprecatedAPI) {
+ HarmonyIsolate isolate;
+ HandleScope scope;
+ LocalContext context;
+ Handle<ObjectTemplate> tmpl = ObjectTemplate::New();
+ tmpl->SetAccessCheckCallbacks(NamedAccessAlwaysAllowed,
+ IndexedAccessAlwaysAllowed);
+ Handle<Object> instance = tmpl->NewInstance();
+ context->Global()->Set(String::New("obj"), instance);
+ TryCatch try_catch;
+ CompileRun("var records = null;"
+ "Object.observe(obj, function(r) { records = r });");
+ CHECK(try_catch.HasCaught());
+ CompileRun("obj.foo = 'bar'");
+ CHECK(CompileRun("records")->IsNull());
+}
« 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