Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/AudioWorkletGlobalScopeBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM AudioWorkletGlobalScope.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "AudioWorkletGlobalScopeBinding.h"
4
#include "FunctionBinding.h"
5
#include "WorkletGlobalScopeBinding.h"
6
#include "WrapperFactory.h"
7
#include "mozilla/FloatingPoint.h"
8
#include "mozilla/OwningNonNull.h"
9
#include "mozilla/dom/AudioWorkletGlobalScope.h"
10
#include "mozilla/dom/BindingUtils.h"
11
#include "mozilla/dom/DOMJSClass.h"
12
#include "mozilla/dom/NonRefcountedDOMObject.h"
13
#include "mozilla/dom/PrimitiveConversions.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 AudioWorkletGlobalScope_Binding {
23
24
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<WorkletGlobalScope_Binding::NativeType>::value,
25
              "Can't inherit from an interface with a different ownership model.");
26
27
MOZ_CAN_RUN_SCRIPT static bool
28
registerProcessor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioWorkletGlobalScope* self, const JSJitMethodCallArgs& args)
29
0
{
30
0
  AUTO_PROFILER_LABEL_FAST("AudioWorkletGlobalScope.registerProcessor", DOM, cx);
31
0
32
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
33
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "AudioWorkletGlobalScope.registerProcessor");
34
0
  }
35
0
  binding_detail::FakeString arg0;
36
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
37
0
    return false;
38
0
  }
39
0
  RootedCallback<OwningNonNull<binding_detail::FastVoidFunction>> arg1(cx);
40
0
  if (args[1].isObject()) {
41
0
    if (JS::IsCallable(&args[1].toObject())) {
42
0
    { // scope for tempRoot and tempGlobalRoot if needed
43
0
      arg1 = new binding_detail::FastVoidFunction(&args[1].toObject(), JS::CurrentGlobalOrNull(cx));
44
0
    }
45
0
    } else {
46
0
      ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "Argument 2 of AudioWorkletGlobalScope.registerProcessor");
47
0
      return false;
48
0
    }
49
0
  } else {
50
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of AudioWorkletGlobalScope.registerProcessor");
51
0
    return false;
52
0
  }
53
0
  self->RegisterProcessor(NonNullHelper(Constify(arg0)), NonNullHelper(arg1));
54
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
55
0
  args.rval().setUndefined();
56
0
  return true;
57
0
}
58
59
static const JSJitInfo registerProcessor_methodinfo = {
60
  { (JSJitGetterOp)registerProcessor },
61
  { prototypes::id::AudioWorkletGlobalScope },
62
  { PrototypeTraits<prototypes::id::AudioWorkletGlobalScope>::Depth },
63
  JSJitInfo::Method,
64
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
65
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
66
  false,  /* isInfallible. False in setters. */
67
  false,  /* isMovable.  Not relevant for setters. */
68
  false, /* isEliminatable.  Not relevant for setters. */
69
  false, /* isAlwaysInSlot.  Only relevant for getters. */
70
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
71
  false,  /* isTypedMethod.  Only relevant for methods. */
72
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
73
};
74
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
75
static_assert(0 < 1, "There is no slot for us");
76
77
MOZ_CAN_RUN_SCRIPT static bool
78
get_currentFrame(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioWorkletGlobalScope* self, JSJitGetterCallArgs args)
79
0
{
80
0
  AUTO_PROFILER_LABEL_FAST("get AudioWorkletGlobalScope.currentFrame", DOM, cx);
81
0
82
0
  uint64_t result(self->CurrentFrame());
83
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
84
0
  args.rval().set(JS_NumberValue(double(result)));
85
0
  return true;
86
0
}
87
88
static const JSJitInfo currentFrame_getterinfo = {
89
  { (JSJitGetterOp)get_currentFrame },
90
  { prototypes::id::AudioWorkletGlobalScope },
91
  { PrototypeTraits<prototypes::id::AudioWorkletGlobalScope>::Depth },
92
  JSJitInfo::Getter,
93
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
94
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
95
  true,  /* isInfallible. False in setters. */
96
  false,  /* isMovable.  Not relevant for setters. */
97
  false, /* isEliminatable.  Not relevant for setters. */
98
  false, /* isAlwaysInSlot.  Only relevant for getters. */
99
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
100
  false,  /* isTypedMethod.  Only relevant for methods. */
101
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
102
};
103
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
104
static_assert(0 < 1, "There is no slot for us");
105
106
MOZ_CAN_RUN_SCRIPT static bool
107
get_currentTime(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioWorkletGlobalScope* self, JSJitGetterCallArgs args)
108
0
{
109
0
  AUTO_PROFILER_LABEL_FAST("get AudioWorkletGlobalScope.currentTime", DOM, cx);
110
0
111
0
  double result(self->CurrentTime());
112
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
113
0
  args.rval().set(JS_NumberValue(double(result)));
114
0
  return true;
115
0
}
116
117
static const JSJitInfo currentTime_getterinfo = {
118
  { (JSJitGetterOp)get_currentTime },
119
  { prototypes::id::AudioWorkletGlobalScope },
120
  { PrototypeTraits<prototypes::id::AudioWorkletGlobalScope>::Depth },
121
  JSJitInfo::Getter,
122
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
123
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
124
  true,  /* isInfallible. False in setters. */
125
  false,  /* isMovable.  Not relevant for setters. */
126
  false, /* isEliminatable.  Not relevant for setters. */
127
  false, /* isAlwaysInSlot.  Only relevant for getters. */
128
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
129
  false,  /* isTypedMethod.  Only relevant for methods. */
130
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
131
};
132
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
133
static_assert(0 < 1, "There is no slot for us");
134
135
MOZ_CAN_RUN_SCRIPT static bool
136
get_sampleRate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioWorkletGlobalScope* self, JSJitGetterCallArgs args)
137
0
{
138
0
  AUTO_PROFILER_LABEL_FAST("get AudioWorkletGlobalScope.sampleRate", DOM, cx);
139
0
140
0
  float result(self->SampleRate());
141
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
142
0
  args.rval().set(JS_NumberValue(double(result)));
143
0
  return true;
144
0
}
145
146
static const JSJitInfo sampleRate_getterinfo = {
147
  { (JSJitGetterOp)get_sampleRate },
148
  { prototypes::id::AudioWorkletGlobalScope },
149
  { PrototypeTraits<prototypes::id::AudioWorkletGlobalScope>::Depth },
150
  JSJitInfo::Getter,
151
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
152
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
153
  true,  /* isInfallible. False in setters. */
154
  false,  /* isMovable.  Not relevant for setters. */
155
  false, /* isEliminatable.  Not relevant for setters. */
156
  false, /* isAlwaysInSlot.  Only relevant for getters. */
157
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
158
  false,  /* isTypedMethod.  Only relevant for methods. */
159
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
160
};
161
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
162
static_assert(0 < 1, "There is no slot for us");
163
164
static void
165
_finalize(js::FreeOp* fop, JSObject* obj)
166
0
{
167
0
  mozilla::dom::AudioWorkletGlobalScope* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AudioWorkletGlobalScope>(obj);
168
0
  if (self) {
169
0
    ClearWrapper(self, self, obj);
170
0
    mozilla::dom::FinalizeGlobal(CastToJSFreeOp(fop), obj);
171
0
    AddForDeferredFinalization<mozilla::dom::AudioWorkletGlobalScope>(self);
172
0
  }
173
0
}
174
175
static size_t
176
_objectMoved(JSObject* obj, JSObject* old)
177
0
{
178
0
  mozilla::dom::AudioWorkletGlobalScope* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AudioWorkletGlobalScope>(obj);
179
0
  if (self) {
180
0
    UpdateWrapper(self, self, obj, old);
181
0
  }
182
0
183
0
  return 0;
184
0
}
185
186
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
187
#if defined(__clang__)
188
#pragma clang diagnostic push
189
#pragma clang diagnostic ignored "-Wmissing-braces"
190
#endif
191
static const JSFunctionSpec sMethods_specs[] = {
192
  JS_FNSPEC("registerProcessor", (GenericMethod<MaybeGlobalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&registerProcessor_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
193
  JS_FS_END
194
};
195
#if defined(__clang__)
196
#pragma clang diagnostic pop
197
#endif
198
199
200
static const Prefable<const JSFunctionSpec> sMethods[] = {
201
  { nullptr, &sMethods_specs[0] },
202
  { nullptr, nullptr }
203
};
204
205
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
206
#if defined(__clang__)
207
#pragma clang diagnostic push
208
#pragma clang diagnostic ignored "-Wmissing-braces"
209
#endif
210
static const JSPropertySpec sAttributes_specs[] = {
211
  { "currentFrame", JSPROP_ENUMERATE, GenericGetter<MaybeGlobalThisPolicy, ThrowExceptions>, &currentFrame_getterinfo, nullptr, nullptr },
212
  { "currentTime", JSPROP_ENUMERATE, GenericGetter<MaybeGlobalThisPolicy, ThrowExceptions>, &currentTime_getterinfo, nullptr, nullptr },
213
  { "sampleRate", JSPROP_ENUMERATE, GenericGetter<MaybeGlobalThisPolicy, ThrowExceptions>, &sampleRate_getterinfo, nullptr, nullptr },
214
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
215
};
216
#if defined(__clang__)
217
#pragma clang diagnostic pop
218
#endif
219
220
221
static const Prefable<const JSPropertySpec> sAttributes[] = {
222
  { nullptr, &sAttributes_specs[0] },
223
  { nullptr, nullptr }
224
};
225
226
227
static const NativePropertiesN<2> sNativeProperties = {
228
  false, 0,
229
  false, 0,
230
  true,  0 /* sMethods */,
231
  true,  1 /* sAttributes */,
232
  false, 0,
233
  false, 0,
234
  false, 0,
235
  -1,
236
  0,
237
  nullptr,
238
  {
239
    { sMethods, nullptr },
240
    { sAttributes, nullptr }
241
  }
242
};
243
244
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
245
  {
246
    "Function",
247
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
248
    &sBoringInterfaceObjectClassClassOps,
249
    JS_NULL_CLASS_SPEC,
250
    JS_NULL_CLASS_EXT,
251
    &sInterfaceObjectClassObjectOps
252
  },
253
  eInterface,
254
  true,
255
  prototypes::id::AudioWorkletGlobalScope,
256
  PrototypeTraits<prototypes::id::AudioWorkletGlobalScope>::Depth,
257
  &sEmptyNativePropertyHooks,
258
  "function AudioWorkletGlobalScope() {\n    [native code]\n}",
259
  WorkletGlobalScope_Binding::GetConstructorObject
260
};
261
262
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
263
  {
264
    "AudioWorkletGlobalScopePrototype",
265
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
266
    JS_NULL_CLASS_OPS,
267
    JS_NULL_CLASS_SPEC,
268
    JS_NULL_CLASS_EXT,
269
    JS_NULL_OBJECT_OPS
270
  },
271
  eGlobalInterfacePrototype,
272
  false,
273
  prototypes::id::AudioWorkletGlobalScope,
274
  PrototypeTraits<prototypes::id::AudioWorkletGlobalScope>::Depth,
275
  &sEmptyNativePropertyHooks,
276
  "[object AudioWorkletGlobalScopePrototype]",
277
  WorkletGlobalScope_Binding::GetProtoObject
278
};
279
280
static const js::ClassOps sClassOps = {
281
  nullptr, /* addProperty */
282
  nullptr,               /* delProperty */
283
  nullptr,               /* enumerate */
284
  mozilla::dom::EnumerateGlobal, /* newEnumerate */
285
  mozilla::dom::ResolveGlobal, /* resolve */
286
  mozilla::dom::MayResolveGlobal, /* mayResolve */
287
  _finalize, /* finalize */
288
  nullptr, /* call */
289
  nullptr,               /* hasInstance */
290
  nullptr,               /* construct */
291
  JS_GlobalObjectTraceHook, /* trace */
292
};
293
294
static const js::ClassExtension sClassExtension = {
295
  nullptr, /* weakmapKeyDelegateOp */
296
  _objectMoved /* objectMovedOp */
297
};
298
299
static const DOMJSClass sClass = {
300
  { "AudioWorkletGlobalScope",
301
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_DOM_GLOBAL | JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(DOM_GLOBAL_SLOTS),
302
    &sClassOps,
303
    JS_NULL_CLASS_SPEC,
304
    &sClassExtension,
305
    JS_NULL_OBJECT_OPS
306
  },
307
  { prototypes::id::WorkletGlobalScope, prototypes::id::AudioWorkletGlobalScope, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
308
  IsBaseOf<nsISupports, mozilla::dom::AudioWorkletGlobalScope >::value,
309
  &sEmptyNativePropertyHooks,
310
  FindAssociatedGlobalForNative<mozilla::dom::AudioWorkletGlobalScope>::Get,
311
  GetProtoObjectHandle,
312
  GetCCParticipant<mozilla::dom::AudioWorkletGlobalScope>::Get()
313
};
314
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
315
              "Must have the right minimal number of reserved slots.");
