Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/MediaTrackSupportedConstraintsBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM MediaTrackSupportedConstraints.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "AtomList.h"
4
#include "MediaTrackSupportedConstraintsBinding.h"
5
#include "mozilla/OwningNonNull.h"
6
#include "mozilla/dom/BindingUtils.h"
7
#include "mozilla/dom/NonRefcountedDOMObject.h"
8
#include "mozilla/dom/PrimitiveConversions.h"
9
#include "mozilla/dom/ScriptSettings.h"
10
#include "mozilla/dom/SimpleGlobalObject.h"
11
12
namespace mozilla {
13
namespace dom {
14
15
namespace binding_detail {}; // Just to make sure it's known as a namespace
16
using namespace mozilla::dom::binding_detail;
17
18
19
20
MediaTrackSupportedConstraints::MediaTrackSupportedConstraints()
21
0
{
22
0
  // Safe to pass a null context if we pass a null value
23
0
  Init(nullptr, JS::NullHandleValue);
24
0
}
25
26
27
28
bool
29
MediaTrackSupportedConstraints::InitIds(JSContext* cx, MediaTrackSupportedConstraintsAtoms* atomsCache)
30
0
{
31
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
32
0
33
0
  // Initialize these in reverse order so that any failure leaves the first one
34
0
  // uninitialized.
35
0
  if (!atomsCache->width_id.init(cx, "width") ||
36
0
      !atomsCache->volume_id.init(cx, "volume") ||
37
0
      !atomsCache->viewportWidth_id.init(cx, "viewportWidth") ||
38
0
      !atomsCache->viewportOffsetY_id.init(cx, "viewportOffsetY") ||
39
0
      !atomsCache->viewportOffsetX_id.init(cx, "viewportOffsetX") ||
40
0
      !atomsCache->viewportHeight_id.init(cx, "viewportHeight") ||
41
0
      !atomsCache->scrollWithPage_id.init(cx, "scrollWithPage") ||
42
0
      !atomsCache->sampleSize_id.init(cx, "sampleSize") ||
43
0
      !atomsCache->sampleRate_id.init(cx, "sampleRate") ||
44
0
      !atomsCache->noiseSuppression_id.init(cx, "noiseSuppression") ||
45
0
      !atomsCache->mediaSource_id.init(cx, "mediaSource") ||
46
0
      !atomsCache->latency_id.init(cx, "latency") ||
47
0
      !atomsCache->height_id.init(cx, "height") ||
48
0
      !atomsCache->groupId_id.init(cx, "groupId") ||
49
0
      !atomsCache->frameRate_id.init(cx, "frameRate") ||
50
0
      !atomsCache->facingMode_id.init(cx, "facingMode") ||
51
0
      !atomsCache->echoCancellation_id.init(cx, "echoCancellation") ||
52
0
      !atomsCache->deviceId_id.init(cx, "deviceId") ||
53
0
      !atomsCache->channelCount_id.init(cx, "channelCount") ||
54
0
      !atomsCache->browserWindow_id.init(cx, "browserWindow") ||
55
0
      !atomsCache->autoGainControl_id.init(cx, "autoGainControl") ||
56
0
      !atomsCache->aspectRatio_id.init(cx, "aspectRatio")) {
57
0
    return false;
58
0
  }
59
0
  return true;
60
0
}
61
62
bool
63
MediaTrackSupportedConstraints::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
64
0
{
65
0
  // Passing a null JSContext is OK only if we're initing from null,
66
0
  // Since in that case we will not have to do any property gets
67
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
68
0
  // checkers by static analysis tools
69
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
70
0
  MediaTrackSupportedConstraintsAtoms* atomsCache = nullptr;
71
0
  if (cx) {
72
0
    atomsCache = GetAtomCache<MediaTrackSupportedConstraintsAtoms>(cx);
73
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
74
0
      return false;
75
0
    }
76
0
  }
77
0
78
0
  if (!IsConvertibleToDictionary(val)) {
79
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
80
0
  }
81
0
82
0
  bool isNull = val.isNullOrUndefined();
83
0
  // We only need these if !isNull, in which case we have |cx|.
84
0
  Maybe<JS::Rooted<JSObject *> > object;
85
0
  Maybe<JS::Rooted<JS::Value> > temp;
86
0
  if (!isNull) {
87
0
    MOZ_ASSERT(cx);
88
0
    object.emplace(cx, &val.toObject());
89
0
    temp.emplace(cx);
90
0
  }
91
0
  if (!isNull) {
92
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->aspectRatio_id, temp.ptr())) {
93
0
      return false;
94
0
    }
95
0
  }
96
0
  if (!isNull && !temp->isUndefined()) {
97
0
    mAspectRatio.Construct();
98
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &(mAspectRatio.Value()))) {
99
0
      return false;
100
0
    }
101
0
    mIsAnyMemberPresent = true;
102
0
  }
103
0
104
0
  if (!isNull) {
105
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->autoGainControl_id, temp.ptr())) {
106
0
      return false;
107
0
    }
108
0
  }
109
0
  if (!isNull && !temp->isUndefined()) {
110
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mAutoGainControl)) {
111
0
      return false;
112
0
    }
113
0
  } else {
114
0
    mAutoGainControl = true;
115
0
  }
116
0
  mIsAnyMemberPresent = true;
117
0
118
0
  if (!isNull) {
119
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->browserWindow_id, temp.ptr())) {
120
0
      return false;
121
0
    }
122
0
  }
123
0
  if (!isNull && !temp->isUndefined()) {
124
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mBrowserWindow)) {
125
0
      return false;
126
0
    }
127
0
  } else {
128
0
    mBrowserWindow = true;
129
0
  }
130
0
  mIsAnyMemberPresent = true;
131
0
132
0
  if (!isNull) {
133
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->channelCount_id, temp.ptr())) {
134
0
      return false;
135
0
    }
136
0
  }
137
0
  if (!isNull && !temp->isUndefined()) {
138
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mChannelCount)) {
139
0
      return false;
140
0
    }
141
0
  } else {
142
0
    mChannelCount = true;
143
0
  }
144
0
  mIsAnyMemberPresent = true;
145
0
146
0
  if (!isNull) {
147
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->deviceId_id, temp.ptr())) {
148
0
      return false;
149
0
    }
150
0
  }
151
0
  if (!isNull && !temp->isUndefined()) {
152
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mDeviceId)) {
153
0
      return false;
154
0
    }
155
0
  } else {
156
0
    mDeviceId = true;
157
0
  }
158
0
  mIsAnyMemberPresent = true;
159
0
160
0
  if (!isNull) {
161
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->echoCancellation_id, temp.ptr())) {
162
0
      return false;
163
0
    }
164
0
  }
165
0
  if (!isNull && !temp->isUndefined()) {
166
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mEchoCancellation)) {
167
0
      return false;
168
0
    }
169
0
  } else {
170
0
    mEchoCancellation = true;
171
0
  }
172
0
  mIsAnyMemberPresent = true;
173
0
174
0
  if (!isNull) {
175
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->facingMode_id, temp.ptr())) {
176
0
      return false;
177
0
    }
178
0
  }
179
0
  if (!isNull && !temp->isUndefined()) {
180
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mFacingMode)) {
181
0
      return false;
182
0
    }
183
0
  } else {
184
0
    mFacingMode = true;
185
0
  }
186
0
  mIsAnyMemberPresent = true;
187
0
188
0
  if (!isNull) {
189
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->frameRate_id, temp.ptr())) {
190
0
      return false;
191
0
    }
192
0
  }
193
0
  if (!isNull && !temp->isUndefined()) {
194
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mFrameRate)) {
195
0
      return false;
196
0
    }
197
0
  } else {
198
0
    mFrameRate = true;
199
0
  }
200
0
  mIsAnyMemberPresent = true;
201
0
202
0
  if (!isNull) {
203
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->groupId_id, temp.ptr())) {
204
0
      return false;
205
0
    }
