Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/MediaStreamTrackBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM MediaStreamTrack.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "AtomList.h"
4
#include "EventHandlerBinding.h"
5
#include "EventTargetBinding.h"
6
#include "MediaStreamTrackBinding.h"
7
#include "MediaTrackSettingsBinding.h"
8
#include "WrapperFactory.h"
9
#include "jsapi.h"
10
#include "mozilla/FloatingPoint.h"
11
#include "mozilla/OwningNonNull.h"
12
#include "mozilla/dom/BindingUtils.h"
13
#include "mozilla/dom/DOMJSClass.h"
14
#include "mozilla/dom/MediaStreamTrack.h"
15
#include "mozilla/dom/NonRefcountedDOMObject.h"
16
#include "mozilla/dom/Nullable.h"
17
#include "mozilla/dom/PrimitiveConversions.h"
18
#include "mozilla/dom/Promise.h"
19
#include "mozilla/dom/ScriptSettings.h"
20
#include "mozilla/dom/SimpleGlobalObject.h"
21
#include "mozilla/dom/ToJSValue.h"
22
#include "mozilla/dom/UnionConversions.h"
23
#include "mozilla/dom/XrayExpandoClass.h"
24
#include "nsContentUtils.h"
25
26
namespace mozilla {
27
namespace dom {
28
29
namespace binding_detail {}; // Just to make sure it's known as a namespace
30
using namespace mozilla::dom::binding_detail;
31
32
33
namespace VideoFacingModeEnumValues {
34
extern const EnumEntry strings[5] = {
35
  {"user", 4},
36
  {"environment", 11},
37
  {"left", 4},
38
  {"right", 5},
39
  { nullptr, 0 }
40
};
41
} // namespace VideoFacingModeEnumValues
42
43
bool
44
ToJSValue(JSContext* aCx, VideoFacingModeEnum aArgument, JS::MutableHandle<JS::Value> aValue)
45
0
{
46
0
  MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(VideoFacingModeEnumValues::strings));
47
0
  JSString* resultStr =
48
0
    JS_NewStringCopyN(aCx, VideoFacingModeEnumValues::strings[uint32_t(aArgument)].value,
49
0
                      VideoFacingModeEnumValues::strings[uint32_t(aArgument)].length);
50
0
  if (!resultStr) {
51
0
    return false;
52
0
  }
53
0
  aValue.setString(resultStr);
54
0
  return true;
55
0
}
56
57
58
namespace MediaSourceEnumValues {
59
extern const EnumEntry strings[9] = {
60
  {"camera", 6},
61
  {"screen", 6},
62
  {"application", 11},
63
  {"window", 6},
64
  {"browser", 7},
65
  {"microphone", 10},
66
  {"audioCapture", 12},
67
  {"other", 5},
68
  { nullptr, 0 }
69
};
70
} // namespace MediaSourceEnumValues
71
72
bool
73
ToJSValue(JSContext* aCx, MediaSourceEnum aArgument, JS::MutableHandle<JS::Value> aValue)
74
0
{
75
0
  MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(MediaSourceEnumValues::strings));
76
0
  JSString* resultStr =
77
0
    JS_NewStringCopyN(aCx, MediaSourceEnumValues::strings[uint32_t(aArgument)].value,
78
0
                      MediaSourceEnumValues::strings[uint32_t(aArgument)].length);
79
0
  if (!resultStr) {
80
0
    return false;
81
0
  }
82
0
  aValue.setString(resultStr);
83
0
  return true;
84
0
}
85
86
87
namespace MediaStreamTrackStateValues {
88
extern const EnumEntry strings[3] = {
89
  {"live", 4},
90
  {"ended", 5},
91
  { nullptr, 0 }
92
};
93
} // namespace MediaStreamTrackStateValues
94
95
bool
96
ToJSValue(JSContext* aCx, MediaStreamTrackState aArgument, JS::MutableHandle<JS::Value> aValue)
97
0
{
98
0
  MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(MediaStreamTrackStateValues::strings));
99
0
  JSString* resultStr =
100
0
    JS_NewStringCopyN(aCx, MediaStreamTrackStateValues::strings[uint32_t(aArgument)].value,
101
0
                      MediaStreamTrackStateValues::strings[uint32_t(aArgument)].length);
102
0
  if (!resultStr) {
103
0
    return false;
104
0
  }
105
0
  aValue.setString(resultStr);
106
0
  return true;
