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

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

Issue 618373003: [bindings] partial interfaces should not violate componentization (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed http/tests/serviceworker/fetch\* regression Created 6 years, 2 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/core/V8TestInterface.cpp
diff --git a/Source/bindings/tests/results/core/V8TestInterface.cpp b/Source/bindings/tests/results/core/V8TestInterface.cpp
index 686c2f77e0f056133ccf9e1d2c97336a37c6e1c9..628844fdefc6f57699437d4c6a3f03d6a0c450e5 100644
--- a/Source/bindings/tests/results/core/V8TestInterface.cpp
+++ b/Source/bindings/tests/results/core/V8TestInterface.cpp
@@ -25,7 +25,6 @@
#include "bindings/tests/idls/core/TestImplements3Implementation.h"
#include "bindings/tests/idls/core/TestPartialInterface.h"
#include "bindings/tests/idls/core/TestPartialInterfaceImplementation.h"
-#include "bindings/tests/idls/modules/TestPartialInterfaceImplementation3.h"
#include "core/dom/ContextFeatures.h"
#include "core/dom/Document.h"
#include "core/frame/LocalFrame.h"
@@ -37,7 +36,7 @@
namespace blink {
-const WrapperTypeInfo V8TestInterface::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterface::domTemplate, V8TestInterface::refObject, V8TestInterface::derefObject, V8TestInterface::createPersistentHandle, V8TestInterface::toActiveDOMObject, 0, V8TestInterface::visitDOMWrapper, V8TestInterface::installConditionallyEnabledMethods, V8TestInterface::installConditionallyEnabledProperties, &V8TestInterfaceEmpty::wrapperTypeInfo, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::Dependent, WrapperTypeInfo::RefCountedObject };
+WrapperTypeInfo V8TestInterface::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterface::domTemplate, V8TestInterface::refObject, V8TestInterface::derefObject, V8TestInterface::createPersistentHandle, V8TestInterface::toActiveDOMObject, 0, V8TestInterface::visitDOMWrapper, V8TestInterface::installConditionallyEnabledMethods, V8TestInterface::installConditionallyEnabledProperties, &V8TestInterfaceEmpty::wrapperTypeInfo, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::Dependent, WrapperTypeInfo::RefCountedObject };
// This static member must be declared by DEFINE_WRAPPERTYPEINFO in TestInterfaceImplementation.h.
// For details, see the comment of DEFINE_WRAPPERTYPEINFO in
@@ -45,6 +44,8 @@ const WrapperTypeInfo V8TestInterface::wrapperTypeInfo = { gin::kEmbedderBlink,
const WrapperTypeInfo& TestInterfaceImplementation::s_wrapperTypeInfo = V8TestInterface::wrapperTypeInfo;
namespace TestInterfaceImplementationV8Internal {
+static void (*partial2VoidMethodMethodForPartialInterface)(const v8::FunctionCallbackInfo<v8::Value>&) = 0;
+static void (*partial2StaticVoidMethodMethodForPartialInterface)(const v8::FunctionCallbackInfo<v8::Value>&) = 0;
static void testInterfaceAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
{
@@ -897,62 +898,6 @@ static void partial2StaticLongAttributeAttributeSetterCallback(v8::Local<v8::Str
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
-static void partial3LongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
-{
- v8::Handle<v8::Object> holder = info.Holder();
- TestInterfaceImplementation* impl = V8TestInterface::toImpl(holder);
- v8SetReturnValueInt(info, TestPartialInterfaceImplementation3::partial3LongAttribute(*impl));
-}
-
-static void partial3LongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
-{
- TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
- TestInterfaceImplementationV8Internal::partial3LongAttributeAttributeGetter(info);
- TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
-}
-
-static void partial3LongAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
-{
- v8::Handle<v8::Object> holder = info.Holder();
- ExceptionState exceptionState(ExceptionState::SetterContext, "partial3LongAttribute", "TestInterface", holder, info.GetIsolate());
- TestInterfaceImplementation* impl = V8TestInterface::toImpl(holder);
- TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionState), exceptionState);
- TestPartialInterfaceImplementation3::setPartial3LongAttribute(*impl, cppValue);
-}
-
-static void partial3LongAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
-{
- TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
- TestInterfaceImplementationV8Internal::partial3LongAttributeAttributeSetter(v8Value, info);
- TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
-}
-
-static void partial3StaticLongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
-{
- v8SetReturnValueInt(info, TestPartialInterfaceImplementation3::partial3StaticLongAttribute());
-}
-
-static void partial3StaticLongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
-{
- TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
- TestInterfaceImplementationV8Internal::partial3StaticLongAttributeAttributeGetter(info);
- TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
-}
-
-static void partial3StaticLongAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
-{
- ExceptionState exceptionState(ExceptionState::SetterContext, "partial3StaticLongAttribute", "TestInterface", holder, info.GetIsolate());
- TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionState), exceptionState);
- TestPartialInterfaceImplementation3::setPartial3StaticLongAttribute(cppValue);
-}
-
-static void partial3StaticLongAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
-{
- TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
- TestInterfaceImplementationV8Internal::partial3StaticLongAttributeAttributeSetter(v8Value, info);
- TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
-}
-
static void TestInterfaceImplementationConstructorGetter(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
v8::Handle<v8::Value> data = info.Data();
@@ -1453,57 +1398,6 @@ static void partial2StaticVoidMethod1Method(const v8::FunctionCallbackInfo<v8::V
TestPartialInterfaceImplementation::partial2StaticVoidMethod();
}
-static void voidMethodPartialOverloadMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
-{
- if (UNLIKELY(info.Length() < 1)) {
- V8ThrowException::throwException(createMinimumArityTypeErrorForMethod("voidMethodPartialOverload", "TestInterface", 1, info.Length(), info.GetIsolate()), info.GetIsolate());
- return;
- }
- TestInterfaceImplementation* impl = V8TestInterface::toImpl(info.Holder());
- V8StringResource<> value;
- {
- TOSTRING_VOID_INTERNAL(value, info[0]);
- }
- TestPartialInterfaceImplementation3::voidMethodPartialOverload(*impl, value);
-}
-
-static void voidMethodPartialOverloadMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
-{
- TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
- TestInterfaceImplementationV8Internal::voidMethodPartialOverloadMethod(info);
- TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
-}
-
-static void voidMethodPartialOverloadMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
-{
- if (UNLIKELY(info.Length() < 1)) {
- V8ThrowException::throwException(createMinimumArityTypeErrorForMethod("voidMethodPartialOverload", "TestInterface", 1, info.Length(), info.GetIsolate()), info.GetIsolate());
- return;
- }
- V8StringResource<> value;
- {
- TOSTRING_VOID_INTERNAL(value, info[0]);
- }
- TestPartialInterfaceImplementation3::voidMethodPartialOverload(value);
-}
-
-static void voidMethodPartialOverloadMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
-{
- TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
- TestInterfaceImplementationV8Internal::voidMethodPartialOverloadMethod(info);
- TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
-}
-
-static void partial2VoidMethod2Method(const v8::FunctionCallbackInfo<v8::Value>& info)
-{
- TestInterfaceImplementation* impl = V8TestInterface::toImpl(info.Holder());
- V8StringResource<> value;
- {
- TOSTRING_VOID_INTERNAL(value, info[0]);
- }
- TestPartialInterfaceImplementation3::partial2VoidMethod(*impl, value);
-}
-
static void partial2VoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ExceptionState exceptionState(ExceptionState::ExecutionContext, "partial2VoidMethod", "TestInterface", info.Holder(), info.GetIsolate());
@@ -1515,16 +1409,20 @@ static void partial2VoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>&
}
break;
case 1:
- if (true) {
- partial2VoidMethod2Method(info);
- return;
- }
break;
default:
+ if (partial2VoidMethodMethodForPartialInterface) {
haraken 2014/10/09 04:24:02 Is it possible that partial2VoidMethodMethodForPar
tasak 2014/10/10 07:52:24 Done. If we want downloadable modules, we will ini
+ (partial2VoidMethodMethodForPartialInterface)(info);
+ return;
+ }
exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(0, info.Length()));
exceptionState.throwIfNeeded();
return;
}
+ if (partial2VoidMethodMethodForPartialInterface) {
haraken 2014/10/09 04:24:02 Ditto.
tasak 2014/10/10 07:52:24 Done.
+ (partial2VoidMethodMethodForPartialInterface)(info);
+ return;
+ }
exceptionState.throwTypeError("No function was found that matched the signature provided.");
exceptionState.throwIfNeeded();
}
@@ -1536,15 +1434,6 @@ static void partial2VoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
-static void partial2StaticVoidMethod2Method(const v8::FunctionCallbackInfo<v8::Value>& info)
-{
- V8StringResource<> value;
- {
- TOSTRING_VOID_INTERNAL(value, info[0]);
- }
- TestPartialInterfaceImplementation3::partial2StaticVoidMethod(value);
-}
-
static void partial2StaticVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ExceptionState exceptionState(ExceptionState::ExecutionContext, "partial2StaticVoidMethod", "TestInterface", info.Holder(), info.GetIsolate());
@@ -1556,16 +1445,20 @@ static void partial2StaticVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Va
}
break;
case 1:
- if (true) {
- partial2StaticVoidMethod2Method(info);
- return;
- }
break;
default:
+ if (partial2StaticVoidMethodMethodForPartialInterface) {
+ (partial2StaticVoidMethodMethodForPartialInterface)(info);
+ return;
+ }
exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(0, info.Length()));
exceptionState.throwIfNeeded();
return;
}
+ if (partial2StaticVoidMethodMethodForPartialInterface) {
+ (partial2StaticVoidMethodMethodForPartialInterface)(info);
+ return;
+ }
exceptionState.throwTypeError("No function was found that matched the signature provided.");
exceptionState.throwIfNeeded();
}
@@ -1806,7 +1699,7 @@ static const V8DOMConfiguration::MethodConfiguration V8TestInterfaceMethods[] =
{"partial2VoidMethod", TestInterfaceImplementationV8Internal::partial2VoidMethodMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts},
};
-static void installV8TestInterfaceTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
+void V8TestInterface::installV8TestInterfaceTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
{
functionTemplate->ReadOnlyPrototype();
@@ -1865,7 +1758,6 @@ static void installV8TestInterfaceTemplate(v8::Handle<v8::FunctionTemplate> func
{"IMPLEMENTS_CONSTANT_1", 1, 0, 0, V8DOMConfiguration::ConstantTypeUnsignedShort},
{"IMPLEMENTS_CONSTANT_2", 2, 0, 0, V8DOMConfiguration::ConstantTypeUnsignedShort},
{"PARTIAL2_UNSIGNED_SHORT", 0, 0, 0, V8DOMConfiguration::ConstantTypeUnsignedShort},
- {"PARTIAL3_UNSIGNED_SHORT", 0, 0, 0, V8DOMConfiguration::ConstantTypeUnsignedShort},
};
V8DOMConfiguration::installConstants(functionTemplate, prototypeTemplate, V8TestInterfaceConstants, WTF_ARRAY_LENGTH(V8TestInterfaceConstants), isolate);
if (RuntimeEnabledFeatures::partialFeatureNameEnabled()) {
@@ -1964,7 +1856,6 @@ static void installV8TestInterfaceTemplate(v8::Handle<v8::FunctionTemplate> func
functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "partialStaticLongAttribute"), TestInterfaceImplementationV8Internal::partialStaticLongAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::partialStaticLongAttributeAttributeSetterCallback, v8::External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT));
#endif // ENABLE(PARTIAL_CONDITION)
functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "partial2StaticLongAttribute"), TestInterfaceImplementationV8Internal::partial2StaticLongAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::partial2StaticLongAttributeAttributeSetterCallback, v8::External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT));
- functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "partial3StaticLongAttribute"), TestInterfaceImplementationV8Internal::partial3StaticLongAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::partial3StaticLongAttributeAttributeSetterCallback, v8::External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT));
// Custom toString template
functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
@@ -1972,7 +1863,7 @@ static void installV8TestInterfaceTemplate(v8::Handle<v8::FunctionTemplate> func
v8::Handle<v8::FunctionTemplate> V8TestInterface::domTemplate(v8::Isolate* isolate)
{
- return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestInterfaceTemplate);
+ return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), V8TestInterface::installV8TestInterfaceTemplateFunction);
haraken 2014/10/09 04:24:02 Can we add an assert to verify that V8TestInterfac
tasak 2014/10/10 07:52:24 Done.
}
bool V8TestInterface::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
@@ -2020,16 +1911,6 @@ void V8TestInterface::installConditionallyEnabledProperties(v8::Handle<v8::Objec
{"partial2StaticLongAttribute", TestInterfaceImplementationV8Internal::partial2StaticLongAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::partial2StaticLongAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance};
V8DOMConfiguration::installAttribute(instanceObject, prototypeObject, attributeConfiguration, isolate);
}
- if (context && context->isDocument() && ContextFeatures::partialContextName3Enabled(toDocument(context))) {
- static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
- {"partial3LongAttribute", TestInterfaceImplementationV8Internal::partial3LongAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::partial3LongAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance};
- V8DOMConfiguration::installAttribute(instanceObject, prototypeObject, attributeConfiguration, isolate);
- }
- if (context && context->isDocument() && ContextFeatures::partialContextName3Enabled(toDocument(context))) {
- static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
- {"partial3StaticLongAttribute", TestInterfaceImplementationV8Internal::partial3StaticLongAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::partial3StaticLongAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance};
- V8DOMConfiguration::installAttribute(instanceObject, prototypeObject, attributeConfiguration, isolate);
- }
}
void V8TestInterface::installConditionallyEnabledMethods(v8::Handle<v8::Object> prototypeObject, v8::Isolate* isolate)
@@ -2053,12 +1934,6 @@ void V8TestInterface::installConditionallyEnabledMethods(v8::Handle<v8::Object>
if (context && (context->isDocument() || context->isServiceWorkerGlobalScope())) {
prototypeObject->Set(v8AtomicString(isolate, "windowAndServiceWorkerExposedMethod"), v8::FunctionTemplate::New(isolate, TestInterfaceImplementationV8Internal::windowAndServiceWorkerExposedMethodMethodCallback, v8Undefined(), defaultSignature, 0)->GetFunction());
}
- if (context && context->isDocument() && ContextFeatures::partialContextName3Enabled(toDocument(context))) {
- prototypeObject->Set(v8AtomicString(isolate, "voidMethodPartialOverload"), v8::FunctionTemplate::New(isolate, TestInterfaceImplementationV8Internal::voidMethodPartialOverloadMethodCallback, v8Undefined(), defaultSignature, 1)->GetFunction());
- }
- if (context && context->isDocument() && ContextFeatures::partialContextName3Enabled(toDocument(context))) {
- prototypeObject->Set(v8AtomicString(isolate, "voidMethodPartialOverload"), v8::FunctionTemplate::New(isolate, TestInterfaceImplementationV8Internal::voidMethodPartialOverloadMethodCallback, v8Undefined(), defaultSignature, 1)->GetFunction());
- }
}
ActiveDOMObject* V8TestInterface::toActiveDOMObject(v8::Handle<v8::Object> wrapper)
@@ -2166,5 +2041,22 @@ bool V8TestInterface::PrivateScript::stringAttributeAttributeSetter(LocalFrame*
return PrivateScriptRunner::runDOMAttributeSetter(scriptState, scriptStateInUserScript, "TestInterfaceImplementation", "stringAttribute", holder, v8String(scriptState->isolate(), cppValue));
}
+InstallTemplateFunction V8TestInterface::installV8TestInterfaceTemplateFunction = (InstallTemplateFunction)&V8TestInterface::installV8TestInterfaceTemplate;
+
+void V8TestInterface::updateWrapperTypeInfo(InstallTemplateFunction installTemplateFunction, InstallConditionallyEnabledMethodsFunction installConditionallyEnabledMethodsFunction)
+{
+ V8TestInterface::installV8TestInterfaceTemplateFunction = installTemplateFunction;
+ if (installConditionallyEnabledMethodsFunction)
+ V8TestInterface::wrapperTypeInfo.installConditionallyEnabledMethodsFunction = installConditionallyEnabledMethodsFunction;
+}
+
+void V8TestInterface::registerPartial2VoidMethodMethodForPartialInterface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&))
+{
+ TestInterfaceImplementationV8Internal::partial2VoidMethodMethodForPartialInterface = method;
+}
+void V8TestInterface::registerPartial2StaticVoidMethodMethodForPartialInterface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&))
+{
+ TestInterfaceImplementationV8Internal::partial2StaticVoidMethodMethodForPartialInterface = method;
+}
} // namespace blink
#endif // ENABLE(CONDITION)

Powered by Google App Engine
This is Rietveld 408576698