Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/ImageCaptureErrorEventBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM ImageCaptureErrorEvent.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "AtomList.h"
4
#include "EventBinding.h"
5
#include "ImageCaptureErrorEventBinding.h"
6
#include "WrapperFactory.h"
7
#include "mozilla/OwningNonNull.h"
8
#include "mozilla/Preferences.h"
9
#include "mozilla/dom/BindingUtils.h"
10
#include "mozilla/dom/DOMJSClass.h"
11
#include "mozilla/dom/ImageCaptureError.h"
12
#include "mozilla/dom/ImageCaptureErrorEvent.h"
13
#include "mozilla/dom/NonRefcountedDOMObject.h"
14
#include "mozilla/dom/Nullable.h"
15
#include "mozilla/dom/PrimitiveConversions.h"
16
#include "mozilla/dom/ScriptSettings.h"
17
#include "mozilla/dom/XrayExpandoClass.h"
18
19
namespace mozilla {
20
namespace dom {
21
22
namespace binding_detail {}; // Just to make sure it's known as a namespace
23
using namespace mozilla::dom::binding_detail;
24
25
26
27
ImageCaptureErrorEventInit::ImageCaptureErrorEventInit()
28
  : EventInit(FastDictionaryInitializer())
29
0
{
30
0
  // Safe to pass a null context if we pass a null value
31
0
  Init(nullptr, JS::NullHandleValue);
32
0
}
33
34
35
36
bool
37
ImageCaptureErrorEventInit::InitIds(JSContext* cx, ImageCaptureErrorEventInitAtoms* atomsCache)
38
0
{
39
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
40
0
41
0
  // Initialize these in reverse order so that any failure leaves the first one
42
0
  // uninitialized.
43
0
  if (!atomsCache->imageCaptureError_id.init(cx, "imageCaptureError")) {
44
0
    return false;
45
0
  }
46
0
  return true;
47
0
}
48
49
bool
50
ImageCaptureErrorEventInit::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
51
0
{
52
0
  // Passing a null JSContext is OK only if we're initing from null,
53
0
  // Since in that case we will not have to do any property gets
54
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
55
0
  // checkers by static analysis tools
56
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
57
0
  ImageCaptureErrorEventInitAtoms* atomsCache = nullptr;
58
0
  if (cx) {
59
0
    atomsCache = GetAtomCache<ImageCaptureErrorEventInitAtoms>(cx);
60
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
61
0
      return false;
62
0
    }
63
0
  }
64
0
65
0
  // Per spec, we init the parent's members first
66
0
  if (!EventInit::Init(cx, val)) {
67
0
    return false;
68
0
  }
69
0
70
0
  bool isNull = val.isNullOrUndefined();
71
0
  // We only need these if !isNull, in which case we have |cx|.
72
0
  Maybe<JS::Rooted<JSObject *> > object;
73
0
  Maybe<JS::Rooted<JS::Value> > temp;
74
0
  if (!isNull) {
75
0
    MOZ_ASSERT(cx);
76
0
    object.emplace(cx, &val.toObject());
77
0
    temp.emplace(cx);
78
0
  }
79
0
  if (!isNull) {
80
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->imageCaptureError_id, temp.ptr())) {
81
0
      return false;
82
0
    }
83
0
  }
84
0
  if (!isNull && !temp->isUndefined()) {
85
0
    if (temp.ref().isObject()) {
86
0
      static_assert(IsRefcounted<mozilla::dom::ImageCaptureError>::value, "We can only store refcounted classes.");{
87
0
        nsresult rv = UnwrapObject<prototypes::id::ImageCaptureError, mozilla::dom::ImageCaptureError>(temp.ptr(), mImageCaptureError);
88
0
        if (NS_FAILED(rv)) {
89
0
          ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "'imageCaptureError' member of ImageCaptureErrorEventInit", "ImageCaptureError");
90
0
          return false;
91
0
        }
92
0
      }
93
0
    } else if (temp.ref().isNullOrUndefined()) {
94
0
      mImageCaptureError = nullptr;
95
0
    } else {
96
0
      ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'imageCaptureError' member of ImageCaptureErrorEventInit");
97
0
      return false;
98
0
    }
99
0
  } else {
100
0
    mImageCaptureError = nullptr;
101
0
  }
102
0
  mIsAnyMemberPresent = true;
103
0
  return true;
104
0
}
105
106
bool
107
ImageCaptureErrorEventInit::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
108
0
{
109
0
  ImageCaptureErrorEventInitAtoms* atomsCache = GetAtomCache<ImageCaptureErrorEventInitAtoms>(cx);
110
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
111
0
    return false;
112
0
  }
113
0
114
0
  // Per spec, we define the parent's members first
115
0
  if (!EventInit::ToObjectInternal(cx, rval)) {
116
0
    return false;
117
0
  }
118
0
  JS::Rooted<JSObject*> obj(cx, &rval.toObject());
