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

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: Format 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
« src/bootstrapper.cc ('K') | « 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 ee202c2e997216fcf68d285b3450bbfbc4ac60f7..3c81e43313d69d9b16dfbeaecb419dd1ff52a67f 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -25988,3 +25988,44 @@ TEST(InternalFieldsOnGlobalProxy) {
v8::Local<v8::Object> global = context->Global();
CHECK_EQ(v8::Context::kProxyInternalFieldCount, 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());
+}
« src/bootstrapper.cc ('K') | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698