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

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

Generated by: LCOV version 1.13