119
0
120
0
  do {
121
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
122
0
    JS::Rooted<JS::Value> temp(cx);
123
0
    RefPtr<mozilla::dom::ImageCaptureError> const & currentValue = mImageCaptureError;
124
0
    if (!currentValue) {
125
0
      temp.setNull();
126
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->imageCaptureError_id, temp, JSPROP_ENUMERATE)) {
127
0
        return false;
128
0
      }
129
0
      break;
130
0
    }
131
0
    if (!GetOrCreateDOMReflector(cx, currentValue, &temp)) {
132
0
      MOZ_ASSERT(JS_IsExceptionPending(cx));
133
0
      return false;
134
0
    }
135
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->imageCaptureError_id, temp, JSPROP_ENUMERATE)) {
136
0
      return false;
137
0
    }
138
0
    break;
139
0
  } while(false);
140
0
141
0
  return true;
142
0
}
143
144
void
145
ImageCaptureErrorEventInit::TraceDictionary(JSTracer* trc)
146
0
{
147
0
  EventInit::TraceDictionary(trc);
148
0
}
149
150
151
152
ImageCaptureErrorEventInit&
153
ImageCaptureErrorEventInit::operator=(const ImageCaptureErrorEventInit& aOther)
154
0
{
155
0
  EventInit::operator=(aOther);
156
0
  mImageCaptureError = aOther.mImageCaptureError;
157
0
  return *this;
158
0
}
159
160
namespace binding_detail {
161
} // namespace binding_detail
162
163
164
namespace ImageCaptureError_Binding {
165
166
MOZ_CAN_RUN_SCRIPT static bool
167
get_code(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ImageCaptureError* self, JSJitGetterCallArgs args)
168
0
{
169
0
  AUTO_PROFILER_LABEL_FAST("get ImageCaptureError.code", DOM, cx);
170
0
171
0
  uint16_t result(self->Code());
172
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
173
0
  args.rval().setInt32(int32_t(result));
174
0
  return true;
175
0
}
176
177
static const JSJitInfo code_getterinfo = {
178
  { (JSJitGetterOp)get_code },
179
  { prototypes::id::ImageCaptureError },
180
  { PrototypeTraits<prototypes::id::ImageCaptureError>::Depth },
181
  JSJitInfo::Getter,
182
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
183
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
184
  true,  /* isInfallible. False in setters. */
185
  false,  /* isMovable.  Not relevant for setters. */
186
  false, /* isEliminatable.  Not relevant for setters. */
187
  false, /* isAlwaysInSlot.  Only relevant for getters. */
188
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
189
  false,  /* isTypedMethod.  Only relevant for methods. */
190
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
191
};
192
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
193
static_assert(0 < 1, "There is no slot for us");
194
195
MOZ_CAN_RUN_SCRIPT static bool
196
get_message(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ImageCaptureError* self, JSJitGetterCallArgs args)
197
0
{
198
0
  AUTO_PROFILER_LABEL_FAST("get ImageCaptureError.message", DOM, cx);
199
0
200
0
  DOMString result;
201
0
  self->GetMessage(result);
202
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
203
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
204
0
    return false;
205
0
  }
206
0
  return true;
207
0
}
208
209
static const JSJitInfo message_getterinfo = {
210
  { (JSJitGetterOp)get_message },
211
  { prototypes::id::ImageCaptureError },
212
  { PrototypeTraits<prototypes::id::ImageCaptureError>::Depth },
213
  JSJitInfo::Getter,
214
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
215
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
216
  false,  /* isInfallible. False in setters. */
217
  false,  /* isMovable.  Not relevant for setters. */
218
  false, /* isEliminatable.  Not relevant for setters. */
219
  false, /* isAlwaysInSlot.  Only relevant for getters. */
220
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
221
  false,  /* isTypedMethod.  Only relevant for methods. */
222
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
223
};
224
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
225
static_assert(0 < 1, "There is no slot for us");
226
227
static bool
228
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
229
0
{
230
0
  mozilla::dom::ImageCaptureError* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ImageCaptureError>(obj);
231
0
  // We don't want to preserve if we don't have a wrapper, and we
232
0
  // obviously can't preserve if we're not initialized.
233
0
  if (self && self->GetWrapperPreserveColor()) {
234
0
    PreserveWrapper(self);
235
0
  }
236
0
  return true;
237
0
}
238
239
static void
240
_finalize(js::FreeOp* fop, JSObject* obj)
241
0
{
242
0
  mozilla::dom::ImageCaptureError* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ImageCaptureError>(obj);
243
0
  if (self) {
244
0
    ClearWrapper(self, self, obj);
245
0
    AddForDeferredFinalization<mozilla::dom::ImageCaptureError>(self);
246
0
  }
247
0
}
248
249
static size_t
250
_objectMoved(JSObject* obj, JSObject* old)
251
0
{
252
0
  mozilla::dom::ImageCaptureError* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ImageCaptureError>(obj);
253
0
  if (self) {
254
0
    UpdateWrapper(self, self, obj, old);
255
0
  }
256
0
257
0
  return 0;
258
0
}
259
260
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
261
#if defined(__clang__)
262
#pragma clang diagnostic push
263
#pragma clang diagnostic ignored "-Wmissing-braces"
264
#endif
265
static const JSPropertySpec sAttributes_specs[] = {
266
  { "code", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &code_getterinfo, nullptr, nullptr },
267
  { "message", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &message_getterinfo, nullptr, nullptr },
268
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
269
};
270
#if defined(__clang__)
271
#pragma clang diagnostic pop
272
#endif
273
274
275
static const Prefable<const JSPropertySpec> sAttributes[] = {
276
  { nullptr, &sAttributes_specs[0] },
277
  { nullptr, nullptr }
278
};
279
280
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
281
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
282
static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
283
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
284
285
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
286
#if defined(__clang__)
287
#pragma clang diagnostic push
288
#pragma clang diagnostic ignored "-Wmissing-braces"
289
#endif
290
static const ConstantSpec sConstants_specs[] = {
291
  { "FRAME_GRAB_ERROR", JS::Int32Value(1) },
292
  { "SETTINGS_ERROR", JS::Int32Value(2) },
293
  { "PHOTO_ERROR", JS::Int32Value(3) },
294
  { "ERROR_UNKNOWN", JS::Int32Value(4) },
295
  { 0, JS::UndefinedValue() }
296
};
297
#if defined(__clang__)
298
#pragma clang diagnostic pop
299
#endif
300
301
302
static const Prefable<const ConstantSpec> sConstants[] = {
303
  { nullptr, &sConstants_specs[0] },
304
  { nullptr, nullptr }
305
};
306
307
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
308
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
309
static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
310
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
311
312
313
static uint16_t sNativeProperties_sortedPropertyIndices[6];
314
static PropertyInfo sNativeProperties_propertyInfos[6];
315
316
static const NativePropertiesN<2> sNativeProperties = {
317
  false, 0,
318
  false, 0,
319
  false, 0,
320
  true,  0 /* sAttributes */,
321
  false, 0,
322
  false, 0,
323
  true,  1 /* sConstants */,
324
  -1,
325
  6,
326
  sNativeProperties_sortedPropertyIndices,
327
  {
328
    { sAttributes, &sNativeProperties_propertyInfos[0] },
329
    { sConstants, &sNativeProperties_propertyInfos[2] }
330
  }
331
};
332
static_assert(6 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
333
    "We have a property info count that is oversized");
