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

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 1701 matching lines...) Expand 10 before | Expand all | Expand 10 after
1712 static void testEnumAttributeAttributeGetterCallback(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>& info) 1712 static void testEnumAttributeAttributeGetterCallback(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>& info)
1713 { 1713 {
1714 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 1714 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
1715 TestObjectV8Internal::testEnumAttributeAttributeGetter(info); 1715 TestObjectV8Internal::testEnumAttributeAttributeGetter(info);
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 ExceptionState exceptionState(ExceptionState::SetterContext, "testEnumAttrib ute", "TestObject", holder, info.GetIsolate());
1722 TestObject* impl = V8TestObject::toImpl(holder); 1723 TestObject* impl = V8TestObject::toImpl(holder);
1723 V8StringResource<> cppValue = v8Value; 1724 V8StringResource<> cppValue = v8Value;
1724 if (!cppValue.prepare()) 1725 if (!cppValue.prepare())
1725 return; 1726 return;
1726 String string = cppValue; 1727 static const char* validValues[] = {
1727 if (!(string == "" || string == "EnumValue1" || string == "EnumValue2" || st ring == "EnumValue3")) { 1728 "",
1728 currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMes sage::create(JSMessageSource, WarningMessageLevel, "The provided value '" + stri ng + "' is not a valid value of type 'TestEnum'.")); 1729 "EnumValue1",
1730 "EnumValue2",
1731 "EnumValue3",
1732 };
1733 if (!isValidEnum(cppValue, validValues, WTF_ARRAY_LENGTH(validValues), excep tionState)) {
1734 currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMes sage::create(JSMessageSource, WarningMessageLevel, exceptionState.message()));
1729 return; 1735 return;
1730 } 1736 }
1731 impl->setTestEnumAttribute(cppValue); 1737 impl->setTestEnumAttribute(cppValue);
1732 } 1738 }
1733 1739
1734 static void testEnumAttributeAttributeSetterCallback(v8::Local<v8::Name>, v8::Lo cal<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 1740 static void testEnumAttributeAttributeSetterCallback(v8::Local<v8::Name>, v8::Lo cal<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
1735 { 1741 {
1736 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); 1742 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
1737 TestObjectV8Internal::testEnumAttributeAttributeSetter(v8Value, info); 1743 TestObjectV8Internal::testEnumAttributeAttributeSetter(v8Value, info);
1738 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 1744 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
1739 } 1745 }
1740 1746
1741 static void testEnumOrNullAttributeAttributeGetter(const v8::PropertyCallbackInf o<v8::Value>& info) 1747 static void testEnumOrNullAttributeAttributeGetter(const v8::PropertyCallbackInf o<v8::Value>& info)
1742 { 1748 {
1743 v8::Local<v8::Object> holder = info.Holder(); 1749 v8::Local<v8::Object> holder = info.Holder();
1744 TestObject* impl = V8TestObject::toImpl(holder); 1750 TestObject* impl = V8TestObject::toImpl(holder);
1745 v8SetReturnValueStringOrNull(info, impl->testEnumOrNullAttribute(), info.Get Isolate()); 1751 v8SetReturnValueStringOrNull(info, impl->testEnumOrNullAttribute(), info.Get Isolate());
1746 } 1752 }
1747 1753
1748 static void testEnumOrNullAttributeAttributeGetterCallback(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>& info) 1754 static void testEnumOrNullAttributeAttributeGetterCallback(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>& info)
1749 { 1755 {
1750 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 1756 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
1751 TestObjectV8Internal::testEnumOrNullAttributeAttributeGetter(info); 1757 TestObjectV8Internal::testEnumOrNullAttributeAttributeGetter(info);
1752 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 1758 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
1753 } 1759 }
1754 1760
1755 static void testEnumOrNullAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 1761 static void testEnumOrNullAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
1756 { 1762 {
1757 v8::Local<v8::Object> holder = info.Holder(); 1763 v8::Local<v8::Object> holder = info.Holder();
1764 ExceptionState exceptionState(ExceptionState::SetterContext, "testEnumOrNull Attribute", "TestObject", holder, info.GetIsolate());
1758 TestObject* impl = V8TestObject::toImpl(holder); 1765 TestObject* impl = V8TestObject::toImpl(holder);
1759 V8StringResource<TreatNullAsNullString> cppValue = v8Value; 1766 V8StringResource<TreatNullAsNullString> cppValue = v8Value;
1760 if (!cppValue.prepare()) 1767 if (!cppValue.prepare())
1761 return; 1768 return;
1762 String string = cppValue; 1769 static const char* validValues[] = {
1763 if (!(string == "" || string == "EnumValue1" || string == "EnumValue2" || st ring == "EnumValue3")) { 1770 "",
1764 currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMes sage::create(JSMessageSource, WarningMessageLevel, "The provided value '" + stri ng + "' is not a valid value of type 'TestEnum'.")); 1771 "EnumValue1",
1772 "EnumValue2",
1773 "EnumValue3",
1774 };
1775 if (!isValidEnum(cppValue, validValues, WTF_ARRAY_LENGTH(validValues), excep tionState)) {
1776 currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMes sage::create(JSMessageSource, WarningMessageLevel, exceptionState.message()));
1765 return; 1777 return;
1766 } 1778 }
1767 impl->setTestEnumOrNullAttribute(cppValue); 1779 impl->setTestEnumOrNullAttribute(cppValue);
1768 } 1780 }
1769 1781
1770 static void testEnumOrNullAttributeAttributeSetterCallback(v8::Local<v8::Name>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 1782 static void testEnumOrNullAttributeAttributeSetterCallback(v8::Local<v8::Name>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
1771 { 1783 {
1772 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); 1784 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
1773 TestObjectV8Internal::testEnumOrNullAttributeAttributeSetter(v8Value, info); 1785 TestObjectV8Internal::testEnumOrNullAttributeAttributeSetter(v8Value, info);
1774 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 1786 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
(...skipping 3748 matching lines...) Expand 10 before | Expand all | Expand 10 after
5523 static void enumForPrivateScriptAttributeGetterCallback(v8::Local<v8::Name>, con st v8::PropertyCallbackInfo<v8::Value>& info) 5535 static void enumForPrivateScriptAttributeGetterCallback(v8::Local<v8::Name>, con st v8::PropertyCallbackInfo<v8::Value>& info)
5524 { 5536 {
5525 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 5537 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
5526 TestObjectV8Internal::enumForPrivateScriptAttributeGetter(info); 5538 TestObjectV8Internal::enumForPrivateScriptAttributeGetter(info);
5527 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 5539 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
5528 } 5540 }
5529 5541
5530 static void enumForPrivateScriptAttributeSetter(v8::Local<v8::Value> v8Value, co nst v8::PropertyCallbackInfo<void>& info) 5542 static void enumForPrivateScriptAttributeSetter(v8::Local<v8::Value> v8Value, co nst v8::PropertyCallbackInfo<void>& info)
5531 { 5543 {
5532 v8::Local<v8::Object> holder = info.Holder(); 5544 v8::Local<v8::Object> holder = info.Holder();
5545 ExceptionState exceptionState(ExceptionState::SetterContext, "enumForPrivate Script", "TestObject", holder, info.GetIsolate());
5533 TestObject* impl = V8TestObject::toImpl(holder); 5546 TestObject* impl = V8TestObject::toImpl(holder);
5534 V8StringResource<> cppValue = v8Value; 5547 V8StringResource<> cppValue = v8Value;
5535 if (!cppValue.prepare()) 5548 if (!cppValue.prepare())
5536 return; 5549 return;
5537 String string = cppValue; 5550 static const char* validValues[] = {
5538 if (!(string == "" || string == "EnumValue1" || string == "EnumValue2" || st ring == "EnumValue3")) { 5551 "",
5539 currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMes sage::create(JSMessageSource, WarningMessageLevel, "The provided value '" + stri ng + "' is not a valid value of type 'TestEnum'.")); 5552 "EnumValue1",
5553 "EnumValue2",
5554 "EnumValue3",
5555 };
5556 if (!isValidEnum(cppValue, validValues, WTF_ARRAY_LENGTH(validValues), excep tionState)) {
5557 currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMes sage::create(JSMessageSource, WarningMessageLevel, exceptionState.message()));
5540 return; 5558 return;
5541 } 5559 }
5542 V8TestObject::PrivateScript::enumForPrivateScriptAttributeSetter(toLocalFram e(toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext())), impl, cppValue) ; 5560 V8TestObject::PrivateScript::enumForPrivateScriptAttributeSetter(toLocalFram e(toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext())), impl, cppValue) ;
5543 } 5561 }
5544 5562
5545 static void enumForPrivateScriptAttributeSetterCallback(v8::Local<v8::Name>, v8: :Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 5563 static void enumForPrivateScriptAttributeSetterCallback(v8::Local<v8::Name>, v8: :Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
5546 { 5564 {
5547 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); 5565 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
5548 TestObjectV8Internal::enumForPrivateScriptAttributeSetter(v8Value, info); 5566 TestObjectV8Internal::enumForPrivateScriptAttributeSetter(v8Value, info);
5549 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 5567 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
(...skipping 1832 matching lines...) Expand 10 before | Expand all | Expand 10 after
7382 7400
7383 static void testEnumMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Valu e>& info) 7401 static void testEnumMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Valu e>& info)
7384 { 7402 {
7385 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 7403 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
7386 TestObjectV8Internal::testEnumMethodMethod(info); 7404 TestObjectV8Internal::testEnumMethodMethod(info);
7387 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 7405 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
7388 } 7406 }
7389 7407
7390 static void voidMethodTestEnumArgMethod(const v8::FunctionCallbackInfo<v8::Value >& info) 7408 static void voidMethodTestEnumArgMethod(const v8::FunctionCallbackInfo<v8::Value >& info)
7391 { 7409 {
7410 ExceptionState exceptionState(ExceptionState::ExecutionContext, "voidMethodT estEnumArg", "TestObject", info.Holder(), info.GetIsolate());
7392 if (UNLIKELY(info.Length() < 1)) { 7411 if (UNLIKELY(info.Length() < 1)) {
7393 V8ThrowException::throwException(createMinimumArityTypeErrorForMethod(in fo.GetIsolate(), "voidMethodTestEnumArg", "TestObject", 1, info.Length()), info. GetIsolate()); 7412 setMinimumArityTypeError(exceptionState, 1, info.Length());
7413 exceptionState.throwIfNeeded();
7394 return; 7414 return;
7395 } 7415 }
7396 TestObject* impl = V8TestObject::toImpl(info.Holder()); 7416 TestObject* impl = V8TestObject::toImpl(info.Holder());
7397 V8StringResource<> testEnumTypeArg; 7417 V8StringResource<> testEnumTypeArg;
7398 { 7418 {
7399 testEnumTypeArg = info[0]; 7419 testEnumTypeArg = info[0];
7400 if (!testEnumTypeArg.prepare()) 7420 if (!testEnumTypeArg.prepare())
7401 return; 7421 return;
7402 String string = testEnumTypeArg; 7422 static const char* validValues[] = {
7403 if (!(string == "" || string == "EnumValue1" || string == "EnumValue2" | | string == "EnumValue3")) { 7423 "",
7404 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessage s::failedToExecute("voidMethodTestEnumArg", "TestObject", "parameter 1 ('" + str ing + "') is not a valid enum value.")); 7424 "EnumValue1",
7425 "EnumValue2",
7426 "EnumValue3",
7427 };
7428 if (!isValidEnum(testEnumTypeArg, validValues, WTF_ARRAY_LENGTH(validVal ues), exceptionState)) {
7429 exceptionState.throwIfNeeded();
7405 return; 7430 return;
7406 } 7431 }
7407 } 7432 }
7408 impl->voidMethodTestEnumArg(testEnumTypeArg); 7433 impl->voidMethodTestEnumArg(testEnumTypeArg);
7409 } 7434 }
7410 7435
7411 static void voidMethodTestEnumArgMethodCallback(const v8::FunctionCallbackInfo<v 8::Value>& info) 7436 static void voidMethodTestEnumArgMethodCallback(const v8::FunctionCallbackInfo<v 8::Value>& info)
7412 { 7437 {
7413 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 7438 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
7414 TestObjectV8Internal::voidMethodTestEnumArgMethod(info); 7439 TestObjectV8Internal::voidMethodTestEnumArgMethod(info);
(...skipping 5808 matching lines...) Expand 10 before | Expand all | Expand 10 after
13223 return false; 13248 return false;
13224 13249
13225 ScriptState::Scope scope(scriptState); 13250 ScriptState::Scope scope(scriptState);
13226 v8::Local<v8::Value> holder = toV8(holderImpl, scriptState->context()->Globa l(), scriptState->isolate()); 13251 v8::Local<v8::Value> holder = toV8(holderImpl, scriptState->context()->Globa l(), scriptState->isolate());
13227 13252
13228 ExceptionState exceptionState(ExceptionState::SetterContext, "enumForPrivate Script", "TestObject", scriptState->context()->Global(), scriptState->isolate()) ; 13253 ExceptionState exceptionState(ExceptionState::SetterContext, "enumForPrivate Script", "TestObject", scriptState->context()->Global(), scriptState->isolate()) ;
13229 return PrivateScriptRunner::runDOMAttributeSetter(scriptState, scriptStateIn UserScript, "TestObject", "enumForPrivateScript", holder, v8String(scriptState-> isolate(), cppValue)); 13254 return PrivateScriptRunner::runDOMAttributeSetter(scriptState, scriptStateIn UserScript, "TestObject", "enumForPrivateScript", holder, v8String(scriptState-> isolate(), cppValue));
13230 } 13255 }
13231 13256
13232 } // namespace blink 13257 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698