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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM RTCIdentityAssertion.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "AtomList.h"
       4             : #include "RTCIdentityAssertionBinding.h"
       5             : #include "mozilla/OwningNonNull.h"
       6             : #include "mozilla/dom/BindingUtils.h"
       7             : #include "mozilla/dom/NonRefcountedDOMObject.h"
       8             : #include "mozilla/dom/ScriptSettings.h"
       9             : #include "mozilla/dom/SimpleGlobalObject.h"
      10             : 
      11             : namespace mozilla {
      12             : namespace dom {
      13             : 
      14             : 
      15           0 : RTCIdentityAssertion::RTCIdentityAssertion()
      16             : {
      17             :   // Safe to pass a null context if we pass a null value
      18           0 :   Init(nullptr, JS::NullHandleValue);
      19           0 : }
      20             : 
      21             : 
      22             : 
      23             : bool
      24           0 : RTCIdentityAssertion::InitIds(JSContext* cx, RTCIdentityAssertionAtoms* atomsCache)
      25             : {
      26           0 :   MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
      27             : 
      28             :   // Initialize these in reverse order so that any failure leaves the first one
      29             :   // uninitialized.
      30           0 :   if (!atomsCache->name_id.init(cx, "name") ||
      31           0 :       !atomsCache->idp_id.init(cx, "idp")) {
      32           0 :     return false;
      33             :   }
      34           0 :   return true;
      35             : }
      36             : 
      37             : bool
      38           0 : RTCIdentityAssertion::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
      39             : {
      40             :   // Passing a null JSContext is OK only if we're initing from null,
      41             :   // Since in that case we will not have to do any property gets
      42             :   // Also evaluate isNullOrUndefined in order to avoid false-positive
      43             :   // checkers by static analysis tools
      44           0 :   MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
      45           0 :   RTCIdentityAssertionAtoms* atomsCache = nullptr;
      46           0 :   if (cx) {
      47           0 :     atomsCache = GetAtomCache<RTCIdentityAssertionAtoms>(cx);
      48           0 :     if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
      49           0 :       return false;
      50             :     }
      51             :   }
      52             : 
      53           0 :   if (!IsConvertibleToDictionary(val)) {
      54           0 :     return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
      55             :   }
      56             : 
      57           0 :   bool isNull = val.isNullOrUndefined();
      58             :   // We only need these if !isNull, in which case we have |cx|.
      59           0 :   Maybe<JS::Rooted<JSObject *> > object;
      60           0 :   Maybe<JS::Rooted<JS::Value> > temp;
      61           0 :   if (!isNull) {
      62           0 :     MOZ_ASSERT(cx);
      63           0 :     object.emplace(cx, &val.toObject());
      64           0 :     temp.emplace(cx);
      65             :   }
      66           0 :   if (!isNull) {
      67           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->idp_id, temp.ptr())) {
      68           0 :       return false;
      69             :     }
      70             :   }
      71           0 :   if (!isNull && !temp->isUndefined()) {
      72           0 :     mIdp.Construct();
      73           0 :     if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mIdp.Value()))) {
      74           0 :       return false;
      75             :     }
      76           0 :     mIsAnyMemberPresent = true;
      77             :   }
      78             : 
      79           0 :   if (!isNull) {
      80           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->name_id, temp.ptr())) {
      81           0 :       return false;
      82             :     }
      83             :   }
      84           0 :   if (!isNull && !temp->isUndefined()) {
      85           0 :     mName.Construct();
      86           0 :     if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mName.Value()))) {
      87           0 :       return false;
      88             :     }
      89           0 :     mIsAnyMemberPresent = true;
      90             :   }
      91           0 :   return true;
      92             : }
      93             : 
      94             : bool
      95           0 : RTCIdentityAssertion::Init(const nsAString& aJSON)
      96             : {
      97           0 :   AutoJSAPI jsapi;
      98           0 :   JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
      99           0 :   if (!cleanGlobal) {
     100           0 :     return false;
     101             :   }
     102           0 :   if (!jsapi.Init(cleanGlobal)) {
     103           0 :     return false;
     104             :   }
     105           0 :   JSContext* cx = jsapi.cx();
     106           0 :   JS::Rooted<JS::Value> json(cx);
     107           0 :   bool ok = ParseJSON(cx, aJSON, &json);
     108           0 :   NS_ENSURE_TRUE(ok, false);
     109           0 :   return Init(cx, json);
     110             : }
     111             : 
     112             : bool
     113           0 : RTCIdentityAssertion::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
     114             : {
     115           0 :   RTCIdentityAssertionAtoms* atomsCache = GetAtomCache<RTCIdentityAssertionAtoms>(cx);
     116           0 :   if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     117           0 :     return false;
     118             :   }
     119             : 
     120           0 :   JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
     121           0 :   if (!obj) {
     122           0 :     return false;
     123             :   }
     124           0 :   rval.set(JS::ObjectValue(*obj));
     125             : 
     126           0 :   if (mIdp.WasPassed()) {
     127             :     do {
     128             :       // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     129           0 :       JS::Rooted<JS::Value> temp(cx);
     130           0 :       nsString const & currentValue = mIdp.InternalValue();
     131           0 :       if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
     132           0 :         return false;
     133             :       }
     134           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->idp_id, temp, JSPROP_ENUMERATE)) {
     135           0 :         return false;
     136             :       }
     137           0 :       break;
     138             :     } while(0);
     139             :   }
     140             : 
     141           0 :   if (mName.WasPassed()) {
     142             :     do {
     143             :       // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     144           0 :       JS::Rooted<JS::Value> temp(cx);
     145           0 :       nsString const & currentValue = mName.InternalValue();
     146           0 :       if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
     147           0 :         return false;
     148             :       }
     149           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->name_id, temp, JSPROP_ENUMERATE)) {
     150           0 :         return false;
     151             :       }
     152           0 :       break;
     153             :     } while(0);
     154             :   }
     155             : 
     156           0 :   return true;
     157             : }
     158             : 
     159             : bool
     160           0 : RTCIdentityAssertion::ToJSON(nsAString& aJSON) const
     161             : {
     162           0 :   AutoJSAPI jsapi;
     163           0 :   jsapi.Init();
     164           0 :   JSContext *cx = jsapi.cx();
     165             :   // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
     166             :   // because we'll only be creating objects, in ways that have no
     167             :   // side-effects, followed by a call to JS::ToJSONMaybeSafely,
     168             :   // which likewise guarantees no side-effects for the sorts of
     169             :   // things we will pass it.
     170           0 :   JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
     171           0 :   JS::Rooted<JS::Value> val(cx);
     172           0 :   if (!ToObjectInternal(cx, &val)) {
     173           0 :     return false;
     174             :   }
     175           0 :   JS::Rooted<JSObject*> obj(cx, &val.toObject());
     176           0 :   return StringifyToJSON(cx, obj, aJSON);
     177             : }
     178             : 
     179             : void
     180           0 : RTCIdentityAssertion::TraceDictionary(JSTracer* trc)
     181             : {
     182           0 : }
     183             : 
     184             : RTCIdentityAssertion&
     185           0 : RTCIdentityAssertion::operator=(const RTCIdentityAssertion& aOther)
     186             : {
     187           0 :   mIdp.Reset();
     188           0 :   if (aOther.mIdp.WasPassed()) {
     189           0 :     mIdp.Construct(aOther.mIdp.Value());
     190             :   }
     191           0 :   mName.Reset();
     192           0 :   if (aOther.mName.WasPassed()) {
     193           0 :     mName.Construct(aOther.mName.Value());
     194             :   }
     195           0 :   return *this;
     196             : }
     197             : 
     198             : namespace binding_detail {
     199             : } // namespace binding_detail
     200             : 
     201             : 
     202             : } // namespace dom
     203             : } // namespace mozilla

Generated by: LCOV version 1.13