Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/RTCIceCandidateBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM RTCIceCandidate.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "AtomList.h"
4
#include "RTCIceCandidateBinding.h"
5
#include "WrapperFactory.h"
6
#include "mozilla/OwningNonNull.h"
7
#include "mozilla/Preferences.h"
8
#include "mozilla/dom/BindingUtils.h"
9
#include "mozilla/dom/DOMJSClass.h"
10
#include "mozilla/dom/NonRefcountedDOMObject.h"
11
#include "mozilla/dom/Nullable.h"
12
#include "mozilla/dom/PrimitiveConversions.h"
13
#include "mozilla/dom/ScriptSettings.h"
14
#include "mozilla/dom/SimpleGlobalObject.h"
15
#include "mozilla/dom/XrayExpandoClass.h"
16
#include "nsContentUtils.h"
17
#include "nsIGlobalObject.h"
18
19
namespace mozilla {
20
namespace dom {
21
22
namespace binding_detail {}; // Just to make sure it's known as a namespace
23
using namespace mozilla::dom::binding_detail;
24
25
26
27
RTCIceCandidateInit::RTCIceCandidateInit()
28
0
{
29
0
  // Safe to pass a null context if we pass a null value
30
0
  Init(nullptr, JS::NullHandleValue);
31
0
}
32
33
34
35
bool
36
RTCIceCandidateInit::InitIds(JSContext* cx, RTCIceCandidateInitAtoms* atomsCache)
37
0
{
38
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
39
0
40
0
  // Initialize these in reverse order so that any failure leaves the first one
41
0
  // uninitialized.
42
0
  if (!atomsCache->sdpMid_id.init(cx, "sdpMid") ||
43
0
      !atomsCache->sdpMLineIndex_id.init(cx, "sdpMLineIndex") ||
44
0
      !atomsCache->candidate_id.init(cx, "candidate")) {
45
0
    return false;
46
0
  }
47
0
  return true;
48
0
}
49
50
bool
51
RTCIceCandidateInit::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
52
0
{
53
0
  // Passing a null JSContext is OK only if we're initing from null,
54
0
  // Since in that case we will not have to do any property gets
55
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
56
0
  // checkers by static analysis tools
57
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
58
0
  RTCIceCandidateInitAtoms* atomsCache = nullptr;
59
0
  if (cx) {
60
0
    atomsCache = GetAtomCache<RTCIceCandidateInitAtoms>(cx);
61
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
62
0
      return false;
63
0
    }
64
0
  }
65
0
66
0
  if (!IsConvertibleToDictionary(val)) {
67
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
68
0
  }
69
0
70
0
  bool isNull = val.isNullOrUndefined();
71
0
  // We only need these if !isNull, in which case we have |cx|.
72
0
  Maybe<JS::Rooted<JSObject *> > object;
73
0
  Maybe<JS::Rooted<JS::Value> > temp;
74
0
  if (!isNull) {
75
0
    MOZ_ASSERT(cx);
76
0
    object.emplace(cx, &val.toObject());
77
0
    temp.emplace(cx);
78
0
  }
79
0
  if (!isNull) {
80
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->candidate_id, temp.ptr())) {
81
0
      return false;
82
0
    }
83
0
  }
84
0
  if (!isNull && !temp->isUndefined()) {
85
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mCandidate)) {
86
0
      return false;
87
0
    }
88
0
    mIsAnyMemberPresent = true;
89
0
  } else if (cx) {
90
0
    // Don't error out if we have no cx.  In that
91
0
    // situation the caller is default-constructing us and we'll
92
0
    // just assume they know what they're doing.
93
0
    return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
94
0
                             "'candidate' member of RTCIceCandidateInit");
95
0
  }
96
0
97
0
  if (!isNull) {
98
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->sdpMLineIndex_id, temp.ptr())) {
99
0
      return false;
100
0
    }
101
0
  }
102
0
  if (!(!isNull && !temp->isUndefined()) || temp.ref().isNullOrUndefined()) {
103
0
    mSdpMLineIndex.SetNull();
104
0
  } else if (!ValueToPrimitive<uint16_t, eDefault>(cx, temp.ref(), &mSdpMLineIndex.SetValue())) {
105
0
    return false;
106
0
  }
107
0
  mIsAnyMemberPresent = true;
108
0
109
0
  if (!isNull) {
110
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->sdpMid_id, temp.ptr())) {
111
0
      return false;
112
0
    }
113
0
  }
114
0
  if (!isNull && !temp->isUndefined()) {
115
0
    if (!ConvertJSValueToString(cx, temp.ref(), eNull, eNull, mSdpMid)) {
116
0
      return false;
117
0
    }
118
0
  } else {
119
0
    mSdpMid.SetIsVoid(true);
120
0
  }
121
0
  mIsAnyMemberPresent = true;
122
0
  return true;
123
0
}
124
125
bool
126
RTCIceCandidateInit::Init(const nsAString& aJSON)
127
0
{
128
0
  AutoJSAPI jsapi;
129
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
130
0
  if (!cleanGlobal) {
131
0
    return false;
132
0
  }
133
0
  if (!jsapi.Init(cleanGlobal)) {
134
0
    return false;
135
0
  }
136
0
  JSContext* cx = jsapi.cx();
137
0
  JS::Rooted<JS::Value> json(cx);
138
0
  bool ok = ParseJSON(cx, aJSON, &json);
139
0
  NS_ENSURE_TRUE(ok, false);
140
0
  return Init(cx, json);
141
0
}
142
143
bool
144
RTCIceCandidateInit::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
145
0
{
146
0
  RTCIceCandidateInitAtoms* atomsCache = GetAtomCache<RTCIceCandidateInitAtoms>(cx);
147
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
148
0
    return false;
149
0
  }
150
0
151
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
152
0
  if (!obj) {
153
0
    return false;
154
0
  }
155
0
  rval.set(JS::ObjectValue(*obj));
156
0
157
0
  do {
158
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
159
0
    JS::Rooted<JS::Value> temp(cx);
160
0
    nsString const & currentValue = mCandidate;
161
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
162
0
      return false;
163
0
    }
164
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->candidate_id, temp, JSPROP_ENUMERATE)) {
165
0
      return false;
166
0
    }
167
0
    break;
168
0
  } while(false);
169
0
170
0
  do {
171
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
172
0
    JS::Rooted<JS::Value> temp(cx);
173
0
    Nullable<uint16_t> const & currentValue = mSdpMLineIndex;
174
0
    if (currentValue.IsNull()) {
175
0
      temp.setNull();
176
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->sdpMLineIndex_id, temp, JSPROP_ENUMERATE)) {
177
0
        return false;
178
0
      }
179
0
      break;
180
0
    }
181
0
    temp.setInt32(int32_t(currentValue.Value()));
182
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->sdpMLineIndex_id, temp, JSPROP_ENUMERATE)) {
183
0
      return false;
184
0
    }
185
0
    break;
186
0
  } while(false);
187
0
188
0
  do {
189
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
190
0
    JS::Rooted<JS::Value> temp(cx);
191
0
    nsString const & currentValue = mSdpMid;
192
0
    if (!xpc::StringToJsval(cx, currentValue, &temp)) {
193
0
      return false;
194
0
    }
195
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->sdpMid_id, temp, JSPROP_ENUMERATE)) {
196
0
      return false;
197
0
    }
198
0
    break;
199
0
  } while(false);
200
0
201
0
  return true;