206
0
  }
207
0
  if (!isNull && !temp->isUndefined()) {
208
0
    mGroupId.Construct();
209
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &(mGroupId.Value()))) {
210
0
      return false;
211
0
    }
212
0
    mIsAnyMemberPresent = true;
213
0
  }
214
0
215
0
  if (!isNull) {
216
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->height_id, temp.ptr())) {
217
0
      return false;
218
0
    }
219
0
  }
220
0
  if (!isNull && !temp->isUndefined()) {
221
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mHeight)) {
222
0
      return false;
223
0
    }
224
0
  } else {
225
0
    mHeight = true;
226
0
  }
227
0
  mIsAnyMemberPresent = true;
228
0
229
0
  if (!isNull) {
230
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->latency_id, temp.ptr())) {
231
0
      return false;
232
0
    }
233
0
  }
234
0
  if (!isNull && !temp->isUndefined()) {
235
0
    mLatency.Construct();
236
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &(mLatency.Value()))) {
237
0
      return false;
238
0
    }
239
0
    mIsAnyMemberPresent = true;
240
0
  }
241
0
242
0
  if (!isNull) {
243
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->mediaSource_id, temp.ptr())) {
244
0
      return false;
245
0
    }
246
0
  }
247
0
  if (!isNull && !temp->isUndefined()) {
248
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mMediaSource)) {
249
0
      return false;
250
0
    }
251
0
  } else {
252
0
    mMediaSource = true;
253
0
  }
254
0
  mIsAnyMemberPresent = true;
255
0
256
0
  if (!isNull) {
257
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->noiseSuppression_id, temp.ptr())) {
258
0
      return false;
259
0
    }
260
0
  }
261
0
  if (!isNull && !temp->isUndefined()) {
262
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mNoiseSuppression)) {
263
0
      return false;
264
0
    }
265
0
  } else {
266
0
    mNoiseSuppression = true;
267
0
  }
268
0
  mIsAnyMemberPresent = true;
269
0
270
0
  if (!isNull) {
271
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->sampleRate_id, temp.ptr())) {
272
0
      return false;
273
0
    }
274
0
  }
275
0
  if (!isNull && !temp->isUndefined()) {
276
0
    mSampleRate.Construct();
277
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &(mSampleRate.Value()))) {
278
0
      return false;
279
0
    }
280
0
    mIsAnyMemberPresent = true;
281
0
  }
282
0
283
0
  if (!isNull) {
284
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->sampleSize_id, temp.ptr())) {
285
0
      return false;
286
0
    }
287
0
  }
288
0
  if (!isNull && !temp->isUndefined()) {
289
0
    mSampleSize.Construct();
290
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &(mSampleSize.Value()))) {
291
0
      return false;
292
0
    }
293
0
    mIsAnyMemberPresent = true;
294
0
  }
295
0
296
0
  if (!isNull) {
297
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->scrollWithPage_id, temp.ptr())) {
298
0
      return false;
299
0
    }
300
0
  }
301
0
  if (!isNull && !temp->isUndefined()) {
302
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mScrollWithPage)) {
303
0
      return false;
304
0
    }
305
0
  } else {
306
0
    mScrollWithPage = true;
307
0
  }
308
0
  mIsAnyMemberPresent = true;
309
0
310
0
  if (!isNull) {
311
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->viewportHeight_id, temp.ptr())) {
312
0
      return false;
313
0
    }
314
0
  }
315
0
  if (!isNull && !temp->isUndefined()) {
316
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mViewportHeight)) {
317
0
      return false;
318
0
    }
319
0
  } else {
320
0
    mViewportHeight = true;
321
0
  }
322
0
  mIsAnyMemberPresent = true;
323
0
324
0
  if (!isNull) {
325
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->viewportOffsetX_id, temp.ptr())) {
326
0
      return false;
327
0
    }
328
0
  }
329
0
  if (!isNull && !temp->isUndefined()) {
330
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mViewportOffsetX)) {
331
0
      return false;
332
0
    }