334
335
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
336
  {
337
    "ImageCaptureErrorPrototype",
338
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
339
    JS_NULL_CLASS_OPS,
340
    JS_NULL_CLASS_SPEC,
341
    JS_NULL_CLASS_EXT,
342
    JS_NULL_OBJECT_OPS
343
  },
344
  eInterfacePrototype,
345
  false,
346
  prototypes::id::ImageCaptureError,
347
  PrototypeTraits<prototypes::id::ImageCaptureError>::Depth,
348
  sNativePropertyHooks,
349
  "[object ImageCaptureErrorPrototype]",
350
  JS::GetRealmObjectPrototype
351
};
352
353
static const js::ClassOps sClassOps = {
354
  _addProperty, /* addProperty */
355
  nullptr,               /* delProperty */
356
  nullptr,               /* enumerate */
357
  nullptr, /* newEnumerate */
358
  nullptr, /* resolve */
359
  nullptr, /* mayResolve */
360
  _finalize, /* finalize */
361
  nullptr, /* call */
362
  nullptr,               /* hasInstance */
363
  nullptr,               /* construct */
364
  nullptr, /* trace */
365
};
366
367
static const js::ClassExtension sClassExtension = {
368
  nullptr, /* weakmapKeyDelegateOp */
369
  _objectMoved /* objectMovedOp */
370
};
371
372
static const DOMJSClass sClass = {
373
  { "ImageCaptureError",
374
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
375
    &sClassOps,
376
    JS_NULL_CLASS_SPEC,
377
    &sClassExtension,
378
    JS_NULL_OBJECT_OPS
379
  },
380
  { prototypes::id::ImageCaptureError, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
381
  IsBaseOf<nsISupports, mozilla::dom::ImageCaptureError >::value,
382
  sNativePropertyHooks,
383
  FindAssociatedGlobalForNative<mozilla::dom::ImageCaptureError>::Get,
384
  GetProtoObjectHandle,
385
  GetCCParticipant<mozilla::dom::ImageCaptureError>::Get()
386
};
387
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
388
              "Must have the right minimal number of reserved slots.");
389
static_assert(1 >= 1,
390
              "Must have enough reserved slots.");