107
0
}
108
109
110
bool
111
BooleanOrConstrainBooleanParameters::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
112
0
{
113
0
  switch (mType) {
114
0
    case eUninitialized: {
115
0
      return false;
116
0
      break;
117
0
    }
118
0
    case eBoolean: {
119
0
      rval.setBoolean(mValue.mBoolean.Value());
120
0
      return true;
121
0
      break;
122
0
    }
123
0
    case eConstrainBooleanParameters: {
124
0
      if (!mValue.mConstrainBooleanParameters.Value().ToObjectInternal(cx, rval)) {
125
0
        return false;
126
0
      }
127
0
      return true;
128
0
      break;
129
0
    }
130
0
    default: {
131
0
      return false;
132
0
      break;
133
0
    }
134
0
  }
135
0
136
0
  return false;
137
0
}
138
139
140
bool&
141
OwningBooleanOrConstrainBooleanParameters::RawSetAsBoolean()
142
0
{
143
0
  if (mType == eBoolean) {
144
0
    return mValue.mBoolean.Value();
145
0
  }
146
0
  MOZ_ASSERT(mType == eUninitialized);
147
0
  mType = eBoolean;
148
0
  return mValue.mBoolean.SetValue();
149
0
}
150
151
bool&
152
OwningBooleanOrConstrainBooleanParameters::SetAsBoolean()
153
0
{
154
0
  if (mType == eBoolean) {
155
0
    return mValue.mBoolean.Value();
156
0
  }
157
0
  Uninit();
158
0
  mType = eBoolean;
159
0
  return mValue.mBoolean.SetValue();
160
0
}
161
162
bool
163
OwningBooleanOrConstrainBooleanParameters::TrySetToBoolean(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
164
0
{
165
0
  tryNext = false;
166
0
  { // scope for memberSlot
167
0
    bool& memberSlot = RawSetAsBoolean();
168
0
    if (!ValueToPrimitive<bool, eDefault>(cx, value, &memberSlot)) {
169
0
      return false;
170
0
    }
171
0
  }
172
0
  return true;
173
0
}
174
175
void
176
OwningBooleanOrConstrainBooleanParameters::DestroyBoolean()
177
0
{
178
0
  MOZ_ASSERT(IsBoolean(), "Wrong type!");
179
0
  mValue.mBoolean.Destroy();
180
0
  mType = eUninitialized;
181
0
}
182
183
184
185
186
ConstrainBooleanParameters&
187
OwningBooleanOrConstrainBooleanParameters::RawSetAsConstrainBooleanParameters()
188
0
{
189
0
  if (mType == eConstrainBooleanParameters) {
190
0
    return mValue.mConstrainBooleanParameters.Value();
191
0
  }
192
0
  MOZ_ASSERT(mType == eUninitialized);
193
0
  mType = eConstrainBooleanParameters;
194
0
  return mValue.mConstrainBooleanParameters.SetValue();
195
0
}
196
197
ConstrainBooleanParameters&
198
OwningBooleanOrConstrainBooleanParameters::SetAsConstrainBooleanParameters()
199
0
{
200
0
  if (mType == eConstrainBooleanParameters) {
201
0
    return mValue.mConstrainBooleanParameters.Value();
202
0
  }
203
0
  Uninit();
204
0
  mType = eConstrainBooleanParameters;
205
0
  return mValue.mConstrainBooleanParameters.SetValue();
206
0
}
207
208
bool
209
OwningBooleanOrConstrainBooleanParameters::TrySetToConstrainBooleanParameters(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
210
0
{
211
0
  tryNext = false;
212
0
  { // scope for memberSlot
213
0
    ConstrainBooleanParameters& memberSlot = RawSetAsConstrainBooleanParameters();
214
0
    if (!IsConvertibleToDictionary(value)) {
215
0
      DestroyConstrainBooleanParameters();
216
0
      tryNext = true;
217
0
      return true;
218
0
    }
219
0
    if (!memberSlot.Init(cx, value,  "Member of BooleanOrConstrainBooleanParameters", passedToJSImpl)) {
220
0
      return false;
221
0
    }
222
0
  }
223
0
  return true;
224
0
}
225
226
void
227
OwningBooleanOrConstrainBooleanParameters::DestroyConstrainBooleanParameters()
228
0
{
229
0
  MOZ_ASSERT(IsConstrainBooleanParameters(), "Wrong type!");
230
0
  mValue.mConstrainBooleanParameters.Destroy();
231
0
  mType = eUninitialized;
232
0
}
233
234
235
236
237
void
238
OwningBooleanOrConstrainBooleanParameters::Uninit()
239
{
240
  switch (mType) {
241
    case eUninitialized: {
242
      break;
243
    }
244
    case eBoolean: {
245
      DestroyBoolean();
246
      break;
247
    }
248
    case eConstrainBooleanParameters: {
249
      DestroyConstrainBooleanParameters();
250
      break;
251
    }
252
  }
253
}
254
255
bool
256
OwningBooleanOrConstrainBooleanParameters::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
257
0
{
258
0
  switch (mType) {
259
0
    case eUninitialized: {
260
0
      return false;
261
0
      break;
262
0
    }
263
0
    case eBoolean: {
264
0
      rval.setBoolean(mValue.mBoolean.Value());
265
0
      return true;
266
0
      break;
267
0
    }
268
0
    case eConstrainBooleanParameters: {
269
0
      if (!mValue.mConstrainBooleanParameters.Value().ToObjectInternal(cx, rval)) {
270
0
        return false;
271
0
      }
272
0
      return true;
273
0
      break;
274
0
    }
275
0
    default: {
276
0
      return false;
277
0
      break;
278
0
    }
279
0
  }
280
0
281
0
  return false;
282
0
}
283
284
void
285
OwningBooleanOrConstrainBooleanParameters::TraceUnion(JSTracer* trc)
286
0
{
287
0
}
288
289
OwningBooleanOrConstrainBooleanParameters&
290
OwningBooleanOrConstrainBooleanParameters::operator=(const OwningBooleanOrConstrainBooleanParameters& aOther)
291
0
{
292
0
  switch (aOther.mType) {
293
0
    case eUninitialized: {
294
0
      MOZ_ASSERT(mType == eUninitialized,
295
0
                 "We need to destroy ourselves?");
296
0
      break;
297
0
    }
298
0
    case eBoolean: {
299
0
      SetAsBoolean() = aOther.GetAsBoolean();
300
0
      break;
301
0
    }
302
0
    case eConstrainBooleanParameters: {
303
0
      SetAsConstrainBooleanParameters() = aOther.GetAsConstrainBooleanParameters();
304
0
      break;
305
0
    }
306
0
  }
307
0
  return *this;
308
0
}
309
310
311
bool
312
DoubleOrConstrainDoubleRange::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
313
0
{
314
0
  switch (mType) {
315
0
    case eUninitialized: {
316
0
      return false;
317
0
      break;
318
0
    }
319
0
    case eDouble: {
320
0
      rval.set(JS_NumberValue(double(mValue.mDouble.Value())));
321
0
      return true;
322
0
      break;
323
0
    }
324
0
    case eConstrainDoubleRange: {
325
0
      if (!mValue.mConstrainDoubleRange.Value().ToObjectInternal(cx, rval)) {
326
0
        return false;
327
0
      }
328
0
      return true;
329
0
      break;
330
0
    }
331
0
    default: {
332
0
      return false;
333
0
      break;
334
0
    }
335
0
  }
336
0
337
0
  return false;
338
0
}
339
340
341
double&
342
OwningDoubleOrConstrainDoubleRange::RawSetAsDouble()
343
0
{
344
0
  if (mType == eDouble) {
345
0
    return mValue.mDouble.Value();
346
0
  }
347
0
  MOZ_ASSERT(mType == eUninitialized);
348
0
  mType = eDouble;
349
0
  return mValue.mDouble.SetValue();
350
0
}
351
352
double&
353
OwningDoubleOrConstrainDoubleRange::SetAsDouble()
354
0
{
355
0
  if (mType == eDouble) {
356
0
    return mValue.mDouble.Value();
357
0
  }
358
0
  Uninit();
359
0
  mType = eDouble;
360
0
  return mValue.mDouble.SetValue();
361
0
}
362
363
bool
364
OwningDoubleOrConstrainDoubleRange::TrySetToDouble(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
365
0
{
366
0
  tryNext = false;
367
0
  { // scope for memberSlot
368
0
    double& memberSlot = RawSetAsDouble();
369
0
    if (!ValueToPrimitive<double, eDefault>(cx, value, &memberSlot)) {
370
0
      return false;
371
0
    } else if (!mozilla::IsFinite(memberSlot)) {
372
0
      ThrowErrorMessage(cx, MSG_NOT_FINITE, "Member of DoubleOrConstrainDoubleRange");
373
0
      return false;
374
0
    }
375
0
  }
376
0
  return true;
377
0
}
378
379
void
380
OwningDoubleOrConstrainDoubleRange::DestroyDouble()
381
0
{
382
0
  MOZ_ASSERT(IsDouble(), "Wrong type!");
383
0
  mValue.mDouble.Destroy();
384
0
  mType = eUninitialized;
385
0
}
386
387
388
389
390
ConstrainDoubleRange&
391
OwningDoubleOrConstrainDoubleRange::RawSetAsConstrainDoubleRange()
392
0
{
393
0
  if (mType == eConstrainDoubleRange) {
394
0
    return mValue.mConstrainDoubleRange.Value();
395
0
  }
396
0
  MOZ_ASSERT(mType == eUninitialized);
397
0
  mType = eConstrainDoubleRange;
398
0
  return mValue.mConstrainDoubleRange.SetValue();
399
0
}
400
401
ConstrainDoubleRange&
402
OwningDoubleOrConstrainDoubleRange::SetAsConstrainDoubleRange()
403
0
{
404
0
  if (mType == eConstrainDoubleRange) {
405
0
    return mValue.mConstrainDoubleRange.Value();
406
0
  }
407
0
  Uninit();
408
0
  mType = eConstrainDoubleRange;
409
0
  return mValue.mConstrainDoubleRange.SetValue();
410
0
}
411
412
bool
413
OwningDoubleOrConstrainDoubleRange::TrySetToConstrainDoubleRange(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
414
0
{
415
0
  tryNext = false;
416
0
  { // scope for memberSlot
417
0
    ConstrainDoubleRange& memberSlot = RawSetAsConstrainDoubleRange();
418
0
    if (!IsConvertibleToDictionary(value)) {
419
0
      DestroyConstrainDoubleRange();
420
0
      tryNext = true;
421
0
      return true;
422
0
    }
423
0
    if (!memberSlot.Init(cx, value,  "Member of DoubleOrConstrainDoubleRange", passedToJSImpl)) {
424
0
      return false;
425
0
    }
426
0
  }
427
0
  return true;
428
0
}
429
430
void
431
OwningDoubleOrConstrainDoubleRange::DestroyConstrainDoubleRange()
432
0
{
433
0
  MOZ_ASSERT(IsConstrainDoubleRange(), "Wrong type!");
434
0
  mValue.mConstrainDoubleRange.Destroy();
435
0
  mType = eUninitialized;
436
0
}
437
438
439
440
441
void
442
OwningDoubleOrConstrainDoubleRange::Uninit()
443
{
444
  switch (mType) {
445
    case eUninitialized: {
446
      break;
447
    }
448
    case eDouble: {
449
      DestroyDouble();
450
      break;
451
    }
452
    case eConstrainDoubleRange: {
453
      DestroyConstrainDoubleRange();
454
      break;
455
    }
456
  }
457
}
458
459
bool
460
OwningDoubleOrConstrainDoubleRange::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
461
0
{
462
0
  switch (mType) {
463
0
    case eUninitialized: {
464
0
      return false;
465
0
      break;
466
0
    }
467
0
    case eDouble: {
468
0
      rval.set(JS_NumberValue(double(mValue.mDouble.Value())));
469
0
      return true;
470
0
      break;
471
0
    }
472
0
    case eConstrainDoubleRange: {
473
0
      if (!mValue.mConstrainDoubleRange.Value().ToObjectInternal(cx, rval)) {
474
0
        return false;
475
0
      }
476
0
      return true;
477
0
      break;
478
0
    }
479
0
    default: {
480
0
      return false;
481
0
      break;
482
0
    }
483
0
  }
484
0
485
0
  return false;
486
0
}
487
488
void
489
OwningDoubleOrConstrainDoubleRange::TraceUnion(JSTracer* trc)
490
0
{
491
0
}
492
493
OwningDoubleOrConstrainDoubleRange&
494
OwningDoubleOrConstrainDoubleRange::operator=(const OwningDoubleOrConstrainDoubleRange& aOther)
495
0
{
496
0
  switch (aOther.mType) {
497
0
    case eUninitialized: {
498
0
      MOZ_ASSERT(mType == eUninitialized,
499
0
                 "We need to destroy ourselves?");
500
0
      break;
501
0
    }
502
0
    case eDouble: {
503
0
      SetAsDouble() = aOther.GetAsDouble();
504
0
      break;
505
0
    }
506
0
    case eConstrainDoubleRange: {
507
0
      SetAsConstrainDoubleRange() = aOther.GetAsConstrainDoubleRange();
508
0
      break;
509
0
    }
510
0
  }
511
0
  return *this;
512
0
}
513
514
515
bool
516
LongOrConstrainLongRange::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
517
0
{
518
0
  switch (mType) {
519
0
    case eUninitialized: {
520
0
      return false;
521
0
      break;
522
0
    }
523
0
    case eLong: {
524
0
      rval.setInt32(int32_t(mValue.mLong.Value()));
525
0
      return true;
526
0
      break;
527
0
    }
528
0
    case eConstrainLongRange: {
529
0
      if (!mValue.mConstrainLongRange.Value().ToObjectInternal(cx, rval)) {
530
0
        return false;
531
0
      }
532
0
      return true;
533
0
      break;
534
0
    }
535
0
    default: {
536
0
      return false;
537
0
      break;
538
0
    }
539
0
  }
540
0
541
0
  return false;
542
0
}
543
544
545
int32_t&
546
OwningLongOrConstrainLongRange::RawSetAsLong()
547
0
{
548
0
  if (mType == eLong) {
549
0
    return mValue.mLong.Value();
550
0
  }
551
0
  MOZ_ASSERT(mType == eUninitialized);
552
0
  mType = eLong;
553
0
  return mValue.mLong.SetValue();
554
0
}
555
556
int32_t&
557
OwningLongOrConstrainLongRange::SetAsLong()
558
0
{
559
0
  if (mType == eLong) {
560
0
    return mValue.mLong.Value();
561
0
  }
562
0
  Uninit();
563
0
  mType = eLong;
564
0
  return mValue.mLong.SetValue();
565
0
}
566
567
bool
568
OwningLongOrConstrainLongRange::TrySetToLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
569
0
{
570
0
  tryNext = false;
571
0
  { // scope for memberSlot
572
0
    int32_t& memberSlot = RawSetAsLong();
573
0
    if (!ValueToPrimitive<int32_t, eDefault>(cx, value, &memberSlot)) {
574
0
      return false;
575
0
    }
576
0
  }
577
0
  return true;
578
0
}
579
580
void
581
OwningLongOrConstrainLongRange::DestroyLong()
582
0
{
583
0
  MOZ_ASSERT(IsLong(), "Wrong type!");
584
0
  mValue.mLong.Destroy();
585
0
  mType = eUninitialized;
586
0
}
587
588
589
590
591
ConstrainLongRange&
592
OwningLongOrConstrainLongRange::RawSetAsConstrainLongRange()
593
0
{
594
0
  if (mType == eConstrainLongRange) {
595
0
    return mValue.mConstrainLongRange.Value();
596
0
  }
597
0
  MOZ_ASSERT(mType == eUninitialized);
598
0
  mType = eConstrainLongRange;
599
0
  return mValue.mConstrainLongRange.SetValue();
600
0
}
601
602
ConstrainLongRange&
603
OwningLongOrConstrainLongRange::SetAsConstrainLongRange()
604
0
{
605
0
  if (mType == eConstrainLongRange) {
606
0
    return mValue.mConstrainLongRange.Value();
607
0
  }
608
0
  Uninit();
609
0
  mType = eConstrainLongRange;
610
0
  return mValue.mConstrainLongRange.SetValue();
611
0
}
612
613
bool
614
OwningLongOrConstrainLongRange::TrySetToConstrainLongRange(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
615
0
{
616
0
  tryNext = false;
617
0
  { // scope for memberSlot
618
0
    ConstrainLongRange& memberSlot = RawSetAsConstrainLongRange();
619
0
    if (!IsConvertibleToDictionary(value)) {
620
0
      DestroyConstrainLongRange();
621
0
      tryNext = true;
622
0
      return true;
623
0
    }
624
0
    if (!memberSlot.Init(cx, value,  "Member of LongOrConstrainLongRange", passedToJSImpl)) {
625
0
      return false;
626
0
    }
627
0
  }
628
0
  return true;
629
0
}
630
631
void
632
OwningLongOrConstrainLongRange::DestroyConstrainLongRange()
633
0
{
634
0
  MOZ_ASSERT(IsConstrainLongRange(), "Wrong type!");
635
0
  mValue.mConstrainLongRange.Destroy();
636
0
  mType = eUninitialized;
637
0
}
638
639
640
641
642
void
643
OwningLongOrConstrainLongRange::Uninit()
644
{
645
  switch (mType) {
646
    case eUninitialized: {
647
      break;
648
    }
649
    case eLong: {
650
      DestroyLong();
651
      break;
652
    }
653
    case eConstrainLongRange: {
654
      DestroyConstrainLongRange();
655
      break;
656
    }
657
  }
658
}
659
660
bool
661
OwningLongOrConstrainLongRange::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
662
0
{
663
0
  switch (mType) {
664
0
    case eUninitialized: {
665
0
      return false;
666
0
      break;
667
0
    }
668
0
    case eLong: {
669
0
      rval.setInt32(int32_t(mValue.mLong.Value()));
670
0
      return true;
671
0
      break;
672
0
    }
673
0
    case eConstrainLongRange: {
674
0
      if (!mValue.mConstrainLongRange.Value().ToObjectInternal(cx, rval)) {
675
0
        return false;
676
0
      }
677
0
      return true;
678
0
      break;
679
0
    }
680
0
    default: {
681
0
      return false;
682
0
      break;
683
0
    }
684
0
  }
685
0
686
0
  return false;
687
0
}
688
689
void
690
OwningLongOrConstrainLongRange::TraceUnion(JSTracer* trc)
691
0
{
692
0
}
693
694
OwningLongOrConstrainLongRange&
695
OwningLongOrConstrainLongRange::operator=(const OwningLongOrConstrainLongRange& aOther)
696
0
{
697
0
  switch (aOther.mType) {
698
0
    case eUninitialized: {
699
0
      MOZ_ASSERT(mType == eUninitialized,
700
0
                 "We need to destroy ourselves?");
701
0
      break;
702
0
    }
703
0
    case eLong: {
704
0
      SetAsLong() = aOther.GetAsLong();
705
0
      break;
706
0
    }
707
0
    case eConstrainLongRange: {
708
0
      SetAsConstrainLongRange() = aOther.GetAsConstrainLongRange();
709
0
      break;
710
0
    }
711
0
  }
712
0
  return *this;
713
0
}
714
715
716
bool
717
StringOrStringSequenceOrConstrainDOMStringParameters::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
718
0
{
719
0
  switch (mType) {
720
0
    case eUninitialized: {
721
0
      return false;
722
0
      break;
723
0
    }
724
0
    case eString: {
725
0
      if (!xpc::NonVoidStringToJsval(cx, mValue.mString.Value(), rval)) {
726
0
        return false;
727
0
      }
728
0
      return true;
729
0
      break;
730
0
    }
731
0
    case eStringSequence: {
732
0
733
0
      uint32_t length = mValue.mStringSequence.Value().Length();
734
0
      JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
735
0
      if (!returnArray) {
736
0
        return false;
737
0
      }
738
0
      // Scope for 'tmp'
739
0
      {
740
0
        JS::Rooted<JS::Value> tmp(cx);
741
0
        for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
742
0
          // Control block to let us common up the JS_DefineElement calls when there
743
0
          // are different ways to succeed at wrapping the object.
744
0
          do {
745
0
            if (!xpc::NonVoidStringToJsval(cx, mValue.mStringSequence.Value()[sequenceIdx0], &tmp)) {
746
0
              return false;
747
0
            }
748
0
            break;
749
0
          } while (false);
750
0
          if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
751
0
                                JSPROP_ENUMERATE)) {
752
0
            return false;
753
0
          }
754
0
        }
755
0
      }
756
0
      rval.setObject(*returnArray);
757
0
      return true;
758
0
      break;
759
0
    }
760
0
    case eConstrainDOMStringParameters: {
761
0
      if (!mValue.mConstrainDOMStringParameters.Value().ToObjectInternal(cx, rval)) {
762
0
        return false;
763
0
      }
764
0
      return true;
765
0
      break;
766
0
    }
767
0
    default: {
768
0
      return false;
769
0
      break;
770
0
    }
771
0
  }
772
0
773
0
  return false;
774
0
}
775
776
777
nsString&
778
OwningStringOrStringSequenceOrConstrainDOMStringParameters::RawSetAsString()
779
0
{
780
0
  if (mType == eString) {
781
0
    return mValue.mString.Value();
782
0
  }
783
0
  MOZ_ASSERT(mType == eUninitialized);
784
0
  mType = eString;
785
0
  return mValue.mString.SetValue();
786
0
}
787
788
nsString&
789
OwningStringOrStringSequenceOrConstrainDOMStringParameters::SetAsString()
790
0
{
791
0
  if (mType == eString) {
792
0
    return mValue.mString.Value();
793
0
  }
794
0
  Uninit();
795
0
  mType = eString;
796
0
  return mValue.mString.SetValue();
797
0
}
798
799
bool
800
OwningStringOrStringSequenceOrConstrainDOMStringParameters::TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
801
0
{
802
0
  tryNext = false;
803
0
  { // scope for memberSlot
804
0
    nsString& memberSlot = RawSetAsString();
805
0
    if (!ConvertJSValueToString(cx, value, eStringify, eStringify, memberSlot)) {
806
0
      return false;
807
0
    }
808
0
  }
809
0
  return true;
810
0
}
811
812
813
void
814
OwningStringOrStringSequenceOrConstrainDOMStringParameters::DestroyString()
815
0
{
816
0
  MOZ_ASSERT(IsString(), "Wrong type!");
817
0
  mValue.mString.Destroy();
818
0
  mType = eUninitialized;
819
0
}
820
821
822
823
824
Sequence<nsString>&
825
OwningStringOrStringSequenceOrConstrainDOMStringParameters::RawSetAsStringSequence()
826
0
{
827
0
  if (mType == eStringSequence) {
828
0
    return mValue.mStringSequence.Value();
829
0
  }
830
0
  MOZ_ASSERT(mType == eUninitialized);
831
0
  mType = eStringSequence;
832
0
  return mValue.mStringSequence.SetValue();
833
0
}
834
835
Sequence<nsString>&
836
OwningStringOrStringSequenceOrConstrainDOMStringParameters::SetAsStringSequence()
837
0
{
838
0
  if (mType == eStringSequence) {
839
0
    return mValue.mStringSequence.Value();
840
0
  }
841
0
  Uninit();
842
0
  mType = eStringSequence;
843
0
  return mValue.mStringSequence.SetValue();
844
0
}
845
846
bool
847
OwningStringOrStringSequenceOrConstrainDOMStringParameters::TrySetToStringSequence(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
848
0
{
849
0
  tryNext = false;
850
0
  { // scope for memberSlot
851
0
    Sequence<nsString>& memberSlot = RawSetAsStringSequence();
852
0
    JS::ForOfIterator iter(cx);
853
0
    if (!iter.init(value, JS::ForOfIterator::AllowNonIterable)) {
854
0
      return false;
855
0
    }
856
0
    if (!iter.valueIsIterable()) {
857
0
      DestroyStringSequence();
858
0
      tryNext = true;
859
0
      return true;
860
0
    }
861
0
    Sequence<nsString> &arr = memberSlot;
862
0
    JS::Rooted<JS::Value> temp(cx);
863
0
    while (true) {
864
0
      bool done;
865
0
      if (!iter.next(&temp, &done)) {
866
0
        return false;
867
0
      }
868
0
      if (done) {
869
0
        break;
870
0
      }
871
0
      nsString* slotPtr = arr.AppendElement(mozilla::fallible);
872
0
      if (!slotPtr) {
873
0
        JS_ReportOutOfMemory(cx);
874
0
        return false;
875
0
      }
876
0
      nsString& slot = *slotPtr;
877
0
      if (!ConvertJSValueToString(cx, temp, eStringify, eStringify, slot)) {
878
0
        return false;
879
0
      }
880
0
    }
881
0
  }
882
0
  return true;
883
0
}
884
885
void
886
OwningStringOrStringSequenceOrConstrainDOMStringParameters::DestroyStringSequence()
887
0
{
888
0
  MOZ_ASSERT(IsStringSequence(), "Wrong type!");
889
0
  mValue.mStringSequence.Destroy();
890
0
  mType = eUninitialized;
891
0
}
892
893
894
895
896
ConstrainDOMStringParameters&
897
OwningStringOrStringSequenceOrConstrainDOMStringParameters::RawSetAsConstrainDOMStringParameters()
898
0
{
899
0
  if (mType == eConstrainDOMStringParameters) {
900
0
    return mValue.mConstrainDOMStringParameters.Value();
901
0
  }
902
0
  MOZ_ASSERT(mType == eUninitialized);
903
0
  mType = eConstrainDOMStringParameters;
904
0
  return mValue.mConstrainDOMStringParameters.SetValue();
905
0
}
906
907
ConstrainDOMStringParameters&
908
OwningStringOrStringSequenceOrConstrainDOMStringParameters::SetAsConstrainDOMStringParameters()
909
0
{
910
0
  if (mType == eConstrainDOMStringParameters) {
911
0
    return mValue.mConstrainDOMStringParameters.Value();
912
0
  }
913
0
  Uninit();
914
0
  mType = eConstrainDOMStringParameters;
915
0
  return mValue.mConstrainDOMStringParameters.SetValue();
916
0
}
917
918
bool
919
OwningStringOrStringSequenceOrConstrainDOMStringParameters::TrySetToConstrainDOMStringParameters(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
920
0
{
921
0
  tryNext = false;
922
0
  { // scope for memberSlot
923
0
    ConstrainDOMStringParameters& memberSlot = RawSetAsConstrainDOMStringParameters();
924
0
    if (!IsConvertibleToDictionary(value)) {
925
0
      DestroyConstrainDOMStringParameters();
926
0
      tryNext = true;
927
0
      return true;
928
0
    }
929
0
    if (!memberSlot.Init(cx, value,  "Member of StringOrStringSequenceOrConstrainDOMStringParameters", passedToJSImpl)) {
930
0
      return false;
931
0
    }
932
0
  }
933
0
  return true;
934
0
}
935
936
void
937
OwningStringOrStringSequenceOrConstrainDOMStringParameters::DestroyConstrainDOMStringParameters()
938
0
{
939
0
  MOZ_ASSERT(IsConstrainDOMStringParameters(), "Wrong type!");
940
0
  mValue.mConstrainDOMStringParameters.Destroy();
941
0
  mType = eUninitialized;
942
0
}
943
944
945
946
947
void
948
OwningStringOrStringSequenceOrConstrainDOMStringParameters::Uninit()
949
{
950
  switch (mType) {
951
    case eUninitialized: {
952
      break;
953
    }
954
    case eString: {
955
      DestroyString();
956
      break;
957
    }
958
    case eStringSequence: {
959
      DestroyStringSequence();
960
      break;
961
    }
962
    case eConstrainDOMStringParameters: {
963
      DestroyConstrainDOMStringParameters();
964
      break;
965
    }
966
  }
967
}
968
969
bool
970
OwningStringOrStringSequenceOrConstrainDOMStringParameters::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
971
0
{
972
0
  switch (mType) {
973
0
    case eUninitialized: {
974
0
      return false;
975
0
      break;
976
0
    }
977
0
    case eString: {
978
0
      if (!xpc::NonVoidStringToJsval(cx, mValue.mString.Value(), rval)) {
979
0
        return false;
980
0
      }
981
0
      return true;
982
0
      break;
983
0
    }
984
0
    case eStringSequence: {
985
0
986
0
      uint32_t length = mValue.mStringSequence.Value().Length();
987
0
      JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
988
0
      if (!returnArray) {
989
0
        return false;
990
0
      }
991
0
      // Scope for 'tmp'
992
0
      {
993
0
        JS::Rooted<JS::Value> tmp(cx);
994
0
        for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
995
0
          // Control block to let us common up the JS_DefineElement calls when there
996
0
          // are different ways to succeed at wrapping the object.
997
0
          do {
998
0
            if (!xpc::NonVoidStringToJsval(cx, mValue.mStringSequence.Value()[sequenceIdx0], &tmp)) {
999
0
              return false;
1000
0
            }
1001
0
            break;
1002
0
          } while (false);
1003
0
          if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
1004
0
                                JSPROP_ENUMERATE)) {
1005
0
            return false;
1006
0
          }
1007
0
        }
1008
0
      }
1009
0
      rval.setObject(*returnArray);
1010
0
      return true;
1011
0
      break;
1012
0
    }
1013
0
    case eConstrainDOMStringParameters: {
1014
0
      if (!mValue.mConstrainDOMStringParameters.Value().ToObjectInternal(cx, rval)) {
1015
0
        return false;
1016
0
      }
1017
0
      return true;
1018
0
      break;
1019
0
    }
1020
0
    default: {
1021
0
      return false;
1022
0
      break;
1023
0
    }
1024
0
  }
1025
0
1026
0
  return false;
1027
0
}
1028
1029
void
1030
OwningStringOrStringSequenceOrConstrainDOMStringParameters::TraceUnion(JSTracer* trc)
1031
0
{
1032
0
}
1033
1034
OwningStringOrStringSequenceOrConstrainDOMStringParameters&
1035
OwningStringOrStringSequenceOrConstrainDOMStringParameters::operator=(const OwningStringOrStringSequenceOrConstrainDOMStringParameters& aOther)
1036
0
{
1037
0
  switch (aOther.mType) {
1038
0
    case eUninitialized: {
1039
0
      MOZ_ASSERT(mType == eUninitialized,
1040
0
                 "We need to destroy ourselves?");
1041
0
      break;
1042
0
    }
1043
0
    case eString: {
1044
0
      SetAsString() = aOther.GetAsString();
1045
0
      break;
1046
0
    }
1047
0
    case eStringSequence: {
1048
0
      SetAsStringSequence() = aOther.GetAsStringSequence();
1049
0
      break;
1050
0
    }
1051
0
    case eConstrainDOMStringParameters: {
1052
0
      SetAsConstrainDOMStringParameters() = aOther.GetAsConstrainDOMStringParameters();
1053
0
      break;
1054
0
    }
1055
0
  }
1056
0
  return *this;
1057
0
}
1058
1059
1060
1061
MediaTrackConstraintSet::MediaTrackConstraintSet()
1062
0
{
1063
0
  // Safe to pass a null context if we pass a null value
1064
0
  Init(nullptr, JS::NullHandleValue);
1065
0
}
1066
1067
1068
1069
bool
1070
MediaTrackConstraintSet::InitIds(JSContext* cx, MediaTrackConstraintSetAtoms* atomsCache)
1071
0
{
1072
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
1073
0
1074
0
  // Initialize these in reverse order so that any failure leaves the first one
1075
0
  // uninitialized.
1076
0
  if (!atomsCache->width_id.init(cx, "width") ||
1077
0
      !atomsCache->viewportWidth_id.init(cx, "viewportWidth") ||
1078
0
      !atomsCache->viewportOffsetY_id.init(cx, "viewportOffsetY") ||
1079
0
      !atomsCache->viewportOffsetX_id.init(cx, "viewportOffsetX") ||
1080
0
      !atomsCache->viewportHeight_id.init(cx, "viewportHeight") ||
1081
0
      !atomsCache->scrollWithPage_id.init(cx, "scrollWithPage") ||
1082
0
      !atomsCache->noiseSuppression_id.init(cx, "noiseSuppression") ||
1083
0
      !atomsCache->mozNoiseSuppression_id.init(cx, "mozNoiseSuppression") ||
1084
0
      !atomsCache->mozAutoGainControl_id.init(cx, "mozAutoGainControl") ||
1085
0
      !atomsCache->mediaSource_id.init(cx, "mediaSource") ||
1086
0
      !atomsCache->height_id.init(cx, "height") ||
1087
0
      !atomsCache->frameRate_id.init(cx, "frameRate") ||
1088
0
      !atomsCache->facingMode_id.init(cx, "facingMode") ||
1089
0
      !atomsCache->echoCancellation_id.init(cx, "echoCancellation") ||
1090
0
      !atomsCache->deviceId_id.init(cx, "deviceId") ||
1091
0
      !atomsCache->channelCount_id.init(cx, "channelCount") ||
1092
0
      !atomsCache->browserWindow_id.init(cx, "browserWindow") ||
1093
0
      !atomsCache->autoGainControl_id.init(cx, "autoGainControl")) {
1094
0
    return false;
1095
0
  }
1096
0
  return true;
1097
0
}
1098
1099
bool
1100
MediaTrackConstraintSet::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
1101
0
{
1102
0
  // Passing a null JSContext is OK only if we're initing from null,
1103
0
  // Since in that case we will not have to do any property gets
1104
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
1105
0
  // checkers by static analysis tools
1106
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
1107
0
  MediaTrackConstraintSetAtoms* atomsCache = nullptr;
1108
0
  if (cx) {
1109
0
    atomsCache = GetAtomCache<MediaTrackConstraintSetAtoms>(cx);
1110
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
1111
0
      return false;
1112
0
    }
1113
0
  }
1114
0
1115
0
  if (!IsConvertibleToDictionary(val)) {
1116
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
1117
0
  }
1118
0
1119
0
  bool isNull = val.isNullOrUndefined();
1120
0
  // We only need these if !isNull, in which case we have |cx|.
1121
0
  Maybe<JS::Rooted<JSObject *> > object;
1122
0
  Maybe<JS::Rooted<JS::Value> > temp;
1123
0
  if (!isNull) {
1124
0
    MOZ_ASSERT(cx);
1125
0
    object.emplace(cx, &val.toObject());
1126
0
    temp.emplace(cx);
1127
0
  }
1128
0
  if (!isNull) {
1129
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->autoGainControl_id, temp.ptr())) {
1130
0
      return false;
1131
0
    }
