Coverage Report

Created: 2018-09-25 14:53

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