Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/BaseAudioContextBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM BaseAudioContext.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "BaseAudioContextBinding.h"
4
#include "EventHandlerBinding.h"
5
#include "EventTargetBinding.h"
6
#include "PeriodicWaveBinding.h"
7
#include "WrapperFactory.h"
8
#include "jsapi.h"
9
#include "jsfriendapi.h"
10
#include "mozilla/FloatingPoint.h"
11
#include "mozilla/OwningNonNull.h"
12
#include "mozilla/Preferences.h"
13
#include "mozilla/dom/AnalyserNode.h"
14
#include "mozilla/dom/AudioBuffer.h"
15
#include "mozilla/dom/AudioBufferSourceNode.h"
16
#include "mozilla/dom/AudioContext.h"
17
#include "mozilla/dom/AudioDestinationNode.h"
18
#include "mozilla/dom/AudioListener.h"
19
#include "mozilla/dom/BindingUtils.h"
20
#include "mozilla/dom/BiquadFilterNode.h"
21
#include "mozilla/dom/ChannelMergerNode.h"
22
#include "mozilla/dom/ChannelSplitterNode.h"
23
#include "mozilla/dom/ConstantSourceNode.h"
24
#include "mozilla/dom/ConvolverNode.h"
25
#include "mozilla/dom/DOMException.h"
26
#include "mozilla/dom/DOMJSClass.h"
27
#include "mozilla/dom/DelayNode.h"
28
#include "mozilla/dom/DynamicsCompressorNode.h"
29
#include "mozilla/dom/GainNode.h"
30
#include "mozilla/dom/IIRFilterNode.h"
31
#include "mozilla/dom/NonRefcountedDOMObject.h"
32
#include "mozilla/dom/Nullable.h"
33
#include "mozilla/dom/OscillatorNode.h"
34
#include "mozilla/dom/PannerNode.h"
35
#include "mozilla/dom/PeriodicWave.h"
36
#include "mozilla/dom/PrimitiveConversions.h"
37
#include "mozilla/dom/Promise.h"
38
#include "mozilla/dom/ScriptProcessorNode.h"
39
#include "mozilla/dom/StereoPannerNode.h"
40
#include "mozilla/dom/ToJSValue.h"
41
#include "mozilla/dom/TypedArray.h"
42
#include "mozilla/dom/WaveShaperNode.h"
43
#include "mozilla/dom/Worklet.h"
44
#include "mozilla/dom/XrayExpandoClass.h"
45
46
namespace mozilla {
47
namespace dom {
48
49
namespace binding_detail {}; // Just to make sure it's known as a namespace
50
using namespace mozilla::dom::binding_detail;
51
52
53
namespace AudioContextStateValues {
54
extern const EnumEntry strings[4] = {
55
  {"suspended", 9},
56
  {"running", 7},
57
  {"closed", 6},
58
  { nullptr, 0 }
59
};
60
} // namespace AudioContextStateValues
61
62
bool
63
ToJSValue(JSContext* aCx, AudioContextState aArgument, JS::MutableHandle<JS::Value> aValue)
64
0
{
65
0
  MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(AudioContextStateValues::strings));
66
0
  JSString* resultStr =
67
0
    JS_NewStringCopyN(aCx, AudioContextStateValues::strings[uint32_t(aArgument)].value,
68
0
                      AudioContextStateValues::strings[uint32_t(aArgument)].length);
69
0
  if (!resultStr) {
70
0
    return false;
71
0
  }
72
0
  aValue.setString(resultStr);
73
0
  return true;
74
0
}
75
76
77
void
78
DecodeSuccessCallback::Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, AudioBuffer& decodedData, ErrorResult& aRv)
79
0
{
80
0
  JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
81
0
  JS::AutoValueVector argv(cx);
82
0
  if (!argv.resize(1)) {
83
0
    aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
84
0
    return;
85
0
  }
86
0
  unsigned argc = 1;
87
0
88
0
  do {
89
0
    if (!GetOrCreateDOMReflector(cx, decodedData, argv[0])) {
90
0
      MOZ_ASSERT(JS_IsExceptionPending(cx));
91
0
      aRv.Throw(NS_ERROR_UNEXPECTED);
92
0
      return;
93
0
    }
94
0
    break;
95
0
  } while (false);
96
0
97
0
  JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
98
0
  if (!JS::Call(cx, aThisVal, callable,
99
0
                JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
100
0
    aRv.NoteJSContextException(cx);
101
0
    return;
102
0
  }
103
0
}
104
105
106
107
void
108
DecodeErrorCallback::Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, DOMException& error, ErrorResult& aRv)
109
0
{
110
0
  JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
111
0
  JS::AutoValueVector argv(cx);
112
0
  if (!argv.resize(1)) {
113
0
    aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
114
0
    return;
115
0
  }
116
0
  unsigned argc = 1;
117
0
118
0
  do {
119
0
    if (!GetOrCreateDOMReflector(cx, error, argv[0])) {
120
0
      MOZ_ASSERT(JS_IsExceptionPending(cx));
121
0
      aRv.Throw(NS_ERROR_UNEXPECTED);
122
0
      return;
123
0
    }
124
0
    break;
125
0
  } while (false);
126
0
127
0
  JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
128
0
  if (!JS::Call(cx, aThisVal, callable,
129
0
                JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
130
0
    aRv.NoteJSContextException(cx);
131
0
    return;
132
0
  }
133
0
}
134
135
136
137
namespace binding_detail {
138
} // namespace binding_detail
139
140
141
namespace binding_detail {
142
} // namespace binding_detail
143
144
145
namespace BaseAudioContext_Binding {
146
147
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTarget_Binding::NativeType>::value,
148
              "Can't inherit from an interface with a different ownership model.");
149
150
MOZ_CAN_RUN_SCRIPT static bool
151
get_destination(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, JSJitGetterCallArgs args)
152
0
{
153
0
  AUTO_PROFILER_LABEL_FAST("get BaseAudioContext.destination", DOM, cx);
154
0
155
0
  auto result(StrongOrRawPtr<mozilla::dom::AudioDestinationNode>(self->Destination()));
156
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
157
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
158
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
159
0
    return false;
160
0
  }
161
0
  return true;
162
0
}
163
164
static const JSJitInfo destination_getterinfo = {
165
  { (JSJitGetterOp)get_destination },
166
  { prototypes::id::BaseAudioContext },
167
  { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
168
  JSJitInfo::Getter,
169
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
170
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
171
  false,  /* isInfallible. False in setters. */
172
  false,  /* isMovable.  Not relevant for setters. */
173
  false, /* isEliminatable.  Not relevant for setters. */
174
  false, /* isAlwaysInSlot.  Only relevant for getters. */
175
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
176
  false,  /* isTypedMethod.  Only relevant for methods. */
177
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
178
};
179
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
180
static_assert(0 < 1, "There is no slot for us");
181
182
MOZ_CAN_RUN_SCRIPT static bool
183
get_sampleRate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, JSJitGetterCallArgs args)
184
0
{
185
0
  AUTO_PROFILER_LABEL_FAST("get BaseAudioContext.sampleRate", DOM, cx);
186
0
187
0
  float result(self->SampleRate());
188
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
189
0
  args.rval().set(JS_NumberValue(double(result)));
190
0
  return true;
191
0
}
192
193
static const JSJitInfo sampleRate_getterinfo = {
194
  { (JSJitGetterOp)get_sampleRate },
195
  { prototypes::id::BaseAudioContext },
196
  { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
197
  JSJitInfo::Getter,
198
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
199
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
200
  true,  /* isInfallible. False in setters. */
201
  false,  /* isMovable.  Not relevant for setters. */
202
  false, /* isEliminatable.  Not relevant for setters. */
203
  false, /* isAlwaysInSlot.  Only relevant for getters. */
204
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
205
  false,  /* isTypedMethod.  Only relevant for methods. */
206
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
207
};
208
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
209
static_assert(0 < 1, "There is no slot for us");
210
211
MOZ_CAN_RUN_SCRIPT static bool
212
get_currentTime(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, JSJitGetterCallArgs args)
213
0
{
214
0
  AUTO_PROFILER_LABEL_FAST("get BaseAudioContext.currentTime", DOM, cx);
215
0
216
0
  double result(self->CurrentTime());
217
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
218
0
  args.rval().set(JS_NumberValue(double(result)));
219
0
  return true;
220
0
}
221
222
static const JSJitInfo currentTime_getterinfo = {
223
  { (JSJitGetterOp)get_currentTime },
224
  { prototypes::id::BaseAudioContext },
225
  { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
226
  JSJitInfo::Getter,
227
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
228
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
229
  true,  /* isInfallible. False in setters. */
230
  false,  /* isMovable.  Not relevant for setters. */
231
  false, /* isEliminatable.  Not relevant for setters. */
232
  false, /* isAlwaysInSlot.  Only relevant for getters. */
233
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
234
  false,  /* isTypedMethod.  Only relevant for methods. */
235
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
236
};
237
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
238
static_assert(0 < 1, "There is no slot for us");
239
240
MOZ_CAN_RUN_SCRIPT static bool
241
get_listener(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, JSJitGetterCallArgs args)
242
0
{
243
0
  AUTO_PROFILER_LABEL_FAST("get BaseAudioContext.listener", DOM, cx);
244
0
245
0
  auto result(StrongOrRawPtr<mozilla::dom::AudioListener>(self->Listener()));
246
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
247
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
248
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
249
0
    return false;
250
0
  }
251
0
  return true;
252
0
}
253
254
static const JSJitInfo listener_getterinfo = {
255
  { (JSJitGetterOp)get_listener },
256
  { prototypes::id::BaseAudioContext },
257
  { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
258
  JSJitInfo::Getter,
259
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
260
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
261
  false,  /* isInfallible. False in setters. */
262
  false,  /* isMovable.  Not relevant for setters. */
263
  false, /* isEliminatable.  Not relevant for setters. */
264
  false, /* isAlwaysInSlot.  Only relevant for getters. */
265
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
266
  false,  /* isTypedMethod.  Only relevant for methods. */
267
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
268
};
269
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
270
static_assert(0 < 1, "There is no slot for us");
271
272
MOZ_CAN_RUN_SCRIPT static bool
273
get_state(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, JSJitGetterCallArgs args)
274
0
{
275
0
  AUTO_PROFILER_LABEL_FAST("get BaseAudioContext.state", DOM, cx);
276
0
277
0
  AudioContextState result(self->State());
278
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
279
0
  if (!ToJSValue(cx, result, args.rval())) {
280
0
    return false;
281
0
  }
282
0
  return true;
283
0
}
284
285
static const JSJitInfo state_getterinfo = {
286
  { (JSJitGetterOp)get_state },
287
  { prototypes::id::BaseAudioContext },
288
  { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
289
  JSJitInfo::Getter,
290
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
291
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
292
  false,  /* isInfallible. False in setters. */
293
  false,  /* isMovable.  Not relevant for setters. */
294
  false, /* isEliminatable.  Not relevant for setters. */
295
  false, /* isAlwaysInSlot.  Only relevant for getters. */
296
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
297
  false,  /* isTypedMethod.  Only relevant for methods. */
298
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
299
};
300
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
301
static_assert(0 < 1, "There is no slot for us");
302
303
MOZ_CAN_RUN_SCRIPT static bool
304
get_audioWorklet(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, JSJitGetterCallArgs args)
305
0
{
306
0
  AUTO_PROFILER_LABEL_FAST("get BaseAudioContext.audioWorklet", DOM, cx);
307
0
308
0
  FastErrorResult rv;
309
0
  auto result(StrongOrRawPtr<mozilla::dom::Worklet>(self->GetAudioWorklet(rv)));
310
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
311
0
    return false;
312
0
  }
313
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
314
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
315
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
316
0
    return false;
317
0
  }
318
0
  return true;
319
0
}
320
321
static const JSJitInfo audioWorklet_getterinfo = {
322
  { (JSJitGetterOp)get_audioWorklet },
323
  { prototypes::id::BaseAudioContext },
324
  { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
325
  JSJitInfo::Getter,
326
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
327
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
328
  false,  /* isInfallible. False in setters. */
329
  false,  /* isMovable.  Not relevant for setters. */
330
  false, /* isEliminatable.  Not relevant for setters. */
331
  false, /* isAlwaysInSlot.  Only relevant for getters. */
332
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
333
  false,  /* isTypedMethod.  Only relevant for methods. */
334
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
335
};
336
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
337
static_assert(0 < 1, "There is no slot for us");
338
339
MOZ_CAN_RUN_SCRIPT static bool
340
resume(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
341
0
{
342
0
  AUTO_PROFILER_LABEL_FAST("BaseAudioContext.resume", DOM, cx);
343
0
344
0
  FastErrorResult rv;
345
0
  auto result(StrongOrRawPtr<Promise>(self->Resume(rv)));
346
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
347
0
    return false;
348
0
  }
349
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
350
0
  if (!ToJSValue(cx, result, args.rval())) {
351
0
    return false;
352
0
  }
353
0
  return true;
354
0
}
355
356
MOZ_CAN_RUN_SCRIPT static bool
357
resume_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
358
0
{
359
0
  bool ok = resume(cx, obj, self, args);
360
0
  if (ok) {
361
0
    return true;
362
0
  }
363
0
  return ConvertExceptionToPromise(cx, args.rval());
364
0
}
365
366
static const JSJitInfo resume_methodinfo = {
367
  { (JSJitGetterOp)resume_promiseWrapper },
368
  { prototypes::id::BaseAudioContext },
369
  { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
370
  JSJitInfo::Method,
371
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
372
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
373
  false,  /* isInfallible. False in setters. */
374
  false,  /* isMovable.  Not relevant for setters. */
375
  false, /* isEliminatable.  Not relevant for setters. */
376
  false, /* isAlwaysInSlot.  Only relevant for getters. */
377
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
378
  false,  /* isTypedMethod.  Only relevant for methods. */
379
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
380
};
381
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
382
static_assert(0 < 1, "There is no slot for us");
383
384
MOZ_CAN_RUN_SCRIPT static bool
385
get_onstatechange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, JSJitGetterCallArgs args)
386
0
{
387
0
  AUTO_PROFILER_LABEL_FAST("get BaseAudioContext.onstatechange", DOM, cx);
388
0
389
0
  RefPtr<EventHandlerNonNull> result(self->GetOnstatechange());
390
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
391
0
  if (result) {
392
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
393
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
394
0
      return false;
395
0
    }
396
0
    return true;
397
0
  } else {
398
0
    args.rval().setNull();
399
0
    return true;
400
0
  }
401
0
}
402
403
MOZ_CAN_RUN_SCRIPT static bool
404
set_onstatechange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, JSJitSetterCallArgs args)
405
0
{
406
0
  AUTO_PROFILER_LABEL_FAST("set BaseAudioContext.onstatechange", DOM, cx);
407
0
408
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
409
0
  if (args[0].isObject()) {
410
0
    { // scope for tempRoot and tempGlobalRoot if needed
411
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
412
0
    }
413
0
  } else {
414
0
    arg0 = nullptr;
415
0
  }
416
0
  self->SetOnstatechange(Constify(arg0));
417
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
418
0
419
0
  return true;
420
0
}
421
422
static const JSJitInfo onstatechange_getterinfo = {
423
  { (JSJitGetterOp)get_onstatechange },
424
  { prototypes::id::BaseAudioContext },
425
  { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
426
  JSJitInfo::Getter,
427
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
428
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
429
  false,  /* isInfallible. False in setters. */
430
  false,  /* isMovable.  Not relevant for setters. */
431
  false, /* isEliminatable.  Not relevant for setters. */
432
  false, /* isAlwaysInSlot.  Only relevant for getters. */
433
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
434
  false,  /* isTypedMethod.  Only relevant for methods. */
435
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
436
};
437
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
438
static_assert(0 < 1, "There is no slot for us");
439
static const JSJitInfo onstatechange_setterinfo = {
440
  { (JSJitGetterOp)set_onstatechange },
441
  { prototypes::id::BaseAudioContext },
442
  { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
443
  JSJitInfo::Setter,
444
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
445
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
446
  false,  /* isInfallible. False in setters. */
447
  false,  /* isMovable.  Not relevant for setters. */
448
  false, /* isEliminatable.  Not relevant for setters. */
449
  false, /* isAlwaysInSlot.  Only relevant for getters. */
450
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
451
  false,  /* isTypedMethod.  Only relevant for methods. */
452
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
453
};
454
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
455
static_assert(0 < 1, "There is no slot for us");
456
457
MOZ_CAN_RUN_SCRIPT static bool
458
createBuffer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
459
0
{
460
0
  AUTO_PROFILER_LABEL_FAST("BaseAudioContext.createBuffer", DOM, cx);
461
0
462
0
  if (MOZ_UNLIKELY(args.length() < 3)) {
463
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "BaseAudioContext.createBuffer");
464
0
  }
465
0
  uint32_t arg0;
466
0
  if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
467
0
    return false;
468
0
  }
469
0
  uint32_t arg1;
470
0
  if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) {
471
0
    return false;
472
0
  }