202
0
}
203
204
bool
205
RTCIceCandidateInit::ToJSON(nsAString& aJSON) const
206
0
{
207
0
  AutoJSAPI jsapi;
208
0
  jsapi.Init();
209
0
  JSContext *cx = jsapi.cx();
210
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
211
0
  // because we'll only be creating objects, in ways that have no
212
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
213
0
  // which likewise guarantees no side-effects for the sorts of
214
0
  // things we will pass it.
215
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
216
0
  JS::Rooted<JS::Value> val(cx);
217
0
  if (!ToObjectInternal(cx, &val)) {
218
0
    return false;
219
0
  }
220
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
221
0
  return StringifyToJSON(cx, obj, aJSON);
222
0
}
223
224
void
225
RTCIceCandidateInit::TraceDictionary(JSTracer* trc)
226
0
{
227
0
}
228
229
RTCIceCandidateInit&
230
RTCIceCandidateInit::operator=(const RTCIceCandidateInit& aOther)
231
0
{
232
0
  DictionaryBase::operator=(aOther);
233
0
  mCandidate = aOther.mCandidate;
234
0
  mSdpMLineIndex = aOther.mSdpMLineIndex;
235
0
  mSdpMid = aOther.mSdpMid;
236
0
  return *this;
237
0
}
238
239
namespace binding_detail {
240
} // namespace binding_detail
241
242
243
namespace RTCIceCandidate_Binding {
244
245
MOZ_CAN_RUN_SCRIPT static bool
246
get_candidate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCIceCandidate* self, JSJitGetterCallArgs args)
247
0
{
248
0
  AUTO_PROFILER_LABEL_FAST("get RTCIceCandidate.candidate", DOM, cx);
249
0
250
0
  Maybe<JS::Rooted<JSObject*> > unwrappedObj;
251
0
  bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
252
0
  if (objIsXray) {
253
0
    unwrappedObj.emplace(cx, obj);
254
0
  }
255
0
  if (objIsXray) {
256
0
    unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref());
257
0
    if (!unwrappedObj.ref()) {
258
0
      return false;
259
0
    }
260
0
  }
261
0
  FastErrorResult rv;
262
0
  DOMString result;
263
0
  self->GetCandidate(result, rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx)));
264
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
265
0
    return false;
266
0
  }
267
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
268
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
269
0
    return false;
270
0
  }
271
0
  return true;
272
0
}
273
274
MOZ_CAN_RUN_SCRIPT static bool
275
set_candidate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCIceCandidate* self, JSJitSetterCallArgs args)
276
0
{
277
0
  AUTO_PROFILER_LABEL_FAST("set RTCIceCandidate.candidate", DOM, cx);
278
0
279
0
  Maybe<JS::Rooted<JSObject*> > unwrappedObj;
280
0
  bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
281
0
  if (objIsXray) {
282
0
    unwrappedObj.emplace(cx, obj);
283
0
  }
284
0
  binding_detail::FakeString arg0;
285
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
286
0
    return false;
287
0
  }
288
0
  if (objIsXray) {
289
0
    unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref());
290
0
    if (!unwrappedObj.ref()) {
291
0
      return false;
292
0
    }
293
0
  }
294
0
  FastErrorResult rv;
295
0
  self->SetCandidate(NonNullHelper(Constify(arg0)), rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx)));
296
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
297
0
    return false;
298
0
  }
299
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
300
0
301
0
  return true;
302
0
}
303
304
static const JSJitInfo candidate_getterinfo = {
305
  { (JSJitGetterOp)get_candidate },
306
  { prototypes::id::RTCIceCandidate },
307
  { PrototypeTraits<prototypes::id::RTCIceCandidate>::Depth },
308
  JSJitInfo::Getter,
309
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
310
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
311
  false,  /* isInfallible. False in setters. */
312
  false,  /* isMovable.  Not relevant for setters. */
313
  false, /* isEliminatable.  Not relevant for setters. */
314
  false, /* isAlwaysInSlot.  Only relevant for getters. */
315
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
316
  false,  /* isTypedMethod.  Only relevant for methods. */
317
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
318
};
319
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
320
static_assert(0 < 1, "There is no slot for us");
321
static const JSJitInfo candidate_setterinfo = {
322
  { (JSJitGetterOp)set_candidate },
323
  { prototypes::id::RTCIceCandidate },
324
  { PrototypeTraits<prototypes::id::RTCIceCandidate>::Depth },
325
  JSJitInfo::Setter,
326
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
327
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
328
  false,  /* isInfallible. False in setters. */
329
  false,  /* isMovable.  Not relevant for setters. */
330
  false, /* isEliminatable.  Not relevant for setters. */
331
  false, /* isAlwaysInSlot.  Only relevant for getters. */
332
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
333
  false,  /* isTypedMethod.  Only relevant for methods. */
334
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
335
};
336
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
337
static_assert(0 < 1, "There is no slot for us");
338
339
MOZ_CAN_RUN_SCRIPT static bool
340
get_sdpMid(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCIceCandidate* self, JSJitGetterCallArgs args)
341
0
{
342
0
  AUTO_PROFILER_LABEL_FAST("get RTCIceCandidate.sdpMid", DOM, cx);
343
0
344
0
  Maybe<JS::Rooted<JSObject*> > unwrappedObj;
345
0
  bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
346
0
  if (objIsXray) {
347
0
    unwrappedObj.emplace(cx, obj);
348
0
  }
349
0
  if (objIsXray) {
350
0
    unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref());
351
0
    if (!unwrappedObj.ref()) {
352
0
      return false;
353
0
    }
354
0
  }
355
0
  FastErrorResult rv;
356
0
  DOMString result;
357
0
  self->GetSdpMid(result, rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx)));
358
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
359
0
    return false;
360
0
  }
361
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
362
0
  if (!xpc::StringToJsval(cx, result, args.rval())) {
363
0
    return false;
364
0
  }
365
0
  return true;
366
0
}
367
368
MOZ_CAN_RUN_SCRIPT static bool
369
set_sdpMid(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCIceCandidate* self, JSJitSetterCallArgs args)
370
0
{
371
0
  AUTO_PROFILER_LABEL_FAST("set RTCIceCandidate.sdpMid", DOM, cx);
372
0
373
0
  Maybe<JS::Rooted<JSObject*> > unwrappedObj;
374
0
  bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
375
0
  if (objIsXray) {
376
0
    unwrappedObj.emplace(cx, obj);
377
0
  }
378
0
  binding_detail::FakeString arg0;
379
0
  if (!ConvertJSValueToString(cx, args[0], eNull, eNull, arg0)) {
380
0
    return false;
381
0
  }
382
0
  if (objIsXray) {
383
0
    unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref());
384
0
    if (!unwrappedObj.ref()) {
385
0
      return false;
386
0
    }
387
0
  }
388
0
  FastErrorResult rv;
389
0
  self->SetSdpMid(NonNullHelper(Constify(arg0)), rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx)));
390
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
391
0
    return false;
392
0
  }
393
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
394
0
395
0
  return true;
