OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 25330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
25341 } | 25341 } |
25342 | 25342 |
25343 TEST(PrivateForApiIsNumber) { | 25343 TEST(PrivateForApiIsNumber) { |
25344 LocalContext context; | 25344 LocalContext context; |
25345 v8::Isolate* isolate = CcTest::isolate(); | 25345 v8::Isolate* isolate = CcTest::isolate(); |
25346 v8::HandleScope scope(isolate); | 25346 v8::HandleScope scope(isolate); |
25347 | 25347 |
25348 // Shouldn't crash. | 25348 // Shouldn't crash. |
25349 v8::Private::ForApi(isolate, v8_str("42")); | 25349 v8::Private::ForApi(isolate, v8_str("42")); |
25350 } | 25350 } |
| 25351 |
| 25352 THREADED_TEST(ImmutableProto) { |
| 25353 LocalContext context; |
| 25354 v8::Isolate* isolate = context->GetIsolate(); |
| 25355 v8::HandleScope handle_scope(isolate); |
| 25356 |
| 25357 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); |
| 25358 templ->InstanceTemplate()->SetImmutableProto(); |
| 25359 |
| 25360 Local<v8::Object> object = templ->GetFunction(context.local()) |
| 25361 .ToLocalChecked() |
| 25362 ->NewInstance(context.local()) |
| 25363 .ToLocalChecked(); |
| 25364 |
| 25365 // Look up the prototype |
| 25366 Local<v8::Value> original_proto = |
| 25367 object->Get(context.local(), v8_str("__proto__")).ToLocalChecked(); |
| 25368 |
| 25369 // Setting the prototype (e.g., to null) throws |
| 25370 CHECK(object->SetPrototype(context.local(), v8::Null(isolate)).IsNothing()); |
| 25371 |
| 25372 // The original prototype is still there |
| 25373 Local<Value> new_proto = |
| 25374 object->Get(context.local(), v8_str("__proto__")).ToLocalChecked(); |
| 25375 CHECK(new_proto->IsObject()); |
| 25376 CHECK(new_proto.As<v8::Object>() |
| 25377 ->Equals(context.local(), original_proto) |
| 25378 .FromJust()); |
| 25379 } |
OLD | NEW |