LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - IDBFactoryBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 60 396 15.2 %
Date: 2017-07-14 16:53:18 Functions: 5 23 21.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM IDBFactory.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "AtomList.h"
       4             : #include "IDBFactoryBinding.h"
       5             : #include "IDBRequest.h"
       6             : #include "WrapperFactory.h"
       7             : #include "mozilla/OwningNonNull.h"
       8             : #include "mozilla/dom/BindingUtils.h"
       9             : #include "mozilla/dom/DOMJSClass.h"
      10             : #include "mozilla/dom/IDBFactory.h"
      11             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      12             : #include "mozilla/dom/PrimitiveConversions.h"
      13             : #include "mozilla/dom/ScriptSettings.h"
      14             : #include "mozilla/dom/SimpleGlobalObject.h"
      15             : #include "mozilla/dom/XrayExpandoClass.h"
      16             : #include "nsContentUtils.h"
      17             : #include "nsIPrincipal.h"
      18             : 
      19             : namespace mozilla {
      20             : namespace dom {
      21             : 
      22             : 
      23           0 : IDBOpenDBOptions::IDBOpenDBOptions()
      24             : {
      25             :   // Safe to pass a null context if we pass a null value
      26           0 :   Init(nullptr, JS::NullHandleValue);
      27           0 : }
      28             : 
      29             : 
      30             : 
      31             : bool
      32           0 : IDBOpenDBOptions::InitIds(JSContext* cx, IDBOpenDBOptionsAtoms* atomsCache)
      33             : {
      34           0 :   MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
      35             : 
      36             :   // Initialize these in reverse order so that any failure leaves the first one
      37             :   // uninitialized.
      38           0 :   if (!atomsCache->version_id.init(cx, "version") ||
      39           0 :       !atomsCache->storage_id.init(cx, "storage")) {
      40           0 :     return false;
      41             :   }
      42           0 :   return true;
      43             : }
      44             : 
      45             : bool
      46           0 : IDBOpenDBOptions::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
      47             : {
      48             :   // Passing a null JSContext is OK only if we're initing from null,
      49             :   // Since in that case we will not have to do any property gets
      50             :   // Also evaluate isNullOrUndefined in order to avoid false-positive
      51             :   // checkers by static analysis tools
      52           0 :   MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
      53           0 :   IDBOpenDBOptionsAtoms* atomsCache = nullptr;
      54           0 :   if (cx) {
      55           0 :     atomsCache = GetAtomCache<IDBOpenDBOptionsAtoms>(cx);
      56           0 :     if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
      57           0 :       return false;
      58             :     }
      59             :   }
      60             : 
      61           0 :   if (!IsConvertibleToDictionary(val)) {
      62           0 :     return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
      63             :   }
      64             : 
      65           0 :   bool isNull = val.isNullOrUndefined();
      66             :   // We only need these if !isNull, in which case we have |cx|.
      67           0 :   Maybe<JS::Rooted<JSObject *> > object;
      68           0 :   Maybe<JS::Rooted<JS::Value> > temp;
      69           0 :   if (!isNull) {
      70           0 :     MOZ_ASSERT(cx);
      71           0 :     object.emplace(cx, &val.toObject());
      72           0 :     temp.emplace(cx);
      73             :   }
      74           0 :   if (!isNull) {
      75           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->storage_id, temp.ptr())) {
      76           0 :       return false;
      77             :     }
      78             :   }
      79           0 :   if (!isNull && !temp->isUndefined()) {
      80           0 :     mStorage.Construct();
      81             :     {
      82             :       int index;
      83           0 :       if (!FindEnumStringIndex<true>(cx, temp.ref(), StorageTypeValues::strings, "StorageType", "'storage' member of IDBOpenDBOptions", &index)) {
      84           0 :         return false;
      85             :       }
      86           0 :       MOZ_ASSERT(index >= 0);
      87           0 :       (mStorage.Value()) = static_cast<StorageType>(index);
      88             :     }
      89           0 :     mIsAnyMemberPresent = true;
      90             :   }
      91             : 
      92           0 :   if (!isNull) {
      93           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->version_id, temp.ptr())) {
      94           0 :       return false;
      95             :     }
      96             :   }
      97           0 :   if (!isNull && !temp->isUndefined()) {
      98           0 :     mVersion.Construct();
      99           0 :     if (!ValueToPrimitive<uint64_t, eEnforceRange>(cx, temp.ref(), &(mVersion.Value()))) {
     100           0 :       return false;
     101             :     }
     102           0 :     mIsAnyMemberPresent = true;
     103             :   }
     104           0 :   return true;
     105             : }
     106             : 
     107             : bool
     108           0 : IDBOpenDBOptions::Init(const nsAString& aJSON)
     109             : {
     110           0 :   AutoJSAPI jsapi;
     111           0 :   JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
     112           0 :   if (!cleanGlobal) {
     113           0 :     return false;
     114             :   }
     115           0 :   if (!jsapi.Init(cleanGlobal)) {
     116           0 :     return false;
     117             :   }
     118           0 :   JSContext* cx = jsapi.cx();
     119           0 :   JS::Rooted<JS::Value> json(cx);
     120           0 :   bool ok = ParseJSON(cx, aJSON, &json);
     121           0 :   NS_ENSURE_TRUE(ok, false);
     122           0 :   return Init(cx, json);
     123             : }
     124             : 
     125             : bool
     126           0 : IDBOpenDBOptions::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
     127             : {
     128           0 :   IDBOpenDBOptionsAtoms* atomsCache = GetAtomCache<IDBOpenDBOptionsAtoms>(cx);
     129           0 :   if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     130           0 :     return false;
     131             :   }
     132             : 
     133           0 :   JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
     134           0 :   if (!obj) {
     135           0 :     return false;
     136             :   }
     137           0 :   rval.set(JS::ObjectValue(*obj));
     138             : 
     139           0 :   if (mStorage.WasPassed()) {
     140             :     do {
     141             :       // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     142           0 :       JS::Rooted<JS::Value> temp(cx);
     143           0 :       StorageType const & currentValue = mStorage.InternalValue();
     144           0 :       if (!ToJSValue(cx, currentValue, &temp)) {
     145           0 :         return false;
     146             :       }
     147           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->storage_id, temp, JSPROP_ENUMERATE)) {
     148           0 :         return false;
     149             :       }
     150           0 :       break;
     151             :     } while(0);
     152             :   }
     153             : 
     154           0 :   if (mVersion.WasPassed()) {
     155             :     do {
     156             :       // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     157           0 :       JS::Rooted<JS::Value> temp(cx);
     158           0 :       uint64_t const & currentValue = mVersion.InternalValue();
     159           0 :       temp.set(JS_NumberValue(double(currentValue)));
     160           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->version_id, temp, JSPROP_ENUMERATE)) {
     161           0 :         return false;
     162             :       }
     163           0 :       break;
     164             :     } while(0);
     165             :   }
     166             : 
     167           0 :   return true;
     168             : }
     169             : 
     170             : bool
     171           0 : IDBOpenDBOptions::ToJSON(nsAString& aJSON) const
     172             : {
     173           0 :   AutoJSAPI jsapi;
     174           0 :   jsapi.Init();
     175           0 :   JSContext *cx = jsapi.cx();
     176             :   // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
     177             :   // because we'll only be creating objects, in ways that have no
     178             :   // side-effects, followed by a call to JS::ToJSONMaybeSafely,
     179             :   // which likewise guarantees no side-effects for the sorts of
     180             :   // things we will pass it.
     181           0 :   JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
     182           0 :   JS::Rooted<JS::Value> val(cx);
     183           0 :   if (!ToObjectInternal(cx, &val)) {
     184           0 :     return false;
     185             :   }
     186           0 :   JS::Rooted<JSObject*> obj(cx, &val.toObject());
     187           0 :   return StringifyToJSON(cx, obj, aJSON);
     188             : }
     189             : 
     190             : void
     191           0 : IDBOpenDBOptions::TraceDictionary(JSTracer* trc)
     192             : {
     193           0 : }
     194             : 
     195             : IDBOpenDBOptions&
     196           0 : IDBOpenDBOptions::operator=(const IDBOpenDBOptions& aOther)
     197             : {
     198           0 :   mStorage.Reset();
     199           0 :   if (aOther.mStorage.WasPassed()) {
     200           0 :     mStorage.Construct(aOther.mStorage.Value());
     201             :   }
     202           0 :   mVersion.Reset();
     203           0 :   if (aOther.mVersion.WasPassed()) {
     204           0 :     mVersion.Construct(aOther.mVersion.Value());
     205             :   }
     206           0 :   return *this;
     207             : }
     208             : 
     209             : namespace binding_detail {
     210             : } // namespace binding_detail
     211             : 
     212             : 
     213             : namespace IDBFactoryBinding {
     214             : 
     215             : static bool
     216           0 : open(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBFactory* self, const JSJitMethodCallArgs& args)
     217             : {
     218           0 :   unsigned argcount = std::min(args.length(), 2u);
     219           0 :   switch (argcount) {
     220             :     case 1: {
     221           0 :       binding_detail::FakeString arg0;
     222           0 :       if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     223           0 :         return false;
     224             :       }
     225           0 :       binding_detail::FastIDBOpenDBOptions arg1;
     226           0 :       if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue,  "Argument 2 of IDBFactory.open", false)) {
     227           0 :         return false;
     228             :       }
     229           0 :       binding_detail::FastErrorResult rv;
     230           0 :       auto result(StrongOrRawPtr<mozilla::dom::IDBOpenDBRequest>(self->Open(cx, NonNullHelper(Constify(arg0)), Constify(arg1), nsContentUtils::ThreadsafeIsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv)));
     231           0 :       if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     232           0 :         return false;
     233             :       }
     234           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
     235           0 :       if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     236           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     237           0 :         return false;
     238             :       }
     239           0 :       return true;
     240             :       break;
     241             :     }
     242             :     case 2: {
     243           0 :       binding_detail::FakeString arg0;
     244           0 :       if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     245           0 :         return false;
     246             :       }
     247           0 :       if (args[1].isNullOrUndefined()) {
     248           0 :         binding_detail::FastIDBOpenDBOptions arg1;
     249           0 :         if (!arg1.Init(cx, args[1],  "Argument 2 of IDBFactory.open", false)) {
     250           0 :           return false;
     251             :         }
     252           0 :         binding_detail::FastErrorResult rv;
     253           0 :         auto result(StrongOrRawPtr<mozilla::dom::IDBOpenDBRequest>(self->Open(cx, NonNullHelper(Constify(arg0)), Constify(arg1), nsContentUtils::ThreadsafeIsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv)));
     254           0 :         if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     255           0 :           return false;
     256             :         }
     257           0 :         MOZ_ASSERT(!JS_IsExceptionPending(cx));
     258           0 :         if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     259           0 :           MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     260           0 :           return false;
     261             :         }
     262           0 :         return true;
     263             :       }
     264           0 :       if (args[1].isObject()) {
     265             :         do {
     266           0 :           binding_detail::FastIDBOpenDBOptions arg1;
     267           0 :           if (!arg1.Init(cx, args[1],  "Argument 2 of IDBFactory.open", false)) {
     268           0 :             return false;
     269             :           }
     270           0 :           binding_detail::FastErrorResult rv;
     271           0 :           auto result(StrongOrRawPtr<mozilla::dom::IDBOpenDBRequest>(self->Open(cx, NonNullHelper(Constify(arg0)), Constify(arg1), nsContentUtils::ThreadsafeIsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv)));
     272           0 :           if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     273           0 :             return false;
     274             :           }
     275           0 :           MOZ_ASSERT(!JS_IsExceptionPending(cx));
     276           0 :           if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     277           0 :             MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     278           0 :             return false;
     279             :           }
     280           0 :           return true;
     281             :         } while (0);
     282             :       }
     283             :       uint64_t arg1;
     284           0 :       if (!ValueToPrimitive<uint64_t, eEnforceRange>(cx, args[1], &arg1)) {
     285           0 :         return false;
     286             :       }
     287           0 :       binding_detail::FastErrorResult rv;
     288           0 :       auto result(StrongOrRawPtr<mozilla::dom::IDBOpenDBRequest>(self->Open(cx, NonNullHelper(Constify(arg0)), arg1, nsContentUtils::ThreadsafeIsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv)));
     289           0 :       if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     290           0 :         return false;
     291             :       }
     292           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
     293           0 :       if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     294           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     295           0 :         return false;
     296             :       }
     297           0 :       return true;
     298             :       break;
     299             :     }
     300             :     default: {
     301           0 :       return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "IDBFactory.open");
     302             :       break;
     303             :     }
     304             :   }
     305             :   MOZ_CRASH("We have an always-returning default case");
     306             :   return false;
     307             : }
     308             : 
     309             : static const JSJitInfo open_methodinfo = {
     310             :   { (JSJitGetterOp)open },
     311             :   { prototypes::id::IDBFactory },
     312             :   { PrototypeTraits<prototypes::id::IDBFactory>::Depth },
     313             :   JSJitInfo::Method,
     314             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     315             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     316             :   false,  /* isInfallible. False in setters. */
     317             :   false,  /* isMovable.  Not relevant for setters. */
     318             :   false, /* isEliminatable.  Not relevant for setters. */
     319             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     320             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     321             :   false,  /* isTypedMethod.  Only relevant for methods. */
     322             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     323             : };
     324             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     325             : static_assert(0 < 1, "There is no slot for us");
     326             : 
     327             : static bool
     328           0 : deleteDatabase(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBFactory* self, const JSJitMethodCallArgs& args)
     329             : {
     330           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     331           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "IDBFactory.deleteDatabase");
     332             :   }
     333           0 :   binding_detail::FakeString arg0;
     334           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     335           0 :     return false;
     336             :   }
     337           0 :   binding_detail::FastIDBOpenDBOptions arg1;
     338           0 :   if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue,  "Argument 2 of IDBFactory.deleteDatabase", false)) {
     339           0 :     return false;
     340             :   }
     341           0 :   binding_detail::FastErrorResult rv;
     342           0 :   auto result(StrongOrRawPtr<mozilla::dom::IDBOpenDBRequest>(self->DeleteDatabase(cx, NonNullHelper(Constify(arg0)), Constify(arg1), nsContentUtils::ThreadsafeIsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv)));
     343           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     344           0 :     return false;
     345             :   }
     346           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     347           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     348           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     349           0 :     return false;
     350             :   }
     351           0 :   return true;
     352             : }
     353             : 
     354             : static const JSJitInfo deleteDatabase_methodinfo = {
     355             :   { (JSJitGetterOp)deleteDatabase },
     356             :   { prototypes::id::IDBFactory },
     357             :   { PrototypeTraits<prototypes::id::IDBFactory>::Depth },
     358             :   JSJitInfo::Method,
     359             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     360             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     361             :   false,  /* isInfallible. False in setters. */
     362             :   false,  /* isMovable.  Not relevant for setters. */
     363             :   false, /* isEliminatable.  Not relevant for setters. */
     364             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     365             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     366             :   false,  /* isTypedMethod.  Only relevant for methods. */
     367             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     368             : };
     369             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     370             : static_assert(0 < 1, "There is no slot for us");
     371             : 
     372             : static bool
     373           0 : cmp(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBFactory* self, const JSJitMethodCallArgs& args)
     374             : {
     375           0 :   if (MOZ_UNLIKELY(args.length() < 2)) {
     376           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "IDBFactory.cmp");
     377             :   }
     378           0 :   JS::Rooted<JS::Value> arg0(cx);
     379           0 :   arg0 = args[0];
     380           0 :   JS::Rooted<JS::Value> arg1(cx);
     381           0 :   arg1 = args[1];
     382           0 :   binding_detail::FastErrorResult rv;
     383           0 :   int16_t result(self->Cmp(cx, arg0, arg1, rv));
     384           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     385           0 :     return false;
     386             :   }
     387           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     388           0 :   args.rval().setInt32(int32_t(result));
     389           0 :   return true;
     390             : }
     391             : 
     392             : static const JSJitInfo cmp_methodinfo = {
     393             :   { (JSJitGetterOp)cmp },
     394             :   { prototypes::id::IDBFactory },
     395             :   { PrototypeTraits<prototypes::id::IDBFactory>::Depth },
     396             :   JSJitInfo::Method,
     397             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     398             :   JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
     399             :   false,  /* isInfallible. False in setters. */
     400             :   false,  /* isMovable.  Not relevant for setters. */
     401             :   false, /* isEliminatable.  Not relevant for setters. */
     402             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     403             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     404             :   false,  /* isTypedMethod.  Only relevant for methods. */
     405             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     406             : };
     407             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     408             : static_assert(0 < 1, "There is no slot for us");
     409             : 
     410             : static bool
     411           0 : openForPrincipal(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBFactory* self, const JSJitMethodCallArgs& args)
     412             : {
     413           0 :   unsigned argcount = std::min(args.length(), 3u);
     414           0 :   switch (argcount) {
     415             :     case 2: {
     416             :       nsIPrincipal* arg0;
     417           0 :       RefPtr<nsIPrincipal> arg0_holder;
     418           0 :       if (args[0].isObject()) {
     419           0 :         JS::Rooted<JSObject*> source(cx, &args[0].toObject());
     420           0 :         if (NS_FAILED(UnwrapArg<nsIPrincipal>(cx, source, getter_AddRefs(arg0_holder)))) {
     421           0 :           ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of IDBFactory.openForPrincipal", "Principal");
     422           0 :           return false;
     423             :         }
     424           0 :         MOZ_ASSERT(arg0_holder);
     425           0 :         arg0 = arg0_holder;
     426             :       } else {
     427           0 :         ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of IDBFactory.openForPrincipal");
     428           0 :         return false;
     429             :       }
     430           0 :       binding_detail::FakeString arg1;
     431           0 :       if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
     432           0 :         return false;
     433             :       }
     434           0 :       binding_detail::FastIDBOpenDBOptions arg2;
     435           0 :       if (!arg2.Init(cx, (args.hasDefined(2)) ? args[2] : JS::NullHandleValue,  "Argument 3 of IDBFactory.openForPrincipal", false)) {
     436           0 :         return false;
     437             :       }
     438           0 :       binding_detail::FastErrorResult rv;
     439           0 :       auto result(StrongOrRawPtr<mozilla::dom::IDBOpenDBRequest>(self->OpenForPrincipal(cx, NonNullHelper(arg0), NonNullHelper(Constify(arg1)), Constify(arg2), SystemCallerGuarantee(), rv)));
     440           0 :       if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     441           0 :         return false;
     442             :       }
     443           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
     444           0 :       if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     445           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     446           0 :         return false;
     447             :       }
     448           0 :       return true;
     449             :       break;
     450             :     }
     451             :     case 3: {
     452             :       nsIPrincipal* arg0;
     453           0 :       RefPtr<nsIPrincipal> arg0_holder;
     454           0 :       if (args[0].isObject()) {
     455           0 :         JS::Rooted<JSObject*> source(cx, &args[0].toObject());
     456           0 :         if (NS_FAILED(UnwrapArg<nsIPrincipal>(cx, source, getter_AddRefs(arg0_holder)))) {
     457           0 :           ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of IDBFactory.openForPrincipal", "Principal");
     458           0 :           return false;
     459             :         }
     460           0 :         MOZ_ASSERT(arg0_holder);
     461           0 :         arg0 = arg0_holder;
     462             :       } else {
     463           0 :         ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of IDBFactory.openForPrincipal");
     464           0 :         return false;
     465             :       }
     466           0 :       binding_detail::FakeString arg1;
     467           0 :       if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
     468           0 :         return false;
     469             :       }
     470           0 :       if (args[2].isNullOrUndefined()) {
     471           0 :         binding_detail::FastIDBOpenDBOptions arg2;
     472           0 :         if (!arg2.Init(cx, args[2],  "Argument 3 of IDBFactory.openForPrincipal", false)) {
     473           0 :           return false;
     474             :         }
     475           0 :         binding_detail::FastErrorResult rv;
     476           0 :         auto result(StrongOrRawPtr<mozilla::dom::IDBOpenDBRequest>(self->OpenForPrincipal(cx, NonNullHelper(arg0), NonNullHelper(Constify(arg1)), Constify(arg2), SystemCallerGuarantee(), rv)));
     477           0 :         if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     478           0 :           return false;
     479             :         }
     480           0 :         MOZ_ASSERT(!JS_IsExceptionPending(cx));
     481           0 :         if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     482           0 :           MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     483           0 :           return false;
     484             :         }
     485           0 :         return true;
     486             :       }
     487           0 :       if (args[2].isObject()) {
     488             :         do {
     489           0 :           binding_detail::FastIDBOpenDBOptions arg2;
     490           0 :           if (!arg2.Init(cx, args[2],  "Argument 3 of IDBFactory.openForPrincipal", false)) {
     491           0 :             return false;
     492             :           }
     493           0 :           binding_detail::FastErrorResult rv;
     494           0 :           auto result(StrongOrRawPtr<mozilla::dom::IDBOpenDBRequest>(self->OpenForPrincipal(cx, NonNullHelper(arg0), NonNullHelper(Constify(arg1)), Constify(arg2), SystemCallerGuarantee(), rv)));
     495           0 :           if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     496           0 :             return false;
     497             :           }
     498           0 :           MOZ_ASSERT(!JS_IsExceptionPending(cx));
     499           0 :           if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     500           0 :             MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     501           0 :             return false;
     502             :           }
     503           0 :           return true;
     504             :         } while (0);
     505             :       }
     506             :       uint64_t arg2;
     507           0 :       if (!ValueToPrimitive<uint64_t, eEnforceRange>(cx, args[2], &arg2)) {
     508           0 :         return false;
     509             :       }
     510           0 :       binding_detail::FastErrorResult rv;
     511           0 :       auto result(StrongOrRawPtr<mozilla::dom::IDBOpenDBRequest>(self->OpenForPrincipal(cx, NonNullHelper(arg0), NonNullHelper(Constify(arg1)), arg2, SystemCallerGuarantee(), rv)));
     512           0 :       if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     513           0 :         return false;
     514             :       }
     515           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
     516           0 :       if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     517           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     518           0 :         return false;
     519             :       }
     520           0 :       return true;
     521             :       break;
     522             :     }
     523             :     default: {
     524           0 :       return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "IDBFactory.openForPrincipal");
     525             :       break;
     526             :     }
     527             :   }
     528             :   MOZ_CRASH("We have an always-returning default case");
     529             :   return false;
     530             : }
     531             : 
     532             : static const JSJitInfo openForPrincipal_methodinfo = {
     533             :   { (JSJitGetterOp)openForPrincipal },
     534             :   { prototypes::id::IDBFactory },
     535             :   { PrototypeTraits<prototypes::id::IDBFactory>::Depth },
     536             :   JSJitInfo::Method,
     537             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     538             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     539             :   false,  /* isInfallible. False in setters. */
     540             :   false,  /* isMovable.  Not relevant for setters. */
     541             :   false, /* isEliminatable.  Not relevant for setters. */
     542             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     543             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     544             :   false,  /* isTypedMethod.  Only relevant for methods. */
     545             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     546             : };
     547             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     548             : static_assert(0 < 1, "There is no slot for us");
     549             : 
     550             : static bool
     551           0 : deleteForPrincipal(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBFactory* self, const JSJitMethodCallArgs& args)
     552             : {
     553           0 :   if (MOZ_UNLIKELY(args.length() < 2)) {
     554           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "IDBFactory.deleteForPrincipal");
     555             :   }
     556             :   nsIPrincipal* arg0;
     557           0 :   RefPtr<nsIPrincipal> arg0_holder;
     558           0 :   if (args[0].isObject()) {
     559           0 :     JS::Rooted<JSObject*> source(cx, &args[0].toObject());
     560           0 :     if (NS_FAILED(UnwrapArg<nsIPrincipal>(cx, source, getter_AddRefs(arg0_holder)))) {
     561           0 :       ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of IDBFactory.deleteForPrincipal", "Principal");
     562           0 :       return false;
     563             :     }
     564           0 :     MOZ_ASSERT(arg0_holder);
     565           0 :     arg0 = arg0_holder;
     566             :   } else {
     567           0 :     ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of IDBFactory.deleteForPrincipal");
     568           0 :     return false;
     569             :   }
     570           0 :   binding_detail::FakeString arg1;
     571           0 :   if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
     572           0 :     return false;
     573             :   }
     574           0 :   binding_detail::FastIDBOpenDBOptions arg2;
     575           0 :   if (!arg2.Init(cx, (args.hasDefined(2)) ? args[2] : JS::NullHandleValue,  "Argument 3 of IDBFactory.deleteForPrincipal", false)) {
     576           0 :     return false;
     577             :   }
     578           0 :   binding_detail::FastErrorResult rv;
     579           0 :   auto result(StrongOrRawPtr<mozilla::dom::IDBOpenDBRequest>(self->DeleteForPrincipal(cx, NonNullHelper(arg0), NonNullHelper(Constify(arg1)), Constify(arg2), SystemCallerGuarantee(), rv)));
     580           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     581           0 :     return false;
     582             :   }
     583           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     584           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     585           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     586           0 :     return false;
     587             :   }
     588           0 :   return true;
     589             : }
     590             : 
     591             : static const JSJitInfo deleteForPrincipal_methodinfo = {
     592             :   { (JSJitGetterOp)deleteForPrincipal },
     593             :   { prototypes::id::IDBFactory },
     594             :   { PrototypeTraits<prototypes::id::IDBFactory>::Depth },
     595             :   JSJitInfo::Method,
     596             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     597             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     598             :   false,  /* isInfallible. False in setters. */
     599             :   false,  /* isMovable.  Not relevant for setters. */
     600             :   false, /* isEliminatable.  Not relevant for setters. */
     601             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     602             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     603             :   false,  /* isTypedMethod.  Only relevant for methods. */
     604             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     605             : };
     606             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     607             : static_assert(0 < 1, "There is no slot for us");
     608             : 
     609             : static bool
     610           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     611             : {
     612           0 :   mozilla::dom::IDBFactory* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IDBFactory>(obj);
     613             :   // We don't want to preserve if we don't have a wrapper, and we
     614             :   // obviously can't preserve if we're not initialized.
     615           0 :   if (self && self->GetWrapperPreserveColor()) {
     616           0 :     PreserveWrapper(self);
     617             :   }
     618           0 :   return true;
     619             : }
     620             : 
     621             : static void
     622           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     623             : {
     624           0 :   mozilla::dom::IDBFactory* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IDBFactory>(obj);
     625           0 :   if (self) {
     626           0 :     ClearWrapper(self, self, obj);
     627           0 :     AddForDeferredFinalization<mozilla::dom::IDBFactory>(self);
     628             :   }
     629           0 : }
     630             : 
     631             : static void
     632           0 : _objectMoved(JSObject* obj, const JSObject* old)
     633             : {
     634           0 :   mozilla::dom::IDBFactory* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IDBFactory>(obj);
     635           0 :   if (self) {
     636           0 :     UpdateWrapper(self, self, obj, old);
     637             :   }
     638           0 : }
     639             : 
     640             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     641             : #if defined(__clang__)
     642             : #pragma clang diagnostic push
     643             : #pragma clang diagnostic ignored "-Wmissing-braces"
     644             : #endif
     645             : static const JSFunctionSpec sMethods_specs[] = {
     646             :   JS_FNSPEC("open", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&open_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     647             :   JS_FNSPEC("deleteDatabase", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&deleteDatabase_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     648             :   JS_FNSPEC("cmp", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&cmp_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
     649             :   JS_FS_END
     650             : };
     651             : #if defined(__clang__)
     652             : #pragma clang diagnostic pop
     653             : #endif
     654             : 
     655             : 
     656             : // Can't be const because the pref-enabled boolean needs to be writable
     657             : static Prefable<const JSFunctionSpec> sMethods[] = {
     658             :   { nullptr, &sMethods_specs[0] },
     659             :   { nullptr, nullptr }
     660             : };
     661             : 
     662             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     663             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     664             : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     665             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     666             : 
     667             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     668             : #if defined(__clang__)
     669             : #pragma clang diagnostic push
     670             : #pragma clang diagnostic ignored "-Wmissing-braces"
     671             : #endif
     672             : static const JSFunctionSpec sChromeMethods_specs[] = {
     673             :   JS_FNSPEC("openForPrincipal", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&openForPrincipal_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
     674             :   JS_FNSPEC("deleteForPrincipal", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&deleteForPrincipal_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
     675             :   JS_FS_END
     676             : };
     677             : #if defined(__clang__)
     678             : #pragma clang diagnostic pop
     679             : #endif
     680             : 
     681             : 
     682             : // Can't be const because the pref-enabled boolean needs to be writable
     683             : static Prefable<const JSFunctionSpec> sChromeMethods[] = {
     684             :   { nullptr, &sChromeMethods_specs[0] },
     685             :   { nullptr, nullptr }
     686             : };
     687             : 
     688             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     689             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     690             : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     691             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     692             : 
     693             : 
     694             : static uint16_t sNativeProperties_sortedPropertyIndices[3];
     695             : static PropertyInfo sNativeProperties_propertyInfos[3];
     696             : 
     697             : static const NativePropertiesN<1> sNativeProperties = {
     698             :   false, 0,
     699             :   false, 0,
     700             :   true,  0 /* sMethods */,
     701             :   false, 0,
     702             :   false, 0,
     703             :   false, 0,
     704             :   false, 0,
     705             :   -1,
     706             :   3,
     707             :   sNativeProperties_sortedPropertyIndices,
     708             :   {
     709             :     { sMethods, &sNativeProperties_propertyInfos[0] }
     710             :   }
     711             : };
     712             : static_assert(3 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     713             :     "We have a property info count that is oversized");
     714             : 
     715             : static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[2];
     716             : static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[2];
     717             : 
     718             : static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
     719             :   false, 0,
     720             :   false, 0,
     721             :   true,  0 /* sChromeMethods */,
     722             :   false, 0,
     723             :   false, 0,
     724             :   false, 0,
     725             :   false, 0,
     726             :   -1,
     727             :   2,
     728             :   sChromeOnlyNativeProperties_sortedPropertyIndices,
     729             :   {
     730             :     { sChromeMethods, &sChromeOnlyNativeProperties_propertyInfos[0] }
     731             :   }
     732             : };
     733             : static_assert(2 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
     734             :     "We have a property info count that is oversized");
     735             : 
     736             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     737             :   {
     738             :     "Function",
     739             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     740             :     &sBoringInterfaceObjectClassClassOps,
     741             :     JS_NULL_CLASS_SPEC,
     742             :     JS_NULL_CLASS_EXT,
     743             :     &sInterfaceObjectClassObjectOps
     744             :   },
     745             :   eInterface,
     746             :   true,
     747             :   prototypes::id::IDBFactory,
     748             :   PrototypeTraits<prototypes::id::IDBFactory>::Depth,
     749             :   sNativePropertyHooks,
     750             :   "function IDBFactory() {\n    [native code]\n}",
     751             :   JS::GetRealmFunctionPrototype
     752             : };
     753             : 
     754             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     755             :   {
     756             :     "IDBFactoryPrototype",
     757             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     758             :     JS_NULL_CLASS_OPS,
     759             :     JS_NULL_CLASS_SPEC,
     760             :     JS_NULL_CLASS_EXT,
     761             :     JS_NULL_OBJECT_OPS
     762             :   },
     763             :   eInterfacePrototype,
     764             :   false,
     765             :   prototypes::id::IDBFactory,
     766             :   PrototypeTraits<prototypes::id::IDBFactory>::Depth,
     767             :   sNativePropertyHooks,
     768             :   "[object IDBFactoryPrototype]",
     769             :   JS::GetRealmObjectPrototype
     770             : };
     771             : 
     772             : JSObject*
     773           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     774             : {
     775           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     776             : }
     777             : 
     778             : static const js::ClassOps sClassOps = {
     779             :   _addProperty, /* addProperty */
     780             :   nullptr,               /* delProperty */
     781             :   nullptr,               /* getProperty */
     782             :   nullptr,               /* setProperty */
     783             :   nullptr,               /* enumerate */
     784             :   nullptr, /* newEnumerate */
     785             :   nullptr, /* resolve */
     786             :   nullptr, /* mayResolve */
     787             :   _finalize, /* finalize */
     788             :   nullptr, /* call */
     789             :   nullptr,               /* hasInstance */
     790             :   nullptr,               /* construct */
     791             :   nullptr, /* trace */
     792             : };
     793             : 
     794             : static const js::ClassExtension sClassExtension = {
     795             :   nullptr, /* weakmapKeyDelegateOp */
     796             :   _objectMoved /* objectMovedOp */
     797             : };
     798             : 
     799             : static const DOMJSClass sClass = {
     800             :   { "IDBFactory",
     801             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     802             :     &sClassOps,
     803             :     JS_NULL_CLASS_SPEC,
     804             :     &sClassExtension,
     805             :     JS_NULL_OBJECT_OPS
     806             :   },
     807             :   { prototypes::id::IDBFactory, 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 },
     808             :   IsBaseOf<nsISupports, mozilla::dom::IDBFactory >::value,
     809             :   sNativePropertyHooks,
     810             :   FindAssociatedGlobalForNative<mozilla::dom::IDBFactory>::Get,
     811             :   GetProtoObjectHandle,
     812             :   GetCCParticipant<mozilla::dom::IDBFactory>::Get()
     813             : };
     814             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     815             :               "Must have the right minimal number of reserved slots.");
     816             : static_assert(1 >= 1,
     817             :               "Must have enough reserved slots.");
     818             : 
     819             : const JSClass*
     820           0 : GetJSClass()
     821             : {
     822           0 :   return sClass.ToJSClass();
     823             : }
     824             : 
     825             : bool
     826          14 : Wrap(JSContext* aCx, mozilla::dom::IDBFactory* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     827             : {
     828             :   MOZ_ASSERT(static_cast<mozilla::dom::IDBFactory*>(aObject) ==
     829             :              reinterpret_cast<mozilla::dom::IDBFactory*>(aObject),
     830             :              "Multiple inheritance for mozilla::dom::IDBFactory is broken.");
     831          14 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     832          14 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     833          14 :   MOZ_ASSERT(!aCache->GetWrapper(),
     834             :              "You should probably not be using Wrap() directly; use "
     835             :              "GetOrCreateDOMReflector instead");
     836             : 
     837          14 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     838             :              "nsISupports must be on our primary inheritance chain");
     839             : 
     840          28 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     841          14 :   if (!global) {
     842           0 :     return false;
     843             :   }
     844          14 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     845          14 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     846             : 
     847             :   // That might have ended up wrapping us already, due to the wonders
     848             :   // of XBL.  Check for that, and bail out as needed.
     849          14 :   aReflector.set(aCache->GetWrapper());
     850          14 :   if (aReflector) {
     851             : #ifdef DEBUG
     852           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     853             : #endif // DEBUG
     854           0 :     return true;
     855             :   }
     856             : 
     857          28 :   JSAutoCompartment ac(aCx, global);
     858          14 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     859          14 :   if (!canonicalProto) {
     860           0 :     return false;
     861             :   }
     862          28 :   JS::Rooted<JSObject*> proto(aCx);
     863          14 :   if (aGivenProto) {
     864           0 :     proto = aGivenProto;
     865             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     866             :     // coming in, we changed compartments to that of "parent" so may need
     867             :     // to wrap the proto here.
     868           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     869           0 :       if (!JS_WrapObject(aCx, &proto)) {
     870           0 :         return false;
     871             :       }
     872             :     }
     873             :   } else {
     874          14 :     proto = canonicalProto;
     875             :   }
     876             : 
     877          28 :   BindingJSObjectCreator<mozilla::dom::IDBFactory> creator(aCx);
     878          14 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     879          14 :   if (!aReflector) {
     880           0 :     return false;
     881             :   }
     882             : 
     883          14 :   aCache->SetWrapper(aReflector);
     884          14 :   creator.InitializationSucceeded();
     885             : 
     886          14 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     887             :              aCache->GetWrapperPreserveColor() == aReflector);
     888             :   // If proto != canonicalProto, we have to preserve our wrapper;
     889             :   // otherwise we won't be able to properly recreate it later, since
     890             :   // we won't know what proto to use.  Note that we don't check
     891             :   // aGivenProto here, since it's entirely possible (and even
     892             :   // somewhat common) to have a non-null aGivenProto which is the
     893             :   // same as canonicalProto.
     894          14 :   if (proto != canonicalProto) {
     895           0 :     PreserveWrapper(aObject);
     896             :   }
     897             : 
     898          14 :   return true;
     899             : }
     900             : 
     901             : const NativePropertyHooks sNativePropertyHooks[] = { {
     902             :   nullptr,
     903             :   nullptr,
     904             :   nullptr,
     905             :   { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
     906             :   prototypes::id::IDBFactory,
     907             :   constructors::id::IDBFactory,
     908             :   nullptr,
     909             :   &DefaultXrayExpandoObjectClass
     910             : } };
     911             : 
     912             : void
     913          15 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     914             : {
     915          30 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
     916          15 :   if (!parentProto) {
     917           0 :     return;
     918             :   }
     919             : 
     920          30 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
     921          15 :   if (!constructorProto) {
     922           0 :     return;
     923             :   }
     924             : 
     925             :   static bool sIdsInited = false;
     926          15 :   if (!sIdsInited && NS_IsMainThread()) {
     927           1 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     928           0 :       return;
     929             :     }
     930           1 :     if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
     931           0 :       return;
     932             :     }
     933           1 :     sIdsInited = true;
     934             :   }
     935             : 
     936          15 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::IDBFactory);
     937          15 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::IDBFactory);
     938          45 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     939             :                               &sPrototypeClass.mBase, protoCache,
     940             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     941             :                               interfaceCache,
     942             :                               sNativeProperties.Upcast(),
     943          15 :                               nsContentUtils::ThreadsafeIsSystemCaller(aCx) ? sChromeOnlyNativeProperties.Upcast() : nullptr,
     944             :                               "IDBFactory", aDefineOnGlobal,
     945             :                               nullptr,
     946          15 :                               false);
     947             : }
     948             : 
     949             : JS::Handle<JSObject*>
     950          14 : GetProtoObjectHandle(JSContext* aCx)
     951             : {
     952             :   /* Get the interface prototype object for this class.  This will create the
     953             :      object as needed. */
     954          14 :   bool aDefineOnGlobal = true;
     955             : 
     956             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     957          14 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     958          14 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     959           0 :     return nullptr;
     960             :   }
     961             : 
     962             :   /* Check to see whether the interface objects are already installed */
     963          14 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     964          14 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::IDBFactory)) {
     965           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     966           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     967             :   }
     968             : 
     969             :   /*
     970             :    * The object might _still_ be null, but that's OK.
     971             :    *
     972             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     973             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     974             :    * changed after they have been set.
     975             :    *
     976             :    * Calling address() avoids the read read barrier that does gray
     977             :    * unmarking, but it's not possible for the object to be gray here.
     978             :    */
     979             : 
     980          14 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::IDBFactory);
     981          14 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     982          14 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     983             : }
     984             : 
     985             : JS::Handle<JSObject*>
     986          15 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     987             : {
     988             :   /* Get the interface object for this class.  This will create the object as
     989             :      needed. */
     990             : 
     991             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     992          15 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     993          15 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     994           0 :     return nullptr;
     995             :   }
     996             : 
     997             :   /* Check to see whether the interface objects are already installed */
     998          15 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     999          15 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::IDBFactory)) {
    1000          30 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1001          15 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1002             :   }
    1003             : 
    1004             :   /*
    1005             :    * The object might _still_ be null, but that's OK.
    1006             :    *
    1007             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1008             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1009             :    * changed after they have been set.
    1010             :    *
    1011             :    * Calling address() avoids the read read barrier that does gray
    1012             :    * unmarking, but it's not possible for the object to be gray here.
    1013             :    */
    1014             : 
    1015          15 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::IDBFactory);
    1016          15 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1017          15 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1018             : }
    1019             : 
    1020             : JSObject*
    1021          15 : GetConstructorObject(JSContext* aCx)
    1022             : {
    1023          15 :   return GetConstructorObjectHandle(aCx);
    1024             : }
    1025             : 
    1026             : } // namespace IDBFactoryBinding
    1027             : 
    1028             : 
    1029             : 
    1030             : } // namespace dom
    1031             : } // namespace mozilla

Generated by: LCOV version 1.13