1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */

#![allow(non_camel_case_types,non_upper_case_globals,unused_imports,unused_variables,unused_assignments,unused_mut,clippy::approx_constant,clippy::let_unit_value,clippy::needless_return,clippy::too_many_arguments,clippy::unnecessary_cast,clippy::upper_case_acronyms)]

use crate::dom::bindings::import::base::*;

pub use self::TestBindingProxy_Binding::{Wrap, TestBindingProxyMethods, GetProtoObject, DefineDOMInterface};
pub mod TestBindingProxy_Binding {
use crate::dom;
use crate::dom::bindings::codegen::Bindings::TestBindingBinding::TestBinding_Binding;
use crate::dom::bindings::import::module::*;
use crate::dom::types::TestBinding;
use crate::dom::types::TestBindingProxy;

unsafe extern fn get_length(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool {
    let mut result = false;
    wrap_panic(&mut || result = (|| {
        let cx = SafeJSContext::from_ptr(cx);
        let this = &*(this as *const TestBindingProxy);
        let result: u32 = this.Length();

        (result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
        return true;
    })());
    result
}


const length_getterinfo: JSJitInfo = JSJitInfo {
    __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
        getter: Some(get_length)
    },
    __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
        protoID: PrototypeList::ID::TestBindingProxy as u16,
    },
    __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
    _bitfield_align_1: [],
    _bitfield_1: __BindgenBitfieldUnit::new(
        new_jsjitinfo_bitfield_1!(
            JSJitInfo_OpType::Getter as u8,
            JSJitInfo_AliasSet::AliasEverything as u8,
            JSValueType::JSVAL_TYPE_DOUBLE as u8,
            true,
            false,
            false,
            false,
            false,
            false,
            0,
        ).to_ne_bytes()
    ),
};

unsafe extern fn getNamedItem(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool {
    let mut result = false;
    wrap_panic(&mut || result = (|| {
        let cx = SafeJSContext::from_ptr(cx);
        let this = &*(this as *const TestBindingProxy);
        let args = &*args;
        let argc = args.argc_;

        if argc < 1 {
            throw_type_error(*cx, "Not enough arguments to \"TestBindingProxy.getNamedItem\".");
            return false;
        }
        let arg0: DOMString = match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(0)), StringificationBehavior::Default) {
            Ok(ConversionResult::Success(strval)) => strval,
            Ok(ConversionResult::Failure(error)) => {
                throw_type_error(*cx, &error);
                return false;

            }
            _ => { return false;
         },
        };
        let result: DOMString = this.GetNamedItem(arg0);

        (result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
        return true;
    })());
    result
}


const getNamedItem_methodinfo: JSJitInfo = JSJitInfo {
    __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
        method: Some(getNamedItem)
    },
    __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
        protoID: PrototypeList::ID::TestBindingProxy as u16,
    },
    __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
    _bitfield_align_1: [],
    _bitfield_1: __BindgenBitfieldUnit::new(
        new_jsjitinfo_bitfield_1!(
            JSJitInfo_OpType::Method as u8,
            JSJitInfo_AliasSet::AliasEverything as u8,
            JSValueType::JSVAL_TYPE_STRING as u8,
            false,
            false,
            false,
            false,
            false,
            false,
            0,
        ).to_ne_bytes()
    ),
};

unsafe extern fn setNamedItem(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool {
    let mut result = false;
    wrap_panic(&mut || result = (|| {
        let cx = SafeJSContext::from_ptr(cx);
        let this = &*(this as *const TestBindingProxy);
        let args = &*args;
        let argc = args.argc_;

        if argc < 2 {
            throw_type_error(*cx, "Not enough arguments to \"TestBindingProxy.setNamedItem\".");
            return false;
        }
        let arg0: DOMString = match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(0)), StringificationBehavior::Default) {
            Ok(ConversionResult::Success(strval)) => strval,
            Ok(ConversionResult::Failure(error)) => {
                throw_type_error(*cx, &error);
                return false;

            }
            _ => { return false;
         },
        };
        let arg1: DOMString = match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(1)), StringificationBehavior::Default) {
            Ok(ConversionResult::Success(strval)) => strval,
            Ok(ConversionResult::Failure(error)) => {
                throw_type_error(*cx, &error);
                return false;

            }
            _ => { return false;
         },
        };
        let result: () = this.SetNamedItem(arg0, arg1);

        (result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
        return true;
    })());
    result
}


