Commit 4e3d186c authored by Marina Sakai's avatar Marina Sakai Committed by Commit Bot

Separate kCrossOriginAttributeTable for accessor and data properties

Split |kCrossOriginAttributeTable| into two tables; one is for attributes, which should be accessor properties, and the other is for operations, which are data properties.
Currently cross origin attributes are implemented as data properties, but will be converted to accessor properties in following changes.

Bug: 809011
Change-Id: If95e6a402c532648ffd406b1ee451df92807375a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1775689Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Marina Sakai <marinasakai@google.com>
Cr-Commit-Position: refs/heads/master@{#692000}
parent 509e0a77
......@@ -156,7 +156,6 @@ static const struct {
const GetterCallback getter;
const SetterCallback setter;
} kCrossOriginAttributeTable[] = {
{##### Cross-origin attributes #####}
{% for attribute in attributes if attribute.has_cross_origin_getter or attribute.has_cross_origin_setter %}
{
"{{attribute.name}}",
......@@ -172,10 +171,17 @@ static const struct {
{%+ if attribute.has_cross_origin_setter %}&{{internal_namespace}}::{{attribute.camel_case_name}}AttributeSetter{% else %}nullptr{% endif %},
},
{% endfor %}
{##### Cross-origin methods #####}
};
static const struct {
using ValueCallback = void(*)(const v8::PropertyCallbackInfo<v8::Value>&);
const char* const name;
const ValueCallback value;
} kCrossOriginOperationTable[] = {
{% for method in methods if method.is_cross_origin and
(not method.overload_index or method.overloads) %}
{"{{method.name}}", &{{internal_namespace}}::{{method.camel_case_name}}OriginSafeMethodGetter, nullptr},
{"{{method.name}}", &{{internal_namespace}}::{{method.camel_case_name}}OriginSafeMethodGetter},
{% endfor %}
};
{% endif %}
......@@ -273,6 +279,12 @@ void {{v8_class_or_partial}}::CrossOriginNamedGetter(v8::Local<v8::Name> name, c
return;
}
}
for (const auto& operation : {{internal_namespace}}::kCrossOriginOperationTable) {
if (property_name == operation.name) {
operation.value(info);
return;
}
}
{% if named_property_getter and named_property_getter.is_cross_origin %}
{% if named_property_getter.is_custom %}
......@@ -330,6 +342,8 @@ void {{v8_class_or_partial}}::CrossOriginNamedEnumerator(const v8::PropertyCallb
Vector<String> names;
for (const auto& attribute : {{internal_namespace}}::kCrossOriginAttributeTable)
names.push_back(attribute.name);
for (const auto& operation : {{internal_namespace}}::kCrossOriginOperationTable)
names.push_back(operation.name);
// Use the current context as the creation context, as a cross-origin access
// may involve an object that does not have a creation context.
......
......@@ -627,10 +627,18 @@ static const struct {
test_interface_check_security_v8_internal::DoNotCheckSecurityReplaceableReadonlyLongAttributeAttributeGetter,
nullptr,
},
{"doNotCheckSecurityVoidMethod", &test_interface_check_security_v8_internal::DoNotCheckSecurityVoidMethodOriginSafeMethodGetter, nullptr},
{"doNotCheckSecurityPerWorldBindingsVoidMethod", &test_interface_check_security_v8_internal::DoNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetter, nullptr},
{"doNotCheckSecurityUnforgeableVoidMethod", &test_interface_check_security_v8_internal::DoNotCheckSecurityUnforgeableVoidMethodOriginSafeMethodGetter, nullptr},
{"doNotCheckSecurityVoidOverloadMethod", &test_interface_check_security_v8_internal::DoNotCheckSecurityVoidOverloadMethodOriginSafeMethodGetter, nullptr},
};
static const struct {
using ValueCallback = void(*)(const v8::PropertyCallbackInfo<v8::Value>&);
const char* const name;
const ValueCallback value;
} kCrossOriginOperationTable[] = {
{"doNotCheckSecurityVoidMethod", &test_interface_check_security_v8_internal::DoNotCheckSecurityVoidMethodOriginSafeMethodGetter},
{"doNotCheckSecurityPerWorldBindingsVoidMethod", &test_interface_check_security_v8_internal::DoNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetter},
{"doNotCheckSecurityUnforgeableVoidMethod", &test_interface_check_security_v8_internal::DoNotCheckSecurityUnforgeableVoidMethodOriginSafeMethodGetter},
{"doNotCheckSecurityVoidOverloadMethod", &test_interface_check_security_v8_internal::DoNotCheckSecurityVoidOverloadMethodOriginSafeMethodGetter},
};
} // namespace test_interface_check_security_v8_internal
......@@ -792,6 +800,12 @@ void V8TestInterfaceCheckSecurity::CrossOriginNamedGetter(v8::Local<v8::Name> na
return;
}
}
for (const auto& operation : test_interface_check_security_v8_internal::kCrossOriginOperationTable) {
if (property_name == operation.name) {
operation.value(info);
return;
}
}
// HTML 7.2.3.3 CrossOriginGetOwnPropertyHelper ( O, P )
// https://html.spec.whatwg.org/C/#crossorigingetownpropertyhelper-(-o,-p-)
......@@ -834,6 +848,8 @@ void V8TestInterfaceCheckSecurity::CrossOriginNamedEnumerator(const v8::Property
Vector<String> names;
for (const auto& attribute : test_interface_check_security_v8_internal::kCrossOriginAttributeTable)
names.push_back(attribute.name);
for (const auto& operation : test_interface_check_security_v8_internal::kCrossOriginOperationTable)
names.push_back(operation.name);
// Use the current context as the creation context, as a cross-origin access
// may involve an object that does not have a creation context.
......
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