Update binding test expectation for http://trac.webkit.org/changeset/128400
[WebKit.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 "BindingSecurity.h"
25 #include "ExceptionCode.h"
26 #include "JSDOMBinding.h"
27 #include "JSNode.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 ASSERT_CLASS_FITS_IN_CELL(JSTestActiveDOMObject);
37 /* Hash table */
38
39 static const HashTableValue JSTestActiveDOMObjectTableValues[] =
40 {
41     { "excitingAttr", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestActiveDOMObjectExcitingAttr), (intptr_t)0, NoIntrinsic },
42     { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestActiveDOMObjectConstructor), (intptr_t)0, NoIntrinsic },
43     { 0, 0, 0, 0, NoIntrinsic }
44 };
45
46 static const HashTable JSTestActiveDOMObjectTable = { 4, 3, JSTestActiveDOMObjectTableValues, 0 };
47 /* Hash table for constructor */
48
49 static const HashTableValue JSTestActiveDOMObjectConstructorTableValues[] =
50 {
51     { 0, 0, 0, 0, NoIntrinsic }
52 };
53
54 static const HashTable JSTestActiveDOMObjectConstructorTable = { 1, 0, JSTestActiveDOMObjectConstructorTableValues, 0 };
55 const ClassInfo JSTestActiveDOMObjectConstructor::s_info = { "TestActiveDOMObjectConstructor", &Base::s_info, &JSTestActiveDOMObjectConstructorTable, 0, CREATE_METHOD_TABLE(JSTestActiveDOMObjectConstructor) };
56
57 JSTestActiveDOMObjectConstructor::JSTestActiveDOMObjectConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
58     : DOMConstructorObject(structure, globalObject)
59 {
60 }
61
62 void JSTestActiveDOMObjectConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
63 {
64     Base::finishCreation(exec->globalData());
65     ASSERT(inherits(&s_info));
66     putDirect(exec->globalData(), exec->propertyNames().prototype, JSTestActiveDOMObjectPrototype::self(exec, globalObject), DontDelete | ReadOnly);
67 }
68
69 bool JSTestActiveDOMObjectConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
70 {
71     return getStaticValueSlot<JSTestActiveDOMObjectConstructor, JSDOMWrapper>(exec, &JSTestActiveDOMObjectConstructorTable, jsCast<JSTestActiveDOMObjectConstructor*>(cell), propertyName, slot);
72 }
73
74 bool JSTestActiveDOMObjectConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
75 {
76     return getStaticValueDescriptor<JSTestActiveDOMObjectConstructor, JSDOMWrapper>(exec, &JSTestActiveDOMObjectConstructorTable, jsCast<JSTestActiveDOMObjectConstructor*>(object), propertyName, descriptor);
77 }
78
79 /* Hash table for prototype */
80
81 static const HashTableValue JSTestActiveDOMObjectPrototypeTableValues[] =
82 {
83     { "excitingFunction", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestActiveDOMObjectPrototypeFunctionExcitingFunction), (intptr_t)1, NoIntrinsic },
84     { "postMessage", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestActiveDOMObjectPrototypeFunctionPostMessage), (intptr_t)1, NoIntrinsic },
85     { 0, 0, 0, 0, NoIntrinsic }
86 };
87
88 static const HashTable JSTestActiveDOMObjectPrototypeTable = { 4, 3, JSTestActiveDOMObjectPrototypeTableValues, 0 };
89 const ClassInfo JSTestActiveDOMObjectPrototype::s_info = { "TestActiveDOMObjectPrototype", &Base::s_info, &JSTestActiveDOMObjectPrototypeTable, 0, CREATE_METHOD_TABLE(JSTestActiveDOMObjectPrototype) };
90
91 JSObject* JSTestActiveDOMObjectPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
92 {
93     return getDOMPrototype<JSTestActiveDOMObject>(exec, globalObject);
94 }
95
96 bool JSTestActiveDOMObjectPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
97 {
98     JSTestActiveDOMObjectPrototype* thisObject = jsCast<JSTestActiveDOMObjectPrototype*>(cell);
99     return getStaticFunctionSlot<JSObject>(exec, &JSTestActiveDOMObjectPrototypeTable, thisObject, propertyName, slot);
100 }
101
102 bool JSTestActiveDOMObjectPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
103 {
104     JSTestActiveDOMObjectPrototype* thisObject = jsCast<JSTestActiveDOMObjectPrototype*>(object);
105     return getStaticFunctionDescriptor<JSObject>(exec, &JSTestActiveDOMObjectPrototypeTable, thisObject, propertyName, descriptor);
106 }
107
108 const ClassInfo JSTestActiveDOMObject::s_info = { "TestActiveDOMObject", &Base::s_info, &JSTestActiveDOMObjectTable, 0 , CREATE_METHOD_TABLE(JSTestActiveDOMObject) };
109
110 JSTestActiveDOMObject::JSTestActiveDOMObject(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestActiveDOMObject> impl)
111     : JSDOMWrapper(structure, globalObject)
112     , m_impl(impl.leakRef())
113 {
114 }
115
116 void JSTestActiveDOMObject::finishCreation(JSGlobalData& globalData)
117 {
118     Base::finishCreation(globalData);
119     ASSERT(inherits(&s_info));
120 }
121
122 JSObject* JSTestActiveDOMObject::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
123 {
124     return JSTestActiveDOMObjectPrototype::create(exec->globalData(), globalObject, JSTestActiveDOMObjectPrototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype()));
125 }
126
127 void JSTestActiveDOMObject::destroy(JSC::JSCell* cell)
128 {
129     JSTestActiveDOMObject* thisObject = static_cast<JSTestActiveDOMObject*>(cell);
130     thisObject->JSTestActiveDOMObject::~JSTestActiveDOMObject();
131 }
132
133 JSTestActiveDOMObject::~JSTestActiveDOMObject()
134 {
135     releaseImplIfNotNull();
136 }
137
138 bool JSTestActiveDOMObject::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
139 {
140     JSTestActiveDOMObject* thisObject = jsCast<JSTestActiveDOMObject*>(cell);
141     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
142     return getStaticValueSlot<JSTestActiveDOMObject, Base>(exec, &JSTestActiveDOMObjectTable, thisObject, propertyName, slot);
143 }
144
145 bool JSTestActiveDOMObject::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
146 {
147     JSTestActiveDOMObject* thisObject = jsCast<JSTestActiveDOMObject*>(object);
148     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
149     if (!shouldAllowAccessToFrame(exec, thisObject->impl()->frame()))
150         return false;
151     return getStaticValueDescriptor<JSTestActiveDOMObject, Base>(exec, &JSTestActiveDOMObjectTable, thisObject, propertyName, descriptor);
152 }
153
154 JSValue jsTestActiveDOMObjectExcitingAttr(ExecState* exec, JSValue slotBase, PropertyName)
155 {
156     JSTestActiveDOMObject* castedThis = jsCast<JSTestActiveDOMObject*>(asObject(slotBase));
157     if (!BindingSecurity::shouldAllowAccessToDOMWindow(exec, castedThis->impl()))
158         return jsUndefined();
159     UNUSED_PARAM(exec);
160     TestActiveDOMObject* impl = static_cast<TestActiveDOMObject*>(castedThis->impl());
161     JSValue result = jsNumber(impl->excitingAttr());
162     return result;
163 }
164
165
166 JSValue jsTestActiveDOMObjectConstructor(ExecState* exec, JSValue slotBase, PropertyName)
167 {
168     JSTestActiveDOMObject* domObject = jsCast<JSTestActiveDOMObject*>(asObject(slotBase));
169     if (!BindingSecurity::shouldAllowAccessToDOMWindow(exec, domObject->impl()))
170         return jsUndefined();
171     return JSTestActiveDOMObject::getConstructor(exec, domObject->globalObject());
172 }
173
174 JSValue JSTestActiveDOMObject::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
175 {
176     return getDOMConstructor<JSTestActiveDOMObjectConstructor>(exec, jsCast<JSDOMGlobalObject*>(globalObject));
177 }
178
179 EncodedJSValue JSC_HOST_CALL jsTestActiveDOMObjectPrototypeFunctionExcitingFunction(ExecState* exec)
180 {
181     JSValue thisValue = exec->hostThisValue();
182     if (!thisValue.inherits(&JSTestActiveDOMObject::s_info))
183         return throwVMTypeError(exec);
184     JSTestActiveDOMObject* castedThis = jsCast<JSTestActiveDOMObject*>(asObject(thisValue));
185     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestActiveDOMObject::s_info);
186     if (!BindingSecurity::shouldAllowAccessToDOMWindow(exec, castedThis->impl()))
187         return JSValue::encode(jsUndefined());
188     TestActiveDOMObject* impl = static_cast<TestActiveDOMObject*>(castedThis->impl());
189     if (exec->argumentCount() < 1)
190         return throwVMError(exec, createNotEnoughArgumentsError(exec));
191     Node* nextChild(toNode(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
192     if (exec->hadException())
193         return JSValue::encode(jsUndefined());
194     impl->excitingFunction(nextChild);
195     return JSValue::encode(jsUndefined());
196 }
197
198 EncodedJSValue JSC_HOST_CALL jsTestActiveDOMObjectPrototypeFunctionPostMessage(ExecState* exec)
199 {
200     JSValue thisValue = exec->hostThisValue();
201     if (!thisValue.inherits(&JSTestActiveDOMObject::s_info))
202         return throwVMTypeError(exec);
203     JSTestActiveDOMObject* castedThis = jsCast<JSTestActiveDOMObject*>(asObject(thisValue));
204     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestActiveDOMObject::s_info);
205     TestActiveDOMObject* impl = static_cast<TestActiveDOMObject*>(castedThis->impl());
206     if (exec->argumentCount() < 1)
207         return throwVMError(exec, createNotEnoughArgumentsError(exec));
208     const String& message(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).isEmpty() ? String() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toString(exec)->value(exec));
209     if (exec->hadException())
210         return JSValue::encode(jsUndefined());
211     impl->postMessage(message);
212     return JSValue::encode(jsUndefined());
213 }
214
215 static inline bool isObservable(JSTestActiveDOMObject* jsTestActiveDOMObject)
216 {
217     if (jsTestActiveDOMObject->hasCustomProperties())
218         return true;
219     return false;
220 }
221
222 bool JSTestActiveDOMObjectOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
223 {
224     JSTestActiveDOMObject* jsTestActiveDOMObject = jsCast<JSTestActiveDOMObject*>(handle.get().asCell());
225     if (!isObservable(jsTestActiveDOMObject))
226         return false;
227     UNUSED_PARAM(visitor);
228     return false;
229 }
230
231 void JSTestActiveDOMObjectOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
232 {
233     JSTestActiveDOMObject* jsTestActiveDOMObject = jsCast<JSTestActiveDOMObject*>(handle.get().asCell());
234     DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
235     uncacheWrapper(world, jsTestActiveDOMObject->impl(), jsTestActiveDOMObject);
236     jsTestActiveDOMObject->releaseImpl();
237 }
238
239 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestActiveDOMObject* impl)
240 {
241     return wrap<JSTestActiveDOMObject>(exec, globalObject, impl);
242 }
243
244 TestActiveDOMObject* toTestActiveDOMObject(JSC::JSValue value)
245 {
246     return value.inherits(&JSTestActiveDOMObject::s_info) ? jsCast<JSTestActiveDOMObject*>(asObject(value))->impl() : 0;
247 }
248
249 }