Coverage Report

Created: 2018-09-25 14:53

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