const setNamedItem_methodinfo: JSJitInfo = JSJitInfo {
    __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
        method: Some(setNamedItem)
    },
    __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
        protoID: PrototypeList::ID::TestBindingProxy as u16,
    },
    __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
    _bitfield_align_1: [],
    _bitfield_1: __BindgenBitfieldUnit::new(
        new_jsjitinfo_bitfield_1!(
            JSJitInfo_OpType::Method as u8,
            JSJitInfo_AliasSet::AliasEverything as u8,
            JSValueType::JSVAL_TYPE_UNDEFINED as u8,
            false,
            false,
            false,
            false,
            false,
            false,
            0,
        ).to_ne_bytes()
    ),
};

unsafe extern fn getItem(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool {
    let mut result = false;
    wrap_panic(&mut || result = (|| {
        let cx = SafeJSContext::from_ptr(cx);
        let this = &*(this as *const TestBindingProxy);
        let args = &*args;
        let argc = args.argc_;

        if argc < 1 {
            throw_type_error(*cx, "Not enough arguments to \"TestBindingProxy.getItem\".");
            return false;
        }
        let arg0: u32 = match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(0)), ConversionBehavior::Default) {
            Ok(ConversionResult::Success(v)) => v,
            Ok(ConversionResult::Failure(error)) => {
                throw_type_error(*cx, &error);
                return false;

            }
            _ => { return false;
         }
        };
        let result: DOMString = this.GetItem(arg0);

        (result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
        return true;
    })());
    result
}


const getItem_methodinfo: JSJitInfo = JSJitInfo {
    __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
        method: Some(getItem)
    },
    __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
        protoID: PrototypeList::ID::TestBindingProxy as u16,
    },
    __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
    _bitfield_align_1: [],
    _bitfield_1: __BindgenBitfieldUnit::new(
        new_jsjitinfo_bitfield_1!(
            JSJitInfo_OpType::Method as u8,
            JSJitInfo_AliasSet::AliasEverything as u8,
            JSValueType::JSVAL_TYPE_STRING as u8,
            false,
            false,
            false,
            false,
            false,
            false,
            0,
        ).to_ne_bytes()
    ),
};

unsafe extern fn setItem(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool {
    let mut result = false;
    wrap_panic(&mut || result = (|| {
        let cx = SafeJSContext::from_ptr(cx);
        let this = &*(this as *const TestBindingProxy);
        let args = &*args;
        let argc = args.argc_;

        if argc < 2 {
            throw_type_error(*cx, "Not enough arguments to \"TestBindingProxy.setItem\".");
            return false;
        }
        let arg0: u32 = match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(0)), ConversionBehavior::Default) {
            Ok(ConversionResult::Success(v)) => v,
            Ok(ConversionResult::Failure(error)) => {
                throw_type_error(*cx, &error);
                return false;

            }
            _ => { return false;
         }
        };
        let arg1: DOMString = match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(1)), StringificationBehavior::Default) {
            Ok(ConversionResult::Success(strval)) => strval,
            Ok(ConversionResult::Failure(error)) => {
                throw_type_error(*cx, &error);
                return false;

            }
            _ => { return false;
         },
        };
        let result: () = this.SetItem(arg0, arg1);

        (result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
        return true;
    })());
    result
}


const setItem_methodinfo: JSJitInfo = JSJitInfo {
    __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
        method: Some(setItem)
    },
    __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
        protoID: PrototypeList::ID::TestBindingProxy as u16,
    },
    __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
    _bitfield_align_1: [],
    _bitfield_1: __BindgenBitfieldUnit::new(
        new_jsjitinfo_bitfield_1!(
            JSJitInfo_OpType::Method as u8,
            JSJitInfo_AliasSet::AliasEverything as u8,
            JSValueType::JSVAL_TYPE_UNDEFINED as u8,
            false,
            false,
            false,
            false,
            false,
            false,
            0,
        ).to_ne_bytes()
    ),
};

unsafe extern fn removeItem(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool {
    let mut result = false;
    wrap_panic(&mut || result = (|| {
        let cx = SafeJSContext::from_ptr(cx);
        let this = &*(this as *const TestBindingProxy);
        let args = &*args;
        let argc = args.argc_;

        if argc < 1 {
            throw_type_error(*cx, "Not enough arguments to \"TestBindingProxy.removeItem\".");
            return false;
        }
        let arg0: DOMString = match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(0)), StringificationBehavior::Default) {
            Ok(ConversionResult::Success(strval)) => strval,
            Ok(ConversionResult::Failure(error)) => {
                throw_type_error(*cx, &error);
                return false;

            }
            _ => { return false;
         },
        };
        let result: () = this.RemoveItem(arg0);

        (result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
        return true;
    })());
    result
}


