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

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

Issue 871443002: IDL: Further improve indexed/named property setter type checking (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 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_interface.py ('k') | Source/bindings/tests/idls/core/TestInterface2.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/templates/interface.cpp
diff --git a/Source/bindings/templates/interface.cpp b/Source/bindings/templates/interface.cpp
index 5d52210d3ee16d0efdd6ce50c90e5fddef4c4451..5da47a89b6533626e3f90a0aa2fd535dfe2c64cc 100644
--- a/Source/bindings/templates/interface.cpp
+++ b/Source/bindings/templates/interface.cpp
@@ -61,7 +61,7 @@ static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> v8Value,
{% if setter.has_type_checking_interface %}
{# Type checking for interface types (if interface not implemented, throw
TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #}
- if (!isUndefinedOrNull(v8Value) && !V8{{setter.idl_type}}::hasInstance(v8Value, info.GetIsolate())) {
+ if (!propertyValue{% if setter.is_nullable %} && !isUndefinedOrNull(v8Value){% endif %}) {
exceptionState.throwTypeError("The provided value is not of type '{{setter.idl_type}}'.");
exceptionState.throwIfNeeded();
return;
@@ -232,6 +232,15 @@ static void namedPropertySetter(v8::Local<v8::Name> name, v8::Local<v8::Value> v
{# v8_value_to_local_cpp_value('DOMString', 'nameString', 'propertyName') #}
TOSTRING_VOID(V8StringResource<>, propertyName, nameString);
{{setter.v8_value_to_local_cpp_value}};
+ {% if setter.has_type_checking_interface %}
+ {# Type checking for interface types (if interface not implemented, throw
+ TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #}
+ if (!propertyValue{% if setter.is_nullable %} && !isUndefinedOrNull(v8Value){% endif %}) {
+ exceptionState.throwTypeError("The provided value is not of type '{{setter.idl_type}}'.");
+ exceptionState.throwIfNeeded();
+ return;
+ }
+ {% endif %}
{% set setter_name = setter.name or 'anonymousNamedSetter' %}
{% set setter_arguments =
['propertyName', 'propertyValue', 'exceptionState']
« no previous file with comments | « Source/bindings/scripts/v8_interface.py ('k') | Source/bindings/tests/idls/core/TestInterface2.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698