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

Side by Side Diff: Source/bindings/tests/results/core/V8TestObject.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 #include "V8TestObject.h" 8 #include "V8TestObject.h"
9 9
10 #include "bindings/core/v8/BindingSecurity.h" 10 #include "bindings/core/v8/BindingSecurity.h"
(...skipping 1705 matching lines...) Expand 10 before | Expand all | Expand 10 after
1716 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 1716 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
1717 } 1717 }
1718 1718
1719 static void testEnumAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 1719 static void testEnumAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
1720 { 1720 {
1721 v8::Local<v8::Object> holder = info.Holder(); 1721 v8::Local<v8::Object> holder = info.Holder();
1722 TestObject* impl = V8TestObject::toImpl(holder); 1722 TestObject* impl = V8TestObject::toImpl(holder);
1723 V8StringResource<> cppValue = v8Value; 1723 V8StringResource<> cppValue = v8Value;
1724 if (!cppValue.prepare()) 1724 if (!cppValue.prepare())
1725 return; 1725 return;
1726 String string = cppValue; 1726 const char* validValues[] = {
1727 if (!(string == "" || string == "EnumValue1" || string == "EnumValue2" || st ring == "EnumValue3")) { 1727 "",
1728 currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMes sage::create(JSMessageSource, WarningMessageLevel, "The provided value '" + stri ng + "' is not a valid value of type 'TestEnum'.")); 1728 "EnumValue1",
1729 "EnumValue2",
1730 "EnumValue3",
1731 };
1732 if (!isValidEnum(cppValue, validValues, 4)) {
1733 currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMes sage::create(JSMessageSource, WarningMessageLevel, "The provided value is not a valid value of type 'TestEnum'."));
haraken 2015/03/31 06:11:17 It's a shame that we lose the |string| information
bashi 2015/04/01 00:17:31 I dropped this because it requires a Vector<String
1729 return; 1734 return;
1730 } 1735 }
1731 impl->setTestEnumAttribute(cppValue); 1736 impl->setTestEnumAttribute(cppValue);
1732 } 1737 }
1733 1738
1734 static void testEnumAttributeAttributeSetterCallback(v8::Local<v8::Name>, v8::Lo cal<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 1739 static void testEnumAttributeAttributeSetterCallback(v8::Local<v8::Name>, v8::Lo cal<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
1735 { 1740 {
1736 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); 1741 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
1737 TestObjectV8Internal::testEnumAttributeAttributeSetter(v8Value, info); 1742 TestObjectV8Internal::testEnumAttributeAttributeSetter(v8Value, info);
1738 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 1743 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
(...skipping 13 matching lines...) Expand all
1752 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 1757 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
1753 } 1758 }
1754 1759
1755 static void testEnumOrNullAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 1760 static void testEnumOrNullAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
1756 { 1761 {
1757 v8::Local<v8::Object> holder = info.Holder(); 1762 v8::Local<v8::Object> holder = info.Holder();
1758 TestObject* impl = V8TestObject::toImpl(holder); 1763 TestObject* impl = V8TestObject::toImpl(holder);
1759 V8StringResource<TreatNullAsNullString> cppValue = v8Value; 1764 V8StringResource<TreatNullAsNullString> cppValue = v8Value;
1760 if (!cppValue.prepare()) 1765 if (!cppValue.prepare())
1761 return; 1766 return;
1762 String string = cppValue; 1767 const char* validValues[] = {
1763 if (!(string == "" || string == "EnumValue1" || string == "EnumValue2" || st ring == "EnumValue3")) { 1768 "",
1764 currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMes sage::create(JSMessageSource, WarningMessageLevel, "The provided value '" + stri ng + "' is not a valid value of type 'TestEnum'.")); 1769 "EnumValue1",
1770 "EnumValue2",
1771 "EnumValue3",
1772 };
1773 if (!isValidEnum(cppValue, validValues, 4)) {
1774 currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMes sage::create(JSMessageSource, WarningMessageLevel, "The provided value is not a valid value of type 'TestEnum'."));
1765 return; 1775 return;
1766 } 1776 }
1767 impl->setTestEnumOrNullAttribute(cppValue); 1777 impl->setTestEnumOrNullAttribute(cppValue);
1768 } 1778 }
1769 1779
1770 static void testEnumOrNullAttributeAttributeSetterCallback(v8::Local<v8::Name>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 1780 static void testEnumOrNullAttributeAttributeSetterCallback(v8::Local<v8::Name>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
1771 { 1781 {
1772 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); 1782 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
1773 TestObjectV8Internal::testEnumOrNullAttributeAttributeSetter(v8Value, info); 1783 TestObjectV8Internal::testEnumOrNullAttributeAttributeSetter(v8Value, info);
1774 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 1784 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
(...skipping 3752 matching lines...) Expand 10 before | Expand all | Expand 10 after
5527 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 5537 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
5528 } 5538 }
5529 5539
5530 static void enumForPrivateScriptAttributeSetter(v8::Local<v8::Value> v8Value, co nst v8::PropertyCallbackInfo<void>& info) 5540 static void enumForPrivateScriptAttributeSetter(v8::Local<v8::Value> v8Value, co nst v8::PropertyCallbackInfo<void>& info)
5531 { 5541 {
5532 v8::Local<v8::Object> holder = info.Holder(); 5542 v8::Local<v8::Object> holder = info.Holder();
5533 TestObject* impl = V8TestObject::toImpl(holder); 5543 TestObject* impl = V8TestObject::toImpl(holder);
5534 V8StringResource<> cppValue = v8Value; 5544 V8StringResource<> cppValue = v8Value;
5535 if (!cppValue.prepare()) 5545 if (!cppValue.prepare())
5536 return; 5546 return;
5537 String string = cppValue; 5547 const char* validValues[] = {
5538 if (!(string == "" || string == "EnumValue1" || string == "EnumValue2" || st ring == "EnumValue3")) { 5548 "",
5539 currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMes sage::create(JSMessageSource, WarningMessageLevel, "The provided value '" + stri ng + "' is not a valid value of type 'TestEnum'.")); 5549 "EnumValue1",
5550 "EnumValue2",
5551 "EnumValue3",
5552 };
5553 if (!isValidEnum(cppValue, validValues, 4)) {
5554 currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMes sage::create(JSMessageSource, WarningMessageLevel, "The provided value is not a valid value of type 'TestEnum'."));
5540 return; 5555 return;
5541 } 5556 }
5542 V8TestObject::PrivateScript::enumForPrivateScriptAttributeSetter(toLocalFram e(toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext())), impl, cppValue) ; 5557 V8TestObject::PrivateScript::enumForPrivateScriptAttributeSetter(toLocalFram e(toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext())), impl, cppValue) ;
5543 } 5558 }
5544 5559
5545 static void enumForPrivateScriptAttributeSetterCallback(v8::Local<v8::Name>, v8: :Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 5560 static void enumForPrivateScriptAttributeSetterCallback(v8::Local<v8::Name>, v8: :Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
5546 { 5561 {
5547 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); 5562 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
5548 TestObjectV8Internal::enumForPrivateScriptAttributeSetter(v8Value, info); 5563 TestObjectV8Internal::enumForPrivateScriptAttributeSetter(v8Value, info);
5549 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 5564 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
(...skipping 1842 matching lines...) Expand 10 before | Expand all | Expand 10 after
7392 if (UNLIKELY(info.Length() < 1)) { 7407 if (UNLIKELY(info.Length() < 1)) {
7393 V8ThrowException::throwException(createMinimumArityTypeErrorForMethod(in fo.GetIsolate(), "voidMethodTestEnumArg", "TestObject", 1, info.Length()), info. GetIsolate()); 7408 V8ThrowException::throwException(createMinimumArityTypeErrorForMethod(in fo.GetIsolate(), "voidMethodTestEnumArg", "TestObject", 1, info.Length()), info. GetIsolate());
7394 return; 7409 return;
7395 } 7410 }
7396 TestObject* impl = V8TestObject::toImpl(info.Holder()); 7411 TestObject* impl = V8TestObject::toImpl(info.Holder());
7397 V8StringResource<> testEnumTypeArg; 7412 V8StringResource<> testEnumTypeArg;
7398 { 7413 {
7399 testEnumTypeArg = info[0]; 7414 testEnumTypeArg = info[0];
7400 if (!testEnumTypeArg.prepare()) 7415 if (!testEnumTypeArg.prepare())
7401 return; 7416 return;
7402 String string = testEnumTypeArg; 7417 const char* validValues[] = {
7403 if (!(string == "" || string == "EnumValue1" || string == "EnumValue2" | | string == "EnumValue3")) { 7418 "",
7404 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessage s::failedToExecute("voidMethodTestEnumArg", "TestObject", "parameter 1 ('" + str ing + "') is not a valid enum value.")); 7419 "EnumValue1",
7420 "EnumValue2",
7421 "EnumValue3",
7422 };
7423 if (!isValidEnum(testEnumTypeArg, validValues, 4)) {
7424 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessage s::failedToExecute("voidMethodTestEnumArg", "TestObject", "parameter 1 is not a valid enum value."));
7405 return; 7425 return;
7406 } 7426 }
7407 } 7427 }
7408 impl->voidMethodTestEnumArg(testEnumTypeArg); 7428 impl->voidMethodTestEnumArg(testEnumTypeArg);
7409 } 7429 }
7410 7430
7411 static void voidMethodTestEnumArgMethodCallback(const v8::FunctionCallbackInfo<v 8::Value>& info) 7431 static void voidMethodTestEnumArgMethodCallback(const v8::FunctionCallbackInfo<v 8::Value>& info)
7412 { 7432 {
7413 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 7433 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
7414 TestObjectV8Internal::voidMethodTestEnumArgMethod(info); 7434 TestObjectV8Internal::voidMethodTestEnumArgMethod(info);
(...skipping 5793 matching lines...) Expand 10 before | Expand all | Expand 10 after
13208 return false; 13228 return false;
13209 13229
13210 ScriptState::Scope scope(scriptState); 13230 ScriptState::Scope scope(scriptState);
13211 v8::Local<v8::Value> holder = toV8(holderImpl, scriptState->context()->Globa l(), scriptState->isolate()); 13231 v8::Local<v8::Value> holder = toV8(holderImpl, scriptState->context()->Globa l(), scriptState->isolate());
13212 13232
13213 ExceptionState exceptionState(ExceptionState::SetterContext, "enumForPrivate Script", "TestObject", scriptState->context()->Global(), scriptState->isolate()) ; 13233 ExceptionState exceptionState(ExceptionState::SetterContext, "enumForPrivate Script", "TestObject", scriptState->context()->Global(), scriptState->isolate()) ;
13214 return PrivateScriptRunner::runDOMAttributeSetter(scriptState, scriptStateIn UserScript, "TestObject", "enumForPrivateScript", holder, v8String(scriptState-> isolate(), cppValue)); 13234 return PrivateScriptRunner::runDOMAttributeSetter(scriptState, scriptStateIn UserScript, "TestObject", "enumForPrivateScript", holder, v8String(scriptState-> isolate(), cppValue));
13215 } 13235 }
13216 13236
13217 } // namespace blink 13237 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698