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 2449163004: Allow immutable prototype templates to inherit (Closed)
Patch Set: Fix up test 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/api-natives.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 92fee1715a49e9b6b43987432ca7bae2b27a3f5a..585cf6ac72c7d826e3e36186fd683b8082e41d22 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -25947,3 +25947,41 @@ TEST(EvalInAccessCheckedContext) {
CHECK_EQ(42, x_value->Int32Value(context1).FromJust());
context1->Exit();
}
+
+THREADED_TEST(ImmutableProtoWithParent) {
+ LocalContext context;
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::HandleScope handle_scope(isolate);
+
+ Local<v8::FunctionTemplate> parent = v8::FunctionTemplate::New(isolate);
+
+ Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
+ templ->Inherit(parent);
+ templ->PrototypeTemplate()->SetImmutableProto();
+
+ Local<v8::Function> function =
+ templ->GetFunction(context.local()).ToLocalChecked();
+ Local<v8::Object> instance =
+ function->NewInstance(context.local()).ToLocalChecked();
+ Local<v8::Object> prototype =
+ instance->Get(context.local(), v8_str("__proto__"))
+ .ToLocalChecked()
+ ->ToObject(context.local())
+ .ToLocalChecked();
+
+ // Look up the prototype
+ Local<v8::Value> original_proto =
+ prototype->Get(context.local(), v8_str("__proto__")).ToLocalChecked();
+
+ // Setting the prototype (e.g., to null) throws
+ CHECK(
+ prototype->SetPrototype(context.local(), v8::Null(isolate)).IsNothing());
+
+ // The original prototype is still there
+ Local<Value> new_proto =
+ prototype->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 | « src/api-natives.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698