473
0
  float arg2;
474
0
  if (!ValueToPrimitive<float, eDefault>(cx, args[2], &arg2)) {
475
0
    return false;
476
0
  } else if (!mozilla::IsFinite(arg2)) {
477
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 3 of BaseAudioContext.createBuffer");
478
0
    return false;
479
0
  }
480
0
  FastErrorResult rv;
481
0
  auto result(StrongOrRawPtr<mozilla::dom::AudioBuffer>(self->CreateBuffer(arg0, arg1, arg2, rv)));
482
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
483
0
    return false;
484
0
  }
485
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
486
0
  static_assert(!IsPointer<decltype(result)>::value,
487
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
488
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
489
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
490
0
    return false;
491
0
  }
492
0
  return true;
493
0
}
494
495
static const JSJitInfo createBuffer_methodinfo = {
496
  { (JSJitGetterOp)createBuffer },
497
  { prototypes::id::BaseAudioContext },
498
  { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
499
  JSJitInfo::Method,
500
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
501
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
502
  false,  /* isInfallible. False in setters. */
503
  false,  /* isMovable.  Not relevant for setters. */
504
  false, /* isEliminatable.  Not relevant for setters. */
505
  false, /* isAlwaysInSlot.  Only relevant for getters. */
506
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
507
  false,  /* isTypedMethod.  Only relevant for methods. */
508
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
509
};
510
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
511
static_assert(0 < 1, "There is no slot for us");
512
513
MOZ_CAN_RUN_SCRIPT static bool
514
decodeAudioData(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
515
0
{
516
0
  AUTO_PROFILER_LABEL_FAST("BaseAudioContext.decodeAudioData", DOM, cx);
517
0
518
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
519
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "BaseAudioContext.decodeAudioData");
520
0
  }
521
0
  RootedSpiderMonkeyInterface<ArrayBuffer> arg0(cx);
522
0
  if (args[0].isObject()) {
523
0
    if (!arg0.Init(&args[0].toObject())) {
524
0
      ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of BaseAudioContext.decodeAudioData", "ArrayBuffer");
525
0
      return false;
526
0
    }
527
0
  } else {
528
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of BaseAudioContext.decodeAudioData");
529
0
    return false;
530
0
  }
531
0
  Optional<OwningNonNull<DecodeSuccessCallback>> arg1;
532
0
  if (args.hasDefined(1)) {
533
0
    arg1.Construct();
534
0
    if (args[1].isObject()) {
535
0
      if (JS::IsCallable(&args[1].toObject())) {
536
0
      { // scope for tempRoot and tempGlobalRoot if needed
537
0
        JS::Rooted<JSObject*> tempRoot(cx, &args[1].toObject());
538
0
        JS::Rooted<JSObject*> tempGlobalRoot(cx, JS::CurrentGlobalOrNull(cx));
539
0
        arg1.Value() = new DecodeSuccessCallback(cx, tempRoot, tempGlobalRoot, GetIncumbentGlobal());
540
0
      }
541
0
      } else {
542
0
        ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "Argument 2 of BaseAudioContext.decodeAudioData");
543
0
        return false;
544
0
      }
545
0
    } else {
546
0
      ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of BaseAudioContext.decodeAudioData");
547
0
      return false;
548
0
    }
549
0
  }
