Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/MediaSourceBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM MediaSource.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "EventHandlerBinding.h"
4
#include "EventTargetBinding.h"
5
#include "MediaSourceBinding.h"
6
#include "WrapperFactory.h"
7
#include "jsapi.h"
8
#include "mozilla/FloatingPoint.h"
9
#include "mozilla/OwningNonNull.h"
10
#include "mozilla/dom/BindingUtils.h"
11
#include "mozilla/dom/DOMJSClass.h"
12
#include "mozilla/dom/MediaSource.h"
13
#include "mozilla/dom/NonRefcountedDOMObject.h"
14
#include "mozilla/dom/Nullable.h"
15
#include "mozilla/dom/PrimitiveConversions.h"
16
#include "mozilla/dom/SourceBuffer.h"
17
#include "mozilla/dom/SourceBufferList.h"
18
#include "mozilla/dom/XrayExpandoClass.h"
19
#include "nsContentUtils.h"
20
21
namespace mozilla {
22
namespace dom {
23
24
namespace binding_detail {}; // Just to make sure it's known as a namespace
25
using namespace mozilla::dom::binding_detail;
26
27
28
namespace MediaSourceReadyStateValues {
29
extern const EnumEntry strings[4] = {
30
  {"closed", 6},
31
  {"open", 4},
32
  {"ended", 5},
33
  { nullptr, 0 }
34
};
35
} // namespace MediaSourceReadyStateValues
36
37
bool
38
ToJSValue(JSContext* aCx, MediaSourceReadyState aArgument, JS::MutableHandle<JS::Value> aValue)
39
0
{
40
0
  MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(MediaSourceReadyStateValues::strings));
41
0
  JSString* resultStr =
42
0
    JS_NewStringCopyN(aCx, MediaSourceReadyStateValues::strings[uint32_t(aArgument)].value,
43
0
                      MediaSourceReadyStateValues::strings[uint32_t(aArgument)].length);
44
0
  if (!resultStr) {
45
0
    return false;
46
0
  }
47
0
  aValue.setString(resultStr);
48
0
  return true;
49
0
}
50
51
52
namespace MediaSourceEndOfStreamErrorValues {
53
extern const EnumEntry strings[3] = {
54
  {"network", 7},
55
  {"decode", 6},
56
  { nullptr, 0 }
57
};
58
} // namespace MediaSourceEndOfStreamErrorValues
59
60
bool
61
ToJSValue(JSContext* aCx, MediaSourceEndOfStreamError aArgument, JS::MutableHandle<JS::Value> aValue)
62
0
{
63
0
  MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(MediaSourceEndOfStreamErrorValues::strings));
64
0
  JSString* resultStr =
65
0
    JS_NewStringCopyN(aCx, MediaSourceEndOfStreamErrorValues::strings[uint32_t(aArgument)].value,
66
0
                      MediaSourceEndOfStreamErrorValues::strings[uint32_t(aArgument)].length);
67
0
  if (!resultStr) {
68
0
    return false;
69
0
  }
70
0
  aValue.setString(resultStr);
71
0
  return true;
72
0
}
73
74
75
namespace MediaSource_Binding {
76
77
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTarget_Binding::NativeType>::value,
78
              "Can't inherit from an interface with a different ownership model.");
79
80
MOZ_CAN_RUN_SCRIPT static bool
81
get_sourceBuffers(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaSource* self, JSJitGetterCallArgs args)
82
0
{
83
0
  AUTO_PROFILER_LABEL_FAST("get MediaSource.sourceBuffers", DOM, cx);
84
0
85
0
  auto result(StrongOrRawPtr<mozilla::dom::SourceBufferList>(self->SourceBuffers()));
86
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
87
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
88
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
89
0
    return false;
90
0
  }
91
0
  return true;
92
0
}
93
94
static const JSJitInfo sourceBuffers_getterinfo = {
95
  { (JSJitGetterOp)get_sourceBuffers },
96
  { prototypes::id::MediaSource },
97
  { PrototypeTraits<prototypes::id::MediaSource>::Depth },
98
  JSJitInfo::Getter,
99
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
100
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
101
  false,  /* isInfallible. False in setters. */
102
  false,  /* isMovable.  Not relevant for setters. */
103
  false, /* isEliminatable.  Not relevant for setters. */
104
  false, /* isAlwaysInSlot.  Only relevant for getters. */
105
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
106
  false,  /* isTypedMethod.  Only relevant for methods. */
107
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
108
};
109
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
110
static_assert(0 < 1, "There is no slot for us");
111
112
MOZ_CAN_RUN_SCRIPT static bool
113
get_activeSourceBuffers(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaSource* self, JSJitGetterCallArgs args)
114
0
{
115
0
  AUTO_PROFILER_LABEL_FAST("get MediaSource.activeSourceBuffers", DOM, cx);
116
0
117
0
  auto result(StrongOrRawPtr<mozilla::dom::SourceBufferList>(self->ActiveSourceBuffers()));
118
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
119
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
120
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
121
0
    return false;
122
0
  }
123
0
  return true;
