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

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

Issue 143943020: Replace [TreatNullAs=functionName] with [StrictTypeChecking] (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update tests, Python, and IDLExtendedAttributes.txt Created 6 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/unstable/v8_interface.py ('k') | Source/bindings/tests/idls/TestEventTarget.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 7def609c24a65a716bcc72397292eea7cfc07931..58e9e8861163c3988616ff129be9ebf4aa750a01 100644
--- a/Source/bindings/templates/interface.cpp
+++ b/Source/bindings/templates/interface.cpp
@@ -142,6 +142,15 @@ static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> jsValue,
{
{{cpp_class}}* collection = {{v8_class}}::toNative(info.Holder());
{{setter.v8_value_to_local_cpp_value}};
+ {% if setter.has_strict_type_checking %}
+ {# Type checking for interface types (if interface not implemented, throw
+ TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #}
+ if (!isUndefinedOrNull(jsValue) && !V8{{setter.idl_type}}::hasInstance(jsValue, info.GetIsolate())) {
+ exceptionState.throwTypeError("The provided value is not of type '{{setter.idl_type}}'.");
+ exceptionState.throwIfNeeded();
+ return;
+ }
+ {% endif %}
{% set setter_name = setter.name or 'anonymousIndexedSetter' %}
bool result = collection->{{setter_name}}(index, propertyValue);
if (!result)
« no previous file with comments | « Source/bindings/scripts/unstable/v8_interface.py ('k') | Source/bindings/tests/idls/TestEventTarget.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698