550
0
  Optional<OwningNonNull<DecodeErrorCallback>> arg2;
551
0
  if (args.hasDefined(2)) {
552
0
    arg2.Construct();
553
0
    if (args[2].isObject()) {
554
0
      if (JS::IsCallable(&args[2].toObject())) {
555
0
      { // scope for tempRoot and tempGlobalRoot if needed
556
0
        JS::Rooted<JSObject*> tempRoot(cx, &args[2].toObject());
557
0
        JS::Rooted<JSObject*> tempGlobalRoot(cx, JS::CurrentGlobalOrNull(cx));
558
0
        arg2.Value() = new DecodeErrorCallback(cx, tempRoot, tempGlobalRoot, GetIncumbentGlobal());
559
0
      }
560
0
      } else {
561
0
        ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "Argument 3 of BaseAudioContext.decodeAudioData");
562
0
        return false;
563
0
      }
564
0
    } else {
565
0
      ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 3 of BaseAudioContext.decodeAudioData");
566
0
      return false;
567
0
    }
568
0
  }
569
0
  FastErrorResult rv;
570
0
  auto result(StrongOrRawPtr<Promise>(self->DecodeAudioData(Constify(arg0), NonNullHelper(Constify(arg1)), NonNullHelper(Constify(arg2)), rv)));
571
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
572
0
    return false;
573
0
  }
574
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
575
0
  if (!ToJSValue(cx, result, args.rval())) {
576
0
    return false;
577
0
  }
578
0
  return true;
579
0
}
580
581
MOZ_CAN_RUN_SCRIPT static bool
582
decodeAudioData_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
583
0
{
584
0
  bool ok = decodeAudioData(cx, obj, self, args);
585
0
  if (ok) {
586
0
    return true;
587
0
  }
588
0
  return ConvertExceptionToPromise(cx, args.rval());
589
0
}
590
591
static const JSJitInfo decodeAudioData_methodinfo = {
592
  { (JSJitGetterOp)decodeAudioData_promiseWrapper },
593
  { prototypes::id::BaseAudioContext },
594
  { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
595
  JSJitInfo::Method,
596
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
597
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
598
  false,  /* isInfallible. False in setters. */
599
  false,  /* isMovable.  Not relevant for setters. */
600
  false, /* isEliminatable.  Not relevant for setters. */
601
  false, /* isAlwaysInSlot.  Only relevant for getters. */
602
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
603
  false,  /* isTypedMethod.  Only relevant for methods. */
604
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
605
};
606
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
607
static_assert(0 < 1, "There is no slot for us");
608
609
MOZ_CAN_RUN_SCRIPT static bool
610
createBufferSource(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
611
0
{
612
0
  AUTO_PROFILER_LABEL_FAST("BaseAudioContext.createBufferSource", DOM, cx);
613
0
614
0
  FastErrorResult rv;
615
0
  auto result(StrongOrRawPtr<mozilla::dom::AudioBufferSourceNode>(self->CreateBufferSource(rv)));
616
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
617
0
    return false;
618
0
  }
619
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
620
0
  static_assert(!IsPointer<decltype(result)>::value,
621
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
622
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
623
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
624
0
    return false;
625
0
  }
626
0
  return true;
627
0
}
628
629
static const JSJitInfo createBufferSource_methodinfo = {
630
  { (JSJitGetterOp)createBufferSource },
631
  { prototypes::id::BaseAudioContext },
632
  { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
633
  JSJitInfo::Method,
634
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
635
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
636
  false,  /* isInfallible. False in setters. */
637
  false,  /* isMovable.  Not relevant for setters. */
638
  false, /* isEliminatable.  Not relevant for setters. */
639
  false, /* isAlwaysInSlot.  Only relevant for getters. */
640
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
641
  false,  /* isTypedMethod.  Only relevant for methods. */
642
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
643
};
644
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
645
static_assert(0 < 1, "There is no slot for us");
646
647
MOZ_CAN_RUN_SCRIPT static bool
648
createConstantSource(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
649
0
{
650
0
  AUTO_PROFILER_LABEL_FAST("BaseAudioContext.createConstantSource", DOM, cx);
651
0
652
0
  FastErrorResult rv;
653
0
  auto result(StrongOrRawPtr<mozilla::dom::ConstantSourceNode>(self->CreateConstantSource(rv)));
654
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
655
0
    return false;
656
0
  }
657
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
658
0
  static_assert(!IsPointer<decltype(result)>::value,
659
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
660
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
661
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
662
0
    return false;
663
0
  }
664
0
  return true;
665
0
}
666
667
static const JSJitInfo createConstantSource_methodinfo = {
668
  { (JSJitGetterOp)createConstantSource },
669
  { prototypes::id::BaseAudioContext },
670
  { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
671
  JSJitInfo::Method,
672
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
673
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
674
  false,  /* isInfallible. False in setters. */
675
  false,  /* isMovable.  Not relevant for setters. */
676
  false, /* isEliminatable.  Not relevant for setters. */
677
  false, /* isAlwaysInSlot.  Only relevant for getters. */
678
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
679
  false,  /* isTypedMethod.  Only relevant for methods. */
680
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
681
};
682
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
683
static_assert(0 < 1, "There is no slot for us");
684
685
MOZ_CAN_RUN_SCRIPT static bool
686
createScriptProcessor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
687
0
{
688
0
  AUTO_PROFILER_LABEL_FAST("BaseAudioContext.createScriptProcessor", DOM, cx);
689
0
690
0
  uint32_t arg0;
691
0
  if (args.hasDefined(0)) {
692
0
    if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
693
0
      return false;
694
0
    }
695
0
  } else {
696
0
    arg0 = 0U;
697
0
  }
698
0
  uint32_t arg1;
699
0
  if (args.hasDefined(1)) {
700
0
    if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) {
701
0
      return false;
702
0
    }
703
0
  } else {
704
0
    arg1 = 2U;
705
0
  }
706
0
  uint32_t arg2;
707
0
  if (args.hasDefined(2)) {
708
0
    if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[2], &arg2)) {
709
0
      return false;
710
0
    }
711
0
  } else {
712
0
    arg2 = 2U;
713
0
  }
714
0
  FastErrorResult rv;
715
0
  auto result(StrongOrRawPtr<mozilla::dom::ScriptProcessorNode>(self->CreateScriptProcessor(arg0, arg1, arg2, rv)));
716
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
717
0
    return false;
718
0
  }
719
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
720
0
  static_assert(!IsPointer<decltype(result)>::value,
721
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
722
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
723
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
724
0
    return false;
725
0
  }
726
0
  return true;
727
0
}
728
729
static const JSJitInfo createScriptProcessor_methodinfo = {
730
  { (JSJitGetterOp)createScriptProcessor },
731
  { prototypes::id::BaseAudioContext },
732
  { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
733
  JSJitInfo::Method,
734
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
735
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
736
  false,  /* isInfallible. False in setters. */
737
  false,  /* isMovable.  Not relevant for setters. */
738
  false, /* isEliminatable.  Not relevant for setters. */
739
  false, /* isAlwaysInSlot.  Only relevant for getters. */
740
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
741
  false,  /* isTypedMethod.  Only relevant for methods. */
742
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
743
};
744
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
745
static_assert(0 < 1, "There is no slot for us");
746
747
MOZ_CAN_RUN_SCRIPT static bool
748
createAnalyser(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
749
0
{
750
0
  AUTO_PROFILER_LABEL_FAST("BaseAudioContext.createAnalyser", DOM, cx);
751
0
752
0
  FastErrorResult rv;
753
0
  auto result(StrongOrRawPtr<mozilla::dom::AnalyserNode>(self->CreateAnalyser(rv)));
754
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
755
0
    return false;
756
0
  }
757
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
758
0
  static_assert(!IsPointer<decltype(result)>::value,
759
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
760
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
761
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
762
0
    return false;
763
0
  }
764
0
  return true;
765
0
}
766
767
static const JSJitInfo createAnalyser_methodinfo = {
768
  { (JSJitGetterOp)createAnalyser },
769
  { prototypes::id::BaseAudioContext },
770
  { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
771
  JSJitInfo::Method,
772
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
773
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
774
  false,  /* isInfallible. False in setters. */
775
  false,  /* isMovable.  Not relevant for setters. */
776
  false, /* isEliminatable.  Not relevant for setters. */
777
  false, /* isAlwaysInSlot.  Only relevant for getters. */
778
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
779
  false,  /* isTypedMethod.  Only relevant for methods. */
780
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
781
};
782
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
783
static_assert(0 < 1, "There is no slot for us");
784
785
MOZ_CAN_RUN_SCRIPT static bool
786
createGain(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
787
0
{
788
0
  AUTO_PROFILER_LABEL_FAST("BaseAudioContext.createGain", DOM, cx);
789
0
790
0
  FastErrorResult rv;
791
0
  auto result(StrongOrRawPtr<mozilla::dom::GainNode>(self->CreateGain(rv)));
792
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
793
0
    return false;
794
0
  }
795
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
796
0
  static_assert(!IsPointer<decltype(result)>::value,
797
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
798
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
799
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
800
0
    return false;
801
0
  }
802
0
  return true;
803
0
}
804
805
static const JSJitInfo createGain_methodinfo = {
806
  { (JSJitGetterOp)createGain },
807
  { prototypes::id::BaseAudioContext },
808
  { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
809
  JSJitInfo::Method,
810
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
811
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
812
  false,  /* isInfallible. False in setters. */
813
  false,  /* isMovable.  Not relevant for setters. */
814
  false, /* isEliminatable.  Not relevant for setters. */
815
  false, /* isAlwaysInSlot.  Only relevant for getters. */
816
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
817
  false,  /* isTypedMethod.  Only relevant for methods. */
818
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
819
};
820
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
821
static_assert(0 < 1, "There is no slot for us");
822
823
MOZ_CAN_RUN_SCRIPT static bool
824
createDelay(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
825
0
{
826
0
  AUTO_PROFILER_LABEL_FAST("BaseAudioContext.createDelay", DOM, cx);
827
0
828
0
  double arg0;
829
0
  if (args.hasDefined(0)) {
830
0
    if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
831
0
      return false;
832
0
    } else if (!mozilla::IsFinite(arg0)) {
833
0
      ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 1 of BaseAudioContext.createDelay");
834
0
      return false;
835
0
    }
836
0
  } else {
837
0
    arg0 = 1.0;
838
0
  }
839
0
  FastErrorResult rv;
840
0
  auto result(StrongOrRawPtr<mozilla::dom::DelayNode>(self->CreateDelay(arg0, rv)));
841
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
842
0
    return false;
843
0
  }
844
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
845
0
  static_assert(!IsPointer<decltype(result)>::value,
846
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
847
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
848
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
849
0
    return false;
850
0
  }
851
0
  return true;
852
0
}
853
854
static const JSJitInfo createDelay_methodinfo = {
855
  { (JSJitGetterOp)createDelay },
856
  { prototypes::id::BaseAudioContext },
857
  { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
858
  JSJitInfo::Method,
859
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
860
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
861
  false,  /* isInfallible. False in setters. */
862
  false,  /* isMovable.  Not relevant for setters. */
863
  false, /* isEliminatable.  Not relevant for setters. */
864
  false, /* isAlwaysInSlot.  Only relevant for getters. */
865
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
866
  false,  /* isTypedMethod.  Only relevant for methods. */
867
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
868
};
869
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
870
static_assert(0 < 1, "There is no slot for us");
871
872
MOZ_CAN_RUN_SCRIPT static bool
873
createBiquadFilter(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
874
0
{
875
0
  AUTO_PROFILER_LABEL_FAST("BaseAudioContext.createBiquadFilter", DOM, cx);
876
0
877
0
  FastErrorResult rv;
878
0
  auto result(StrongOrRawPtr<mozilla::dom::BiquadFilterNode>(self->CreateBiquadFilter(rv)));
879
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
880
0
    return false;
881
0
  }
882
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
883
0
  static_assert(!IsPointer<decltype(result)>::value,
884
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
885
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
886
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
887
0
    return false;
888
0
  }
889
0
  return true;
890
0
}
891
892
static const JSJitInfo createBiquadFilter_methodinfo = {
893
  { (JSJitGetterOp)createBiquadFilter },
894
  { prototypes::id::BaseAudioContext },
895
  { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
896
  JSJitInfo::Method,
897
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
898
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
899
  false,  /* isInfallible. False in setters. */
900
  false,  /* isMovable.  Not relevant for setters. */
901
  false, /* isEliminatable.  Not relevant for setters. */
902
  false, /* isAlwaysInSlot.  Only relevant for getters. */
903
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
904
  false,  /* isTypedMethod.  Only relevant for methods. */
905
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
906
};
907
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
908
static_assert(0 < 1, "There is no slot for us");
909
910
MOZ_CAN_RUN_SCRIPT static bool
911
createIIRFilter(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
912
0
{
913
0
  AUTO_PROFILER_LABEL_FAST("BaseAudioContext.createIIRFilter", DOM, cx);
914
0
915
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
916
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "BaseAudioContext.createIIRFilter");
917
0
  }
918
0
  binding_detail::AutoSequence<double> arg0;
919
0
  if (args[0].isObject()) {
920
0
    JS::ForOfIterator iter(cx);
921
0
    if (!iter.init(args[0], JS::ForOfIterator::AllowNonIterable)) {
922
0
      return false;
923
0
    }
924
0
    if (!iter.valueIsIterable()) {
925
0
      ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 1 of BaseAudioContext.createIIRFilter");
926
0
      return false;
927
0
    }
928
0
    binding_detail::AutoSequence<double> &arr = arg0;
929
0
    JS::Rooted<JS::Value> temp(cx);
930
0
    while (true) {
931
0
      bool done;
932
0
      if (!iter.next(&temp, &done)) {
933
0
        return false;
934
0
      }
935
0
      if (done) {
936
0
        break;
937
0
      }
938
0
      double* slotPtr = arr.AppendElement(mozilla::fallible);
939
0
      if (!slotPtr) {
940
0
        JS_ReportOutOfMemory(cx);
941
0
        return false;
942
0
      }
943
0
      double& slot = *slotPtr;
944
0
      if (!ValueToPrimitive<double, eDefault>(cx, temp, &slot)) {
945
0
        return false;
946
0
      } else if (!mozilla::IsFinite(slot)) {
947
0
        ThrowErrorMessage(cx, MSG_NOT_FINITE, "Element of argument 1 of BaseAudioContext.createIIRFilter");
948
0
        return false;
949
0
      }
950
0
    }
951
0
  } else {
952
0
    ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 1 of BaseAudioContext.createIIRFilter");
953
0
    return false;
954
0
  }
955
0
  binding_detail::AutoSequence<double> arg1;
956
0
  if (args[1].isObject()) {
957
0
    JS::ForOfIterator iter(cx);
958
0
    if (!iter.init(args[1], JS::ForOfIterator::AllowNonIterable)) {
959
0
      return false;
960
0
    }
961
0
    if (!iter.valueIsIterable()) {
962
0
      ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 2 of BaseAudioContext.createIIRFilter");
963
0
      return false;
964
0
    }
965
0
    binding_detail::AutoSequence<double> &arr = arg1;
966
0
    JS::Rooted<JS::Value> temp(cx);
967
0
    while (true) {
968
0
      bool done;
969
0
      if (!iter.next(&temp, &done)) {
970
0
        return false;
971
0
      }
972
0
      if (done) {
973
0
        break;
974
0
      }
975
0
      double* slotPtr = arr.AppendElement(mozilla::fallible);
976
0
      if (!slotPtr) {
977
0
        JS_ReportOutOfMemory(cx);
978
0
        return false;
979
0
      }
980
0
      double& slot = *slotPtr;
981
0
      if (!ValueToPrimitive<double, eDefault>(cx, temp, &slot)) {
982
0
        return false;
983
0
      } else if (!mozilla::IsFinite(slot)) {
984
0
        ThrowErrorMessage(cx, MSG_NOT_FINITE, "Element of argument 2 of BaseAudioContext.createIIRFilter");
985
0
        return false;
986
0
      }
987
0
    }
988
0
  } else {
989
0
    ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 2 of BaseAudioContext.createIIRFilter");
990
0
    return false;
991
0
  }
992
0
  FastErrorResult rv;
993
0
  auto result(StrongOrRawPtr<mozilla::dom::IIRFilterNode>(self->CreateIIRFilter(Constify(arg0), Constify(arg1), rv)));
994
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
995
0
    return false;
996
0
  }
997
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
998
0
  static_assert(!IsPointer<decltype(result)>::value,
999
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
1000
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1001
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1002
0
    return false;
1003
0
  }
1004
0
  return true;
1005
0
}
1006
1007
static const JSJitInfo createIIRFilter_methodinfo = {
1008
  { (JSJitGetterOp)createIIRFilter },
1009
  { prototypes::id::BaseAudioContext },
1010
  { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
1011
  JSJitInfo::Method,
1012
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1013
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1014
  false,  /* isInfallible. False in setters. */
1015
  false,  /* isMovable.  Not relevant for setters. */
1016
  false, /* isEliminatable.  Not relevant for setters. */
1017
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1018
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1019
  false,  /* isTypedMethod.  Only relevant for methods. */
1020
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1021
};
1022
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1023
static_assert(0 < 1, "There is no slot for us");
1024
1025
MOZ_CAN_RUN_SCRIPT static bool
1026
createWaveShaper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
1027
0
{
1028
0
  AUTO_PROFILER_LABEL_FAST("BaseAudioContext.createWaveShaper", DOM, cx);
1029
0
1030
0
  FastErrorResult rv;
1031
0
  auto result(StrongOrRawPtr<mozilla::dom::WaveShaperNode>(self->CreateWaveShaper(rv)));
1032
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1033
0
    return false;
1034
0
  }
1035
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1036
0
  static_assert(!IsPointer<decltype(result)>::value,
1037
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
1038
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1039
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1040
0
    return false;
1041
0
  }
1042
0
  return true;
1043
0
}
1044
1045
static const JSJitInfo createWaveShaper_methodinfo = {
1046
  { (JSJitGetterOp)createWaveShaper },
1047
  { prototypes::id::BaseAudioContext },
1048
  { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
1049
  JSJitInfo::Method,
1050
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1051
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1052
  false,  /* isInfallible. False in setters. */
1053
  false,  /* isMovable.  Not relevant for setters. */
1054
  false, /* isEliminatable.  Not relevant for setters. */
1055
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1056
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1057
  false,  /* isTypedMethod.  Only relevant for methods. */
1058
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1059
};
1060
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1061
static_assert(0 < 1, "There is no slot for us");
1062
1063
MOZ_CAN_RUN_SCRIPT static bool
1064
createPanner(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
1065
0
{
1066
0
  AUTO_PROFILER_LABEL_FAST("BaseAudioContext.createPanner", DOM, cx);
1067
0
1068
0
  FastErrorResult rv;
1069
0
  auto result(StrongOrRawPtr<mozilla::dom::PannerNode>(self->CreatePanner(rv)));
1070
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1071
0
    return false;
1072
0
  }
1073
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1074
0
  static_assert(!IsPointer<decltype(result)>::value,
1075
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
1076
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1077
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1078
0
    return false;
1079
0
  }
1080
0
  return true;
1081
0
}
1082
1083
static const JSJitInfo createPanner_methodinfo = {
1084
  { (JSJitGetterOp)createPanner },
1085
  { prototypes::id::BaseAudioContext },
1086
  { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
1087
  JSJitInfo::Method,
1088
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1089
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1090
  false,  /* isInfallible. False in setters. */
1091
  false,  /* isMovable.  Not relevant for setters. */
1092
  false, /* isEliminatable.  Not relevant for setters. */
1093
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1094
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1095
  false,  /* isTypedMethod.  Only relevant for methods. */
1096
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1097
};
1098
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1099
static_assert(0 < 1, "There is no slot for us");
1100
1101
MOZ_CAN_RUN_SCRIPT static bool
1102
createStereoPanner(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
1103
0
{
1104
0
  AUTO_PROFILER_LABEL_FAST("BaseAudioContext.createStereoPanner", DOM, cx);
1105
0
1106
0
  FastErrorResult rv;
1107
0
  auto result(StrongOrRawPtr<mozilla::dom::StereoPannerNode>(self->CreateStereoPanner(rv)));
1108
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1109
0
    return false;
1110
0
  }
1111
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1112
0
  static_assert(!IsPointer<decltype(result)>::value,
1113
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
1114
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1115
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1116
0
    return false;
1117
0
  }
1118
0
  return true;
1119
0
}
1120
1121
static const JSJitInfo createStereoPanner_methodinfo = {
1122
  { (JSJitGetterOp)createStereoPanner },
1123
  { prototypes::id::BaseAudioContext },
1124
  { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
1125
  JSJitInfo::Method,
1126
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1127
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1128
  false,  /* isInfallible. False in setters. */
1129
  false,  /* isMovable.  Not relevant for setters. */
1130
  false, /* isEliminatable.  Not relevant for setters. */
1131
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1132
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1133
  false,  /* isTypedMethod.  Only relevant for methods. */
1134
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1135
};
1136
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1137
static_assert(0 < 1, "There is no slot for us");
1138
1139
MOZ_CAN_RUN_SCRIPT static bool
1140
createConvolver(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
1141
0
{
1142
0
  AUTO_PROFILER_LABEL_FAST("BaseAudioContext.createConvolver", DOM, cx);
1143
0
1144
0
  FastErrorResult rv;
1145
0
  auto result(StrongOrRawPtr<mozilla::dom::ConvolverNode>(self->CreateConvolver(rv)));
1146
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1147
0
    return false;
1148
0
  }
1149
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1150
0
  static_assert(!IsPointer<decltype(result)>::value,
1151
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
1152
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1153
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1154
0
    return false;
1155
0
  }
1156
0
  return true;
1157
0
}
1158
1159
static const JSJitInfo createConvolver_methodinfo = {
1160
  { (JSJitGetterOp)createConvolver },
1161
  { prototypes::id::BaseAudioContext },
1162
  { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
1163
  JSJitInfo::Method,
1164
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1165
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1166
  false,  /* isInfallible. False in setters. */
1167
  false,  /* isMovable.  Not relevant for setters. */
1168
  false, /* isEliminatable.  Not relevant for setters. */
1169
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1170
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1171
  false,  /* isTypedMethod.  Only relevant for methods. */
1172
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1173
};
1174
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1175
static_assert(0 < 1, "There is no slot for us");
1176
1177
MOZ_CAN_RUN_SCRIPT static bool
1178
createChannelSplitter(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
1179
0
{
1180
0
  AUTO_PROFILER_LABEL_FAST("BaseAudioContext.createChannelSplitter", DOM, cx);
1181
0
1182
0
  uint32_t arg0;
1183
0
  if (args.hasDefined(0)) {
1184
0
    if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
1185
0
      return false;
1186
0
    }
1187
0
  } else {
1188
0
    arg0 = 6U;
1189
0
  }
1190
0
  FastErrorResult rv;
1191
0
  auto result(StrongOrRawPtr<mozilla::dom::ChannelSplitterNode>(self->CreateChannelSplitter(arg0, rv)));
1192
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1193
0
    return false;
1194
0
  }
1195
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1196
0
  static_assert(!IsPointer<decltype(result)>::value,
1197
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
1198
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1199
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1200
0
    return false;
1201
0
  }
1202
0
  return true;
1203
0
}
1204
1205
static const JSJitInfo createChannelSplitter_methodinfo = {
1206
  { (JSJitGetterOp)createChannelSplitter },
1207
  { prototypes::id::BaseAudioContext },
1208
  { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
1209
  JSJitInfo::Method,
1210
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1211
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1212
  false,  /* isInfallible. False in setters. */
1213
  false,  /* isMovable.  Not relevant for setters. */
1214
  false, /* isEliminatable.  Not relevant for setters. */
1215
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1216
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1217
  false,  /* isTypedMethod.  Only relevant for methods. */
1218
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1219
};
1220
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1221
static_assert(0 < 1, "There is no slot for us");
1222
1223
MOZ_CAN_RUN_SCRIPT static bool
1224
createChannelMerger(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
1225
0
{
1226
0
  AUTO_PROFILER_LABEL_FAST("BaseAudioContext.createChannelMerger", DOM, cx);
1227
0
1228
0
  uint32_t arg0;
1229
0
  if (args.hasDefined(0)) {
1230
0
    if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
1231
0
      return false;
1232
0
    }
1233
0
  } else {
1234
0
    arg0 = 6U;
1235
0
  }
1236
0
  FastErrorResult rv;
1237
0
  auto result(StrongOrRawPtr<mozilla::dom::ChannelMergerNode>(self->CreateChannelMerger(arg0, rv)));
1238
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1239
0
    return false;
1240
0
  }
1241
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1242
0
  static_assert(!IsPointer<decltype(result)>::value,
1243
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
1244
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1245
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1246
0
    return false;
1247
0
  }
1248
0
  return true;
1249
0
}
1250
1251
static const JSJitInfo createChannelMerger_methodinfo = {
1252
  { (JSJitGetterOp)createChannelMerger },
1253
  { prototypes::id::BaseAudioContext },
1254
  { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
1255
  JSJitInfo::Method,
1256
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1257
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1258
  false,  /* isInfallible. False in setters. */
1259
  false,  /* isMovable.  Not relevant for setters. */
1260
  false, /* isEliminatable.  Not relevant for setters. */
1261
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1262
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1263
  false,  /* isTypedMethod.  Only relevant for methods. */
1264
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1265
};
1266
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1267
static_assert(0 < 1, "There is no slot for us");
1268
1269
MOZ_CAN_RUN_SCRIPT static bool
1270
createDynamicsCompressor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
1271
0
{
1272
0
  AUTO_PROFILER_LABEL_FAST("BaseAudioContext.createDynamicsCompressor", DOM, cx);
1273
0
1274
0
  FastErrorResult rv;
1275
0
  auto result(StrongOrRawPtr<mozilla::dom::DynamicsCompressorNode>(self->CreateDynamicsCompressor(rv)));
1276
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1277
0
    return false;
1278
0
  }
1279
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1280
0
  static_assert(!IsPointer<decltype(result)>::value,
1281
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
1282
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1283
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1284
0
    return false;
1285
0
  }
1286
0
  return true;
1287
0
}
1288
1289
static const JSJitInfo createDynamicsCompressor_methodinfo = {
1290
  { (JSJitGetterOp)createDynamicsCompressor },
1291
  { prototypes::id::BaseAudioContext },
1292
  { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
1293
  JSJitInfo::Method,
1294
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1295
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1296
  false,  /* isInfallible. False in setters. */
1297
  false,  /* isMovable.  Not relevant for setters. */
1298
  false, /* isEliminatable.  Not relevant for setters. */
1299
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1300
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1301
  false,  /* isTypedMethod.  Only relevant for methods. */
1302
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1303
};
1304
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1305
static_assert(0 < 1, "There is no slot for us");
1306
1307
MOZ_CAN_RUN_SCRIPT static bool
1308
createOscillator(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
1309
0
{
1310
0
  AUTO_PROFILER_LABEL_FAST("BaseAudioContext.createOscillator", DOM, cx);
1311
0
1312
0
  FastErrorResult rv;
1313
0
  auto result(StrongOrRawPtr<mozilla::dom::OscillatorNode>(self->CreateOscillator(rv)));
1314
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1315
0
    return false;
1316
0
  }
1317
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1318
0
  static_assert(!IsPointer<decltype(result)>::value,
1319
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
1320
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1321
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1322
0
    return false;
1323
0
  }
1324
0
  return true;
1325
0
}
1326
1327
static const JSJitInfo createOscillator_methodinfo = {
1328
  { (JSJitGetterOp)createOscillator },
1329
  { prototypes::id::BaseAudioContext },
1330
  { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
1331
  JSJitInfo::Method,
1332
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1333
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1334
  false,  /* isInfallible. False in setters. */
1335
  false,  /* isMovable.  Not relevant for setters. */
1336
  false, /* isEliminatable.  Not relevant for setters. */
1337
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1338
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1339
  false,  /* isTypedMethod.  Only relevant for methods. */
1340
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1341
};
1342
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1343
static_assert(0 < 1, "There is no slot for us");
1344
1345
MOZ_CAN_RUN_SCRIPT static bool
1346
createPeriodicWave(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
1347
0
{
1348
0
  AUTO_PROFILER_LABEL_FAST("BaseAudioContext.createPeriodicWave", DOM, cx);
1349
0
1350
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
1351
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "BaseAudioContext.createPeriodicWave");
1352
0
  }
1353
0
  RootedSpiderMonkeyInterface<Float32Array> arg0(cx);
1354
0
  if (args[0].isObject()) {
1355
0
    if (!arg0.Init(&args[0].toObject())) {
1356
0
      ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of BaseAudioContext.createPeriodicWave", "Float32Array");
1357
0
      return false;
1358
0
    }
1359
0
  } else {
1360
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of BaseAudioContext.createPeriodicWave");
1361
0
    return false;
1362
0
  }
1363
0
  RootedSpiderMonkeyInterface<Float32Array> arg1(cx);
1364
0
  if (args[1].isObject()) {
1365
0
    if (!arg1.Init(&args[1].toObject())) {
1366
0
      ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 2 of BaseAudioContext.createPeriodicWave", "Float32Array");
1367
0
      return false;
1368
0
    }
1369
0
  } else {
1370
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of BaseAudioContext.createPeriodicWave");
1371
0
    return false;
1372
0
  }
1373
0
  binding_detail::FastPeriodicWaveConstraints arg2;
1374
0
  if (!arg2.Init(cx, (args.hasDefined(2)) ? args[2] : JS::NullHandleValue,  "Argument 3 of BaseAudioContext.createPeriodicWave", false)) {
1375
0
    return false;
1376
0
  }
1377
0
  FastErrorResult rv;
1378
0
  auto result(StrongOrRawPtr<mozilla::dom::PeriodicWave>(self->CreatePeriodicWave(Constify(arg0), Constify(arg1), Constify(arg2), rv)));
1379
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1380
0
    return false;
1381
0
  }
1382
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1383
0
  static_assert(!IsPointer<decltype(result)>::value,
1384
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
1385
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1386
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1387
0
    return false;
1388
0
  }
1389
0
  return true;
1390
0
}
1391
1392
static const JSJitInfo createPeriodicWave_methodinfo = {
1393
  { (JSJitGetterOp)createPeriodicWave },
1394
  { prototypes::id::BaseAudioContext },
1395
  { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
1396
  JSJitInfo::Method,
1397
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1398
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1399
  false,  /* isInfallible. False in setters. */
1400
  false,  /* isMovable.  Not relevant for setters. */
1401
  false, /* isEliminatable.  Not relevant for setters. */
1402
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1403
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1404
  false,  /* isTypedMethod.  Only relevant for methods. */
1405
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1406
};
1407
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1408
static_assert(0 < 1, "There is no slot for us");
1409
1410
static bool
1411
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
1412
0
{
1413
0
  mozilla::dom::AudioContext* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AudioContext>(obj);
1414
0
  // We don't want to preserve if we don't have a wrapper, and we
1415
0
  // obviously can't preserve if we're not initialized.
1416
0
  if (self && self->GetWrapperPreserveColor()) {
1417
0
    PreserveWrapper(self);
1418
0
  }
1419
0
  return true;
1420
0
}
1421
1422
static void
1423
_finalize(js::FreeOp* fop, JSObject* obj)
1424
0
{
1425
0
  mozilla::dom::AudioContext* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AudioContext>(obj);
1426
0
  if (self) {
1427
0
    ClearWrapper(self, self, obj);
1428
0
    AddForDeferredFinalization<mozilla::dom::AudioContext>(self);
1429
0
  }
1430
0
}
1431
1432
static size_t
1433
_objectMoved(JSObject* obj, JSObject* old)
1434
0
{
1435
0
  mozilla::dom::AudioContext* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AudioContext>(obj);
1436
0
  if (self) {
1437
0
    UpdateWrapper(self, self, obj, old);
1438
0
  }
1439
0
1440
0
  return 0;
1441
0
}
1442
1443
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1444
#if defined(__clang__)
1445
#pragma clang diagnostic push
1446
#pragma clang diagnostic ignored "-Wmissing-braces"
1447
#endif
1448
static const JSFunctionSpec sMethods_specs[] = {
1449
  JS_FNSPEC("resume", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&resume_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1450
  JS_FNSPEC("createBuffer", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createBuffer_methodinfo), 3, JSPROP_ENUMERATE, nullptr),
1451
  JS_FNSPEC("decodeAudioData", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&decodeAudioData_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1452
  JS_FNSPEC("createBufferSource", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createBufferSource_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1453
  JS_FNSPEC("createConstantSource", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createConstantSource_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1454
  JS_FNSPEC("createScriptProcessor", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createScriptProcessor_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1455
  JS_FNSPEC("createAnalyser", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createAnalyser_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1456
  JS_FNSPEC("createGain", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createGain_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1457
  JS_FNSPEC("createDelay", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createDelay_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1458
  JS_FNSPEC("createBiquadFilter", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createBiquadFilter_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1459
  JS_FNSPEC("createIIRFilter", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createIIRFilter_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
1460
  JS_FNSPEC("createWaveShaper", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createWaveShaper_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1461
  JS_FNSPEC("createPanner", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createPanner_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1462
  JS_FNSPEC("createStereoPanner", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createStereoPanner_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1463
  JS_FNSPEC("createConvolver", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createConvolver_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1464
  JS_FNSPEC("createChannelSplitter", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createChannelSplitter_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1465
  JS_FNSPEC("createChannelMerger", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createChannelMerger_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1466
  JS_FNSPEC("createDynamicsCompressor", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createDynamicsCompressor_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1467
  JS_FNSPEC("createOscillator", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createOscillator_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1468
  JS_FNSPEC("createPeriodicWave", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createPeriodicWave_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
1469
  JS_FS_END
1470
};
1471
#if defined(__clang__)
1472
#pragma clang diagnostic pop
1473
#endif
1474
1475
1476
static const Prefable<const JSFunctionSpec> sMethods[] = {
1477
  { nullptr, &sMethods_specs[0] },
1478
  { nullptr, nullptr }
1479
};
1480
1481
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1482
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1483
static_assert(20 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1484
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1485
1486
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1487
#if defined(__clang__)
1488
#pragma clang diagnostic push
1489
#pragma clang diagnostic ignored "-Wmissing-braces"
1490
#endif
1491
static const JSPropertySpec sAttributes_specs[] = {
1492
  { "destination", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &destination_getterinfo, nullptr, nullptr },
1493
  { "sampleRate", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &sampleRate_getterinfo, nullptr, nullptr },
1494
  { "currentTime", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &currentTime_getterinfo, nullptr, nullptr },
1495
  { "listener", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &listener_getterinfo, nullptr, nullptr },
1496
  { "state", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &state_getterinfo, nullptr, nullptr },
1497
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
1498
  { "audioWorklet", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &audioWorklet_getterinfo, nullptr, nullptr },
1499
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
1500
  { "onstatechange", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onstatechange_getterinfo, GenericSetter<NormalThisPolicy>, &onstatechange_setterinfo },
1501
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1502
};
1503
#if defined(__clang__)
1504
#pragma clang diagnostic pop
1505
#endif
1506
1507
// Can't be const because the pref-enabled boolean needs to be writable
1508
static PrefableDisablers sAttributes_disablers6 = {
1509
  true, true, 0, nullptr
1510
};
1511
1512
static const Prefable<const JSPropertySpec> sAttributes[] = {
1513
  { nullptr, &sAttributes_specs[0] },
1514
  { &sAttributes_disablers6, &sAttributes_specs[6] },
1515
  { nullptr, &sAttributes_specs[8] },
1516
  { nullptr, nullptr }
1517
};
1518
1519
static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1520
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1521
static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1522
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1523
1524
1525
static uint16_t sNativeProperties_sortedPropertyIndices[27];
1526
static PropertyInfo sNativeProperties_propertyInfos[27];
1527
1528
static const NativePropertiesN<2> sNativeProperties = {
1529
  false, 0,
1530
  false, 0,
1531
  true,  0 /* sMethods */,
1532
  true,  1 /* sAttributes */,
1533
  false, 0,
1534
  false, 0,
1535
  false, 0,
1536
  -1,
1537
  27,
1538
  sNativeProperties_sortedPropertyIndices,
1539
  {
1540
    { sMethods, &sNativeProperties_propertyInfos[0] },
1541
    { sAttributes, &sNativeProperties_propertyInfos[20] }
1542
  }
1543
};
1544
static_assert(27 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
1545
    "We have a property info count that is oversized");
1546
1547
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
1548
  {
1549
    "Function",
1550
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
1551
    &sBoringInterfaceObjectClassClassOps,
1552
    JS_NULL_CLASS_SPEC,
1553
    JS_NULL_CLASS_EXT,
1554
    &sInterfaceObjectClassObjectOps
1555
  },
1556
  eInterface,
1557
  true,
1558
  prototypes::id::BaseAudioContext,
1559
  PrototypeTraits<prototypes::id::BaseAudioContext>::Depth,
1560
  sNativePropertyHooks,
1561
  "function BaseAudioContext() {\n    [native code]\n}",
1562
  EventTarget_Binding::GetConstructorObject
1563
};
1564
1565
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1566
  {
1567
    "BaseAudioContextPrototype",
1568
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
1569
    JS_NULL_CLASS_OPS,
1570
    JS_NULL_CLASS_SPEC,
1571
    JS_NULL_CLASS_EXT,
1572
    JS_NULL_OBJECT_OPS
1573
  },
1574
  eInterfacePrototype,
1575
  false,
1576
  prototypes::id::BaseAudioContext,
1577
  PrototypeTraits<prototypes::id::BaseAudioContext>::Depth,
1578
  sNativePropertyHooks,
1579
  "[object BaseAudioContextPrototype]",
1580
  EventTarget_Binding::GetProtoObject
1581
};
1582
1583
static const js::ClassOps sClassOps = {
1584
  _addProperty, /* addProperty */
1585
  nullptr,               /* delProperty */
1586
  nullptr,               /* enumerate */
1587
  nullptr, /* newEnumerate */
1588
  nullptr, /* resolve */
1589
  nullptr, /* mayResolve */
1590
  _finalize, /* finalize */
1591
  nullptr, /* call */
1592
  nullptr,               /* hasInstance */
1593
  nullptr,               /* construct */
1594
  nullptr, /* trace */
1595
};
1596
1597
static const js::ClassExtension sClassExtension = {
1598
  nullptr, /* weakmapKeyDelegateOp */
1599
  _objectMoved /* objectMovedOp */
1600
};
1601
1602
static const DOMJSClass sClass = {
1603
  { "BaseAudioContext",
1604
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
1605
    &sClassOps,
1606
    JS_NULL_CLASS_SPEC,
1607
    &sClassExtension,
1608
    JS_NULL_OBJECT_OPS
1609
  },
1610
  { prototypes::id::EventTarget, prototypes::id::BaseAudioContext, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
1611
  IsBaseOf<nsISupports, mozilla::dom::AudioContext >::value,
1612
  sNativePropertyHooks,
1613
  FindAssociatedGlobalForNative<mozilla::dom::AudioContext>::Get,
1614
  GetProtoObjectHandle,
1615
  GetCCParticipant<mozilla::dom::AudioContext>::Get()
1616
};
1617
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
1618
              "Must have the right minimal number of reserved slots.");
1619
static_assert(1 >= 1,
1620
              "Must have enough reserved slots.");
1621
1622
const JSClass*
1623
GetJSClass()
1624
0
{
1625
0
  return sClass.ToJSClass();
1626
0
}
1627
1628
bool
1629
Wrap(JSContext* aCx, mozilla::dom::AudioContext* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1630
0
{
1631
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::AudioContext>::value,
1632
0
                "Shouldn't have wrappercached things that are not refcounted.");
1633
0
  MOZ_ASSERT(static_cast<mozilla::dom::AudioContext*>(aObject) ==
1634
0
             reinterpret_cast<mozilla::dom::AudioContext*>(aObject),
1635
0
             "Multiple inheritance for mozilla::dom::AudioContext is broken.");
1636
0
  MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
1637
0
             reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
1638
0
             "Multiple inheritance for mozilla::dom::EventTarget is broken.");
1639
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1640
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1641
0
  MOZ_ASSERT(!aCache->GetWrapper(),
1642
0
             "You should probably not be using Wrap() directly; use "
1643
0
             "GetOrCreateDOMReflector instead");
1644
0
1645
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1646
0
             "nsISupports must be on our primary inheritance chain");
1647
0
1648
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1649
0
  if (!global) {
1650
0
    return false;
1651
0
  }
1652
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
1653
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
1654
0
1655
0
  // That might have ended up wrapping us already, due to the wonders
1656
0
  // of XBL.  Check for that, and bail out as needed.
1657
0
  aReflector.set(aCache->GetWrapper());
1658
0
  if (aReflector) {
1659
#ifdef DEBUG
1660
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1661
#endif // DEBUG
1662
    return true;
1663
0
  }
1664
0
1665
0
  JSAutoRealm ar(aCx, global);
1666
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1667
0
  if (!canonicalProto) {
1668
0
    return false;
1669
0
  }
1670
0
  JS::Rooted<JSObject*> proto(aCx);
1671
0
  if (aGivenProto) {
1672
0
    proto = aGivenProto;
1673
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
1674
0
    // coming in, we changed compartments to that of "parent" so may need
1675
0
    // to wrap the proto here.
1676
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1677
0
      if (!JS_WrapObject(aCx, &proto)) {
1678
0
        return false;
1679
0
      }
1680
0
    }
1681
0
  } else {
1682
0
    proto = canonicalProto;
1683
0
  }
1684
0
1685
0
  BindingJSObjectCreator<mozilla::dom::AudioContext> creator(aCx);
1686
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
1687
0
  if (!aReflector) {
1688
0
    return false;
1689
0
  }
1690
0
1691
0
  aCache->SetWrapper(aReflector);
1692
0
  creator.InitializationSucceeded();
1693
0
1694
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1695
0
             aCache->GetWrapperPreserveColor() == aReflector);
1696
0
  // If proto != canonicalProto, we have to preserve our wrapper;
1697
0
  // otherwise we won't be able to properly recreate it later, since
1698
0
  // we won't know what proto to use.  Note that we don't check
1699
0
  // aGivenProto here, since it's entirely possible (and even
1700
0
  // somewhat common) to have a non-null aGivenProto which is the
1701
0
  // same as canonicalProto.
1702
0
  if (proto != canonicalProto) {
1703
0
    PreserveWrapper(aObject);
1704
0
  }
1705
0
1706
0
  return true;
1707
0
}
1708
1709
const NativePropertyHooks sNativePropertyHooks[] = { {
1710
  nullptr,
1711
  nullptr,
1712
  nullptr,
1713
  { sNativeProperties.Upcast(), nullptr },
1714
  prototypes::id::BaseAudioContext,
1715
  constructors::id::BaseAudioContext,
1716
  EventTarget_Binding::sNativePropertyHooks,
1717
  &DefaultXrayExpandoObjectClass
1718
} };
1719
1720
void
1721
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1722
0
{
1723
0
  JS::Handle<JSObject*> parentProto(EventTarget_Binding::GetProtoObjectHandle(aCx));
1724
0
  if (!parentProto) {
1725
0
    return;
1726
0
  }
1727
0
1728
0
  JS::Handle<JSObject*> constructorProto(EventTarget_Binding::GetConstructorObjectHandle(aCx));
1729
0
  if (!constructorProto) {
1730
0
    return;
1731
0
  }
1732
0
1733
0
  static bool sIdsInited = false;
1734
0
  if (!sIdsInited && NS_IsMainThread()) {
1735
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
1736
0
      return;
1737
0
    }
1738
0
    sIdsInited = true;
1739
0
  }
1740
0
1741
0
  static bool sPrefCachesInited = false;
1742
0
  if (!sPrefCachesInited && NS_IsMainThread()) {
1743
0
    sPrefCachesInited = true;
1744
0
    Preferences::AddBoolVarCache(&sAttributes[1].disablers->enabled, "dom.audioworklet.enabled");
1745
0
  }
1746
0
1747
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::BaseAudioContext);
1748
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::BaseAudioContext);
1749
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1750
0
                              &sPrototypeClass.mBase, protoCache,
1751
0
                              nullptr,
1752
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
1753
0
                              interfaceCache,
1754
0
                              sNativeProperties.Upcast(),
1755
0
                              nullptr,
1756
0
                              "BaseAudioContext", aDefineOnGlobal,
1757
0
                              nullptr,
1758
0
                              false);
1759
0
}
1760
1761
JSObject*
1762
GetProtoObject(JSContext* aCx)
1763
0
{
1764
0
  return GetProtoObjectHandle(aCx);
1765
0
}
1766
1767
JSObject*
1768
GetConstructorObject(JSContext* aCx)
1769
0
{
1770
0
  return GetConstructorObjectHandle(aCx);
1771
0
}
1772
1773
} // namespace BaseAudioContext_Binding
1774
1775
1776
1777
} // namespace dom
1778
} // namespace mozilla