396
0
}
397
398
static const JSJitInfo sdpMid_getterinfo = {
399
  { (JSJitGetterOp)get_sdpMid },
400
  { prototypes::id::RTCIceCandidate },
401
  { PrototypeTraits<prototypes::id::RTCIceCandidate>::Depth },
402
  JSJitInfo::Getter,
403
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
404
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
405
  false,  /* isInfallible. False in setters. */
406
  false,  /* isMovable.  Not relevant for setters. */
407
  false, /* isEliminatable.  Not relevant for setters. */
408
  false, /* isAlwaysInSlot.  Only relevant for getters. */
409
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
410
  false,  /* isTypedMethod.  Only relevant for methods. */
411
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
412
};
413
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
414
static_assert(0 < 1, "There is no slot for us");
415
static const JSJitInfo sdpMid_setterinfo = {
416
  { (JSJitGetterOp)set_sdpMid },
417
  { prototypes::id::RTCIceCandidate },
418
  { PrototypeTraits<prototypes::id::RTCIceCandidate>::Depth },
419
  JSJitInfo::Setter,
420
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
421
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
422
  false,  /* isInfallible. False in setters. */
423
  false,  /* isMovable.  Not relevant for setters. */
424
  false, /* isEliminatable.  Not relevant for setters. */
425
  false, /* isAlwaysInSlot.  Only relevant for getters. */
426
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
427
  false,  /* isTypedMethod.  Only relevant for methods. */
428
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
429
};
430
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
431
static_assert(0 < 1, "There is no slot for us");
432
433
MOZ_CAN_RUN_SCRIPT static bool
434
get_sdpMLineIndex(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCIceCandidate* self, JSJitGetterCallArgs args)
435
0
{
436
0
  AUTO_PROFILER_LABEL_FAST("get RTCIceCandidate.sdpMLineIndex", DOM, cx);
437
0
438
0
  Maybe<JS::Rooted<JSObject*> > unwrappedObj;
439
0
  bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
440
0
  if (objIsXray) {
441
0
    unwrappedObj.emplace(cx, obj);
442
0
  }
443
0
  if (objIsXray) {
444
0
    unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref());
445
0
    if (!unwrappedObj.ref()) {
446
0
      return false;
447
0
    }
448
0
  }
449
0
  FastErrorResult rv;
450
0
  Nullable<uint16_t> result(self->GetSdpMLineIndex(rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))));
451
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
452
0
    return false;
453
0
  }
454
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
455
0
  if (result.IsNull()) {
456
0
    args.rval().setNull();
457
0
    return true;
458
0
  }
459
0
  args.rval().setInt32(int32_t(result.Value()));
460
0
  return true;
461
0
}
462
463
MOZ_CAN_RUN_SCRIPT static bool
464
set_sdpMLineIndex(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCIceCandidate* self, JSJitSetterCallArgs args)
465
0
{
466
0
  AUTO_PROFILER_LABEL_FAST("set RTCIceCandidate.sdpMLineIndex", DOM, cx);
467
0
468
0
  Maybe<JS::Rooted<JSObject*> > unwrappedObj;
469
0
  bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
470
0
  if (objIsXray) {
471
0
    unwrappedObj.emplace(cx, obj);
472
0
  }
473
0
  Nullable<uint16_t> arg0;
474
0
  if (args[0].isNullOrUndefined()) {
475
0
    arg0.SetNull();
476
0
  } else if (!ValueToPrimitive<uint16_t, eDefault>(cx, args[0], &arg0.SetValue())) {
477
0
    return false;
478
0
  }
479
0
  if (objIsXray) {
480
0
    unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref());
481
0
    if (!unwrappedObj.ref()) {
482
0
      return false;
483
0
    }
484
0
  }
485
0
  FastErrorResult rv;
486
0
  self->SetSdpMLineIndex(Constify(arg0), rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx)));
487
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
488
0
    return false;
489
0
  }
490
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
491
0
492
0
  return true;
493
0
}
494
495
static const JSJitInfo sdpMLineIndex_getterinfo = {
496
  { (JSJitGetterOp)get_sdpMLineIndex },
497
  { prototypes::id::RTCIceCandidate },
498
  { PrototypeTraits<prototypes::id::RTCIceCandidate>::Depth },
499
  JSJitInfo::Getter,
500
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
501
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
502
  false,  /* isInfallible. False in setters. */
503
  false,  /* isMovable.  Not relevant for setters. */
504
  false, /* isEliminatable.  Not relevant for setters. */
505
  false, /* isAlwaysInSlot.  Only relevant for getters. */
506
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
507
  false,  /* isTypedMethod.  Only relevant for methods. */
508
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
509
};
510
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
511
static_assert(0 < 1, "There is no slot for us");
512
static const JSJitInfo sdpMLineIndex_setterinfo = {
513
  { (JSJitGetterOp)set_sdpMLineIndex },
514
  { prototypes::id::RTCIceCandidate },
515
  { PrototypeTraits<prototypes::id::RTCIceCandidate>::Depth },
516
  JSJitInfo::Setter,
517
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
518
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
519
  false,  /* isInfallible. False in setters. */
520
  false,  /* isMovable.  Not relevant for setters. */
521
  false, /* isEliminatable.  Not relevant for setters. */
522
  false, /* isAlwaysInSlot.  Only relevant for getters. */
523
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
524
  false,  /* isTypedMethod.  Only relevant for methods. */
525
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
526
};
527
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
528
static_assert(0 < 1, "There is no slot for us");
529
530
MOZ_CAN_RUN_SCRIPT static bool
531
toJSON(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCIceCandidate* self, const JSJitMethodCallArgs& args)
532
0
{
533
0
  AUTO_PROFILER_LABEL_FAST("RTCIceCandidate.toJSON", DOM, cx);
534
0
535
0
  JS::Rooted<JSObject*> result(cx, JS_NewPlainObject(cx));
536
0
  if (!result) {
537
0
    return false;
538
0
  }
539
0
  if (!RTCIceCandidate_Binding::CollectJSONAttributes(cx, obj, self, result)) {
540
0
    return false;
541
0
  }
542
0
  args.rval().setObject(*result);
543
0
  return true;
544
0
}
545
546
static const JSJitInfo toJSON_methodinfo = {
547
  { (JSJitGetterOp)toJSON },
548
  { prototypes::id::RTCIceCandidate },
549
  { PrototypeTraits<prototypes::id::RTCIceCandidate>::Depth },
550
  JSJitInfo::Method,
551
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
552
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
553
  false,  /* isInfallible. False in setters. */
554
  false,  /* isMovable.  Not relevant for setters. */
555
  false, /* isEliminatable.  Not relevant for setters. */
556
  false, /* isAlwaysInSlot.  Only relevant for getters. */
557
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
558
  false,  /* isTypedMethod.  Only relevant for methods. */
559
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
560
};
561
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
562
static_assert(0 < 1, "There is no slot for us");
563
564
static bool
565
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
566
0
{
567
0
  mozilla::dom::RTCIceCandidate* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::RTCIceCandidate>(obj);
568
0
  // We don't want to preserve if we don't have a wrapper, and we
569
0
  // obviously can't preserve if we're not initialized.
570
0
  if (self && self->GetWrapperPreserveColor()) {
571
0
    PreserveWrapper(self);
572
0
  }
573
0
  return true;
574
0
}
575
576
static void
577
_finalize(js::FreeOp* fop, JSObject* obj)
578
0
{
579
0
  mozilla::dom::RTCIceCandidate* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::RTCIceCandidate>(obj);
580
0
  if (self) {
581
0
    ClearWrapper(self, self, obj);
582
0
    AddForDeferredFinalization<mozilla::dom::RTCIceCandidate>(self);
583
0
  }
584
0
}
585
586
static size_t
587
_objectMoved(JSObject* obj, JSObject* old)
588
0
{
589
0
  mozilla::dom::RTCIceCandidate* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::RTCIceCandidate>(obj);
590
0
  if (self) {
591
0
    UpdateWrapper(self, self, obj, old);
592
0
  }
593
0
594
0
  return 0;
595
0
}
596
597
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
598
#if defined(__clang__)
599
#pragma clang diagnostic push
600
#pragma clang diagnostic ignored "-Wmissing-braces"
601
#endif
602
static const JSFunctionSpec sChromeStaticMethods_specs[] = {
603
  JS_FNSPEC("_create", RTCIceCandidate::_Create, nullptr, 2, 0, nullptr),
604
  JS_FS_END
605
};
606
#if defined(__clang__)
607
#pragma clang diagnostic pop
608
#endif
609
610
611
static const Prefable<const JSFunctionSpec> sChromeStaticMethods[] = {
612
  { nullptr, &sChromeStaticMethods_specs[0] },
613
  { nullptr, nullptr }
614
};
615
616
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
617
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
618
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
619
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
620
621
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
622
#if defined(__clang__)
623
#pragma clang diagnostic push
624
#pragma clang diagnostic ignored "-Wmissing-braces"
625
#endif
626
static const JSFunctionSpec sMethods_specs[] = {
627
  JS_FNSPEC("toJSON", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&toJSON_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
628
  JS_FS_END
629
};
630
#if defined(__clang__)
631
#pragma clang diagnostic pop
632
#endif
633
634
635
static const Prefable<const JSFunctionSpec> sMethods[] = {
636
  { nullptr, &sMethods_specs[0] },
637
  { nullptr, nullptr }
638
};
639
640
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
641
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
642
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
643
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
644
645
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
646
#if defined(__clang__)
647
#pragma clang diagnostic push
648
#pragma clang diagnostic ignored "-Wmissing-braces"
649
#endif
650
static const JSPropertySpec sAttributes_specs[] = {
651
  { "candidate", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &candidate_getterinfo, GenericSetter<NormalThisPolicy>, &candidate_setterinfo },
652
  { "sdpMid", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &sdpMid_getterinfo, GenericSetter<NormalThisPolicy>, &sdpMid_setterinfo },
653
  { "sdpMLineIndex", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &sdpMLineIndex_getterinfo, GenericSetter<NormalThisPolicy>, &sdpMLineIndex_setterinfo },
654
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
655
};
656
#if defined(__clang__)
657
#pragma clang diagnostic pop
658
#endif
659
660
661
static const Prefable<const JSPropertySpec> sAttributes[] = {
662
  { nullptr, &sAttributes_specs[0] },
663
  { nullptr, nullptr }
664
};
665
666
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
667
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
668
static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
669
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
670
671
672
static uint16_t sNativeProperties_sortedPropertyIndices[4];
673
static PropertyInfo sNativeProperties_propertyInfos[4];
674
675
static const NativePropertiesN<2> sNativeProperties = {
676
  false, 0,
677
  false, 0,
678
  true,  0 /* sMethods */,
679
  true,  1 /* sAttributes */,
680
  false, 0,
681
  false, 0,
682
  false, 0,
683
  -1,
684
  4,
685
  sNativeProperties_sortedPropertyIndices,
686
  {
687
    { sMethods, &sNativeProperties_propertyInfos[0] },
688
    { sAttributes, &sNativeProperties_propertyInfos[1] }
689
  }
690
};
691
static_assert(4 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
692
    "We have a property info count that is oversized");
693
694
static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1];
695
static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1];
696
697
static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
698
  true,  0 /* sChromeStaticMethods */,