391
392
const JSClass*
393
GetJSClass()
394
0
{
395
0
  return sClass.ToJSClass();
396
0
}
397
398
bool
399
Wrap(JSContext* aCx, mozilla::dom::ImageCaptureError* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
400
0
{
401
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::ImageCaptureError>::value,
402
0
                "Shouldn't have wrappercached things that are not refcounted.");
403
0
  MOZ_ASSERT(static_cast<mozilla::dom::ImageCaptureError*>(aObject) ==
404
0
             reinterpret_cast<mozilla::dom::ImageCaptureError*>(aObject),
405
0
             "Multiple inheritance for mozilla::dom::ImageCaptureError is broken.");
406
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
407
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
408
0
  MOZ_ASSERT(!aCache->GetWrapper(),
409
0
             "You should probably not be using Wrap() directly; use "
410
0
             "GetOrCreateDOMReflector instead");
411
0
412
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
413
0
             "nsISupports must be on our primary inheritance chain");
414
0
415
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
416
0
  if (!global) {
417
0
    return false;
418
0
  }
419
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
420
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
421
0
422
0
  // That might have ended up wrapping us already, due to the wonders
423
0
  // of XBL.  Check for that, and bail out as needed.
424
0
  aReflector.set(aCache->GetWrapper());
425
0
  if (aReflector) {
426
#ifdef DEBUG
427
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
428
#endif // DEBUG
429
    return true;
430
0
  }
431
0
432
0
  JSAutoRealm ar(aCx, global);
433
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
434
0
  if (!canonicalProto) {
435
0
    return false;
436
0
  }
437
0
  JS::Rooted<JSObject*> proto(aCx);
438
0
  if (aGivenProto) {
439
0
    proto = aGivenProto;
440
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
441
0
    // coming in, we changed compartments to that of "parent" so may need
442
0
    // to wrap the proto here.
443
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
444
0
      if (!JS_WrapObject(aCx, &proto)) {
445
0
        return false;
446
0
      }
447
0
    }
448
0
  } else {
449
0
    proto = canonicalProto;
450
0
  }
451
0
452
0
  BindingJSObjectCreator<mozilla::dom::ImageCaptureError> creator(aCx);
453
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
454
0
  if (!aReflector) {
455
0
    return false;
456
0
  }
457
0
458
0
  aCache->SetWrapper(aReflector);
459
0
  creator.InitializationSucceeded();
460
0
461
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
462
0
             aCache->GetWrapperPreserveColor() == aReflector);
463
0
  // If proto != canonicalProto, we have to preserve our wrapper;
464
0
  // otherwise we won't be able to properly recreate it later, since
465
0
  // we won't know what proto to use.  Note that we don't check
466
0
  // aGivenProto here, since it's entirely possible (and even
467
0
  // somewhat common) to have a non-null aGivenProto which is the
468
0
  // same as canonicalProto.
469
0
  if (proto != canonicalProto) {
470
0
    PreserveWrapper(aObject);
471
0
  }
472
0
473
0
  return true;
474
0
}
475
476
const NativePropertyHooks sNativePropertyHooks[] = { {
477
  nullptr,
478
  nullptr,
479
  nullptr,
480
  { sNativeProperties.Upcast(), nullptr },
481
  prototypes::id::ImageCaptureError,
482
  constructors::id::_ID_Count,
483
  nullptr,
484
  &DefaultXrayExpandoObjectClass
485
} };
486
487
void
488
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
489
0
{
490
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
491
0
  if (!parentProto) {
492
0
    return;
493
0
  }
494
0
495
0
  static bool sIdsInited = false;
496
0
  if (!sIdsInited && NS_IsMainThread()) {
497
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
498
0
      return;
499
0
    }
500
0
    sIdsInited = true;
501
0
  }
502
0
503
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::ImageCaptureError);
504
0
  JS::Heap<JSObject*>* interfaceCache = nullptr;
505
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
506
0
                              &sPrototypeClass.mBase, protoCache,
507
0
                              nullptr,
508
0
                              nullptr, nullptr, 0, nullptr,
509
0
                              interfaceCache,
510
0
                              sNativeProperties.Upcast(),
511
0
                              nullptr,
512
0
                              nullptr, aDefineOnGlobal,
513
0
                              nullptr,
514
0
                              false);
515
0
}
516
517
} // namespace ImageCaptureError_Binding
518
519
520
521
namespace ImageCaptureErrorEvent_Binding {
522
523
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<Event_Binding::NativeType>::value,
524
              "Can't inherit from an interface with a different ownership model.");
525
526
MOZ_CAN_RUN_SCRIPT static bool
527
get_imageCaptureError(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ImageCaptureErrorEvent* self, JSJitGetterCallArgs args)
528
0
{
529
0
  AUTO_PROFILER_LABEL_FAST("get ImageCaptureErrorEvent.imageCaptureError", DOM, cx);
530
0
531
0
  auto result(StrongOrRawPtr<mozilla::dom::ImageCaptureError>(self->GetImageCaptureError()));
532
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
533
0
  if (!result) {
534
0
    args.rval().setNull();
535
0
    return true;
536
0
  }
537
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
538
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
539
0
    return false;
540
0
  }
541
0
  return true;
542
0
}
543
544
static const JSJitInfo imageCaptureError_getterinfo = {
545
  { (JSJitGetterOp)get_imageCaptureError },
546
  { prototypes::id::ImageCaptureErrorEvent },
547
  { PrototypeTraits<prototypes::id::ImageCaptureErrorEvent>::Depth },
548
  JSJitInfo::Getter,
549
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
550
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
551
  false,  /* isInfallible. False in setters. */
552
  false,  /* isMovable.  Not relevant for setters. */
553
  false, /* isEliminatable.  Not relevant for setters. */
554
  false, /* isAlwaysInSlot.  Only relevant for getters. */
555
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
556
  false,  /* isTypedMethod.  Only relevant for methods. */
557
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
558
};
559
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
560
static_assert(0 < 1, "There is no slot for us");
561
562
MOZ_CAN_RUN_SCRIPT static bool
563
get_isTrusted(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ImageCaptureErrorEvent* self, JSJitGetterCallArgs args)
564
0
{
565
0
  AUTO_PROFILER_LABEL_FAST("get ImageCaptureErrorEvent.isTrusted", DOM, cx);
566
0
567
0
  bool result(self->IsTrusted());
568
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
569
0
  args.rval().setBoolean(result);
570
0
  return true;
571
0
}
572
573
static const JSJitInfo isTrusted_getterinfo = {
574
  { (JSJitGetterOp)get_isTrusted },
575
  { prototypes::id::ImageCaptureErrorEvent },
576
  { PrototypeTraits<prototypes::id::ImageCaptureErrorEvent>::Depth },
577
  JSJitInfo::Getter,
578
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
579
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
580
  true,  /* isInfallible. False in setters. */
581
  true,  /* isMovable.  Not relevant for setters. */
582
  true, /* isEliminatable.  Not relevant for setters. */
583
  false, /* isAlwaysInSlot.  Only relevant for getters. */
584
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
585
  false,  /* isTypedMethod.  Only relevant for methods. */
586
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
587
};
588
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
589
static_assert(0 < 1, "There is no slot for us");
590
591
static bool
592
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
593
0
{
594
0
  mozilla::dom::ImageCaptureErrorEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ImageCaptureErrorEvent>(obj);
595
0
  // We don't want to preserve if we don't have a wrapper, and we
596
0
  // obviously can't preserve if we're not initialized.
597
0
  if (self && self->GetWrapperPreserveColor()) {
598
0
    PreserveWrapper(self);
599
0
  }
600
0
  return true;
601
0
}
602
603
static void
604
_finalize(js::FreeOp* fop, JSObject* obj)
605
0
{
606
0
  mozilla::dom::ImageCaptureErrorEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ImageCaptureErrorEvent>(obj);
607
0
  if (self) {
608
0
    ClearWrapper(self, self, obj);
609
0
    AddForDeferredFinalization<mozilla::dom::ImageCaptureErrorEvent>(self);
610
0
  }
611
0
}
612
613
static size_t
614
_objectMoved(JSObject* obj, JSObject* old)
615
0
{
616
0
  mozilla::dom::ImageCaptureErrorEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ImageCaptureErrorEvent>(obj);
617
0
  if (self) {
618
0
    UpdateWrapper(self, self, obj, old);
619
0
  }
620
0
621
0
  return 0;
622
0
}
623
624
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
625
#if defined(__clang__)
626
#pragma clang diagnostic push
627
#pragma clang diagnostic ignored "-Wmissing-braces"
628
#endif
629
static const JSPropertySpec sAttributes_specs[] = {
630
  { "imageCaptureError", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &imageCaptureError_getterinfo, nullptr, nullptr },
631
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
632
};
633
#if defined(__clang__)
634
#pragma clang diagnostic pop
635
#endif
636
637
638
static const Prefable<const JSPropertySpec> sAttributes[] = {
639
  { nullptr, &sAttributes_specs[0] },
640
  { nullptr, nullptr }
641
};
642
643
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
644
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
645
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
646
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
647
648
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
649
#if defined(__clang__)
650
#pragma clang diagnostic push
651
#pragma clang diagnostic ignored "-Wmissing-braces"
652
#endif
653
static const JSPropertySpec sUnforgeableAttributes_specs[] = {
654
  { "isTrusted", JSPROP_ENUMERATE | JSPROP_PERMANENT, GenericGetter<NormalThisPolicy, ThrowExceptions>, &isTrusted_getterinfo, nullptr, nullptr },
655
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
656
};
657
#if defined(__clang__)
658
#pragma clang diagnostic pop
659
#endif
660
661
662
static const Prefable<const JSPropertySpec> sUnforgeableAttributes[] = {
663
  { nullptr, &sUnforgeableAttributes_specs[0] },
664
  { nullptr, nullptr }
665
};
666
667
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
668
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
669
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
670
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
671
672
673
static uint16_t sNativeProperties_sortedPropertyIndices[2];
674
static PropertyInfo sNativeProperties_propertyInfos[2];
675
676
static const NativePropertiesN<2> sNativeProperties = {
677
  false, 0,
678
  false, 0,
679
  false, 0,
680
  true,  0 /* sAttributes */,
681
  false, 0,
682
  true,  1 /* sUnforgeableAttributes */,
683
  false, 0,
684
  -1,
685
  2,
686
  sNativeProperties_sortedPropertyIndices,
687
  {
688
    { sAttributes, &sNativeProperties_propertyInfos[0] },
689
    { sUnforgeableAttributes, &sNativeProperties_propertyInfos[1] }
690
  }
691
};
692
static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
693
    "We have a property info count that is oversized");
