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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/unittests/BUILD.gn ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/api/remote-object-unittest.cc
diff --git a/test/unittests/api/remote-object-unittest.cc b/test/unittests/api/remote-object-unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d03050ed675b365c7edea40ff4011a575619487d
--- /dev/null
+++ b/test/unittests/api/remote-object-unittest.cc
@@ -0,0 +1,54 @@
+// Copyright 2017 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+#include "include/v8.h"
+#include "test/unittests/test-utils.h"
+
+namespace v8 {
+
+typedef TestWithIsolate RemoteObjectTest;
+
+namespace {
+
+bool AccessCheck(Local<Context> accessing_context,
+ Local<Object> accessed_object, Local<Value> data) {
+ return false;
+}
+
+void NamedGetter(Local<Name> property,
+ const PropertyCallbackInfo<Value>& info) {}
+
+void Constructor(const FunctionCallbackInfo<Value>& info) {
+ ASSERT_TRUE(info.IsConstructCall());
+}
+
+} // namespace
+
+TEST_F(RemoteObjectTest, RemoteContextInstanceChecks) {
+ Local<FunctionTemplate> parent_template =
+ FunctionTemplate::New(isolate(), Constructor);
+
+ Local<FunctionTemplate> constructor_template =
+ FunctionTemplate::New(isolate(), Constructor);
+ constructor_template->InstanceTemplate()->SetAccessCheckCallbackAndHandler(
+ AccessCheck, NamedPropertyHandlerConfiguration(NamedGetter),
+ IndexedPropertyHandlerConfiguration());
+ constructor_template->Inherit(parent_template);
+
+ Local<Object> remote_context =
+ Context::NewRemoteContext(isolate(),
+ constructor_template->InstanceTemplate())
+ .ToLocalChecked();
+ EXPECT_TRUE(parent_template->HasInstance(remote_context));
+ EXPECT_TRUE(constructor_template->HasInstance(remote_context));
+
+ EXPECT_EQ(remote_context,
+ remote_context->FindInstanceInPrototypeChain(parent_template));
+ EXPECT_EQ(remote_context,
+ remote_context->FindInstanceInPrototypeChain(constructor_template));
+}
+
+} // namespace v8
« 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