const removeItem_methodinfo: JSJitInfo = JSJitInfo {
    __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
        method: Some(removeItem)
    },
    __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
        protoID: PrototypeList::ID::TestBindingProxy as u16,
    },
    __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
    _bitfield_align_1: [],
    _bitfield_1: __BindgenBitfieldUnit::new(
        new_jsjitinfo_bitfield_1!(
            JSJitInfo_OpType::Method as u8,
            JSJitInfo_AliasSet::AliasEverything as u8,
            JSValueType::JSVAL_TYPE_UNDEFINED as u8,
            false,
            false,
            false,
            false,
            false,
            false,
            0,
        ).to_ne_bytes()
    ),
};

unsafe extern fn __stringifier(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool {
    let mut result = false;
    wrap_panic(&mut || result = (|| {
        let cx = SafeJSContext::from_ptr(cx);
        let this = &*(this as *const TestBindingProxy);
        let args = &*args;
        let argc = args.argc_;
        let result: DOMString = this.Stringifier();

        (result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
        return true;
    })());
    result
}


const __stringifier_methodinfo: JSJitInfo = JSJitInfo {
    __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
        method: Some(__stringifier)
    },
    __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
        protoID: PrototypeList::ID::TestBindingProxy as u16,
    },
    __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
    _bitfield_align_1: [],
    _bitfield_1: __BindgenBitfieldUnit::new(
        new_jsjitinfo_bitfield_1!(
            JSJitInfo_OpType::Method as u8,
            JSJitInfo_AliasSet::AliasEverything as u8,
            JSValueType::JSVAL_TYPE_STRING as u8,
            true,
            false,
            false,
            false,
            false,
            false,
            0,
        ).to_ne_bytes()
    ),
};

unsafe extern fn _finalize(_cx: *mut GCContext, obj: *mut JSObject) {
    wrap_panic(&mut || {

        let this = native_from_object_static::<TestBindingProxy>(obj).unwrap();
        finalize_common(this);
    })
}

unsafe extern fn _trace(trc: *mut JSTracer, obj: *mut JSObject) {
    wrap_panic(&mut || {

        let this = native_from_object_static::<TestBindingProxy>(obj).unwrap();
        if this.is_null() { return; } // GC during obj creation
        (*this).trace(trc);
    })
}

pub unsafe fn DefineProxyHandler() -> *const libc::c_void {
    let traps = ProxyTraps {
        enter: None,
        getOwnPropertyDescriptor: Some(getOwnPropertyDescriptor),
        defineProperty: Some(defineProperty),
        ownPropertyKeys: Some(own_property_keys),
        delete_: Some(delete),
        enumerate: None,
        getPrototypeIfOrdinary: Some(proxyhandler::get_prototype_if_ordinary),
        getPrototype: None,
        setPrototype: None,
        setImmutablePrototype: None,
        preventExtensions: Some(proxyhandler::prevent_extensions),
        isExtensible: Some(proxyhandler::is_extensible),
        has: None,
        get: Some(get),
        set: None,
        call: None,
        construct: None,
        hasOwn: Some(hasOwn),
        getOwnEnumerablePropertyKeys: Some(own_property_keys),
        nativeCall: None,
        objectClassIs: None,
        className: Some(className),
        fun_toString: None,
        boxedValue_unbox: None,
        defaultValue: None,
        trace: Some(_trace),
        finalize: Some(_finalize),
        objectMoved: None,
        isCallable: None,
        isConstructor: None,
    };

    CreateProxyHandler(&traps, Class.as_void_ptr())
}

#[inline] unsafe fn UnwrapProxy(obj: RawHandleObject) -> *const TestBindingProxy {
            let mut slot = UndefinedValue();
            GetProxyReservedSlot(obj.get(), 0, &mut slot);
            let box_ = slot.to_private() as *const TestBindingProxy;
    return box_;
}

static Class: DOMClass = DOMClass {
    interface_chain: [ PrototypeList::ID::TestBinding, PrototypeList::ID::TestBindingProxy, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last ],
    depth: 1,
    type_id: crate::dom::bindings::codegen::InheritTypes::TopTypeId { testbinding: (crate::dom::bindings::codegen::InheritTypes::TestBindingTypeId::TestBindingProxy) },
    malloc_size_of: malloc_size_of_including_raw_self::<TestBindingProxy> as unsafe fn(&mut _, _) -> _,
    global: InterfaceObjectMap::Globals::EMPTY,
};