694
695
static bool
696
_constructor(JSContext* cx, unsigned argc, JS::Value* vp)
697
0
{
698
0
  AUTO_PROFILER_LABEL_FAST("ImageCaptureErrorEvent constructor", DOM, cx);
699
0
700
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
701
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
702
0
  if (!args.isConstructing()) {
703
0
    // XXXbz wish I could get the name from the callee instead of
704
0
    // Adding more relocations
705
0
    return ThrowConstructorWithoutNew(cx, "ImageCaptureErrorEvent");
706
0
  }
707
0
708
0
  JS::Rooted<JSObject*> desiredProto(cx);
709
0
  if (!GetDesiredProto(cx, args, &desiredProto)) {
710
0
    return false;
711
0
  }
712
0
713
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
714
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "ImageCaptureErrorEvent");
715
0
  }
716
0
  GlobalObject global(cx, obj);
717
0
  if (global.Failed()) {
718
0
    return false;
719
0
  }
720
0
721
0
  bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
722
0
  binding_detail::FakeString arg0;
723
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
724
0
    return false;
725
0
  }
726
0
  binding_detail::FastImageCaptureErrorEventInit arg1;
727
0
  if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue,  "Argument 2 of ImageCaptureErrorEvent.constructor", false)) {
728
0
    return false;
729
0
  }
730
0
  Maybe<JSAutoRealm> ar;
731
0
  if (objIsXray) {
732
0
    obj = js::CheckedUnwrap(obj);
733
0
    if (!obj) {
734
0
      return false;
735
0
    }
736
0
    ar.emplace(cx, obj);
737
0
    if (!JS_WrapObject(cx, &desiredProto)) {
738
0
      return false;
739
0
    }
740
0
  }
741
0
  FastErrorResult rv;
742
0
  auto result(StrongOrRawPtr<mozilla::dom::ImageCaptureErrorEvent>(mozilla::dom::ImageCaptureErrorEvent::Constructor(global, NonNullHelper(Constify(arg0)), Constify(arg1), rv)));
743
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
744
0
    return false;
745
0
  }
746
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
747
0
  static_assert(!IsPointer<decltype(result)>::value,
748
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
749
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
750
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
751
0
    return false;
752
0
  }
753
0
  return true;
754
0
}
755
756
static const js::ClassOps sInterfaceObjectClassOps = {
757
    nullptr,               /* addProperty */
758
    nullptr,               /* delProperty */
759
    nullptr,               /* enumerate */
760
    nullptr,               /* newEnumerate */
761
    nullptr,               /* resolve */
762
    nullptr,               /* mayResolve */
763
    nullptr,               /* finalize */
764
    _constructor, /* call */
765
    nullptr,               /* hasInstance */
766
    _constructor, /* construct */
767
    nullptr,               /* trace */
768
};
769
770
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
771
  {
772
    "Function",
773
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
774
    &sInterfaceObjectClassOps,
775
    JS_NULL_CLASS_SPEC,
776
    JS_NULL_CLASS_EXT,
777
    &sInterfaceObjectClassObjectOps
778
  },
779
  eInterface,
780
  true,
781
  prototypes::id::ImageCaptureErrorEvent,
782
  PrototypeTraits<prototypes::id::ImageCaptureErrorEvent>::Depth,
783
  sNativePropertyHooks,
784
  "function ImageCaptureErrorEvent() {\n    [native code]\n}",
785
  Event_Binding::GetConstructorObject
786
};
787
788
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
789
  {
790
    "ImageCaptureErrorEventPrototype",
791
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE + 1 /* slot for the JSObject holding the unforgeable properties */),
792
    JS_NULL_CLASS_OPS,
793
    JS_NULL_CLASS_SPEC,
794
    JS_NULL_CLASS_EXT,
795
    JS_NULL_OBJECT_OPS
796
  },
797
  eInterfacePrototype,
