Commit e5f89fa5 authored by dcheng's avatar dcheng Committed by Commit bot

Don't mark remote contexts as callable or constructible.

Marking it as callable makes typeof return 'function' instead of
'object' when invoked on a remote context or object.

BUG=chromium:527190

Review-Url: https://codereview.chromium.org/2715593002
Cr-Commit-Position: refs/heads/master@{#43416}
parent 42ded33b
...@@ -538,8 +538,6 @@ MaybeHandle<JSObject> ApiNatives::InstantiateRemoteObject( ...@@ -538,8 +538,6 @@ MaybeHandle<JSObject> ApiNatives::InstantiateRemoteObject(
JSFunction::SetInitialMap(object_function, object_map, JSFunction::SetInitialMap(object_function, object_map,
isolate->factory()->null_value()); isolate->factory()->null_value());
object_map->set_is_access_check_needed(true); object_map->set_is_access_check_needed(true);
object_map->set_is_callable();
object_map->set_is_constructor(true);
Handle<JSObject> object = isolate->factory()->NewJSObject(object_function); Handle<JSObject> object = isolate->factory()->NewJSObject(object_function);
JSObject::ForceSetPrototype(object, isolate->factory()->null_value()); JSObject::ForceSetPrototype(object, isolate->factory()->null_value());
......
...@@ -4961,8 +4961,6 @@ Genesis::Genesis(Isolate* isolate, ...@@ -4961,8 +4961,6 @@ Genesis::Genesis(Isolate* isolate,
JSFunction::SetInitialMap(global_proxy_function, global_proxy_map, JSFunction::SetInitialMap(global_proxy_function, global_proxy_map,
factory()->null_value()); factory()->null_value());
global_proxy_map->set_is_access_check_needed(true); global_proxy_map->set_is_access_check_needed(true);
global_proxy_map->set_is_callable();
global_proxy_map->set_is_constructor(true);
global_proxy_map->set_has_hidden_prototype(true); global_proxy_map->set_has_hidden_prototype(true);
Handle<String> global_name = factory()->global_string(); Handle<String> global_name = factory()->global_string();
......
...@@ -63,10 +63,35 @@ TEST_F(RemoteObjectTest, RemoteContextInstanceChecks) { ...@@ -63,10 +63,35 @@ TEST_F(RemoteObjectTest, RemoteContextInstanceChecks) {
Local<Object> remote_context = Local<Object> remote_context =
Context::NewRemoteContext(isolate(), Context::NewRemoteContext(isolate(),
constructor_template->InstanceTemplate()) constructor_template->InstanceTemplate())
.ToLocalChecked(); .ToLocalChecked();
EXPECT_TRUE(parent_template->HasInstance(remote_context)); EXPECT_TRUE(parent_template->HasInstance(remote_context));
EXPECT_TRUE(constructor_template->HasInstance(remote_context)); EXPECT_TRUE(constructor_template->HasInstance(remote_context));
} }
TEST_F(RemoteObjectTest, TypeOfRemoteContext) {
Local<ObjectTemplate> global_template = ObjectTemplate::New(isolate());
global_template->SetAccessCheckCallbackAndHandler(
AccessCheck, NamedPropertyHandlerConfiguration(NamedGetter),
IndexedPropertyHandlerConfiguration());
Local<Object> remote_context =
Context::NewRemoteContext(isolate(), global_template).ToLocalChecked();
String::Utf8Value result(remote_context->TypeOf(isolate()));
EXPECT_STREQ("object", *result);
}
TEST_F(RemoteObjectTest, TypeOfRemoteObject) {
Local<FunctionTemplate> constructor_template =
FunctionTemplate::New(isolate(), Constructor);
constructor_template->InstanceTemplate()->SetAccessCheckCallbackAndHandler(
AccessCheck, NamedPropertyHandlerConfiguration(NamedGetter),
IndexedPropertyHandlerConfiguration());
Local<Object> remote_object =
constructor_template->NewRemoteInstance().ToLocalChecked();
String::Utf8Value result(remote_object->TypeOf(isolate()));
EXPECT_STREQ("object", *result);
}
} // namespace v8 } // namespace v8
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment