Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/MediaErrorBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM MediaError.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "MediaErrorBinding.h"
4
#include "WrapperFactory.h"
5
#include "mozilla/OwningNonNull.h"
6
#include "mozilla/dom/BindingUtils.h"
7
#include "mozilla/dom/DOMJSClass.h"
8
#include "mozilla/dom/MediaError.h"
9
#include "mozilla/dom/NonRefcountedDOMObject.h"
10
#include "mozilla/dom/PrimitiveConversions.h"
11
#include "mozilla/dom/XrayExpandoClass.h"
12
13
namespace mozilla {
14
namespace dom {
15
16
namespace binding_detail {}; // Just to make sure it's known as a namespace
17
using namespace mozilla::dom::binding_detail;
18
19
20
namespace MediaError_Binding {
21
22
MOZ_CAN_RUN_SCRIPT static bool
23
get_code(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaError* self, JSJitGetterCallArgs args)
24
0
{
25
0
  AUTO_PROFILER_LABEL_FAST("get MediaError.code", DOM, cx);
26
0
27
0
  uint16_t result(self->Code());
28
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
29
0
  args.rval().setInt32(int32_t(result));
30
0
  return true;
31
0
}
32
33
static const JSJitInfo code_getterinfo = {
34
  { (JSJitGetterOp)get_code },
35
  { prototypes::id::MediaError },
36
  { PrototypeTraits<prototypes::id::MediaError>::Depth },
37
  JSJitInfo::Getter,
38
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
39
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
40
  true,  /* isInfallible. False in setters. */
41
  true,  /* isMovable.  Not relevant for setters. */
42
  true, /* isEliminatable.  Not relevant for setters. */
43
  false, /* isAlwaysInSlot.  Only relevant for getters. */
44
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
45
  false,  /* isTypedMethod.  Only relevant for methods. */
46
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
47
};
48
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
49
static_assert(0 < 1, "There is no slot for us");
50
51
MOZ_CAN_RUN_SCRIPT static bool
52
get_message(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaError* self, JSJitGetterCallArgs args)
53
0
{
54
0
  AUTO_PROFILER_LABEL_FAST("get MediaError.message", DOM, cx);
55
0
56
0
  DOMString result;
57
0
  self->GetMessage(result);
58
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
59
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
60
0
    return false;
61
0
  }
62
0
  return true;
63
0
}
64
65
static const JSJitInfo message_getterinfo = {
66
  { (JSJitGetterOp)get_message },
67
  { prototypes::id::MediaError },
68
  { PrototypeTraits<prototypes::id::MediaError>::Depth },
69
  JSJitInfo::Getter,
70
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
71
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
72
  false,  /* isInfallible. False in setters. */
73
  false,  /* isMovable.  Not relevant for setters. */
74
  false, /* isEliminatable.  Not relevant for setters. */
75
  false, /* isAlwaysInSlot.  Only relevant for getters. */
76
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
77
  false,  /* isTypedMethod.  Only relevant for methods. */
78
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
79
};
80
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
81
static_assert(0 < 1, "There is no slot for us");
82
83
static bool
84
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
85
0
{
86
0
  mozilla::dom::MediaError* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MediaError>(obj);
87
0
  // We don't want to preserve if we don't have a wrapper, and we
88
0
  // obviously can't preserve if we're not initialized.
89
0
  if (self && self->GetWrapperPreserveColor()) {
90
0
    PreserveWrapper(self);
91
0
  }
92
0
  return true;
93
0
}
94
95
static void
96
_finalize(js::FreeOp* fop, JSObject* obj)
97
0
{
98
0
  mozilla::dom::MediaError* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MediaError>(obj);
99
0
  if (self) {
100
0
    ClearWrapper(self, self, obj);
101
0
    AddForDeferredFinalization<mozilla::dom::MediaError>(self);
102
0
  }
103
0
}
104
105
static size_t
106
_objectMoved(JSObject* obj, JSObject* old)
107
0
{
108
0
  mozilla::dom::MediaError* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MediaError>(obj);
109
0
  if (self) {
110
0
    UpdateWrapper(self, self, obj, old);
111
0
  }
112
0
113
0
  return 0;
114
0
}
115
116
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
117
#if defined(__clang__)
118
#pragma clang diagnostic push
119
#pragma clang diagnostic ignored "-Wmissing-braces"
120
#endif
121
static const JSPropertySpec sAttributes_specs[] = {
122
  { "code", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &code_getterinfo, nullptr, nullptr },
123
  { "message", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &message_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(2 <= 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 ConstantSpec sConstants_specs[] = {
147
  { "MEDIA_ERR_ABORTED", JS::Int32Value(1) },
148
  { "MEDIA_ERR_NETWORK", JS::Int32Value(2) },
149
  { "MEDIA_ERR_DECODE", JS::Int32Value(3) },
150
  { "MEDIA_ERR_SRC_NOT_SUPPORTED", JS::Int32Value(4) },
151
  { 0, JS::UndefinedValue() }
152
};
153
#if defined(__clang__)
154
#pragma clang diagnostic pop
155
#endif
156
157
158
static const Prefable<const ConstantSpec> sConstants[] = {
159
  { nullptr, &sConstants_specs[0] },
160
  { nullptr, nullptr }
161
};
162
163
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
164
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
165
static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
166
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
167
168
169
static uint16_t sNativeProperties_sortedPropertyIndices[6];
170
static PropertyInfo sNativeProperties_propertyInfos[6];
171
172
static const NativePropertiesN<2> sNativeProperties = {
173
  false, 0,
174
  false, 0,
175
  false, 0,
176
  true,  0 /* sAttributes */,
177
  false, 0,
178
  false, 0,
179
  true,  1 /* sConstants */,
180
  -1,
181
  6,
182
  sNativeProperties_sortedPropertyIndices,
183
  {
184
    { sAttributes, &sNativeProperties_propertyInfos[0] },
185
    { sConstants, &sNativeProperties_propertyInfos[2] }
186
  }
187
};
188
static_assert(6 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
189
    "We have a property info count that is oversized");
190
191
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
192
  {
193
    "Function",
194
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
195
    &sBoringInterfaceObjectClassClassOps,
196
    JS_NULL_CLASS_SPEC,
197
    JS_NULL_CLASS_EXT,
198
    &sInterfaceObjectClassObjectOps
199
  },
200
  eInterface,
201
  true,
202
  prototypes::id::MediaError,
203
  PrototypeTraits<prototypes::id::MediaError>::Depth,
204
  sNativePropertyHooks,
205
  "function MediaError() {\n    [native code]\n}",
206
  JS::GetRealmFunctionPrototype
207
};
208
209
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
210
  {
211
    "MediaErrorPrototype",
212
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
213
    JS_NULL_CLASS_OPS,
214
    JS_NULL_CLASS_SPEC,
215
    JS_NULL_CLASS_EXT,
216
    JS_NULL_OBJECT_OPS
217
  },
218
  eInterfacePrototype,
219
  false,
220
  prototypes::id::MediaError,
221
  PrototypeTraits<prototypes::id::MediaError>::Depth,
222
  sNativePropertyHooks,
223
  "[object MediaErrorPrototype]",
224
  JS::GetRealmObjectPrototype
225
};
226
227
static const js::ClassOps sClassOps = {
228
  _addProperty, /* addProperty */
229
  nullptr,               /* delProperty */
230
  nullptr,               /* enumerate */
231
  nullptr, /* newEnumerate */
232
  nullptr, /* resolve */
233
  nullptr, /* mayResolve */
234
  _finalize, /* finalize */
235
  nullptr, /* call */
236
  nullptr,               /* hasInstance */
237
  nullptr,               /* construct */
238
  nullptr, /* trace */
239
};
240
241
static const js::ClassExtension sClassExtension = {
242
  nullptr, /* weakmapKeyDelegateOp */
243
  _objectMoved /* objectMovedOp */
244
};
245
246
static const DOMJSClass sClass = {
247
  { "MediaError",
248
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
249
    &sClassOps,
250
    JS_NULL_CLASS_SPEC,
251
    &sClassExtension,
252
    JS_NULL_OBJECT_OPS
253
  },
254
  { prototypes::id::MediaError, 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 },
255
  IsBaseOf<nsISupports, mozilla::dom::MediaError >::value,
256
  sNativePropertyHooks,
257
  FindAssociatedGlobalForNative<mozilla::dom::MediaError>::Get,
258
  GetProtoObjectHandle,
259
  GetCCParticipant<mozilla::dom::MediaError>::Get()
260
};
261
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
262
              "Must have the right minimal number of reserved slots.");
263
static_assert(1 >= 1,
264
              "Must have enough reserved slots.");
265
266
const JSClass*
267
GetJSClass()
268
0
{
269
0
  return sClass.ToJSClass();
270
0
}
271
272
bool
273
Wrap(JSContext* aCx, mozilla::dom::MediaError* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
274
0
{
275
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::MediaError>::value,
276
0
                "Shouldn't have wrappercached things that are not refcounted.");
277
0
  MOZ_ASSERT(static_cast<mozilla::dom::MediaError*>(aObject) ==
278
0
             reinterpret_cast<mozilla::dom::MediaError*>(aObject),
279
0
             "Multiple inheritance for mozilla::dom::MediaError 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::MediaError> 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
  creator.InitializationSucceeded();
334
0
335
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
336
0
             aCache->GetWrapperPreserveColor() == aReflector);
337
0
  // If proto != canonicalProto, we have to preserve our wrapper;
338
0
  // otherwise we won't be able to properly recreate it later, since
339
0
  // we won't know what proto to use.  Note that we don't check
340
0
  // aGivenProto here, since it's entirely possible (and even
341
0
  // somewhat common) to have a non-null aGivenProto which is the
342
0
  // same as canonicalProto.
343
0
  if (proto != canonicalProto) {
344
0
    PreserveWrapper(aObject);
345
0
  }
346
0
347
0
  return true;
348
0
}
349
350
const NativePropertyHooks sNativePropertyHooks[] = { {
351
  nullptr,
352
  nullptr,
353
  nullptr,
354
  { sNativeProperties.Upcast(), nullptr },
355
  prototypes::id::MediaError,
356
  constructors::id::MediaError,
357
  nullptr,
358
  &DefaultXrayExpandoObjectClass
359
} };
360
361
void
362
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
363
0
{
364
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
365
0
  if (!parentProto) {
366
0
    return;
367
0
  }
368
0
369
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
370
0
  if (!constructorProto) {
371
0
    return;
372
0
  }
373
0
374
0
  static bool sIdsInited = false;
375
0
  if (!sIdsInited && NS_IsMainThread()) {
376
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
377
0
      return;
378
0
    }
379
0
    sIdsInited = true;
380
0
  }
381
0
382
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::MediaError);
383
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::MediaError);
384
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
385
0
                              &sPrototypeClass.mBase, protoCache,
386
0
                              nullptr,
387
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
388
0
                              interfaceCache,
389
0
                              sNativeProperties.Upcast(),
390
0
                              nullptr,
391
0
                              "MediaError", aDefineOnGlobal,
392
0
                              nullptr,
393
0
                              false);
394
0
}
395
396
JSObject*
397
GetConstructorObject(JSContext* aCx)
398
0
{
399
0
  return GetConstructorObjectHandle(aCx);
400
0
}
401
402
} // namespace MediaError_Binding
403
404
405
406
} // namespace dom
407
} // namespace mozilla