333
0
  } else {
334
0
    mViewportOffsetX = true;
335
0
  }
336
0
  mIsAnyMemberPresent = true;
337
0
338
0
  if (!isNull) {
339
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->viewportOffsetY_id, temp.ptr())) {
340
0
      return false;
341
0
    }
342
0
  }
343
0
  if (!isNull && !temp->isUndefined()) {
344
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mViewportOffsetY)) {
345
0
      return false;
346
0
    }
347
0
  } else {
348
0
    mViewportOffsetY = true;
349
0
  }
350
0
  mIsAnyMemberPresent = true;
351
0
352
0
  if (!isNull) {
353
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->viewportWidth_id, temp.ptr())) {
354
0
      return false;
355
0
    }
356
0
  }
357
0
  if (!isNull && !temp->isUndefined()) {
358
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mViewportWidth)) {
359
0
      return false;
360
0
    }
361
0
  } else {
362
0
    mViewportWidth = true;
363
0
  }
364
0
  mIsAnyMemberPresent = true;
365
0
366
0
  if (!isNull) {
367
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->volume_id, temp.ptr())) {
368
0
      return false;
369
0
    }
370
0
  }
371
0
  if (!isNull && !temp->isUndefined()) {
372
0
    mVolume.Construct();
373
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &(mVolume.Value()))) {
374
0
      return false;
375
0
    }
376
0
    mIsAnyMemberPresent = true;
377
0
  }
378
0
379
0
  if (!isNull) {
380
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->width_id, temp.ptr())) {
381
0
      return false;
382
0
    }
383
0
  }
384
0
  if (!isNull && !temp->isUndefined()) {
385
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mWidth)) {
386
0
      return false;
387
0
    }
388
0
  } else {
389
0
    mWidth = true;
390
0
  }
391
0
  mIsAnyMemberPresent = true;
392
0
  return true;
393
0
}
394
395
bool
396
MediaTrackSupportedConstraints::Init(const nsAString& aJSON)
397
0
{
398
0
  AutoJSAPI jsapi;
399
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
400
0
  if (!cleanGlobal) {
401
0
    return false;
402
0
  }
403
0
  if (!jsapi.Init(cleanGlobal)) {
404
0
    return false;
405
0
  }
406
0
  JSContext* cx = jsapi.cx();
407
0
  JS::Rooted<JS::Value> json(cx);
408
0
  bool ok = ParseJSON(cx, aJSON, &json);
409
0
  NS_ENSURE_TRUE(ok, false);
410
0
  return Init(cx, json);
411
0
}
412
413
bool
414
MediaTrackSupportedConstraints::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
415
0
{
416
0
  MediaTrackSupportedConstraintsAtoms* atomsCache = GetAtomCache<MediaTrackSupportedConstraintsAtoms>(cx);
417
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
418
0
    return false;
419
0
  }
420
0
421
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
422
0
  if (!obj) {
423
0
    return false;
424
0
  }
425
0
  rval.set(JS::ObjectValue(*obj));
426
0
427
0
  if (mAspectRatio.WasPassed()) {
428
0
    do {
429
0
      // block for our 'break' successCode and scope for 'temp' and 'currentValue'
430
0
      JS::Rooted<JS::Value> temp(cx);
431
0
      bool const & currentValue = mAspectRatio.InternalValue();
432
0
      temp.setBoolean(currentValue);
433
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->aspectRatio_id, temp, JSPROP_ENUMERATE)) {
434
0
        return false;
435
0
      }
436
0
      break;
437
0
    } while(false);
438
0
  }
439
0
440
0
  do {
441
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
442
0
    JS::Rooted<JS::Value> temp(cx);
443
0
    bool const & currentValue = mAutoGainControl;
444
0
    temp.setBoolean(currentValue);
445
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->autoGainControl_id, temp, JSPROP_ENUMERATE)) {
446
0
      return false;
447
0
    }
448
0
    break;
449
0
  } while(false);
