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

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

Issue 2108203002: Implement immutable prototype chains (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: IsImmutableProto Created 4 years, 6 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
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 5624e3fbca635c9b42e6079db6bd25441a3ba3af..7ca6b9cdb3858303a0a011bbcb03ae02e81afc59 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -25348,3 +25348,32 @@ TEST(PrivateForApiIsNumber) {
// Shouldn't crash.
v8::Private::ForApi(isolate, v8_str("42"));
}
+
+THREADED_TEST(ImmutableProto) {
+ LocalContext context;
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::HandleScope handle_scope(isolate);
+
+ Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
+ templ->InstanceTemplate()->SetImmutableProto();
+
+ Local<v8::Object> object = templ->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
+
+ // Look up the prototype
+ Local<v8::Value> original_proto =
+ object->Get(context.local(), v8_str("__proto__")).ToLocalChecked();
+
+ // Setting the prototype (e.g., to null) throws
+ CHECK(object->SetPrototype(context.local(), v8::Null(isolate)).IsNothing());
+
+ // The original prototype is still there
+ Local<Value> new_proto =
+ object->Get(context.local(), v8_str("__proto__")).ToLocalChecked();
+ CHECK(new_proto->IsObject());
+ CHECK(new_proto.As<v8::Object>()
+ ->Equals(context.local(), original_proto)
+ .FromJust());
+}
« no previous file with comments | « test/cctest/interpreter/bytecode_expectations/Generators.golden ('k') | test/mjsunit/es6/proxies-global-reference.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698