/work/obj-fuzz/dom/bindings/PaymentResponseBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM PaymentResponse.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "EventHandlerBinding.h" |
4 | | #include "EventTargetBinding.h" |
5 | | #include "PaymentRequestBinding.h" |
6 | | #include "PaymentResponseBinding.h" |
7 | | #include "WrapperFactory.h" |
8 | | #include "jsapi.h" |
9 | | #include "mozilla/OwningNonNull.h" |
10 | | #include "mozilla/dom/BindingUtils.h" |
11 | | #include "mozilla/dom/DOMJSClass.h" |
12 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
13 | | #include "mozilla/dom/Nullable.h" |
14 | | #include "mozilla/dom/PaymentAddress.h" |
15 | | #include "mozilla/dom/PaymentRequest.h" |
16 | | #include "mozilla/dom/PaymentResponse.h" |
17 | | #include "mozilla/dom/Promise.h" |
18 | | #include "mozilla/dom/ToJSValue.h" |
19 | | #include "mozilla/dom/XrayExpandoClass.h" |
20 | | |
21 | | namespace mozilla { |
22 | | namespace dom { |
23 | | |
24 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
25 | | using namespace mozilla::dom::binding_detail; |
26 | | |
27 | | |
28 | | namespace PaymentCompleteValues { |
29 | | extern const EnumEntry strings[4] = { |
30 | | {"success", 7}, |
31 | | {"fail", 4}, |
32 | | {"unknown", 7}, |
33 | | { nullptr, 0 } |
34 | | }; |
35 | | } // namespace PaymentCompleteValues |
36 | | |
37 | | bool |
38 | | ToJSValue(JSContext* aCx, PaymentComplete aArgument, JS::MutableHandle<JS::Value> aValue) |
39 | 0 | { |
40 | 0 | MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(PaymentCompleteValues::strings)); |
41 | 0 | JSString* resultStr = |
42 | 0 | JS_NewStringCopyN(aCx, PaymentCompleteValues::strings[uint32_t(aArgument)].value, |
43 | 0 | PaymentCompleteValues::strings[uint32_t(aArgument)].length); |
44 | 0 | if (!resultStr) { |
45 | 0 | return false; |
46 | 0 | } |
47 | 0 | aValue.setString(resultStr); |
48 | 0 | return true; |
49 | 0 | } |
50 | | |
51 | | |
52 | | namespace PaymentResponse_Binding { |
53 | | |
54 | | static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTarget_Binding::NativeType>::value, |
55 | | "Can't inherit from an interface with a different ownership model."); |
56 | | |
57 | | MOZ_CAN_RUN_SCRIPT static bool |
58 | | get_requestId(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PaymentResponse* self, JSJitGetterCallArgs args) |
59 | 0 | { |
60 | 0 | AUTO_PROFILER_LABEL_FAST("get PaymentResponse.requestId", DOM, cx); |
61 | 0 |
|
62 | 0 | DOMString result; |
63 | 0 | self->GetRequestId(result); |
64 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
65 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
66 | 0 | return false; |
67 | 0 | } |
68 | 0 | return true; |
69 | 0 | } |
70 | | |
71 | | static const JSJitInfo requestId_getterinfo = { |
72 | | { (JSJitGetterOp)get_requestId }, |
73 | | { prototypes::id::PaymentResponse }, |
74 | | { PrototypeTraits<prototypes::id::PaymentResponse>::Depth }, |
75 | | JSJitInfo::Getter, |
76 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
77 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
78 | | false, /* isInfallible. False in setters. */ |
79 | | false, /* isMovable. Not relevant for setters. */ |
80 | | false, /* isEliminatable. Not relevant for setters. */ |
81 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
82 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
83 | | false, /* isTypedMethod. Only relevant for methods. */ |
84 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
85 | | }; |
86 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
87 | | static_assert(0 < 1, "There is no slot for us"); |
88 | | |
89 | | MOZ_CAN_RUN_SCRIPT static bool |
90 | | get_methodName(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PaymentResponse* self, JSJitGetterCallArgs args) |
91 | 0 | { |
92 | 0 | AUTO_PROFILER_LABEL_FAST("get PaymentResponse.methodName", DOM, cx); |
93 | 0 |
|
94 | 0 | DOMString result; |
95 | 0 | self->GetMethodName(result); |
96 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
97 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
98 | 0 | return false; |
99 | 0 | } |
100 | 0 | return true; |
101 | 0 | } |
102 | | |
103 | | static const JSJitInfo methodName_getterinfo = { |
104 | | { (JSJitGetterOp)get_methodName }, |
105 | | { prototypes::id::PaymentResponse }, |
106 | | { PrototypeTraits<prototypes::id::PaymentResponse>::Depth }, |
107 | | JSJitInfo::Getter, |
108 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
109 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
110 | | false, /* isInfallible. False in setters. */ |
111 | | false, /* isMovable. Not relevant for setters. */ |
112 | | false, /* isEliminatable. Not relevant for setters. */ |
113 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
114 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
115 | | false, /* isTypedMethod. Only relevant for methods. */ |
116 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
117 | | }; |
118 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
119 | | static_assert(0 < 1, "There is no slot for us"); |
120 | | |
121 | | MOZ_CAN_RUN_SCRIPT static bool |
122 | | get_details(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PaymentResponse* self, JSJitGetterCallArgs args) |
123 | 0 | { |
124 | 0 | AUTO_PROFILER_LABEL_FAST("get PaymentResponse.details", DOM, cx); |
125 | 0 |
|
126 | 0 | JS::Rooted<JSObject*> result(cx); |
127 | 0 | self->GetDetails(cx, &result); |
128 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
129 | 0 | JS::ExposeObjectToActiveJS(result); |
130 | 0 | args.rval().setObject(*result); |
131 | 0 | if (!MaybeWrapObjectValue(cx, args.rval())) { |
132 | 0 | return false; |
133 | 0 | } |
134 | 0 | return true; |
135 | 0 | } |
136 | | |
137 | | static const JSJitInfo details_getterinfo = { |
138 | | { (JSJitGetterOp)get_details }, |
139 | | { prototypes::id::PaymentResponse }, |
140 | | { PrototypeTraits<prototypes::id::PaymentResponse>::Depth }, |
141 | | JSJitInfo::Getter, |
142 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
143 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
144 | | false, /* isInfallible. False in setters. */ |
145 | | false, /* isMovable. Not relevant for setters. */ |
146 | | false, /* isEliminatable. Not relevant for setters. */ |
147 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
148 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
149 | | false, /* isTypedMethod. Only relevant for methods. */ |
150 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
151 | | }; |
152 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
153 | | static_assert(0 < 1, "There is no slot for us"); |
154 | | |
155 | | MOZ_CAN_RUN_SCRIPT static bool |
156 | | get_shippingAddress(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PaymentResponse* self, JSJitGetterCallArgs args) |
157 | 0 | { |
158 | 0 | AUTO_PROFILER_LABEL_FAST("get PaymentResponse.shippingAddress", DOM, cx); |
159 | 0 |
|
160 | 0 | auto result(StrongOrRawPtr<mozilla::dom::PaymentAddress>(self->GetShippingAddress())); |
161 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
162 | 0 | if (!result) { |
163 | 0 | args.rval().setNull(); |
164 | 0 | return true; |
165 | 0 | } |
166 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
167 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
168 | 0 | return false; |
169 | 0 | } |
170 | 0 | return true; |
171 | 0 | } |
172 | | |
173 | | static const JSJitInfo shippingAddress_getterinfo = { |
174 | | { (JSJitGetterOp)get_shippingAddress }, |
175 | | { prototypes::id::PaymentResponse }, |
176 | | { PrototypeTraits<prototypes::id::PaymentResponse>::Depth }, |
177 | | JSJitInfo::Getter, |
178 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
179 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
180 | | false, /* isInfallible. False in setters. */ |
181 | | false, /* isMovable. Not relevant for setters. */ |
182 | | false, /* isEliminatable. Not relevant for setters. */ |
183 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
184 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
185 | | false, /* isTypedMethod. Only relevant for methods. */ |
186 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
187 | | }; |
188 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
189 | | static_assert(0 < 1, "There is no slot for us"); |
190 | | |
191 | | MOZ_CAN_RUN_SCRIPT static bool |
192 | | get_shippingOption(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PaymentResponse* self, JSJitGetterCallArgs args) |
193 | 0 | { |
194 | 0 | AUTO_PROFILER_LABEL_FAST("get PaymentResponse.shippingOption", DOM, cx); |
195 | 0 |
|
196 | 0 | DOMString result; |
197 | 0 | self->GetShippingOption(result); |
198 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
199 | 0 | if (!xpc::StringToJsval(cx, result, args.rval())) { |
200 | 0 | return false; |
201 | 0 | } |
202 | 0 | return true; |
203 | 0 | } |
204 | | |
205 | | static const JSJitInfo shippingOption_getterinfo = { |
206 | | { (JSJitGetterOp)get_shippingOption }, |
207 | | { prototypes::id::PaymentResponse }, |
208 | | { PrototypeTraits<prototypes::id::PaymentResponse>::Depth }, |
209 | | JSJitInfo::Getter, |
210 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
211 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
212 | | false, /* isInfallible. False in setters. */ |
213 | | false, /* isMovable. Not relevant for setters. */ |
214 | | false, /* isEliminatable. Not relevant for setters. */ |
215 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
216 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
217 | | false, /* isTypedMethod. Only relevant for methods. */ |
218 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
219 | | }; |
220 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
221 | | static_assert(0 < 1, "There is no slot for us"); |
222 | | |
223 | | MOZ_CAN_RUN_SCRIPT static bool |
224 | | get_payerName(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PaymentResponse* self, JSJitGetterCallArgs args) |
225 | 0 | { |
226 | 0 | AUTO_PROFILER_LABEL_FAST("get PaymentResponse.payerName", DOM, cx); |
227 | 0 |
|
228 | 0 | DOMString result; |
229 | 0 | self->GetPayerName(result); |
230 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
231 | 0 | if (!xpc::StringToJsval(cx, result, args.rval())) { |
232 | 0 | return false; |
233 | 0 | } |
234 | 0 | return true; |
235 | 0 | } |
236 | | |
237 | | static const JSJitInfo payerName_getterinfo = { |
238 | | { (JSJitGetterOp)get_payerName }, |
239 | | { prototypes::id::PaymentResponse }, |
240 | | { PrototypeTraits<prototypes::id::PaymentResponse>::Depth }, |
241 | | JSJitInfo::Getter, |
242 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
243 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
244 | | false, /* isInfallible. False in setters. */ |
245 | | false, /* isMovable. Not relevant for setters. */ |
246 | | false, /* isEliminatable. Not relevant for setters. */ |
247 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
248 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
249 | | false, /* isTypedMethod. Only relevant for methods. */ |
250 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
251 | | }; |
252 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
253 | | static_assert(0 < 1, "There is no slot for us"); |
254 | | |
255 | | MOZ_CAN_RUN_SCRIPT static bool |
256 | | get_payerEmail(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PaymentResponse* self, JSJitGetterCallArgs args) |
257 | 0 | { |
258 | 0 | AUTO_PROFILER_LABEL_FAST("get PaymentResponse.payerEmail", DOM, cx); |
259 | 0 |
|
260 | 0 | DOMString result; |
261 | 0 | self->GetPayerEmail(result); |
262 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
263 | 0 | if (!xpc::StringToJsval(cx, result, args.rval())) { |
264 | 0 | return false; |
265 | 0 | } |
266 | 0 | return true; |
267 | 0 | } |
268 | | |
269 | | static const JSJitInfo payerEmail_getterinfo = { |
270 | | { (JSJitGetterOp)get_payerEmail }, |
271 | | { prototypes::id::PaymentResponse }, |
272 | | { PrototypeTraits<prototypes::id::PaymentResponse>::Depth }, |
273 | | JSJitInfo::Getter, |
274 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
275 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
276 | | false, /* isInfallible. False in setters. */ |
277 | | false, /* isMovable. Not relevant for setters. */ |
278 | | false, /* isEliminatable. Not relevant for setters. */ |
279 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
280 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
281 | | false, /* isTypedMethod. Only relevant for methods. */ |
282 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
283 | | }; |
284 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
285 | | static_assert(0 < 1, "There is no slot for us"); |
286 | | |
287 | | MOZ_CAN_RUN_SCRIPT static bool |
288 | | get_payerPhone(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PaymentResponse* self, JSJitGetterCallArgs args) |
289 | 0 | { |
290 | 0 | AUTO_PROFILER_LABEL_FAST("get PaymentResponse.payerPhone", DOM, cx); |
291 | 0 |
|
292 | 0 | DOMString result; |
293 | 0 | self->GetPayerPhone(result); |
294 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
295 | 0 | if (!xpc::StringToJsval(cx, result, args.rval())) { |
296 | 0 | return false; |
297 | 0 | } |
298 | 0 | return true; |
299 | 0 | } |
300 | | |
301 | | static const JSJitInfo payerPhone_getterinfo = { |
302 | | { (JSJitGetterOp)get_payerPhone }, |
303 | | { prototypes::id::PaymentResponse }, |
304 | | { PrototypeTraits<prototypes::id::PaymentResponse>::Depth }, |
305 | | JSJitInfo::Getter, |
306 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
307 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
308 | | false, /* isInfallible. False in setters. */ |
309 | | false, /* isMovable. Not relevant for setters. */ |
310 | | false, /* isEliminatable. Not relevant for setters. */ |
311 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
312 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
313 | | false, /* isTypedMethod. Only relevant for methods. */ |
314 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
315 | | }; |
316 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
317 | | static_assert(0 < 1, "There is no slot for us"); |
318 | | |
319 | | MOZ_CAN_RUN_SCRIPT static bool |
320 | | complete(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PaymentResponse* self, const JSJitMethodCallArgs& args) |
321 | 0 | { |
322 | 0 | AUTO_PROFILER_LABEL_FAST("PaymentResponse.complete", DOM, cx); |
323 | 0 |
|
324 | 0 | PaymentComplete arg0; |
325 | 0 | if (args.hasDefined(0)) { |
326 | 0 | { |
327 | 0 | int index; |
328 | 0 | if (!FindEnumStringIndex<true>(cx, args[0], PaymentCompleteValues::strings, "PaymentComplete", "Argument 1 of PaymentResponse.complete", &index)) { |
329 | 0 | return false; |
330 | 0 | } |
331 | 0 | MOZ_ASSERT(index >= 0); |
332 | 0 | arg0 = static_cast<PaymentComplete>(index); |
333 | 0 | } |
334 | 0 | } else { |
335 | 0 | arg0 = PaymentComplete::Unknown; |
336 | 0 | } |
337 | 0 | FastErrorResult rv; |
338 | 0 | auto result(StrongOrRawPtr<Promise>(self->Complete(arg0, rv))); |
339 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
340 | 0 | return false; |
341 | 0 | } |
342 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
343 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
344 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
345 | 0 | if (!ToJSValue(cx, result, args.rval())) { |
346 | 0 | return false; |
347 | 0 | } |
348 | 0 | return true; |
349 | 0 | } |
350 | | |
351 | | MOZ_CAN_RUN_SCRIPT static bool |
352 | | complete_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PaymentResponse* self, const JSJitMethodCallArgs& args) |
353 | 0 | { |
354 | 0 | bool ok = complete(cx, obj, self, args); |
355 | 0 | if (ok) { |
356 | 0 | return true; |
357 | 0 | } |
358 | 0 | return ConvertExceptionToPromise(cx, args.rval()); |
359 | 0 | } |
360 | | |
361 | | static const JSJitInfo complete_methodinfo = { |
362 | | { (JSJitGetterOp)complete_promiseWrapper }, |
363 | | { prototypes::id::PaymentResponse }, |
364 | | { PrototypeTraits<prototypes::id::PaymentResponse>::Depth }, |
365 | | JSJitInfo::Method, |
366 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
367 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
368 | | false, /* isInfallible. False in setters. */ |
369 | | false, /* isMovable. Not relevant for setters. */ |
370 | | false, /* isEliminatable. Not relevant for setters. */ |
371 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
372 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
373 | | false, /* isTypedMethod. Only relevant for methods. */ |
374 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
375 | | }; |
376 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
377 | | static_assert(0 < 1, "There is no slot for us"); |
378 | | |
379 | | MOZ_CAN_RUN_SCRIPT static bool |
380 | | retry(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PaymentResponse* self, const JSJitMethodCallArgs& args) |
381 | 0 | { |
382 | 0 | AUTO_PROFILER_LABEL_FAST("PaymentResponse.retry", DOM, cx); |
383 | 0 |
|
384 | 0 | RootedDictionary<binding_detail::FastPaymentValidationErrors> arg0(cx); |
385 | 0 | if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue, "Argument 1 of PaymentResponse.retry", false)) { |
386 | 0 | return false; |
387 | 0 | } |
388 | 0 | FastErrorResult rv; |
389 | 0 | auto result(StrongOrRawPtr<Promise>(self->Retry(cx, Constify(arg0), rv))); |
390 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
391 | 0 | return false; |
392 | 0 | } |
393 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
394 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
395 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
396 | 0 | if (!ToJSValue(cx, result, args.rval())) { |
397 | 0 | return false; |
398 | 0 | } |
399 | 0 | return true; |
400 | 0 | } |
401 | | |
402 | | MOZ_CAN_RUN_SCRIPT static bool |
403 | | retry_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PaymentResponse* self, const JSJitMethodCallArgs& args) |
404 | 0 | { |
405 | 0 | bool ok = retry(cx, obj, self, args); |
406 | 0 | if (ok) { |
407 | 0 | return true; |
408 | 0 | } |
409 | 0 | return ConvertExceptionToPromise(cx, args.rval()); |
410 | 0 | } |
411 | | |
412 | | static const JSJitInfo retry_methodinfo = { |
413 | | { (JSJitGetterOp)retry_promiseWrapper }, |
414 | | { prototypes::id::PaymentResponse }, |
415 | | { PrototypeTraits<prototypes::id::PaymentResponse>::Depth }, |
416 | | JSJitInfo::Method, |
417 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
418 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
419 | | false, /* isInfallible. False in setters. */ |
420 | | false, /* isMovable. Not relevant for setters. */ |
421 | | false, /* isEliminatable. Not relevant for setters. */ |
422 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
423 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
424 | | false, /* isTypedMethod. Only relevant for methods. */ |
425 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
426 | | }; |
427 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
428 | | static_assert(0 < 1, "There is no slot for us"); |
429 | | |
430 | | MOZ_CAN_RUN_SCRIPT static bool |
431 | | get_onpayerdetailchange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PaymentResponse* self, JSJitGetterCallArgs args) |
432 | 0 | { |
433 | 0 | AUTO_PROFILER_LABEL_FAST("get PaymentResponse.onpayerdetailchange", DOM, cx); |
434 | 0 |
|
435 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnpayerdetailchange()); |
436 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
437 | 0 | if (result) { |
438 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
439 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
440 | 0 | return false; |
441 | 0 | } |
442 | 0 | return true; |
443 | 0 | } else { |
444 | 0 | args.rval().setNull(); |
445 | 0 | return true; |
446 | 0 | } |
447 | 0 | } |
448 | | |
449 | | MOZ_CAN_RUN_SCRIPT static bool |
450 | | set_onpayerdetailchange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PaymentResponse* self, JSJitSetterCallArgs args) |
451 | 0 | { |
452 | 0 | AUTO_PROFILER_LABEL_FAST("set PaymentResponse.onpayerdetailchange", DOM, cx); |
453 | 0 |
|
454 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
455 | 0 | if (args[0].isObject()) { |
456 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
457 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
458 | 0 | } |
459 | 0 | } else { |
460 | 0 | arg0 = nullptr; |
461 | 0 | } |
462 | 0 | self->SetOnpayerdetailchange(Constify(arg0)); |
463 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
464 | 0 |
|
465 | 0 | return true; |
466 | 0 | } |
467 | | |
468 | | static const JSJitInfo onpayerdetailchange_getterinfo = { |
469 | | { (JSJitGetterOp)get_onpayerdetailchange }, |
470 | | { prototypes::id::PaymentResponse }, |
471 | | { PrototypeTraits<prototypes::id::PaymentResponse>::Depth }, |
472 | | JSJitInfo::Getter, |
473 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
474 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
475 | | false, /* isInfallible. False in setters. */ |
476 | | false, /* isMovable. Not relevant for setters. */ |
477 | | false, /* isEliminatable. Not relevant for setters. */ |
478 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
479 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
480 | | false, /* isTypedMethod. Only relevant for methods. */ |
481 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
482 | | }; |
483 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
484 | | static_assert(0 < 1, "There is no slot for us"); |
485 | | static const JSJitInfo onpayerdetailchange_setterinfo = { |
486 | | { (JSJitGetterOp)set_onpayerdetailchange }, |
487 | | { prototypes::id::PaymentResponse }, |
488 | | { PrototypeTraits<prototypes::id::PaymentResponse>::Depth }, |
489 | | JSJitInfo::Setter, |
490 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
491 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
492 | | false, /* isInfallible. False in setters. */ |
493 | | false, /* isMovable. Not relevant for setters. */ |
494 | | false, /* isEliminatable. Not relevant for setters. */ |
495 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
496 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
497 | | false, /* isTypedMethod. Only relevant for methods. */ |
498 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
499 | | }; |
500 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
501 | | static_assert(0 < 1, "There is no slot for us"); |
502 | | |
503 | | MOZ_CAN_RUN_SCRIPT static bool |
504 | | toJSON(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PaymentResponse* self, const JSJitMethodCallArgs& args) |
505 | 0 | { |
506 | 0 | AUTO_PROFILER_LABEL_FAST("PaymentResponse.toJSON", DOM, cx); |
507 | 0 |
|
508 | 0 | JS::Rooted<JSObject*> result(cx, JS_NewPlainObject(cx)); |
509 | 0 | if (!result) { |
510 | 0 | return false; |
511 | 0 | } |
512 | 0 | if (!PaymentResponse_Binding::CollectJSONAttributes(cx, obj, self, result)) { |
513 | 0 | return false; |
514 | 0 | } |
515 | 0 | args.rval().setObject(*result); |
516 | 0 | return true; |
517 | 0 | } |
518 | | |
519 | | static const JSJitInfo toJSON_methodinfo = { |
520 | | { (JSJitGetterOp)toJSON }, |
521 | | { prototypes::id::PaymentResponse }, |
522 | | { PrototypeTraits<prototypes::id::PaymentResponse>::Depth }, |
523 | | JSJitInfo::Method, |
524 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
525 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
526 | | false, /* isInfallible. False in setters. */ |
527 | | false, /* isMovable. Not relevant for setters. */ |
528 | | false, /* isEliminatable. Not relevant for setters. */ |
529 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
530 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
531 | | false, /* isTypedMethod. Only relevant for methods. */ |
532 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
533 | | }; |
534 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
535 | | static_assert(0 < 1, "There is no slot for us"); |
536 | | |
537 | | static bool |
538 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
539 | 0 | { |
540 | 0 | mozilla::dom::PaymentResponse* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PaymentResponse>(obj); |
541 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
542 | 0 | // obviously can't preserve if we're not initialized. |
543 | 0 | if (self && self->GetWrapperPreserveColor()) { |
544 | 0 | PreserveWrapper(self); |
545 | 0 | } |
546 | 0 | return true; |
547 | 0 | } |
548 | | |
549 | | static void |
550 | | _finalize(js::FreeOp* fop, JSObject* obj) |
551 | 0 | { |
552 | 0 | mozilla::dom::PaymentResponse* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PaymentResponse>(obj); |
553 | 0 | if (self) { |
554 | 0 | ClearWrapper(self, self, obj); |
555 | 0 | AddForDeferredFinalization<mozilla::dom::PaymentResponse>(self); |
556 | 0 | } |
557 | 0 | } |
558 | | |
559 | | static size_t |
560 | | _objectMoved(JSObject* obj, JSObject* old) |
561 | 0 | { |
562 | 0 | mozilla::dom::PaymentResponse* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PaymentResponse>(obj); |
563 | 0 | if (self) { |
564 | 0 | UpdateWrapper(self, self, obj, old); |
565 | 0 | } |
566 | 0 |
|
567 | 0 | return 0; |
568 | 0 | } |
569 | | |
570 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
571 | | #if defined(__clang__) |
572 | | #pragma clang diagnostic push |
573 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
574 | | #endif |
575 | | static const JSFunctionSpec sMethods_specs[] = { |
576 | | JS_FNSPEC("toJSON", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&toJSON_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
577 | | JS_FNSPEC("complete", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&complete_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
578 | | JS_FNSPEC("retry", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&retry_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
579 | | JS_FS_END |
580 | | }; |
581 | | #if defined(__clang__) |
582 | | #pragma clang diagnostic pop |
583 | | #endif |
584 | | |
585 | | // Can't be const because the pref-enabled boolean needs to be writable |
586 | | static PrefableDisablers sMethods_disablers0 = { |
587 | | true, true, 0, nullptr |
588 | | }; |
589 | | |
590 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
591 | | { &sMethods_disablers0, &sMethods_specs[0] }, |
592 | | { nullptr, nullptr } |
593 | | }; |
594 | | |
595 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
596 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
597 | | static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
598 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
599 | | |
600 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
601 | | #if defined(__clang__) |
602 | | #pragma clang diagnostic push |
603 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
604 | | #endif |
605 | | static const JSPropertySpec sAttributes_specs[] = { |
606 | | { "requestId", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &requestId_getterinfo, nullptr, nullptr }, |
607 | | { "methodName", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &methodName_getterinfo, nullptr, nullptr }, |
608 | | { "details", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &details_getterinfo, nullptr, nullptr }, |
609 | | { "shippingAddress", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &shippingAddress_getterinfo, nullptr, nullptr }, |
610 | | { "shippingOption", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &shippingOption_getterinfo, nullptr, nullptr }, |
611 | | { "payerName", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &payerName_getterinfo, nullptr, nullptr }, |
612 | | { "payerEmail", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &payerEmail_getterinfo, nullptr, nullptr }, |
613 | | { "payerPhone", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &payerPhone_getterinfo, nullptr, nullptr }, |
614 | | { "onpayerdetailchange", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onpayerdetailchange_getterinfo, GenericSetter<NormalThisPolicy>, &onpayerdetailchange_setterinfo }, |
615 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
616 | | }; |
617 | | #if defined(__clang__) |
618 | | #pragma clang diagnostic pop |
619 | | #endif |
620 | | |
621 | | // Can't be const because the pref-enabled boolean needs to be writable |
622 | | static PrefableDisablers sAttributes_disablers0 = { |
623 | | true, true, 0, nullptr |
624 | | }; |
625 | | |
626 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
627 | | { &sAttributes_disablers0, &sAttributes_specs[0] }, |
628 | | { nullptr, nullptr } |
629 | | }; |
630 | | |
631 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
632 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
633 | | static_assert(9 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
634 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
635 | | |
636 | | |
637 | | static uint16_t sNativeProperties_sortedPropertyIndices[12]; |
638 | | static PropertyInfo sNativeProperties_propertyInfos[12]; |
639 | | |
640 | | static const NativePropertiesN<2> sNativeProperties = { |
641 | | false, 0, |
642 | | false, 0, |
643 | | true, 0 /* sMethods */, |
644 | | true, 1 /* sAttributes */, |
645 | | false, 0, |
646 | | false, 0, |
647 | | false, 0, |
648 | | -1, |
649 | | 12, |
650 | | sNativeProperties_sortedPropertyIndices, |
651 | | { |
652 | | { sMethods, &sNativeProperties_propertyInfos[0] }, |
653 | | { sAttributes, &sNativeProperties_propertyInfos[3] } |
654 | | } |
655 | | }; |
656 | | static_assert(12 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
657 | | "We have a property info count that is oversized"); |
658 | | |
659 | | MOZ_CAN_RUN_SCRIPT bool |
660 | | CollectJSONAttributes(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PaymentResponse* self, JS::Rooted<JSObject*>& result) |
661 | 0 | { |
662 | 0 | { // scope for "temp" |
663 | 0 | JS::Rooted<JS::Value> temp(cx); |
664 | 0 | if (!get_requestId(cx, obj, self, JSJitGetterCallArgs(&temp))) { |
665 | 0 | return false; |
666 | 0 | } |
667 | 0 | if (!JS_DefineProperty(cx, result, "requestId", temp, JSPROP_ENUMERATE)) { |
668 | 0 | return false; |
669 | 0 | } |
670 | 0 | } |
671 | 0 | { // scope for "temp" |
672 | 0 | JS::Rooted<JS::Value> temp(cx); |
673 | 0 | if (!get_methodName(cx, obj, self, JSJitGetterCallArgs(&temp))) { |
674 | 0 | return false; |
675 | 0 | } |
676 | 0 | if (!JS_DefineProperty(cx, result, "methodName", temp, JSPROP_ENUMERATE)) { |
677 | 0 | return false; |
678 | 0 | } |
679 | 0 | } |
680 | 0 | { // scope for "temp" |
681 | 0 | JS::Rooted<JS::Value> temp(cx); |
682 | 0 | if (!get_details(cx, obj, self, JSJitGetterCallArgs(&temp))) { |
683 | 0 | return false; |
684 | 0 | } |
685 | 0 | if (!JS_DefineProperty(cx, result, "details", temp, JSPROP_ENUMERATE)) { |
686 | 0 | return false; |
687 | 0 | } |
688 | 0 | } |
689 | 0 | { // scope for "temp" |
690 | 0 | JS::Rooted<JS::Value> temp(cx); |
691 | 0 | if (!get_shippingAddress(cx, obj, self, JSJitGetterCallArgs(&temp))) { |
692 | 0 | return false; |
693 | 0 | } |
694 | 0 | if (!JS_DefineProperty(cx, result, "shippingAddress", temp, JSPROP_ENUMERATE)) { |
695 | 0 | return false; |
696 | 0 | } |
697 | 0 | } |
698 | 0 | { // scope for "temp" |
699 | 0 | JS::Rooted<JS::Value> temp(cx); |
700 | 0 | if (!get_shippingOption(cx, obj, self, JSJitGetterCallArgs(&temp))) { |
701 | 0 | return false; |
702 | 0 | } |
703 | 0 | if (!JS_DefineProperty(cx, result, "shippingOption", temp, JSPROP_ENUMERATE)) { |
704 | 0 | return false; |
705 | 0 | } |
706 | 0 | } |
707 | 0 | { // scope for "temp" |
708 | 0 | JS::Rooted<JS::Value> temp(cx); |
709 | 0 | if (!get_payerName(cx, obj, self, JSJitGetterCallArgs(&temp))) { |
710 | 0 | return false; |
711 | 0 | } |
712 | 0 | if (!JS_DefineProperty(cx, result, "payerName", temp, JSPROP_ENUMERATE)) { |
713 | 0 | return false; |
714 | 0 | } |
715 | 0 | } |
716 | 0 | { // scope for "temp" |
717 | 0 | JS::Rooted<JS::Value> temp(cx); |
718 | 0 | if (!get_payerEmail(cx, obj, self, JSJitGetterCallArgs(&temp))) { |
719 | 0 | return false; |
720 | 0 | } |
721 | 0 | if (!JS_DefineProperty(cx, result, "payerEmail", temp, JSPROP_ENUMERATE)) { |
722 | 0 | return false; |
723 | 0 | } |
724 | 0 | } |
725 | 0 | { // scope for "temp" |
726 | 0 | JS::Rooted<JS::Value> temp(cx); |
727 | 0 | if (!get_payerPhone(cx, obj, self, JSJitGetterCallArgs(&temp))) { |
728 | 0 | return false; |
729 | 0 | } |
730 | 0 | if (!JS_DefineProperty(cx, result, "payerPhone", temp, JSPROP_ENUMERATE)) { |
731 | 0 | return false; |
732 | 0 | } |
733 | 0 | } |
734 | 0 | return true; |
735 | 0 | } |
736 | | |
737 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
738 | | { |
739 | | "Function", |
740 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
741 | | &sBoringInterfaceObjectClassClassOps, |
742 | | JS_NULL_CLASS_SPEC, |
743 | | JS_NULL_CLASS_EXT, |
744 | | &sInterfaceObjectClassObjectOps |
745 | | }, |
746 | | eInterface, |
747 | | true, |
748 | | prototypes::id::PaymentResponse, |
749 | | PrototypeTraits<prototypes::id::PaymentResponse>::Depth, |
750 | | sNativePropertyHooks, |
751 | | "function PaymentResponse() {\n [native code]\n}", |
752 | | EventTarget_Binding::GetConstructorObject |
753 | | }; |
754 | | |
755 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
756 | | { |
757 | | "PaymentResponsePrototype", |
758 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
759 | | JS_NULL_CLASS_OPS, |
760 | | JS_NULL_CLASS_SPEC, |
761 | | JS_NULL_CLASS_EXT, |
762 | | JS_NULL_OBJECT_OPS |
763 | | }, |
764 | | eInterfacePrototype, |
765 | | false, |
766 | | prototypes::id::PaymentResponse, |
767 | | PrototypeTraits<prototypes::id::PaymentResponse>::Depth, |
768 | | sNativePropertyHooks, |
769 | | "[object PaymentResponsePrototype]", |
770 | | EventTarget_Binding::GetProtoObject |
771 | | }; |
772 | | |
773 | | bool |
774 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
775 | 0 | { |
776 | 0 | return mozilla::dom::PaymentRequest::PrefEnabled(aCx, aObj) && |
777 | 0 | mozilla::dom::IsSecureContextOrObjectIsFromSecureContext(aCx, aObj); |
778 | 0 | } |
779 | | |
780 | | static const js::ClassOps sClassOps = { |
781 | | _addProperty, /* addProperty */ |
782 | | nullptr, /* delProperty */ |
783 | | nullptr, /* enumerate */ |
784 | | nullptr, /* newEnumerate */ |
785 | | nullptr, /* resolve */ |
786 | | nullptr, /* mayResolve */ |
787 | | _finalize, /* finalize */ |
788 | | nullptr, /* call */ |
789 | | nullptr, /* hasInstance */ |
790 | | nullptr, /* construct */ |
791 | | nullptr, /* trace */ |
792 | | }; |
793 | | |
794 | | static const js::ClassExtension sClassExtension = { |
795 | | nullptr, /* weakmapKeyDelegateOp */ |
796 | | _objectMoved /* objectMovedOp */ |
797 | | }; |
798 | | |
799 | | static const DOMJSClass sClass = { |
800 | | { "PaymentResponse", |
801 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
802 | | &sClassOps, |
803 | | JS_NULL_CLASS_SPEC, |
804 | | &sClassExtension, |
805 | | JS_NULL_OBJECT_OPS |
806 | | }, |
807 | | { prototypes::id::EventTarget, prototypes::id::PaymentResponse, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
808 | | IsBaseOf<nsISupports, mozilla::dom::PaymentResponse >::value, |
809 | | sNativePropertyHooks, |
810 | | FindAssociatedGlobalForNative<mozilla::dom::PaymentResponse>::Get, |
811 | | GetProtoObjectHandle, |
812 | | GetCCParticipant<mozilla::dom::PaymentResponse>::Get() |
813 | | }; |
814 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
815 | | "Must have the right minimal number of reserved slots."); |
816 | | static_assert(1 >= 1, |
817 | | "Must have enough reserved slots."); |
818 | | |
819 | | const JSClass* |
820 | | GetJSClass() |
821 | 0 | { |
822 | 0 | return sClass.ToJSClass(); |
823 | 0 | } |
824 | | |
825 | | bool |
826 | | Wrap(JSContext* aCx, mozilla::dom::PaymentResponse* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
827 | 0 | { |
828 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::PaymentResponse>::value, |
829 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
830 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::PaymentResponse*>(aObject) == |
831 | 0 | reinterpret_cast<mozilla::dom::PaymentResponse*>(aObject), |
832 | 0 | "Multiple inheritance for mozilla::dom::PaymentResponse is broken."); |
833 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) == |
834 | 0 | reinterpret_cast<mozilla::dom::EventTarget*>(aObject), |
835 | 0 | "Multiple inheritance for mozilla::dom::EventTarget is broken."); |
836 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
837 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
838 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
839 | 0 | "You should probably not be using Wrap() directly; use " |
840 | 0 | "GetOrCreateDOMReflector instead"); |
841 | 0 |
|
842 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
843 | 0 | "nsISupports must be on our primary inheritance chain"); |
844 | 0 |
|
845 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
846 | 0 | if (!global) { |
847 | 0 | return false; |
848 | 0 | } |
849 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
850 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
851 | 0 |
|
852 | 0 | // That might have ended up wrapping us already, due to the wonders |
853 | 0 | // of XBL. Check for that, and bail out as needed. |
854 | 0 | aReflector.set(aCache->GetWrapper()); |
855 | 0 | if (aReflector) { |
856 | | #ifdef DEBUG |
857 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
858 | | #endif // DEBUG |
859 | | return true; |
860 | 0 | } |
861 | 0 |
|
862 | 0 | JSAutoRealm ar(aCx, global); |
863 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
864 | 0 | if (!canonicalProto) { |
865 | 0 | return false; |
866 | 0 | } |
867 | 0 | JS::Rooted<JSObject*> proto(aCx); |
868 | 0 | if (aGivenProto) { |
869 | 0 | proto = aGivenProto; |
870 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
871 | 0 | // coming in, we changed compartments to that of "parent" so may need |
872 | 0 | // to wrap the proto here. |
873 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
874 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
875 | 0 | return false; |
876 | 0 | } |
877 | 0 | } |
878 | 0 | } else { |
879 | 0 | proto = canonicalProto; |
880 | 0 | } |
881 | 0 |
|
882 | 0 | BindingJSObjectCreator<mozilla::dom::PaymentResponse> creator(aCx); |
883 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
884 | 0 | if (!aReflector) { |
885 | 0 | return false; |
886 | 0 | } |
887 | 0 | |
888 | 0 | aCache->SetWrapper(aReflector); |
889 | 0 | creator.InitializationSucceeded(); |
890 | 0 |
|
891 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
892 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
893 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
894 | 0 | // otherwise we won't be able to properly recreate it later, since |
895 | 0 | // we won't know what proto to use. Note that we don't check |
896 | 0 | // aGivenProto here, since it's entirely possible (and even |
897 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
898 | 0 | // same as canonicalProto. |
899 | 0 | if (proto != canonicalProto) { |
900 | 0 | PreserveWrapper(aObject); |
901 | 0 | } |
902 | 0 |
|
903 | 0 | return true; |
904 | 0 | } |
905 | | |
906 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
907 | | nullptr, |
908 | | nullptr, |
909 | | nullptr, |
910 | | { sNativeProperties.Upcast(), nullptr }, |
911 | | prototypes::id::PaymentResponse, |
912 | | constructors::id::PaymentResponse, |
913 | | EventTarget_Binding::sNativePropertyHooks, |
914 | | &DefaultXrayExpandoObjectClass |
915 | | } }; |
916 | | |
917 | | void |
918 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
919 | 0 | { |
920 | 0 | JS::Handle<JSObject*> parentProto(EventTarget_Binding::GetProtoObjectHandle(aCx)); |
921 | 0 | if (!parentProto) { |
922 | 0 | return; |
923 | 0 | } |
924 | 0 | |
925 | 0 | JS::Handle<JSObject*> constructorProto(EventTarget_Binding::GetConstructorObjectHandle(aCx)); |
926 | 0 | if (!constructorProto) { |
927 | 0 | return; |
928 | 0 | } |
929 | 0 | |
930 | 0 | static bool sIdsInited = false; |
931 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
932 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
933 | 0 | return; |
934 | 0 | } |
935 | 0 | sIdsInited = true; |
936 | 0 | } |
937 | 0 |
|
938 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::PaymentResponse); |
939 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::PaymentResponse); |
940 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
941 | 0 | &sPrototypeClass.mBase, protoCache, |
942 | 0 | nullptr, |
943 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
944 | 0 | interfaceCache, |
945 | 0 | sNativeProperties.Upcast(), |
946 | 0 | nullptr, |
947 | 0 | "PaymentResponse", aDefineOnGlobal, |
948 | 0 | nullptr, |
949 | 0 | false); |
950 | 0 | } |
951 | | |
952 | | JSObject* |
953 | | GetConstructorObject(JSContext* aCx) |
954 | 0 | { |
955 | 0 | return GetConstructorObjectHandle(aCx); |
956 | 0 | } |
957 | | |
958 | | } // namespace PaymentResponse_Binding |
959 | | |
960 | | |
961 | | |
962 | | } // namespace dom |
963 | | } // namespace mozilla |