699
  false, 0,
700
  false, 0,
701
  false, 0,
702
  false, 0,
703
  false, 0,
704
  false, 0,
705
  -1,
706
  1,
707
  sChromeOnlyNativeProperties_sortedPropertyIndices,
708
  {
709
    { sChromeStaticMethods, &sChromeOnlyNativeProperties_propertyInfos[0] }
710
  }
711
};
712
static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
713
    "We have a property info count that is oversized");
714
715
MOZ_CAN_RUN_SCRIPT bool
716
CollectJSONAttributes(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCIceCandidate* self, JS::Rooted<JSObject*>& result)
717
0
{
718
0
  { // scope for "temp"
719
0
    JS::Rooted<JS::Value> temp(cx);
720
0
    if (!get_candidate(cx, obj, self, JSJitGetterCallArgs(&temp))) {
721
0
      return false;
722
0
    }
723
0
    if (!JS_DefineProperty(cx, result, "candidate", temp, JSPROP_ENUMERATE)) {
724
0
      return false;
725
0
    }
726
0
  }
727
0
  { // scope for "temp"
728
0
    JS::Rooted<JS::Value> temp(cx);
729
0
    if (!get_sdpMid(cx, obj, self, JSJitGetterCallArgs(&temp))) {
730
0
      return false;
731
0
    }
732
0
    if (!JS_DefineProperty(cx, result, "sdpMid", temp, JSPROP_ENUMERATE)) {
733
0
      return false;
734
0
    }
735
0
  }
736
0
  { // scope for "temp"
737
0
    JS::Rooted<JS::Value> temp(cx);
738
0
    if (!get_sdpMLineIndex(cx, obj, self, JSJitGetterCallArgs(&temp))) {
739
0
      return false;
740
0
    }
741
0
    if (!JS_DefineProperty(cx, result, "sdpMLineIndex", temp, JSPROP_ENUMERATE)) {
742
0
      return false;
743
0
    }
744
0
  }
745
0
  return true;
746
0
}
747
748
static bool
749
_constructor(JSContext* cx, unsigned argc, JS::Value* vp)
750
0
{
751
0
  AUTO_PROFILER_LABEL_FAST("RTCIceCandidate constructor", DOM, cx);
752
0
753
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
754
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
755
0
  if (!args.isConstructing()) {
756
0
    // XXXbz wish I could get the name from the callee instead of
757
0
    // Adding more relocations
758
0
    return ThrowConstructorWithoutNew(cx, "RTCIceCandidate");
759
0
  }
760
0
761
0
  JS::Rooted<JSObject*> desiredProto(cx);
762
0
  if (!GetDesiredProto(cx, args, &desiredProto)) {
763
0
    return false;
764
0
  }
765
0
766
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
767
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "RTCIceCandidate");
768
0
  }
769
0
  GlobalObject global(cx, obj);
770
0
  if (global.Failed()) {
771
0
    return false;
772
0
  }
773
0
774
0
  bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
775
0
  binding_detail::FastRTCIceCandidateInit arg0;
776
0
  if (!arg0.Init(cx, args[0],  "Argument 1 of RTCIceCandidate.constructor", true)) {
777
0
    return false;
778
0
  }
779
0
  Maybe<JSAutoRealm> ar;
780
0
  if (objIsXray) {
781
0
    obj = js::CheckedUnwrap(obj);
782
0
    if (!obj) {
783
0
      return false;
784
0
    }
785
0
    ar.emplace(cx, obj);
786
0
    if (!JS_WrapObject(cx, &desiredProto)) {
787
0
      return false;
788
0
    }
789
0
  }
790
0
  FastErrorResult rv;
791
0
  auto result(StrongOrRawPtr<mozilla::dom::RTCIceCandidate>(mozilla::dom::RTCIceCandidate::Constructor(global, cx, Constify(arg0), rv, desiredProto)));
792
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
793
0
    return false;
794
0
  }
795
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
796
0
  static_assert(!IsPointer<decltype(result)>::value,
797
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
798
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
799
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
800
0
    return false;
801
0
  }
802
0
  return true;
803
0
}
804
805
static const js::ClassOps sInterfaceObjectClassOps = {
806
    nullptr,               /* addProperty */
807
    nullptr,               /* delProperty */
808
    nullptr,               /* enumerate */
809
    nullptr,               /* newEnumerate */
810
    nullptr,               /* resolve */
811
    nullptr,               /* mayResolve */
812
    nullptr,               /* finalize */
813
    _constructor, /* call */
814
    nullptr,               /* hasInstance */
815
    _constructor, /* construct */
816
    nullptr,               /* trace */
817
};
818
819
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
820
  {
821
    "Function",
822
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
823
    &sInterfaceObjectClassOps,
824
    JS_NULL_CLASS_SPEC,
825
    JS_NULL_CLASS_EXT,
826
    &sInterfaceObjectClassObjectOps
827
  },