124
0
}
125
126
static const JSJitInfo activeSourceBuffers_getterinfo = {
127
  { (JSJitGetterOp)get_activeSourceBuffers },
128
  { prototypes::id::MediaSource },
129
  { PrototypeTraits<prototypes::id::MediaSource>::Depth },
130
  JSJitInfo::Getter,
131
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
132
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
133
  false,  /* isInfallible. False in setters. */
134
  false,  /* isMovable.  Not relevant for setters. */
135
  false, /* isEliminatable.  Not relevant for setters. */
136
  false, /* isAlwaysInSlot.  Only relevant for getters. */
137
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
138
  false,  /* isTypedMethod.  Only relevant for methods. */
139
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
140
};
141
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
142
static_assert(0 < 1, "There is no slot for us");
143
144
MOZ_CAN_RUN_SCRIPT static bool
145
get_readyState(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaSource* self, JSJitGetterCallArgs args)
146
0
{
147
0
  AUTO_PROFILER_LABEL_FAST("get MediaSource.readyState", DOM, cx);
148
0
149
0
  MediaSourceReadyState result(self->ReadyState());
150
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
151
0
  if (!ToJSValue(cx, result, args.rval())) {
152
0
    return false;
153
0
  }
154
0
  return true;
155
0
}
156
157
static const JSJitInfo readyState_getterinfo = {
158
  { (JSJitGetterOp)get_readyState },
159
  { prototypes::id::MediaSource },
160
  { PrototypeTraits<prototypes::id::MediaSource>::Depth },
161
  JSJitInfo::Getter,
162
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
163
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
164
  false,  /* isInfallible. False in setters. */
165
  false,  /* isMovable.  Not relevant for setters. */
166
  false, /* isEliminatable.  Not relevant for setters. */
167
  false, /* isAlwaysInSlot.  Only relevant for getters. */
168
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
169
  false,  /* isTypedMethod.  Only relevant for methods. */
170
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
171
};
172
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
173
static_assert(0 < 1, "There is no slot for us");
174
175
MOZ_CAN_RUN_SCRIPT static bool
176
get_duration(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaSource* self, JSJitGetterCallArgs args)
177
0
{
178
0
  AUTO_PROFILER_LABEL_FAST("get MediaSource.duration", DOM, cx);
179
0
180
0
  double result(self->Duration());
181
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
182
0
  args.rval().set(JS_NumberValue(double(result)));
183
0
  return true;
184
0
}
185
186
MOZ_CAN_RUN_SCRIPT static bool
187
set_duration(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaSource* self, JSJitSetterCallArgs args)
188
0
{
189
0
  AUTO_PROFILER_LABEL_FAST("set MediaSource.duration", DOM, cx);
190
0
191
0
  double arg0;
192
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
193
0
    return false;
194
0
  }
195
0
  FastErrorResult rv;
196
0
  self->SetDuration(arg0, rv);
197
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
198
0
    return false;
199
0
  }
200
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
201
0
202
0
  return true;
203
0
}
204
205
static const JSJitInfo duration_getterinfo = {
206
  { (JSJitGetterOp)get_duration },
207
  { prototypes::id::MediaSource },
208
  { PrototypeTraits<prototypes::id::MediaSource>::Depth },
209
  JSJitInfo::Getter,
210
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
211
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
212
  true,  /* isInfallible. False in setters. */
213
  false,  /* isMovable.  Not relevant for setters. */
214
  false, /* isEliminatable.  Not relevant for setters. */
215
  false, /* isAlwaysInSlot.  Only relevant for getters. */
216
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
217
  false,  /* isTypedMethod.  Only relevant for methods. */
218
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
219
};
220
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
221
static_assert(0 < 1, "There is no slot for us");
222
static const JSJitInfo duration_setterinfo = {
223
  { (JSJitGetterOp)set_duration },
224
  { prototypes::id::MediaSource },
225
  { PrototypeTraits<prototypes::id::MediaSource>::Depth },
226
  JSJitInfo::Setter,
227
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
228
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
229
  false,  /* 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_onsourceopen(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaSource* self, JSJitGetterCallArgs args)
242
0
{
243
0
  AUTO_PROFILER_LABEL_FAST("get MediaSource.onsourceopen", DOM, cx);
244
0
245
0
  RefPtr<EventHandlerNonNull> result(self->GetOnsourceopen());
246
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
247
0
  if (result) {
248
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
249
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
250
0
      return false;
251
0
    }
252
0
    return true;
253
0
  } else {
254
0
    args.rval().setNull();
255
0
    return true;
256
0
  }
257
0
}
258
259
MOZ_CAN_RUN_SCRIPT static bool
260
set_onsourceopen(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaSource* self, JSJitSetterCallArgs args)
261
0
{
262
0
  AUTO_PROFILER_LABEL_FAST("set MediaSource.onsourceopen", DOM, cx);
263
0
264
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
265
0
  if (args[0].isObject()) {
266
0
    { // scope for tempRoot and tempGlobalRoot if needed
267
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
268
0
    }
269
0
  } else {
270
0
    arg0 = nullptr;
271
0
  }
272
0
  self->SetOnsourceopen(Constify(arg0));
273
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
274
0
275
0
  return true;
276
0
}
277
278
static const JSJitInfo onsourceopen_getterinfo = {
279
  { (JSJitGetterOp)get_onsourceopen },
280
  { prototypes::id::MediaSource },
281
  { PrototypeTraits<prototypes::id::MediaSource>::Depth },
282
  JSJitInfo::Getter,
283
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
284
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
285
  false,  /* isInfallible. False in setters. */
286
  false,  /* isMovable.  Not relevant for setters. */
287
  false, /* isEliminatable.  Not relevant for setters. */
288
  false, /* isAlwaysInSlot.  Only relevant for getters. */
289
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
290
  false,  /* isTypedMethod.  Only relevant for methods. */
291
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
292
};
293
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
294
static_assert(0 < 1, "There is no slot for us");
295
static const JSJitInfo onsourceopen_setterinfo = {
296
  { (JSJitGetterOp)set_onsourceopen },
297
  { prototypes::id::MediaSource },
298
  { PrototypeTraits<prototypes::id::MediaSource>::Depth },
299
  JSJitInfo::Setter,
300
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
301
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
302
  false,  /* isInfallible. False in setters. */
303
  false,  /* isMovable.  Not relevant for setters. */
304
  false, /* isEliminatable.  Not relevant for setters. */
305
  false, /* isAlwaysInSlot.  Only relevant for getters. */
306
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
307
  false,  /* isTypedMethod.  Only relevant for methods. */
308
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
309
};
310
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
311
static_assert(0 < 1, "There is no slot for us");
312
313
MOZ_CAN_RUN_SCRIPT static bool
314
get_onsourceended(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaSource* self, JSJitGetterCallArgs args)
315
0
{
316
0
  AUTO_PROFILER_LABEL_FAST("get MediaSource.onsourceended", DOM, cx);
317
0
318
0
  RefPtr<EventHandlerNonNull> result(self->GetOnsourceended());
319
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
320
0
  if (result) {
321
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
322
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
323
0
      return false;
324
0
    }
325
0
    return true;
326
0
  } else {
327
0
    args.rval().setNull();
328
0
    return true;
329
0
  }