unsafe extern fn own_property_keys(cx: *mut JSContext, proxy: RawHandleObject, props: RawMutableHandleIdVector) -> bool {
    let mut result = false;
    wrap_panic(&mut || result = (|| {
        let cx = SafeJSContext::from_ptr(cx);
        let unwrapped_proxy = UnwrapProxy(proxy);
        for i in 0..(*unwrapped_proxy).Length() {
            rooted!(in(*cx) let mut rooted_jsid: jsid);
            int_to_jsid(i as i32, rooted_jsid.handle_mut());
            AppendToIdVector(props, rooted_jsid.handle());
        }
        for name in (*unwrapped_proxy).SupportedPropertyNames() {
            let cstring = CString::new(name).unwrap();
            let jsstring = JS_AtomizeAndPinString(*cx, cstring.as_ptr());
            rooted!(in(*cx) let rooted = jsstring);
            rooted!(in(*cx) let mut rooted_jsid: jsid);
            RUST_INTERNED_STRING_TO_JSID(*cx, rooted.handle().get(), rooted_jsid.handle_mut());
            AppendToIdVector(props, rooted_jsid.handle());
        }
        rooted!(in(*cx) let mut expando = ptr::null_mut::<JSObject>());
        get_expando_object(proxy, expando.handle_mut());
        if !expando.is_null() &&
            !GetPropertyKeys(*cx, expando.handle(), JSITER_OWNONLY | JSITER_HIDDEN | JSITER_SYMBOLS, props) {
            return false;
        }

        true

    })());
    result
}

unsafe extern fn getOwnPropertyDescriptor(cx: *mut JSContext, proxy: RawHandleObject, id: RawHandleId, mut desc: RawMutableHandle<PropertyDescriptor>, is_none: *mut bool) -> bool {
    let mut result = false;
    wrap_panic(&mut || result = (|| {
        let cx = SafeJSContext::from_ptr(cx);
        let index = get_array_index_from_id(*cx, Handle::from_raw(id));
        if let Some(index) = index {
            let this = UnwrapProxy(proxy);
            let this = &*this;
            let result: Option<DOMString> = this.IndexedGetter(index);

            if let Some(result) = result {
                rooted!(in(*cx) let mut rval = UndefinedValue());
                (result).to_jsval(*cx, rval.handle_mut());
                set_property_descriptor(
                    MutableHandle::from_raw(desc),
                    rval.handle(),
                    (JSPROP_ENUMERATE) as u32,
                    &mut *is_none
                );
                return true;
            }
        }
        rooted!(in(*cx) let mut expando = ptr::null_mut::<JSObject>());
        get_expando_object(proxy, expando.handle_mut());
        //if (!xpc::WrapperFactory::IsXrayWrapper(proxy) && (expando = GetExpandoObject(proxy))) {
        let proxy_lt = Handle::from_raw(proxy);
        let id_lt = Handle::from_raw(id);
        if !expando.is_null() {
            rooted!(in(*cx) let mut ignored = ptr::null_mut::<JSObject>());
            if !JS_GetPropertyDescriptorById(*cx, expando.handle().into(), id, desc, ignored.handle_mut().into(), is_none) {
                return false;
            }
            if !*is_none {
                // Pretend the property lives on the wrapper.
                return true;
            }
        }

        if index.is_none() && (id.is_string() || id.is_int()) {
            let mut has_on_proto = false;
            if !has_property_on_prototype(*cx, proxy_lt, id_lt, &mut has_on_proto) {
                return false;
            }
            if !has_on_proto {
                        let item_name = jsid_to_string(*cx, Handle::from_raw(id)).expect("Not a string-convertible JSID?");
                let this = UnwrapProxy(proxy);
                let this = &*this;
                let result: Option<DOMString> = this.NamedGetter(item_name);

                if let Some(result) = result {
                    rooted!(in(*cx) let mut rval = UndefinedValue());
                    (result).to_jsval(*cx, rval.handle_mut());
                    set_property_descriptor(
                        MutableHandle::from_raw(desc),
                        rval.handle(),
                        (JSPROP_ENUMERATE) as u32,
                        &mut *is_none
                    );
                    return true;
                }
            }
        }
        true
    })());
    result
}

unsafe extern fn className(cx: *mut JSContext, _proxy: RawHandleObject) -> *const libc::c_char {
    b"TestBindingProxy\0" as *const u8 as *const libc::c_char
}

