Rebaseline bindings tests results after r183648.
[WebKit-https.git] / Source / WebCore / bindings / scripts / test / JS / JSTestActiveDOMObject.cpp
1 /*
2     This file is part of the WebKit open source project.
3     This file has been generated by generate-bindings.pl. DO NOT MODIFY!
4
5     This library is free software; you can redistribute it and/or
6     modify it under the terms of the GNU Library General Public
7     License as published by the Free Software Foundation; either
8     version 2 of the License, or (at your option) any later version.
9
10     This library is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13     Library General Public License for more details.
14
15     You should have received a copy of the GNU Library General Public License
16     along with this library; see the file COPYING.LIB.  If not, write to
17     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18     Boston, MA 02110-1301, USA.
19 */
20
21 #include "config.h"
22 #include "JSTestActiveDOMObject.h"
23
24 #include "ExceptionCode.h"
25 #include "JSDOMBinding.h"
26 #include "JSNode.h"
27 #include "ScriptExecutionContext.h"
28 #include "TestActiveDOMObject.h"
29 #include <runtime/Error.h>
30 #include <wtf/GetPtr.h>
31
32 using namespace JSC;
33
34 namespace WebCore {
35
36 // Functions
37
38 JSC::EncodedJSValue JSC_HOST_CALL jsTestActiveDOMObjectPrototypeFunctionExcitingFunction(JSC::ExecState*);
39 JSC::EncodedJSValue JSC_HOST_CALL jsTestActiveDOMObjectPrototypeFunctionPostMessage(JSC::ExecState*);
40
41 // Attributes
42
43 JSC::EncodedJSValue jsTestActiveDOMObjectExcitingAttr(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
44 JSC::EncodedJSValue jsTestActiveDOMObjectConstructor(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
45
46 class JSTestActiveDOMObjectPrototype : public JSC::JSNonFinalObject {
47 public:
48     typedef JSC::JSNonFinalObject Base;
49     static JSTestActiveDOMObjectPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
50     {
51         JSTestActiveDOMObjectPrototype* ptr = new (NotNull, JSC::allocateCell<JSTestActiveDOMObjectPrototype>(vm.heap)) JSTestActiveDOMObjectPrototype(vm, globalObject, structure);
52         ptr->finishCreation(vm);
53         return ptr;
54     }
55
56     DECLARE_INFO;
57     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
58     {
59         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
60     }
61
62 private:
63     JSTestActiveDOMObjectPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
64         : JSC::JSNonFinalObject(vm, structure)
65     {
66     }
67
68     void finishCreation(JSC::VM&);
69 };
70
71 class JSTestActiveDOMObjectConstructor : public DOMConstructorObject {
72 private:
73     JSTestActiveDOMObjectConstructor(JSC::Structure*, JSDOMGlobalObject*);
74     void finishCreation(JSC::VM&, JSDOMGlobalObject*);
75
76 public:
77     typedef DOMConstructorObject Base;
78     static JSTestActiveDOMObjectConstructor* create(JSC::VM& vm, JSC::Structure* structure, JSDOMGlobalObject* globalObject)
79     {
80         JSTestActiveDOMObjectConstructor* ptr = new (NotNull, JSC::allocateCell<JSTestActiveDOMObjectConstructor>(vm.heap)) JSTestActiveDOMObjectConstructor(structure, globalObject);
81         ptr->finishCreation(vm, globalObject);
82         return ptr;
83     }
84
85     DECLARE_INFO;
86     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
87     {
88         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
89     }
90 };
91
92 /* Hash table */
93
94 static const struct CompactHashIndex JSTestActiveDOMObjectTableIndex[4] = {
95     { 1, -1 },
96     { 0, -1 },
97     { -1, -1 },
98     { -1, -1 },
99 };
100
101
102 static const HashTableValue JSTestActiveDOMObjectTableValues[] =
103 {
104     { "constructor", DontEnum | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestActiveDOMObjectConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
105     { "excitingAttr", DontDelete | ReadOnly | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestActiveDOMObjectExcitingAttr), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
106 };
107
108 static const HashTable JSTestActiveDOMObjectTable = { 2, 3, true, JSTestActiveDOMObjectTableValues, 0, JSTestActiveDOMObjectTableIndex };
109 const ClassInfo JSTestActiveDOMObjectConstructor::s_info = { "TestActiveDOMObjectConstructor", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestActiveDOMObjectConstructor) };
110
111 JSTestActiveDOMObjectConstructor::JSTestActiveDOMObjectConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
112     : DOMConstructorObject(structure, globalObject)
113 {
114 }
115
116 void JSTestActiveDOMObjectConstructor::finishCreation(VM& vm, JSDOMGlobalObject* globalObject)
117 {
118     Base::finishCreation(vm);
119     ASSERT(inherits(info()));
120     putDirect(vm, vm.propertyNames->prototype, JSTestActiveDOMObject::getPrototype(vm, globalObject), DontDelete | ReadOnly);
121     putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
122 }
123
124 /* Hash table for prototype */
125
126 static const HashTableValue JSTestActiveDOMObjectPrototypeTableValues[] =
127 {
128     { "excitingFunction", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestActiveDOMObjectPrototypeFunctionExcitingFunction), (intptr_t) (1) },
129     { "postMessage", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestActiveDOMObjectPrototypeFunctionPostMessage), (intptr_t) (1) },
130 };
131
132 const ClassInfo JSTestActiveDOMObjectPrototype::s_info = { "TestActiveDOMObjectPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestActiveDOMObjectPrototype) };
133
134 void JSTestActiveDOMObjectPrototype::finishCreation(VM& vm)
135 {
136     Base::finishCreation(vm);
137     reifyStaticProperties(vm, JSTestActiveDOMObjectPrototypeTableValues, *this);
138 }
139
140 const ClassInfo JSTestActiveDOMObject::s_info = { "TestActiveDOMObject", &Base::s_info, &JSTestActiveDOMObjectTable, CREATE_METHOD_TABLE(JSTestActiveDOMObject) };
141
142 JSTestActiveDOMObject::JSTestActiveDOMObject(Structure* structure, JSDOMGlobalObject* globalObject, Ref<TestActiveDOMObject>&& impl)
143     : JSDOMWrapper(structure, globalObject)
144     , m_impl(&impl.leakRef())
145 {
146 }
147
148 JSObject* JSTestActiveDOMObject::createPrototype(VM& vm, JSGlobalObject* globalObject)
149 {
150     return JSTestActiveDOMObjectPrototype::create(vm, globalObject, JSTestActiveDOMObjectPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
151 }
152
153 JSObject* JSTestActiveDOMObject::getPrototype(VM& vm, JSGlobalObject* globalObject)
154 {
155     return getDOMPrototype<JSTestActiveDOMObject>(vm, globalObject);
156 }
157
158 void JSTestActiveDOMObject::destroy(JSC::JSCell* cell)
159 {
160     JSTestActiveDOMObject* thisObject = static_cast<JSTestActiveDOMObject*>(cell);
161     thisObject->JSTestActiveDOMObject::~JSTestActiveDOMObject();
162 }
163
164 JSTestActiveDOMObject::~JSTestActiveDOMObject()
165 {
166     releaseImpl();
167 }
168
169 bool JSTestActiveDOMObject::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
170 {
171     auto* thisObject = jsCast<JSTestActiveDOMObject*>(object);
172     ASSERT_GC_OBJECT_INHERITS(thisObject, info());
173     return getStaticValueSlot<JSTestActiveDOMObject, Base>(exec, JSTestActiveDOMObjectTable, thisObject, propertyName, slot);
174 }
175
176 EncodedJSValue jsTestActiveDOMObjectExcitingAttr(ExecState* exec, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
177 {
178     UNUSED_PARAM(exec);
179     UNUSED_PARAM(slotBase);
180     UNUSED_PARAM(thisValue);
181     auto* castedThis = jsCast<JSTestActiveDOMObject*>(slotBase);
182     if (!BindingSecurity::shouldAllowAccessToDOMWindow(exec, castedThis->impl()))
183         return JSValue::encode(jsUndefined());
184     auto& impl = castedThis->impl();
185     JSValue result = jsNumber(impl.excitingAttr());
186     return JSValue::encode(result);
187 }
188
189
190 EncodedJSValue jsTestActiveDOMObjectConstructor(ExecState* exec, JSObject*, EncodedJSValue thisValue, PropertyName)
191 {
192     JSTestActiveDOMObject* domObject = jsDynamicCast<JSTestActiveDOMObject*>(JSValue::decode(thisValue));
193     if (!domObject)
194         return throwVMTypeError(exec);
195     if (!BindingSecurity::shouldAllowAccessToDOMWindow(exec, domObject->impl()))
196         return JSValue::encode(jsUndefined());
197     return JSValue::encode(JSTestActiveDOMObject::getConstructor(exec->vm(), domObject->globalObject()));
198 }
199
200 JSValue JSTestActiveDOMObject::getConstructor(VM& vm, JSGlobalObject* globalObject)
201 {
202     return getDOMConstructor<JSTestActiveDOMObjectConstructor>(vm, jsCast<JSDOMGlobalObject*>(globalObject));
203 }
204
205 EncodedJSValue JSC_HOST_CALL jsTestActiveDOMObjectPrototypeFunctionExcitingFunction(ExecState* exec)
206 {
207     JSValue thisValue = exec->thisValue();
208     JSTestActiveDOMObject* castedThis = jsDynamicCast<JSTestActiveDOMObject*>(thisValue);
209     if (UNLIKELY(!castedThis))
210         return throwThisTypeError(*exec, "TestActiveDOMObject", "excitingFunction");
211     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestActiveDOMObject::info());
212     if (!BindingSecurity::shouldAllowAccessToDOMWindow(exec, castedThis->impl()))
213         return JSValue::encode(jsUndefined());
214     auto& impl = castedThis->impl();
215     if (UNLIKELY(exec->argumentCount() < 1))
216         return throwVMError(exec, createNotEnoughArgumentsError(exec));
217     Node* nextChild(JSNode::toWrapped(exec->argument(0)));
218     if (UNLIKELY(exec->hadException()))
219         return JSValue::encode(jsUndefined());
220     impl.excitingFunction(nextChild);
221     return JSValue::encode(jsUndefined());
222 }
223
224 EncodedJSValue JSC_HOST_CALL jsTestActiveDOMObjectPrototypeFunctionPostMessage(ExecState* exec)
225 {
226     JSValue thisValue = exec->thisValue();
227     JSTestActiveDOMObject* castedThis = jsDynamicCast<JSTestActiveDOMObject*>(thisValue);
228     if (UNLIKELY(!castedThis))
229         return throwThisTypeError(*exec, "TestActiveDOMObject", "postMessage");
230     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestActiveDOMObject::info());
231     auto& impl = castedThis->impl();
232     if (UNLIKELY(exec->argumentCount() < 1))
233         return throwVMError(exec, createNotEnoughArgumentsError(exec));
234     const String message(exec->argument(0).isEmpty() ? String() : exec->argument(0).toString(exec)->value(exec));
235     if (UNLIKELY(exec->hadException()))
236         return JSValue::encode(jsUndefined());
237     impl.postMessage(message);
238     return JSValue::encode(jsUndefined());
239 }
240
241 bool JSTestActiveDOMObjectOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
242 {
243     UNUSED_PARAM(handle);
244     UNUSED_PARAM(visitor);
245     return false;
246 }
247
248 void JSTestActiveDOMObjectOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
249 {
250     auto* jsTestActiveDOMObject = jsCast<JSTestActiveDOMObject*>(handle.slot()->asCell());
251     auto& world = *static_cast<DOMWrapperWorld*>(context);
252     uncacheWrapper(world, &jsTestActiveDOMObject->impl(), jsTestActiveDOMObject);
253 }
254
255 #if ENABLE(BINDING_INTEGRITY)
256 #if PLATFORM(WIN)
257 #pragma warning(disable: 4483)
258 extern "C" { extern void (*const __identifier("??_7TestActiveDOMObject@WebCore@@6B@")[])(); }
259 #else
260 extern "C" { extern void* _ZTVN7WebCore19TestActiveDOMObjectE[]; }
261 #endif
262 #endif
263 JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject* globalObject, TestActiveDOMObject* impl)
264 {
265     if (!impl)
266         return jsNull();
267     if (JSValue result = getExistingWrapper<JSTestActiveDOMObject>(globalObject, impl))
268         return result;
269
270 #if ENABLE(BINDING_INTEGRITY)
271     void* actualVTablePointer = *(reinterpret_cast<void**>(impl));
272 #if PLATFORM(WIN)
273     void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7TestActiveDOMObject@WebCore@@6B@"));
274 #else
275     void* expectedVTablePointer = &_ZTVN7WebCore19TestActiveDOMObjectE[2];
276 #if COMPILER(CLANG)
277     // If this fails TestActiveDOMObject does not have a vtable, so you need to add the
278     // ImplementationLacksVTable attribute to the interface definition
279     COMPILE_ASSERT(__is_polymorphic(TestActiveDOMObject), TestActiveDOMObject_is_not_polymorphic);
280 #endif
281 #endif
282     // If you hit this assertion you either have a use after free bug, or
283     // TestActiveDOMObject has subclasses. If TestActiveDOMObject has subclasses that get passed
284     // to toJS() we currently require TestActiveDOMObject you to opt out of binding hardening
285     // by adding the SkipVTableValidation attribute to the interface IDL definition
286     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
287 #endif
288     return createNewWrapper<JSTestActiveDOMObject>(globalObject, impl);
289 }
290
291 TestActiveDOMObject* JSTestActiveDOMObject::toWrapped(JSC::JSValue value)
292 {
293     if (auto* wrapper = jsDynamicCast<JSTestActiveDOMObject*>(value))
294         return &wrapper->impl();
295     return nullptr;
296 }
297
298 }