450
0
451
0
  do {
452
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
453
0
    JS::Rooted<JS::Value> temp(cx);
454
0
    bool const & currentValue = mBrowserWindow;
455
0
    temp.setBoolean(currentValue);
456
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->browserWindow_id, temp, JSPROP_ENUMERATE)) {
457
0
      return false;
458
0
    }
459
0
    break;
460
0
  } while(false);
461
0
462
0
  do {
463
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
464
0
    JS::Rooted<JS::Value> temp(cx);
465
0
    bool const & currentValue = mChannelCount;
466
0
    temp.setBoolean(currentValue);
467
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->channelCount_id, temp, JSPROP_ENUMERATE)) {
468
0
      return false;
469
0
    }
470
0
    break;
471
0
  } while(false);
472
0
473
0
  do {
474
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
475
0
    JS::Rooted<JS::Value> temp(cx);
476
0
    bool const & currentValue = mDeviceId;
477
0
    temp.setBoolean(currentValue);
478
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->deviceId_id, temp, JSPROP_ENUMERATE)) {
479
0
      return false;
480
0
    }
481
0
    break;
482
0
  } while(false);
483
0
484
0
  do {
485
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
486
0
    JS::Rooted<JS::Value> temp(cx);
487
0
    bool const & currentValue = mEchoCancellation;
488
0
    temp.setBoolean(currentValue);
489
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->echoCancellation_id, temp, JSPROP_ENUMERATE)) {
490
0
      return false;
491
0
    }
492
0
    break;
493
0
  } while(false);
494
0
495
0
  do {
496
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
497
0
    JS::Rooted<JS::Value> temp(cx);
498
0
    bool const & currentValue = mFacingMode;
499
0
    temp.setBoolean(currentValue);
500
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->facingMode_id, temp, JSPROP_ENUMERATE)) {
501
0
      return false;
502
0
    }
503
0
    break;
504
0
  } while(false);
505
0
506
0
  do {
507
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
508
0
    JS::Rooted<JS::Value> temp(cx);
509
0
    bool const & currentValue = mFrameRate;
510
0
    temp.setBoolean(currentValue);
511
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->frameRate_id, temp, JSPROP_ENUMERATE)) {
512
0
      return false;
513
0
    }
514
0
    break;
515
0
  } while(false);
516
0
517
0
  if (mGroupId.WasPassed()) {
518
0
    do {
519
0
      // block for our 'break' successCode and scope for 'temp' and 'currentValue'
520
0
      JS::Rooted<JS::Value> temp(cx);
521
0
      bool const & currentValue = mGroupId.InternalValue();
522
0
      temp.setBoolean(currentValue);
523
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->groupId_id, temp, JSPROP_ENUMERATE)) {
524
0
        return false;
525
0
      }
526
0
      break;
527
0
    } while(false);
528
0
  }
529
0
530
0
  do {
531
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
532
0
    JS::Rooted<JS::Value> temp(cx);
533
0
    bool const & currentValue = mHeight;
534
0
    temp.setBoolean(currentValue);
535
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->height_id, temp, JSPROP_ENUMERATE)) {
536
0
      return false;
537
0
    }
538
0
    break;
539
0
  } while(false);
540
0
541
0
  if (mLatency.WasPassed()) {
542
0
    do {
543
0
      // block for our 'break' successCode and scope for 'temp' and 'currentValue'
544
0
      JS::Rooted<JS::Value> temp(cx);
545
0
      bool const & currentValue = mLatency.InternalValue();
546
0
      temp.setBoolean(currentValue);
547
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->latency_id, temp, JSPROP_ENUMERATE)) {
548
0
        return false;
549
0
      }
550
0
      break;
551
0
    } while(false);
552
0
  }
553
0
554
0
  do {
555
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
556
0
    JS::Rooted<JS::Value> temp(cx);
557
0
    bool const & currentValue = mMediaSource;
558
0
    temp.setBoolean(currentValue);
559
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->mediaSource_id, temp, JSPROP_ENUMERATE)) {
560
0
      return false;
561
0
    }