unsafe extern fn get(cx: *mut JSContext, proxy: RawHandleObject, receiver: RawHandleValue, id: RawHandleId, vp: RawMutableHandleValue) -> bool {
    let mut result = false;
    wrap_panic(&mut || result = (|| {
        //MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
        //"Should not have a XrayWrapper here");
        let cx = SafeJSContext::from_ptr(cx);



        let proxy_lt = Handle::from_raw(proxy);
        let vp_lt = MutableHandle::from_raw(vp);
        let id_lt = Handle::from_raw(id);
        let receiver_lt = Handle::from_raw(receiver);

        let index = get_array_index_from_id(*cx, id_lt);
        if let Some(index) = index {
            let this = UnwrapProxy(proxy);
            let this = &*this;
            let result: Option<DOMString> = this.IndexedGetter(index);

            if let Some(result) = result {

                (result).to_jsval(*cx, vp_lt);
                return true;
            }    // Even if we don't have this index, we don't forward the
            // get on to our expando object.
        } else {
            rooted!(in(*cx) let mut expando = ptr::null_mut::<JSObject>());
            get_expando_object(proxy, expando.handle_mut());
            if !expando.is_null() {
                let mut hasProp = false;
                if !JS_HasPropertyById(*cx, expando.handle().into(), id, &mut hasProp) {
                    return false;
                }

                if hasProp {
                    return JS_ForwardGetPropertyTo(*cx, expando.handle().into(), id, receiver, vp);
                }
            }
        }

        let mut found = false;
        if !get_property_on_prototype(*cx, proxy_lt, receiver_lt, id_lt, &mut found, vp_lt) {
            return false;
        }

        if found {
            return true;
        }
        if index.is_none() && (id.is_string() || id.is_int()) {
            let item_name = jsid_to_string(*cx, Handle::from_raw(id)).expect("Not a string-convertible JSID?");
            let this = UnwrapProxy(proxy);
            let this = &*this;
            let result: Option<DOMString> = this.NamedGetter(item_name);

            if let Some(result) = result {

                (result).to_jsval(*cx, vp_lt);
                return true;
            }}

        vp.set(UndefinedValue());
        true
    })());
    result
}

unsafe extern fn hasOwn(cx: *mut JSContext, proxy: RawHandleObject, id: RawHandleId, bp: *mut bool) -> bool {
    let mut result = false;
    wrap_panic(&mut || result = (|| {
        let cx = SafeJSContext::from_ptr(cx);
        let index = get_array_index_from_id(*cx, Handle::from_raw(id));
        if let Some(index) = index {
            let this = UnwrapProxy(proxy);
            let this = &*this;
            let result: Option<DOMString> = this.IndexedGetter(index);

            *bp = result.is_some();
            return true;
        }

        rooted!(in(*cx) let mut expando = ptr::null_mut::<JSObject>());
        let proxy_lt = Handle::from_raw(proxy);
        let id_lt = Handle::from_raw(id);
        get_expando_object(proxy, expando.handle_mut());
        if !expando.is_null() {
            let ok = JS_HasPropertyById(*cx, expando.handle().into(), id, bp);
            if !ok || *bp {
                return ok;
            }
        }
        if index.is_none() && (id.is_string() || id.is_int()) {
            let mut has_on_proto = false;
            if !has_property_on_prototype(*cx, proxy_lt, id_lt, &mut has_on_proto) {
                return false;
            }
            if !has_on_proto {
                        let item_name = jsid_to_string(*cx, Handle::from_raw(id)).expect("Not a string-convertible JSID?");
                let this = UnwrapProxy(proxy);
                let this = &*this;
                let result: Option<DOMString> = this.NamedGetter(item_name);

                *bp = result.is_some();
                return true;
            }
        }

        *bp = false;
        true
    })());
    result
}

unsafe extern fn defineProperty(cx: *mut JSContext, proxy: RawHandleObject, id: RawHandleId, desc: RawHandle<PropertyDescriptor>, opresult: *mut ObjectOpResult) -> bool {
    let mut result = false;
    wrap_panic(&mut || result = (|| {
        let cx = SafeJSContext::from_ptr(cx);
        let index = get_array_index_from_id(*cx, Handle::from_raw(id));
        if let Some(index) = index {
            let this = UnwrapProxy(proxy);
            let this = &*this;
            rooted!(in(*cx) let value = desc.value_);
            let value: DOMString = match FromJSValConvertible::from_jsval(*cx, value.handle(), StringificationBehavior::Default) {
                Ok(ConversionResult::Success(strval)) => strval,
                Ok(ConversionResult::Failure(error)) => {
                    throw_type_error(*cx, &error);
                    return false;
                }
                _ => { return false; },
            };
            let result: () = this.IndexedSetter(index, value);
            return (*opresult).succeed();
        }
        if id.is_string() || id.is_int() {
            let item_name = jsid_to_string(*cx, Handle::from_raw(id)).expect("Not a string-convertible JSID?");
            let this = UnwrapProxy(proxy);
            let this = &*this;
            rooted!(in(*cx) let value = desc.value_);
            let value: DOMString = match FromJSValConvertible::from_jsval(*cx, value.handle(), StringificationBehavior::Default) {
                Ok(ConversionResult::Success(strval)) => strval,
                Ok(ConversionResult::Failure(error)) => {
                    throw_type_error(*cx, &error);
                    return false;
                }
                _ => { return false; },
            };
            let result: () = this.NamedSetter(item_name, value);
            return (*opresult).succeed();
        }
        return proxyhandler::define_property(*cx, proxy, id, desc, opresult);
    })());
    result
}