330
0
}
331
332
MOZ_CAN_RUN_SCRIPT static bool
333
set_onsourceended(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaSource* self, JSJitSetterCallArgs args)
334
0
{
335
0
  AUTO_PROFILER_LABEL_FAST("set MediaSource.onsourceended", DOM, cx);
336
0
337
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
338
0
  if (args[0].isObject()) {
339
0
    { // scope for tempRoot and tempGlobalRoot if needed
340
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
341
0
    }
342
0
  } else {
343
0
    arg0 = nullptr;
344
0
  }
345
0
  self->SetOnsourceended(Constify(arg0));
346
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
347
0
348
0
  return true;
349
0
}
350
351
static const JSJitInfo onsourceended_getterinfo = {
352
  { (JSJitGetterOp)get_onsourceended },
353
  { prototypes::id::MediaSource },
354
  { PrototypeTraits<prototypes::id::MediaSource>::Depth },
355
  JSJitInfo::Getter,
356
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
357
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
358
  false,  /* isInfallible. False in setters. */
359
  false,  /* isMovable.  Not relevant for setters. */
360
  false, /* isEliminatable.  Not relevant for setters. */
361
  false, /* isAlwaysInSlot.  Only relevant for getters. */
362
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
363
  false,  /* isTypedMethod.  Only relevant for methods. */
364
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
365
};
366
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
367
static_assert(0 < 1, "There is no slot for us");
368
static const JSJitInfo onsourceended_setterinfo = {
369
  { (JSJitGetterOp)set_onsourceended },
370
  { prototypes::id::MediaSource },
371
  { PrototypeTraits<prototypes::id::MediaSource>::Depth },
372
  JSJitInfo::Setter,
373
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
374
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
375
  false,  /* isInfallible. False in setters. */
376
  false,  /* isMovable.  Not relevant for setters. */
377
  false, /* isEliminatable.  Not relevant for setters. */
378
  false, /* isAlwaysInSlot.  Only relevant for getters. */
379
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
380
  false,  /* isTypedMethod.  Only relevant for methods. */
381
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
382
};
383
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
384
static_assert(0 < 1, "There is no slot for us");
385
386
MOZ_CAN_RUN_SCRIPT static bool
387
get_onsourceclosed(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaSource* self, JSJitGetterCallArgs args)
388
0
{
389
0
  AUTO_PROFILER_LABEL_FAST("get MediaSource.onsourceclosed", DOM, cx);
390
0
391
0
  RefPtr<EventHandlerNonNull> result(self->GetOnsourceclosed());
392
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
393
0
  if (result) {
394
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
395
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
396
0
      return false;
397
0
    }
398
0
    return true;
399
0
  } else {
400
0
    args.rval().setNull();
401
0
    return true;
402
0
  }
403
0
}
404
405
MOZ_CAN_RUN_SCRIPT static bool
406
set_onsourceclosed(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaSource* self, JSJitSetterCallArgs args)
407
0
{
408
0
  AUTO_PROFILER_LABEL_FAST("set MediaSource.onsourceclosed", DOM, cx);
409
0
410
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
411
0
  if (args[0].isObject()) {
412
0
    { // scope for tempRoot and tempGlobalRoot if needed
413
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
414
0
    }
415
0
  } else {
416
0
    arg0 = nullptr;
417
0
  }
418
0
  self->SetOnsourceclosed(Constify(arg0));
419
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
420
0
421
0
  return true;
422
0
}
423
424
static const JSJitInfo onsourceclosed_getterinfo = {
425
  { (JSJitGetterOp)get_onsourceclosed },
426
  { prototypes::id::MediaSource },
427
  { PrototypeTraits<prototypes::id::MediaSource>::Depth },
428
  JSJitInfo::Getter,
429
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
430
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
431
  false,  /* isInfallible. False in setters. */
432
  false,  /* isMovable.  Not relevant for setters. */
433
  false, /* isEliminatable.  Not relevant for setters. */
434
  false, /* isAlwaysInSlot.  Only relevant for getters. */
435
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
436
  false,  /* isTypedMethod.  Only relevant for methods. */
437
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
438
};
439
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
440
static_assert(0 < 1, "There is no slot for us");
441
static const JSJitInfo onsourceclosed_setterinfo = {
442
  { (JSJitGetterOp)set_onsourceclosed },
443
  { prototypes::id::MediaSource },
444
  { PrototypeTraits<prototypes::id::MediaSource>::Depth },
445
  JSJitInfo::Setter,
446
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
447
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
448
  false,  /* isInfallible. False in setters. */
449
  false,  /* isMovable.  Not relevant for setters. */
450
  false, /* isEliminatable.  Not relevant for setters. */
451
  false, /* isAlwaysInSlot.  Only relevant for getters. */
452
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
453
  false,  /* isTypedMethod.  Only relevant for methods. */
454
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
455
};
456
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
457
static_assert(0 < 1, "There is no slot for us");
458
459
MOZ_CAN_RUN_SCRIPT static bool
460
addSourceBuffer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaSource* self, const JSJitMethodCallArgs& args)
461
0
{
462
0
  AUTO_PROFILER_LABEL_FAST("MediaSource.addSourceBuffer", DOM, cx);
463
0
464
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
465
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MediaSource.addSourceBuffer");
466
0
  }
