Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/MediaKeyErrorBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM MediaKeyError.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "EventBinding.h"
4
#include "MediaKeyErrorBinding.h"
5
#include "WrapperFactory.h"
6
#include "mozilla/OwningNonNull.h"
7
#include "mozilla/dom/BindingUtils.h"
8
#include "mozilla/dom/DOMJSClass.h"
9
#include "mozilla/dom/MediaKeyError.h"
10
#include "mozilla/dom/NonRefcountedDOMObject.h"
11
#include "mozilla/dom/PrimitiveConversions.h"
12
#include "mozilla/dom/XrayExpandoClass.h"
13
14
namespace mozilla {
15
namespace dom {
16
17
namespace binding_detail {}; // Just to make sure it's known as a namespace
18
using namespace mozilla::dom::binding_detail;
19
20
21
namespace MediaKeyError_Binding {
22
23
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<Event_Binding::NativeType>::value,
24
              "Can't inherit from an interface with a different ownership model.");
25
26
MOZ_CAN_RUN_SCRIPT static bool
27
get_systemCode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeyError* self, JSJitGetterCallArgs args)
28
0
{
29
0
  AUTO_PROFILER_LABEL_FAST("get MediaKeyError.systemCode", DOM, cx);
30
0
31
0
  uint32_t result(self->SystemCode());
32
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
33
0
  args.rval().setNumber(result);
34
0
  return true;
35
0
}
36
37
static const JSJitInfo systemCode_getterinfo = {
38
  { (JSJitGetterOp)get_systemCode },
39
  { prototypes::id::MediaKeyError },
40
  { PrototypeTraits<prototypes::id::MediaKeyError>::Depth },
41
  JSJitInfo::Getter,
42
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
43
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
44
  true,  /* isInfallible. False in setters. */
45
  false,  /* isMovable.  Not relevant for setters. */
46
  false, /* isEliminatable.  Not relevant for setters. */
47
  false, /* isAlwaysInSlot.  Only relevant for getters. */
48
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
49
  false,  /* isTypedMethod.  Only relevant for methods. */
50
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
51
};
52
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
53
static_assert(0 < 1, "There is no slot for us");
54
55
MOZ_CAN_RUN_SCRIPT static bool
56
get_isTrusted(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeyError* self, JSJitGetterCallArgs args)
57
0
{
58
0
  AUTO_PROFILER_LABEL_FAST("get MediaKeyError.isTrusted", DOM, cx);
59
0
60
0
  bool result(self->IsTrusted());
61
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
62
0
  args.rval().setBoolean(result);
63
0
  return true;
64
0
}
65
66
static const JSJitInfo isTrusted_getterinfo = {
67
  { (JSJitGetterOp)get_isTrusted },
68
  { prototypes::id::MediaKeyError },
69
  { PrototypeTraits<prototypes::id::MediaKeyError>::Depth },
70
  JSJitInfo::Getter,
71
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
72
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
73
  true,  /* isInfallible. False in setters. */
74
  true,  /* isMovable.  Not relevant for setters. */
75
  true, /* isEliminatable.  Not relevant for setters. */
76
  false, /* isAlwaysInSlot.  Only relevant for getters. */
77
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
78
  false,  /* isTypedMethod.  Only relevant for methods. */
79
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
80
};
81
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
82
static_assert(0 < 1, "There is no slot for us");
83
84
static bool
85
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
86
0
{
87
0
  mozilla::dom::MediaKeyError* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MediaKeyError>(obj);
88
0
  // We don't want to preserve if we don't have a wrapper, and we
89
0
  // obviously can't preserve if we're not initialized.
90
0
  if (self && self->GetWrapperPreserveColor()) {
91
0
    PreserveWrapper(self);
92
0
  }
93
0
  return true;
94
0
}
95
96
static void
97
_finalize(js::FreeOp* fop, JSObject* obj)
98
0
{
99
0
  mozilla::dom::MediaKeyError* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MediaKeyError>(obj);
100
0
  if (self) {
101
0
    ClearWrapper(self, self, obj);
102
0
    AddForDeferredFinalization<mozilla::dom::MediaKeyError>(self);
103
0
  }
104
0
}
105
106
static size_t
107
_objectMoved(JSObject* obj, JSObject* old)
108
0
{
109
0
  mozilla::dom::MediaKeyError* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MediaKeyError>(obj);
110
0
  if (self) {
111
0
    UpdateWrapper(self, self, obj, old);
112
0
  }
113
0
114
0
  return 0;
115
0
}
116
117
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
118
#if defined(__clang__)
119
#pragma clang diagnostic push
120
#pragma clang diagnostic ignored "-Wmissing-braces"
121
#endif
122
static const JSPropertySpec sAttributes_specs[] = {
123
  { "systemCode", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &systemCode_getterinfo, nullptr, nullptr },
124
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
125
};
126
#if defined(__clang__)
127
#pragma clang diagnostic pop
128
#endif
129
130
131
static const Prefable<const JSPropertySpec> sAttributes[] = {
132
  { nullptr, &sAttributes_specs[0] },
133
  { nullptr, nullptr }
134
};
135
136
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
137
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
138
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
139
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
140
141
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
142
#if defined(__clang__)
143
#pragma clang diagnostic push
144
#pragma clang diagnostic ignored "-Wmissing-braces"
145
#endif
146
static const JSPropertySpec sUnforgeableAttributes_specs[] = {
147
  { "isTrusted", JSPROP_ENUMERATE | JSPROP_PERMANENT, GenericGetter<NormalThisPolicy, ThrowExceptions>, &isTrusted_getterinfo, nullptr, nullptr },
148
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
149
};
150
#if defined(__clang__)
151
#pragma clang diagnostic pop
152
#endif
153
154
155
static const Prefable<const JSPropertySpec> sUnforgeableAttributes[] = {
156
  { nullptr, &sUnforgeableAttributes_specs[0] },
157
  { nullptr, nullptr }
158
};
159
160
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
161
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
162
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
163
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
164
165
166
static uint16_t sNativeProperties_sortedPropertyIndices[2];
167
static PropertyInfo sNativeProperties_propertyInfos[2];
168
169
static const NativePropertiesN<2> sNativeProperties = {
170
  false, 0,
171
  false, 0,
172
  false, 0,
173
  true,  0 /* sAttributes */,
174
  false, 0,
175
  true,  1 /* sUnforgeableAttributes */,
176
  false, 0,
177
  -1,
178
  2,
179
  sNativeProperties_sortedPropertyIndices,
180
  {
181
    { sAttributes, &sNativeProperties_propertyInfos[0] },
182
    { sUnforgeableAttributes, &sNativeProperties_propertyInfos[1] }
183
  }
184
};
185
static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
186
    "We have a property info count that is oversized");
