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

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

Issue 1057453002: bindings: Throw TypeError when required dictionary member is undefined (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
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
« no previous file with comments | « Source/bindings/scripts/v8_dictionary.py ('k') | Source/bindings/tests/idls/core/TestDictionaryDerived.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/templates/dictionary_v8.cpp
diff --git a/Source/bindings/templates/dictionary_v8.cpp b/Source/bindings/templates/dictionary_v8.cpp
index c6b6d1343a7b3922a93e49f78d18884ee6347a01..1b782325a33c287f99d6d000207ca237a127dde7 100644
--- a/Source/bindings/templates/dictionary_v8.cpp
+++ b/Source/bindings/templates/dictionary_v8.cpp
@@ -46,7 +46,12 @@ void {{v8_class}}::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, {{
return;
}
if ({{member.name}}Value.IsEmpty() || {{member.name}}Value->IsUndefined()) {
+ {% if member.is_required %}
+ exceptionState.throwTypeError("required member {{member.name}} is undefined.");
+ return;
+ {% else %}
// Do nothing.
+ {% endif %}
{% if member.is_nullable %}
} else if ({{member.name}}Value->IsNull()) {
impl.{{member.null_setter_name}}();
@@ -101,6 +106,9 @@ void toV8{{cpp_class}}(const {{cpp_class}}& impl, v8::Local<v8::Object> dictiona
{% if member.v8_default_value %}
} else {
dictionary->Set(v8String(isolate, "{{member.name}}"), {{member.v8_default_value}});
+ {% elif member.is_required %}
+ } else {
+ ASSERT_NOT_REACHED();
{% endif %}
}
« no previous file with comments | « Source/bindings/scripts/v8_dictionary.py ('k') | Source/bindings/tests/idls/core/TestDictionaryDerived.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698