1132
0
  }
1133
0
  mAutoGainControl.Uninit();
1134
0
  if (!(!isNull && !temp->isUndefined())) {
1135
0
    if (!mAutoGainControl.RawSetAsConstrainBooleanParameters().Init(cx, JS::NullHandleValue, "Member of BooleanOrConstrainBooleanParameters")) {
1136
0
      return false;
1137
0
    }
1138
0
  } else {
1139
0
    {
1140
0
      bool done = false, failed = false, tryNext;
1141
0
      if (!done) {
1142
0
        done = (failed = !mAutoGainControl.TrySetToConstrainBooleanParameters(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext;
1143
0
      }
1144
0
      if (!done) {
1145
0
        do {
1146
0
          done = (failed = !mAutoGainControl.TrySetToBoolean(cx, temp.ref(), tryNext)) || !tryNext;
1147
0
          break;
1148
0
        } while (false);
1149
0
      }
1150
0
      if (failed) {
1151
0
        return false;
1152
0
      }
1153
0
      if (!done) {
1154
0
        ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "'autoGainControl' member of MediaTrackConstraintSet", "ConstrainBooleanParameters");
1155
0
        return false;
1156
0
      }
1157
0
    }
1158
0
  }
1159
0
  mIsAnyMemberPresent = true;
1160
0
1161
0
  if (!isNull) {
1162
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->browserWindow_id, temp.ptr())) {
1163
0
      return false;
1164
0
    }
1165
0
  }
1166
0
  if (!isNull && !temp->isUndefined()) {
1167
0
    mBrowserWindow.Construct();
1168
0
    if (!ValueToPrimitive<int64_t, eDefault>(cx, temp.ref(), &(mBrowserWindow.Value()))) {
1169
0
      return false;
1170
0
    }
1171
0
    mIsAnyMemberPresent = true;
1172
0
  }
1173
0
1174
0
  if (!isNull) {
1175
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->channelCount_id, temp.ptr())) {
1176
0
      return false;
1177
0
    }
1178
0
  }
1179
0
  mChannelCount.Uninit();
1180
0
  if (!(!isNull && !temp->isUndefined())) {
1181
0
    if (!mChannelCount.RawSetAsConstrainLongRange().Init(cx, JS::NullHandleValue, "Member of LongOrConstrainLongRange")) {
1182
0
      return false;
1183
0
    }
1184
0
  } else {
1185
0
    {
1186
0
      bool done = false, failed = false, tryNext;
1187
0
      if (!done) {
1188
0
        done = (failed = !mChannelCount.TrySetToConstrainLongRange(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext;
1189
0
      }
1190
0
      if (!done) {
1191
0
        do {
1192
0
          done = (failed = !mChannelCount.TrySetToLong(cx, temp.ref(), tryNext)) || !tryNext;
1193
0
          break;
1194
0
        } while (false);
1195
0
      }
1196
0
      if (failed) {
1197
0
        return false;
1198
0
      }
1199
0
      if (!done) {
1200
0
        ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "'channelCount' member of MediaTrackConstraintSet", "ConstrainLongRange");
1201
0
        return false;
1202
0
      }
1203
0
    }
1204
0
  }
1205
0
  mIsAnyMemberPresent = true;
1206
0
1207
0
  if (!isNull) {
1208
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->deviceId_id, temp.ptr())) {
1209
0
      return false;
1210
0
    }
1211
0
  }
1212
0
  mDeviceId.Uninit();
1213
0
  if (!(!isNull && !temp->isUndefined())) {
1214
0
    if (!mDeviceId.RawSetAsConstrainDOMStringParameters().Init(cx, JS::NullHandleValue, "Member of StringOrStringSequenceOrConstrainDOMStringParameters")) {
1215
0
      return false;
1216
0
    }
1217
0
  } else {
1218
0
    {
1219
0
      bool done = false, failed = false, tryNext;
1220
0
      if (temp.ref().isObject()) {
1221
0
        done = (failed = !mDeviceId.TrySetToStringSequence(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext;
1222
0
      }
1223
0
      if (!done) {
1224
0
        done = (failed = !mDeviceId.TrySetToConstrainDOMStringParameters(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext;
1225
0
      }
1226
0
      if (!done) {
1227
0
        do {
1228
0
          done = (failed = !mDeviceId.TrySetToString(cx, temp.ref(), tryNext)) || !tryNext;
1229
0
          break;
1230
0
        } while (false);
1231
0
      }
1232
0
      if (failed) {
1233
0
        return false;
1234
0
      }
1235
0
      if (!done) {
1236
0
        ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "'deviceId' member of MediaTrackConstraintSet", "StringSequence, ConstrainDOMStringParameters");
1237
0
        return false;
1238
0
      }
1239
0
    }
1240
0
  }
1241
0
  mIsAnyMemberPresent = true;
1242
0
1243
0
  if (!isNull) {
1244
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->echoCancellation_id, temp.ptr())) {
1245
0
      return false;
1246
0
    }
1247
0
  }
1248
0
  mEchoCancellation.Uninit();
1249
0
  if (!(!isNull && !temp->isUndefined())) {
1250
0
    if (!mEchoCancellation.RawSetAsConstrainBooleanParameters().Init(cx, JS::NullHandleValue, "Member of BooleanOrConstrainBooleanParameters")) {
1251
0
      return false;
1252
0
    }
1253
0
  } else {
1254
0
    {
1255
0
      bool done = false, failed = false, tryNext;
1256
0
      if (!done) {
1257
0
        done = (failed = !mEchoCancellation.TrySetToConstrainBooleanParameters(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext;
1258
0
      }
1259
0
      if (!done) {
1260
0
        do {
1261
0
          done = (failed = !mEchoCancellation.TrySetToBoolean(cx, temp.ref(), tryNext)) || !tryNext;
1262
0
          break;
1263
0
        } while (false);
1264
0
      }
1265
0
      if (failed) {
1266
0
        return false;
1267
0
      }
1268
0
      if (!done) {
1269
0
        ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "'echoCancellation' member of MediaTrackConstraintSet", "ConstrainBooleanParameters");
1270
0
        return false;
1271
0
      }
1272
0
    }
1273
0
  }
1274
0
  mIsAnyMemberPresent = true;
1275
0
1276
0
  if (!isNull) {
1277
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->facingMode_id, temp.ptr())) {
1278
0
      return false;
1279
0
    }
1280
0
  }
1281
0
  mFacingMode.Uninit();
1282
0
  if (!(!isNull && !temp->isUndefined())) {
1283
0
    if (!mFacingMode.RawSetAsConstrainDOMStringParameters().Init(cx, JS::NullHandleValue, "Member of StringOrStringSequenceOrConstrainDOMStringParameters")) {
1284
0
      return false;
1285
0
    }
1286
0
  } else {
1287
0
    {
1288
0
      bool done = false, failed = false, tryNext;
1289
0
      if (temp.ref().isObject()) {
1290
0
        done = (failed = !mFacingMode.TrySetToStringSequence(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext;
1291
0
      }
1292
0
      if (!done) {
1293
0
        done = (failed = !mFacingMode.TrySetToConstrainDOMStringParameters(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext;
1294
0
      }
1295
0
      if (!done) {
1296
0
        do {
1297
0
          done = (failed = !mFacingMode.TrySetToString(cx, temp.ref(), tryNext)) || !tryNext;
1298
0
          break;
1299
0
        } while (false);
1300
0
      }
1301
0
      if (failed) {
1302
0
        return false;
1303
0
      }
1304
0
      if (!done) {
1305
0
        ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "'facingMode' member of MediaTrackConstraintSet", "StringSequence, ConstrainDOMStringParameters");
1306
0
        return false;
1307
0
      }
1308
0
    }
1309
0
  }
1310
0
  mIsAnyMemberPresent = true;
1311
0
1312
0
  if (!isNull) {
1313
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->frameRate_id, temp.ptr())) {
1314
0
      return false;
1315
0
    }
1316
0
  }
1317
0
  mFrameRate.Uninit();
1318
0
  if (!(!isNull && !temp->isUndefined())) {
1319
0
    if (!mFrameRate.RawSetAsConstrainDoubleRange().Init(cx, JS::NullHandleValue, "Member of DoubleOrConstrainDoubleRange")) {
1320
0
      return false;
1321
0
    }
1322
0
  } else {
1323
0
    {
1324
0
      bool done = false, failed = false, tryNext;
1325
0
      if (!done) {
1326
0
        done = (failed = !mFrameRate.TrySetToConstrainDoubleRange(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext;
1327
0
      }
1328
0
      if (!done) {
1329
0
        do {
1330
0
          done = (failed = !mFrameRate.TrySetToDouble(cx, temp.ref(), tryNext)) || !tryNext;
1331
0
          break;
1332
0
        } while (false);
1333
0
      }
1334
0
      if (failed) {
1335
0
        return false;
1336
0
      }
1337
0
      if (!done) {
1338
0
        ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "'frameRate' member of MediaTrackConstraintSet", "ConstrainDoubleRange");
1339
0
        return false;
1340
0
      }
1341
0
    }
1342
0
  }
1343
0
  mIsAnyMemberPresent = true;
1344
0
1345
0
  if (!isNull) {
1346
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->height_id, temp.ptr())) {
1347
0
      return false;
1348
0
    }
1349
0
  }
1350
0
  mHeight.Uninit();
1351
0
  if (!(!isNull && !temp->isUndefined())) {
1352
0
    if (!mHeight.RawSetAsConstrainLongRange().Init(cx, JS::NullHandleValue, "Member of LongOrConstrainLongRange")) {
1353
0
      return false;
1354
0
    }
1355
0
  } else {
1356
0
    {
1357
0
      bool done = false, failed = false, tryNext;
1358
0
      if (!done) {
1359
0
        done = (failed = !mHeight.TrySetToConstrainLongRange(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext;
1360
0
      }
1361
0
      if (!done) {
1362
0
        do {
1363
0
          done = (failed = !mHeight.TrySetToLong(cx, temp.ref(), tryNext)) || !tryNext;
1364
0
          break;
1365
0
        } while (false);
1366
0
      }
1367
0
      if (failed) {
1368
0
        return false;
1369
0
      }
1370
0
      if (!done) {
1371
0
        ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "'height' member of MediaTrackConstraintSet", "ConstrainLongRange");
1372
0
        return false;
1373
0
      }
1374
0
    }
1375
0
  }
1376
0
  mIsAnyMemberPresent = true;
1377
0
1378
0
  if (!isNull) {
1379
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->mediaSource_id, temp.ptr())) {
1380
0
      return false;
1381
0
    }
1382
0
  }
1383
0
  if (!isNull && !temp->isUndefined()) {
1384
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mMediaSource)) {
1385
0
      return false;
1386
0
    }
1387
0
  } else {
1388
0
    static const char16_t data[] = { 'c', 'a', 'm', 'e', 'r', 'a', 0 };
1389
0
    mMediaSource.Rebind(data, ArrayLength(data) - 1);
1390
0
  }
1391
0
  mIsAnyMemberPresent = true;
1392
0
1393
0
  if (!isNull) {
1394
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->mozAutoGainControl_id, temp.ptr())) {
1395
0
      return false;
1396
0
    }
1397
0
  }
1398
0
  mMozAutoGainControl.Uninit();
1399
0
  if (!(!isNull && !temp->isUndefined())) {
1400
0
    if (!mMozAutoGainControl.RawSetAsConstrainBooleanParameters().Init(cx, JS::NullHandleValue, "Member of BooleanOrConstrainBooleanParameters")) {
1401
0
      return false;
1402
0
    }
1403
0
  } else {
1404
0
    {
1405
0
      bool done = false, failed = false, tryNext;
1406
0
      if (!done) {
1407
0
        done = (failed = !mMozAutoGainControl.TrySetToConstrainBooleanParameters(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext;
1408
0
      }
1409
0
      if (!done) {
1410
0
        do {
1411
0
          done = (failed = !mMozAutoGainControl.TrySetToBoolean(cx, temp.ref(), tryNext)) || !tryNext;
1412
0
          break;
1413
0
        } while (false);
1414
0
      }
1415
0
      if (failed) {
1416
0
        return false;
1417
0
      }
1418
0
      if (!done) {
1419
0
        ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "'mozAutoGainControl' member of MediaTrackConstraintSet", "ConstrainBooleanParameters");
1420
0
        return false;
1421
0
      }
1422
0
    }
1423
0
  }
1424
0
  mIsAnyMemberPresent = true;
1425
0
1426
0
  if (!isNull) {
1427
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->mozNoiseSuppression_id, temp.ptr())) {
1428
0
      return false;
1429
0
    }
1430
0
  }
1431
0
  mMozNoiseSuppression.Uninit();
1432
0
  if (!(!isNull && !temp->isUndefined())) {
1433
0
    if (!mMozNoiseSuppression.RawSetAsConstrainBooleanParameters().Init(cx, JS::NullHandleValue, "Member of BooleanOrConstrainBooleanParameters")) {
1434
0
      return false;
1435
0
    }
1436
0
  } else {
1437
0
    {
1438
0
      bool done = false, failed = false, tryNext;
1439
0
      if (!done) {
1440
0
        done = (failed = !mMozNoiseSuppression.TrySetToConstrainBooleanParameters(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext;
1441
0
      }
1442
0
      if (!done) {
1443
0
        do {
1444
0
          done = (failed = !mMozNoiseSuppression.TrySetToBoolean(cx, temp.ref(), tryNext)) || !tryNext;
1445
0
          break;
1446
0
        } while (false);
1447
0
      }
1448
0
      if (failed) {
1449
0
        return false;
1450
0
      }
1451
0
      if (!done) {
1452
0
        ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "'mozNoiseSuppression' member of MediaTrackConstraintSet", "ConstrainBooleanParameters");
1453
0
        return false;
1454
0
      }
1455
0
    }
1456
0
  }
1457
0
  mIsAnyMemberPresent = true;
1458
0
1459
0
  if (!isNull) {
1460
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->noiseSuppression_id, temp.ptr())) {
1461
0
      return false;
1462
0
    }
1463
0
  }
1464
0
  mNoiseSuppression.Uninit();
1465
0
  if (!(!isNull && !temp->isUndefined())) {
1466
0
    if (!mNoiseSuppression.RawSetAsConstrainBooleanParameters().Init(cx, JS::NullHandleValue, "Member of BooleanOrConstrainBooleanParameters")) {
1467
0
      return false;
1468
0
    }
1469
0
  } else {
1470
0
    {
1471
0
      bool done = false, failed = false, tryNext;
1472
0
      if (!done) {
1473
0
        done = (failed = !mNoiseSuppression.TrySetToConstrainBooleanParameters(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext;
1474
0
      }
1475
0
      if (!done) {
1476
0
        do {
1477
0
          done = (failed = !mNoiseSuppression.TrySetToBoolean(cx, temp.ref(), tryNext)) || !tryNext;
1478
0
          break;
1479
0
        } while (false);
1480
0
      }
1481
0
      if (failed) {
1482
0
        return false;
1483
0
      }
1484
0
      if (!done) {
1485
0
        ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "'noiseSuppression' member of MediaTrackConstraintSet", "ConstrainBooleanParameters");
1486
0
        return false;
1487
0
      }
1488
0
    }
1489
0
  }
1490
0
  mIsAnyMemberPresent = true;
1491
0
1492
0
  if (!isNull) {
1493
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->scrollWithPage_id, temp.ptr())) {
1494
0
      return false;
1495
0
    }
1496
0
  }
1497
0
  if (!isNull && !temp->isUndefined()) {
1498
0
    mScrollWithPage.Construct();
1499
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &(mScrollWithPage.Value()))) {
1500
0
      return false;
1501
0
    }
1502
0
    mIsAnyMemberPresent = true;
1503
0
  }
1504
0
1505
0
  if (!isNull) {
1506
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->viewportHeight_id, temp.ptr())) {
1507
0
      return false;
1508
0
    }
1509
0
  }
1510
0
  mViewportHeight.Uninit();
1511
0
  if (!(!isNull && !temp->isUndefined())) {
1512
0
    if (!mViewportHeight.RawSetAsConstrainLongRange().Init(cx, JS::NullHandleValue, "Member of LongOrConstrainLongRange")) {
1513
0
      return false;
1514
0
    }
1515
0
  } else {
1516
0
    {
1517
0
      bool done = false, failed = false, tryNext;
1518
0
      if (!done) {
1519
0
        done = (failed = !mViewportHeight.TrySetToConstrainLongRange(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext;
1520
0
      }
1521
0
      if (!done) {
1522
0
        do {
1523
0
          done = (failed = !mViewportHeight.TrySetToLong(cx, temp.ref(), tryNext)) || !tryNext;
1524
0
          break;
1525
0
        } while (false);
1526
0
      }
1527
0
      if (failed) {
1528
0
        return false;
1529
0
      }
1530
0
      if (!done) {
1531
0
        ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "'viewportHeight' member of MediaTrackConstraintSet", "ConstrainLongRange");
1532
0
        return false;
1533
0
      }
1534
0
    }
1535
0
  }
1536
0
  mIsAnyMemberPresent = true;
1537
0
1538
0
  if (!isNull) {
1539
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->viewportOffsetX_id, temp.ptr())) {
1540
0
      return false;
1541
0
    }
1542
0
  }
1543
0
  mViewportOffsetX.Uninit();
1544
0
  if (!(!isNull && !temp->isUndefined())) {
1545
0
    if (!mViewportOffsetX.RawSetAsConstrainLongRange().Init(cx, JS::NullHandleValue, "Member of LongOrConstrainLongRange")) {
1546
0
      return false;
1547
0
    }
1548
0
  } else {
1549
0
    {
1550
0
      bool done = false, failed = false, tryNext;
1551
0
      if (!done) {
1552
0
        done = (failed = !mViewportOffsetX.TrySetToConstrainLongRange(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext;
1553
0
      }
1554
0
      if (!done) {
1555
0
        do {
1556
0
          done = (failed = !mViewportOffsetX.TrySetToLong(cx, temp.ref(), tryNext)) || !tryNext;
1557
0
          break;
1558
0
        } while (false);
1559
0
      }
1560
0
      if (failed) {
1561
0
        return false;
1562
0
      }
1563
0
      if (!done) {
1564
0
        ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "'viewportOffsetX' member of MediaTrackConstraintSet", "ConstrainLongRange");
1565
0
        return false;
1566
0
      }
1567
0
    }
1568
0
  }
1569
0
  mIsAnyMemberPresent = true;
1570
0
1571
0
  if (!isNull) {
1572
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->viewportOffsetY_id, temp.ptr())) {
1573
0
      return false;
1574
0
    }
1575
0
  }
1576
0
  mViewportOffsetY.Uninit();
1577
0
  if (!(!isNull && !temp->isUndefined())) {
1578
0
    if (!mViewportOffsetY.RawSetAsConstrainLongRange().Init(cx, JS::NullHandleValue, "Member of LongOrConstrainLongRange")) {
1579
0
      return false;
1580
0
    }
1581
0
  } else {
1582
0
    {
1583
0
      bool done = false, failed = false, tryNext;
1584
0
      if (!done) {
1585
0
        done = (failed = !mViewportOffsetY.TrySetToConstrainLongRange(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext;
1586
0
      }
1587
0
      if (!done) {
1588
0
        do {
1589
0
          done = (failed = !mViewportOffsetY.TrySetToLong(cx, temp.ref(), tryNext)) || !tryNext;
1590
0
          break;
1591
0
        } while (false);
1592
0
      }
1593
0
      if (failed) {
1594
0
        return false;
1595
0
      }
1596
0
      if (!done) {
1597
0
        ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "'viewportOffsetY' member of MediaTrackConstraintSet", "ConstrainLongRange");
1598
0
        return false;
1599
0
      }
1600
0
    }
1601
0
  }
1602
0
  mIsAnyMemberPresent = true;
1603
0
1604
0
  if (!isNull) {
1605
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->viewportWidth_id, temp.ptr())) {
1606
0
      return false;
1607
0
    }
1608
0
  }
1609
0
  mViewportWidth.Uninit();
1610
0
  if (!(!isNull && !temp->isUndefined())) {
1611
0
    if (!mViewportWidth.RawSetAsConstrainLongRange().Init(cx, JS::NullHandleValue, "Member of LongOrConstrainLongRange")) {
1612
0
      return false;
1613
0
    }
1614
0
  } else {
1615
0
    {
1616
0
      bool done = false, failed = false, tryNext;
1617
0
      if (!done) {
1618
0
        done = (failed = !mViewportWidth.TrySetToConstrainLongRange(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext;
1619
0
      }
1620
0
      if (!done) {
1621
0
        do {
1622
0
          done = (failed = !mViewportWidth.TrySetToLong(cx, temp.ref(), tryNext)) || !tryNext;
1623
0
          break;
1624
0
        } while (false);
1625
0
      }
1626
0
      if (failed) {
1627
0
        return false;
1628
0
      }
1629
0
      if (!done) {
1630
0
        ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "'viewportWidth' member of MediaTrackConstraintSet", "ConstrainLongRange");
1631
0
        return false;
1632
0
      }
1633
0
    }
1634
0
  }
1635
0
  mIsAnyMemberPresent = true;
1636
0
1637
0
  if (!isNull) {
1638
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->width_id, temp.ptr())) {
1639
0
      return false;
1640
0
    }
1641
0
  }
1642
0
  mWidth.Uninit();
1643
0
  if (!(!isNull && !temp->isUndefined())) {
1644
0
    if (!mWidth.RawSetAsConstrainLongRange().Init(cx, JS::NullHandleValue, "Member of LongOrConstrainLongRange")) {
1645
0
      return false;
1646
0
    }
1647
0
  } else {
1648
0
    {
1649
0
      bool done = false, failed = false, tryNext;
1650
0
      if (!done) {
1651
0
        done = (failed = !mWidth.TrySetToConstrainLongRange(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext;
1652
0
      }
1653
0
      if (!done) {
1654
0
        do {
1655
0
          done = (failed = !mWidth.TrySetToLong(cx, temp.ref(), tryNext)) || !tryNext;
1656
0
          break;
1657
0
        } while (false);
1658
0
      }
1659
0
      if (failed) {
1660
0
        return false;
1661
0
      }
1662
0
      if (!done) {
1663
0
        ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "'width' member of MediaTrackConstraintSet", "ConstrainLongRange");
1664
0
        return false;
1665
0
      }
1666
0
    }
1667
0
  }
1668
0
  mIsAnyMemberPresent = true;
1669
0
  return true;
1670
0
}
1671
1672
bool
1673
MediaTrackConstraintSet::Init(const nsAString& aJSON)
1674
0
{
1675
0
  AutoJSAPI jsapi;
1676
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
1677
0
  if (!cleanGlobal) {
1678
0
    return false;
1679
0
  }
1680
0
  if (!jsapi.Init(cleanGlobal)) {
1681
0
    return false;
1682
0
  }
1683
0
  JSContext* cx = jsapi.cx();
1684
0
  JS::Rooted<JS::Value> json(cx);
1685
0
  bool ok = ParseJSON(cx, aJSON, &json);
1686
0
  NS_ENSURE_TRUE(ok, false);
1687
0
  return Init(cx, json);
1688
0
}
1689
1690
bool
1691
MediaTrackConstraintSet::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
1692
0
{
1693
0
  MediaTrackConstraintSetAtoms* atomsCache = GetAtomCache<MediaTrackConstraintSetAtoms>(cx);
1694
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
1695
0
    return false;
1696
0
  }
1697
0
1698
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
1699
0
  if (!obj) {
1700
0
    return false;
1701
0
  }
1702
0
  rval.set(JS::ObjectValue(*obj));
1703
0
1704
0
  do {
1705
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1706
0
    JS::Rooted<JS::Value> temp(cx);
1707
0
    OwningBooleanOrConstrainBooleanParameters const & currentValue = mAutoGainControl;
1708
0
    if (!currentValue.ToJSVal(cx, obj, &temp)) {
1709
0
      return false;
1710
0
    }
1711
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->autoGainControl_id, temp, JSPROP_ENUMERATE)) {
1712
0
      return false;
1713
0
    }
1714
0
    break;
1715
0
  } while(false);
1716
0
1717
0
  if (mBrowserWindow.WasPassed()) {
1718
0
    do {
1719
0
      // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1720
0
      JS::Rooted<JS::Value> temp(cx);
1721
0
      int64_t const & currentValue = mBrowserWindow.InternalValue();
1722
0
      temp.set(JS_NumberValue(double(currentValue)));
1723
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->browserWindow_id, temp, JSPROP_ENUMERATE)) {
1724
0
        return false;
1725
0
      }
1726
0
      break;
1727
0
    } while(false);
1728
0
  }
1729
0
1730
0
  do {
1731
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1732
0
    JS::Rooted<JS::Value> temp(cx);
1733
0
    OwningLongOrConstrainLongRange const & currentValue = mChannelCount;
1734
0
    if (!currentValue.ToJSVal(cx, obj, &temp)) {
1735
0
      return false;
1736
0
    }
1737
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->channelCount_id, temp, JSPROP_ENUMERATE)) {
1738
0
      return false;
1739
0
    }
1740
0
    break;
1741
0
  } while(false);
1742
0
1743
0
  do {
1744
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1745
0
    JS::Rooted<JS::Value> temp(cx);
1746
0
    OwningStringOrStringSequenceOrConstrainDOMStringParameters const & currentValue = mDeviceId;
1747
0
    if (!currentValue.ToJSVal(cx, obj, &temp)) {
1748
0
      return false;
1749
0
    }
1750
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->deviceId_id, temp, JSPROP_ENUMERATE)) {
1751
0
      return false;
1752
0
    }
1753
0
    break;
1754
0
  } while(false);
1755
0
1756
0
  do {
1757
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1758
0
    JS::Rooted<JS::Value> temp(cx);
1759
0
    OwningBooleanOrConstrainBooleanParameters const & currentValue = mEchoCancellation;
1760
0
    if (!currentValue.ToJSVal(cx, obj, &temp)) {
1761
0
      return false;
1762
0
    }
1763
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->echoCancellation_id, temp, JSPROP_ENUMERATE)) {
1764
0
      return false;
1765
0
    }
1766
0
    break;
1767
0
  } while(false);
1768
0
1769
0
  do {
1770
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1771
0
    JS::Rooted<JS::Value> temp(cx);
1772
0
    OwningStringOrStringSequenceOrConstrainDOMStringParameters const & currentValue = mFacingMode;
1773
0
    if (!currentValue.ToJSVal(cx, obj, &temp)) {
1774
0
      return false;
1775
0
    }
1776
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->facingMode_id, temp, JSPROP_ENUMERATE)) {
1777
0
      return false;
1778
0
    }
1779
0
    break;
1780
0
  } while(false);
1781
0
1782
0
  do {
1783
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1784
0
    JS::Rooted<JS::Value> temp(cx);
1785
0
    OwningDoubleOrConstrainDoubleRange const & currentValue = mFrameRate;
1786
0
    if (!currentValue.ToJSVal(cx, obj, &temp)) {
1787
0
      return false;
1788
0
    }
1789
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->frameRate_id, temp, JSPROP_ENUMERATE)) {
1790
0
      return false;
1791
0
    }
1792
0
    break;
1793
0
  } while(false);
1794
0
1795
0
  do {
1796
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1797
0
    JS::Rooted<JS::Value> temp(cx);
1798
0
    OwningLongOrConstrainLongRange const & currentValue = mHeight;
1799
0
    if (!currentValue.ToJSVal(cx, obj, &temp)) {
1800
0
      return false;
1801
0
    }
1802
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->height_id, temp, JSPROP_ENUMERATE)) {
1803
0
      return false;
1804
0
    }
1805
0
    break;
1806
0
  } while(false);
1807
0
1808
0
  do {
1809
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1810
0
    JS::Rooted<JS::Value> temp(cx);
1811
0
    nsString const & currentValue = mMediaSource;
1812
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
1813
0
      return false;
1814
0
    }
1815
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->mediaSource_id, temp, JSPROP_ENUMERATE)) {
1816
0
      return false;
1817
0
    }
1818
0
    break;
1819
0
  } while(false);
1820
0
1821
0
  do {
1822
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1823
0
    JS::Rooted<JS::Value> temp(cx);
1824
0
    OwningBooleanOrConstrainBooleanParameters const & currentValue = mMozAutoGainControl;
1825
0
    if (!currentValue.ToJSVal(cx, obj, &temp)) {
1826
0
      return false;
1827
0
    }
1828
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->mozAutoGainControl_id, temp, JSPROP_ENUMERATE)) {
1829
0
      return false;
1830
0
    }
1831
0
    break;
1832
0
  } while(false);
1833
0
1834
0
  do {
1835
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1836
0
    JS::Rooted<JS::Value> temp(cx);
1837
0
    OwningBooleanOrConstrainBooleanParameters const & currentValue = mMozNoiseSuppression;
1838
0
    if (!currentValue.ToJSVal(cx, obj, &temp)) {
1839
0
      return false;
1840
0
    }
1841
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->mozNoiseSuppression_id, temp, JSPROP_ENUMERATE)) {
1842
0
      return false;
1843
0
    }
1844
0
    break;
1845
0
  } while(false);
1846
0
1847
0
  do {
1848
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1849
0
    JS::Rooted<JS::Value> temp(cx);
1850
0
    OwningBooleanOrConstrainBooleanParameters const & currentValue = mNoiseSuppression;
1851
0
    if (!currentValue.ToJSVal(cx, obj, &temp)) {
1852
0
      return false;
1853
0
    }
1854
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->noiseSuppression_id, temp, JSPROP_ENUMERATE)) {
1855
0
      return false;
1856
0
    }
1857
0
    break;
1858
0
  } while(false);
1859
0
1860
0
  if (mScrollWithPage.WasPassed()) {
1861
0
    do {
1862
0
      // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1863
0
      JS::Rooted<JS::Value> temp(cx);
1864
0
      bool const & currentValue = mScrollWithPage.InternalValue();
1865
0
      temp.setBoolean(currentValue);
1866
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->scrollWithPage_id, temp, JSPROP_ENUMERATE)) {
1867
0
        return false;
1868
0
      }
1869
0
      break;
1870
0
    } while(false);
1871
0
  }
1872
0
1873
0
  do {
1874
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1875
0
    JS::Rooted<JS::Value> temp(cx);
1876
0
    OwningLongOrConstrainLongRange const & currentValue = mViewportHeight;
1877
0
    if (!currentValue.ToJSVal(cx, obj, &temp)) {
1878
0
      return false;
1879
0
    }
1880
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->viewportHeight_id, temp, JSPROP_ENUMERATE)) {
1881
0
      return false;
1882
0
    }
1883
0
    break;
1884
0
  } while(false);
1885
0
1886
0
  do {
1887
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1888
0
    JS::Rooted<JS::Value> temp(cx);
1889
0
    OwningLongOrConstrainLongRange const & currentValue = mViewportOffsetX;
1890
0
    if (!currentValue.ToJSVal(cx, obj, &temp)) {
1891
0
      return false;
1892
0
    }
1893
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->viewportOffsetX_id, temp, JSPROP_ENUMERATE)) {
1894
0
      return false;
1895
0
    }
1896
0
    break;
1897
0
  } while(false);
1898
0
1899
0
  do {
1900
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1901
0
    JS::Rooted<JS::Value> temp(cx);
1902
0
    OwningLongOrConstrainLongRange const & currentValue = mViewportOffsetY;
1903
0
    if (!currentValue.ToJSVal(cx, obj, &temp)) {
1904
0
      return false;
1905
0
    }
1906
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->viewportOffsetY_id, temp, JSPROP_ENUMERATE)) {
1907
0
      return false;
1908
0
    }
1909
0
    break;
1910
0
  } while(false);
1911
0
1912
0
  do {
1913
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1914
0
    JS::Rooted<JS::Value> temp(cx);
1915
0
    OwningLongOrConstrainLongRange const & currentValue = mViewportWidth;
1916
0
    if (!currentValue.ToJSVal(cx, obj, &temp)) {
1917
0
      return false;
1918
0
    }
1919
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->viewportWidth_id, temp, JSPROP_ENUMERATE)) {
1920
0
      return false;
1921
0
    }
1922
0
    break;
1923
0
  } while(false);
1924
0
1925
0
  do {
1926
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1927
0
    JS::Rooted<JS::Value> temp(cx);
1928
0
    OwningLongOrConstrainLongRange const & currentValue = mWidth;
1929
0
    if (!currentValue.ToJSVal(cx, obj, &temp)) {
1930
0
      return false;
1931
0
    }
1932
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->width_id, temp, JSPROP_ENUMERATE)) {
1933
0
      return false;
1934
0
    }
1935
0
    break;
1936
0
  } while(false);
1937
0
1938
0
  return true;
