Coverage Report

Created: 2018-09-25 14:53

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