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
23#if ENABLE(PAYMENT_REQUEST)
24
25#include "JSPaymentRequest.h"
26
27#include "DOMPromiseProxy.h"
28#include "Document.h"
29#include "EventNames.h"
30#include "JSDOMAttribute.h"
31#include "JSDOMBinding.h"
32#include "JSDOMConstructor.h"
33#include "JSDOMConvertDictionary.h"
34#include "JSDOMConvertEnumeration.h"
35#include "JSDOMConvertInterface.h"
36#include "JSDOMConvertNullable.h"
37#include "JSDOMConvertPromise.h"
38#include "JSDOMConvertStrings.h"
39#include "JSDOMExceptionHandling.h"
40#include "JSDOMGlobalObject.h"
41#include "JSDOMOperation.h"
42#include "JSDOMOperationReturningPromise.h"
43#include "JSDOMWrapperCache.h"
44#include "JSEventListener.h"
45#include "JSPaymentAddress.h"
46#include "JSPaymentDetailsUpdate.h"
47#include "JSPaymentShippingType.h"
48#include "ScriptExecutionContext.h"
49#include <JavaScriptCore/HeapSnapshotBuilder.h>
50#include <JavaScriptCore/JSCInlines.h>
51#include <wtf/GetPtr.h>
52#include <wtf/PointerPreparations.h>
53#include <wtf/URL.h>
54
55#if ENABLE(PAYMENT_REQUEST)
56#include "JSDOMConvertSequences.h"
57#include "JSPaymentDetailsInit.h"
58#include "JSPaymentMethodData.h"
59#include "JSPaymentOptions.h"
60#include <JavaScriptCore/JSArray.h>
61#endif
62
63
64namespace WebCore {
65using namespace JSC;
66
67// Functions
68
69JSC::EncodedJSValue JSC_HOST_CALL jsPaymentRequestPrototypeFunctionShow(JSC::ExecState*);
70JSC::EncodedJSValue JSC_HOST_CALL jsPaymentRequestPrototypeFunctionAbort(JSC::ExecState*);
71JSC::EncodedJSValue JSC_HOST_CALL jsPaymentRequestPrototypeFunctionCanMakePayment(JSC::ExecState*);
72
73// Attributes
74
75JSC::EncodedJSValue jsPaymentRequestConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
76bool setJSPaymentRequestConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
77JSC::EncodedJSValue jsPaymentRequestId(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
78JSC::EncodedJSValue jsPaymentRequestShippingAddress(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
79JSC::EncodedJSValue jsPaymentRequestShippingOption(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
80JSC::EncodedJSValue jsPaymentRequestShippingType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
81JSC::EncodedJSValue jsPaymentRequestOnmerchantvalidation(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
82bool setJSPaymentRequestOnmerchantvalidation(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
83JSC::EncodedJSValue jsPaymentRequestOnshippingaddresschange(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
84bool setJSPaymentRequestOnshippingaddresschange(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
85JSC::EncodedJSValue jsPaymentRequestOnshippingoptionchange(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
86bool setJSPaymentRequestOnshippingoptionchange(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
87JSC::EncodedJSValue jsPaymentRequestOnpaymentmethodchange(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
88bool setJSPaymentRequestOnpaymentmethodchange(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
89
90class JSPaymentRequestPrototype : public JSC::JSNonFinalObject {
91public:
92 using Base = JSC::JSNonFinalObject;
93 static JSPaymentRequestPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
94 {
95 JSPaymentRequestPrototype* ptr = new (NotNull, JSC::allocateCell<JSPaymentRequestPrototype>(vm.heap)) JSPaymentRequestPrototype(vm, globalObject, structure);
96 ptr->finishCreation(vm);
97 return ptr;
98 }
99
100 DECLARE_INFO;
101 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
102 {
103 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
104 }
105
106private:
107 JSPaymentRequestPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
108 : JSC::JSNonFinalObject(vm, structure)
109 {
110 }
111
112 void finishCreation(JSC::VM&);
113};
114
115using JSPaymentRequestConstructor = JSDOMConstructor<JSPaymentRequest>;
116
117template<> EncodedJSValue JSC_HOST_CALL JSPaymentRequestConstructor::construct(ExecState* state)
118{
119 VM& vm = state->vm();
120 auto throwScope = DECLARE_THROW_SCOPE(vm);
121 UNUSED_PARAM(throwScope);
122 auto* castedThis = jsCast<JSPaymentRequestConstructor*>(state->jsCallee());
123 ASSERT(castedThis);
124 if (UNLIKELY(state->argumentCount() < 2))
125 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
126 auto* context = castedThis->scriptExecutionContext();
127 if (UNLIKELY(!context))
128 return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "PaymentRequest");
129 ASSERT(context->isDocument());
130 auto& document = downcast<Document>(*context);
131 auto methodData = convert<IDLSequence<IDLDictionary<PaymentMethodData>>>(*state, state->uncheckedArgument(0));
132 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
133 auto details = convert<IDLDictionary<PaymentDetailsInit>>(*state, state->uncheckedArgument(1));
134 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
135 auto options = convert<IDLDictionary<PaymentOptions>>(*state, state->argument(2));
136 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
137 auto object = PaymentRequest::create(document, WTFMove(methodData), WTFMove(details), WTFMove(options));
138 return JSValue::encode(toJSNewlyCreated<IDLInterface<PaymentRequest>>(*state, *castedThis->globalObject(), throwScope, WTFMove(object)));
139}
140
141template<> JSValue JSPaymentRequestConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
142{
143 return JSEventTarget::getConstructor(vm, &globalObject);
144}
145
146template<> void JSPaymentRequestConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
147{
148 putDirect(vm, vm.propertyNames->prototype, JSPaymentRequest::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
149 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("PaymentRequest"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
150 putDirect(vm, vm.propertyNames->length, jsNumber(2), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
151}
152
153template<> const ClassInfo JSPaymentRequestConstructor::s_info = { "PaymentRequest", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSPaymentRequestConstructor) };
154
155/* Hash table for prototype */
156
157static const HashTableValue JSPaymentRequestPrototypeTableValues[] =
158{
159 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPaymentRequestConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSPaymentRequestConstructor) } },
160 { "id", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPaymentRequestId), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
161 { "shippingAddress", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPaymentRequestShippingAddress), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
162 { "shippingOption", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPaymentRequestShippingOption), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
163 { "shippingType", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPaymentRequestShippingType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
164 { "onmerchantvalidation", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPaymentRequestOnmerchantvalidation), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSPaymentRequestOnmerchantvalidation) } },
165 { "onshippingaddresschange", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPaymentRequestOnshippingaddresschange), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSPaymentRequestOnshippingaddresschange) } },
166 { "onshippingoptionchange", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPaymentRequestOnshippingoptionchange), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSPaymentRequestOnshippingoptionchange) } },
167 { "onpaymentmethodchange", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPaymentRequestOnpaymentmethodchange), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSPaymentRequestOnpaymentmethodchange) } },
168 { "show", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsPaymentRequestPrototypeFunctionShow), (intptr_t) (0) } },
169 { "abort", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsPaymentRequestPrototypeFunctionAbort), (intptr_t) (0) } },
170 { "canMakePayment", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsPaymentRequestPrototypeFunctionCanMakePayment), (intptr_t) (0) } },
171};
172
173const ClassInfo JSPaymentRequestPrototype::s_info = { "PaymentRequestPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSPaymentRequestPrototype) };
174
175void JSPaymentRequestPrototype::finishCreation(VM& vm)
176{
177 Base::finishCreation(vm);
178 reifyStaticProperties(vm, JSPaymentRequest::info(), JSPaymentRequestPrototypeTableValues, *this);
179}
180
181const ClassInfo JSPaymentRequest::s_info = { "PaymentRequest", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSPaymentRequest) };
182
183JSPaymentRequest::JSPaymentRequest(Structure* structure, JSDOMGlobalObject& globalObject, Ref<PaymentRequest>&& impl)
184 : JSEventTarget(structure, globalObject, WTFMove(impl))
185{
186}
187
188void JSPaymentRequest::finishCreation(VM& vm)
189{
190 Base::finishCreation(vm);
191 ASSERT(inherits(vm, info()));
192
193}
194
195JSObject* JSPaymentRequest::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
196{
197 return JSPaymentRequestPrototype::create(vm, &globalObject, JSPaymentRequestPrototype::createStructure(vm, &globalObject, JSEventTarget::prototype(vm, globalObject)));
198}
199
200JSObject* JSPaymentRequest::prototype(VM& vm, JSDOMGlobalObject& globalObject)
201{
202 return getDOMPrototype<JSPaymentRequest>(vm, globalObject);
203}
204
205JSValue JSPaymentRequest::getConstructor(VM& vm, const JSGlobalObject* globalObject)
206{
207 return getDOMConstructor<JSPaymentRequestConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
208}
209
210template<> inline JSPaymentRequest* IDLAttribute<JSPaymentRequest>::cast(ExecState& state, EncodedJSValue thisValue)
211{
212 return jsDynamicCast<JSPaymentRequest*>(state.vm(), JSValue::decode(thisValue));
213}
214
215template<> inline JSPaymentRequest* IDLOperation<JSPaymentRequest>::cast(ExecState& state)
216{
217 return jsDynamicCast<JSPaymentRequest*>(state.vm(), state.thisValue());
218}
219
220EncodedJSValue jsPaymentRequestConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
221{
222 VM& vm = state->vm();
223 auto throwScope = DECLARE_THROW_SCOPE(vm);
224 auto* prototype = jsDynamicCast<JSPaymentRequestPrototype*>(vm, JSValue::decode(thisValue));
225 if (UNLIKELY(!prototype))
226 return throwVMTypeError(state, throwScope);
227 return JSValue::encode(JSPaymentRequest::getConstructor(state->vm(), prototype->globalObject()));
228}
229
230bool setJSPaymentRequestConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
231{
232 VM& vm = state->vm();
233 auto throwScope = DECLARE_THROW_SCOPE(vm);
234 auto* prototype = jsDynamicCast<JSPaymentRequestPrototype*>(vm, JSValue::decode(thisValue));
235 if (UNLIKELY(!prototype)) {
236 throwVMTypeError(state, throwScope);
237 return false;
238 }
239 // Shadowing a built-in constructor
240 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
241}
242
243static inline JSValue jsPaymentRequestIdGetter(ExecState& state, JSPaymentRequest& thisObject, ThrowScope& throwScope)
244{
245 UNUSED_PARAM(throwScope);
246 UNUSED_PARAM(state);
247 auto& impl = thisObject.wrapped();
248 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.id());
249 return result;
250}
251
252EncodedJSValue jsPaymentRequestId(ExecState* state, EncodedJSValue thisValue, PropertyName)
253{
254 return IDLAttribute<JSPaymentRequest>::get<jsPaymentRequestIdGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "id");
255}
256
257static inline JSValue jsPaymentRequestShippingAddressGetter(ExecState& state, JSPaymentRequest& thisObject, ThrowScope& throwScope)
258{
259 UNUSED_PARAM(throwScope);
260 UNUSED_PARAM(state);
261 auto& impl = thisObject.wrapped();
262 JSValue result = toJS<IDLNullable<IDLInterface<PaymentAddress>>>(state, *thisObject.globalObject(), throwScope, impl.shippingAddress());
263 return result;
264}
265
266EncodedJSValue jsPaymentRequestShippingAddress(ExecState* state, EncodedJSValue thisValue, PropertyName)
267{
268 return IDLAttribute<JSPaymentRequest>::get<jsPaymentRequestShippingAddressGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "shippingAddress");
269}
270
271static inline JSValue jsPaymentRequestShippingOptionGetter(ExecState& state, JSPaymentRequest& thisObject, ThrowScope& throwScope)
272{
273 UNUSED_PARAM(throwScope);
274 UNUSED_PARAM(state);
275 auto& impl = thisObject.wrapped();
276 JSValue result = toJS<IDLNullable<IDLDOMString>>(state, throwScope, impl.shippingOption());
277 return result;
278}
279
280EncodedJSValue jsPaymentRequestShippingOption(ExecState* state, EncodedJSValue thisValue, PropertyName)
281{
282 return IDLAttribute<JSPaymentRequest>::get<jsPaymentRequestShippingOptionGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "shippingOption");
283}
284
285static inline JSValue jsPaymentRequestShippingTypeGetter(ExecState& state, JSPaymentRequest& thisObject, ThrowScope& throwScope)
286{
287 UNUSED_PARAM(throwScope);
288 UNUSED_PARAM(state);
289 auto& impl = thisObject.wrapped();
290 JSValue result = toJS<IDLNullable<IDLEnumeration<PaymentShippingType>>>(state, throwScope, impl.shippingType());
291 return result;
292}
293
294EncodedJSValue jsPaymentRequestShippingType(ExecState* state, EncodedJSValue thisValue, PropertyName)
295{
296 return IDLAttribute<JSPaymentRequest>::get<jsPaymentRequestShippingTypeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "shippingType");
297}
298
299static inline JSValue jsPaymentRequestOnmerchantvalidationGetter(ExecState& state, JSPaymentRequest& thisObject, ThrowScope& throwScope)
300{
301 UNUSED_PARAM(throwScope);
302 UNUSED_PARAM(state);
303 return eventHandlerAttribute(thisObject.wrapped(), eventNames().merchantvalidationEvent, worldForDOMObject(thisObject));
304}
305
306EncodedJSValue jsPaymentRequestOnmerchantvalidation(ExecState* state, EncodedJSValue thisValue, PropertyName)
307{
308 return IDLAttribute<JSPaymentRequest>::get<jsPaymentRequestOnmerchantvalidationGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onmerchantvalidation");
309}
310
311static inline bool setJSPaymentRequestOnmerchantvalidationSetter(ExecState& state, JSPaymentRequest& thisObject, JSValue value, ThrowScope& throwScope)
312{
313 UNUSED_PARAM(throwScope);
314 setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().merchantvalidationEvent, value);
315 return true;
316}
317
318bool setJSPaymentRequestOnmerchantvalidation(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
319{
320 return IDLAttribute<JSPaymentRequest>::set<setJSPaymentRequestOnmerchantvalidationSetter>(*state, thisValue, encodedValue, "onmerchantvalidation");
321}
322
323static inline JSValue jsPaymentRequestOnshippingaddresschangeGetter(ExecState& state, JSPaymentRequest& thisObject, ThrowScope& throwScope)
324{
325 UNUSED_PARAM(throwScope);
326 UNUSED_PARAM(state);
327 return eventHandlerAttribute(thisObject.wrapped(), eventNames().shippingaddresschangeEvent, worldForDOMObject(thisObject));
328}
329
330EncodedJSValue jsPaymentRequestOnshippingaddresschange(ExecState* state, EncodedJSValue thisValue, PropertyName)
331{
332 return IDLAttribute<JSPaymentRequest>::get<jsPaymentRequestOnshippingaddresschangeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onshippingaddresschange");
333}
334
335static inline bool setJSPaymentRequestOnshippingaddresschangeSetter(ExecState& state, JSPaymentRequest& thisObject, JSValue value, ThrowScope& throwScope)
336{
337 UNUSED_PARAM(throwScope);
338 setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().shippingaddresschangeEvent, value);
339 return true;
340}
341
342bool setJSPaymentRequestOnshippingaddresschange(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
343{
344 return IDLAttribute<JSPaymentRequest>::set<setJSPaymentRequestOnshippingaddresschangeSetter>(*state, thisValue, encodedValue, "onshippingaddresschange");
345}
346
347static inline JSValue jsPaymentRequestOnshippingoptionchangeGetter(ExecState& state, JSPaymentRequest& thisObject, ThrowScope& throwScope)
348{
349 UNUSED_PARAM(throwScope);
350 UNUSED_PARAM(state);
351 return eventHandlerAttribute(thisObject.wrapped(), eventNames().shippingoptionchangeEvent, worldForDOMObject(thisObject));
352}
353
354EncodedJSValue jsPaymentRequestOnshippingoptionchange(ExecState* state, EncodedJSValue thisValue, PropertyName)
355{
356 return IDLAttribute<JSPaymentRequest>::get<jsPaymentRequestOnshippingoptionchangeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onshippingoptionchange");
357}
358
359static inline bool setJSPaymentRequestOnshippingoptionchangeSetter(ExecState& state, JSPaymentRequest& thisObject, JSValue value, ThrowScope& throwScope)
360{
361 UNUSED_PARAM(throwScope);
362 setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().shippingoptionchangeEvent, value);
363 return true;
364}
365
366bool setJSPaymentRequestOnshippingoptionchange(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
367{
368 return IDLAttribute<JSPaymentRequest>::set<setJSPaymentRequestOnshippingoptionchangeSetter>(*state, thisValue, encodedValue, "onshippingoptionchange");
369}
370
371static inline JSValue jsPaymentRequestOnpaymentmethodchangeGetter(ExecState& state, JSPaymentRequest& thisObject, ThrowScope& throwScope)
372{
373 UNUSED_PARAM(throwScope);
374 UNUSED_PARAM(state);
375 return eventHandlerAttribute(thisObject.wrapped(), eventNames().paymentmethodchangeEvent, worldForDOMObject(thisObject));
376}
377
378EncodedJSValue jsPaymentRequestOnpaymentmethodchange(ExecState* state, EncodedJSValue thisValue, PropertyName)
379{
380 return IDLAttribute<JSPaymentRequest>::get<jsPaymentRequestOnpaymentmethodchangeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onpaymentmethodchange");
381}
382
383static inline bool setJSPaymentRequestOnpaymentmethodchangeSetter(ExecState& state, JSPaymentRequest& thisObject, JSValue value, ThrowScope& throwScope)
384{
385 UNUSED_PARAM(throwScope);
386 setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().paymentmethodchangeEvent, value);
387 return true;
388}
389
390bool setJSPaymentRequestOnpaymentmethodchange(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
391{
392 return IDLAttribute<JSPaymentRequest>::set<setJSPaymentRequestOnpaymentmethodchangeSetter>(*state, thisValue, encodedValue, "onpaymentmethodchange");
393}
394
395static inline JSC::EncodedJSValue jsPaymentRequestPrototypeFunctionShowBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSPaymentRequest>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope)
396{
397 UNUSED_PARAM(state);
398 UNUSED_PARAM(throwScope);
399 auto& impl = castedThis->wrapped();
400 auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext();
401 if (UNLIKELY(!context))
402 return JSValue::encode(jsUndefined());
403 ASSERT(context->isDocument());
404 auto& document = downcast<Document>(*context);
405 auto detailsPromise = state->argument(0).isUndefined() ? nullptr : convert<IDLPromise<IDLDictionary<PaymentDetailsUpdate>>>(*state, state->uncheckedArgument(0));
406 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
407 impl.show(document, WTFMove(detailsPromise), WTFMove(promise));
408 return JSValue::encode(jsUndefined());
409}
410
411EncodedJSValue JSC_HOST_CALL jsPaymentRequestPrototypeFunctionShow(ExecState* state)
412{
413 return IDLOperationReturningPromise<JSPaymentRequest>::call<jsPaymentRequestPrototypeFunctionShowBody, PromiseExecutionScope::WindowOnly>(*state, "show");
414}
415
416static inline JSC::EncodedJSValue jsPaymentRequestPrototypeFunctionAbortBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSPaymentRequest>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope)
417{
418 UNUSED_PARAM(state);
419 UNUSED_PARAM(throwScope);
420 auto& impl = castedThis->wrapped();
421 impl.abort(WTFMove(promise));
422 return JSValue::encode(jsUndefined());
423}
424
425EncodedJSValue JSC_HOST_CALL jsPaymentRequestPrototypeFunctionAbort(ExecState* state)
426{
427 return IDLOperationReturningPromise<JSPaymentRequest>::call<jsPaymentRequestPrototypeFunctionAbortBody, PromiseExecutionScope::WindowOnly>(*state, "abort");
428}
429
430static inline JSC::EncodedJSValue jsPaymentRequestPrototypeFunctionCanMakePaymentBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSPaymentRequest>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope)
431{
432 UNUSED_PARAM(state);
433 UNUSED_PARAM(throwScope);
434 auto& impl = castedThis->wrapped();
435 auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext();
436 if (UNLIKELY(!context))
437 return JSValue::encode(jsUndefined());
438 ASSERT(context->isDocument());
439 auto& document = downcast<Document>(*context);
440 impl.canMakePayment(document, WTFMove(promise));
441 return JSValue::encode(jsUndefined());
442}
443
444EncodedJSValue JSC_HOST_CALL jsPaymentRequestPrototypeFunctionCanMakePayment(ExecState* state)
445{
446 return IDLOperationReturningPromise<JSPaymentRequest>::call<jsPaymentRequestPrototypeFunctionCanMakePaymentBody, PromiseExecutionScope::WindowOnly>(*state, "canMakePayment");
447}
448
449void JSPaymentRequest::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
450{
451 auto* thisObject = jsCast<JSPaymentRequest*>(cell);
452 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
453 if (thisObject->scriptExecutionContext())
454 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
455 Base::heapSnapshot(cell, builder);
456}
457
458bool JSPaymentRequestOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
459{
460 auto* jsPaymentRequest = jsCast<JSPaymentRequest*>(handle.slot()->asCell());
461 if (jsPaymentRequest->wrapped().hasPendingActivity()) {
462 if (UNLIKELY(reason))
463 *reason = "ActiveDOMObject with pending activity";
464 return true;
465 }
466 if (jsPaymentRequest->wrapped().isFiringEventListeners()) {
467 if (UNLIKELY(reason))
468 *reason = "EventTarget firing event listeners";
469 return true;
470 }
471 UNUSED_PARAM(visitor);
472 UNUSED_PARAM(reason);
473 return false;
474}
475
476void JSPaymentRequestOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
477{
478 auto* jsPaymentRequest = static_cast<JSPaymentRequest*>(handle.slot()->asCell());
479 auto& world = *static_cast<DOMWrapperWorld*>(context);
480 uncacheWrapper(world, &jsPaymentRequest->wrapped(), jsPaymentRequest);
481}
482
483#if ENABLE(BINDING_INTEGRITY)
484#if PLATFORM(WIN)
485#pragma warning(disable: 4483)
486extern "C" { extern void (*const __identifier("??_7PaymentRequest@WebCore@@6B@")[])(); }
487#else
488extern "C" { extern void* _ZTVN7WebCore14PaymentRequestE[]; }
489#endif
490#endif
491
492JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<PaymentRequest>&& impl)
493{
494
495#if ENABLE(BINDING_INTEGRITY)
496 void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
497#if PLATFORM(WIN)
498 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7PaymentRequest@WebCore@@6B@"));
499#else
500 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore14PaymentRequestE[2]);
501#endif
502
503 // If this fails PaymentRequest does not have a vtable, so you need to add the
504 // ImplementationLacksVTable attribute to the interface definition
505 static_assert(std::is_polymorphic<PaymentRequest>::value, "PaymentRequest is not polymorphic");
506
507 // If you hit this assertion you either have a use after free bug, or
508 // PaymentRequest has subclasses. If PaymentRequest has subclasses that get passed
509 // to toJS() we currently require PaymentRequest you to opt out of binding hardening
510 // by adding the SkipVTableValidation attribute to the interface IDL definition
511 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
512#endif
513 return createWrapper<PaymentRequest>(globalObject, WTFMove(impl));
514}
515
516JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, PaymentRequest& impl)
517{
518 return wrap(state, globalObject, impl);
519}
520
521PaymentRequest* JSPaymentRequest::toWrapped(JSC::VM& vm, JSC::JSValue value)
522{
523 if (auto* wrapper = jsDynamicCast<JSPaymentRequest*>(vm, value))
524 return &wrapper->wrapped();
525 return nullptr;
526}
527
528}
529
530#endif // ENABLE(PAYMENT_REQUEST)
531