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

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

Generated by: LCOV version 1.13