798
  false,
799
  prototypes::id::ImageCaptureErrorEvent,
800
  PrototypeTraits<prototypes::id::ImageCaptureErrorEvent>::Depth,
801
  sNativePropertyHooks,
802
  "[object ImageCaptureErrorEventPrototype]",
803
  Event_Binding::GetProtoObject
804
};
805
806
bool
807
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
808
0
{
809
0
  static bool sPrefValue;
810
0
  static bool sPrefCacheSetUp = false;
811
0
  if (!sPrefCacheSetUp) {
812
0
    sPrefCacheSetUp = true;
813
0
    Preferences::AddBoolVarCache(&sPrefValue, "dom.imagecapture.enabled");
814
0
  }
815
0
816
0
  return sPrefValue;
817
0
}
818
819
static const js::ClassOps sClassOps = {
820
  _addProperty, /* addProperty */
821
  nullptr,               /* delProperty */
822
  nullptr,               /* enumerate */
823
  nullptr, /* newEnumerate */
824
  nullptr, /* resolve */
825
  nullptr, /* mayResolve */
826
  _finalize, /* finalize */
827
  nullptr, /* call */
828
  nullptr,               /* hasInstance */
829
  nullptr,               /* construct */
830
  nullptr, /* trace */
831
};
832
833
static const js::ClassExtension sClassExtension = {
834
  nullptr, /* weakmapKeyDelegateOp */
835
  _objectMoved /* objectMovedOp */
836
};
837
838
static const DOMJSClass sClass = {
839
  { "ImageCaptureErrorEvent",
840
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_SKIP_NURSERY_FINALIZE,
841
    &sClassOps,
842
    JS_NULL_CLASS_SPEC,
843
    &sClassExtension,
844
    JS_NULL_OBJECT_OPS
845
  },
846
  { prototypes::id::Event, prototypes::id::ImageCaptureErrorEvent, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
847
  IsBaseOf<nsISupports, mozilla::dom::ImageCaptureErrorEvent >::value,
848
  sNativePropertyHooks,
849
  FindAssociatedGlobalForNative<mozilla::dom::ImageCaptureErrorEvent>::Get,
850
  GetProtoObjectHandle,
851
  GetCCParticipant<mozilla::dom::ImageCaptureErrorEvent>::Get()
852
};
853
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
854
              "Must have the right minimal number of reserved slots.");
855
static_assert(1 >= 1,
856
              "Must have enough reserved slots.");
857
858
const JSClass*
859
GetJSClass()
860
0
{
861
0
  return sClass.ToJSClass();
862
0
}
863
864
bool
865
Wrap(JSContext* aCx, mozilla::dom::ImageCaptureErrorEvent* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
866
0
{
867
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::ImageCaptureErrorEvent>::value,
868
0
                "Shouldn't have wrappercached things that are not refcounted.");
869
0
  MOZ_ASSERT(static_cast<mozilla::dom::ImageCaptureErrorEvent*>(aObject) ==
870
0
             reinterpret_cast<mozilla::dom::ImageCaptureErrorEvent*>(aObject),
871
0
             "Multiple inheritance for mozilla::dom::ImageCaptureErrorEvent is broken.");
872
0
  MOZ_ASSERT(static_cast<mozilla::dom::Event*>(aObject) ==
873
0
             reinterpret_cast<mozilla::dom::Event*>(aObject),
874
0
             "Multiple inheritance for mozilla::dom::Event is broken.");
875
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
876
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
877
0
  MOZ_ASSERT(!aCache->GetWrapper(),
878
0
             "You should probably not be using Wrap() directly; use "
879
0
             "GetOrCreateDOMReflector instead");
880
0
881
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
882
0
             "nsISupports must be on our primary inheritance chain");
883
0
884
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
885
0
  if (!global) {
886
0
    return false;
887
0
  }
888
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
889
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
890
0
891
0
  // That might have ended up wrapping us already, due to the wonders
892
0
  // of XBL.  Check for that, and bail out as needed.
893
0
  aReflector.set(aCache->GetWrapper());
894
0
  if (aReflector) {
895
#ifdef DEBUG
896
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
897
#endif // DEBUG
898
    return true;
899
0
  }
900
0
901
0
  JSAutoRealm ar(aCx, global);
902
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
903
0
  if (!canonicalProto) {
904
0
    return false;
905
0
  }
906
0
  JS::Rooted<JSObject*> proto(aCx);
907
0
  if (aGivenProto) {
908
0
    proto = aGivenProto;
909
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
910
0
    // coming in, we changed compartments to that of "parent" so may need
911
0
    // to wrap the proto here.
912
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
913
0
      if (!JS_WrapObject(aCx, &proto)) {
914
0
        return false;
915
0
      }
916
0
    }
917
0
  } else {
918
0
    proto = canonicalProto;
919
0
  }