467
0
  binding_detail::FakeString arg0;
468
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
469
0
    return false;
470
0
  }
471
0
  FastErrorResult rv;
472
0
  auto result(StrongOrRawPtr<mozilla::dom::SourceBuffer>(self->AddSourceBuffer(NonNullHelper(Constify(arg0)), rv)));
473
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
474
0
    return false;
475
0
  }
476
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
477
0
  static_assert(!IsPointer<decltype(result)>::value,
478
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
479
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
480
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
481
0
    return false;
482
0
  }
483
0
  return true;
484
0
}
485
486
static const JSJitInfo addSourceBuffer_methodinfo = {
487
  { (JSJitGetterOp)addSourceBuffer },
488
  { prototypes::id::MediaSource },
489
  { PrototypeTraits<prototypes::id::MediaSource>::Depth },
490
  JSJitInfo::Method,
491
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
492
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
493
  false,  /* isInfallible. False in setters. */
494
  false,  /* isMovable.  Not relevant for setters. */
495
  false, /* isEliminatable.  Not relevant for setters. */
496
  false, /* isAlwaysInSlot.  Only relevant for getters. */
497
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
498
  false,  /* isTypedMethod.  Only relevant for methods. */
499
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
500
};
501
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
502
static_assert(0 < 1, "There is no slot for us");
503
504
MOZ_CAN_RUN_SCRIPT static bool
505
removeSourceBuffer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaSource* self, const JSJitMethodCallArgs& args)
506
0
{
507
0
  AUTO_PROFILER_LABEL_FAST("MediaSource.removeSourceBuffer", DOM, cx);
508
0
509
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
510
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MediaSource.removeSourceBuffer");
511
0
  }
512
0
  NonNull<mozilla::dom::SourceBuffer> arg0;
513
0
  if (args[0].isObject()) {
514
0
    {
515
0
      nsresult rv = UnwrapObject<prototypes::id::SourceBuffer, mozilla::dom::SourceBuffer>(args[0], arg0);
516
0
      if (NS_FAILED(rv)) {
517
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of MediaSource.removeSourceBuffer", "SourceBuffer");
518
0
        return false;
519
0
      }
520
0
    }
521
0
  } else {
522
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of MediaSource.removeSourceBuffer");
523
0
    return false;
524
0
  }
525
0
  FastErrorResult rv;
526
0
  self->RemoveSourceBuffer(MOZ_KnownLive(NonNullHelper(arg0)), rv);
527
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
528
0
    return false;
529
0
  }
530
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
531
0
  args.rval().setUndefined();
532
0
  return true;
533
0
}
534
535
static const JSJitInfo removeSourceBuffer_methodinfo = {
536
  { (JSJitGetterOp)removeSourceBuffer },
537
  { prototypes::id::MediaSource },
538
  { PrototypeTraits<prototypes::id::MediaSource>::Depth },
539
  JSJitInfo::Method,
540
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
541
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
542
  false,  /* isInfallible. False in setters. */
543
  false,  /* isMovable.  Not relevant for setters. */
544
  false, /* isEliminatable.  Not relevant for setters. */
545
  false, /* isAlwaysInSlot.  Only relevant for getters. */
546
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
547
  false,  /* isTypedMethod.  Only relevant for methods. */
548
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
549
};
550
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
551
static_assert(0 < 1, "There is no slot for us");
552
553
MOZ_CAN_RUN_SCRIPT static bool
554
endOfStream(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaSource* self, const JSJitMethodCallArgs& args)
555
0
{
556
0
  AUTO_PROFILER_LABEL_FAST("MediaSource.endOfStream", DOM, cx);
557
0
558
0
  Optional<MediaSourceEndOfStreamError> arg0;
559
0
  if (args.hasDefined(0)) {
560
0
    arg0.Construct();
561
0
    {
562
0
      int index;
563
0
      if (!FindEnumStringIndex<true>(cx, args[0], MediaSourceEndOfStreamErrorValues::strings, "MediaSourceEndOfStreamError", "Argument 1 of MediaSource.endOfStream", &index)) {
564
0
        return false;
565
0
      }
566
0
      MOZ_ASSERT(index >= 0);
567
0
      arg0.Value() = static_cast<MediaSourceEndOfStreamError>(index);
568
0
    }
569
0
  }
570
0
  FastErrorResult rv;
571
0
  self->EndOfStream(Constify(arg0), rv);
572
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
573
0
    return false;
574
0
  }
575
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
576
0
  args.rval().setUndefined();
577
0
  return true;
