Coverage Report

Created: 2018-09-25 14:53

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