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

Unified Diff: third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor2.cpp

Issue 2647643002: Fix V8 bindings for named constructors to set prototype object correctly (Closed)
Patch Set: Created 3 years, 11 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: third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor2.cpp
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor2.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor2.cpp
index bac94610ada1907fb3f6de1465a6a15a33ba92cb..d6dd136141f4a49ce98c161ebfa8bfad8caebadd 100644
--- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor2.cpp
+++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor2.cpp
@@ -109,6 +109,41 @@ v8::Local<v8::FunctionTemplate> V8TestInterfaceNamedConstructor2Constructor::dom
return result;
}
+void V8TestInterfaceNamedConstructor2Constructor::NamedConstructorAttributeGetter(
+ v8::Local<v8::Name> propertyName,
+ const v8::PropertyCallbackInfo<v8::Value>& info) {
+ ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ConstructionContext, "TestInterfaceNamedConstructor2");
+ v8::Local<v8::Value> data = info.Data();
+ DCHECK(data->IsExternal());
+ V8PerContextData* perContextData =
+ V8PerContextData::from(info.Holder()->CreationContext());
+ if (!perContextData)
+ return;
+
+ v8::Local<v8::Function> namedConstructorInterface = perContextData->constructorForType(WrapperTypeInfo::unwrap(data));
+ v8::Local<v8::Function> interface = perContextData->constructorForType(&V8TestInterfaceNamedConstructor2::wrapperTypeInfo);
+
+ // Set the prototype of named constructors to the regular constructor.
+ v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
+ auto privateProperty = V8PrivateProperty::getNamedConstructorInitialized(info.GetIsolate());
+ v8::Local<v8::Value> privateValue = privateProperty.get(context, namedConstructorInterface);
+ if (privateValue.IsEmpty()) {
+ v8::MaybeLocal<v8::Value> interfacePrototype = interface->Get(context, v8AtomicString(info.GetIsolate(), "prototype"));
+ if (interfacePrototype.IsEmpty())
+ exceptionState.throwTypeError("Could not get prototype for V8TestInterfaceNamedConstructor2.");
+
+ v8::Maybe<bool> setResult = namedConstructorInterface->Set(context, v8AtomicString(info.GetIsolate(), "prototype"), interfacePrototype.ToLocalChecked());
+ if (setResult.IsNothing() || setResult.ToChecked() != true) {
+ exceptionState.throwTypeError("Could not set prototype for TestInterfaceNamedConstructor2.");
+ }
+
+ privateProperty.set(context, namedConstructorInterface, v8::True(info.GetIsolate()));
+ }
+
+ v8SetReturnValue(
+ info, perContextData->constructorForType(WrapperTypeInfo::unwrap(data)));
+}
+
static void installV8TestInterfaceNamedConstructor2Template(v8::Isolate* isolate, const DOMWrapperWorld& world, v8::Local<v8::FunctionTemplate> interfaceTemplate) {
// Initialize the interface object's template.
V8DOMConfiguration::initializeDOMInterfaceTemplate(isolate, interfaceTemplate, V8TestInterfaceNamedConstructor2::wrapperTypeInfo.interfaceName, v8::Local<v8::FunctionTemplate>(), V8TestInterfaceNamedConstructor2::internalFieldCount);

Powered by Google App Engine
This is Rietveld 408576698