187
188
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
189
  {
190
    "Function",
191
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
192
    &sBoringInterfaceObjectClassClassOps,
193
    JS_NULL_CLASS_SPEC,
194
    JS_NULL_CLASS_EXT,
195
    &sInterfaceObjectClassObjectOps
196
  },
197
  eInterface,
198
  true,
199
  prototypes::id::MediaKeyError,
200
  PrototypeTraits<prototypes::id::MediaKeyError>::Depth,
201
  sNativePropertyHooks,
202
  "function MediaKeyError() {\n    [native code]\n}",
203
  Event_Binding::GetConstructorObject
204
};
205
206
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
207
  {
208
    "MediaKeyErrorPrototype",
209
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE + 1 /* slot for the JSObject holding the unforgeable properties */),
210
    JS_NULL_CLASS_OPS,
211
    JS_NULL_CLASS_SPEC,
212
    JS_NULL_CLASS_EXT,
213
    JS_NULL_OBJECT_OPS
214
  },
215
  eInterfacePrototype,
216
  false,
217
  prototypes::id::MediaKeyError,
218
  PrototypeTraits<prototypes::id::MediaKeyError>::Depth,
219
  sNativePropertyHooks,
220
  "[object MediaKeyErrorPrototype]",
221
  Event_Binding::GetProtoObject