1939
0
}
1940
1941
bool
1942
MediaTrackConstraintSet::ToJSON(nsAString& aJSON) const
1943
0
{
1944
0
  AutoJSAPI jsapi;
1945
0
  jsapi.Init();
1946
0
  JSContext *cx = jsapi.cx();
1947
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
1948
0
  // because we'll only be creating objects, in ways that have no
1949
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
1950
0
  // which likewise guarantees no side-effects for the sorts of
1951
0
  // things we will pass it.
1952
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
1953
0
  JS::Rooted<JS::Value> val(cx);
1954
0
  if (!ToObjectInternal(cx, &val)) {
1955
0
    return false;
1956
0
  }
1957
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
1958
0
  return StringifyToJSON(cx, obj, aJSON);
1959
0
}
1960
1961
void
1962
MediaTrackConstraintSet::TraceDictionary(JSTracer* trc)
1963
0
{
1964
0
}
1965
1966
MediaTrackConstraintSet&
1967
MediaTrackConstraintSet::operator=(const MediaTrackConstraintSet& aOther)
1968
0
{
1969
0
  DictionaryBase::operator=(aOther);
1970
0
  mAutoGainControl = aOther.mAutoGainControl;
1971
0
  mBrowserWindow.Reset();
1972
0
  if (aOther.mBrowserWindow.WasPassed()) {
1973
0
    mBrowserWindow.Construct(aOther.mBrowserWindow.Value());
1974
0
  }
1975
0
  mChannelCount = aOther.mChannelCount;
1976
0
  mDeviceId = aOther.mDeviceId;
1977
0
  mEchoCancellation = aOther.mEchoCancellation;
1978
0
  mFacingMode = aOther.mFacingMode;
1979
0
  mFrameRate = aOther.mFrameRate;
1980
0
  mHeight = aOther.mHeight;
1981
0
  mMediaSource = aOther.mMediaSource;
1982
0
  mMozAutoGainControl = aOther.mMozAutoGainControl;
1983
0
  mMozNoiseSuppression = aOther.mMozNoiseSuppression;
1984
0
  mNoiseSuppression = aOther.mNoiseSuppression;
1985
0
  mScrollWithPage.Reset();
1986
0
  if (aOther.mScrollWithPage.WasPassed()) {
1987
0
    mScrollWithPage.Construct(aOther.mScrollWithPage.Value());
1988
0
  }
1989
0
  mViewportHeight = aOther.mViewportHeight;
1990
0
  mViewportOffsetX = aOther.mViewportOffsetX;
1991
0
  mViewportOffsetY = aOther.mViewportOffsetY;
1992
0
  mViewportWidth = aOther.mViewportWidth;
1993
0
  mWidth = aOther.mWidth;
1994
0
  return *this;
1995
0
}
1996
1997
namespace binding_detail {
1998
} // namespace binding_detail
1999
2000
2001
2002
MediaTrackConstraints::MediaTrackConstraints()
2003
  : MediaTrackConstraintSet(FastDictionaryInitializer())
2004
0
{
2005
0
  // Safe to pass a null context if we pass a null value
2006
0
  Init(nullptr, JS::NullHandleValue);
2007
0
}
2008
2009
2010
2011
bool
2012
MediaTrackConstraints::InitIds(JSContext* cx, MediaTrackConstraintsAtoms* atomsCache)
2013
0
{
2014
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
2015
0
2016
0
  // Initialize these in reverse order so that any failure leaves the first one
2017
0
  // uninitialized.
2018
0
  if (!atomsCache->advanced_id.init(cx, "advanced")) {
2019
0
    return false;
2020
0
  }
2021
0
  return true;
2022
0
}
2023
2024
bool
2025
MediaTrackConstraints::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
2026
0
{
2027
0
  // Passing a null JSContext is OK only if we're initing from null,
2028
0
  // Since in that case we will not have to do any property gets
2029
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
2030
0
  // checkers by static analysis tools
2031
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
2032
0
  MediaTrackConstraintsAtoms* atomsCache = nullptr;
2033
0
  if (cx) {
2034
0
    atomsCache = GetAtomCache<MediaTrackConstraintsAtoms>(cx);
2035
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
2036
0
      return false;
2037
0
    }
2038
0
  }
2039
0
2040
0
  // Per spec, we init the parent's members first
2041
0
  if (!MediaTrackConstraintSet::Init(cx, val)) {
2042
0
    return false;
2043
0
  }
2044
0
2045
0
  bool isNull = val.isNullOrUndefined();
2046
0
  // We only need these if !isNull, in which case we have |cx|.
2047
0
  Maybe<JS::Rooted<JSObject *> > object;
2048
0
  Maybe<JS::Rooted<JS::Value> > temp;
2049
0
  if (!isNull) {
2050
0
    MOZ_ASSERT(cx);
2051
0
    object.emplace(cx, &val.toObject());
2052
0
    temp.emplace(cx);
2053
0
  }
2054
0
  if (!isNull) {
2055
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->advanced_id, temp.ptr())) {
2056
0
      return false;
2057
0
    }
2058
0
  }
2059
0
  if (!isNull && !temp->isUndefined()) {
2060
0
    mAdvanced.Construct();
2061
0
    if (temp.ref().isObject()) {
2062
0
      JS::ForOfIterator iter(cx);
2063
0
      if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
2064
0
        return false;
2065
0
      }
2066
0
      if (!iter.valueIsIterable()) {
2067
0
        ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'advanced' member of MediaTrackConstraints");
2068
0
        return false;
2069
0
      }
2070
0
      Sequence<MediaTrackConstraintSet> &arr = (mAdvanced.Value());
2071
0
      JS::Rooted<JS::Value> temp(cx);
2072
0
      while (true) {
2073
0
        bool done;
2074
0
        if (!iter.next(&temp, &done)) {
2075
0
          return false;
2076
0
        }
2077
0
        if (done) {
2078
0
          break;
2079
0
        }
2080
0
        MediaTrackConstraintSet* slotPtr = arr.AppendElement(mozilla::fallible);
2081
0
        if (!slotPtr) {
2082
0
          JS_ReportOutOfMemory(cx);
2083
0
          return false;
2084
0
        }
2085
0
        MediaTrackConstraintSet& slot = *slotPtr;
2086
0
        if (!slot.Init(cx, temp,  "Element of 'advanced' member of MediaTrackConstraints", passedToJSImpl)) {
2087
0
          return false;
2088
0
        }
2089
0
      }
2090
0
    } else {
2091
0
      ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'advanced' member of MediaTrackConstraints");
2092
0
      return false;
2093
0
    }
2094
0
    mIsAnyMemberPresent = true;
2095
0
  }
2096
0
  return true;
2097
0
}
2098
2099
bool
2100
MediaTrackConstraints::Init(const nsAString& aJSON)
2101
0
{
2102
0
  AutoJSAPI jsapi;
2103
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
2104
0
  if (!cleanGlobal) {
2105
0
    return false;
2106
0
  }
2107
0
  if (!jsapi.Init(cleanGlobal)) {
2108
0
    return false;
2109
0
  }
2110
0
  JSContext* cx = jsapi.cx();
2111
0
  JS::Rooted<JS::Value> json(cx);
2112
0
  bool ok = ParseJSON(cx, aJSON, &json);
2113
0
  NS_ENSURE_TRUE(ok, false);
2114
0
  return Init(cx, json);
2115
0
}
2116
2117
bool
2118
MediaTrackConstraints::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
2119
0
{
2120
0
  MediaTrackConstraintsAtoms* atomsCache = GetAtomCache<MediaTrackConstraintsAtoms>(cx);
2121
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
2122
0
    return false;
2123
0
  }
2124
0
2125
0
  // Per spec, we define the parent's members first
2126
0
  if (!MediaTrackConstraintSet::ToObjectInternal(cx, rval)) {
2127
0
    return false;
2128
0
  }
2129
0
  JS::Rooted<JSObject*> obj(cx, &rval.toObject());
2130
0
2131
0
  if (mAdvanced.WasPassed()) {
2132
0
    do {
2133
0
      // block for our 'break' successCode and scope for 'temp' and 'currentValue'
2134
0
      JS::Rooted<JS::Value> temp(cx);
2135
0
      Sequence<MediaTrackConstraintSet> const & currentValue = mAdvanced.InternalValue();
2136
0
2137
0
      uint32_t length = currentValue.Length();
2138
0
      JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
2139
0
      if (!returnArray) {
2140
0
        return false;
2141
0
      }
2142
0
      // Scope for 'tmp'
2143
0
      {
2144
0
        JS::Rooted<JS::Value> tmp(cx);
2145
0
        for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
2146
0
          // Control block to let us common up the JS_DefineElement calls when there
2147
0
          // are different ways to succeed at wrapping the object.
2148
0
          do {
2149
0
            if (!currentValue[sequenceIdx0].ToObjectInternal(cx, &tmp)) {
2150
0
              return false;
2151
0
            }
2152
0
            break;
2153
0
          } while (false);
2154
0
          if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
2155
0
                                JSPROP_ENUMERATE)) {
2156
0
            return false;
2157
0
          }
2158
0
        }
2159
0
      }
2160
0
      temp.setObject(*returnArray);
2161
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->advanced_id, temp, JSPROP_ENUMERATE)) {
2162
0
        return false;
2163
0
      }
2164
0
      break;
2165
0
    } while(false);
2166
0
  }
2167
0
2168
0
  return true;
2169
0
}
2170
2171
bool
2172
MediaTrackConstraints::ToJSON(nsAString& aJSON) const
2173
0
{
2174
0
  AutoJSAPI jsapi;
2175
0
  jsapi.Init();
2176
0
  JSContext *cx = jsapi.cx();
2177
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
2178
0
  // because we'll only be creating objects, in ways that have no
2179
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
2180
0
  // which likewise guarantees no side-effects for the sorts of
2181
0
  // things we will pass it.
2182
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
2183
0
  JS::Rooted<JS::Value> val(cx);
2184
0
  if (!ToObjectInternal(cx, &val)) {
2185
0
    return false;
2186
0
  }
2187
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
2188
0
  return StringifyToJSON(cx, obj, aJSON);
2189
0
}
2190
2191
void
2192
MediaTrackConstraints::TraceDictionary(JSTracer* trc)
2193
0
{
2194
0
  MediaTrackConstraintSet::TraceDictionary(trc);
2195
0
}
2196
2197
MediaTrackConstraints&
2198
MediaTrackConstraints::operator=(const MediaTrackConstraints& aOther)
2199
0
{
2200
0
  MediaTrackConstraintSet::operator=(aOther);
2201
0
  mAdvanced.Reset();
2202
0
  if (aOther.mAdvanced.WasPassed()) {
2203
0
    mAdvanced.Construct(aOther.mAdvanced.Value());
2204
0
  }
2205
0
  return *this;
2206
0
}
2207
2208
namespace binding_detail {
2209
} // namespace binding_detail
2210
2211
2212
namespace MediaStreamTrack_Binding {
2213
2214
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTarget_Binding::NativeType>::value,
2215
              "Can't inherit from an interface with a different ownership model.");
2216
2217
MOZ_CAN_RUN_SCRIPT static bool
2218
get_kind(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaStreamTrack* self, JSJitGetterCallArgs args)
2219
0
{
2220
0
  AUTO_PROFILER_LABEL_FAST("get MediaStreamTrack.kind", DOM, cx);
2221
0
2222
0
  DOMString result;
2223
0
  self->GetKind(result);
2224
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2225
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
2226
0
    return false;
2227
0
  }
2228
0
  return true;
2229
0
}
2230
2231
static const JSJitInfo kind_getterinfo = {
2232
  { (JSJitGetterOp)get_kind },
2233
  { prototypes::id::MediaStreamTrack },
2234
  { PrototypeTraits<prototypes::id::MediaStreamTrack>::Depth },
2235
  JSJitInfo::Getter,
2236
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2237
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
2238
  false,  /* isInfallible. False in setters. */
2239
  false,  /* isMovable.  Not relevant for setters. */
2240
  false, /* isEliminatable.  Not relevant for setters. */
2241
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2242
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2243
  false,  /* isTypedMethod.  Only relevant for methods. */
2244
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2245
};
2246
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2247
static_assert(0 < 1, "There is no slot for us");
2248
2249
MOZ_CAN_RUN_SCRIPT static bool
2250
get_id(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaStreamTrack* self, JSJitGetterCallArgs args)
2251
0
{
2252
0
  AUTO_PROFILER_LABEL_FAST("get MediaStreamTrack.id", DOM, cx);
2253
0
2254
0
  DOMString result;
2255
0
  self->GetId(result);
2256
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2257
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
2258
0
    return false;
2259
0
  }
2260
0
  return true;
2261
0
}
2262
2263
static const JSJitInfo id_getterinfo = {
2264
  { (JSJitGetterOp)get_id },
2265
  { prototypes::id::MediaStreamTrack },
2266
  { PrototypeTraits<prototypes::id::MediaStreamTrack>::Depth },
2267
  JSJitInfo::Getter,
2268
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2269
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
2270
  false,  /* isInfallible. False in setters. */
2271
  false,  /* isMovable.  Not relevant for setters. */
2272
  false, /* isEliminatable.  Not relevant for setters. */
2273
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2274
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2275
  false,  /* isTypedMethod.  Only relevant for methods. */
2276
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2277
};
2278
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2279
static_assert(0 < 1, "There is no slot for us");
2280
2281
MOZ_CAN_RUN_SCRIPT static bool
2282
get_label(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaStreamTrack* self, JSJitGetterCallArgs args)
2283
0
{
2284
0
  AUTO_PROFILER_LABEL_FAST("get MediaStreamTrack.label", DOM, cx);
2285
0
2286
0
  DOMString result;
2287
0
  self->GetLabel(result, nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem);
2288
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2289
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
2290
0
    return false;
2291
0
  }
2292
0
  return true;
2293
0
}
2294
2295
static const JSJitInfo label_getterinfo = {
2296
  { (JSJitGetterOp)get_label },
2297
  { prototypes::id::MediaStreamTrack },
2298
  { PrototypeTraits<prototypes::id::MediaStreamTrack>::Depth },
2299
  JSJitInfo::Getter,
2300
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2301
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
2302
  false,  /* isInfallible. False in setters. */
2303
  false,  /* isMovable.  Not relevant for setters. */
2304
  false, /* isEliminatable.  Not relevant for setters. */
2305
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2306
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2307
  false,  /* isTypedMethod.  Only relevant for methods. */
2308
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2309
};
2310
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2311
static_assert(0 < 1, "There is no slot for us");
2312
2313
MOZ_CAN_RUN_SCRIPT static bool
2314
get_enabled(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaStreamTrack* self, JSJitGetterCallArgs args)
2315
0
{
2316
0
  AUTO_PROFILER_LABEL_FAST("get MediaStreamTrack.enabled", DOM, cx);
2317
0
2318
0
  bool result(self->Enabled());
2319
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2320
0
  args.rval().setBoolean(result);
2321
0
  return true;
2322
0
}
2323
2324
MOZ_CAN_RUN_SCRIPT static bool
2325
set_enabled(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaStreamTrack* self, JSJitSetterCallArgs args)
2326
0
{
2327
0
  AUTO_PROFILER_LABEL_FAST("set MediaStreamTrack.enabled", DOM, cx);
2328
0
2329
0
  bool arg0;
2330
0
  if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
2331
0
    return false;
2332
0
  }
