| 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..3ce0b50581a3903365da57571ac3395761cfae6b 100644
|
| --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor2.cpp
|
| +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor2.cpp
|
| @@ -15,6 +15,7 @@
|
| #include "bindings/core/v8/GeneratedCodeHelper.h"
|
| #include "bindings/core/v8/V8DOMConfiguration.h"
|
| #include "bindings/core/v8/V8ObjectConstructor.h"
|
| +#include "bindings/core/v8/V8PrivateProperty.h"
|
| #include "core/dom/Document.h"
|
| #include "core/frame/LocalDOMWindow.h"
|
| #include "wtf/GetPtr.h"
|
| @@ -103,12 +104,47 @@ v8::Local<v8::FunctionTemplate> V8TestInterfaceNamedConstructor2Constructor::dom
|
| result = v8::FunctionTemplate::New(isolate, V8TestInterfaceNamedConstructor2ConstructorCallback);
|
| v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate();
|
| instanceTemplate->SetInternalFieldCount(V8TestInterfaceNamedConstructor2::internalFieldCount);
|
| - result->SetClassName(v8AtomicString(isolate, "TestInterfaceNamedConstructor2"));
|
| + result->SetClassName(v8AtomicString(isolate, "Audio"));
|
| result->Inherit(V8TestInterfaceNamedConstructor2::domTemplate(isolate, world));
|
| data->setInterfaceTemplate(world, &domTemplateKey, result);
|
| return result;
|
| }
|
|
|
| +void V8TestInterfaceNamedConstructor2Constructor::NamedConstructorAttributeGetter(
|
| + v8::Local<v8::Name> propertyName,
|
| + const v8::PropertyCallbackInfo<v8::Value>& info) {
|
| + v8::Local<v8::Context> currentContext = info.Holder()->CreationContext();
|
| + V8PerContextData* perContextData = V8PerContextData::from(currentContext);
|
| + if (!perContextData)
|
| + return;
|
| +
|
| + v8::Local<v8::Function> namedConstructor = perContextData->constructorForType(&V8TestInterfaceNamedConstructor2Constructor::wrapperTypeInfo);
|
| +
|
| + // Set the prototype of named constructors to the regular constructor.
|
| + auto privateProperty = V8PrivateProperty::getNamedConstructorInitialized(info.GetIsolate());
|
| + v8::Local<v8::Value> privateValue = privateProperty.get(currentContext, namedConstructor);
|
| + if (privateValue.IsEmpty()) {
|
| + v8::Local<v8::Function> interface = perContextData->constructorForType(&V8TestInterfaceNamedConstructor2::wrapperTypeInfo);
|
| + // Only Window exposes named constructors, so that will always be the interface name.
|
| + ExceptionState exceptionState(info.GetIsolate(), ExceptionState::GetterContext, "Window", "Audio");
|
| + v8::MaybeLocal<v8::Value> interfacePrototype = interface->Get(currentContext, v8AtomicString(info.GetIsolate(), "prototype"));
|
| + if (interfacePrototype.IsEmpty()) {
|
| + exceptionState.throwTypeError("Could not get prototype for V8TestInterfaceNamedConstructor2.");
|
| + return;
|
| + }
|
| +
|
| + v8::Maybe<bool> setResult = namedConstructor->Set(currentContext, v8AtomicString(info.GetIsolate(), "prototype"), interfacePrototype.ToLocalChecked());
|
| + if (setResult.IsNothing() || setResult.ToChecked() != true) {
|
| + exceptionState.throwTypeError("Could not set prototype for Audio.");
|
| + return;
|
| + }
|
| +
|
| + privateProperty.set(currentContext, namedConstructor, v8::True(info.GetIsolate()));
|
| + }
|
| +
|
| + v8SetReturnValue(info, namedConstructor);
|
| +}
|
| +
|
| 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);
|
|
|