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

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

Side-by-side diff isn't available for this file because of its large size.
Issue 2474843003: Allow the global object to be frozen through the global template (Closed)
Patch Set: Nit cleanup Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
Download patch
« no previous file with comments | « src/objects.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-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 8bf1d4c1e08b57dc477372476a3a7000e23df9d2..38a9f45e2ff85a6d9b77210102b28a224732f755 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -25978,3 +25978,44 @@ TEST(InternalFieldsOnGlobalProxy) {
v8::Local<v8::Object> global = context->Global();
CHECK_EQ(1, global->InternalFieldCount());
}
+
+THREADED_TEST(ImmutableProtoGlobal) {
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope handle_scope(isolate);
+ Local<ObjectTemplate> global_template = ObjectTemplate::New(isolate);
+ global_template->SetImmutableProto();
+ v8::Local<Context> context = Context::New(isolate, 0, global_template);
+ Context::Scope context_scope(context);
+ v8::Local<Value> result = CompileRun(
+ "global = this;"
+ "(function() {"
+ " try {"
+ " global.__proto__ = {};"
+ " return 0;"
+ " } catch (e) {"
+ " return 1;"
+ " }"
+ "})()");
+ CHECK(result->Equals(context, v8::Integer::New(CcTest::isolate(), 1))
+ .FromJust());
+}
+
+THREADED_TEST(MutableProtoGlobal) {
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope handle_scope(isolate);
+ Local<ObjectTemplate> global_template = ObjectTemplate::New(isolate);
+ v8::Local<Context> context = Context::New(isolate, 0, global_template);
+ Context::Scope context_scope(context);
+ v8::Local<Value> result = CompileRun(
+ "global = this;"
+ "(function() {"
+ " try {"
+ " global.__proto__ = {};"
+ " return 0;"
+ " } catch (e) {"
+ " return 1;"
+ " }"
+ "})()");
+ CHECK(result->Equals(context, v8::Integer::New(CcTest::isolate(), 0))
+ .FromJust());
+}
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698