578
0
}
579
580
static const JSJitInfo endOfStream_methodinfo = {
581
  { (JSJitGetterOp)endOfStream },
582
  { prototypes::id::MediaSource },
583
  { PrototypeTraits<prototypes::id::MediaSource>::Depth },
584
  JSJitInfo::Method,
585
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
586
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
587
  false,  /* isInfallible. False in setters. */
588
  false,  /* isMovable.  Not relevant for setters. */
589
  false, /* isEliminatable.  Not relevant for setters. */
590
  false, /* isAlwaysInSlot.  Only relevant for getters. */
591
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
592
  false,  /* isTypedMethod.  Only relevant for methods. */
593
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
594
};
595
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
596
static_assert(0 < 1, "There is no slot for us");
597
598
MOZ_CAN_RUN_SCRIPT static bool
599
setLiveSeekableRange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaSource* self, const JSJitMethodCallArgs& args)
600
0
{
601
0
  AUTO_PROFILER_LABEL_FAST("MediaSource.setLiveSeekableRange", DOM, cx);
602
0
603
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
604
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MediaSource.setLiveSeekableRange");
605
0
  }
606
0
  double arg0;
607
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
608
0
    return false;
609
0
  } else if (!mozilla::IsFinite(arg0)) {
610
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 1 of MediaSource.setLiveSeekableRange");
611
0
    return false;
612
0
  }
613
0
  double arg1;
614
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
615
0
    return false;
616
0
  } else if (!mozilla::IsFinite(arg1)) {
617
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 2 of MediaSource.setLiveSeekableRange");
618
0
    return false;
619
0
  }
620
0
  FastErrorResult rv;
621
0
  self->SetLiveSeekableRange(arg0, arg1, rv);
622
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
623
0
    return false;
624
0
  }
625
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
626
0
  args.rval().setUndefined();
627
0
  return true;
628
0
}
629
630
static const JSJitInfo setLiveSeekableRange_methodinfo = {
631
  { (JSJitGetterOp)setLiveSeekableRange },
632
  { prototypes::id::MediaSource },
633
  { PrototypeTraits<prototypes::id::MediaSource>::Depth },
634
  JSJitInfo::Method,
635
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
636
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
637
  false,  /* isInfallible. False in setters. */
638
  false,  /* isMovable.  Not relevant for setters. */
639
  false, /* isEliminatable.  Not relevant for setters. */
640
  false, /* isAlwaysInSlot.  Only relevant for getters. */
641
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
642
  false,  /* isTypedMethod.  Only relevant for methods. */
643
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
644
};
645
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
646
static_assert(0 < 1, "There is no slot for us");
647
648
MOZ_CAN_RUN_SCRIPT static bool
649
clearLiveSeekableRange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaSource* self, const JSJitMethodCallArgs& args)
650
0
{
651
0
  AUTO_PROFILER_LABEL_FAST("MediaSource.clearLiveSeekableRange", DOM, cx);
652
0
653
0
  FastErrorResult rv;
654
0
  self->ClearLiveSeekableRange(rv);
655
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
656
0
    return false;
657
0
  }
658
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
659
0
  args.rval().setUndefined();
660
0
  return true;
661
0
}
662
663
static const JSJitInfo clearLiveSeekableRange_methodinfo = {
664
  { (JSJitGetterOp)clearLiveSeekableRange },
665
  { prototypes::id::MediaSource },
666
  { PrototypeTraits<prototypes::id::MediaSource>::Depth },
667
  JSJitInfo::Method,
668
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
669
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
670
  false,  /* isInfallible. False in setters. */
671
  false,  /* isMovable.  Not relevant for setters. */
672
  false, /* isEliminatable.  Not relevant for setters. */
673
  false, /* isAlwaysInSlot.  Only relevant for getters. */
674
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
675
  false,  /* isTypedMethod.  Only relevant for methods. */
676
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
677
};
678
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
679
static_assert(0 < 1, "There is no slot for us");
680
681
static bool
682
isTypeSupported(JSContext* cx, unsigned argc, JS::Value* vp)
683
0
{
684
0
  AUTO_PROFILER_LABEL_FAST("MediaSource.isTypeSupported", DOM, cx);
685
0
686
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
687
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
688
0
689
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
690
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MediaSource.isTypeSupported");
691
0
  }
692
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
693
0
  if (global.Failed()) {
694
0
    return false;
695
0
  }
696
0
697
0
  binding_detail::FakeString arg0;
698
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
699
0
    return false;
700
0
  }
701
0
  bool result(mozilla::dom::MediaSource::IsTypeSupported(global, NonNullHelper(Constify(arg0))));
702
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
703
0
  args.rval().setBoolean(result);
704
0
  return true;
705
0
}
706
707
MOZ_CAN_RUN_SCRIPT static bool
708
get_mozDebugReaderData(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaSource* self, JSJitGetterCallArgs args)
709
0
{
710
0
  AUTO_PROFILER_LABEL_FAST("get MediaSource.mozDebugReaderData", DOM, cx);
711
0
712
0
  DOMString result;
713
0
  self->GetMozDebugReaderData(result);
714
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
715
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
716
0
    return false;
717
0
  }
718
0
  return true;