828
  eInterface,
829
  true,
830
  prototypes::id::RTCIceCandidate,
831
  PrototypeTraits<prototypes::id::RTCIceCandidate>::Depth,
832
  sNativePropertyHooks,
833
  "function RTCIceCandidate() {\n    [native code]\n}",
834
  JS::GetRealmFunctionPrototype
835
};
836
837
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
838
  {
839
    "RTCIceCandidatePrototype",
840
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
841
    JS_NULL_CLASS_OPS,
842
    JS_NULL_CLASS_SPEC,
843
    JS_NULL_CLASS_EXT,
844
    JS_NULL_OBJECT_OPS
845
  },
846
  eInterfacePrototype,
847
  false,
848
  prototypes::id::RTCIceCandidate,
849
  PrototypeTraits<prototypes::id::RTCIceCandidate>::Depth,
850
  sNativePropertyHooks,
851
  "[object RTCIceCandidatePrototype]",
852
  JS::GetRealmObjectPrototype
853
};
854
855
bool
856
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
857
0
{
858
0
  static bool sPrefValue;
859
0
  static bool sPrefCacheSetUp = false;
860
0
  if (!sPrefCacheSetUp) {
861
0
    sPrefCacheSetUp = true;
862
0
    Preferences::AddBoolVarCache(&sPrefValue, "media.peerconnection.enabled");
863
0
  }
864
0
865
0
  return sPrefValue;
866
0
}
867
868
static const js::ClassOps sClassOps = {
869
  _addProperty, /* addProperty */
870
  nullptr,               /* delProperty */
871
  nullptr,               /* enumerate */
872
  nullptr, /* newEnumerate */
873
  nullptr, /* resolve */
874
  nullptr, /* mayResolve */
875
  _finalize, /* finalize */
876
  nullptr, /* call */
877
  nullptr,               /* hasInstance */
878
  nullptr,               /* construct */
879
  nullptr, /* trace */
880
};
881
882
static const js::ClassExtension sClassExtension = {
883
  nullptr, /* weakmapKeyDelegateOp */
884
  _objectMoved /* objectMovedOp */
885
};
886
887
static const DOMJSClass sClass = {
888
  { "RTCIceCandidate",
889
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
890
    &sClassOps,
891
    JS_NULL_CLASS_SPEC,
892
    &sClassExtension,
893
    JS_NULL_OBJECT_OPS
894
  },
895
  { prototypes::id::RTCIceCandidate, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
896
  IsBaseOf<nsISupports, mozilla::dom::RTCIceCandidate >::value,
897
  sNativePropertyHooks,
898
  FindAssociatedGlobalForNative<mozilla::dom::RTCIceCandidate>::Get,
899
  GetProtoObjectHandle,
900
  GetCCParticipant<mozilla::dom::RTCIceCandidate>::Get()
901
};
902
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
903
              "Must have the right minimal number of reserved slots.");
904
static_assert(1 >= 1,
905
              "Must have enough reserved slots.");
906
907
const JSClass*
908
GetJSClass()
909
0
{
910
0
  return sClass.ToJSClass();
911
0
}
912
913
bool
914
Wrap(JSContext* aCx, mozilla::dom::RTCIceCandidate* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
915
0
{
916
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::RTCIceCandidate>::value,
917
0
                "Shouldn't have wrappercached things that are not refcounted.");
918
0
  MOZ_ASSERT(static_cast<mozilla::dom::RTCIceCandidate*>(aObject) ==
919
0
             reinterpret_cast<mozilla::dom::RTCIceCandidate*>(aObject),
920
0
             "Multiple inheritance for mozilla::dom::RTCIceCandidate is broken.");
921
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
922
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
923
0
  MOZ_ASSERT(!aCache->GetWrapper(),
924
0
             "You should probably not be using Wrap() directly; use "
925
0
             "GetOrCreateDOMReflector instead");
926
0
927
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
928
0
             "nsISupports must be on our primary inheritance chain");
929
0
930
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
931
0
  if (!global) {
932
0
    return false;
933
0
  }
934
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
935
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
936
0
937
0
  // That might have ended up wrapping us already, due to the wonders
938
0
  // of XBL.  Check for that, and bail out as needed.
939
0
  aReflector.set(aCache->GetWrapper());
940
0
  if (aReflector) {
941
#ifdef DEBUG
942
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
943
#endif // DEBUG
944
    return true;
945
0
  }
946
0
947
0
  JSAutoRealm ar(aCx, global);
948
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
949
0
  if (!canonicalProto) {
950
0
    return false;
951
0
  }
952
0
  JS::Rooted<JSObject*> proto(aCx);
953
0
  if (aGivenProto) {
954
0
    proto = aGivenProto;
955
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
956
0
    // coming in, we changed compartments to that of "parent" so may need
957
0
    // to wrap the proto here.
958
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
959
0
      if (!JS_WrapObject(aCx, &proto)) {
960
0
        return false;
961
0
      }
962
0
    }
963
0
  } else {
964
0
    proto = canonicalProto;
965
0
  }
966
0
967
0
  BindingJSObjectCreator<mozilla::dom::RTCIceCandidate> creator(aCx);
968
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
969
0
  if (!aReflector) {
970
0
    return false;
971
0
  }
972
0
973
0
  aCache->SetWrapper(aReflector);
974
0
  creator.InitializationSucceeded();
975
0
976
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
977
0
             aCache->GetWrapperPreserveColor() == aReflector);
978
0
  // If proto != canonicalProto, we have to preserve our wrapper;
979
0
  // otherwise we won't be able to properly recreate it later, since
980
0
  // we won't know what proto to use.  Note that we don't check
981
0
  // aGivenProto here, since it's entirely possible (and even
982
0
  // somewhat common) to have a non-null aGivenProto which is the
983
0
  // same as canonicalProto.
984
0
  if (proto != canonicalProto) {
985
0
    PreserveWrapper(aObject);
986
0
  }
987
0
988
0
  return true;
989
0
}
990
991
const NativePropertyHooks sNativePropertyHooks[] = { {
992
  nullptr,
993
  nullptr,
994
  nullptr,
995
  { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
996
  prototypes::id::RTCIceCandidate,
997
  constructors::id::RTCIceCandidate,
998
  nullptr,
999
  &DefaultXrayExpandoObjectClass
1000
} };
1001
1002
void
1003
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1004
0
{
1005
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
1006
0
  if (!parentProto) {
1007
0
    return;
1008
0
  }
1009
0
1010
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
1011
0
  if (!constructorProto) {
1012
0
    return;
1013
0
  }
1014
0
1015
0
  static bool sIdsInited = false;
1016
0
  if (!sIdsInited && NS_IsMainThread()) {
1017
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
1018
0
      return;
1019
0
    }
1020
0
    if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
1021
0
      return;
1022
0
    }
1023
0
    sIdsInited = true;
1024
0
  }
1025
0
1026
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::RTCIceCandidate);
1027
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::RTCIceCandidate);
1028
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1029
0
                              &sPrototypeClass.mBase, protoCache,
1030
0
                              nullptr,
1031
0
                              constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr,
1032
0
                              interfaceCache,
1033
0
                              sNativeProperties.Upcast(),
