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

Unified Diff: third_party/WebKit/Source/bindings/templates/callback_function.cpp.tmpl

Issue 2802223002: bindings: Throw a type error if converting an interface or callback function fails. (Closed)
Patch Set: Add |callback_function_name| to the callback function template Created 3 years, 8 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/callback_function.cpp.tmpl
diff --git a/third_party/WebKit/Source/bindings/templates/callback_function.cpp.tmpl b/third_party/WebKit/Source/bindings/templates/callback_function.cpp.tmpl
index 50e3b25f6728ce7f06c67f4a1120ba8640239e42..8390f85535d9592c3dcb32121768fa70dd6078ce 100644
--- a/third_party/WebKit/Source/bindings/templates/callback_function.cpp.tmpl
+++ b/third_party/WebKit/Source/bindings/templates/callback_function.cpp.tmpl
@@ -81,7 +81,10 @@ bool {{cpp_class}}::call({{argument_declarations | join(', ')}}) {
}
{{cpp_class}}* NativeValueTraits<{{cpp_class}}>::nativeValue(v8::Isolate* isolate, v8::Local<v8::Value> value, ExceptionState& exceptionState) {
- return {{cpp_class}}::create(ScriptState::current(isolate), value);
+ {{cpp_class}}* nativeValue = {{cpp_class}}::create(ScriptState::current(isolate), value);
+ if (!nativeValue)
+ exceptionState.throwTypeError("Unable to convert value to {{callback_function_name}}.");
+ return nativeValue;
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698