920
0
921
0
  BindingJSObjectCreator<mozilla::dom::ImageCaptureErrorEvent> creator(aCx);
922
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
923
0
  if (!aReflector) {
924
0
    return false;
925
0
  }
926
0
927
0
  aCache->SetWrapper(aReflector);
928
0
929
0
  // Important: do unforgeable property setup after we have handed
930
0
  // over ownership of the C++ object to obj as needed, so that if
931
0
  // we fail and it ends up GCed it won't have problems in the
932
0
  // finalizer trying to drop its ownership of the C++ object.
933
0
  JS::Rooted<JSObject*> unforgeableHolder(aCx,
934
0
    &js::GetReservedSlot(canonicalProto, DOM_INTERFACE_PROTO_SLOTS_BASE).toObject());
935
0
  if (!JS_InitializePropertiesFromCompatibleNativeObject(aCx, aReflector, unforgeableHolder)) {
936
0
    aCache->ReleaseWrapper(aObject);
937
0
    aCache->ClearWrapper();
938
0
    return false;
939
0
  }
940
0
  creator.InitializationSucceeded();
941
0
942
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
943
0
             aCache->GetWrapperPreserveColor() == aReflector);
944
0
  // If proto != canonicalProto, we have to preserve our wrapper;
945
0
  // otherwise we won't be able to properly recreate it later, since
946
0
  // we won't know what proto to use.  Note that we don't check
947
0
  // aGivenProto here, since it's entirely possible (and even
948
0
  // somewhat common) to have a non-null aGivenProto which is the
949
0
  // same as canonicalProto.
950
0
  if (proto != canonicalProto) {
951
0
    PreserveWrapper(aObject);
952
0
  }
953
0
954
0
  return true;
955
0
}
956
957
const NativePropertyHooks sNativePropertyHooks[] = { {
958
  nullptr,
959
  nullptr,
960
  nullptr,
961
  { sNativeProperties.Upcast(), nullptr },
962
  prototypes::id::ImageCaptureErrorEvent,
963
  constructors::id::ImageCaptureErrorEvent,
964
  Event_Binding::sNativePropertyHooks,
965
  &DefaultXrayExpandoObjectClass
966
} };
967
968
void
969
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
970
0
{
971
0
  JS::Handle<JSObject*> parentProto(Event_Binding::GetProtoObjectHandle(aCx));
972
0
  if (!parentProto) {
973
0
    return;
974
0
  }
975
0
976
0
  JS::Handle<JSObject*> constructorProto(Event_Binding::GetConstructorObjectHandle(aCx));
977
0
  if (!constructorProto) {
978
0
    return;
979
0
  }
980
0
981
0
  static bool sIdsInited = false;
982
0
  if (!sIdsInited && NS_IsMainThread()) {
983
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
984
0
      return;
985
0
    }
986
0
    sIdsInited = true;
987
0
  }
988
0
989
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::ImageCaptureErrorEvent);
990
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::ImageCaptureErrorEvent);
991
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
992
0
                              &sPrototypeClass.mBase, protoCache,
993
0
                              nullptr,
994
0
                              constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr,
995
0
                              interfaceCache,
996
0
                              sNativeProperties.Upcast(),
997
0
                              nullptr,
998
0
                              "ImageCaptureErrorEvent", aDefineOnGlobal,
999
0
                              nullptr,
1000
0
                              false);
1001
0
1002
0
  JS::Rooted<JSObject*> unforgeableHolder(aCx);
1003
0
  {
1004
0
    JS::Rooted<JSObject*> holderProto(aCx, *protoCache);
1005
0
    unforgeableHolder = JS_NewObjectWithoutMetadata(aCx, sClass.ToJSClass(), holderProto);
1006
0
    if (!unforgeableHolder) {
1007
0
      *protoCache = nullptr;
1008
0
      if (interfaceCache) {
1009
0
        *interfaceCache = nullptr;
1010
0
      }
1011
0
      return;
1012
0
    }
1013
0
  }
1014
0
1015
0
  if (!DefineUnforgeableAttributes(aCx, unforgeableHolder, sUnforgeableAttributes)) {
1016
0
    *protoCache = nullptr;
1017
0
    if (interfaceCache) {
1018
0
      *interfaceCache = nullptr;
1019
0
    }
1020
0
    return;
1021
0
  }
1022
0
1023
0
  if (*protoCache) {
1024
0
    js::SetReservedSlot(*protoCache, DOM_INTERFACE_PROTO_SLOTS_BASE,
1025
0
                        JS::ObjectValue(*unforgeableHolder));
1026
0
  }
1027
0
}
1028
1029
JSObject*
1030
GetConstructorObject(JSContext* aCx)
1031
0
{
1032
0
  return GetConstructorObjectHandle(aCx);
1033
0
}
1034
1035
} // namespace ImageCaptureErrorEvent_Binding
1036
1037
1038
1039
} // namespace dom
1040
} // namespace mozilla