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

Side by Side Diff: Source/bindings/tests/results/core/V8TestInterface.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, 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY! 5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY!
6 6
7 #include "config.h" 7 #include "config.h"
8 #if ENABLE(CONDITION) 8 #if ENABLE(CONDITION)
9 #include "V8TestInterface.h" 9 #include "V8TestInterface.h"
10 10
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 static void testEnumAttributeAttributeGetterCallback(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>& info) 270 static void testEnumAttributeAttributeGetterCallback(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>& info)
271 { 271 {
272 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 272 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
273 TestInterfaceImplementationV8Internal::testEnumAttributeAttributeGetter(info ); 273 TestInterfaceImplementationV8Internal::testEnumAttributeAttributeGetter(info );
274 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 274 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
275 } 275 }
276 276
277 static void testEnumAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 277 static void testEnumAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
278 { 278 {
279 v8::Local<v8::Object> holder = info.Holder(); 279 v8::Local<v8::Object> holder = info.Holder();
280 ExceptionState exceptionState(ExceptionState::SetterContext, "testEnumAttrib ute", "TestInterface", holder, info.GetIsolate());
bashi 2015/04/01 08:25:34 Changed to use actual ExceptionState.
280 TestInterfaceImplementation* impl = V8TestInterface::toImpl(holder); 281 TestInterfaceImplementation* impl = V8TestInterface::toImpl(holder);
281 V8StringResource<> cppValue = v8Value; 282 V8StringResource<> cppValue = v8Value;
282 if (!cppValue.prepare()) 283 if (!cppValue.prepare())
283 return; 284 return;
284 String string = cppValue; 285 static const char* validValues[] = {
285 if (!(string == "" || string == "EnumValue1" || string == "EnumValue2" || st ring == "EnumValue3")) { 286 "",
286 currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMes sage::create(JSMessageSource, WarningMessageLevel, "The provided value '" + stri ng + "' is not a valid value of type 'TestEnum'.")); 287 "EnumValue1",
288 "EnumValue2",
289 "EnumValue3",
290 };
291 if (!isValidEnum(cppValue, validValues, WTF_ARRAY_LENGTH(validValues), excep tionState)) {
292 currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMes sage::create(JSMessageSource, WarningMessageLevel, exceptionState.message()));
287 return; 293 return;
288 } 294 }
289 impl->setTestEnumAttribute(cppValue); 295 impl->setTestEnumAttribute(cppValue);
290 } 296 }
291 297
292 static void testEnumAttributeAttributeSetterCallback(v8::Local<v8::Name>, v8::Lo cal<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 298 static void testEnumAttributeAttributeSetterCallback(v8::Local<v8::Name>, v8::Lo cal<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
293 { 299 {
294 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); 300 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
295 TestInterfaceImplementationV8Internal::testEnumAttributeAttributeSetter(v8Va lue, info); 301 TestInterfaceImplementationV8Internal::testEnumAttributeAttributeSetter(v8Va lue, info);
296 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 302 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 958 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
953 TestInterfaceImplementationV8Internal::partialPartialEnumTypeAttributeAttrib uteGetter(info); 959 TestInterfaceImplementationV8Internal::partialPartialEnumTypeAttributeAttrib uteGetter(info);
954 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 960 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
955 } 961 }
956 #endif // ENABLE(PARTIAL_CONDITION) 962 #endif // ENABLE(PARTIAL_CONDITION)
957 963
958 #if ENABLE(PARTIAL_CONDITION) 964 #if ENABLE(PARTIAL_CONDITION)
959 static void partialPartialEnumTypeAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 965 static void partialPartialEnumTypeAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
960 { 966 {
961 v8::Local<v8::Object> holder = info.Holder(); 967 v8::Local<v8::Object> holder = info.Holder();
968 ExceptionState exceptionState(ExceptionState::SetterContext, "partialPartial EnumTypeAttribute", "TestInterface", holder, info.GetIsolate());
962 TestInterfaceImplementation* impl = V8TestInterface::toImpl(holder); 969 TestInterfaceImplementation* impl = V8TestInterface::toImpl(holder);
963 V8StringResource<> cppValue = v8Value; 970 V8StringResource<> cppValue = v8Value;
964 if (!cppValue.prepare()) 971 if (!cppValue.prepare())
965 return; 972 return;
966 String string = cppValue; 973 static const char* validValues[] = {
967 if (!(string == "foo" || string == "bar")) { 974 "foo",
968 currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMes sage::create(JSMessageSource, WarningMessageLevel, "The provided value '" + stri ng + "' is not a valid value of type 'PartialEnumType'.")); 975 "bar",
976 };
977 if (!isValidEnum(cppValue, validValues, WTF_ARRAY_LENGTH(validValues), excep tionState)) {
978 currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMes sage::create(JSMessageSource, WarningMessageLevel, exceptionState.message()));
969 return; 979 return;
970 } 980 }
971 TestPartialInterface::setPartialPartialEnumTypeAttribute(*impl, cppValue); 981 TestPartialInterface::setPartialPartialEnumTypeAttribute(*impl, cppValue);
972 } 982 }
973 #endif // ENABLE(PARTIAL_CONDITION) 983 #endif // ENABLE(PARTIAL_CONDITION)
974 984
975 #if ENABLE(PARTIAL_CONDITION) 985 #if ENABLE(PARTIAL_CONDITION)
976 static void partialPartialEnumTypeAttributeAttributeSetterCallback(v8::Local<v8: :Name>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info ) 986 static void partialPartialEnumTypeAttributeAttributeSetterCallback(v8::Local<v8: :Name>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info )
977 { 987 {
978 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); 988 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 1172
1163 static void voidMethodUnrestrictedDoubleArgUnrestrictedFloatArgMethodCallback(co nst v8::FunctionCallbackInfo<v8::Value>& info) 1173 static void voidMethodUnrestrictedDoubleArgUnrestrictedFloatArgMethodCallback(co nst v8::FunctionCallbackInfo<v8::Value>& info)
1164 { 1174 {
1165 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 1175 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
1166 TestInterfaceImplementationV8Internal::voidMethodUnrestrictedDoubleArgUnrest rictedFloatArgMethod(info); 1176 TestInterfaceImplementationV8Internal::voidMethodUnrestrictedDoubleArgUnrest rictedFloatArgMethod(info);
1167 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 1177 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
1168 } 1178 }
1169 1179
1170 static void voidMethodTestEnumArgMethod(const v8::FunctionCallbackInfo<v8::Value >& info) 1180 static void voidMethodTestEnumArgMethod(const v8::FunctionCallbackInfo<v8::Value >& info)
1171 { 1181 {
1182 ExceptionState exceptionState(ExceptionState::ExecutionContext, "voidMethodT estEnumArg", "TestInterface", info.Holder(), info.GetIsolate());
1172 if (UNLIKELY(info.Length() < 1)) { 1183 if (UNLIKELY(info.Length() < 1)) {
1173 V8ThrowException::throwException(createMinimumArityTypeErrorForMethod(in fo.GetIsolate(), "voidMethodTestEnumArg", "TestInterface", 1, info.Length()), in fo.GetIsolate()); 1184 setMinimumArityTypeError(exceptionState, 1, info.Length());
1185 exceptionState.throwIfNeeded();
1174 return; 1186 return;
1175 } 1187 }
1176 TestInterfaceImplementation* impl = V8TestInterface::toImpl(info.Holder()); 1188 TestInterfaceImplementation* impl = V8TestInterface::toImpl(info.Holder());
1177 V8StringResource<> testEnumArg; 1189 V8StringResource<> testEnumArg;
1178 { 1190 {
1179 testEnumArg = info[0]; 1191 testEnumArg = info[0];
1180 if (!testEnumArg.prepare()) 1192 if (!testEnumArg.prepare())
1181 return; 1193 return;
1182 String string = testEnumArg; 1194 static const char* validValues[] = {
1183 if (!(string == "" || string == "EnumValue1" || string == "EnumValue2" | | string == "EnumValue3")) { 1195 "",
1184 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessage s::failedToExecute("voidMethodTestEnumArg", "TestInterface", "parameter 1 ('" + string + "') is not a valid enum value.")); 1196 "EnumValue1",
1197 "EnumValue2",
1198 "EnumValue3",
1199 };
1200 if (!isValidEnum(testEnumArg, validValues, WTF_ARRAY_LENGTH(validValues) , exceptionState)) {
1201 exceptionState.throwIfNeeded();
1185 return; 1202 return;
1186 } 1203 }
1187 } 1204 }
1188 impl->voidMethodTestEnumArg(testEnumArg); 1205 impl->voidMethodTestEnumArg(testEnumArg);
1189 } 1206 }
1190 1207
1191 static void voidMethodTestEnumArgMethodCallback(const v8::FunctionCallbackInfo<v 8::Value>& info) 1208 static void voidMethodTestEnumArgMethodCallback(const v8::FunctionCallbackInfo<v 8::Value>& info)
1192 { 1209 {
1193 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 1210 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
1194 TestInterfaceImplementationV8Internal::voidMethodTestEnumArgMethod(info); 1211 TestInterfaceImplementationV8Internal::voidMethodTestEnumArgMethod(info);
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after
2559 void V8TestInterface::registerPartial2VoidMethodMethodForPartialInterface(void ( *method)(const v8::FunctionCallbackInfo<v8::Value>&)) 2576 void V8TestInterface::registerPartial2VoidMethodMethodForPartialInterface(void ( *method)(const v8::FunctionCallbackInfo<v8::Value>&))
2560 { 2577 {
2561 TestInterfaceImplementationV8Internal::partial2VoidMethodMethodForPartialInt erface = method; 2578 TestInterfaceImplementationV8Internal::partial2VoidMethodMethodForPartialInt erface = method;
2562 } 2579 }
2563 void V8TestInterface::registerPartial2StaticVoidMethodMethodForPartialInterface( void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) 2580 void V8TestInterface::registerPartial2StaticVoidMethodMethodForPartialInterface( void (*method)(const v8::FunctionCallbackInfo<v8::Value>&))
2564 { 2581 {
2565 TestInterfaceImplementationV8Internal::partial2StaticVoidMethodMethodForPart ialInterface = method; 2582 TestInterfaceImplementationV8Internal::partial2StaticVoidMethodMethodForPart ialInterface = method;
2566 } 2583 }
2567 } // namespace blink 2584 } // namespace blink
2568 #endif // ENABLE(CONDITION) 2585 #endif // ENABLE(CONDITION)
OLDNEW
« no previous file with comments | « Source/bindings/tests/results/core/V8TestDictionary.cpp ('k') | Source/bindings/tests/results/core/V8TestObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698