Coverage Report

Created: 2018-09-25 14:53

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