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

Unified Diff: Source/bindings/tests/results/modules/V8TestInterfacePartial.cpp

Issue 1047993002: bindings: Add validation for enum Sequence or Array (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 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: Source/bindings/tests/results/modules/V8TestInterfacePartial.cpp
diff --git a/Source/bindings/tests/results/modules/V8TestInterfacePartial.cpp b/Source/bindings/tests/results/modules/V8TestInterfacePartial.cpp
index ce85958b6117668f272894090421a464a8fa82f5..e6882b49e57fca9ca18c1584d2ffeeb70e6b7690 100644
--- a/Source/bindings/tests/results/modules/V8TestInterfacePartial.cpp
+++ b/Source/bindings/tests/results/modules/V8TestInterfacePartial.cpp
@@ -223,8 +223,10 @@ static void partial2VoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>&
static void partialVoidTestEnumModulesArgMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "partialVoidTestEnumModulesArgMethod", "TestInterface", info.Holder(), info.GetIsolate());
if (UNLIKELY(info.Length() < 1)) {
- V8ThrowException::throwException(createMinimumArityTypeErrorForMethod(info.GetIsolate(), "partialVoidTestEnumModulesArgMethod", "TestInterface", 1, info.Length()), info.GetIsolate());
+ setMinimumArityTypeError(exceptionState, 1, info.Length());
+ exceptionState.throwIfNeeded();
return;
}
TestInterfaceImplementation* impl = V8TestInterface::toImpl(info.Holder());
@@ -233,9 +235,12 @@ static void partialVoidTestEnumModulesArgMethodMethod(const v8::FunctionCallback
arg = info[0];
if (!arg.prepare())
return;
- String string = arg;
- if (!(string == "EnumModulesValue1" || string == "EnumModulesValue2")) {
- V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("partialVoidTestEnumModulesArgMethod", "TestInterface", "parameter 1 ('" + string + "') is not a valid enum value."));
+ static const char* validValues[] = {
+ "EnumModulesValue1",
+ "EnumModulesValue2",
+ };
+ if (!isValidEnum(arg, validValues, WTF_ARRAY_LENGTH(validValues), exceptionState)) {
+ exceptionState.throwIfNeeded();
return;
}
}

Powered by Google App Engine
This is Rietveld 408576698