Index: third_party/WebKit/Source/bindings/templates/interface_base.cpp |
diff --git a/third_party/WebKit/Source/bindings/templates/interface_base.cpp b/third_party/WebKit/Source/bindings/templates/interface_base.cpp |
index 22102d8796868d8ad8c07e5265562e0feb5022a6..a8518dd43cd6920ef8f4e178e1381ceedd227d27 100644 |
--- a/third_party/WebKit/Source/bindings/templates/interface_base.cpp |
+++ b/third_party/WebKit/Source/bindings/templates/interface_base.cpp |
@@ -223,7 +223,8 @@ bool securityCheck(v8::Local<v8::Context> accessingContext, v8::Local<v8::Object |
const V8DOMConfiguration::AttributeConfiguration {{v8_class}}Attributes[] = { |
{% for attribute in attributes |
if not (attribute.exposed_test or |
- attribute.runtime_enabled_function) and |
+ attribute.runtime_enabled_function or |
+ attribute.experimental_api_name) and |
attribute.is_data_type_property and |
attribute.should_be_exposed_to_script %} |
{% filter conditional(attribute.conditional_string) %} |
@@ -244,7 +245,8 @@ const V8DOMConfiguration::AttributeConfiguration {{v8_class}}Attributes[] = { |
const V8DOMConfiguration::AccessorConfiguration {{v8_class}}Accessors[] = { |
{% for attribute in attributes |
if not (attribute.exposed_test or |
- attribute.runtime_enabled_function) and |
+ attribute.runtime_enabled_function or |
+ attribute.experimental_api_name) and |
not attribute.is_data_type_property and |
attribute.should_be_exposed_to_script %} |
{% filter conditional(attribute.conditional_string) %} |
@@ -279,6 +281,29 @@ const V8DOMConfiguration::MethodConfiguration {{v8_class}}Methods[] = { |
{% from 'methods.cpp' import install_custom_signature with context %} |
{% from 'attributes.cpp' import attribute_configuration with context %} |
{% from 'constants.cpp' import install_constants with context %} |
+{% for attribute in attributes |
+ if attribute.experimental_api_name %} |
+{# TODO(dhnishi): This is a hack to stop experimentally enabled interfaces |
+ from exposing their constructors when disabled. Because the DOMWindow |
+ template is initialized before the experiment can be verified, we have it |
+ return 'undefined' when the user tries to get the attribute. This allows for |
+ feature detection, but it does not stop the DOM attribute from showing up on |
+ the object entirely. |
+ |
+ More bindings work will be needed to have this function perfectly. #} |
haraken
2015/12/16 02:16:42
Yeah, this is hacky... This needs to be addressed
|
+void is{{attribute.name}}ExperimentallyEnabled(v8::Local<v8::Name> propertyName, const v8::PropertyCallbackInfo<v8::Value>& info) { |
+ V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->CreationContext()); |
+ if (!perContextData) { |
+ v8SetReturnValue(info, v8::Undefined(info.GetIsolate())); |
+ return; |
+ } |
+ v8::Isolate* isolate = perContextData->context()->GetIsolate(); |
+ String errorMessage; |
+ if (Experiments::isApiEnabled(currentExecutionContext(isolate), "{{attribute.experimental_api_name}}", errorMessage)) { |
+ return v8ConstructorAttributeGetter(propertyName, info); |
+ } |
+} |
+{% endfor %} |
{% if has_partial_interface or is_partial %} |
void {{v8_class_or_partial}}::install{{v8_class}}Template(v8::Local<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate) |
{% else %} |
@@ -304,6 +329,18 @@ static void install{{v8_class}}Template(v8::Local<v8::FunctionTemplate> function |
{% endif %} |
{% set runtime_enabled_indent = 4 if runtime_enabled_function else 0 %} |
{% filter indent(runtime_enabled_indent, true) %} |
+ {% if experimental_api_name %} |
+ { |
+ ExecutionContext* ec = currentExecutionContext(isolate); |
+ ALLOW_UNUSED_LOCAL(ec); |
+ String errorMessage; |
+ if (!Experiments::isApiEnabled(ec, "{{experimental_api_name}}", errorMessage)) { |
+ defaultSignature = V8DOMConfiguration::installDOMClassTemplate(isolate, functionTemplate, "{{interface_name}}", {{parent_template}}, {{v8_class}}::internalFieldCount, 0, 0, 0, 0, 0, 0); |
+ } |
+ else |
+ {% endif %} |
+ {% set experiment_enabled_indent = 8 if experimental_api_name else 0 %} |
+ {% filter indent(experiment_enabled_indent, true) %} |
defaultSignature = V8DOMConfiguration::installDOMClassTemplate(isolate, functionTemplate, "{{interface_name}}", {{parent_template}}, {{v8_class}}::internalFieldCount, |
{# Test needed as size 0 arrays definitions are not allowed per standard |
(so objects have distinct addresses), which is enforced by MSVC. |
@@ -326,7 +363,12 @@ static void install{{v8_class}}Template(v8::Local<v8::FunctionTemplate> function |
{{attributes_name}}, {{attributes_length}}, |
{{accessors_name}}, {{accessors_length}}, |
{{methods_name}}, {{methods_length}}); |
- {% endfilter %} |
+ {% endfilter %}{# experiment_enabled_indent #} |
+ {% endfilter %}{# runtime_enabled_indent #} |
+ {% if runtime_enabled_function and experimental_api_name %} |
+ |
+ } |
+ {% endif %} |
{% if constructors or has_custom_constructor or has_event_constructor %} |
functionTemplate->SetCallHandler({{v8_class}}::constructorCallback); |
@@ -391,11 +433,15 @@ static void install{{v8_class}}Template(v8::Local<v8::FunctionTemplate> function |
{% if named_property_getter and not has_named_properties_object %} |
{{install_named_property_handler('instanceTemplate') | indent}} |
{% endif %} |
+ String errorMessage; |
+ ALLOW_UNUSED_LOCAL(errorMessage); |
{% if iterator_method %} |
{% filter exposed(iterator_method.exposed_test) %} |
{% filter runtime_enabled(iterator_method.runtime_enabled_function) %} |
+ {% filter experiment_enabled(iterator_method.experimental_api_name, "errorMessage") %} |
const V8DOMConfiguration::SymbolKeyedMethodConfiguration symbolKeyedIteratorConfiguration = { v8::Symbol::GetIterator, {{cpp_class_or_partial}}V8Internal::iteratorMethodCallback, 0, v8::DontDelete, V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype }; |
V8DOMConfiguration::installMethod(isolate, prototypeTemplate, defaultSignature, symbolKeyedIteratorConfiguration); |
+ {% endfilter %}{# experiment_enabled() #} |
{% endfilter %}{# runtime_enabled() #} |
{% endfilter %}{# exposed() #} |
{% endif %} |
@@ -416,12 +462,17 @@ static void install{{v8_class}}Template(v8::Local<v8::FunctionTemplate> function |
{% filter runtime_enabled(method.overloads.runtime_enabled_function_all |
if method.overloads else |
method.runtime_enabled_function) %} |
+ {% filter experiment_enabled(method.overloads.experimental_api_name_all |
+ if method.overloads else |
+ method.experimental_api_name, |
+ "errorMessage") %} |
{% if method.is_do_not_check_security %} |
{{install_do_not_check_security_method(method, '', 'instanceTemplate', 'prototypeTemplate') | indent}} |
{% else %}{# is_do_not_check_security #} |
{% set signature = 'v8::Local<v8::Signature>()' if method.is_do_not_check_signature else 'defaultSignature' %} |
{{install_custom_signature(method, 'instanceTemplate', 'prototypeTemplate', 'functionTemplate', signature) | indent}} |
{% endif %}{# is_do_not_check_security #} |
+ {% endfilter %}{# experiment_enabled() #} |
{% endfilter %}{# runtime_enabled() #} |
{% endfilter %}{# exposed() #} |
{% endfilter %}{# conditional() #} |