562
0
    break;
563
0
  } while(false);
564
0
565
0
  do {
566
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
567
0
    JS::Rooted<JS::Value> temp(cx);
568
0
    bool const & currentValue = mNoiseSuppression;
569
0
    temp.setBoolean(currentValue);
570
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->noiseSuppression_id, temp, JSPROP_ENUMERATE)) {
571
0
      return false;
572
0
    }
573
0
    break;
574
0
  } while(false);
575
0
576
0
  if (mSampleRate.WasPassed()) {
577
0
    do {
578
0
      // block for our 'break' successCode and scope for 'temp' and 'currentValue'
579
0
      JS::Rooted<JS::Value> temp(cx);
580
0
      bool const & currentValue = mSampleRate.InternalValue();
581
0
      temp.setBoolean(currentValue);
582
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->sampleRate_id, temp, JSPROP_ENUMERATE)) {
583
0
        return false;
584
0
      }
585
0
      break;
586
0
    } while(false);
587
0
  }
588
0
589
0
  if (mSampleSize.WasPassed()) {
590
0
    do {
591
0
      // block for our 'break' successCode and scope for 'temp' and 'currentValue'
592
0
      JS::Rooted<JS::Value> temp(cx);
593
0
      bool const & currentValue = mSampleSize.InternalValue();
594
0
      temp.setBoolean(currentValue);
595
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->sampleSize_id, temp, JSPROP_ENUMERATE)) {
596
0
        return false;
597
0
      }
598
0
      break;
599
0
    } while(false);
600
0
  }
601
0
602
0
  do {
603
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
604
0
    JS::Rooted<JS::Value> temp(cx);
605
0
    bool const & currentValue = mScrollWithPage;
606
0
    temp.setBoolean(currentValue);
607
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->scrollWithPage_id, temp, JSPROP_ENUMERATE)) {
608
0
      return false;
609
0
    }
610
0
    break;
611
0
  } while(false);
612
0
613
0
  do {
614
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
615
0
    JS::Rooted<JS::Value> temp(cx);
616
0
    bool const & currentValue = mViewportHeight;
617
0
    temp.setBoolean(currentValue);
618
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->viewportHeight_id, temp, JSPROP_ENUMERATE)) {
619
0
      return false;
620
0
    }
621
0
    break;
622
0
  } while(false);
623
0
624
0
  do {
625
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
626
0
    JS::Rooted<JS::Value> temp(cx);
627
0
    bool const & currentValue = mViewportOffsetX;
628
0
    temp.setBoolean(currentValue);
629
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->viewportOffsetX_id, temp, JSPROP_ENUMERATE)) {
630
0
      return false;
631
0
    }
632
0
    break;
633
0
  } while(false);
634
0
635
0
  do {
636
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
637
0
    JS::Rooted<JS::Value> temp(cx);
638
0
    bool const & currentValue = mViewportOffsetY;
639
0
    temp.setBoolean(currentValue);
640
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->viewportOffsetY_id, temp, JSPROP_ENUMERATE)) {
641
0
      return false;
642
0
    }
643
0
    break;
644
0
  } while(false);
645
0
646
0
  do {
647
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
648
0
    JS::Rooted<JS::Value> temp(cx);
649
0
    bool const & currentValue = mViewportWidth;
650
0
    temp.setBoolean(currentValue);
651
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->viewportWidth_id, temp, JSPROP_ENUMERATE)) {
652
0
      return false;
653
0
    }
654
0
    break;
655
0
  } while(false);
656
0
657
0
  if (mVolume.WasPassed()) {
658
0
    do {
659
0
      // block for our 'break' successCode and scope for 'temp' and 'currentValue'
660
0
      JS::Rooted<JS::Value> temp(cx);
661
0
      bool const & currentValue = mVolume.InternalValue();
662
0
      temp.setBoolean(currentValue);
663
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->volume_id, temp, JSPROP_ENUMERATE)) {
664
0
        return false;
665
0
      }