unsafe extern fn delete(cx: *mut JSContext, proxy: RawHandleObject, id: RawHandleId, res: *mut ObjectOpResult) -> bool {
    let mut result = false;
    wrap_panic(&mut || result = (|| {
        let cx = SafeJSContext::from_ptr(cx);
        let name = jsid_to_string(*cx, Handle::from_raw(id)).expect("Not a string-convertible JSID?");
        let this = UnwrapProxy(proxy);
        let this = &*this;
        let result: () = this.NamedDeleter(name);
        return proxyhandler::delete(*cx, proxy, id, res);
    })());
    result
}

pub unsafe fn Wrap(cx: SafeJSContext, scope: &GlobalScope, given_proto: Option<HandleObject>, object: Box<TestBindingProxy>) -> DomRoot<TestBindingProxy> {
    let raw = Root::new(MaybeUnreflectedDom::from_box(object));

    let scope = scope.reflector().get_jsobject();
    assert!(!scope.get().is_null());
    assert!(((*get_object_class(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0);
    let _ac = JSAutoRealm::new(*cx, scope.get());

    rooted!(in(*cx) let mut canonical_proto = ptr::null_mut::<JSObject>());
    GetProtoObject(cx, scope, canonical_proto.handle_mut());
    assert!(!canonical_proto.is_null());


    let handler: *const libc::c_void =
        RegisterBindings::proxy_handlers::TestBindingProxy
        .load(std::sync::atomic::Ordering::Acquire);
    rooted!(in(*cx) let obj = NewProxyObject(
        *cx,
        handler,
        Handle::from_raw(UndefinedHandleValue),
        canonical_proto.get(),
        ptr::null(),
        false,
    ));
    assert!(!obj.is_null());
    SetProxyReservedSlot(
        obj.get(),
        0,
        &PrivateValue(raw.as_ptr() as *const libc::c_void),
    );

    let root = raw.reflect_with(obj.get());



    DomRoot::from_ref(&*root)
}

impl DomObjectWrap for dom::testbindingproxy::TestBindingProxy {
    const WRAP: unsafe fn(
        SafeJSContext,
        &GlobalScope,
        Option<HandleObject>,
        Box<Self>,
    ) -> Root<Dom<Self>> = Wrap;
}

impl IDLInterface for TestBindingProxy {
    #[inline]
    fn derives(class: &'static DOMClass) -> bool {
        ptr::eq(class, &Class)
    }
}

impl PartialEq for TestBindingProxy {
    fn eq(&self, other: &TestBindingProxy) -> bool {
        self as *const TestBindingProxy == other
    }
}

pub trait TestBindingProxyMethods {
    fn Length(&self) -> u32;
    fn GetNamedItem(&self, item_name: DOMString) -> DOMString;
    fn SetNamedItem(&self, item_name: DOMString, value: DOMString);
    fn GetItem(&self, index: u32) -> DOMString;
    fn SetItem(&self, index: u32, value: DOMString);
    fn RemoveItem(&self, name: DOMString);
    fn Stringifier(&self) -> DOMString;
    fn IndexedGetter(&self, index: u32) -> Option<DOMString>;
    fn IndexedSetter(&self, index: u32, value: DOMString);
    fn SupportedPropertyNames(&self) -> Vec<DOMString>;
    fn NamedGetter(&self, item_name: DOMString) -> Option<DOMString>;
    fn NamedSetter(&self, item_name: DOMString, value: DOMString);
    fn NamedDeleter(&self, name: DOMString);
}
const sMethods_specs: &[&[JSFunctionSpec]] = &[
&[
    JSFunctionSpec {
        name: JSPropertySpec_Name { string_: b"getNamedItem\0" as *const u8 as *const libc::c_char },
        call: JSNativeWrapper { op: Some(generic_method), info: &getNamedItem_methodinfo as *const _ as *const JSJitInfo },
        nargs: 1,
        flags: (JSPROP_ENUMERATE) as u16,
        selfHostedName: 0 as *const libc::c_char
    },
    JSFunctionSpec {
        name: JSPropertySpec_Name { string_: b"setNamedItem\0" as *const u8 as *const libc::c_char },
        call: JSNativeWrapper { op: Some(generic_method), info: &setNamedItem_methodinfo as *const _ as *const JSJitInfo },
        nargs: 2,
        flags: (JSPROP_ENUMERATE) as u16,
        selfHostedName: 0 as *const libc::c_char
    },
    JSFunctionSpec {
        name: JSPropertySpec_Name { string_: b"getItem\0" as *const u8 as *const libc::c_char },
        call: JSNativeWrapper { op: Some(generic_method), info: &getItem_methodinfo as *const _ as *const JSJitInfo },
        nargs: 1,
        flags: (JSPROP_ENUMERATE) as u16,
        selfHostedName: 0 as *const libc::c_char
    },
    JSFunctionSpec {
        name: JSPropertySpec_Name { string_: b"setItem\0" as *const u8 as *const libc::c_char },
        call: JSNativeWrapper { op: Some(generic_method), info: &setItem_methodinfo as *const _ as *const JSJitInfo },
        nargs: 2,
        flags: (JSPROP_ENUMERATE) as u16,
        selfHostedName: 0 as *const libc::c_char
    },
    JSFunctionSpec {
        name: JSPropertySpec_Name { string_: b"removeItem\0" as *const u8 as *const libc::c_char },
        call: JSNativeWrapper { op: Some(generic_method), info: &removeItem_methodinfo as *const _ as *const JSJitInfo },
        nargs: 1,
        flags: (JSPROP_ENUMERATE) as u16,
        selfHostedName: 0 as *const libc::c_char
    },
    JSFunctionSpec {
        name: JSPropertySpec_Name { string_: ptr::null() },
        call: JSNativeWrapper { op: None, info: ptr::null() },
        nargs: 0,
        flags: 0,
        selfHostedName: ptr::null()
    }]
,
&[
    JSFunctionSpec {
        name: JSPropertySpec_Name { symbol_: SymbolCode::iterator as usize + 1 },
        call: JSNativeWrapper { op: None, info: ptr::null() },
        nargs: 0,
        flags: 0,
        selfHostedName: b"$ArrayValues\0" as *const u8 as *const libc::c_char
    },
    JSFunctionSpec {
        name: JSPropertySpec_Name { string_: ptr::null() },
        call: JSNativeWrapper { op: None, info: ptr::null() },
        nargs: 0,
        flags: 0,
        selfHostedName: ptr::null()
    }]
,
&[
    JSFunctionSpec {
        name: JSPropertySpec_Name { string_: b"toString\0" as *const u8 as *const libc::c_char },
        call: JSNativeWrapper { op: Some(generic_method), info: &__stringifier_methodinfo as *const _ as *const JSJitInfo },
        nargs: 0,
        flags: (JSPROP_ENUMERATE) as u16,
        selfHostedName: 0 as *const libc::c_char
    },
    JSFunctionSpec {
        name: JSPropertySpec_Name { string_: ptr::null() },
        call: JSNativeWrapper { op: None, info: ptr::null() },
        nargs: 0,
        flags: 0,
        selfHostedName: ptr::null()
    }]

];
const sMethods: &[Guard<&[JSFunctionSpec]>] = &[
    Guard::new(Condition::Exposed(InterfaceObjectMap::Globals::WINDOW), sMethods_specs[0]),
    Guard::new(Condition::Exposed(InterfaceObjectMap::Globals::SERVICE_WORKER_GLOBAL_SCOPE), sMethods_specs[0]),
    Guard::new(Condition::Exposed(InterfaceObjectMap::Globals::DEDICATED_WORKER_GLOBAL_SCOPE), sMethods_specs[0]),
    Guard::new(Condition::Satisfied, sMethods_specs[1]),
    Guard::new(Condition::Exposed(InterfaceObjectMap::Globals::WINDOW), sMethods_specs[2]),
    Guard::new(Condition::Exposed(InterfaceObjectMap::Globals::SERVICE_WORKER_GLOBAL_SCOPE), sMethods_specs[2]),
    Guard::new(Condition::Exposed(InterfaceObjectMap::Globals::DEDICATED_WORKER_GLOBAL_SCOPE), sMethods_specs[2])
];
const sAttributes_specs: &[&[JSPropertySpec]] = &[
&[
    JSPropertySpec {
                    name: JSPropertySpec_Name { string_: b"length\0" as *const u8 as *const libc::c_char },
                    attributes_: (JSPROP_ENUMERATE),
                    kind_: (JSPropertySpec_Kind::NativeAccessor),
                    u: JSPropertySpec_AccessorsOrValue {
                        accessors: JSPropertySpec_AccessorsOrValue_Accessors {
                            getter: JSPropertySpec_Accessor {
                                native: JSNativeWrapper { op: Some(generic_getter), info: &length_getterinfo },
                            },
                            setter: JSPropertySpec_Accessor {
                                native: JSNativeWrapper { op: None, info: 0 as *const JSJitInfo },
                            }
                        }
                    }
                }
,
    JSPropertySpec::ZERO]
,
&[
    JSPropertySpec {
                    name: JSPropertySpec_Name { symbol_: SymbolCode::toStringTag as usize + 1 },
                    attributes_: (JSPROP_READONLY),
                    kind_: (JSPropertySpec_Kind::Value),
                    u: JSPropertySpec_AccessorsOrValue {
                        value: JSPropertySpec_ValueWrapper {
                            type_: JSPropertySpec_ValueWrapper_Type::String,
                            __bindgen_anon_1: JSPropertySpec_ValueWrapper__bindgen_ty_1 {
                                string: b"TestBindingProxy\0" as *const u8 as *const libc::c_char,
                            }
                        }
                    }
                }
,
    JSPropertySpec::ZERO]

];
const sAttributes: &[Guard<&[JSPropertySpec]>] = &[
    Guard::new(Condition::Exposed(InterfaceObjectMap::Globals::WINDOW), sAttributes_specs[0]),
    Guard::new(Condition::Exposed(InterfaceObjectMap::Globals::SERVICE_WORKER_GLOBAL_SCOPE), sAttributes_specs[0]),
    Guard::new(Condition::Exposed(InterfaceObjectMap::Globals::DEDICATED_WORKER_GLOBAL_SCOPE), sAttributes_specs[0]),
    Guard::new(Condition::Satisfied, sAttributes_specs[1])
];

pub fn GetProtoObject(cx: SafeJSContext, global: HandleObject, mut rval: MutableHandleObject) {
    /* Get the interface prototype object for this class.  This will create the
       object as needed. */
            get_per_interface_object_handle(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::TestBindingProxy), CreateInterfaceObjects, rval)

}

static PrototypeClass: JSClass = JSClass {
    name: b"TestBindingProxyPrototype\0" as *const u8 as *const libc::c_char,
    flags:
        // JSCLASS_HAS_RESERVED_SLOTS(0)
        (0 ) << JSCLASS_RESERVED_SLOTS_SHIFT,
    cOps: 0 as *const _,
    spec: ptr::null(),
    ext: ptr::null(),
    oOps: ptr::null(),
};

static INTERFACE_OBJECT_CLASS: NonCallbackInterfaceObjectClass =
    NonCallbackInterfaceObjectClass::new(
        {
            // Intermediate `const` because as of nightly-2018-10-05,
            // rustc is conservative in promotion to `'static` of the return values of `const fn`s:
            // https://github.com/rust-lang/rust/issues/54846
            // https://github.com/rust-lang/rust/pull/53851
            const BEHAVIOR: InterfaceConstructorBehavior = InterfaceConstructorBehavior::throw();
            &BEHAVIOR
        },
        b"function TestBindingProxy() {\n    [native code]\n}",
        PrototypeList::ID::TestBindingProxy,
        1);

pub fn DefineDOMInterface(cx: SafeJSContext, global: HandleObject) {

            define_dom_interface(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::TestBindingProxy), CreateInterfaceObjects, ConstructorEnabled)

}

fn ConstructorEnabled(aCx: SafeJSContext, aObj: HandleObject) -> bool {
    is_exposed_in(aObj, InterfaceObjectMap::Globals::DEDICATED_WORKER_GLOBAL_SCOPE | InterfaceObjectMap::Globals::SERVICE_WORKER_GLOBAL_SCOPE | InterfaceObjectMap::Globals::WINDOW) &&
    pref!(dom.testbinding.enabled)
}

unsafe fn CreateInterfaceObjects(cx: SafeJSContext, global: HandleObject, cache: *mut ProtoOrIfaceArray) {
    rooted!(in(*cx) let mut prototype_proto = ptr::null_mut::<JSObject>());
    TestBinding_Binding::GetProtoObject(cx, global, prototype_proto.handle_mut());
    assert!(!prototype_proto.is_null());

    rooted!(in(*cx) let mut prototype = ptr::null_mut::<JSObject>());
    create_interface_prototype_object(cx,
                                      global,
                                      prototype_proto.handle(),
                                      &PrototypeClass,
                                      sMethods,
                                      sAttributes,
                                      &[],
                                      &[],
                                      prototype.handle_mut());
    assert!(!prototype.is_null());
    assert!((*cache)[PrototypeList::ID::TestBindingProxy as usize].is_null());
    (*cache)[PrototypeList::ID::TestBindingProxy as usize] = prototype.get();
    <*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::TestBindingProxy as isize),
                                  ptr::null_mut(),
                                  prototype.get());

    rooted!(in(*cx) let mut interface_proto = ptr::null_mut::<JSObject>());

    TestBinding_Binding::GetConstructorObject(cx, global, interface_proto.handle_mut());
    assert!(!interface_proto.is_null());

    rooted!(in(*cx) let mut interface = ptr::null_mut::<JSObject>());
    create_noncallback_interface_object(cx,
                                        global,
                                        interface_proto.handle(),
                                        &INTERFACE_OBJECT_CLASS,
                                        &[],
                                        &[],
                                        &[],
                                        prototype.handle(),
                                        b"TestBindingProxy\0",
                                        0,
                                        &[],
                                        interface.handle_mut());
    assert!(!interface.is_null());
}
} // mod TestBindingProxy_Binding