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

Unified Diff: Source/bindings/tests/results/core/V8TestObject.cpp

Issue 810563007: IDL: Add missing type-check for callback function arguments (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/tests/results/core/V8TestInterface.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/tests/results/core/V8TestObject.cpp
diff --git a/Source/bindings/tests/results/core/V8TestObject.cpp b/Source/bindings/tests/results/core/V8TestObject.cpp
index 925385b4426dfd1e05e520d243fdaea22ab9a0c0..13723029f0d31a5243da2dcd314ab81086dad2a6 100644
--- a/Source/bindings/tests/results/core/V8TestObject.cpp
+++ b/Source/bindings/tests/results/core/V8TestObject.cpp
@@ -5783,6 +5783,10 @@ static void voidMethodVoidCallbackFunctionArgMethod(const v8::FunctionCallbackIn
TestObject* impl = V8TestObject::toImpl(info.Holder());
ScriptValue voidCallbackFunctionArg;
{
+ if (!info[0]->IsFunction()) {
+ V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("voidMethodVoidCallbackFunctionArg", "TestObject", "The callback provided as parameter 1 is not a function."));
+ return;
+ }
voidCallbackFunctionArg = ScriptValue(ScriptState::current(info.GetIsolate()), info[0]);
}
impl->voidMethodVoidCallbackFunctionArg(voidCallbackFunctionArg);
@@ -5795,6 +5799,56 @@ static void voidMethodVoidCallbackFunctionArgMethodCallback(const v8::FunctionCa
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
+static void voidMethodOptionalVoidCallbackFunctionArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TestObject* impl = V8TestObject::toImpl(info.Holder());
+ ScriptValue voidCallbackFunctionArg;
+ {
+ if (UNLIKELY(info.Length() <= 0)) {
+ impl->voidMethodOptionalVoidCallbackFunctionArg();
+ return;
+ }
+ if (!info[0]->IsFunction()) {
+ V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("voidMethodOptionalVoidCallbackFunctionArg", "TestObject", "The callback provided as parameter 1 is not a function."));
+ return;
+ }
+ voidCallbackFunctionArg = ScriptValue(ScriptState::current(info.GetIsolate()), info[0]);
+ }
+ impl->voidMethodOptionalVoidCallbackFunctionArg(voidCallbackFunctionArg);
+}
+
+static void voidMethodOptionalVoidCallbackFunctionArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
+ TestObjectV8Internal::voidMethodOptionalVoidCallbackFunctionArgMethod(info);
+ TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
+}
+
+static void voidMethodNullableVoidCallbackFunctionArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ if (UNLIKELY(info.Length() < 1)) {
+ V8ThrowException::throwException(createMinimumArityTypeErrorForMethod(info.GetIsolate(), "voidMethodNullableVoidCallbackFunctionArg", "TestObject", 1, info.Length()), info.GetIsolate());
+ return;
+ }
+ TestObject* impl = V8TestObject::toImpl(info.Holder());
+ ScriptValue voidCallbackFunctionArg;
+ {
+ if (!info[0]->IsFunction() && !info[0]->IsNull()) {
+ V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("voidMethodNullableVoidCallbackFunctionArg", "TestObject", "The callback provided as parameter 1 is not a function."));
+ return;
+ }
+ voidCallbackFunctionArg = ScriptValue(ScriptState::current(info.GetIsolate()), info[0]);
+ }
+ impl->voidMethodNullableVoidCallbackFunctionArg(voidCallbackFunctionArg);
+}
+
+static void voidMethodNullableVoidCallbackFunctionArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
+ TestObjectV8Internal::voidMethodNullableVoidCallbackFunctionArgMethod(info);
+ TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
+}
+
static void voidMethodAnyCallbackFunctionOptionalAnyArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
if (UNLIKELY(info.Length() < 1)) {
@@ -5804,6 +5858,10 @@ static void voidMethodAnyCallbackFunctionOptionalAnyArgMethod(const v8::Function
TestObject* impl = V8TestObject::toImpl(info.Holder());
ScriptValue anyCallbackFunctionOptionalAnyArgArg;
{
+ if (!info[0]->IsFunction()) {
+ V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("voidMethodAnyCallbackFunctionOptionalAnyArg", "TestObject", "The callback provided as parameter 1 is not a function."));
+ return;
+ }
anyCallbackFunctionOptionalAnyArgArg = ScriptValue(ScriptState::current(info.GetIsolate()), info[0]);
}
impl->voidMethodAnyCallbackFunctionOptionalAnyArg(anyCallbackFunctionOptionalAnyArgArg);
@@ -8377,6 +8435,10 @@ static void overloadedMethodK1Method(const v8::FunctionCallbackInfo<v8::Value>&
TestObject* impl = V8TestObject::toImpl(info.Holder());
ScriptValue functionArg;
{
+ if (!info[0]->IsFunction()) {
+ V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("overloadedMethodK", "TestObject", "The callback provided as parameter 1 is not a function."));
+ return;
+ }
functionArg = ScriptValue(ScriptState::current(info.GetIsolate()), info[0]);
}
impl->overloadedMethodK(functionArg);
@@ -10828,6 +10890,8 @@ static const V8DOMConfiguration::MethodConfiguration V8TestObjectMethods[] = {
{"voidCallbackFunctionMethod", TestObjectV8Internal::voidCallbackFunctionMethodMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts},
{"anyCallbackFunctionOptionalAnyArgMethod", TestObjectV8Internal::anyCallbackFunctionOptionalAnyArgMethodMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts},
{"voidMethodVoidCallbackFunctionArg", TestObjectV8Internal::voidMethodVoidCallbackFunctionArgMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts},
+ {"voidMethodOptionalVoidCallbackFunctionArg", TestObjectV8Internal::voidMethodOptionalVoidCallbackFunctionArgMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts},
+ {"voidMethodNullableVoidCallbackFunctionArg", TestObjectV8Internal::voidMethodNullableVoidCallbackFunctionArgMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts},
{"voidMethodAnyCallbackFunctionOptionalAnyArg", TestObjectV8Internal::voidMethodAnyCallbackFunctionOptionalAnyArgMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts},
{"anyMethod", TestObjectV8Internal::anyMethodMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts},
{"voidMethodEventTargetArg", TestObjectV8Internal::voidMethodEventTargetArgMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts},
« no previous file with comments | « Source/bindings/tests/results/core/V8TestInterface.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698