316
static_assert(JSCLASS_GLOBAL_APPLICATION_SLOTS >= 1,
317
              "Must have enough reserved slots.");
318
319
const JSClass*
320
GetJSClass()
321
0
{
322
0
  return sClass.ToJSClass();
323
0
}
324
325
bool
326
Wrap(JSContext* aCx, mozilla::dom::AudioWorkletGlobalScope* aObject, nsWrapperCache* aCache, JS::RealmOptions& aOptions, JSPrincipals* aPrincipal, bool aInitStandardClasses, JS::MutableHandle<JSObject*> aReflector)
327
0
{
328
0
  MOZ_ASSERT(static_cast<mozilla::dom::AudioWorkletGlobalScope*>(aObject) ==
329
0
             reinterpret_cast<mozilla::dom::AudioWorkletGlobalScope*>(aObject),
330
0
             "Multiple inheritance for mozilla::dom::AudioWorkletGlobalScope is broken.");
331
0
  MOZ_ASSERT(static_cast<mozilla::dom::WorkletGlobalScope*>(aObject) ==
332
0
             reinterpret_cast<mozilla::dom::WorkletGlobalScope*>(aObject),
333
0
             "Multiple inheritance for mozilla::dom::WorkletGlobalScope is broken.");
334
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
335
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
336
0
             "nsISupports must be on our primary inheritance chain");