2333
0
  self->SetEnabled(arg0);
2334
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2335
0
2336
0
  return true;
2337
0
}
2338
2339
static const JSJitInfo enabled_getterinfo = {
2340
  { (JSJitGetterOp)get_enabled },
2341
  { prototypes::id::MediaStreamTrack },
2342
  { PrototypeTraits<prototypes::id::MediaStreamTrack>::Depth },
2343
  JSJitInfo::Getter,
2344
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2345
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
2346
  true,  /* isInfallible. False in setters. */
2347
  false,  /* isMovable.  Not relevant for setters. */
2348
  false, /* isEliminatable.  Not relevant for setters. */
2349
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2350
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2351
  false,  /* isTypedMethod.  Only relevant for methods. */
2352
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2353
};
2354
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2355
static_assert(0 < 1, "There is no slot for us");
2356
static const JSJitInfo enabled_setterinfo = {
2357
  { (JSJitGetterOp)set_enabled },
2358
  { prototypes::id::MediaStreamTrack },
2359
  { PrototypeTraits<prototypes::id::MediaStreamTrack>::Depth },
2360
  JSJitInfo::Setter,
2361
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2362
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2363
  false,  /* isInfallible. False in setters. */
2364
  false,  /* isMovable.  Not relevant for setters. */
2365
  false, /* isEliminatable.  Not relevant for setters. */
2366
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2367
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2368
  false,  /* isTypedMethod.  Only relevant for methods. */
2369
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2370
};
2371
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2372
static_assert(0 < 1, "There is no slot for us");
2373
2374
MOZ_CAN_RUN_SCRIPT static bool
2375
get_muted(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaStreamTrack* self, JSJitGetterCallArgs args)
2376
0
{
2377
0
  AUTO_PROFILER_LABEL_FAST("get MediaStreamTrack.muted", DOM, cx);
2378
0
2379
0
  bool result(self->Muted());
2380
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2381
0
  args.rval().setBoolean(result);
2382
0
  return true;
2383
0
}
2384
2385
static const JSJitInfo muted_getterinfo = {
2386
  { (JSJitGetterOp)get_muted },
2387
  { prototypes::id::MediaStreamTrack },
2388
  { PrototypeTraits<prototypes::id::MediaStreamTrack>::Depth },
2389
  JSJitInfo::Getter,
2390
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2391
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
2392
  true,  /* isInfallible. False in setters. */
2393
  false,  /* isMovable.  Not relevant for setters. */
2394
  false, /* isEliminatable.  Not relevant for setters. */
2395
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2396
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2397
  false,  /* isTypedMethod.  Only relevant for methods. */
2398
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2399
};
2400
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2401
static_assert(0 < 1, "There is no slot for us");
2402
2403
MOZ_CAN_RUN_SCRIPT static bool
2404
get_onmute(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaStreamTrack* self, JSJitGetterCallArgs args)
2405
0
{
2406
0
  AUTO_PROFILER_LABEL_FAST("get MediaStreamTrack.onmute", DOM, cx);
2407
0
2408
0
  RefPtr<EventHandlerNonNull> result(self->GetOnmute());
2409
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2410
0
  if (result) {
2411
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
2412
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
2413
0
      return false;
2414
0
    }
2415
0
    return true;
2416
0
  } else {
2417
0
    args.rval().setNull();
2418
0
    return true;
2419
0
  }
2420
0
}
2421
2422
MOZ_CAN_RUN_SCRIPT static bool
2423
set_onmute(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaStreamTrack* self, JSJitSetterCallArgs args)
2424
0
{
2425
0
  AUTO_PROFILER_LABEL_FAST("set MediaStreamTrack.onmute", DOM, cx);
2426
0
2427
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
2428
0
  if (args[0].isObject()) {
2429
0
    { // scope for tempRoot and tempGlobalRoot if needed
2430
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
2431
0
    }
2432
0
  } else {
2433
0
    arg0 = nullptr;
2434
0
  }
2435
0
  self->SetOnmute(Constify(arg0));
2436
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2437
0
2438
0
  return true;
2439
0
}
2440
2441
static const JSJitInfo onmute_getterinfo = {
2442
  { (JSJitGetterOp)get_onmute },
2443
  { prototypes::id::MediaStreamTrack },
2444
  { PrototypeTraits<prototypes::id::MediaStreamTrack>::Depth },
2445
  JSJitInfo::Getter,
2446
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2447
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
2448
  false,  /* isInfallible. False in setters. */
2449
  false,  /* isMovable.  Not relevant for setters. */
2450
  false, /* isEliminatable.  Not relevant for setters. */
2451
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2452
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2453
  false,  /* isTypedMethod.  Only relevant for methods. */
2454
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2455
};
2456
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2457
static_assert(0 < 1, "There is no slot for us");
2458
static const JSJitInfo onmute_setterinfo = {
2459
  { (JSJitGetterOp)set_onmute },
2460
  { prototypes::id::MediaStreamTrack },
2461
  { PrototypeTraits<prototypes::id::MediaStreamTrack>::Depth },
2462
  JSJitInfo::Setter,
2463
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2464
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2465
  false,  /* isInfallible. False in setters. */
2466
  false,  /* isMovable.  Not relevant for setters. */
2467
  false, /* isEliminatable.  Not relevant for setters. */
2468
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2469
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2470
  false,  /* isTypedMethod.  Only relevant for methods. */
2471
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2472
};
2473
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2474
static_assert(0 < 1, "There is no slot for us");
2475
2476
MOZ_CAN_RUN_SCRIPT static bool
2477
get_onunmute(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaStreamTrack* self, JSJitGetterCallArgs args)
2478
0
{
2479
0
  AUTO_PROFILER_LABEL_FAST("get MediaStreamTrack.onunmute", DOM, cx);
2480
0
2481
0
  RefPtr<EventHandlerNonNull> result(self->GetOnunmute());
2482
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2483
0
  if (result) {
2484
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
2485
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
2486
0
      return false;
2487
0
    }
2488
0
    return true;
2489
0
  } else {
2490
0
    args.rval().setNull();
2491
0
    return true;
2492
0
  }
2493
0
}
2494
2495
MOZ_CAN_RUN_SCRIPT static bool
2496
set_onunmute(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaStreamTrack* self, JSJitSetterCallArgs args)
2497
0
{
2498
0
  AUTO_PROFILER_LABEL_FAST("set MediaStreamTrack.onunmute", DOM, cx);
2499
0
2500
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
2501
0
  if (args[0].isObject()) {
2502
0
    { // scope for tempRoot and tempGlobalRoot if needed
2503
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
2504
0
    }
2505
0
  } else {
2506
0
    arg0 = nullptr;
2507
0
  }
2508
0
  self->SetOnunmute(Constify(arg0));
2509
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2510
0
2511
0
  return true;
2512
0
}
2513
2514
static const JSJitInfo onunmute_getterinfo = {
2515
  { (JSJitGetterOp)get_onunmute },
2516
  { prototypes::id::MediaStreamTrack },
2517
  { PrototypeTraits<prototypes::id::MediaStreamTrack>::Depth },
2518
  JSJitInfo::Getter,
2519
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2520
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
2521
  false,  /* isInfallible. False in setters. */
2522
  false,  /* isMovable.  Not relevant for setters. */
2523
  false, /* isEliminatable.  Not relevant for setters. */
2524
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2525
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2526
  false,  /* isTypedMethod.  Only relevant for methods. */
2527
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2528
};
2529
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2530
static_assert(0 < 1, "There is no slot for us");
2531
static const JSJitInfo onunmute_setterinfo = {
2532
  { (JSJitGetterOp)set_onunmute },
2533
  { prototypes::id::MediaStreamTrack },
2534
  { PrototypeTraits<prototypes::id::MediaStreamTrack>::Depth },
2535
  JSJitInfo::Setter,
2536
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2537
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2538
  false,  /* isInfallible. False in setters. */
2539
  false,  /* isMovable.  Not relevant for setters. */
2540
  false, /* isEliminatable.  Not relevant for setters. */
2541
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2542
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2543
  false,  /* isTypedMethod.  Only relevant for methods. */
2544
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2545
};
2546
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2547
static_assert(0 < 1, "There is no slot for us");
2548
2549
MOZ_CAN_RUN_SCRIPT static bool
2550
get_readyState(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaStreamTrack* self, JSJitGetterCallArgs args)
2551
0
{
2552
0
  AUTO_PROFILER_LABEL_FAST("get MediaStreamTrack.readyState", DOM, cx);
2553
0
2554
0
  MediaStreamTrackState result(self->ReadyState());
2555
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2556
0
  if (!ToJSValue(cx, result, args.rval())) {
2557
0
    return false;
2558
0
  }
2559
0
  return true;
2560
0
}
2561
2562
static const JSJitInfo readyState_getterinfo = {
2563
  { (JSJitGetterOp)get_readyState },
2564
  { prototypes::id::MediaStreamTrack },
2565
  { PrototypeTraits<prototypes::id::MediaStreamTrack>::Depth },
2566
  JSJitInfo::Getter,
2567
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2568
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
2569
  false,  /* isInfallible. False in setters. */
2570
  false,  /* isMovable.  Not relevant for setters. */
2571
  false, /* isEliminatable.  Not relevant for setters. */
2572
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2573
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2574
  false,  /* isTypedMethod.  Only relevant for methods. */
2575
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2576
};
2577
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2578
static_assert(0 < 1, "There is no slot for us");
2579
2580
MOZ_CAN_RUN_SCRIPT static bool
2581
get_onended(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaStreamTrack* self, JSJitGetterCallArgs args)
2582
0
{
2583
0
  AUTO_PROFILER_LABEL_FAST("get MediaStreamTrack.onended", DOM, cx);
2584
0
2585
0
  RefPtr<EventHandlerNonNull> result(self->GetOnended());
2586
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2587
0
  if (result) {
2588
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
2589
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
2590
0
      return false;
2591
0
    }
2592
0
    return true;
2593
0
  } else {
2594
0
    args.rval().setNull();
2595
0
    return true;
2596
0
  }
2597
0
}
2598
2599
MOZ_CAN_RUN_SCRIPT static bool
2600
set_onended(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaStreamTrack* self, JSJitSetterCallArgs args)
2601
0
{
2602
0
  AUTO_PROFILER_LABEL_FAST("set MediaStreamTrack.onended", DOM, cx);
2603
0
2604
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
2605
0
  if (args[0].isObject()) {
2606
0
    { // scope for tempRoot and tempGlobalRoot if needed
2607
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
2608
0
    }
2609
0
  } else {
2610
0
    arg0 = nullptr;
2611
0
  }
2612
0
  self->SetOnended(Constify(arg0));
2613
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2614
0
2615
0
  return true;
2616
0
}
2617
2618
static const JSJitInfo onended_getterinfo = {
2619
  { (JSJitGetterOp)get_onended },
2620
  { prototypes::id::MediaStreamTrack },
2621
  { PrototypeTraits<prototypes::id::MediaStreamTrack>::Depth },
2622
  JSJitInfo::Getter,
2623
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2624
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
2625
  false,  /* isInfallible. False in setters. */
2626
  false,  /* isMovable.  Not relevant for setters. */
2627
  false, /* isEliminatable.  Not relevant for setters. */
2628
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2629
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2630
  false,  /* isTypedMethod.  Only relevant for methods. */
2631
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2632
};
2633
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2634
static_assert(0 < 1, "There is no slot for us");
2635
static const JSJitInfo onended_setterinfo = {
2636
  { (JSJitGetterOp)set_onended },
2637
  { prototypes::id::MediaStreamTrack },
2638
  { PrototypeTraits<prototypes::id::MediaStreamTrack>::Depth },
2639
  JSJitInfo::Setter,
2640
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2641
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2642
  false,  /* isInfallible. False in setters. */
2643
  false,  /* isMovable.  Not relevant for setters. */
2644
  false, /* isEliminatable.  Not relevant for setters. */
2645
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2646
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2647
  false,  /* isTypedMethod.  Only relevant for methods. */
2648
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2649
};
2650
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2651
static_assert(0 < 1, "There is no slot for us");
2652
2653
MOZ_CAN_RUN_SCRIPT static bool
2654
clone(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaStreamTrack* self, const JSJitMethodCallArgs& args)
2655
0
{
2656
0
  AUTO_PROFILER_LABEL_FAST("MediaStreamTrack.clone", DOM, cx);
2657
0
2658
0
  auto result(StrongOrRawPtr<mozilla::dom::MediaStreamTrack>(self->Clone()));
2659
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2660
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
2661
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
2662
0
    return false;
2663
0
  }
2664
0
  return true;