1034
0
                              sChromeOnlyNativeProperties.Upcast(),
1035
0
                              "RTCIceCandidate", aDefineOnGlobal,
1036
0
                              nullptr,
1037
0
                              false);
1038
0
}
1039
1040
JSObject*
1041
GetProtoObject(JSContext* aCx)
1042
0
{
1043
0
  return GetProtoObjectHandle(aCx);
1044
0
}
1045
1046
JSObject*
1047
GetConstructorObject(JSContext* aCx)
1048
0
{
1049
0
  return GetConstructorObjectHandle(aCx);
1050
0
}
1051
1052
} // namespace RTCIceCandidate_Binding
1053
1054
1055
1056
void
1057
RTCIceCandidateJSImpl::ToJSON(JS::MutableHandle<JSObject*> aRetVal, ErrorResult& aRv, JS::Realm* aRealm)
1058
0
{
1059
0
  CallSetup s(this, aRv, "RTCIceCandidate.toJSON", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true);
1060
0
  JSContext* cx = s.GetContext();
1061
0
  if (!cx) {
1062
0
    MOZ_ASSERT(aRv.Failed());
1063
0
    return;
1064
0
  }
1065
0
  JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
1066
0
1067
0
  JS::Rooted<JS::Value> callable(cx);
1068
0
  RTCIceCandidateAtoms* atomsCache = GetAtomCache<RTCIceCandidateAtoms>(cx);
1069
0
  if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) ||
1070
0
      !GetCallableProperty(cx, atomsCache->toJSON_id, &callable)) {
1071
0
    aRv.Throw(NS_ERROR_UNEXPECTED);
1072
0
    return;
1073
0
  }
1074
0
  JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback));
1075
0
  if (!JS::Call(cx, thisValue, callable,
1076
0
                JS::HandleValueArray::empty(), &rval)) {
1077
0
    aRv.NoteJSContextException(cx);
1078
0
    return;
1079
0
  }
1080
0
  JS::Rooted<JSObject*> rvalDecl(cx);
1081
0
  if (rval.isObject()) {
1082
0
#ifdef __clang__
1083
0
#pragma clang diagnostic push
1084
0
#pragma clang diagnostic ignored "-Wunreachable-code"
1085
0
#pragma clang diagnostic ignored "-Wunreachable-code-return"
1086
0
#endif // __clang__
1087
0
    if ((false) && !CallerSubsumes(rval)) {
1088
0
      ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "return value of RTCIceCandidate.toJSON");
1089
0
      aRv.Throw(NS_ERROR_UNEXPECTED);
1090
0
      return;
1091
0
    }
1092
0
#ifdef __clang__
1093
0
#pragma clang diagnostic pop
1094
0
#endif // __clang__
1095
0
    rvalDecl = &rval.toObject();
1096
0
  } else {
1097
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Return value of RTCIceCandidate.toJSON");
1098
0
    aRv.Throw(NS_ERROR_UNEXPECTED);
1099
0
    return;
1100
0
  }
1101
0
  aRetVal.set(rvalDecl);
1102
0
}
1103
1104
void
1105
RTCIceCandidateJSImpl::__Init(const RTCIceCandidateInit& candidateInitDict, ErrorResult& aRv, JS::Realm* aRealm)
1106
0
{
1107
0
  CallSetup s(this, aRv, "__init", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true);
1108
0
  JSContext* cx = s.GetContext();
1109
0
  if (!cx) {
1110
0
    MOZ_ASSERT(aRv.Failed());
1111
0
    return;
1112
0
  }
1113
0
  JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
1114
0
  JS::AutoValueVector argv(cx);
1115
0
  if (!argv.resize(1)) {
1116
0
    aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
1117
0
    return;
1118
0
  }
1119
0
  unsigned argc = 1;
1120
0
1121
0
  do {
1122
0
    if (!candidateInitDict.ToObjectInternal(cx, argv[0])) {
1123
0
      aRv.Throw(NS_ERROR_UNEXPECTED);
1124
0
      return;
1125
0
    }
1126
0
    break;
1127
0
  } while (false);
1128
0
1129
0
  JS::Rooted<JS::Value> callable(cx);
1130
0
  RTCIceCandidateAtoms* atomsCache = GetAtomCache<RTCIceCandidateAtoms>(cx);
1131
0
  if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) ||
1132
0
      !GetCallableProperty(cx, atomsCache->__init_id, &callable)) {
1133
0
    aRv.Throw(NS_ERROR_UNEXPECTED);
1134
0
    return;
1135
0
  }
1136
0
  JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback));
1137
0
  if (!JS::Call(cx, thisValue, callable,
1138
0
                JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
1139
0
    aRv.NoteJSContextException(cx);
1140
0
    return;
1141
0
  }
1142
0
}
1143
1144
bool
1145
RTCIceCandidateJSImpl::InitIds(JSContext* cx, RTCIceCandidateAtoms* atomsCache)
1146
0
{
1147
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
1148
0
1149
0
  // Initialize these in reverse order so that any failure leaves the first one
1150
0
  // uninitialized.
1151
0
  if (!atomsCache->__init_id.init(cx, "__init") ||
1152
0
      !atomsCache->toJSON_id.init(cx, "toJSON") ||
1153
0
      !atomsCache->sdpMLineIndex_id.init(cx, "sdpMLineIndex") ||
1154
0
      !atomsCache->sdpMid_id.init(cx, "sdpMid") ||
1155
0
      !atomsCache->candidate_id.init(cx, "candidate")) {
1156
0
    return false;
1157
0
  }
1158
0
  return true;
1159
0
}
1160
1161
1162
void
1163
RTCIceCandidateJSImpl::GetCandidate(nsString& aRetVal, ErrorResult& aRv, JS::Realm* aRealm)
1164
0
{
1165
0
  CallSetup s(this, aRv, "RTCIceCandidate.candidate", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true);
1166
0
  JSContext* cx = s.GetContext();
1167
0
  if (!cx) {
1168
0
    MOZ_ASSERT(aRv.Failed());
1169
0
    return;
1170
0
  }
1171
0
  JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
1172
0
1173
0
  JS::Rooted<JSObject *> callback(cx, mCallback);
1174
0
  RTCIceCandidateAtoms* atomsCache = GetAtomCache<RTCIceCandidateAtoms>(cx);
1175
0
  if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) ||
1176
0
      !JS_GetPropertyById(cx, callback, atomsCache->candidate_id, &rval)) {
1177
0
    aRv.Throw(NS_ERROR_UNEXPECTED);
1178
0
    return;
1179
0
  }
1180
0
  binding_detail::FakeString rvalDecl;
1181
0
  if (!ConvertJSValueToString(cx, rval, eStringify, eStringify, rvalDecl)) {
1182
0
    aRv.Throw(NS_ERROR_UNEXPECTED);
1183
0
    return;
1184
0
  }
1185
0
  aRetVal = rvalDecl;
1186
0
}
1187
1188
void
1189
RTCIceCandidateJSImpl::GetSdpMid(nsString& aRetVal, ErrorResult& aRv, JS::Realm* aRealm)
1190
0
{
1191
0
  CallSetup s(this, aRv, "RTCIceCandidate.sdpMid", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true);
1192
0
  JSContext* cx = s.GetContext();
1193
0
  if (!cx) {
1194
0
    MOZ_ASSERT(aRv.Failed());
1195
0
    return;
1196
0
  }
1197
0
  JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
1198
0
1199
0
  JS::Rooted<JSObject *> callback(cx, mCallback);
1200
0
  RTCIceCandidateAtoms* atomsCache = GetAtomCache<RTCIceCandidateAtoms>(cx);
1201
0
  if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) ||
