1#![allow(non_camel_case_types,non_upper_case_globals,unsafe_op_in_unsafe_fn,unused_imports,unused_variables,unused_assignments,unused_mut,clippy::approx_constant,clippy::enum_variant_names,clippy::let_unit_value,clippy::needless_return,clippy::too_many_arguments,clippy::unnecessary_cast,clippy::upper_case_acronyms)]
4
5use crate::codegen::GenericBindings::EventBinding::Event_Binding;
6use crate::codegen::GenericBindings::EventTargetBinding::EventTarget_Binding;
7use crate::codegen::GenericBindings::WorkerGlobalScopeBinding::WorkerGlobalScope_Binding;
8use crate::import::base::*;
9
10#[derive(JSTraceable)]
11#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]
12pub struct PromiseRejectionEventInit {
13 pub parent: crate::codegen::GenericBindings::EventBinding::EventInit,
14 pub promise: RootedTraceableBox<Heap<*mut JSObject>>,
15 pub reason: RootedTraceableBox<Heap<JSVal>>,
16}
17
18impl PromiseRejectionEventInit {
19
20 pub fn new(cx: SafeJSContext, val: HandleValue, can_gc: CanGc)
21 -> Result<ConversionResult<RootedTraceableBox<PromiseRejectionEventInit>>, ()> {
22 unsafe {
23 let object = if val.get().is_null_or_undefined() {
24 ptr::null_mut()
25 } else if val.get().is_object() {
26 val.get().to_object()
27 } else {
28 return Ok(ConversionResult::Failure("Value is not an object.".into()));
29 };
30 rooted!(&in(cx) let object = object);
31 let dictionary = RootedTraceableBox::new(PromiseRejectionEventInit {
32 parent: {
33 match crate::codegen::GenericBindings::EventBinding::EventInit::new(cx, val, can_gc)? {
34 ConversionResult::Success(v) => v,
35 ConversionResult::Failure(error) => {
36 throw_type_error(cx.raw_cx(), &error);
37 return Err(());
38 }
39 }
40 },
41 promise: {
42 rooted!(&in(cx) let mut rval = UndefinedValue());
43 if get_dictionary_property(cx.raw_cx(), object.handle(), "promise", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
44 if rval.handle().get().is_object() {
45 RootedTraceableBox::from_box(Heap::boxed(rval.handle().get().to_object()))
46 } else {
47 throw_type_error(cx.raw_cx(), "Value is not an object.");
48 return Err(());
49
50 }
51 } else {
52 throw_type_error(cx.raw_cx(), "Missing required member \"promise\".");
53 return Err(());
54 }
55 },
56 reason: {
57 rooted!(&in(cx) let mut rval = UndefinedValue());
58 if get_dictionary_property(cx.raw_cx(), object.handle(), "reason", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
59 RootedTraceableBox::from_box(Heap::boxed(rval.handle().get()))
60 } else {
61 RootedTraceableBox::from_box(Heap::boxed(UndefinedValue()))
62 }
63 },
64 });
65 Ok(ConversionResult::Success(dictionary))
66 }
67 }
68}
69
70impl FromJSValConvertible for RootedTraceableBox<PromiseRejectionEventInit> {
71 type Config = ();
72 unsafe fn from_jsval(cx: *mut RawJSContext, value: HandleValue, _option: ())
73 -> Result<ConversionResult<RootedTraceableBox<PromiseRejectionEventInit>>, ()> {
74 PromiseRejectionEventInit::new(SafeJSContext::from_ptr(cx), value, CanGc::note())
75 }
76}
77
78impl PromiseRejectionEventInit {
79 #[allow(clippy::wrong_self_convention)]
80 pub unsafe fn to_jsobject(&self, cx: *mut RawJSContext, mut obj: MutableHandleObject) {
81 self.parent.to_jsobject(cx, obj.reborrow());
82 let promise = &self.promise;
83 rooted!(in(cx) let mut promise_js = UndefinedValue());
84 promise.to_jsval(cx, promise_js.handle_mut());
85 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "promise", promise_js.handle()).unwrap();
86 let reason = &self.reason;
87 rooted!(in(cx) let mut reason_js = UndefinedValue());
88 reason.to_jsval(cx, reason_js.handle_mut());
89 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "reason", reason_js.handle()).unwrap();
90 }
91}
92
93impl ToJSValConvertible for PromiseRejectionEventInit {
94 unsafe fn to_jsval(&self, cx: *mut RawJSContext, mut rval: MutableHandleValue) {
95 rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
96 self.to_jsobject(cx, obj.handle_mut());
97 rval.set(ObjectOrNullValue(obj.get()))
98 }
99}
100
101
102pub use self::PromiseRejectionEvent_Binding::{Wrap, PromiseRejectionEventMethods, GetProtoObject, DefineDOMInterface};
103pub mod PromiseRejectionEvent_Binding {
104use crate::codegen::GenericBindings::EventBinding::Event_Binding;
105use crate::codegen::GenericBindings::EventTargetBinding::EventTarget_Binding;
106use crate::codegen::GenericBindings::PromiseRejectionEventBinding::PromiseRejectionEventInit;
107use crate::codegen::GenericBindings::WorkerGlobalScopeBinding::WorkerGlobalScope_Binding;
108use crate::import::module::*;
109
110unsafe extern "C" fn get_promise<D: DomTypes>
111(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
112 let mut result = false;
113 wrap_panic(&mut || result = (|| {
114 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
115 let this = &*(this as *const D::PromiseRejectionEvent);
116 let result: NonNull<JSObject> = this.Promise(SafeJSContext::from_ptr(cx.raw_cx()));
117
118 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
119 return true;
120 })());
121 result
122}
123
124
125static promise_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
126
127pub(crate) fn init_promise_getterinfo<D: DomTypes>() {
128 promise_getterinfo.set(JSJitInfo {
129 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
130 getter: Some(get_promise::<D>)
131 },
132 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
133 protoID: PrototypeList::ID::PromiseRejectionEvent as u16,
134 },
135 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
136 _bitfield_align_1: [],
137 _bitfield_1: __BindgenBitfieldUnit::new(
138 new_jsjitinfo_bitfield_1!(
139 JSJitInfo_OpType::Getter as u8,
140 JSJitInfo_AliasSet::AliasEverything as u8,
141 JSValueType::JSVAL_TYPE_OBJECT as u8,
142 true,
143 false,
144 false,
145 false,
146 false,
147 false,
148 0,
149 ).to_ne_bytes()
150 ),
151});
152}
153unsafe extern "C" fn get_reason<D: DomTypes>
154(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
155 let mut result = false;
156 wrap_panic(&mut || result = (|| {
157 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
158 let this = &*(this as *const D::PromiseRejectionEvent);
159 rooted!(&in(cx) let mut retval: JSVal);
160 let result: () = this.Reason(SafeJSContext::from_ptr(cx.raw_cx()), retval.handle_mut());
161
162 (retval).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
163 return true;
164 })());
165 result
166}
167
168
169static reason_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
170
171pub(crate) fn init_reason_getterinfo<D: DomTypes>() {
172 reason_getterinfo.set(JSJitInfo {
173 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
174 getter: Some(get_reason::<D>)
175 },
176 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
177 protoID: PrototypeList::ID::PromiseRejectionEvent as u16,
178 },
179 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
180 _bitfield_align_1: [],
181 _bitfield_1: __BindgenBitfieldUnit::new(
182 new_jsjitinfo_bitfield_1!(
183 JSJitInfo_OpType::Getter as u8,
184 JSJitInfo_AliasSet::AliasEverything as u8,
185 JSValueType::JSVAL_TYPE_UNKNOWN as u8,
186 true,
187 false,
188 false,
189 false,
190 false,
191 false,
192 0,
193 ).to_ne_bytes()
194 ),
195});
196}
197unsafe extern "C" fn get_isTrusted<D: DomTypes>
198(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
199 let mut result = false;
200 wrap_panic(&mut || result = (|| {
201 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
202 let this = &*(this as *const D::PromiseRejectionEvent);
203 let result: bool = this.IsTrusted();
204
205 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
206 return true;
207 })());
208 result
209}
210
211
212static isTrusted_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
213
214pub(crate) fn init_isTrusted_getterinfo<D: DomTypes>() {
215 isTrusted_getterinfo.set(JSJitInfo {
216 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
217 getter: Some(get_isTrusted::<D>)
218 },
219 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
220 protoID: PrototypeList::ID::PromiseRejectionEvent as u16,
221 },
222 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
223 _bitfield_align_1: [],
224 _bitfield_1: __BindgenBitfieldUnit::new(
225 new_jsjitinfo_bitfield_1!(
226 JSJitInfo_OpType::Getter as u8,
227 JSJitInfo_AliasSet::AliasEverything as u8,
228 JSValueType::JSVAL_TYPE_BOOLEAN as u8,
229 true,
230 false,
231 false,
232 false,
233 false,
234 false,
235 0,
236 ).to_ne_bytes()
237 ),
238});
239}
240unsafe extern "C" fn _finalize<D: DomTypes>
241(_cx: *mut GCContext, obj: *mut JSObject){
242 wrap_panic(&mut || {
243
244 let this = native_from_object_static::<D::PromiseRejectionEvent>(obj).unwrap();
245 finalize_common(this);
246 })
247}
248
249unsafe extern "C" fn _trace<D: DomTypes>
250(trc: *mut JSTracer, obj: *mut JSObject){
251 wrap_panic(&mut || {
252
253 let this = native_from_object_static::<D::PromiseRejectionEvent>(obj).unwrap();
254 if this.is_null() { return; } (*this).trace(trc);
256 })
257}
258
259
260static CLASS_OPS: ThreadUnsafeOnceLock<JSClassOps> = ThreadUnsafeOnceLock::new();
261
262pub(crate) fn init_class_ops<D: DomTypes>() {
263 CLASS_OPS.set(JSClassOps {
264 addProperty: None,
265 delProperty: None,
266 enumerate: None,
267 newEnumerate: None,
268 resolve: None,
269 mayResolve: None,
270 finalize: Some(_finalize::<D>),
271 call: None,
272 construct: None,
273 trace: Some(_trace::<D>),
274 });
275}
276
277pub static Class: ThreadUnsafeOnceLock<DOMJSClass> = ThreadUnsafeOnceLock::new();
278
279pub(crate) fn init_domjs_class<D: DomTypes>() {
280 init_class_ops::<D>();
281 Class.set(DOMJSClass {
282 base: JSClass {
283 name: c"PromiseRejectionEvent".as_ptr(),
284 flags: JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE |
285 (((1) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT)
286 ,
287 cOps: unsafe { CLASS_OPS.get() },
288 spec: ptr::null(),
289 ext: ptr::null(),
290 oOps: ptr::null(),
291 },
292 dom_class:
293DOMClass {
294 interface_chain: [ PrototypeList::ID::Event, PrototypeList::ID::PromiseRejectionEvent, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last ],
295 depth: 1,
296 type_id: crate::codegen::InheritTypes::TopTypeId { event: (crate::codegen::InheritTypes::EventTypeId::PromiseRejectionEvent) },
297 malloc_size_of: malloc_size_of_including_raw_self::<D::PromiseRejectionEvent> as unsafe fn(&mut _, _) -> _,
298 global: Globals::EMPTY,
299},
300 });
301}
302
303#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub unsafe fn Wrap<D: DomTypes>
304(cx: SafeJSContext, scope: &D::GlobalScope, given_proto: Option<HandleObject>, object: Box<D::PromiseRejectionEvent>, _can_gc: CanGc) -> DomRoot<D::PromiseRejectionEvent>{
305
306 let raw = Root::new(MaybeUnreflectedDom::from_box(object));
307
308 let scope = scope.reflector().get_jsobject();
309 assert!(!scope.get().is_null());
310 assert!(((*get_object_class(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0);
311 let _ac = JSAutoRealm::new(cx.raw_cx(), scope.get());
312
313 rooted!(&in(cx) let mut canonical_proto = ptr::null_mut::<JSObject>());
314 GetProtoObject::<D>(cx, scope, canonical_proto.handle_mut());
315 assert!(!canonical_proto.is_null());
316
317
318 rooted!(&in(cx) let mut proto = ptr::null_mut::<JSObject>());
319 if let Some(given) = given_proto {
320 proto.set(*given);
321 if get_context_realm(cx.raw_cx()) != get_object_realm(*given) {
322 assert!(JS_WrapObject(cx.raw_cx(), proto.handle_mut()));
323 }
324 } else {
325 proto.set(*canonical_proto);
326 }
327 rooted!(&in(cx) let obj = JS_NewObjectWithGivenProto(
328 cx.raw_cx(),
329 &Class.get().base,
330 proto.handle(),
331 ));
332 assert!(!obj.is_null());
333 JS_SetReservedSlot(
334 obj.get(),
335 DOM_OBJECT_SLOT,
336 &PrivateValue(raw.as_ptr() as *const libc::c_void),
337 );
338
339 let root = raw.reflect_with(obj.get());
340
341
342 let mut slot = UndefinedValue();
343 JS_GetReservedSlot(canonical_proto.get(), DOM_PROTO_UNFORGEABLE_HOLDER_SLOT, &mut slot);
344 rooted!(&in(cx) let mut unforgeable_holder = ptr::null_mut::<JSObject>());
345 unforgeable_holder.handle_mut().set(slot.to_object());
346 assert!(JS_InitializePropertiesFromCompatibleNativeObject(cx.raw_cx(), obj.handle(), unforgeable_holder.handle()));
347
348
349 DomRoot::from_ref(&*root)
350}
351
352pub trait PromiseRejectionEventMethods<D: DomTypes> {
353 fn Promise(&self, r#cx: SafeJSContext) -> NonNull<JSObject>;
354 fn Reason(&self, r#cx: SafeJSContext, r#retval: MutableHandleValue);
355 fn IsTrusted(&self, ) -> bool;
356 fn Constructor(r#global: &D::GlobalScope, r#proto: Option<HandleObject>, r#can_gc: CanGc, r#type_: DOMString, r#eventInitDict: RootedTraceableBox<crate::codegen::GenericBindings::PromiseRejectionEventBinding::PromiseRejectionEventInit>) -> Fallible<DomRoot<D::PromiseRejectionEvent>>;
357}
358static sAttributes_specs: ThreadUnsafeOnceLock<&[&[JSPropertySpec]]> = ThreadUnsafeOnceLock::new();
359
360pub(crate) fn init_sAttributes_specs<D: DomTypes>() {
361 sAttributes_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
362 JSPropertySpec {
363 name: JSPropertySpec_Name { string_: c"promise".as_ptr() },
364 attributes_: (JSPROP_ENUMERATE),
365 kind_: (JSPropertySpec_Kind::NativeAccessor),
366 u: JSPropertySpec_AccessorsOrValue {
367 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
368 getter: JSPropertySpec_Accessor {
369 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { promise_getterinfo.get() } },
370 },
371 setter: JSPropertySpec_Accessor {
372 native: JSNativeWrapper { op: None, info: ptr::null() },
373 }
374 }
375 }
376 }
377,
378 JSPropertySpec {
379 name: JSPropertySpec_Name { string_: c"reason".as_ptr() },
380 attributes_: (JSPROP_ENUMERATE),
381 kind_: (JSPropertySpec_Kind::NativeAccessor),
382 u: JSPropertySpec_AccessorsOrValue {
383 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
384 getter: JSPropertySpec_Accessor {
385 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { reason_getterinfo.get() } },
386 },
387 setter: JSPropertySpec_Accessor {
388 native: JSNativeWrapper { op: None, info: ptr::null() },
389 }
390 }
391 }
392 }
393,
394 JSPropertySpec::ZERO]))[..]
395,
396&Box::leak(Box::new([
397 JSPropertySpec {
398 name: JSPropertySpec_Name { symbol_: SymbolCode::toStringTag as usize + 1 },
399 attributes_: (JSPROP_READONLY),
400 kind_: (JSPropertySpec_Kind::Value),
401 u: JSPropertySpec_AccessorsOrValue {
402 value: JSPropertySpec_ValueWrapper {
403 type_: JSPropertySpec_ValueWrapper_Type::String,
404 __bindgen_anon_1: JSPropertySpec_ValueWrapper__bindgen_ty_1 {
405 string: c"PromiseRejectionEvent".as_ptr(),
406 }
407 }
408 }
409 }
410,
411 JSPropertySpec::ZERO]))[..]
412])));
413}static sAttributes: ThreadUnsafeOnceLock<&[Guard<&[JSPropertySpec]>]> = ThreadUnsafeOnceLock::new();
414
415pub(crate) fn init_sAttributes_prefs<D: DomTypes>() {
416 sAttributes.set(Box::leak(Box::new([ Guard::new(&[Condition::Exposed(Globals::WINDOW),Condition::Exposed(Globals::SERVICE_WORKER_GLOBAL_SCOPE),Condition::Exposed(Globals::DEDICATED_WORKER_GLOBAL_SCOPE)], (unsafe { sAttributes_specs.get() })[0]),
417 Guard::new(&[Condition::Satisfied], (unsafe { sAttributes_specs.get() })[1])])));
418}static sLegacyUnforgeableAttributes_specs: ThreadUnsafeOnceLock<&[&[JSPropertySpec]]> = ThreadUnsafeOnceLock::new();
419
420pub(crate) fn init_sLegacyUnforgeableAttributes_specs<D: DomTypes>() {
421 sLegacyUnforgeableAttributes_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
422 JSPropertySpec {
423 name: JSPropertySpec_Name { string_: c"isTrusted".as_ptr() },
424 attributes_: (JSPROP_ENUMERATE | JSPROP_PERMANENT),
425 kind_: (JSPropertySpec_Kind::NativeAccessor),
426 u: JSPropertySpec_AccessorsOrValue {
427 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
428 getter: JSPropertySpec_Accessor {
429 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { isTrusted_getterinfo.get() } },
430 },
431 setter: JSPropertySpec_Accessor {
432 native: JSNativeWrapper { op: None, info: ptr::null() },
433 }
434 }
435 }
436 }
437,
438 JSPropertySpec::ZERO]))[..]
439])));
440}static sLegacyUnforgeableAttributes: ThreadUnsafeOnceLock<&[Guard<&[JSPropertySpec]>]> = ThreadUnsafeOnceLock::new();
441
442pub(crate) fn init_sLegacyUnforgeableAttributes_prefs<D: DomTypes>() {
443 sLegacyUnforgeableAttributes.set(Box::leak(Box::new([ Guard::new(&[Condition::Exposed(Globals::WINDOW),Condition::Exposed(Globals::SERVICE_WORKER_GLOBAL_SCOPE),Condition::Exposed(Globals::PAINT_WORKLET_GLOBAL_SCOPE),Condition::Exposed(Globals::DEDICATED_WORKER_GLOBAL_SCOPE),Condition::Exposed(Globals::DEBUGGER_GLOBAL_SCOPE),Condition::Exposed(Globals::DISSIMILAR_ORIGIN_WINDOW),Condition::Exposed(Globals::TEST_WORKLET_GLOBAL_SCOPE)], (unsafe { sLegacyUnforgeableAttributes_specs.get() })[0])])));
444}
445pub fn GetProtoObject<D: DomTypes>
446(cx: SafeJSContext, global: HandleObject, mut rval: MutableHandleObject){
447 get_per_interface_object_handle(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::PromiseRejectionEvent), CreateInterfaceObjects::<D>, rval)
449}
450
451
452static PrototypeClass: JSClass = JSClass {
453 name: c"PromiseRejectionEventPrototype".as_ptr(),
454 flags:
455 (1 & JSCLASS_RESERVED_SLOTS_MASK ) << JSCLASS_RESERVED_SLOTS_SHIFT,
457 cOps: ptr::null(),
458 spec: ptr::null(),
459 ext: ptr::null(),
460 oOps: ptr::null(),
461};
462
463unsafe extern "C" fn _constructor<D: DomTypes>
464(cx: *mut RawJSContext, argc: u32, vp: *mut JSVal) -> bool{
465 let mut result = false;
466 wrap_panic(&mut || result = {
467 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
468 let args = CallArgs::from_vp(vp, argc);
469 let global = D::GlobalScope::from_object(JS_CALLEE(cx.raw_cx(), vp).to_object());
470
471 call_default_constructor::<D>(
472 SafeJSContext::from_ptr(cx.raw_cx()),
473 &args,
474 &global,
475 PrototypeList::ID::PromiseRejectionEvent,
476 "PromiseRejectionEvent",
477 CreateInterfaceObjects::<D>,
478 |cx: SafeJSContext, args: &CallArgs, global: &D::GlobalScope, desired_proto: HandleObject| {
479
480 if argc < 2 {
481 throw_type_error(cx.raw_cx(), "Not enough arguments to \"PromiseRejectionEvent.constructor\".");
482 return false;
483 }
484 let arg0: DOMString = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), StringificationBehavior::Default) {
485 Ok(ConversionResult::Success(value)) => value,
486 Ok(ConversionResult::Failure(error)) => {
487 throw_type_error(cx.raw_cx(), &error);
488 return false;
489
490 }
491 _ => {
492 return false;
493
494 },
495 }
496 ;
497 let arg1: RootedTraceableBox<crate::codegen::GenericBindings::PromiseRejectionEventBinding::PromiseRejectionEventInit> = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(1)), ()) {
498 Ok(ConversionResult::Success(value)) => value,
499 Ok(ConversionResult::Failure(error)) => {
500 throw_type_error(cx.raw_cx(), &error);
501 return false;
502
503 }
504 _ => {
505 return false;
506
507 },
508 }
509 ;
510 let result: Result<DomRoot<D::PromiseRejectionEvent>, Error> = <D::PromiseRejectionEvent>::Constructor(global, Some(desired_proto), CanGc::note(), arg0, arg1);
511 let result = match result {
512 Ok(result) => result,
513 Err(e) => {
514 <D as DomHelpers<D>>::throw_dom_exception(SafeJSContext::from_ptr(cx.raw_cx()), global.upcast::<D::GlobalScope>(), e, CanGc::note());
515 return false;
516 },
517 };
518
519 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
520 return true;
521 }
522 )
523
524 });
525 result
526}
527
528
529static INTERFACE_OBJECT_CLASS: ThreadUnsafeOnceLock<NonCallbackInterfaceObjectClass> = ThreadUnsafeOnceLock::new();
530
531pub(crate) fn init_interface_object<D: DomTypes>() {
532 INTERFACE_OBJECT_CLASS.set(NonCallbackInterfaceObjectClass::new(
533 Box::leak(Box::new(InterfaceConstructorBehavior::call(_constructor::<D>))),
534 b"function PromiseRejectionEvent() {\n [native code]\n}",
535 PrototypeList::ID::PromiseRejectionEvent,
536 1,
537 ));
538}
539
540pub fn DefineDOMInterface<D: DomTypes>
541(cx: SafeJSContext, global: HandleObject){
542 define_dom_interface(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::PromiseRejectionEvent),CreateInterfaceObjects::<D>, ConstructorEnabled::<D>)
543}
544
545pub fn ConstructorEnabled<D: DomTypes>
546(aCx: SafeJSContext, aObj: HandleObject) -> bool{
547 is_exposed_in(aObj, Globals::DEDICATED_WORKER_GLOBAL_SCOPE | Globals::SERVICE_WORKER_GLOBAL_SCOPE | Globals::WINDOW)
548}
549
550unsafe fn CreateInterfaceObjects<D: DomTypes>
551(cx: SafeJSContext, global: HandleObject, cache: *mut ProtoOrIfaceArray){
552
553 rooted!(&in(cx) let mut prototype_proto = ptr::null_mut::<JSObject>());
554 Event_Binding::GetProtoObject::<D>(cx, global, prototype_proto.handle_mut());
555 assert!(!prototype_proto.is_null());
556
557 rooted!(&in(cx) let mut prototype = ptr::null_mut::<JSObject>());
558 create_interface_prototype_object::<D>(cx,
559 global,
560 prototype_proto.handle(),
561 &PrototypeClass,
562 &[],
563 sAttributes.get(),
564 &[],
565 &[],
566 prototype.handle_mut());
567 assert!(!prototype.is_null());
568 assert!((*cache)[PrototypeList::ID::PromiseRejectionEvent as usize].is_null());
569 (*cache)[PrototypeList::ID::PromiseRejectionEvent as usize] = prototype.get();
570 <*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::PromiseRejectionEvent as isize),
571 ptr::null_mut(),
572 prototype.get());
573
574 rooted!(&in(cx) let mut interface_proto = ptr::null_mut::<JSObject>());
575
576 Event_Binding::GetConstructorObject::<D>(cx, global, interface_proto.handle_mut());
577
578 assert!(!interface_proto.is_null());
579
580 rooted!(&in(cx) let mut interface = ptr::null_mut::<JSObject>());
581 create_noncallback_interface_object::<D>(cx,
582 global,
583 interface_proto.handle(),
584 INTERFACE_OBJECT_CLASS.get(),
585 &[],
586 &[],
587 &[],
588 prototype.handle(),
589 c"PromiseRejectionEvent",
590 2,
591 &[],
592 interface.handle_mut());
593 assert!(!interface.is_null());
594
595 rooted!(&in(cx) let mut unforgeable_holder = ptr::null_mut::<JSObject>());
596 unforgeable_holder.handle_mut().set(
597 JS_NewObjectWithoutMetadata(cx.raw_cx(), &Class.get().base as *const JSClass, prototype.handle()));
598 assert!(!unforgeable_holder.is_null());
599
600 define_guarded_properties::<D>(cx, unforgeable_holder.handle(), unsafe { sLegacyUnforgeableAttributes.get() }, global);
601 let val = ObjectValue(unforgeable_holder.get());
602 JS_SetReservedSlot(prototype.get(), DOM_PROTO_UNFORGEABLE_HOLDER_SLOT, &val)
603}
604
605
606 pub(crate) fn init_statics<D: DomTypes>() {
607 init_interface_object::<D>();
608 init_domjs_class::<D>();
609
610 init_promise_getterinfo::<D>();
611init_reason_getterinfo::<D>();
612init_isTrusted_getterinfo::<D>();
613
614
615 init_sAttributes_specs::<D>();
616init_sAttributes_prefs::<D>();
617init_sLegacyUnforgeableAttributes_specs::<D>();
618init_sLegacyUnforgeableAttributes_prefs::<D>();
619 }
620 }