LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - RTCIceCandidateBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 631 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 57 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.13