337
0
338
0
  if (!CreateGlobal<mozilla::dom::AudioWorkletGlobalScope, GetProtoObjectHandle>(aCx,
339
0
                                   aObject,
340
0
                                   aCache,
341
0
                                   sClass.ToJSClass(),
342
0
                                   aOptions,
343
0
                                   aPrincipal,
344
0
                                   aInitStandardClasses,
345
0
                                   aReflector)) {
346
0
    aCache->ReleaseWrapper(aObject);
347
0
    aCache->ClearWrapper();
348
0
    return false;
349
0
  }
350
0
351
0
  // aReflector is a new global, so has a new realm.  Enter it
352
0
  // before doing anything with it.
353
0
  JSAutoRealm ar(aCx, aReflector);
354
0
355
0
  if (!DefineProperties(aCx, aReflector, sNativeProperties.Upcast(), nullptr)) {
356
0
    aCache->ReleaseWrapper(aObject);
357
0
    aCache->ClearWrapper();
358
0
    return false;
359
0
  }
360
0
361
0
362
0
  return true;
363
0
}
364
365
void
366
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
367
0
{
368
0
  JS::Handle<JSObject*> parentProto(WorkletGlobalScope_Binding::GetProtoObjectHandle(aCx));
369
0
  if (!parentProto) {
370
0
    return;
371
0
  }
372
0
373
0
  JS::Handle<JSObject*> constructorProto(WorkletGlobalScope_Binding::GetConstructorObjectHandle(aCx));
374
0
  if (!constructorProto) {
375
0
    return;
376
0
  }
377
0
378
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::AudioWorkletGlobalScope);
379
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::AudioWorkletGlobalScope);
380
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
381
0
                              &sPrototypeClass.mBase, protoCache,
382
0
                              nullptr,
383
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
384
0
                              interfaceCache,
385
0
                              sNativeProperties.Upcast(),
386
0
                              nullptr,
387
0
                              "AudioWorkletGlobalScope", aDefineOnGlobal,
388
0
                              nullptr,
389
0
                              true);
390
0
391
0
  if (*&aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::AudioWorkletGlobalScope)) {
392
0
    bool succeeded;
393
0
    JS::Handle<JSObject*> prot = GetProtoObjectHandle(aCx);
394
0
    if (!JS_SetImmutablePrototype(aCx, prot, &succeeded)) {
395
0
      *protoCache = nullptr;
396
0
      if (interfaceCache) {
397
0
        *interfaceCache = nullptr;
398
0
      }
399
0
      return;
400
0
    }
401
0
402
0
    MOZ_ASSERT(succeeded,
403
0
               "making a fresh prototype object's [[Prototype]] "
404
0
               "immutable can internally fail, but it should "
405
0
               "never be unsuccessful");
406
0
  }
407
0
}
408
409
JSObject*
410
GetConstructorObject(JSContext* aCx)
411
0
{
412
0
  return GetConstructorObjectHandle(aCx);
413
0
}
414
415
} // namespace AudioWorkletGlobalScope_Binding
416
417
418
419
} // namespace dom
420
} // namespace mozilla