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

Unified Diff: Source/bindings/templates/methods.cpp

Issue 1047993002: bindings: Add validation for enum Sequence or Array (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 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
Index: Source/bindings/templates/methods.cpp
diff --git a/Source/bindings/templates/methods.cpp b/Source/bindings/templates/methods.cpp
index e059c508cd6564ec2b09fb720ea19162e7d96fa0..4fcc64570ada842149ef196639f281cd0ec2e2ba 100644
--- a/Source/bindings/templates/methods.cpp
+++ b/Source/bindings/templates/methods.cpp
@@ -1,4 +1,4 @@
-{% from 'conversions.cpp' import v8_value_to_local_cpp_value %}
+{% from 'conversions.cpp' import declare_enum_validation_variable, v8_value_to_local_cpp_value %}
{##############################################################################}
@@ -196,12 +196,12 @@ if (!{{argument.name}}{% if argument.is_nullable %} && !isUndefinedOrNull(info[{
{{throw_type_error(method, '"parameter %s is not of type \'%s\'."' %
(argument.index + 1, argument.idl_type)) | indent}}
}
-{% elif argument.enum_validation_expression %}
+{% elif argument.enum_values %}
{# Invalid enum values: http://www.w3.org/TR/WebIDL/#idl-enums #}
-String string = {{argument.name}};
-if (!({{argument.enum_validation_expression}})) {
+{{declare_enum_validation_variable(argument.enum_values)}}
+if (!isValidEnum({{argument.name}}, validValues, {{argument.enum_values|length}})) {
haraken 2015/03/31 06:11:17 Space around '|'?
{{throw_type_error(method,
- '"parameter %s (\'" + string + "\') is not a valid enum value."' %
+ '"parameter %s is not a valid enum value."' %
(argument.index + 1)) | indent}}
}
{% elif argument.idl_type == 'Promise' %}

Powered by Google App Engine
This is Rietveld 408576698