Coverage Report

Created: 2018-09-25 14:53

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