1202
0
      !JS_GetPropertyById(cx, callback, atomsCache->sdpMid_id, &rval)) {
1203
0
    aRv.Throw(NS_ERROR_UNEXPECTED);
1204
0
    return;
1205
0
  }
1206
0
  binding_detail::FakeString rvalDecl;
1207
0
  if (!ConvertJSValueToString(cx, rval, eNull, eNull, rvalDecl)) {
1208
0
    aRv.Throw(NS_ERROR_UNEXPECTED);
1209
0
    return;
1210
0
  }
1211
0
  aRetVal = rvalDecl;
1212
0
}
1213
1214
Nullable<uint16_t>
1215
RTCIceCandidateJSImpl::GetSdpMLineIndex(ErrorResult& aRv, JS::Realm* aRealm)
1216
0
{
1217
0
  CallSetup s(this, aRv, "RTCIceCandidate.sdpMLineIndex", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true);
1218
0
  JSContext* cx = s.GetContext();
1219
0
  if (!cx) {
1220
0
    MOZ_ASSERT(aRv.Failed());
1221
0
    return Nullable<uint16_t>();
1222
0
  }
1223
0
  JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
1224
0
1225
0
  JS::Rooted<JSObject *> callback(cx, mCallback);
1226
0
  RTCIceCandidateAtoms* atomsCache = GetAtomCache<RTCIceCandidateAtoms>(cx);
1227
0
  if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) ||
1228
0
      !JS_GetPropertyById(cx, callback, atomsCache->sdpMLineIndex_id, &rval)) {
1229
0
    aRv.Throw(NS_ERROR_UNEXPECTED);
1230
0
    return Nullable<uint16_t>();
1231
0
  }
1232
0
  Nullable<uint16_t> rvalDecl;
1233
0
  if (rval.isNullOrUndefined()) {
1234
0
    rvalDecl.SetNull();
1235
0
  } else if (!ValueToPrimitive<uint16_t, eDefault>(cx, rval, &rvalDecl.SetValue())) {
1236
0
    aRv.Throw(NS_ERROR_UNEXPECTED);
1237
0
    return Nullable<uint16_t>();
1238
0
  }
1239
0
  return rvalDecl;
1240
0
}
1241
1242
void
1243
RTCIceCandidateJSImpl::SetCandidate(const nsAString& arg, ErrorResult& aRv, JS::Realm* aRealm)
1244
0
{
1245
0
  CallSetup s(this, aRv, "RTCIceCandidate.candidate", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true);
1246
0
  JSContext* cx = s.GetContext();
1247
0
  if (!cx) {
1248
0
    MOZ_ASSERT(aRv.Failed());
1249
0
    return;
1250
0
  }
1251
0
  JS::AutoValueVector argv(cx);
1252
0
  if (!argv.resize(1)) {
1253
0
    aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
1254
0
    return;
1255
0
  }
1256
0
  do {
1257
0
    nsString mutableStr(arg);
1258
0
    if (!xpc::NonVoidStringToJsval(cx, mutableStr, argv[0])) {
1259
0
      aRv.Throw(NS_ERROR_UNEXPECTED);
1260
0
      return;
1261
0
    }
1262
0
    break;
1263
0
  } while (false);
1264
0
1265
0
  MOZ_ASSERT(argv.length() == 1);
1266
0
  RTCIceCandidateAtoms* atomsCache = GetAtomCache<RTCIceCandidateAtoms>(cx);
1267
0
  if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) ||
1268
0
      !JS_SetPropertyById(cx, CallbackKnownNotGray(), atomsCache->candidate_id, argv[0])) {
1269
0
    aRv.Throw(NS_ERROR_UNEXPECTED);
1270
0
    return;
1271
0
  }
1272
0
}
1273
1274
void
1275
RTCIceCandidateJSImpl::SetSdpMid(const nsAString& arg, ErrorResult& aRv, JS::Realm* aRealm)
1276
0
{
1277
0
  CallSetup s(this, aRv, "RTCIceCandidate.sdpMid", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true);
1278
0
  JSContext* cx = s.GetContext();
1279
0
  if (!cx) {
1280
0
    MOZ_ASSERT(aRv.Failed());
1281
0
    return;
1282
0
  }
1283
0
  JS::AutoValueVector argv(cx);
1284
0
  if (!argv.resize(1)) {
1285
0
    aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
1286
0
    return;
1287
0
  }
1288
0
  do {
1289
0
    nsString mutableStr(arg);
1290
0
    if (!xpc::StringToJsval(cx, mutableStr, argv[0])) {
1291
0
      aRv.Throw(NS_ERROR_UNEXPECTED);
1292
0
      return;
1293
0
    }
1294
0
    break;
1295
0
  } while (false);
1296
0
1297
0
  MOZ_ASSERT(argv.length() == 1);
1298
0
  RTCIceCandidateAtoms* atomsCache = GetAtomCache<RTCIceCandidateAtoms>(cx);
1299
0
  if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) ||
1300
0
      !JS_SetPropertyById(cx, CallbackKnownNotGray(), atomsCache->sdpMid_id, argv[0])) {
1301
0
    aRv.Throw(NS_ERROR_UNEXPECTED);
1302
0
    return;
1303
0
  }
1304
0
}
1305
1306
void
1307
RTCIceCandidateJSImpl::SetSdpMLineIndex(const Nullable<uint16_t>& arg, ErrorResult& aRv, JS::Realm* aRealm)
1308
0
{
1309
0
  CallSetup s(this, aRv, "RTCIceCandidate.sdpMLineIndex", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true);
1310
0
  JSContext* cx = s.GetContext();
1311
0
  if (!cx) {
1312
0
    MOZ_ASSERT(aRv.Failed());
1313
0
    return;
1314
0
  }
1315
0
  JS::AutoValueVector argv(cx);
1316
0
  if (!argv.resize(1)) {
1317
0
    aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
1318
0
    return;
1319
0
  }
1320
0
  do {
1321
0
    if (arg.IsNull()) {
1322
0
      argv[0].setNull();
1323
0
      break;
1324
0
    }
1325
0
    argv[0].setInt32(int32_t(arg.Value()));
1326
0
    break;
1327
0
  } while (false);
1328
0
1329
0
  MOZ_ASSERT(argv.length() == 1);
1330
0
  RTCIceCandidateAtoms* atomsCache = GetAtomCache<RTCIceCandidateAtoms>(cx);
1331
0
  if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) ||
1332
0
      !JS_SetPropertyById(cx, CallbackKnownNotGray(), atomsCache->sdpMLineIndex_id, argv[0])) {
1333
0
    aRv.Throw(NS_ERROR_UNEXPECTED);
1334
0
    return;
1335
0
  }
1336
0
}
1337
1338
1339
NS_IMPL_CYCLE_COLLECTION_CLASS(RTCIceCandidate)
1340
0
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(RTCIceCandidate)
1341
0
  NS_IMPL_CYCLE_COLLECTION_UNLINK(mImpl)
1342
0
  NS_IMPL_CYCLE_COLLECTION_UNLINK(mParent)
1343
0
  NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
1344
0
  tmp->ClearWeakReferences();
1345
0
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
1346
0
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(RTCIceCandidate)
1347
0
  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mImpl)
1348
0
  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParent)
1349
0
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
1350
NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(RTCIceCandidate)
1351
NS_IMPL_CYCLE_COLLECTING_ADDREF(RTCIceCandidate)
1352
NS_IMPL_CYCLE_COLLECTING_RELEASE(RTCIceCandidate)
1353
0
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(RTCIceCandidate)
1354
0
  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
