LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - DOMExceptionBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 76 410 18.5 %
Date: 2017-07-14 16:53:18 Functions: 7 42 16.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM DOMException.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "DOMExceptionBinding.h"
       4             : #include "WrapperFactory.h"
       5             : #include "mozilla/OwningNonNull.h"
       6             : #include "mozilla/dom/BindingUtils.h"
       7             : #include "mozilla/dom/DOMException.h"
       8             : #include "mozilla/dom/DOMJSClass.h"
       9             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      10             : #include "mozilla/dom/Nullable.h"
      11             : #include "mozilla/dom/PrimitiveConversions.h"
      12             : #include "mozilla/dom/XrayExpandoClass.h"
      13             : #include "nsContentUtils.h"
      14             : #include "nsIException.h"
      15             : #include "nsISupports.h"
      16             : 
      17             : namespace mozilla {
      18             : namespace dom {
      19             : 
      20             : namespace DOMExceptionBinding {
      21             : 
      22             : static bool
      23           0 : get_code(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMException* self, JSJitGetterCallArgs args)
      24             : {
      25           0 :   uint16_t result(self->Code());
      26           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      27           0 :   args.rval().setInt32(int32_t(result));
      28           0 :   return true;
      29             : }
      30             : 
      31             : static const JSJitInfo code_getterinfo = {
      32             :   { (JSJitGetterOp)get_code },
      33             :   { prototypes::id::DOMException },
      34             :   { PrototypeTraits<prototypes::id::DOMException>::Depth },
      35             :   JSJitInfo::Getter,
      36             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      37             :   JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
      38             :   true,  /* isInfallible. False in setters. */
      39             :   false,  /* isMovable.  Not relevant for setters. */
      40             :   false, /* isEliminatable.  Not relevant for setters. */
      41             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      42             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      43             :   false,  /* isTypedMethod.  Only relevant for methods. */
      44             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      45             : };
      46             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      47             : static_assert(0 < 1, "There is no slot for us");
      48             : 
      49             : static bool
      50           0 : get_message(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMException* self, JSJitGetterCallArgs args)
      51             : {
      52           0 :   DOMString result;
      53           0 :   self->GetMessageMoz(result);
      54           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      55           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
      56           0 :     return false;
      57             :   }
      58           0 :   return true;
      59             : }
      60             : 
      61             : static const JSJitInfo message_getterinfo = {
      62             :   { (JSJitGetterOp)get_message },
      63             :   { prototypes::id::DOMException },
      64             :   { PrototypeTraits<prototypes::id::DOMException>::Depth },
      65             :   JSJitInfo::Getter,
      66             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      67             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
      68             :   false,  /* isInfallible. False in setters. */
      69             :   false,  /* isMovable.  Not relevant for setters. */
      70             :   false, /* isEliminatable.  Not relevant for setters. */
      71             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      72             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      73             :   false,  /* isTypedMethod.  Only relevant for methods. */
      74             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      75             : };
      76             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      77             : static_assert(0 < 1, "There is no slot for us");
      78             : 
      79             : static bool
      80           0 : get_result(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMException* self, JSJitGetterCallArgs args)
      81             : {
      82           0 :   uint32_t result(self->Result());
      83           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      84           0 :   args.rval().setNumber(result);
      85           0 :   return true;
      86             : }
      87             : 
      88             : static const JSJitInfo result_getterinfo = {
      89             :   { (JSJitGetterOp)get_result },
      90             :   { prototypes::id::DOMException },
      91             :   { PrototypeTraits<prototypes::id::DOMException>::Depth },
      92             :   JSJitInfo::Getter,
      93             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      94             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
      95             :   true,  /* isInfallible. False in setters. */
      96             :   false,  /* isMovable.  Not relevant for setters. */
      97             :   false, /* isEliminatable.  Not relevant for setters. */
      98             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      99             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     100             :   false,  /* isTypedMethod.  Only relevant for methods. */
     101             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     102             : };
     103             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     104             : static_assert(0 < 1, "There is no slot for us");
     105             : 
     106             : static bool
     107           0 : get_name(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMException* self, JSJitGetterCallArgs args)
     108             : {
     109           0 :   DOMString result;
     110           0 :   self->GetName(result);
     111           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     112           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     113           0 :     return false;
     114             :   }
     115           0 :   return true;
     116             : }
     117             : 
     118             : static const JSJitInfo name_getterinfo = {
     119             :   { (JSJitGetterOp)get_name },
     120             :   { prototypes::id::DOMException },
     121             :   { PrototypeTraits<prototypes::id::DOMException>::Depth },
     122             :   JSJitInfo::Getter,
     123             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     124             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     125             :   false,  /* isInfallible. False in setters. */
     126             :   false,  /* isMovable.  Not relevant for setters. */
     127             :   false, /* isEliminatable.  Not relevant for setters. */
     128             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     129             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     130             :   false,  /* isTypedMethod.  Only relevant for methods. */
     131             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     132             : };
     133             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     134             : static_assert(0 < 1, "There is no slot for us");
     135             : 
     136             : static bool
     137           0 : get_filename(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMException* self, JSJitGetterCallArgs args)
     138             : {
     139           0 :   DOMString result;
     140           0 :   self->GetFilename(cx, result);
     141           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     142           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     143           0 :     return false;
     144             :   }
     145           0 :   return true;
     146             : }
     147             : 
     148             : static const JSJitInfo filename_getterinfo = {
     149             :   { (JSJitGetterOp)get_filename },
     150             :   { prototypes::id::DOMException },
     151             :   { PrototypeTraits<prototypes::id::DOMException>::Depth },
     152             :   JSJitInfo::Getter,
     153             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     154             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     155             :   false,  /* isInfallible. False in setters. */
     156             :   false,  /* isMovable.  Not relevant for setters. */
     157             :   false, /* isEliminatable.  Not relevant for setters. */
     158             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     159             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     160             :   false,  /* isTypedMethod.  Only relevant for methods. */
     161             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     162             : };
     163             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     164             : static_assert(0 < 1, "There is no slot for us");
     165             : 
     166             : static bool
     167           0 : get_lineNumber(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMException* self, JSJitGetterCallArgs args)
     168             : {
     169           0 :   uint32_t result(self->LineNumber(cx));
     170           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     171           0 :   args.rval().setNumber(result);
     172           0 :   return true;
     173             : }
     174             : 
     175             : static const JSJitInfo lineNumber_getterinfo = {
     176             :   { (JSJitGetterOp)get_lineNumber },
     177             :   { prototypes::id::DOMException },
     178             :   { PrototypeTraits<prototypes::id::DOMException>::Depth },
     179             :   JSJitInfo::Getter,
     180             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     181             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     182             :   true,  /* isInfallible. False in setters. */
     183             :   false,  /* isMovable.  Not relevant for setters. */
     184             :   false, /* isEliminatable.  Not relevant for setters. */
     185             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     186             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     187             :   false,  /* isTypedMethod.  Only relevant for methods. */
     188             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     189             : };
     190             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     191             : static_assert(0 < 1, "There is no slot for us");
     192             : 
     193             : static bool
     194           0 : get_columnNumber(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMException* self, JSJitGetterCallArgs args)
     195             : {
     196           0 :   uint32_t result(self->ColumnNumber());
     197           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     198           0 :   args.rval().setNumber(result);
     199           0 :   return true;
     200             : }
     201             : 
     202             : static const JSJitInfo columnNumber_getterinfo = {
     203             :   { (JSJitGetterOp)get_columnNumber },
     204             :   { prototypes::id::DOMException },
     205             :   { PrototypeTraits<prototypes::id::DOMException>::Depth },
     206             :   JSJitInfo::Getter,
     207             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     208             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     209             :   true,  /* isInfallible. False in setters. */
     210             :   false,  /* isMovable.  Not relevant for setters. */
     211             :   false, /* isEliminatable.  Not relevant for setters. */
     212             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     213             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     214             :   false,  /* isTypedMethod.  Only relevant for methods. */
     215             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     216             : };
     217             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     218             : static_assert(0 < 1, "There is no slot for us");
     219             : 
     220             : static bool
     221           0 : get_location(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMException* self, JSJitGetterCallArgs args)
     222             : {
     223           0 :   auto result(StrongOrRawPtr<nsIStackFrame>(self->GetLocation()));
     224           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     225           0 :   if (!result) {
     226           0 :     args.rval().setNull();
     227           0 :     return true;
     228             :   }
     229           0 :   if (!WrapObject(cx, result, &NS_GET_IID(nsIStackFrame), args.rval())) {
     230           0 :     return false;
     231             :   }
     232           0 :   return true;
     233             : }
     234             : 
     235             : static const JSJitInfo location_getterinfo = {
     236             :   { (JSJitGetterOp)get_location },
     237             :   { prototypes::id::DOMException },
     238             :   { PrototypeTraits<prototypes::id::DOMException>::Depth },
     239             :   JSJitInfo::Getter,
     240             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     241             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     242             :   false,  /* isInfallible. False in setters. */
     243             :   false,  /* isMovable.  Not relevant for setters. */
     244             :   false, /* isEliminatable.  Not relevant for setters. */
     245             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     246             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     247             :   false,  /* isTypedMethod.  Only relevant for methods. */
     248             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     249             : };
     250             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     251             : static_assert(0 < 1, "There is no slot for us");
     252             : 
     253             : static bool
     254           0 : get_data(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMException* self, JSJitGetterCallArgs args)
     255             : {
     256           0 :   auto result(StrongOrRawPtr<nsISupports>(self->GetData()));
     257           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     258           0 :   if (!result) {
     259           0 :     args.rval().setNull();
     260           0 :     return true;
     261             :   }
     262           0 :   if (!WrapObject(cx, result, args.rval())) {
     263           0 :     return false;
     264             :   }
     265           0 :   return true;
     266             : }
     267             : 
     268             : static const JSJitInfo data_getterinfo = {
     269             :   { (JSJitGetterOp)get_data },
     270             :   { prototypes::id::DOMException },
     271             :   { PrototypeTraits<prototypes::id::DOMException>::Depth },
     272             :   JSJitInfo::Getter,
     273             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     274             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     275             :   false,  /* isInfallible. False in setters. */
     276             :   false,  /* isMovable.  Not relevant for setters. */
     277             :   false, /* isEliminatable.  Not relevant for setters. */
     278             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     279             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     280             :   false,  /* isTypedMethod.  Only relevant for methods. */
     281             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     282             : };
     283             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     284             : static_assert(0 < 1, "There is no slot for us");
     285             : 
     286             : static bool
     287           0 : get_stack(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMException* self, JSJitGetterCallArgs args)
     288             : {
     289           0 :   binding_detail::FastErrorResult rv;
     290           0 :   DOMString result;
     291           0 :   self->GetStack(cx, result, rv);
     292           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     293           0 :     return false;
     294             :   }
     295           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     296           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     297           0 :     return false;
     298             :   }
     299           0 :   return true;
     300             : }
     301             : 
     302             : static bool
     303           0 : set_stack(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMException* self, JSJitSetterCallArgs args)
     304             : {
     305           0 :   return JS_DefineProperty(cx, obj, "stack", args[0], JSPROP_ENUMERATE);
     306             : }
     307             : 
     308             : static const JSJitInfo stack_getterinfo = {
     309             :   { (JSJitGetterOp)get_stack },
     310             :   { prototypes::id::DOMException },
     311             :   { PrototypeTraits<prototypes::id::DOMException>::Depth },
     312             :   JSJitInfo::Getter,
     313             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     314             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     315             :   false,  /* isInfallible. False in setters. */
     316             :   false,  /* isMovable.  Not relevant for setters. */
     317             :   false, /* isEliminatable.  Not relevant for setters. */
     318             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     319             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     320             :   false,  /* isTypedMethod.  Only relevant for methods. */
     321             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     322             : };
     323             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     324             : static_assert(0 < 1, "There is no slot for us");
     325             : static const JSJitInfo stack_setterinfo = {
     326             :   { (JSJitGetterOp)set_stack },
     327             :   { prototypes::id::DOMException },
     328             :   { PrototypeTraits<prototypes::id::DOMException>::Depth },
     329             :   JSJitInfo::Setter,
     330             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     331             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     332             :   false,  /* isInfallible. False in setters. */
     333             :   false,  /* isMovable.  Not relevant for setters. */
     334             :   false, /* isEliminatable.  Not relevant for setters. */
     335             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     336             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     337             :   false,  /* isTypedMethod.  Only relevant for methods. */
     338             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     339             : };
     340             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     341             : static_assert(0 < 1, "There is no slot for us");
     342             : 
     343             : static bool
     344           0 : genericLenientGetter(JSContext* cx, unsigned argc, JS::Value* vp)
     345             : {
     346           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     347           0 :   if (!args.thisv().isObject()) {
     348           0 :     MOZ_ASSERT(!JS_IsExceptionPending(cx));
     349           0 :     if (!ReportLenientThisUnwrappingFailure(cx, &args.callee())) {
     350           0 :       return false;
     351             :     }
     352           0 :     args.rval().set(JS::UndefinedValue());
     353           0 :     return true;
     354             :   }
     355           0 :   JS::Rooted<JSObject*> obj(cx, &args.thisv().toObject());
     356             : 
     357             :   mozilla::dom::DOMException* self;
     358           0 :   JS::Rooted<JS::Value> rootSelf(cx, JS::ObjectValue(*obj));
     359             :   {
     360           0 :     nsresult rv = UnwrapObject<prototypes::id::DOMException, mozilla::dom::DOMException>(&rootSelf, self);
     361           0 :     if (NS_FAILED(rv)) {
     362           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
     363           0 :       if (!ReportLenientThisUnwrappingFailure(cx, &args.callee())) {
     364           0 :         return false;
     365             :       }
     366           0 :       args.rval().set(JS::UndefinedValue());
     367           0 :       return true;
     368             :     }
     369             :   }
     370           0 :   const JSJitInfo *info = FUNCTION_VALUE_TO_JITINFO(args.calleev());
     371           0 :   MOZ_ASSERT(info->type() == JSJitInfo::Getter);
     372           0 :   JSJitGetterOp getter = info->getter;
     373           0 :   bool ok = getter(cx, obj, self, JSJitGetterCallArgs(args));
     374             : #ifdef DEBUG
     375           0 :   if (ok) {
     376           0 :     AssertReturnTypeMatchesJitinfo(info, args.rval());
     377             :   }
     378             : #endif
     379           0 :   return ok;
     380             : }
     381             : 
     382             : static bool
     383           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     384             : {
     385           0 :   mozilla::dom::DOMException* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::DOMException>(obj);
     386             :   // We don't want to preserve if we don't have a wrapper, and we
     387             :   // obviously can't preserve if we're not initialized.
     388           0 :   if (self && self->GetWrapperPreserveColor()) {
     389           0 :     PreserveWrapper(self);
     390             :   }
     391           0 :   return true;
     392             : }
     393             : 
     394             : static void
     395           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     396             : {
     397           0 :   mozilla::dom::DOMException* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::DOMException>(obj);
     398           0 :   if (self) {
     399           0 :     ClearWrapper(self, self, obj);
     400           0 :     AddForDeferredFinalization<mozilla::dom::DOMException>(self);
     401             :   }
     402           0 : }
     403             : 
     404             : static void
     405           0 : _objectMoved(JSObject* obj, const JSObject* old)
     406             : {
     407           0 :   mozilla::dom::DOMException* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::DOMException>(obj);
     408           0 :   if (self) {
     409           0 :     UpdateWrapper(self, self, obj, old);
     410             :   }
     411           0 : }
     412             : 
     413             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     414             : #if defined(__clang__)
     415             : #pragma clang diagnostic push
     416             : #pragma clang diagnostic ignored "-Wmissing-braces"
     417             : #endif
     418             : static const JSPropertySpec sAttributes_specs[] = {
     419             :   { "code", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &code_getterinfo, nullptr, nullptr },
     420             :   { "message", JSPROP_SHARED | JSPROP_ENUMERATE, genericLenientGetter, &message_getterinfo, nullptr, nullptr },
     421             :   { "result", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &result_getterinfo, nullptr, nullptr },
     422             :   { "name", JSPROP_SHARED | JSPROP_ENUMERATE, genericLenientGetter, &name_getterinfo, nullptr, nullptr },
     423             :   { "filename", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &filename_getterinfo, nullptr, nullptr },
     424             :   { "lineNumber", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &lineNumber_getterinfo, nullptr, nullptr },
     425             :   { "columnNumber", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &columnNumber_getterinfo, nullptr, nullptr },
     426             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
     427             :   { "data", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &data_getterinfo, nullptr, nullptr },
     428             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
     429             :   { "stack", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &stack_getterinfo, GenericBindingSetter, &stack_setterinfo },
     430             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     431             : };
     432             : #if defined(__clang__)
     433             : #pragma clang diagnostic pop
     434             : #endif
     435             : 
     436             : static PrefableDisablers sAttributes_disablers8 = {
     437             :   true, false, GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope, nullptr
     438             : };
     439             : 
     440             : // Can't be const because the pref-enabled boolean needs to be writable
     441             : static Prefable<const JSPropertySpec> sAttributes[] = {
     442             :   { nullptr, &sAttributes_specs[0] },
     443             :   { &sAttributes_disablers8, &sAttributes_specs[8] },
     444             :   { nullptr, &sAttributes_specs[10] },
     445             :   { nullptr, nullptr }
     446             : };
     447             : 
     448             : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     449             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     450             : static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     451             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     452             : 
     453             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     454             : #if defined(__clang__)
     455             : #pragma clang diagnostic push
     456             : #pragma clang diagnostic ignored "-Wmissing-braces"
     457             : #endif
     458             : static const JSPropertySpec sChromeAttributes_specs[] = {
     459             :   { "location", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &location_getterinfo, nullptr, nullptr },
     460             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     461             : };
     462             : #if defined(__clang__)
     463             : #pragma clang diagnostic pop
     464             : #endif
     465             : 
     466             : static PrefableDisablers sChromeAttributes_disablers0 = {
     467             :   true, false, GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope, nullptr
     468             : };
     469             : 
     470             : // Can't be const because the pref-enabled boolean needs to be writable
     471             : static Prefable<const JSPropertySpec> sChromeAttributes[] = {
     472             :   { &sChromeAttributes_disablers0, &sChromeAttributes_specs[0] },
     473             :   { nullptr, nullptr }
     474             : };
     475             : 
     476             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     477             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     478             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     479             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     480             : 
     481             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     482             : #if defined(__clang__)
     483             : #pragma clang diagnostic push
     484             : #pragma clang diagnostic ignored "-Wmissing-braces"
     485             : #endif
     486             : static const ConstantSpec sConstants_specs[] = {
     487             :   { "INDEX_SIZE_ERR", JS::Int32Value(1) },
     488             :   { "DOMSTRING_SIZE_ERR", JS::Int32Value(2) },
     489             :   { "HIERARCHY_REQUEST_ERR", JS::Int32Value(3) },
     490             :   { "WRONG_DOCUMENT_ERR", JS::Int32Value(4) },
     491             :   { "INVALID_CHARACTER_ERR", JS::Int32Value(5) },
     492             :   { "NO_DATA_ALLOWED_ERR", JS::Int32Value(6) },
     493             :   { "NO_MODIFICATION_ALLOWED_ERR", JS::Int32Value(7) },
     494             :   { "NOT_FOUND_ERR", JS::Int32Value(8) },
     495             :   { "NOT_SUPPORTED_ERR", JS::Int32Value(9) },
     496             :   { "INUSE_ATTRIBUTE_ERR", JS::Int32Value(10) },
     497             :   { "INVALID_STATE_ERR", JS::Int32Value(11) },
     498             :   { "SYNTAX_ERR", JS::Int32Value(12) },
     499             :   { "INVALID_MODIFICATION_ERR", JS::Int32Value(13) },
     500             :   { "NAMESPACE_ERR", JS::Int32Value(14) },
     501             :   { "INVALID_ACCESS_ERR", JS::Int32Value(15) },
     502             :   { "VALIDATION_ERR", JS::Int32Value(16) },
     503             :   { "TYPE_MISMATCH_ERR", JS::Int32Value(17) },
     504             :   { "SECURITY_ERR", JS::Int32Value(18) },
     505             :   { "NETWORK_ERR", JS::Int32Value(19) },
     506             :   { "ABORT_ERR", JS::Int32Value(20) },
     507             :   { "URL_MISMATCH_ERR", JS::Int32Value(21) },
     508             :   { "QUOTA_EXCEEDED_ERR", JS::Int32Value(22) },
     509             :   { "TIMEOUT_ERR", JS::Int32Value(23) },
     510             :   { "INVALID_NODE_TYPE_ERR", JS::Int32Value(24) },
     511             :   { "DATA_CLONE_ERR", JS::Int32Value(25) },
     512             :   { 0, JS::UndefinedValue() }
     513             : };
     514             : #if defined(__clang__)
     515             : #pragma clang diagnostic pop
     516             : #endif
     517             : 
     518             : 
     519             : // Can't be const because the pref-enabled boolean needs to be writable
     520             : static Prefable<const ConstantSpec> sConstants[] = {
     521             :   { nullptr, &sConstants_specs[0] },
     522             :   { nullptr, nullptr }
     523             : };
     524             : 
     525             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     526             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     527             : static_assert(25 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     528             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     529             : 
     530             : 
     531             : static uint16_t sNativeProperties_sortedPropertyIndices[34];
     532             : static PropertyInfo sNativeProperties_propertyInfos[34];
     533             : 
     534             : static const NativePropertiesN<2> sNativeProperties = {
     535             :   false, 0,
     536             :   false, 0,
     537             :   false, 0,
     538             :   true,  0 /* sAttributes */,
     539             :   false, 0,
     540             :   false, 0,
     541             :   true,  1 /* sConstants */,
     542             :   -1,
     543             :   34,
     544             :   sNativeProperties_sortedPropertyIndices,
     545             :   {
     546             :     { sAttributes, &sNativeProperties_propertyInfos[0] },
     547             :     { sConstants, &sNativeProperties_propertyInfos[9] }
     548             :   }
     549             : };
     550             : static_assert(34 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     551             :     "We have a property info count that is oversized");
     552             : 
     553             : static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1];
     554             : static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1];
     555             : 
     556             : static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
     557             :   false, 0,
     558             :   false, 0,
     559             :   false, 0,
     560             :   true,  0 /* sChromeAttributes */,
     561             :   false, 0,
     562             :   false, 0,
     563             :   false, 0,
     564             :   -1,
     565             :   1,
     566             :   sChromeOnlyNativeProperties_sortedPropertyIndices,
     567             :   {
     568             :     { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[0] }
     569             :   }
     570             : };
     571             : static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
     572             :     "We have a property info count that is oversized");
     573             : 
     574             : static bool
     575           0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
     576             : {
     577           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     578           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     579           0 :   if (!args.isConstructing()) {
     580             :     // XXXbz wish I could get the name from the callee instead of
     581             :     // Adding more relocations
     582           0 :     return ThrowConstructorWithoutNew(cx, "DOMException");
     583             :   }
     584             : 
     585           0 :   GlobalObject global(cx, obj);
     586           0 :   if (global.Failed()) {
     587           0 :     return false;
     588             :   }
     589             : 
     590           0 :   JS::Rooted<JSObject*> desiredProto(cx);
     591           0 :   if (!GetDesiredProto(cx, args, &desiredProto)) {
     592           0 :     return false;
     593             :   }
     594             : 
     595           0 :   bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
     596           0 :   binding_detail::FakeString arg0;
     597           0 :   if (args.hasDefined(0)) {
     598           0 :     if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     599           0 :       return false;
     600             :     }
     601             :   } else {
     602             :     static const char16_t data[] = { 0 };
     603           0 :     arg0.Rebind(data, ArrayLength(data) - 1);
     604             :   }
     605           0 :   Optional<nsAString> arg1;
     606           0 :   binding_detail::FakeString arg1_holder;
     607           0 :   if (args.hasDefined(1)) {
     608           0 :     if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1_holder)) {
     609           0 :       return false;
     610             :     }
     611           0 :     arg1 = &arg1_holder;
     612             :   }
     613           0 :   Maybe<JSAutoCompartment> ac;
     614           0 :   if (objIsXray) {
     615           0 :     obj = js::CheckedUnwrap(obj);
     616           0 :     if (!obj) {
     617           0 :       return false;
     618             :     }
     619           0 :     ac.emplace(cx, obj);
     620           0 :     if (!JS_WrapObject(cx, &desiredProto)) {
     621           0 :       return false;
     622             :     }
     623             :   }
     624           0 :   binding_detail::FastErrorResult rv;
     625           0 :   auto result(StrongOrRawPtr<mozilla::dom::DOMException>(mozilla::dom::DOMException::Constructor(global, NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), rv)));
     626           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     627           0 :     return false;
     628             :   }
     629           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     630             :   static_assert(!IsPointer<decltype(result)>::value,
     631             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
     632           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
     633           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     634           0 :     return false;
     635             :   }
     636           0 :   return true;
     637             : }
     638             : 
     639             : static const js::ClassOps sInterfaceObjectClassOps = {
     640             :     nullptr,               /* addProperty */
     641             :     nullptr,               /* delProperty */
     642             :     nullptr,               /* getProperty */
     643             :     nullptr,               /* setProperty */
     644             :     nullptr,               /* enumerate */
     645             :     nullptr,               /* newEnumerate */
     646             :     nullptr,               /* resolve */
     647             :     nullptr,               /* mayResolve */
     648             :     nullptr,               /* finalize */
     649             :     _constructor, /* call */
     650             :     nullptr,               /* hasInstance */
     651             :     _constructor, /* construct */
     652             :     nullptr,               /* trace */
     653             : };
     654             : 
     655             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     656             :   {
     657             :     "Function",
     658             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     659             :     &sInterfaceObjectClassOps,
     660             :     JS_NULL_CLASS_SPEC,
     661             :     JS_NULL_CLASS_EXT,
     662             :     &sInterfaceObjectClassObjectOps
     663             :   },
     664             :   eInterface,
     665             :   true,
     666             :   prototypes::id::DOMException,
     667             :   PrototypeTraits<prototypes::id::DOMException>::Depth,
     668             :   sNativePropertyHooks,
     669             :   "function DOMException() {\n    [native code]\n}",
     670             :   JS::GetRealmFunctionPrototype
     671             : };
     672             : 
     673             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     674             :   {
     675             :     "DOMExceptionPrototype",
     676             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     677             :     JS_NULL_CLASS_OPS,
     678             :     JS_NULL_CLASS_SPEC,
     679             :     JS_NULL_CLASS_EXT,
     680             :     JS_NULL_OBJECT_OPS
     681             :   },
     682             :   eInterfacePrototype,
     683             :   false,
     684             :   prototypes::id::DOMException,
     685             :   PrototypeTraits<prototypes::id::DOMException>::Depth,
     686             :   sNativePropertyHooks,
     687             :   "[object DOMExceptionPrototype]",
     688             :   JS::GetRealmErrorPrototype
     689             : };
     690             : 
     691             : JSObject*
     692           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     693             : {
     694           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     695             : }
     696             : 
     697             : static const js::ClassOps sClassOps = {
     698             :   _addProperty, /* addProperty */
     699             :   nullptr,               /* delProperty */
     700             :   nullptr,               /* getProperty */
     701             :   nullptr,               /* setProperty */
     702             :   nullptr,               /* enumerate */
     703             :   nullptr, /* newEnumerate */
     704             :   nullptr, /* resolve */
     705             :   nullptr, /* mayResolve */
     706             :   _finalize, /* finalize */
     707             :   nullptr, /* call */
     708             :   nullptr,               /* hasInstance */
     709             :   nullptr,               /* construct */
     710             :   nullptr, /* trace */
     711             : };
     712             : 
     713             : static const js::ClassExtension sClassExtension = {
     714             :   nullptr, /* weakmapKeyDelegateOp */
     715             :   _objectMoved /* objectMovedOp */
     716             : };
     717             : 
     718             : static const DOMJSClass sClass = {
     719             :   { "DOMException",
     720             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     721             :     &sClassOps,
     722             :     JS_NULL_CLASS_SPEC,
     723             :     &sClassExtension,
     724             :     JS_NULL_OBJECT_OPS
     725             :   },
     726             :   { prototypes::id::DOMException, 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 },
     727             :   IsBaseOf<nsISupports, mozilla::dom::DOMException >::value,
     728             :   sNativePropertyHooks,
     729             :   FindAssociatedGlobalForNative<mozilla::dom::DOMException>::Get,
     730             :   GetProtoObjectHandle,
     731             :   GetCCParticipant<mozilla::dom::DOMException>::Get()
     732             : };
     733             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     734             :               "Must have the right minimal number of reserved slots.");
     735             : static_assert(1 >= 1,
     736             :               "Must have enough reserved slots.");
     737             : 
     738             : const JSClass*
     739           0 : GetJSClass()
     740             : {
     741           0 :   return sClass.ToJSClass();
     742             : }
     743             : 
     744             : bool
     745           0 : Wrap(JSContext* aCx, mozilla::dom::DOMException* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     746             : {
     747             :   MOZ_ASSERT(static_cast<mozilla::dom::DOMException*>(aObject) ==
     748             :              reinterpret_cast<mozilla::dom::DOMException*>(aObject),
     749             :              "Multiple inheritance for mozilla::dom::DOMException is broken.");
     750           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     751           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     752           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     753             :              "You should probably not be using Wrap() directly; use "
     754             :              "GetOrCreateDOMReflector instead");
     755             : 
     756           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     757             :              "nsISupports must be on our primary inheritance chain");
     758             : 
     759           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     760           0 :   if (!global) {
     761           0 :     return false;
     762             :   }
     763           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     764           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     765             : 
     766             :   // That might have ended up wrapping us already, due to the wonders
     767             :   // of XBL.  Check for that, and bail out as needed.
     768           0 :   aReflector.set(aCache->GetWrapper());
     769           0 :   if (aReflector) {
     770             : #ifdef DEBUG
     771           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     772             : #endif // DEBUG
     773           0 :     return true;
     774             :   }
     775             : 
     776           0 :   JSAutoCompartment ac(aCx, global);
     777           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     778           0 :   if (!canonicalProto) {
     779           0 :     return false;
     780             :   }
     781           0 :   JS::Rooted<JSObject*> proto(aCx);
     782           0 :   if (aGivenProto) {
     783           0 :     proto = aGivenProto;
     784             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     785             :     // coming in, we changed compartments to that of "parent" so may need
     786             :     // to wrap the proto here.
     787           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     788           0 :       if (!JS_WrapObject(aCx, &proto)) {
     789           0 :         return false;
     790             :       }
     791             :     }
     792             :   } else {
     793           0 :     proto = canonicalProto;
     794             :   }
     795             : 
     796           0 :   BindingJSObjectCreator<mozilla::dom::DOMException> creator(aCx);
     797           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     798           0 :   if (!aReflector) {
     799           0 :     return false;
     800             :   }
     801             : 
     802           0 :   aCache->SetWrapper(aReflector);
     803           0 :   creator.InitializationSucceeded();
     804             : 
     805           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     806             :              aCache->GetWrapperPreserveColor() == aReflector);
     807             :   // If proto != canonicalProto, we have to preserve our wrapper;
     808             :   // otherwise we won't be able to properly recreate it later, since
     809             :   // we won't know what proto to use.  Note that we don't check
     810             :   // aGivenProto here, since it's entirely possible (and even
     811             :   // somewhat common) to have a non-null aGivenProto which is the
     812             :   // same as canonicalProto.
     813           0 :   if (proto != canonicalProto) {
     814           0 :     PreserveWrapper(aObject);
     815             :   }
     816             : 
     817           0 :   return true;
     818             : }
     819             : 
     820             : const NativePropertyHooks sNativePropertyHooks[] = { {
     821             :   nullptr,
     822             :   nullptr,
     823             :   nullptr,
     824             :   { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
     825             :   prototypes::id::DOMException,
     826             :   constructors::id::DOMException,
     827             :   nullptr,
     828             :   &DefaultXrayExpandoObjectClass
     829             : } };
     830             : 
     831             : void
     832           1 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     833             : {
     834           2 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmErrorPrototype(aCx));
     835           1 :   if (!parentProto) {
     836           0 :     return;
     837             :   }
     838             : 
     839           2 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
     840           1 :   if (!constructorProto) {
     841           0 :     return;
     842             :   }
     843             : 
     844             :   static bool sIdsInited = false;
     845           1 :   if (!sIdsInited && NS_IsMainThread()) {
     846           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     847           0 :       return;
     848             :     }
     849           0 :     if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
     850           0 :       return;
     851             :     }
     852           0 :     sIdsInited = true;
     853             :   }
     854             : 
     855           1 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::DOMException);
     856           1 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::DOMException);
     857           3 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     858             :                               &sPrototypeClass.mBase, protoCache,
     859             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     860             :                               interfaceCache,
     861             :                               sNativeProperties.Upcast(),
     862           1 :                               nsContentUtils::ThreadsafeIsSystemCaller(aCx) ? sChromeOnlyNativeProperties.Upcast() : nullptr,
     863             :                               "DOMException", aDefineOnGlobal,
     864             :                               nullptr,
     865           1 :                               false);
     866             : }
     867             : 
     868             : JS::Handle<JSObject*>
     869           0 : GetProtoObjectHandle(JSContext* aCx)
     870             : {
     871             :   /* Get the interface prototype object for this class.  This will create the
     872             :      object as needed. */
     873           0 :   bool aDefineOnGlobal = true;
     874             : 
     875             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     876           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     877           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     878           0 :     return nullptr;
     879             :   }
     880             : 
     881             :   /* Check to see whether the interface objects are already installed */
     882           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     883           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::DOMException)) {
     884           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     885           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     886             :   }
     887             : 
     888             :   /*
     889             :    * The object might _still_ be null, but that's OK.
     890             :    *
     891             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     892             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     893             :    * changed after they have been set.
     894             :    *
     895             :    * Calling address() avoids the read read barrier that does gray
     896             :    * unmarking, but it's not possible for the object to be gray here.
     897             :    */
     898             : 
     899           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::DOMException);
     900           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     901           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     902             : }
     903             : 
     904             : JS::Handle<JSObject*>
     905           1 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     906             : {
     907             :   /* Get the interface object for this class.  This will create the object as
     908             :      needed. */
     909             : 
     910             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     911           1 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     912           1 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     913           0 :     return nullptr;
     914             :   }
     915             : 
     916             :   /* Check to see whether the interface objects are already installed */
     917           1 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     918           1 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::DOMException)) {
     919           2 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     920           1 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     921             :   }
     922             : 
     923             :   /*
     924             :    * The object might _still_ be null, but that's OK.
     925             :    *
     926             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     927             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     928             :    * changed after they have been set.
     929             :    *
     930             :    * Calling address() avoids the read read barrier that does gray
     931             :    * unmarking, but it's not possible for the object to be gray here.
     932             :    */
     933             : 
     934           1 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::DOMException);
     935           1 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     936           1 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     937             : }
     938             : 
     939             : JSObject*
     940           1 : GetConstructorObject(JSContext* aCx)
     941             : {
     942           1 :   return GetConstructorObjectHandle(aCx);
     943             : }
     944             : 
     945             : } // namespace DOMExceptionBinding
     946             : 
     947             : 
     948             : 
     949             : namespace ExceptionBinding {
     950             : 
     951             : static bool
     952           0 : __stringifier(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Exception* self, const JSJitMethodCallArgs& args)
     953             : {
     954           0 :   DOMString result;
     955           0 :   self->Stringify(cx, result);
     956           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     957           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     958           0 :     return false;
     959             :   }
     960           0 :   return true;
     961             : }
     962             : 
     963             : static const JSJitInfo __stringifier_methodinfo = {
     964             :   { (JSJitGetterOp)__stringifier },
     965             :   { prototypes::id::Exception },
     966             :   { PrototypeTraits<prototypes::id::Exception>::Depth },
     967             :   JSJitInfo::Method,
     968             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     969             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     970             :   false,  /* isInfallible. False in setters. */
     971             :   false,  /* isMovable.  Not relevant for setters. */
     972             :   false, /* isEliminatable.  Not relevant for setters. */
     973             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     974             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     975             :   false,  /* isTypedMethod.  Only relevant for methods. */
     976             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     977             : };
     978             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     979             : static_assert(0 < 1, "There is no slot for us");
     980             : 
     981             : static bool
     982           0 : get_message(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Exception* self, JSJitGetterCallArgs args)
     983             : {
     984           0 :   DOMString result;
     985           0 :   self->GetMessageMoz(result);
     986           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     987           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     988           0 :     return false;
     989             :   }
     990           0 :   return true;
     991             : }
     992             : 
     993             : static const JSJitInfo message_getterinfo = {
     994             :   { (JSJitGetterOp)get_message },
     995             :   { prototypes::id::Exception },
     996             :   { PrototypeTraits<prototypes::id::Exception>::Depth },
     997             :   JSJitInfo::Getter,
     998             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     999             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    1000             :   false,  /* isInfallible. False in setters. */
    1001             :   false,  /* isMovable.  Not relevant for setters. */
    1002             :   false, /* isEliminatable.  Not relevant for setters. */
    1003             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1004             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1005             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1006             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1007             : };
    1008             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1009             : static_assert(0 < 1, "There is no slot for us");
    1010             : 
    1011             : static bool
    1012           2 : get_result(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Exception* self, JSJitGetterCallArgs args)
    1013             : {
    1014           2 :   uint32_t result(self->Result());
    1015           2 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1016           2 :   args.rval().setNumber(result);
    1017           2 :   return true;
    1018             : }
    1019             : 
    1020             : static const JSJitInfo result_getterinfo = {
    1021             :   { (JSJitGetterOp)get_result },
    1022             :   { prototypes::id::Exception },
    1023             :   { PrototypeTraits<prototypes::id::Exception>::Depth },
    1024             :   JSJitInfo::Getter,
    1025             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1026             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    1027             :   true,  /* isInfallible. False in setters. */
    1028             :   false,  /* isMovable.  Not relevant for setters. */
    1029             :   false, /* isEliminatable.  Not relevant for setters. */
    1030             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1031             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1032             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1033             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1034             : };
    1035             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1036             : static_assert(0 < 1, "There is no slot for us");
    1037             : 
    1038             : static bool
    1039           0 : get_name(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Exception* self, JSJitGetterCallArgs args)
    1040             : {
    1041           0 :   DOMString result;
    1042           0 :   self->GetName(result);
    1043           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1044           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
    1045           0 :     return false;
    1046             :   }
    1047           0 :   return true;
    1048             : }
    1049             : 
    1050             : static const JSJitInfo name_getterinfo = {
    1051             :   { (JSJitGetterOp)get_name },
    1052             :   { prototypes::id::Exception },
    1053             :   { PrototypeTraits<prototypes::id::Exception>::Depth },
    1054             :   JSJitInfo::Getter,
    1055             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1056             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    1057             :   false,  /* isInfallible. False in setters. */
    1058             :   false,  /* isMovable.  Not relevant for setters. */
    1059             :   false, /* isEliminatable.  Not relevant for setters. */
    1060             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1061             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1062             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1063             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1064             : };
    1065             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1066             : static_assert(0 < 1, "There is no slot for us");
    1067             : 
    1068             : static bool
    1069           0 : get_filename(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Exception* self, JSJitGetterCallArgs args)
    1070             : {
    1071           0 :   DOMString result;
    1072           0 :   self->GetFilename(cx, result);
    1073           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1074           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
    1075           0 :     return false;
    1076             :   }
    1077           0 :   return true;
    1078             : }
    1079             : 
    1080             : static const JSJitInfo filename_getterinfo = {
    1081             :   { (JSJitGetterOp)get_filename },
    1082             :   { prototypes::id::Exception },
    1083             :   { PrototypeTraits<prototypes::id::Exception>::Depth },
    1084             :   JSJitInfo::Getter,
    1085             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1086             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    1087             :   false,  /* isInfallible. False in setters. */
    1088             :   false,  /* isMovable.  Not relevant for setters. */
    1089             :   false, /* isEliminatable.  Not relevant for setters. */
    1090             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1091             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1092             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1093             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1094             : };
    1095             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1096             : static_assert(0 < 1, "There is no slot for us");
    1097             : 
    1098             : static bool
    1099           0 : get_lineNumber(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Exception* self, JSJitGetterCallArgs args)
    1100             : {
    1101           0 :   uint32_t result(self->LineNumber(cx));
    1102           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1103           0 :   args.rval().setNumber(result);
    1104           0 :   return true;
    1105             : }
    1106             : 
    1107             : static const JSJitInfo lineNumber_getterinfo = {
    1108             :   { (JSJitGetterOp)get_lineNumber },
    1109             :   { prototypes::id::Exception },
    1110             :   { PrototypeTraits<prototypes::id::Exception>::Depth },
    1111             :   JSJitInfo::Getter,
    1112             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1113             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    1114             :   true,  /* isInfallible. False in setters. */
    1115             :   false,  /* isMovable.  Not relevant for setters. */
    1116             :   false, /* isEliminatable.  Not relevant for setters. */
    1117             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1118             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1119             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1120             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1121             : };
    1122             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1123             : static_assert(0 < 1, "There is no slot for us");
    1124             : 
    1125             : static bool
    1126           0 : get_columnNumber(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Exception* self, JSJitGetterCallArgs args)
    1127             : {
    1128           0 :   uint32_t result(self->ColumnNumber());
    1129           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1130           0 :   args.rval().setNumber(result);
    1131           0 :   return true;
    1132             : }
    1133             : 
    1134             : static const JSJitInfo columnNumber_getterinfo = {
    1135             :   { (JSJitGetterOp)get_columnNumber },
    1136             :   { prototypes::id::Exception },
    1137             :   { PrototypeTraits<prototypes::id::Exception>::Depth },
    1138             :   JSJitInfo::Getter,
    1139             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1140             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    1141             :   true,  /* isInfallible. False in setters. */
    1142             :   false,  /* isMovable.  Not relevant for setters. */
    1143             :   false, /* isEliminatable.  Not relevant for setters. */
    1144             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1145             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1146             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1147             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1148             : };
    1149             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1150             : static_assert(0 < 1, "There is no slot for us");
    1151             : 
    1152             : static bool
    1153           0 : get_location(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Exception* self, JSJitGetterCallArgs args)
    1154             : {
    1155           0 :   auto result(StrongOrRawPtr<nsIStackFrame>(self->GetLocation()));
    1156           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1157           0 :   if (!result) {
    1158           0 :     args.rval().setNull();
    1159           0 :     return true;
    1160             :   }
    1161           0 :   if (!WrapObject(cx, result, &NS_GET_IID(nsIStackFrame), args.rval())) {
    1162           0 :     return false;
    1163             :   }
    1164           0 :   return true;
    1165             : }
    1166             : 
    1167             : static const JSJitInfo location_getterinfo = {
    1168             :   { (JSJitGetterOp)get_location },
    1169             :   { prototypes::id::Exception },
    1170             :   { PrototypeTraits<prototypes::id::Exception>::Depth },
    1171             :   JSJitInfo::Getter,
    1172             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1173             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
    1174             :   false,  /* isInfallible. False in setters. */
    1175             :   false,  /* isMovable.  Not relevant for setters. */
    1176             :   false, /* isEliminatable.  Not relevant for setters. */
    1177             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1178             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1179             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1180             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1181             : };
    1182             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1183             : static_assert(0 < 1, "There is no slot for us");
    1184             : 
    1185             : static bool
    1186           0 : get_data(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Exception* self, JSJitGetterCallArgs args)
    1187             : {
    1188           0 :   auto result(StrongOrRawPtr<nsISupports>(self->GetData()));
    1189           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1190           0 :   if (!result) {
    1191           0 :     args.rval().setNull();
    1192           0 :     return true;
    1193             :   }
    1194           0 :   if (!WrapObject(cx, result, args.rval())) {
    1195           0 :     return false;
    1196             :   }
    1197           0 :   return true;
    1198             : }
    1199             : 
    1200             : static const JSJitInfo data_getterinfo = {
    1201             :   { (JSJitGetterOp)get_data },
    1202             :   { prototypes::id::Exception },
    1203             :   { PrototypeTraits<prototypes::id::Exception>::Depth },
    1204             :   JSJitInfo::Getter,
    1205             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1206             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
    1207             :   false,  /* isInfallible. False in setters. */
    1208             :   false,  /* isMovable.  Not relevant for setters. */
    1209             :   false, /* isEliminatable.  Not relevant for setters. */
    1210             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1211             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1212             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1213             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1214             : };
    1215             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1216             : static_assert(0 < 1, "There is no slot for us");
    1217             : 
    1218             : static bool
    1219           0 : get_stack(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Exception* self, JSJitGetterCallArgs args)
    1220             : {
    1221           0 :   binding_detail::FastErrorResult rv;
    1222           0 :   DOMString result;
    1223           0 :   self->GetStack(cx, result, rv);
    1224           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    1225           0 :     return false;
    1226             :   }
    1227           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1228           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
    1229           0 :     return false;
    1230             :   }
    1231           0 :   return true;
    1232             : }
    1233             : 
    1234             : static bool
    1235           0 : set_stack(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Exception* self, JSJitSetterCallArgs args)
    1236             : {
    1237           0 :   return JS_DefineProperty(cx, obj, "stack", args[0], JSPROP_ENUMERATE);
    1238             : }
    1239             : 
    1240             : static const JSJitInfo stack_getterinfo = {
    1241             :   { (JSJitGetterOp)get_stack },
    1242             :   { prototypes::id::Exception },
    1243             :   { PrototypeTraits<prototypes::id::Exception>::Depth },
    1244             :   JSJitInfo::Getter,
    1245             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1246             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    1247             :   false,  /* isInfallible. False in setters. */
    1248             :   false,  /* isMovable.  Not relevant for setters. */
    1249             :   false, /* isEliminatable.  Not relevant for setters. */
    1250             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1251             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1252             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1253             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1254             : };
    1255             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1256             : static_assert(0 < 1, "There is no slot for us");
    1257             : static const JSJitInfo stack_setterinfo = {
    1258             :   { (JSJitGetterOp)set_stack },
    1259             :   { prototypes::id::Exception },
    1260             :   { PrototypeTraits<prototypes::id::Exception>::Depth },
    1261             :   JSJitInfo::Setter,
    1262             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1263             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    1264             :   false,  /* isInfallible. False in setters. */
    1265             :   false,  /* isMovable.  Not relevant for setters. */
    1266             :   false, /* isEliminatable.  Not relevant for setters. */
    1267             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1268             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1269             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1270             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1271             : };
    1272             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1273             : static_assert(0 < 1, "There is no slot for us");
    1274             : 
    1275             : static bool
    1276           0 : genericLenientGetter(JSContext* cx, unsigned argc, JS::Value* vp)
    1277             : {
    1278           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
    1279           0 :   if (!args.thisv().isObject()) {
    1280           0 :     MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1281           0 :     if (!ReportLenientThisUnwrappingFailure(cx, &args.callee())) {
    1282           0 :       return false;
    1283             :     }
    1284           0 :     args.rval().set(JS::UndefinedValue());
    1285           0 :     return true;
    1286             :   }
    1287           0 :   JS::Rooted<JSObject*> obj(cx, &args.thisv().toObject());
    1288             : 
    1289             :   mozilla::dom::Exception* self;
    1290           0 :   JS::Rooted<JS::Value> rootSelf(cx, JS::ObjectValue(*obj));
    1291             :   {
    1292           0 :     nsresult rv = UnwrapObject<prototypes::id::Exception, mozilla::dom::Exception>(&rootSelf, self);
    1293           0 :     if (NS_FAILED(rv)) {
    1294           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1295           0 :       if (!ReportLenientThisUnwrappingFailure(cx, &args.callee())) {
    1296           0 :         return false;
    1297             :       }
    1298           0 :       args.rval().set(JS::UndefinedValue());
    1299           0 :       return true;
    1300             :     }
    1301             :   }
    1302           0 :   const JSJitInfo *info = FUNCTION_VALUE_TO_JITINFO(args.calleev());
    1303           0 :   MOZ_ASSERT(info->type() == JSJitInfo::Getter);
    1304           0 :   JSJitGetterOp getter = info->getter;
    1305           0 :   bool ok = getter(cx, obj, self, JSJitGetterCallArgs(args));
    1306             : #ifdef DEBUG
    1307           0 :   if (ok) {
    1308           0 :     AssertReturnTypeMatchesJitinfo(info, args.rval());
    1309             :   }
    1310             : #endif
    1311           0 :   return ok;
    1312             : }
    1313             : 
    1314             : static bool
    1315           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
    1316             : {
    1317           0 :   mozilla::dom::Exception* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Exception>(obj);
    1318             :   // We don't want to preserve if we don't have a wrapper, and we
    1319             :   // obviously can't preserve if we're not initialized.
    1320           0 :   if (self && self->GetWrapperPreserveColor()) {
    1321           0 :     PreserveWrapper(self);
    1322             :   }
    1323           0 :   return true;
    1324             : }
    1325             : 
    1326             : static void
    1327           0 : _finalize(js::FreeOp* fop, JSObject* obj)
    1328             : {
    1329           0 :   mozilla::dom::Exception* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Exception>(obj);
    1330           0 :   if (self) {
    1331           0 :     ClearWrapper(self, self, obj);
    1332           0 :     AddForDeferredFinalization<mozilla::dom::Exception>(self);
    1333             :   }
    1334           0 : }
    1335             : 
    1336             : static void
    1337           0 : _objectMoved(JSObject* obj, const JSObject* old)
    1338             : {
    1339           0 :   mozilla::dom::Exception* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Exception>(obj);
    1340           0 :   if (self) {
    1341           0 :     UpdateWrapper(self, self, obj, old);
    1342             :   }
    1343           0 : }
    1344             : 
    1345             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1346             : #if defined(__clang__)
    1347             : #pragma clang diagnostic push
    1348             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1349             : #endif
    1350             : static const JSFunctionSpec sMethods_specs[] = {
    1351             :   JS_FNSPEC("toString", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&__stringifier_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    1352             :   JS_FS_END
    1353             : };
    1354             : #if defined(__clang__)
    1355             : #pragma clang diagnostic pop
    1356             : #endif
    1357             : 
    1358             : 
    1359             : // Can't be const because the pref-enabled boolean needs to be writable
    1360             : static Prefable<const JSFunctionSpec> sMethods[] = {
    1361             :   { nullptr, &sMethods_specs[0] },
    1362             :   { nullptr, nullptr }
    1363             : };
    1364             : 
    1365             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1366             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1367             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1368             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1369             : 
    1370             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1371             : #if defined(__clang__)
    1372             : #pragma clang diagnostic push
    1373             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1374             : #endif
    1375             : static const JSPropertySpec sAttributes_specs[] = {
    1376             :   { "message", JSPROP_SHARED | JSPROP_ENUMERATE, genericLenientGetter, &message_getterinfo, nullptr, nullptr },
    1377             :   { "result", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &result_getterinfo, nullptr, nullptr },
    1378             :   { "name", JSPROP_SHARED | JSPROP_ENUMERATE, genericLenientGetter, &name_getterinfo, nullptr, nullptr },
    1379             :   { "filename", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &filename_getterinfo, nullptr, nullptr },
    1380             :   { "lineNumber", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &lineNumber_getterinfo, nullptr, nullptr },
    1381             :   { "columnNumber", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &columnNumber_getterinfo, nullptr, nullptr },
    1382             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
    1383             :   { "data", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &data_getterinfo, nullptr, nullptr },
    1384             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
    1385             :   { "stack", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &stack_getterinfo, GenericBindingSetter, &stack_setterinfo },
    1386             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
    1387             : };
    1388             : #if defined(__clang__)
    1389             : #pragma clang diagnostic pop
    1390             : #endif
    1391             : 
    1392             : static PrefableDisablers sAttributes_disablers7 = {
    1393             :   true, false, GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope, nullptr
    1394             : };
    1395             : 
    1396             : // Can't be const because the pref-enabled boolean needs to be writable
    1397             : static Prefable<const JSPropertySpec> sAttributes[] = {
    1398             :   { nullptr, &sAttributes_specs[0] },
    1399             :   { &sAttributes_disablers7, &sAttributes_specs[7] },
    1400             :   { nullptr, &sAttributes_specs[9] },
    1401             :   { nullptr, nullptr }
    1402             : };
    1403             : 
    1404             : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1405             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1406             : static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1407             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1408             : 
    1409             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1410             : #if defined(__clang__)
    1411             : #pragma clang diagnostic push
    1412             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1413             : #endif
    1414             : static const JSPropertySpec sChromeAttributes_specs[] = {
    1415             :   { "location", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &location_getterinfo, nullptr, nullptr },
    1416             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
    1417             : };
    1418             : #if defined(__clang__)
    1419             : #pragma clang diagnostic pop
    1420             : #endif
    1421             : 
    1422             : static PrefableDisablers sChromeAttributes_disablers0 = {
    1423             :   true, false, GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope, nullptr
    1424             : };
    1425             : 
    1426             : // Can't be const because the pref-enabled boolean needs to be writable
    1427             : static Prefable<const JSPropertySpec> sChromeAttributes[] = {
    1428             :   { &sChromeAttributes_disablers0, &sChromeAttributes_specs[0] },
    1429             :   { nullptr, nullptr }
    1430             : };
    1431             : 
    1432             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1433             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1434             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1435             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1436             : 
    1437             : 
    1438             : static uint16_t sNativeProperties_sortedPropertyIndices[9];
    1439             : static PropertyInfo sNativeProperties_propertyInfos[9];
    1440             : 
    1441             : static const NativePropertiesN<2> sNativeProperties = {
    1442             :   false, 0,
    1443             :   false, 0,
    1444             :   true,  0 /* sMethods */,
    1445             :   true,  1 /* sAttributes */,
    1446             :   false, 0,
    1447             :   false, 0,
    1448             :   false, 0,
    1449             :   -1,
    1450             :   9,
    1451             :   sNativeProperties_sortedPropertyIndices,
    1452             :   {
    1453             :     { sMethods, &sNativeProperties_propertyInfos[0] },
    1454             :     { sAttributes, &sNativeProperties_propertyInfos[1] }
    1455             :   }
    1456             : };
    1457             : static_assert(9 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
    1458             :     "We have a property info count that is oversized");
    1459             : 
    1460             : static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1];
    1461             : static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1];
    1462             : 
    1463             : static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
    1464             :   false, 0,
    1465             :   false, 0,
    1466             :   false, 0,
    1467             :   true,  0 /* sChromeAttributes */,
    1468             :   false, 0,
    1469             :   false, 0,
    1470             :   false, 0,
    1471             :   -1,
    1472             :   1,
    1473             :   sChromeOnlyNativeProperties_sortedPropertyIndices,
    1474             :   {
    1475             :     { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[0] }
    1476             :   }
    1477             : };
    1478             : static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
    1479             :     "We have a property info count that is oversized");
    1480             : 
    1481             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
    1482             :   {
    1483             :     "ExceptionPrototype",
    1484             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
    1485             :     JS_NULL_CLASS_OPS,
    1486             :     JS_NULL_CLASS_SPEC,
    1487             :     JS_NULL_CLASS_EXT,
    1488             :     JS_NULL_OBJECT_OPS
    1489             :   },
    1490             :   eInterfacePrototype,
    1491             :   false,
    1492             :   prototypes::id::Exception,
    1493             :   PrototypeTraits<prototypes::id::Exception>::Depth,
    1494             :   sNativePropertyHooks,
    1495             :   "[object ExceptionPrototype]",
    1496             :   JS::GetRealmObjectPrototype
    1497             : };
    1498             : 
    1499             : static const js::ClassOps sClassOps = {
    1500             :   _addProperty, /* addProperty */
    1501             :   nullptr,               /* delProperty */
    1502             :   nullptr,               /* getProperty */
    1503             :   nullptr,               /* setProperty */
    1504             :   nullptr,               /* enumerate */
    1505             :   nullptr, /* newEnumerate */
    1506             :   nullptr, /* resolve */
    1507             :   nullptr, /* mayResolve */
    1508             :   _finalize, /* finalize */
    1509             :   nullptr, /* call */
    1510             :   nullptr,               /* hasInstance */
    1511             :   nullptr,               /* construct */
    1512             :   nullptr, /* trace */
    1513             : };
    1514             : 
    1515             : static const js::ClassExtension sClassExtension = {
    1516             :   nullptr, /* weakmapKeyDelegateOp */
    1517             :   _objectMoved /* objectMovedOp */
    1518             : };
    1519             : 
    1520             : static const DOMJSClass sClass = {
    1521             :   { "Exception",
    1522             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
    1523             :     &sClassOps,
    1524             :     JS_NULL_CLASS_SPEC,
    1525             :     &sClassExtension,
    1526             :     JS_NULL_OBJECT_OPS
    1527             :   },
    1528             :   { prototypes::id::Exception, 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 },
    1529             :   IsBaseOf<nsISupports, mozilla::dom::Exception >::value,
    1530             :   sNativePropertyHooks,
    1531             :   FindAssociatedGlobalForNative<mozilla::dom::Exception>::Get,
    1532             :   GetProtoObjectHandle,
    1533             :   GetCCParticipant<mozilla::dom::Exception>::Get()
    1534             : };
    1535             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
    1536             :               "Must have the right minimal number of reserved slots.");
    1537             : static_assert(1 >= 1,
    1538             :               "Must have enough reserved slots.");
    1539             : 
    1540             : const JSClass*
    1541           0 : GetJSClass()
    1542             : {
    1543           0 :   return sClass.ToJSClass();
    1544             : }
    1545             : 
    1546             : bool
    1547        1979 : Wrap(JSContext* aCx, mozilla::dom::Exception* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
    1548             : {
    1549             :   MOZ_ASSERT(static_cast<mozilla::dom::Exception*>(aObject) ==
    1550             :              reinterpret_cast<mozilla::dom::Exception*>(aObject),
    1551             :              "Multiple inheritance for mozilla::dom::Exception is broken.");
    1552        1979 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
    1553        1979 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
    1554        1979 :   MOZ_ASSERT(!aCache->GetWrapper(),
    1555             :              "You should probably not be using Wrap() directly; use "
    1556             :              "GetOrCreateDOMReflector instead");
    1557             : 
    1558        1979 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
    1559             :              "nsISupports must be on our primary inheritance chain");
    1560             : 
    1561        3958 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
    1562        1979 :   if (!global) {
    1563           0 :     return false;
    1564             :   }
    1565        1979 :   MOZ_ASSERT(JS_IsGlobalObject(global));
    1566        1979 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
    1567             : 
    1568             :   // That might have ended up wrapping us already, due to the wonders
    1569             :   // of XBL.  Check for that, and bail out as needed.
    1570        1979 :   aReflector.set(aCache->GetWrapper());
    1571        1979 :   if (aReflector) {
    1572             : #ifdef DEBUG
    1573           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
    1574             : #endif // DEBUG
    1575           0 :     return true;
    1576             :   }
    1577             : 
    1578        3958 :   JSAutoCompartment ac(aCx, global);
    1579        1979 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
    1580        1979 :   if (!canonicalProto) {
    1581           0 :     return false;
    1582             :   }
    1583        3958 :   JS::Rooted<JSObject*> proto(aCx);
    1584        1979 :   if (aGivenProto) {
    1585           0 :     proto = aGivenProto;
    1586             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    1587             :     // coming in, we changed compartments to that of "parent" so may need
    1588             :     // to wrap the proto here.
    1589           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    1590           0 :       if (!JS_WrapObject(aCx, &proto)) {
    1591           0 :         return false;
    1592             :       }
    1593             :     }
    1594             :   } else {
    1595        1979 :     proto = canonicalProto;
    1596             :   }
    1597             : 
    1598        3958 :   BindingJSObjectCreator<mozilla::dom::Exception> creator(aCx);
    1599        1979 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
    1600        1979 :   if (!aReflector) {
    1601           0 :     return false;
    1602             :   }
    1603             : 
    1604        1979 :   aCache->SetWrapper(aReflector);
    1605        1979 :   creator.InitializationSucceeded();
    1606             : 
    1607        1979 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
    1608             :              aCache->GetWrapperPreserveColor() == aReflector);
    1609             :   // If proto != canonicalProto, we have to preserve our wrapper;
    1610             :   // otherwise we won't be able to properly recreate it later, since
    1611             :   // we won't know what proto to use.  Note that we don't check
    1612             :   // aGivenProto here, since it's entirely possible (and even
    1613             :   // somewhat common) to have a non-null aGivenProto which is the
    1614             :   // same as canonicalProto.
    1615        1979 :   if (proto != canonicalProto) {
    1616           0 :     PreserveWrapper(aObject);
    1617             :   }
    1618             : 
    1619        1979 :   return true;
    1620             : }
    1621             : 
    1622             : const NativePropertyHooks sNativePropertyHooks[] = { {
    1623             :   nullptr,
    1624             :   nullptr,
    1625             :   nullptr,
    1626             :   { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
    1627             :   prototypes::id::Exception,
    1628             :   constructors::id::_ID_Count,
    1629             :   nullptr,
    1630             :   &DefaultXrayExpandoObjectClass
    1631             : } };
    1632             : 
    1633             : void
    1634          21 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    1635             : {
    1636          42 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
    1637          21 :   if (!parentProto) {
    1638           0 :     return;
    1639             :   }
    1640             : 
    1641             :   static bool sIdsInited = false;
    1642          21 :   if (!sIdsInited && NS_IsMainThread()) {
    1643           2 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    1644           0 :       return;
    1645             :     }
    1646           2 :     if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
    1647           0 :       return;
    1648             :     }
    1649           2 :     sIdsInited = true;
    1650             :   }
    1651             : 
    1652          21 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::Exception);
    1653          21 :   JS::Heap<JSObject*>* interfaceCache = nullptr;
    1654          63 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    1655             :                               &sPrototypeClass.mBase, protoCache,
    1656             :                               nullptr, nullptr, 0, nullptr,
    1657             :                               interfaceCache,
    1658             :                               sNativeProperties.Upcast(),
    1659          21 :                               nsContentUtils::ThreadsafeIsSystemCaller(aCx) ? sChromeOnlyNativeProperties.Upcast() : nullptr,
    1660             :                               nullptr, aDefineOnGlobal,
    1661             :                               nullptr,
    1662          21 :                               false);
    1663             : }
    1664             : 
    1665             : JS::Handle<JSObject*>
    1666        1979 : GetProtoObjectHandle(JSContext* aCx)
    1667             : {
    1668             :   /* Get the interface prototype object for this class.  This will create the
    1669             :      object as needed. */
    1670        1979 :   bool aDefineOnGlobal = true;
    1671             : 
    1672             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    1673        1979 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    1674        1979 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    1675           0 :     return nullptr;
    1676             :   }
    1677             : 
    1678             :   /* Check to see whether the interface objects are already installed */
    1679        1979 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    1680        1979 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::Exception)) {
    1681          42 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1682          21 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1683             :   }
    1684             : 
    1685             :   /*
    1686             :    * The object might _still_ be null, but that's OK.
    1687             :    *
    1688             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1689             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1690             :    * changed after they have been set.
    1691             :    *
    1692             :    * Calling address() avoids the read read barrier that does gray
    1693             :    * unmarking, but it's not possible for the object to be gray here.
    1694             :    */
    1695             : 
    1696        1979 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::Exception);
    1697        1979 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1698        1979 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1699             : }
    1700             : 
    1701             : } // namespace ExceptionBinding
    1702             : 
    1703             : 
    1704             : 
    1705             : } // namespace dom
    1706             : } // namespace mozilla

Generated by: LCOV version 1.13