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

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

Issue 1346813002: Disallow Object.observe calls on access-checked objects (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add new error message and tests Created 5 years, 3 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/runtime-object.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 37dde078fe97762bb0d720da3522d1f3194de330..07cc772df0eba845e7f489dbdcb7bf1960490f80 100644
--- a/test/cctest/test-object-observe.cc
+++ b/test/cctest/test-object-observe.cc
@@ -885,3 +885,39 @@ TEST(UseCountObjectGetNotifier) {
CompileRun("Object.getNotifier(obj)");
CHECK_EQ(1, use_counts[v8::Isolate::kObjectObserve]);
}
+
+
+static bool NamedAccessCheckAlwaysAllow(Local<v8::Object> global,
+ Local<v8::Value> name,
+ v8::AccessType type,
+ Local<Value> data) {
+ return true;
+}
+
+
+TEST(DisallowObserveAccessCheckedObject) {
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ LocalContext env;
+ v8::Local<v8::ObjectTemplate> object_template =
+ v8::ObjectTemplate::New(isolate);
+ object_template->SetAccessCheckCallbacks(NamedAccessCheckAlwaysAllow, NULL);
+ env->Global()->Set(v8_str("obj"), object_template->NewInstance());
+ v8::TryCatch try_catch(isolate);
+ CompileRun("Object.observe(obj, function(){})");
+ CHECK(try_catch.HasCaught());
+}
+
+
+TEST(DisallowGetNotifierAccessCheckedObject) {
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ LocalContext env;
+ v8::Local<v8::ObjectTemplate> object_template =
+ v8::ObjectTemplate::New(isolate);
+ object_template->SetAccessCheckCallbacks(NamedAccessCheckAlwaysAllow, NULL);
+ env->Global()->Set(v8_str("obj"), object_template->NewInstance());
+ v8::TryCatch try_catch(isolate);
+ CompileRun("Object.getNotifier(obj)");
+ CHECK(try_catch.HasCaught());
+}
« no previous file with comments | « src/runtime/runtime-object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698