222
};
223
224
static const js::ClassOps sClassOps = {
225
  _addProperty, /* addProperty */
226
  nullptr,               /* delProperty */
227
  nullptr,               /* enumerate */
228
  nullptr, /* newEnumerate */
229
  nullptr, /* resolve */
230
  nullptr, /* mayResolve */
231
  _finalize, /* finalize */
232
  nullptr, /* call */
233
  nullptr,               /* hasInstance */
234
  nullptr,               /* construct */
235
  nullptr, /* trace */
236
};
237
238
static const js::ClassExtension sClassExtension = {
239
  nullptr, /* weakmapKeyDelegateOp */
240
  _objectMoved /* objectMovedOp */
241
};
242
243
static const DOMJSClass sClass = {
244
  { "MediaKeyError",
245
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_SKIP_NURSERY_FINALIZE,
246
    &sClassOps,
247
    JS_NULL_CLASS_SPEC,
248
    &sClassExtension,
249
    JS_NULL_OBJECT_OPS
250
  },
251
  { prototypes::id::Event, prototypes::id::MediaKeyError, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
252
  IsBaseOf<nsISupports, mozilla::dom::MediaKeyError >::value,
253
  sNativePropertyHooks,
254
  FindAssociatedGlobalForNative<mozilla::dom::MediaKeyError>::Get,
255
  GetProtoObjectHandle,
256
  GetCCParticipant<mozilla::dom::MediaKeyError>::Get()
257
};
258
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
259
              "Must have the right minimal number of reserved slots.");
260
static_assert(1 >= 1,
261
              "Must have enough reserved slots.");
262
263
const JSClass*
264
GetJSClass()
265
0
{
266
0
  return sClass.ToJSClass();
267
0
}
268
269
bool
270
Wrap(JSContext* aCx, mozilla::dom::MediaKeyError* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
271
0
{
272
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::MediaKeyError>::value,
273
0
                "Shouldn't have wrappercached things that are not refcounted.");
274
0
  MOZ_ASSERT(static_cast<mozilla::dom::MediaKeyError*>(aObject) ==
275
0
             reinterpret_cast<mozilla::dom::MediaKeyError*>(aObject),
276
0
             "Multiple inheritance for mozilla::dom::MediaKeyError is broken.");
277
0
  MOZ_ASSERT(static_cast<mozilla::dom::Event*>(aObject) ==
278
0
             reinterpret_cast<mozilla::dom::Event*>(aObject),
279
0
             "Multiple inheritance for mozilla::dom::Event is broken.");
280
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
281
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
282
0
  MOZ_ASSERT(!aCache->GetWrapper(),
283
0
             "You should probably not be using Wrap() directly; use "
284
0
             "GetOrCreateDOMReflector instead");
285
0
286
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
287
0
             "nsISupports must be on our primary inheritance chain");
288
0
289
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
290
0
  if (!global) {
291
0
    return false;
292
0
  }
293
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
294
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
295
0
296
0
  // That might have ended up wrapping us already, due to the wonders
297
0
  // of XBL.  Check for that, and bail out as needed.
298
0
  aReflector.set(aCache->GetWrapper());
299
0
  if (aReflector) {
300
#ifdef DEBUG
301
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
302
#endif // DEBUG
303
    return true;
304
0
  }
305
0
306
0
  JSAutoRealm ar(aCx, global);
307
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
308
0
  if (!canonicalProto) {
309
0
    return false;
310
0
  }
311
0
  JS::Rooted<JSObject*> proto(aCx);
312
0
  if (aGivenProto) {
313
0
    proto = aGivenProto;
314
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
315
0
    // coming in, we changed compartments to that of "parent" so may need
316
0
    // to wrap the proto here.
317
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
318
0
      if (!JS_WrapObject(aCx, &proto)) {
319
0
        return false;
320
0
      }
321
0
    }
322
0
  } else {
323
0
    proto = canonicalProto;
324
0
  }
325
0
326
0
  BindingJSObjectCreator<mozilla::dom::MediaKeyError> creator(aCx);
327
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
328
0
  if (!aReflector) {
329
0
    return false;
330
0
  }
331
0
332
0
  aCache->SetWrapper(aReflector);
333
0
334
0
  // Important: do unforgeable property setup after we have handed
335
0
  // over ownership of the C++ object to obj as needed, so that if
336
0
  // we fail and it ends up GCed it won't have problems in the
337
0
  // finalizer trying to drop its ownership of the C++ object.