666
0
      break;
667
0
    } while(false);
668
0
  }
669
0
670
0
  do {
671
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
672
0
    JS::Rooted<JS::Value> temp(cx);
673
0
    bool const & currentValue = mWidth;
674
0
    temp.setBoolean(currentValue);
675
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->width_id, temp, JSPROP_ENUMERATE)) {
676
0
      return false;
677
0
    }
678
0
    break;
679
0
  } while(false);
680
0
681
0
  return true;
682
0
}
683
684
bool
685
MediaTrackSupportedConstraints::ToJSON(nsAString& aJSON) const
686
0
{
687
0
  AutoJSAPI jsapi;
688
0
  jsapi.Init();
689
0
  JSContext *cx = jsapi.cx();
690
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
691
0
  // because we'll only be creating objects, in ways that have no
692
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
693
0
  // which likewise guarantees no side-effects for the sorts of
694
0
  // things we will pass it.
695
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
696
0
  JS::Rooted<JS::Value> val(cx);
697
0
  if (!ToObjectInternal(cx, &val)) {
698
0
    return false;
699
0
  }
700
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
701
0
  return StringifyToJSON(cx, obj, aJSON);
702
0
}
703
704
void
705
MediaTrackSupportedConstraints::TraceDictionary(JSTracer* trc)
706
0
{
707
0
}
708
709
MediaTrackSupportedConstraints&
710
MediaTrackSupportedConstraints::operator=(const MediaTrackSupportedConstraints& aOther)
711
0
{
712
0
  DictionaryBase::operator=(aOther);
713
0
  mAspectRatio.Reset();
714
0
  if (aOther.mAspectRatio.WasPassed()) {
715
0
    mAspectRatio.Construct(aOther.mAspectRatio.Value());
716
0
  }
717
0
  mAutoGainControl = aOther.mAutoGainControl;
718
0
  mBrowserWindow = aOther.mBrowserWindow;
719
0
  mChannelCount = aOther.mChannelCount;
720
0
  mDeviceId = aOther.mDeviceId;
721
0
  mEchoCancellation = aOther.mEchoCancellation;
722
0
  mFacingMode = aOther.mFacingMode;
723
0
  mFrameRate = aOther.mFrameRate;
724
0
  mGroupId.Reset();
725
0
  if (aOther.mGroupId.WasPassed()) {
726
0
    mGroupId.Construct(aOther.mGroupId.Value());
727
0
  }
728
0
  mHeight = aOther.mHeight;
729
0
  mLatency.Reset();
730
0
  if (aOther.mLatency.WasPassed()) {
731
0
    mLatency.Construct(aOther.mLatency.Value());
732
0
  }
733
0
  mMediaSource = aOther.mMediaSource;
734
0
  mNoiseSuppression = aOther.mNoiseSuppression;
735
0
  mSampleRate.Reset();
736
0
  if (aOther.mSampleRate.WasPassed()) {
737
0
    mSampleRate.Construct(aOther.mSampleRate.Value());
738
0
  }
739
0
  mSampleSize.Reset();
740
0
  if (aOther.mSampleSize.WasPassed()) {
741
0
    mSampleSize.Construct(aOther.mSampleSize.Value());
742
0
  }
743
0
  mScrollWithPage = aOther.mScrollWithPage;
744
0
  mViewportHeight = aOther.mViewportHeight;
745
0
  mViewportOffsetX = aOther.mViewportOffsetX;
746
0
  mViewportOffsetY = aOther.mViewportOffsetY;
747
0
  mViewportWidth = aOther.mViewportWidth;
748
0
  mVolume.Reset();
749
0
  if (aOther.mVolume.WasPassed()) {
750
0
    mVolume.Construct(aOther.mVolume.Value());
751
0
  }
752
0
  mWidth = aOther.mWidth;
753
0
  return *this;
754
0
}
755
756
namespace binding_detail {
757
} // namespace binding_detail
758
759
760
} // namespace dom
761
} // namespace mozilla