2665
0
}
2666
2667
static const JSJitInfo clone_methodinfo = {
2668
  { (JSJitGetterOp)clone },
2669
  { prototypes::id::MediaStreamTrack },
2670
  { PrototypeTraits<prototypes::id::MediaStreamTrack>::Depth },
2671
  JSJitInfo::Method,
2672
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2673
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
2674
  false,  /* isInfallible. False in setters. */
2675
  false,  /* isMovable.  Not relevant for setters. */
2676
  false, /* isEliminatable.  Not relevant for setters. */
2677
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2678
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2679
  false,  /* isTypedMethod.  Only relevant for methods. */
2680
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2681
};
2682
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2683
static_assert(0 < 1, "There is no slot for us");
2684
2685
MOZ_CAN_RUN_SCRIPT static bool
2686
stop(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaStreamTrack* self, const JSJitMethodCallArgs& args)
2687
0
{
2688
0
  AUTO_PROFILER_LABEL_FAST("MediaStreamTrack.stop", DOM, cx);
2689
0
2690
0
  self->Stop();
2691
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2692
0
  args.rval().setUndefined();
2693
0
  return true;
2694
0
}
2695
2696
static const JSJitInfo stop_methodinfo = {
2697
  { (JSJitGetterOp)stop },
2698
  { prototypes::id::MediaStreamTrack },
2699
  { PrototypeTraits<prototypes::id::MediaStreamTrack>::Depth },
2700
  JSJitInfo::Method,
2701
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2702
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2703
  true,  /* isInfallible. False in setters. */
2704
  false,  /* isMovable.  Not relevant for setters. */
2705
  false, /* isEliminatable.  Not relevant for setters. */
2706
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2707
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2708
  false,  /* isTypedMethod.  Only relevant for methods. */
2709
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2710
};
2711
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2712
static_assert(0 < 1, "There is no slot for us");
2713
2714
MOZ_CAN_RUN_SCRIPT static bool
2715
getConstraints(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaStreamTrack* self, const JSJitMethodCallArgs& args)
2716
0
{
2717
0
  AUTO_PROFILER_LABEL_FAST("MediaStreamTrack.getConstraints", DOM, cx);
2718
0
2719
0
  MediaTrackConstraints result;
2720
0
  self->GetConstraints(result);
2721
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2722
0
  if (!result.ToObjectInternal(cx, args.rval())) {
2723
0
    return false;
2724
0
  }
2725
0
  return true;
2726
0
}
2727
2728
static const JSJitInfo getConstraints_methodinfo = {
2729
  { (JSJitGetterOp)getConstraints },
2730
  { prototypes::id::MediaStreamTrack },
2731
  { PrototypeTraits<prototypes::id::MediaStreamTrack>::Depth },
2732
  JSJitInfo::Method,
2733
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2734
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
2735
  false,  /* isInfallible. False in setters. */
2736
  false,  /* isMovable.  Not relevant for setters. */
2737
  false, /* isEliminatable.  Not relevant for setters. */
2738
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2739
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2740
  false,  /* isTypedMethod.  Only relevant for methods. */
2741
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2742
};
2743
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2744
static_assert(0 < 1, "There is no slot for us");
2745
2746
MOZ_CAN_RUN_SCRIPT static bool
2747
getSettings(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaStreamTrack* self, const JSJitMethodCallArgs& args)
2748
0
{
2749
0
  AUTO_PROFILER_LABEL_FAST("MediaStreamTrack.getSettings", DOM, cx);
2750
0
2751
0
  MediaTrackSettings result;
2752
0
  self->GetSettings(result, nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem);
2753
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2754
0
  if (!result.ToObjectInternal(cx, args.rval())) {
2755
0
    return false;
2756
0
  }
2757
0
  return true;
2758
0
}
2759
2760
static const JSJitInfo getSettings_methodinfo = {
2761
  { (JSJitGetterOp)getSettings },
2762
  { prototypes::id::MediaStreamTrack },
2763
  { PrototypeTraits<prototypes::id::MediaStreamTrack>::Depth },
2764
  JSJitInfo::Method,
2765
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2766
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
2767
  false,  /* isInfallible. False in setters. */
2768
  false,  /* isMovable.  Not relevant for setters. */
2769
  false, /* isEliminatable.  Not relevant for setters. */
2770
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2771
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2772
  false,  /* isTypedMethod.  Only relevant for methods. */
2773
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2774
};
2775
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2776
static_assert(0 < 1, "There is no slot for us");
2777
2778
MOZ_CAN_RUN_SCRIPT static bool
2779
applyConstraints(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaStreamTrack* self, const JSJitMethodCallArgs& args)
2780
0
{
2781
0
  AUTO_PROFILER_LABEL_FAST("MediaStreamTrack.applyConstraints", DOM, cx);
2782
0
2783
0
  binding_detail::FastMediaTrackConstraints arg0;
2784
0
  if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue,  "Argument 1 of MediaStreamTrack.applyConstraints", false)) {
2785
0
    return false;
2786
0
  }
2787
0
  FastErrorResult rv;
2788
0
  auto result(StrongOrRawPtr<Promise>(self->ApplyConstraints(Constify(arg0), nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv)));
2789
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
2790
0
    return false;
2791
0
  }
2792
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2793
0
  if (!ToJSValue(cx, result, args.rval())) {
2794
0
    return false;
2795
0
  }
2796
0
  return true;
2797
0
}
2798
2799
MOZ_CAN_RUN_SCRIPT static bool
2800
applyConstraints_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaStreamTrack* self, const JSJitMethodCallArgs& args)
2801
0
{
2802
0
  bool ok = applyConstraints(cx, obj, self, args);
2803
0
  if (ok) {
2804
0
    return true;
2805
0
  }
2806
0
  return ConvertExceptionToPromise(cx, args.rval());
2807
0
}
2808
2809
static const JSJitInfo applyConstraints_methodinfo = {
2810
  { (JSJitGetterOp)applyConstraints_promiseWrapper },
2811
  { prototypes::id::MediaStreamTrack },
2812
  { PrototypeTraits<prototypes::id::MediaStreamTrack>::Depth },
2813
  JSJitInfo::Method,
2814
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2815
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
2816
  false,  /* isInfallible. False in setters. */
2817
  false,  /* isMovable.  Not relevant for setters. */
2818
  false, /* isEliminatable.  Not relevant for setters. */
2819
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2820
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2821
  false,  /* isTypedMethod.  Only relevant for methods. */
2822
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2823
};
2824
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2825
static_assert(0 < 1, "There is no slot for us");
2826
2827
MOZ_CAN_RUN_SCRIPT static bool
2828
mutedChanged(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaStreamTrack* self, const JSJitMethodCallArgs& args)
2829
0
{
2830
0
  AUTO_PROFILER_LABEL_FAST("MediaStreamTrack.mutedChanged", DOM, cx);
2831
0
2832
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
2833
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MediaStreamTrack.mutedChanged");
2834
0
  }
2835
0
  bool arg0;
2836
0
  if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
2837
0
    return false;
2838
0
  }
2839
0
  self->MutedChanged(arg0);
2840
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2841
0
  args.rval().setUndefined();
2842
0
  return true;
2843
0
}
2844
2845
static const JSJitInfo mutedChanged_methodinfo = {
2846
  { (JSJitGetterOp)mutedChanged },
2847
  { prototypes::id::MediaStreamTrack },
2848
  { PrototypeTraits<prototypes::id::MediaStreamTrack>::Depth },
2849
  JSJitInfo::Method,
2850
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2851
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2852
  false,  /* isInfallible. False in setters. */
2853
  false,  /* isMovable.  Not relevant for setters. */
2854
  false, /* isEliminatable.  Not relevant for setters. */
2855
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2856
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2857
  false,  /* isTypedMethod.  Only relevant for methods. */
2858
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2859
};
2860
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2861
static_assert(0 < 1, "There is no slot for us");
2862
2863
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
2864
#if defined(__clang__)
2865
#pragma clang diagnostic push
2866
#pragma clang diagnostic ignored "-Wmissing-braces"
2867
#endif
2868
static const JSFunctionSpec sMethods_specs[] = {
2869
  JS_FNSPEC("clone", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&clone_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
2870
  JS_FNSPEC("stop", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&stop_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
2871
  JS_FNSPEC("getConstraints", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getConstraints_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
2872
  JS_FNSPEC("getSettings", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getSettings_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
2873
  JS_FNSPEC("applyConstraints", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&applyConstraints_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
2874
  JS_FS_END
2875
};
2876
#if defined(__clang__)
2877
#pragma clang diagnostic pop
2878
#endif
2879
2880
2881
static const Prefable<const JSFunctionSpec> sMethods[] = {
2882
  { nullptr, &sMethods_specs[0] },
2883
  { nullptr, nullptr }
2884
};
2885
2886
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
2887
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
2888
static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
2889
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
2890
2891
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
2892
#if defined(__clang__)
2893
#pragma clang diagnostic push
2894
#pragma clang diagnostic ignored "-Wmissing-braces"
2895
#endif
2896
static const JSFunctionSpec sChromeMethods_specs[] = {
2897
  JS_FNSPEC("mutedChanged", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&mutedChanged_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
2898
  JS_FS_END
2899
};
2900
#if defined(__clang__)
2901
#pragma clang diagnostic pop
2902
#endif
2903
2904
2905
static const Prefable<const JSFunctionSpec> sChromeMethods[] = {
2906
  { nullptr, &sChromeMethods_specs[0] },
2907
  { nullptr, nullptr }
2908
};
2909
2910
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
2911
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
2912
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
2913
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
2914
2915
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
2916
#if defined(__clang__)
2917
#pragma clang diagnostic push
2918
#pragma clang diagnostic ignored "-Wmissing-braces"
2919
#endif
2920
static const JSPropertySpec sAttributes_specs[] = {
2921
  { "kind", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &kind_getterinfo, nullptr, nullptr },
2922
  { "id", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &id_getterinfo, nullptr, nullptr },
2923
  { "label", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &label_getterinfo, nullptr, nullptr },
2924
  { "enabled", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &enabled_getterinfo, GenericSetter<NormalThisPolicy>, &enabled_setterinfo },
2925
  { "muted", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &muted_getterinfo, nullptr, nullptr },
2926
  { "onmute", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onmute_getterinfo, GenericSetter<NormalThisPolicy>, &onmute_setterinfo },
2927
  { "onunmute", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onunmute_getterinfo, GenericSetter<NormalThisPolicy>, &onunmute_setterinfo },
2928
  { "readyState", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &readyState_getterinfo, nullptr, nullptr },
2929
  { "onended", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onended_getterinfo, GenericSetter<NormalThisPolicy>, &onended_setterinfo },
2930
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
2931
};
2932
#if defined(__clang__)
2933
#pragma clang diagnostic pop
2934
#endif
2935
2936
2937
static const Prefable<const JSPropertySpec> sAttributes[] = {
2938
  { nullptr, &sAttributes_specs[0] },
2939
  { nullptr, nullptr }
2940
};
2941
2942
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
2943
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
2944
static_assert(9 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
2945
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
2946
2947
2948
static uint16_t sNativeProperties_sortedPropertyIndices[14];
2949
static PropertyInfo sNativeProperties_propertyInfos[14];
2950
2951
static const NativePropertiesN<2> sNativeProperties = {
2952
  false, 0,
2953
  false, 0,
2954
  true,  0 /* sMethods */,
2955
  true,  1 /* sAttributes */,
2956
  false, 0,
2957
  false, 0,
2958
  false, 0,
2959
  -1,
2960
  14,
2961
  sNativeProperties_sortedPropertyIndices,
2962
  {
2963
    { sMethods, &sNativeProperties_propertyInfos[0] },
2964
    { sAttributes, &sNativeProperties_propertyInfos[5] }
2965
  }
2966
};
2967
static_assert(14 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
2968
    "We have a property info count that is oversized");
2969
2970
static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1];
2971
static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1];
2972
2973
static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
2974
  false, 0,
2975
  false, 0,
2976
  true,  0 /* sChromeMethods */,
2977
  false, 0,
2978
  false, 0,
2979
  false, 0,
2980
  false, 0,
2981
  -1,
2982
  1,
2983
  sChromeOnlyNativeProperties_sortedPropertyIndices,
2984
  {
2985
    { sChromeMethods, &sChromeOnlyNativeProperties_propertyInfos[0] }
2986
  }
2987
};
2988
static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
2989
    "We have a property info count that is oversized");
2990
2991
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
2992
  {
2993
    "Function",
2994
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
2995
    &sBoringInterfaceObjectClassClassOps,
2996
    JS_NULL_CLASS_SPEC,
2997
    JS_NULL_CLASS_EXT,
2998
    &sInterfaceObjectClassObjectOps
2999
  },
3000
  eInterface,
3001
  true,
3002
  prototypes::id::MediaStreamTrack,
3003
  PrototypeTraits<prototypes::id::MediaStreamTrack>::Depth,
3004
  sNativePropertyHooks,
3005
  "function MediaStreamTrack() {\n    [native code]\n}",
3006
  EventTarget_Binding::GetConstructorObject
3007
};
3008
3009
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
3010
  {
3011
    "MediaStreamTrackPrototype",
3012
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
3013
    JS_NULL_CLASS_OPS,
3014
    JS_NULL_CLASS_SPEC,
3015
    JS_NULL_CLASS_EXT,
3016
    JS_NULL_OBJECT_OPS
3017
  },
3018
  eInterfacePrototype,
3019
  false,
3020
  prototypes::id::MediaStreamTrack,
3021
  PrototypeTraits<prototypes::id::MediaStreamTrack>::Depth,
3022
  sNativePropertyHooks,
3023
  "[object MediaStreamTrackPrototype]",
3024
  EventTarget_Binding::GetProtoObject
3025
};
3026
3027
const NativePropertyHooks sNativePropertyHooks[] = { {
3028
  nullptr,
3029
  nullptr,
3030
  nullptr,
3031
  { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
3032
  prototypes::id::MediaStreamTrack,
3033
  constructors::id::MediaStreamTrack,
3034
  EventTarget_Binding::sNativePropertyHooks,
3035
  &DefaultXrayExpandoObjectClass
3036
} };
3037
3038
void
3039
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
3040
0
{
3041
0
  JS::Handle<JSObject*> parentProto(EventTarget_Binding::GetProtoObjectHandle(aCx));
3042
0
  if (!parentProto) {
3043
0
    return;
3044
0
  }
3045
0
3046
0
  JS::Handle<JSObject*> constructorProto(EventTarget_Binding::GetConstructorObjectHandle(aCx));
3047
0
  if (!constructorProto) {
3048
0
    return;
3049
0
  }
3050
0
3051
0
  static bool sIdsInited = false;
3052
0
  if (!sIdsInited && NS_IsMainThread()) {
3053
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
3054
0
      return;
3055
0
    }
3056
0
    if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
3057
0
      return;
3058
0
    }
3059
0
    sIdsInited = true;
3060
0
  }
3061
0
3062
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::MediaStreamTrack);
3063
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::MediaStreamTrack);
3064
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
3065
0
                              &sPrototypeClass.mBase, protoCache,
3066
0
                              nullptr,
3067
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
3068
0
                              interfaceCache,
3069
0
                              sNativeProperties.Upcast(),
3070
0
                              sChromeOnlyNativeProperties.Upcast(),
3071
0
                              "MediaStreamTrack", aDefineOnGlobal,
3072
0
                              nullptr,
3073
0
                              false);
3074
0
}
3075
3076
JSObject*
3077
GetProtoObject(JSContext* aCx)
3078
0
{
3079
0
  return GetProtoObjectHandle(aCx);
3080
0
}
3081
3082
JSObject*
3083
GetConstructorObject(JSContext* aCx)
3084
0
{
3085
0
  return GetConstructorObjectHandle(aCx);
3086
0
}
3087
3088
} // namespace MediaStreamTrack_Binding
3089
3090
3091
3092
} // namespace dom
3093
} // namespace mozilla