338
0
  JS::Rooted<JSObject*> unforgeableHolder(aCx,
339
0
    &js::GetReservedSlot(canonicalProto, DOM_INTERFACE_PROTO_SLOTS_BASE).toObject());
340
0
  if (!JS_InitializePropertiesFromCompatibleNativeObject(aCx, aReflector, unforgeableHolder)) {
341
0
    aCache->ReleaseWrapper(aObject);
342
0
    aCache->ClearWrapper();
343
0
    return false;
344
0
  }
345
0
  creator.InitializationSucceeded();
346
0
347
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
348
0
             aCache->GetWrapperPreserveColor() == aReflector);
349
0
  // If proto != canonicalProto, we have to preserve our wrapper;
350
0
  // otherwise we won't be able to properly recreate it later, since
351
0
  // we won't know what proto to use.  Note that we don't check
352
0
  // aGivenProto here, since it's entirely possible (and even
353
0
  // somewhat common) to have a non-null aGivenProto which is the
354
0
  // same as canonicalProto.
355
0
  if (proto != canonicalProto) {
356
0
    PreserveWrapper(aObject);
357
0
  }
358
0
359
0
  return true;
360
0
}
361
362
const NativePropertyHooks sNativePropertyHooks[] = { {
363
  nullptr,
364
  nullptr,
365
  nullptr,
366
  { sNativeProperties.Upcast(), nullptr },
367
  prototypes::id::MediaKeyError,
368
  constructors::id::MediaKeyError,
369
  Event_Binding::sNativePropertyHooks,
370
  &DefaultXrayExpandoObjectClass
371
} };
372
373
void
374
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
375
0
{
376
0
  JS::Handle<JSObject*> parentProto(Event_Binding::GetProtoObjectHandle(aCx));
377
0
  if (!parentProto) {
378
0
    return;
379
0
  }
380
0
381
0
  JS::Handle<JSObject*> constructorProto(Event_Binding::GetConstructorObjectHandle(aCx));
382
0
  if (!constructorProto) {
383
0
    return;
384
0
  }
385
0
386
0
  static bool sIdsInited = false;
387
0
  if (!sIdsInited && NS_IsMainThread()) {
388
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
389
0
      return;
390
0
    }
391
0
    sIdsInited = true;
392
0
  }
393
0
394
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::MediaKeyError);
395
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::MediaKeyError);
396
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
397
0
                              &sPrototypeClass.mBase, protoCache,
398
0
                              nullptr,
399
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
400
0
                              interfaceCache,
401
0
                              sNativeProperties.Upcast(),
402
0
                              nullptr,
403
0
                              "MediaKeyError", aDefineOnGlobal,
404
0
                              nullptr,
405
0
                              false);
406
0
407
0
  JS::Rooted<JSObject*> unforgeableHolder(aCx);
408
0
  {
409
0
    JS::Rooted<JSObject*> holderProto(aCx, *protoCache);
410
0
    unforgeableHolder = JS_NewObjectWithoutMetadata(aCx, sClass.ToJSClass(), holderProto);
411
0
    if (!unforgeableHolder) {
412
0
      *protoCache = nullptr;
413
0
      if (interfaceCache) {
414
0
        *interfaceCache = nullptr;
415
0
      }
416
0
      return;
417
0
    }
418
0
  }
419
0
420
0
  if (!DefineUnforgeableAttributes(aCx, unforgeableHolder, sUnforgeableAttributes)) {
421
0
    *protoCache = nullptr;
422
0
    if (interfaceCache) {
423
0
      *interfaceCache = nullptr;
424
0
    }
425
0
    return;
426
0
  }
427
0
428
0
  if (*protoCache) {
429
0
    js::SetReservedSlot(*protoCache, DOM_INTERFACE_PROTO_SLOTS_BASE,
430
0
                        JS::ObjectValue(*unforgeableHolder));
431
0
  }
432
0
}
433
434
JSObject*
435
GetConstructorObject(JSContext* aCx)
436
0
{
437
0
  return GetConstructorObjectHandle(aCx);
438
0
}
439
440
} // namespace MediaKeyError_Binding
441
442
443
444
} // namespace dom
445
} // namespace mozilla