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

Side by Side Diff: test/unittests/api/remote-object-unittest.cc

Issue 2698683003: Make FunctionTemplate::HasInstance checks work with remote contexts. (Closed)
Patch Set: Break dependency on CreationContext patch Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « test/unittests/BUILD.gn ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« no previous file with comments | « test/unittests/BUILD.gn ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698