719
0
}
720
721
static const JSJitInfo mozDebugReaderData_getterinfo = {
722
  { (JSJitGetterOp)get_mozDebugReaderData },
723
  { prototypes::id::MediaSource },
724
  { PrototypeTraits<prototypes::id::MediaSource>::Depth },
725
  JSJitInfo::Getter,
726
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
727
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
728
  false,  /* isInfallible. False in setters. */
729
  false,  /* isMovable.  Not relevant for setters. */
730
  false, /* isEliminatable.  Not relevant for setters. */
731
  false, /* isAlwaysInSlot.  Only relevant for getters. */
732
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
733
  false,  /* isTypedMethod.  Only relevant for methods. */
734
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
735
};
736
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
737
static_assert(0 < 1, "There is no slot for us");
738
739
static bool
740
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
741
0
{
742
0
  mozilla::dom::MediaSource* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MediaSource>(obj);
743
0
  // We don't want to preserve if we don't have a wrapper, and we
744
0
  // obviously can't preserve if we're not initialized.
745
0
  if (self && self->GetWrapperPreserveColor()) {
746
0
    PreserveWrapper(self);
747
0
  }
748
0
  return true;
749
0
}
750
751
static void
752
_finalize(js::FreeOp* fop, JSObject* obj)
753
0
{
754
0
  mozilla::dom::MediaSource* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MediaSource>(obj);
755
0
  if (self) {
756
0
    ClearWrapper(self, self, obj);
757
0
    AddForDeferredFinalization<mozilla::dom::MediaSource>(self);
758
0
  }
759
0
}
760
761
static size_t
762
_objectMoved(JSObject* obj, JSObject* old)
763
0
{
764
0
  mozilla::dom::MediaSource* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MediaSource>(obj);
765
0
  if (self) {
766
0
    UpdateWrapper(self, self, obj, old);
767
0
  }
768
0
769
0
  return 0;
770
0
}
771
772
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
773
#if defined(__clang__)
774
#pragma clang diagnostic push
775
#pragma clang diagnostic ignored "-Wmissing-braces"
776
#endif
777
static const JSFunctionSpec sStaticMethods_specs[] = {
778
  JS_FNSPEC("isTypeSupported", isTypeSupported, nullptr, 1, JSPROP_ENUMERATE, nullptr),
779
  JS_FS_END
780
};
781
#if defined(__clang__)
782
#pragma clang diagnostic pop
783
#endif
784
785
786
static const Prefable<const JSFunctionSpec> sStaticMethods[] = {
787
  { nullptr, &sStaticMethods_specs[0] },
788
  { nullptr, nullptr }
789
};
790
791
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
792
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
793
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
794
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
795
796
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
797
#if defined(__clang__)
798
#pragma clang diagnostic push
799
#pragma clang diagnostic ignored "-Wmissing-braces"
800
#endif
801
static const JSFunctionSpec sMethods_specs[] = {
802
  JS_FNSPEC("addSourceBuffer", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&addSourceBuffer_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
803
  JS_FNSPEC("removeSourceBuffer", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&removeSourceBuffer_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
804
  JS_FNSPEC("endOfStream", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&endOfStream_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
805
  JS_FNSPEC("setLiveSeekableRange", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setLiveSeekableRange_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
806
  JS_FNSPEC("clearLiveSeekableRange", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&clearLiveSeekableRange_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
807
  JS_FS_END
808
};
809
#if defined(__clang__)
810
#pragma clang diagnostic pop
811
#endif
812
813
814
static const Prefable<const JSFunctionSpec> sMethods[] = {
815
  { nullptr, &sMethods_specs[0] },
816
  { nullptr, nullptr }
817
};
818
819
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
820
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
821
static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
822
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
823
824
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
825
#if defined(__clang__)
826
#pragma clang diagnostic push
827
#pragma clang diagnostic ignored "-Wmissing-braces"
828
#endif
829
static const JSPropertySpec sAttributes_specs[] = {
830
  { "sourceBuffers", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &sourceBuffers_getterinfo, nullptr, nullptr },
831
  { "activeSourceBuffers", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &activeSourceBuffers_getterinfo, nullptr, nullptr },
832
  { "readyState", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &readyState_getterinfo, nullptr, nullptr },
833
  { "duration", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &duration_getterinfo, GenericSetter<NormalThisPolicy>, &duration_setterinfo },
834
  { "onsourceopen", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onsourceopen_getterinfo, GenericSetter<NormalThisPolicy>, &onsourceopen_setterinfo },
835
  { "onsourceended", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onsourceended_getterinfo, GenericSetter<NormalThisPolicy>, &onsourceended_setterinfo },
836
  { "onsourceclosed", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onsourceclosed_getterinfo, GenericSetter<NormalThisPolicy>, &onsourceclosed_setterinfo },
837
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
838
};
839
#if defined(__clang__)
840
#pragma clang diagnostic pop
841
#endif
842
843
844
static const Prefable<const JSPropertySpec> sAttributes[] = {
845
  { nullptr, &sAttributes_specs[0] },
846
  { nullptr, nullptr }
847
};
848
849
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
850
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
851
static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
852
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
853
854
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
855
#if defined(__clang__)
856
#pragma clang diagnostic push
857
#pragma clang diagnostic ignored "-Wmissing-braces"
858
#endif
859
static const JSPropertySpec sChromeAttributes_specs[] = {
860
  { "mozDebugReaderData", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &mozDebugReaderData_getterinfo, nullptr, nullptr },
861
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
862
};
863
#if defined(__clang__)
864
#pragma clang diagnostic pop
865
#endif
866
867
868
static const Prefable<const JSPropertySpec> sChromeAttributes[] = {
869
  { nullptr, &sChromeAttributes_specs[0] },
870
  { nullptr, nullptr }
871
};
872
873
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
874
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
875
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
876
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
877
878
879
static uint16_t sNativeProperties_sortedPropertyIndices[13];
880
static PropertyInfo sNativeProperties_propertyInfos[13];
881
882
static const NativePropertiesN<3> sNativeProperties = {
883
  true,  0 /* sStaticMethods */,
884
  false, 0,
885
  true,  1 /* sMethods */,
886
  true,  2 /* sAttributes */,
887
  false, 0,
888
  false, 0,
889
  false, 0,
890
  -1,
891
  13,
892
  sNativeProperties_sortedPropertyIndices,
893
  {
894
    { sStaticMethods, &sNativeProperties_propertyInfos[0] },
895
    { sMethods, &sNativeProperties_propertyInfos[1] },
896
    { sAttributes, &sNativeProperties_propertyInfos[6] }
897
  }
898
};
899
static_assert(13 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
900
    "We have a property info count that is oversized");
901
902
static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1];
903
static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1];
904
905
static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
906
  false, 0,
907
  false, 0,
908
  false, 0,
909
  true,  0 /* sChromeAttributes */,
910
  false, 0,
911
  false, 0,
912
  false, 0,
913
  -1,
914
  1,
915
  sChromeOnlyNativeProperties_sortedPropertyIndices,
916
  {
917
    { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[0] }
918
  }
919
};
920
static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
921
    "We have a property info count that is oversized");
922
923
static bool
924
_constructor(JSContext* cx, unsigned argc, JS::Value* vp)
925
0
{
926
0
  AUTO_PROFILER_LABEL_FAST("MediaSource constructor", DOM, cx);
927
0
928
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
929
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
930
0
  if (!args.isConstructing()) {
931
0
    // XXXbz wish I could get the name from the callee instead of
932
0
    // Adding more relocations
933
0
    return ThrowConstructorWithoutNew(cx, "MediaSource");
934
0
  }
935
0
936
0
  JS::Rooted<JSObject*> desiredProto(cx);
937
0
  if (!GetDesiredProto(cx, args, &desiredProto)) {
938
0
    return false;
939
0
  }
940
0
941
0
  GlobalObject global(cx, obj);
942
0
  if (global.Failed()) {
943
0
    return false;
944
0
  }
945
0
946
0
  bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
947
0
  Maybe<JSAutoRealm> ar;
948
0
  if (objIsXray) {
949
0
    obj = js::CheckedUnwrap(obj);
950
0
    if (!obj) {
951
0
      return false;
952
0
    }
953
0
    ar.emplace(cx, obj);
954
0
    if (!JS_WrapObject(cx, &desiredProto)) {
955
0
      return false;
956
0
    }
957
0
  }
958
0
  FastErrorResult rv;
959
0
  auto result(StrongOrRawPtr<mozilla::dom::MediaSource>(mozilla::dom::MediaSource::Constructor(global, rv)));
960
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
961
0
    return false;
962
0
  }
963
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
964
0
  static_assert(!IsPointer<decltype(result)>::value,
965
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
966
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
967
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
968
0
    return false;
969
0
  }
970
0
  return true;
971
0
}
972
973
static const js::ClassOps sInterfaceObjectClassOps = {
974
    nullptr,               /* addProperty */
975
    nullptr,               /* delProperty */
976
    nullptr,               /* enumerate */
977
    nullptr,               /* newEnumerate */
978
    nullptr,               /* resolve */
979
    nullptr,               /* mayResolve */
980
    nullptr,               /* finalize */
981
    _constructor, /* call */
982
    nullptr,               /* hasInstance */
983
    _constructor, /* construct */
984
    nullptr,               /* trace */
985
};
986
987
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
988
  {
989
    "Function",
990
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
991
    &sInterfaceObjectClassOps,
992
    JS_NULL_CLASS_SPEC,
993
    JS_NULL_CLASS_EXT,
994
    &sInterfaceObjectClassObjectOps
995
  },
