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

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

Issue 2341723002: binding: Indexed property returns undefined if out-of-range. (Closed)
Patch Set: Updated layout test expectations. Created 4 years, 3 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: third_party/WebKit/Source/bindings/templates/interface.cpp
diff --git a/third_party/WebKit/Source/bindings/templates/interface.cpp b/third_party/WebKit/Source/bindings/templates/interface.cpp
index 5dd75b43e0748b7a891b2a09fc1f3b0a30b9beee..9cf59f635e886cc5a3e79496b893ebce1814256b 100644
--- a/third_party/WebKit/Source/bindings/templates/interface.cpp
+++ b/third_party/WebKit/Source/bindings/templates/interface.cpp
@@ -21,6 +21,13 @@ static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo
{{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
+ // We assume that all the implementations support length() method, although
peria 2016/09/14 15:25:03 Please use "{#...#}" style comment not to generate
Yuki 2016/09/15 09:49:17 I intentionally made this comment C++ comment so t
+ // the spec doesn't require that length() must exist. It's okay that
+ // the interface does not have length attribute as long as the
+ // implementation supports length() member function.
+ if (index >= impl->length())
+ return; // Returns undefined due to out-of-range.
+
{% set getter_name = getter.name or 'anonymousIndexedGetter' %}
{% set getter_arguments = ['index'] %}
{% if getter.is_call_with_script_state %}
@@ -31,8 +38,6 @@ static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo
{% set getter_arguments = getter_arguments + ['exceptionState'] %}
{% endif %}
{{getter.cpp_type}} result = impl->{{getter_name}}({{getter_arguments | join(', ')}});
- if ({{getter.is_null_expression}})
- return;
{{getter.v8_set_return_value}};
}

Powered by Google App Engine
This is Rietveld 408576698