OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "testing/gtest/include/gtest/gtest.h" |
| 6 |
| 7 #include "include/v8.h" |
| 8 #include "test/unittests/test-utils.h" |
| 9 |
| 10 namespace v8 { |
| 11 |
| 12 typedef TestWithIsolate RemoteObjectTest; |
| 13 |
| 14 namespace { |
| 15 |
| 16 bool AccessCheck(Local<Context> accessing_context, |
| 17 Local<Object> accessed_object, Local<Value> data) { |
| 18 return false; |
| 19 } |
| 20 |
| 21 void NamedGetter(Local<Name> property, |
| 22 const PropertyCallbackInfo<Value>& info) {} |
| 23 |
| 24 void Constructor(const FunctionCallbackInfo<Value>& info) { |
| 25 ASSERT_TRUE(info.IsConstructCall()); |
| 26 } |
| 27 |
| 28 } // namespace |
| 29 |
| 30 TEST_F(RemoteObjectTest, RemoteContextInstanceChecks) { |
| 31 Local<FunctionTemplate> parent_template = |
| 32 FunctionTemplate::New(isolate(), Constructor); |
| 33 |
| 34 Local<FunctionTemplate> constructor_template = |
| 35 FunctionTemplate::New(isolate(), Constructor); |
| 36 constructor_template->InstanceTemplate()->SetAccessCheckCallbackAndHandler( |
| 37 AccessCheck, NamedPropertyHandlerConfiguration(NamedGetter), |
| 38 IndexedPropertyHandlerConfiguration()); |
| 39 constructor_template->Inherit(parent_template); |
| 40 |
| 41 Local<Object> remote_context = |
| 42 Context::NewRemoteContext(isolate(), |
| 43 constructor_template->InstanceTemplate()) |
| 44 .ToLocalChecked(); |
| 45 EXPECT_TRUE(parent_template->HasInstance(remote_context)); |
| 46 EXPECT_TRUE(constructor_template->HasInstance(remote_context)); |
| 47 |
| 48 EXPECT_EQ(remote_context, |
| 49 remote_context->FindInstanceInPrototypeChain(parent_template)); |
| 50 EXPECT_EQ(remote_context, |
| 51 remote_context->FindInstanceInPrototypeChain(constructor_template)); |
| 52 } |
| 53 |
| 54 } // namespace v8 |
OLD | NEW |