996
  eInterface,
997
  true,
998
  prototypes::id::MediaSource,
999
  PrototypeTraits<prototypes::id::MediaSource>::Depth,
1000
  sNativePropertyHooks,
1001
  "function MediaSource() {\n    [native code]\n}",
1002
  EventTarget_Binding::GetConstructorObject
1003
};
1004
1005
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1006
  {
1007
    "MediaSourcePrototype",
1008
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
1009
    JS_NULL_CLASS_OPS,
1010
    JS_NULL_CLASS_SPEC,
1011
    JS_NULL_CLASS_EXT,
1012
    JS_NULL_OBJECT_OPS
1013
  },
1014
  eInterfacePrototype,
1015
  false,
1016
  prototypes::id::MediaSource,
1017
  PrototypeTraits<prototypes::id::MediaSource>::Depth,
1018
  sNativePropertyHooks,
1019
  "[object MediaSourcePrototype]",
1020
  EventTarget_Binding::GetProtoObject
1021
};
1022
1023
bool
1024
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
1025
0
{
1026
0
  return mozilla::dom::MediaSource::Enabled(aCx, aObj);
1027
0
}
1028
1029
static const js::ClassOps sClassOps = {
1030
  _addProperty, /* addProperty */
1031
  nullptr,               /* delProperty */
1032
  nullptr,               /* enumerate */
1033
  nullptr, /* newEnumerate */
1034
  nullptr, /* resolve */
1035
  nullptr, /* mayResolve */
1036
  _finalize, /* finalize */
1037
  nullptr, /* call */
1038
  nullptr,               /* hasInstance */
1039
  nullptr,               /* construct */
1040
  nullptr, /* trace */
1041
};
1042
1043
static const js::ClassExtension sClassExtension = {
1044
  nullptr, /* weakmapKeyDelegateOp */
1045
  _objectMoved /* objectMovedOp */
1046
};
1047
1048
static const DOMJSClass sClass = {
1049
  { "MediaSource",
1050
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
1051
    &sClassOps,
1052
    JS_NULL_CLASS_SPEC,
1053
    &sClassExtension,
1054
    JS_NULL_OBJECT_OPS
1055
  },
1056
  { prototypes::id::EventTarget, prototypes::id::MediaSource, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
1057
  IsBaseOf<nsISupports, mozilla::dom::MediaSource >::value,
1058
  sNativePropertyHooks,
1059
  FindAssociatedGlobalForNative<mozilla::dom::MediaSource>::Get,
1060
  GetProtoObjectHandle,
1061
  GetCCParticipant<mozilla::dom::MediaSource>::Get()
1062
};
1063
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
1064
              "Must have the right minimal number of reserved slots.");