1355
0
  NS_INTERFACE_MAP_ENTRY(nsISupports)
1356
0
  NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
1357
0
NS_INTERFACE_MAP_END
1358
1359
RTCIceCandidate::RTCIceCandidate(JS::Handle<JSObject*> aJSImplObject, JS::Handle<JSObject*> aJSImplGlobal, nsIGlobalObject* aParent)
1360
  : mImpl(new RTCIceCandidateJSImpl(nullptr, aJSImplObject, aJSImplGlobal, /* aIncumbentGlobal = */ nullptr)),
1361
    mParent(aParent)
1362
0
{
1363
0
}
1364
1365
1366
RTCIceCandidate::~RTCIceCandidate()
1367
0
{
1368
0
}
1369
1370
nsISupports*
1371
RTCIceCandidate::GetParentObject() const
1372
0
{
1373
0
  return mParent;
1374
0
}
1375
1376
JSObject*
1377
RTCIceCandidate::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
1378
0
{
1379
0
  JS::Rooted<JSObject*> obj(aCx, RTCIceCandidate_Binding::Wrap(aCx, this, aGivenProto));
1380
0
  if (!obj) {
1381
0
    return nullptr;
1382
0
  }
1383
0
1384
0
  // Now define it on our chrome object
1385
0
  JSAutoRealm ar(aCx, mImpl->CallbackGlobalOrNull());
1386
0
  if (!JS_WrapObject(aCx, &obj)) {
1387
0
    return nullptr;
1388
0
  }
1389
0
  if (!JS_DefineProperty(aCx, mImpl->CallbackOrNull(), "__DOM_IMPL__", obj, 0)) {
1390
0
    return nullptr;
1391
0
  }
1392
0
  return obj;
1393
0
}
1394
1395
already_AddRefed<RTCIceCandidate>
1396
RTCIceCandidate::Constructor(const GlobalObject& global, JSContext* cx, const RTCIceCandidateInit& candidateInitDict, ErrorResult& aRv, JS::Handle<JSObject*> aGivenProto)
1397
0
{
1398
0
  JS::Rooted<JSObject*> jsImplObj(cx);
1399
0
  nsCOMPtr<nsIGlobalObject> globalHolder =
1400
0
    ConstructJSImplementation("@mozilla.org/dom/rtcicecandidate;1", global, &jsImplObj, aRv);
1401
0
  if (aRv.Failed()) {
1402
0
    return nullptr;
1403
0
  }
1404
0
  // We should be getting the implementation object for the relevant
1405
0
  // contract here, which should never be a cross-compartment wrapper.
1406
0
  JS::Rooted<JSObject*> jsImplGlobal(cx, JS::GetNonCCWObjectGlobal(jsImplObj));
1407
0
  // Build the C++ implementation.
1408
0
  RefPtr<RTCIceCandidate> impl = new RTCIceCandidate(jsImplObj, jsImplGlobal, globalHolder);
1409
0
  // Wrap the object before calling __Init so that __DOM_IMPL__ is available.
1410
0
  JS::Rooted<JSObject*> scopeObj(cx, globalHolder->GetGlobalJSObject());
1411
0
  MOZ_ASSERT(js::IsObjectInContextCompartment(scopeObj, cx));
1412
0
  JS::Rooted<JS::Value> wrappedVal(cx);
1413
0
  if (!GetOrCreateDOMReflector(cx, impl, &wrappedVal, aGivenProto)) {
1414
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1415
0
    aRv.Throw(NS_ERROR_UNEXPECTED);
1416
0
    return nullptr;
1417
0
  }
1418
0
  // Initialize the object with the constructor arguments.
1419
0
  impl->mImpl->__Init(candidateInitDict, aRv, js::GetNonCCWObjectRealm(scopeObj));
1420
0
  if (aRv.Failed()) {
1421
0
    return nullptr;
1422
0
  }
1423
0
  return impl.forget();
1424
0
}
1425
1426
void
1427
RTCIceCandidate::GetCandidate(nsString& aRetVal, ErrorResult& aRv, JS::Realm* aRealm) const
1428
0
{
1429
0
  return mImpl->GetCandidate(aRetVal, aRv, aRealm);
1430
0
}
1431
1432
void
1433
RTCIceCandidate::SetCandidate(const nsAString& arg, ErrorResult& aRv, JS::Realm* aRealm)
1434
0
{
1435
0
  mImpl->SetCandidate(arg, aRv, aRealm);
1436
0
}
1437
1438
void
1439
RTCIceCandidate::GetSdpMid(nsString& aRetVal, ErrorResult& aRv, JS::Realm* aRealm) const
1440
0
{
1441
0
  return mImpl->GetSdpMid(aRetVal, aRv, aRealm);
1442
0
}
1443
1444
void
1445
RTCIceCandidate::SetSdpMid(const nsAString& arg, ErrorResult& aRv, JS::Realm* aRealm)
1446
0
{
1447
0
  mImpl->SetSdpMid(arg, aRv, aRealm);
1448
0
}
1449
1450
Nullable<uint16_t>
1451
RTCIceCandidate::GetSdpMLineIndex(ErrorResult& aRv, JS::Realm* aRealm) const
1452
0
{
1453
0
  return mImpl->GetSdpMLineIndex(aRv, aRealm);
1454
0
}
1455
1456
void
1457
RTCIceCandidate::SetSdpMLineIndex(const Nullable<uint16_t>& arg, ErrorResult& aRv, JS::Realm* aRealm)
1458
0
{
1459
0
  mImpl->SetSdpMLineIndex(arg, aRv, aRealm);
1460
0
}
1461
1462
void
1463
RTCIceCandidate::ToJSON(JS::MutableHandle<JSObject*> aRetVal, ErrorResult& aRv, JS::Realm* aRealm)
1464
0
{
1465
0
  return mImpl->ToJSON(aRetVal, aRv, aRealm);
1466
0
}
1467
1468
bool
1469
RTCIceCandidate::_Create(JSContext* cx, unsigned argc, JS::Value* vp)
1470
0
{
1471
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
1472
0
  if (args.length() < 2) {
1473
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "RTCIceCandidate._create");
1474
0
  }
1475
0
  if (!args[0].isObject()) {
1476
0
    return ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of RTCIceCandidate._create");
1477
0
  }
1478
0
  if (!args[1].isObject()) {
1479
0
    return ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of RTCIceCandidate._create");
1480
0
  }
1481
0
1482
0
  // GlobalObject will go through wrappers as needed for us, and
1483
0
  // is simpler than the right UnwrapArg incantation.
1484
0
  GlobalObject global(cx, &args[0].toObject());
1485
0
  if (global.Failed()) {
1486
0
    return false;
1487
0
  }
1488
0
  nsCOMPtr<nsIGlobalObject> globalHolder = do_QueryInterface(global.GetAsSupports());
1489
0
  MOZ_ASSERT(globalHolder);
1490
0
  JS::Rooted<JSObject*> arg(cx, &args[1].toObject());
1491
0
  JS::Rooted<JSObject*> argGlobal(cx, JS::CurrentGlobalOrNull(cx));
1492
0
  RefPtr<RTCIceCandidate> impl = new RTCIceCandidate(arg, argGlobal, globalHolder);
1493
0
  MOZ_ASSERT(js::IsObjectInContextCompartment(arg, cx));
1494
0
  return GetOrCreateDOMReflector(cx, impl, args.rval());
1495
0
}
1496
1497
1498
} // namespace dom
1499
} // namespace mozilla