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 "JSMessageEvent.h"
23
24#include "JSDOMAttribute.h"
25#include "JSDOMBinding.h"
26#include "JSDOMConstructor.h"
27#include "JSDOMConvertAny.h"
28#include "JSDOMConvertBoolean.h"
29#include "JSDOMConvertInterface.h"
30#include "JSDOMConvertNullable.h"
31#include "JSDOMConvertSequences.h"
32#include "JSDOMConvertStrings.h"
33#include "JSDOMConvertUnion.h"
34#include "JSDOMExceptionHandling.h"
35#include "JSDOMGlobalObject.h"
36#include "JSDOMOperation.h"
37#include "JSDOMWrapperCache.h"
38#include "JSMessagePort.h"
39#include "JSServiceWorker.h"
40#include "JSWindowProxy.h"
41#include "ScriptExecutionContext.h"
42#include <JavaScriptCore/HeapSnapshotBuilder.h>
43#include <JavaScriptCore/JSArray.h>
44#include <JavaScriptCore/JSCInlines.h>
45#include <wtf/GetPtr.h>
46#include <wtf/PointerPreparations.h>
47#include <wtf/URL.h>
48#include <wtf/Variant.h>
49
50
51namespace WebCore {
52using namespace JSC;
53
54template<> MessageEvent::Init convertDictionary<MessageEvent::Init>(ExecState& state, JSValue value)
55{
56 VM& vm = state.vm();
57 auto throwScope = DECLARE_THROW_SCOPE(vm);
58 bool isNullOrUndefined = value.isUndefinedOrNull();
59 auto* object = isNullOrUndefined ? nullptr : value.getObject();
60 if (UNLIKELY(!isNullOrUndefined && !object)) {
61 throwTypeError(&state, throwScope);
62 return { };
63 }
64 MessageEvent::Init result;
65 JSValue bubblesValue;
66 if (isNullOrUndefined)
67 bubblesValue = jsUndefined();
68 else {
69 bubblesValue = object->get(&state, Identifier::fromString(&state, "bubbles"));
70 RETURN_IF_EXCEPTION(throwScope, { });
71 }
72 if (!bubblesValue.isUndefined()) {
73 result.bubbles = convert<IDLBoolean>(state, bubblesValue);
74 RETURN_IF_EXCEPTION(throwScope, { });
75 } else
76 result.bubbles = false;
77 JSValue cancelableValue;
78 if (isNullOrUndefined)
79 cancelableValue = jsUndefined();
80 else {
81 cancelableValue = object->get(&state, Identifier::fromString(&state, "cancelable"));
82 RETURN_IF_EXCEPTION(throwScope, { });
83 }
84 if (!cancelableValue.isUndefined()) {
85 result.cancelable = convert<IDLBoolean>(state, cancelableValue);
86 RETURN_IF_EXCEPTION(throwScope, { });
87 } else
88 result.cancelable = false;
89 JSValue composedValue;
90 if (isNullOrUndefined)
91 composedValue = jsUndefined();
92 else {
93 composedValue = object->get(&state, Identifier::fromString(&state, "composed"));
94 RETURN_IF_EXCEPTION(throwScope, { });
95 }
96 if (!composedValue.isUndefined()) {
97 result.composed = convert<IDLBoolean>(state, composedValue);
98 RETURN_IF_EXCEPTION(throwScope, { });
99 } else
100 result.composed = false;
101 JSValue dataValue;
102 if (isNullOrUndefined)
103 dataValue = jsUndefined();
104 else {
105 dataValue = object->get(&state, Identifier::fromString(&state, "data"));
106 RETURN_IF_EXCEPTION(throwScope, { });
107 }
108 if (!dataValue.isUndefined()) {
109 result.data = convert<IDLAny>(state, dataValue);
110 RETURN_IF_EXCEPTION(throwScope, { });
111 } else
112 result.data = jsNull();
113 JSValue lastEventIdValue;
114 if (isNullOrUndefined)
115 lastEventIdValue = jsUndefined();
116 else {
117 lastEventIdValue = object->get(&state, Identifier::fromString(&state, "lastEventId"));
118 RETURN_IF_EXCEPTION(throwScope, { });
119 }
120 if (!lastEventIdValue.isUndefined()) {
121 result.lastEventId = convert<IDLDOMString>(state, lastEventIdValue);
122 RETURN_IF_EXCEPTION(throwScope, { });
123 } else
124 result.lastEventId = emptyString();
125 JSValue originValue;
126 if (isNullOrUndefined)
127 originValue = jsUndefined();
128 else {
129 originValue = object->get(&state, Identifier::fromString(&state, "origin"));
130 RETURN_IF_EXCEPTION(throwScope, { });
131 }
132 if (!originValue.isUndefined()) {
133 result.origin = convert<IDLUSVString>(state, originValue);
134 RETURN_IF_EXCEPTION(throwScope, { });
135 } else
136 result.origin = emptyString();
137 JSValue portsValue;
138 if (isNullOrUndefined)
139 portsValue = jsUndefined();
140 else {
141 portsValue = object->get(&state, Identifier::fromString(&state, "ports"));
142 RETURN_IF_EXCEPTION(throwScope, { });
143 }
144 if (!portsValue.isUndefined()) {
145 result.ports = convert<IDLSequence<IDLInterface<MessagePort>>>(state, portsValue);
146 RETURN_IF_EXCEPTION(throwScope, { });
147 } else
148 result.ports = Converter<IDLSequence<IDLInterface<MessagePort>>>::ReturnType{ };
149 JSValue sourceValue;
150 if (isNullOrUndefined)
151 sourceValue = jsUndefined();
152 else {
153 sourceValue = object->get(&state, Identifier::fromString(&state, "source"));
154 RETURN_IF_EXCEPTION(throwScope, { });
155 }
156 if (!sourceValue.isUndefined()) {
157 result.source = convert<IDLNullable<IDLUnion<IDLInterface<WindowProxy>, IDLInterface<MessagePort>, IDLInterface<ServiceWorker>>>>(state, sourceValue);
158 RETURN_IF_EXCEPTION(throwScope, { });
159 } else
160 result.source = WTF::nullopt;
161 return result;
162}
163
164// Functions
165
166JSC::EncodedJSValue JSC_HOST_CALL jsMessageEventPrototypeFunctionInitMessageEvent(JSC::ExecState*);
167
168// Attributes
169
170JSC::EncodedJSValue jsMessageEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
171bool setJSMessageEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
172JSC::EncodedJSValue jsMessageEventOrigin(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
173JSC::EncodedJSValue jsMessageEventLastEventId(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
174JSC::EncodedJSValue jsMessageEventSource(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
175JSC::EncodedJSValue jsMessageEventData(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
176JSC::EncodedJSValue jsMessageEventPorts(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
177
178class JSMessageEventPrototype : public JSC::JSNonFinalObject {
179public:
180 using Base = JSC::JSNonFinalObject;
181 static JSMessageEventPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
182 {
183 JSMessageEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSMessageEventPrototype>(vm.heap)) JSMessageEventPrototype(vm, globalObject, structure);
184 ptr->finishCreation(vm);
185 return ptr;
186 }
187
188 DECLARE_INFO;
189 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
190 {
191 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
192 }
193
194private:
195 JSMessageEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
196 : JSC::JSNonFinalObject(vm, structure)
197 {
198 }
199
200 void finishCreation(JSC::VM&);
201};
202
203using JSMessageEventConstructor = JSDOMConstructor<JSMessageEvent>;
204
205template<> EncodedJSValue JSC_HOST_CALL JSMessageEventConstructor::construct(ExecState* state)
206{
207 VM& vm = state->vm();
208 auto throwScope = DECLARE_THROW_SCOPE(vm);
209 UNUSED_PARAM(throwScope);
210 auto* castedThis = jsCast<JSMessageEventConstructor*>(state->jsCallee());
211 ASSERT(castedThis);
212 if (UNLIKELY(state->argumentCount() < 1))
213 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
214 auto type = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
215 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
216 auto eventInitDict = convert<IDLDictionary<MessageEvent::Init>>(*state, state->argument(1));
217 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
218 auto object = MessageEvent::create(WTFMove(type), WTFMove(eventInitDict));
219 return JSValue::encode(toJSNewlyCreated<IDLInterface<MessageEvent>>(*state, *castedThis->globalObject(), WTFMove(object)));
220}
221
222template<> JSValue JSMessageEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
223{
224 return JSEvent::getConstructor(vm, &globalObject);
225}
226
227template<> void JSMessageEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
228{
229 putDirect(vm, vm.propertyNames->prototype, JSMessageEvent::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
230 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("MessageEvent"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
231 putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
232}
233
234template<> const ClassInfo JSMessageEventConstructor::s_info = { "MessageEvent", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMessageEventConstructor) };
235
236/* Hash table for prototype */
237
238static const HashTableValue JSMessageEventPrototypeTableValues[] =
239{
240 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMessageEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMessageEventConstructor) } },
241 { "origin", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMessageEventOrigin), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
242 { "lastEventId", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMessageEventLastEventId), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
243 { "source", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMessageEventSource), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
244 { "data", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMessageEventData), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
245 { "ports", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMessageEventPorts), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
246 { "initMessageEvent", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMessageEventPrototypeFunctionInitMessageEvent), (intptr_t) (1) } },
247};
248
249const ClassInfo JSMessageEventPrototype::s_info = { "MessageEventPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMessageEventPrototype) };
250
251void JSMessageEventPrototype::finishCreation(VM& vm)
252{
253 Base::finishCreation(vm);
254 reifyStaticProperties(vm, JSMessageEvent::info(), JSMessageEventPrototypeTableValues, *this);
255}
256
257const ClassInfo JSMessageEvent::s_info = { "MessageEvent", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMessageEvent) };
258
259JSMessageEvent::JSMessageEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<MessageEvent>&& impl)
260 : JSEvent(structure, globalObject, WTFMove(impl))
261{
262}
263
264void JSMessageEvent::finishCreation(VM& vm)
265{
266 Base::finishCreation(vm);
267 ASSERT(inherits(vm, info()));
268
269}
270
271JSObject* JSMessageEvent::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
272{
273 return JSMessageEventPrototype::create(vm, &globalObject, JSMessageEventPrototype::createStructure(vm, &globalObject, JSEvent::prototype(vm, globalObject)));
274}
275
276JSObject* JSMessageEvent::prototype(VM& vm, JSDOMGlobalObject& globalObject)
277{
278 return getDOMPrototype<JSMessageEvent>(vm, globalObject);
279}
280
281JSValue JSMessageEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject)
282{
283 return getDOMConstructor<JSMessageEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
284}
285
286template<> inline JSMessageEvent* IDLAttribute<JSMessageEvent>::cast(ExecState& state, EncodedJSValue thisValue)
287{
288 return jsDynamicCast<JSMessageEvent*>(state.vm(), JSValue::decode(thisValue));
289}
290
291template<> inline JSMessageEvent* IDLOperation<JSMessageEvent>::cast(ExecState& state)
292{
293 return jsDynamicCast<JSMessageEvent*>(state.vm(), state.thisValue());
294}
295
296EncodedJSValue jsMessageEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
297{
298 VM& vm = state->vm();
299 auto throwScope = DECLARE_THROW_SCOPE(vm);
300 auto* prototype = jsDynamicCast<JSMessageEventPrototype*>(vm, JSValue::decode(thisValue));
301 if (UNLIKELY(!prototype))
302 return throwVMTypeError(state, throwScope);
303 return JSValue::encode(JSMessageEvent::getConstructor(state->vm(), prototype->globalObject()));
304}
305
306bool setJSMessageEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
307{
308 VM& vm = state->vm();
309 auto throwScope = DECLARE_THROW_SCOPE(vm);
310 auto* prototype = jsDynamicCast<JSMessageEventPrototype*>(vm, JSValue::decode(thisValue));
311 if (UNLIKELY(!prototype)) {
312 throwVMTypeError(state, throwScope);
313 return false;
314 }
315 // Shadowing a built-in constructor
316 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
317}
318
319static inline JSValue jsMessageEventOriginGetter(ExecState& state, JSMessageEvent& thisObject, ThrowScope& throwScope)
320{
321 UNUSED_PARAM(throwScope);
322 UNUSED_PARAM(state);
323 auto& impl = thisObject.wrapped();
324 JSValue result = toJS<IDLUSVString>(state, throwScope, impl.origin());
325 return result;
326}
327
328EncodedJSValue jsMessageEventOrigin(ExecState* state, EncodedJSValue thisValue, PropertyName)
329{
330 return IDLAttribute<JSMessageEvent>::get<jsMessageEventOriginGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "origin");
331}
332
333static inline JSValue jsMessageEventLastEventIdGetter(ExecState& state, JSMessageEvent& thisObject, ThrowScope& throwScope)
334{
335 UNUSED_PARAM(throwScope);
336 UNUSED_PARAM(state);
337 auto& impl = thisObject.wrapped();
338 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.lastEventId());
339 return result;
340}
341
342EncodedJSValue jsMessageEventLastEventId(ExecState* state, EncodedJSValue thisValue, PropertyName)
343{
344 return IDLAttribute<JSMessageEvent>::get<jsMessageEventLastEventIdGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "lastEventId");
345}
346
347static inline JSValue jsMessageEventSourceGetter(ExecState& state, JSMessageEvent& thisObject, ThrowScope& throwScope)
348{
349 UNUSED_PARAM(throwScope);
350 UNUSED_PARAM(state);
351 auto& impl = thisObject.wrapped();
352 JSValue result = toJS<IDLNullable<IDLUnion<IDLInterface<WindowProxy>, IDLInterface<MessagePort>, IDLInterface<ServiceWorker>>>>(state, *thisObject.globalObject(), throwScope, impl.source());
353 return result;
354}
355
356EncodedJSValue jsMessageEventSource(ExecState* state, EncodedJSValue thisValue, PropertyName)
357{
358 return IDLAttribute<JSMessageEvent>::get<jsMessageEventSourceGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "source");
359}
360
361static inline JSValue jsMessageEventDataGetter(ExecState& state, JSMessageEvent& thisObject, ThrowScope& throwScope)
362{
363 UNUSED_PARAM(throwScope);
364 UNUSED_PARAM(state);
365 return thisObject.data(state);
366}
367
368EncodedJSValue jsMessageEventData(ExecState* state, EncodedJSValue thisValue, PropertyName)
369{
370 return IDLAttribute<JSMessageEvent>::get<jsMessageEventDataGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "data");
371}
372
373static inline JSValue jsMessageEventPortsGetter(ExecState& state, JSMessageEvent& thisObject, ThrowScope& throwScope)
374{
375 UNUSED_PARAM(throwScope);
376 UNUSED_PARAM(state);
377 return thisObject.ports(state);
378}
379
380EncodedJSValue jsMessageEventPorts(ExecState* state, EncodedJSValue thisValue, PropertyName)
381{
382 return IDLAttribute<JSMessageEvent>::get<jsMessageEventPortsGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "ports");
383}
384
385static inline JSC::EncodedJSValue jsMessageEventPrototypeFunctionInitMessageEventBody(JSC::ExecState* state, typename IDLOperation<JSMessageEvent>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
386{
387 UNUSED_PARAM(state);
388 UNUSED_PARAM(throwScope);
389 auto& impl = castedThis->wrapped();
390 if (UNLIKELY(state->argumentCount() < 1))
391 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
392 auto type = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
393 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
394 auto bubbles = convert<IDLBoolean>(*state, state->argument(1));
395 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
396 auto cancelable = convert<IDLBoolean>(*state, state->argument(2));
397 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
398 auto data = state->argument(3).isUndefined() ? jsNull() : convert<IDLAny>(*state, state->uncheckedArgument(3));
399 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
400 auto originArg = state->argument(4).isUndefined() ? emptyString() : convert<IDLUSVString>(*state, state->uncheckedArgument(4));
401 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
402 auto lastEventId = state->argument(5).isUndefined() ? emptyString() : convert<IDLDOMString>(*state, state->uncheckedArgument(5));
403 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
404 auto source = state->argument(6).isUndefined() ? WTF::nullopt : convert<IDLNullable<IDLUnion<IDLInterface<WindowProxy>, IDLInterface<MessagePort>, IDLInterface<ServiceWorker>>>>(*state, state->uncheckedArgument(6));
405 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
406 auto messagePorts = state->argument(7).isUndefined() ? Converter<IDLSequence<IDLInterface<MessagePort>>>::ReturnType{ } : convert<IDLSequence<IDLInterface<MessagePort>>>(*state, state->uncheckedArgument(7));
407 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
408 impl.initMessageEvent(WTFMove(type), WTFMove(bubbles), WTFMove(cancelable), WTFMove(data), WTFMove(originArg), WTFMove(lastEventId), WTFMove(source), WTFMove(messagePorts));
409 return JSValue::encode(jsUndefined());
410}
411
412EncodedJSValue JSC_HOST_CALL jsMessageEventPrototypeFunctionInitMessageEvent(ExecState* state)
413{
414 return IDLOperation<JSMessageEvent>::call<jsMessageEventPrototypeFunctionInitMessageEventBody>(*state, "initMessageEvent");
415}
416
417void JSMessageEvent::visitChildren(JSCell* cell, SlotVisitor& visitor)
418{
419 auto* thisObject = jsCast<JSMessageEvent*>(cell);
420 ASSERT_GC_OBJECT_INHERITS(thisObject, info());
421 Base::visitChildren(thisObject, visitor);
422 thisObject->visitAdditionalChildren(visitor);
423}
424
425void JSMessageEvent::visitOutputConstraints(JSCell* cell, SlotVisitor& visitor)
426{
427 auto* thisObject = jsCast<JSMessageEvent*>(cell);
428 ASSERT_GC_OBJECT_INHERITS(thisObject, info());
429 Base::visitOutputConstraints(thisObject, visitor);
430 thisObject->visitAdditionalChildren(visitor);
431}
432
433void JSMessageEvent::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
434{
435 auto* thisObject = jsCast<JSMessageEvent*>(cell);
436 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
437 if (thisObject->scriptExecutionContext())
438 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
439 Base::heapSnapshot(cell, builder);
440}
441
442#if ENABLE(BINDING_INTEGRITY)
443#if PLATFORM(WIN)
444#pragma warning(disable: 4483)
445extern "C" { extern void (*const __identifier("??_7MessageEvent@WebCore@@6B@")[])(); }
446#else
447extern "C" { extern void* _ZTVN7WebCore12MessageEventE[]; }
448#endif
449#endif
450
451JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<MessageEvent>&& impl)
452{
453
454#if ENABLE(BINDING_INTEGRITY)
455 void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
456#if PLATFORM(WIN)
457 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7MessageEvent@WebCore@@6B@"));
458#else
459 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore12MessageEventE[2]);
460#endif
461
462 // If this fails MessageEvent does not have a vtable, so you need to add the
463 // ImplementationLacksVTable attribute to the interface definition
464 static_assert(std::is_polymorphic<MessageEvent>::value, "MessageEvent is not polymorphic");
465
466 // If you hit this assertion you either have a use after free bug, or
467 // MessageEvent has subclasses. If MessageEvent has subclasses that get passed
468 // to toJS() we currently require MessageEvent you to opt out of binding hardening
469 // by adding the SkipVTableValidation attribute to the interface IDL definition
470 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
471#endif
472 return createWrapper<MessageEvent>(globalObject, WTFMove(impl));
473}
474
475JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, MessageEvent& impl)
476{
477 return wrap(state, globalObject, impl);
478}
479
480
481}
482