1065
static_assert(1 >= 1,
1066
              "Must have enough reserved slots.");
1067
1068
const JSClass*
1069
GetJSClass()
1070
0
{
1071
0
  return sClass.ToJSClass();
1072
0
}
1073
1074
bool
1075
Wrap(JSContext* aCx, mozilla::dom::MediaSource* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1076
0
{
1077
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::MediaSource>::value,
1078
0
                "Shouldn't have wrappercached things that are not refcounted.");
1079
0
  MOZ_ASSERT(static_cast<mozilla::dom::MediaSource*>(aObject) ==
1080
0
             reinterpret_cast<mozilla::dom::MediaSource*>(aObject),
1081
0
             "Multiple inheritance for mozilla::dom::MediaSource is broken.");
1082
0
  MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
1083
0
             reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
1084
0
             "Multiple inheritance for mozilla::dom::EventTarget is broken.");
1085
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1086
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1087
0
  MOZ_ASSERT(!aCache->GetWrapper(),
1088
0
             "You should probably not be using Wrap() directly; use "
1089
0
             "GetOrCreateDOMReflector instead");
1090
0
1091
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1092
0
             "nsISupports must be on our primary inheritance chain");
1093
0
1094
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1095
0
  if (!global) {
1096
0
    return false;
1097
0
  }
1098
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
1099
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
1100
0
1101
0
  // That might have ended up wrapping us already, due to the wonders
1102
0
  // of XBL.  Check for that, and bail out as needed.
1103
0
  aReflector.set(aCache->GetWrapper());
1104
0
  if (aReflector) {
1105
#ifdef DEBUG
1106
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1107
#endif // DEBUG
1108
    return true;
1109
0
  }
1110
0
1111
0
  JSAutoRealm ar(aCx, global);
1112
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1113
0
  if (!canonicalProto) {
1114
0
    return false;
1115
0
  }
1116
0
  JS::Rooted<JSObject*> proto(aCx);
1117
0
  if (aGivenProto) {
1118
0
    proto = aGivenProto;
1119
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
1120
0
    // coming in, we changed compartments to that of "parent" so may need
1121
0
    // to wrap the proto here.
1122
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1123
0
      if (!JS_WrapObject(aCx, &proto)) {
1124
0
        return false;
1125
0
      }
1126
0
    }
1127
0
  } else {
1128
0
    proto = canonicalProto;
1129
0
  }
1130
0
1131
0
  BindingJSObjectCreator<mozilla::dom::MediaSource> creator(aCx);
1132
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
1133
0
  if (!aReflector) {
1134
0
    return false;
1135
0
  }
1136
0
1137
0
  aCache->SetWrapper(aReflector);
1138
0
  creator.InitializationSucceeded();
1139
0
1140
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1141
0
             aCache->GetWrapperPreserveColor() == aReflector);
1142
0
  // If proto != canonicalProto, we have to preserve our wrapper;
1143
0
  // otherwise we won't be able to properly recreate it later, since
1144
0
  // we won't know what proto to use.  Note that we don't check
1145
0
  // aGivenProto here, since it's entirely possible (and even
1146
0
  // somewhat common) to have a non-null aGivenProto which is the
1147
0
  // same as canonicalProto.
1148
0
  if (proto != canonicalProto) {
1149
0
    PreserveWrapper(aObject);
1150
0
  }
1151
0
1152
0
  return true;
1153
0
}
1154
1155
const NativePropertyHooks sNativePropertyHooks[] = { {
1156
  nullptr,
1157
  nullptr,
1158
  nullptr,
1159
  { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
1160
  prototypes::id::MediaSource,
1161
  constructors::id::MediaSource,
1162
  EventTarget_Binding::sNativePropertyHooks,
1163
  &DefaultXrayExpandoObjectClass
1164
} };
1165
1166
void
1167
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1168
0
{
1169
0
  JS::Handle<JSObject*> parentProto(EventTarget_Binding::GetProtoObjectHandle(aCx));
1170
0
  if (!parentProto) {
1171
0
    return;
1172
0
  }
1173
0
1174
0
  JS::Handle<JSObject*> constructorProto(EventTarget_Binding::GetConstructorObjectHandle(aCx));
1175
0
  if (!constructorProto) {
1176
0
    return;
1177
0
  }
1178
0
1179
0
  static bool sIdsInited = false;
1180
0
  if (!sIdsInited && NS_IsMainThread()) {
1181
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
1182
0
      return;
1183
0
    }
1184
0
    if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
1185
0
      return;
1186
0
    }
1187
0
    sIdsInited = true;
1188
0
  }
1189
0
1190
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::MediaSource);
1191
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::MediaSource);
1192
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1193
0
                              &sPrototypeClass.mBase, protoCache,
1194
0
                              nullptr,
1195
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
1196
0
                              interfaceCache,
1197
0
                              sNativeProperties.Upcast(),
1198
0
                              sChromeOnlyNativeProperties.Upcast(),
1199
0
                              "MediaSource", aDefineOnGlobal,
1200
0
                              nullptr,
1201
0
                              false);
1202
0
}
1203
1204
JSObject*
1205
GetConstructorObject(JSContext* aCx)
1206
0
{
1207
0
  return GetConstructorObjectHandle(aCx);
1208
0
}
1209
1210
} // namespace MediaSource_Binding
1211
1212
1213
1214
} // namespace dom
1215
} // namespace mozilla