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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM Notification.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "AtomList.h"
       4             : #include "EventHandlerBinding.h"
       5             : #include "EventTargetBinding.h"
       6             : #include "NotificationBinding.h"
       7             : #include "WrapperFactory.h"
       8             : #include "jsapi.h"
       9             : #include "mozilla/OwningNonNull.h"
      10             : #include "mozilla/dom/BindingUtils.h"
      11             : #include "mozilla/dom/DOMJSClass.h"
      12             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      13             : #include "mozilla/dom/Notification.h"
      14             : #include "mozilla/dom/Nullable.h"
      15             : #include "mozilla/dom/PrimitiveConversions.h"
      16             : #include "mozilla/dom/Promise.h"
      17             : #include "mozilla/dom/ScriptSettings.h"
      18             : #include "mozilla/dom/SimpleGlobalObject.h"
      19             : #include "mozilla/dom/ToJSValue.h"
      20             : #include "mozilla/dom/XrayExpandoClass.h"
      21             : #include "nsISupports.h"
      22             : #include "xpcjsid.h"
      23             : 
      24             : namespace mozilla {
      25             : namespace dom {
      26             : 
      27             : namespace NotificationPermissionValues {
      28             : extern const EnumEntry strings[4] = {
      29             :   {"default", 7},
      30             :   {"denied", 6},
      31             :   {"granted", 7},
      32             :   { nullptr, 0 }
      33             : };
      34             : } // namespace NotificationPermissionValues
      35             : 
      36             : bool
      37           0 : ToJSValue(JSContext* aCx, NotificationPermission aArgument, JS::MutableHandle<JS::Value> aValue)
      38             : {
      39           0 :   MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(NotificationPermissionValues::strings));
      40             :   JSString* resultStr =
      41           0 :     JS_NewStringCopyN(aCx, NotificationPermissionValues::strings[uint32_t(aArgument)].value,
      42           0 :                       NotificationPermissionValues::strings[uint32_t(aArgument)].length);
      43           0 :   if (!resultStr) {
      44           0 :     return false;
      45             :   }
      46           0 :   aValue.setString(resultStr);
      47           0 :   return true;
      48             : }
      49             : 
      50             : 
      51             : namespace NotificationDirectionValues {
      52             : extern const EnumEntry strings[4] = {
      53             :   {"auto", 4},
      54             :   {"ltr", 3},
      55             :   {"rtl", 3},
      56             :   { nullptr, 0 }
      57             : };
      58             : } // namespace NotificationDirectionValues
      59             : 
      60             : bool
      61           0 : ToJSValue(JSContext* aCx, NotificationDirection aArgument, JS::MutableHandle<JS::Value> aValue)
      62             : {
      63           0 :   MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(NotificationDirectionValues::strings));
      64             :   JSString* resultStr =
      65           0 :     JS_NewStringCopyN(aCx, NotificationDirectionValues::strings[uint32_t(aArgument)].value,
      66           0 :                       NotificationDirectionValues::strings[uint32_t(aArgument)].length);
      67           0 :   if (!resultStr) {
      68           0 :     return false;
      69             :   }
      70           0 :   aValue.setString(resultStr);
      71           0 :   return true;
      72             : }
      73             : 
      74             : 
      75             : 
      76           0 : GetNotificationOptions::GetNotificationOptions()
      77             : {
      78             :   // Safe to pass a null context if we pass a null value
      79           0 :   Init(nullptr, JS::NullHandleValue);
      80           0 : }
      81             : 
      82             : 
      83             : 
      84             : bool
      85           0 : GetNotificationOptions::InitIds(JSContext* cx, GetNotificationOptionsAtoms* atomsCache)
      86             : {
      87           0 :   MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
      88             : 
      89             :   // Initialize these in reverse order so that any failure leaves the first one
      90             :   // uninitialized.
      91           0 :   if (!atomsCache->tag_id.init(cx, "tag")) {
      92           0 :     return false;
      93             :   }
      94           0 :   return true;
      95             : }
      96             : 
      97             : bool
      98           0 : GetNotificationOptions::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
      99             : {
     100             :   // Passing a null JSContext is OK only if we're initing from null,
     101             :   // Since in that case we will not have to do any property gets
     102             :   // Also evaluate isNullOrUndefined in order to avoid false-positive
     103             :   // checkers by static analysis tools
     104           0 :   MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
     105           0 :   GetNotificationOptionsAtoms* atomsCache = nullptr;
     106           0 :   if (cx) {
     107           0 :     atomsCache = GetAtomCache<GetNotificationOptionsAtoms>(cx);
     108           0 :     if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     109           0 :       return false;
     110             :     }
     111             :   }
     112             : 
     113           0 :   if (!IsConvertibleToDictionary(val)) {
     114           0 :     return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
     115             :   }
     116             : 
     117           0 :   bool isNull = val.isNullOrUndefined();
     118             :   // We only need these if !isNull, in which case we have |cx|.
     119           0 :   Maybe<JS::Rooted<JSObject *> > object;
     120           0 :   Maybe<JS::Rooted<JS::Value> > temp;
     121           0 :   if (!isNull) {
     122           0 :     MOZ_ASSERT(cx);
     123           0 :     object.emplace(cx, &val.toObject());
     124           0 :     temp.emplace(cx);
     125             :   }
     126           0 :   if (!isNull) {
     127           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->tag_id, temp.ptr())) {
     128           0 :       return false;
     129             :     }
     130             :   }
     131           0 :   if (!isNull && !temp->isUndefined()) {
     132           0 :     if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mTag)) {
     133           0 :       return false;
     134             :     }
     135             :   } else {
     136             :     static const char16_t data[] = { 0 };
     137           0 :     mTag.Rebind(data, ArrayLength(data) - 1);
     138             :   }
     139           0 :   mIsAnyMemberPresent = true;
     140           0 :   return true;
     141             : }
     142             : 
     143             : bool
     144           0 : GetNotificationOptions::Init(const nsAString& aJSON)
     145             : {
     146           0 :   AutoJSAPI jsapi;
     147           0 :   JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
     148           0 :   if (!cleanGlobal) {
     149           0 :     return false;
     150             :   }
     151           0 :   if (!jsapi.Init(cleanGlobal)) {
     152           0 :     return false;
     153             :   }
     154           0 :   JSContext* cx = jsapi.cx();
     155           0 :   JS::Rooted<JS::Value> json(cx);
     156           0 :   bool ok = ParseJSON(cx, aJSON, &json);
     157           0 :   NS_ENSURE_TRUE(ok, false);
     158           0 :   return Init(cx, json);
     159             : }
     160             : 
     161             : bool
     162           0 : GetNotificationOptions::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
     163             : {
     164           0 :   GetNotificationOptionsAtoms* atomsCache = GetAtomCache<GetNotificationOptionsAtoms>(cx);
     165           0 :   if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     166           0 :     return false;
     167             :   }
     168             : 
     169           0 :   JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
     170           0 :   if (!obj) {
     171           0 :     return false;
     172             :   }
     173           0 :   rval.set(JS::ObjectValue(*obj));
     174             : 
     175             :   do {
     176             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     177           0 :     JS::Rooted<JS::Value> temp(cx);
     178           0 :     nsString const & currentValue = mTag;
     179           0 :     if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
     180           0 :       return false;
     181             :     }
     182           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->tag_id, temp, JSPROP_ENUMERATE)) {
     183           0 :       return false;
     184             :     }
     185           0 :     break;
     186             :   } while(0);
     187             : 
     188           0 :   return true;
     189             : }
     190             : 
     191             : bool
     192           0 : GetNotificationOptions::ToJSON(nsAString& aJSON) const
     193             : {
     194           0 :   AutoJSAPI jsapi;
     195           0 :   jsapi.Init();
     196           0 :   JSContext *cx = jsapi.cx();
     197             :   // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
     198             :   // because we'll only be creating objects, in ways that have no
     199             :   // side-effects, followed by a call to JS::ToJSONMaybeSafely,
     200             :   // which likewise guarantees no side-effects for the sorts of
     201             :   // things we will pass it.
     202           0 :   JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
     203           0 :   JS::Rooted<JS::Value> val(cx);
     204           0 :   if (!ToObjectInternal(cx, &val)) {
     205           0 :     return false;
     206             :   }
     207           0 :   JS::Rooted<JSObject*> obj(cx, &val.toObject());
     208           0 :   return StringifyToJSON(cx, obj, aJSON);
     209             : }
     210             : 
     211             : void
     212           0 : GetNotificationOptions::TraceDictionary(JSTracer* trc)
     213             : {
     214           0 : }
     215             : 
     216             : GetNotificationOptions&
     217           0 : GetNotificationOptions::operator=(const GetNotificationOptions& aOther)
     218             : {
     219           0 :   mTag = aOther.mTag;
     220           0 :   return *this;
     221             : }
     222             : 
     223             : namespace binding_detail {
     224             : } // namespace binding_detail
     225             : 
     226             : 
     227             : 
     228           0 : NotificationBehavior::NotificationBehavior()
     229             : {
     230             :   // Safe to pass a null context if we pass a null value
     231           0 :   Init(nullptr, JS::NullHandleValue);
     232           0 : }
     233             : 
     234             : 
     235             : 
     236             : bool
     237           0 : NotificationBehavior::InitIds(JSContext* cx, NotificationBehaviorAtoms* atomsCache)
     238             : {
     239           0 :   MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
     240             : 
     241             :   // Initialize these in reverse order so that any failure leaves the first one
     242             :   // uninitialized.
     243           0 :   if (!atomsCache->vibrationPattern_id.init(cx, "vibrationPattern") ||
     244           0 :       !atomsCache->soundFile_id.init(cx, "soundFile") ||
     245           0 :       !atomsCache->showOnlyOnce_id.init(cx, "showOnlyOnce") ||
     246           0 :       !atomsCache->noscreen_id.init(cx, "noscreen") ||
     247           0 :       !atomsCache->noclear_id.init(cx, "noclear")) {
     248           0 :     return false;
     249             :   }
     250           0 :   return true;
     251             : }
     252             : 
     253             : bool
     254           0 : NotificationBehavior::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
     255             : {
     256             :   // Passing a null JSContext is OK only if we're initing from null,
     257             :   // Since in that case we will not have to do any property gets
     258             :   // Also evaluate isNullOrUndefined in order to avoid false-positive
     259             :   // checkers by static analysis tools
     260           0 :   MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
     261           0 :   NotificationBehaviorAtoms* atomsCache = nullptr;
     262           0 :   if (cx) {
     263           0 :     atomsCache = GetAtomCache<NotificationBehaviorAtoms>(cx);
     264           0 :     if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     265           0 :       return false;
     266             :     }
     267             :   }
     268             : 
     269           0 :   if (!IsConvertibleToDictionary(val)) {
     270           0 :     return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
     271             :   }
     272             : 
     273           0 :   bool isNull = val.isNullOrUndefined();
     274             :   // We only need these if !isNull, in which case we have |cx|.
     275           0 :   Maybe<JS::Rooted<JSObject *> > object;
     276           0 :   Maybe<JS::Rooted<JS::Value> > temp;
     277           0 :   if (!isNull) {
     278           0 :     MOZ_ASSERT(cx);
     279           0 :     object.emplace(cx, &val.toObject());
     280           0 :     temp.emplace(cx);
     281             :   }
     282           0 :   if (!isNull) {
     283           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->noclear_id, temp.ptr())) {
     284           0 :       return false;
     285             :     }
     286             :   }
     287           0 :   if (!isNull && !temp->isUndefined()) {
     288           0 :     if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mNoclear)) {
     289           0 :       return false;
     290             :     }
     291             :   } else {
     292           0 :     mNoclear = false;
     293             :   }
     294           0 :   mIsAnyMemberPresent = true;
     295             : 
     296           0 :   if (!isNull) {
     297           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->noscreen_id, temp.ptr())) {
     298           0 :       return false;
     299             :     }
     300             :   }
     301           0 :   if (!isNull && !temp->isUndefined()) {
     302           0 :     if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mNoscreen)) {
     303           0 :       return false;
     304             :     }
     305             :   } else {
     306           0 :     mNoscreen = false;
     307             :   }
     308           0 :   mIsAnyMemberPresent = true;
     309             : 
     310           0 :   if (!isNull) {
     311           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->showOnlyOnce_id, temp.ptr())) {
     312           0 :       return false;
     313             :     }
     314             :   }
     315           0 :   if (!isNull && !temp->isUndefined()) {
     316           0 :     if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mShowOnlyOnce)) {
     317           0 :       return false;
     318             :     }
     319             :   } else {
     320           0 :     mShowOnlyOnce = false;
     321             :   }
     322           0 :   mIsAnyMemberPresent = true;
     323             : 
     324           0 :   if (!isNull) {
     325           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->soundFile_id, temp.ptr())) {
     326           0 :       return false;
     327             :     }
     328             :   }
     329           0 :   if (!isNull && !temp->isUndefined()) {
     330           0 :     if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mSoundFile)) {
     331           0 :       return false;
     332             :     }
     333             :   } else {
     334             :     static const char16_t data[] = { 0 };
     335           0 :     mSoundFile.Rebind(data, ArrayLength(data) - 1);
     336             :   }
     337           0 :   mIsAnyMemberPresent = true;
     338             : 
     339           0 :   if (!isNull) {
     340           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->vibrationPattern_id, temp.ptr())) {
     341           0 :       return false;
     342             :     }
     343             :   }
     344           0 :   if (!isNull && !temp->isUndefined()) {
     345           0 :     mVibrationPattern.Construct();
     346           0 :     if (temp.ref().isObject()) {
     347           0 :       JS::ForOfIterator iter(cx);
     348           0 :       if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
     349           0 :         return false;
     350             :       }
     351           0 :       if (!iter.valueIsIterable()) {
     352           0 :         ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'vibrationPattern' member of NotificationBehavior");
     353           0 :         return false;
     354             :       }
     355           0 :       Sequence<uint32_t> &arr = (mVibrationPattern.Value());
     356           0 :       JS::Rooted<JS::Value> temp(cx);
     357             :       while (true) {
     358             :         bool done;
     359           0 :         if (!iter.next(&temp, &done)) {
     360           0 :           return false;
     361             :         }
     362           0 :         if (done) {
     363           0 :           break;
     364             :         }
     365           0 :         uint32_t* slotPtr = arr.AppendElement(mozilla::fallible);
     366           0 :         if (!slotPtr) {
     367           0 :           JS_ReportOutOfMemory(cx);
     368           0 :           return false;
     369             :         }
     370           0 :         uint32_t& slot = *slotPtr;
     371           0 :         if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp, &slot)) {
     372           0 :           return false;
     373             :         }
     374           0 :       }
     375             :     } else {
     376           0 :       ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'vibrationPattern' member of NotificationBehavior");
     377           0 :       return false;
     378             :     }
     379           0 :     mIsAnyMemberPresent = true;
     380             :   }
     381           0 :   return true;
     382             : }
     383             : 
     384             : bool
     385           0 : NotificationBehavior::Init(const nsAString& aJSON)
     386             : {
     387           0 :   AutoJSAPI jsapi;
     388           0 :   JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
     389           0 :   if (!cleanGlobal) {
     390           0 :     return false;
     391             :   }
     392           0 :   if (!jsapi.Init(cleanGlobal)) {
     393           0 :     return false;
     394             :   }
     395           0 :   JSContext* cx = jsapi.cx();
     396           0 :   JS::Rooted<JS::Value> json(cx);
     397           0 :   bool ok = ParseJSON(cx, aJSON, &json);
     398           0 :   NS_ENSURE_TRUE(ok, false);
     399           0 :   return Init(cx, json);
     400             : }
     401             : 
     402             : bool
     403           0 : NotificationBehavior::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
     404             : {
     405           0 :   NotificationBehaviorAtoms* atomsCache = GetAtomCache<NotificationBehaviorAtoms>(cx);
     406           0 :   if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     407           0 :     return false;
     408             :   }
     409             : 
     410           0 :   JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
     411           0 :   if (!obj) {
     412           0 :     return false;
     413             :   }
     414           0 :   rval.set(JS::ObjectValue(*obj));
     415             : 
     416             :   do {
     417             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     418           0 :     JS::Rooted<JS::Value> temp(cx);
     419           0 :     bool const & currentValue = mNoclear;
     420           0 :     temp.setBoolean(currentValue);
     421           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->noclear_id, temp, JSPROP_ENUMERATE)) {
     422           0 :       return false;
     423             :     }
     424           0 :     break;
     425             :   } while(0);
     426             : 
     427             :   do {
     428             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     429           0 :     JS::Rooted<JS::Value> temp(cx);
     430           0 :     bool const & currentValue = mNoscreen;
     431           0 :     temp.setBoolean(currentValue);
     432           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->noscreen_id, temp, JSPROP_ENUMERATE)) {
     433           0 :       return false;
     434             :     }
     435           0 :     break;
     436             :   } while(0);
     437             : 
     438             :   do {
     439             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     440           0 :     JS::Rooted<JS::Value> temp(cx);
     441           0 :     bool const & currentValue = mShowOnlyOnce;
     442           0 :     temp.setBoolean(currentValue);
     443           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->showOnlyOnce_id, temp, JSPROP_ENUMERATE)) {
     444           0 :       return false;
     445             :     }
     446           0 :     break;
     447             :   } while(0);
     448             : 
     449             :   do {
     450             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     451           0 :     JS::Rooted<JS::Value> temp(cx);
     452           0 :     nsString const & currentValue = mSoundFile;
     453           0 :     if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
     454           0 :       return false;
     455             :     }
     456           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->soundFile_id, temp, JSPROP_ENUMERATE)) {
     457           0 :       return false;
     458             :     }
     459           0 :     break;
     460             :   } while(0);
     461             : 
     462           0 :   if (mVibrationPattern.WasPassed()) {
     463             :     do {
     464             :       // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     465           0 :       JS::Rooted<JS::Value> temp(cx);
     466           0 :       Sequence<uint32_t> const & currentValue = mVibrationPattern.InternalValue();
     467             : 
     468           0 :       uint32_t length = currentValue.Length();
     469           0 :       JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
     470           0 :       if (!returnArray) {
     471           0 :         return false;
     472             :       }
     473             :       // Scope for 'tmp'
     474             :       {
     475           0 :         JS::Rooted<JS::Value> tmp(cx);
     476           0 :         for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
     477             :           // Control block to let us common up the JS_DefineElement calls when there
     478             :           // are different ways to succeed at wrapping the object.
     479             :           do {
     480           0 :             tmp.setNumber(currentValue[sequenceIdx0]);
     481           0 :             break;
     482             :           } while (0);
     483           0 :           if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
     484             :                                 JSPROP_ENUMERATE)) {
     485           0 :             return false;
     486             :           }
     487             :         }
     488             :       }
     489           0 :       temp.setObject(*returnArray);
     490           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->vibrationPattern_id, temp, JSPROP_ENUMERATE)) {
     491           0 :         return false;
     492             :       }
     493           0 :       break;
     494             :     } while(0);
     495             :   }
     496             : 
     497           0 :   return true;
     498             : }
     499             : 
     500             : bool
     501           0 : NotificationBehavior::ToJSON(nsAString& aJSON) const
     502             : {
     503           0 :   AutoJSAPI jsapi;
     504           0 :   jsapi.Init();
     505           0 :   JSContext *cx = jsapi.cx();
     506             :   // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
     507             :   // because we'll only be creating objects, in ways that have no
     508             :   // side-effects, followed by a call to JS::ToJSONMaybeSafely,
     509             :   // which likewise guarantees no side-effects for the sorts of
     510             :   // things we will pass it.
     511           0 :   JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
     512           0 :   JS::Rooted<JS::Value> val(cx);
     513           0 :   if (!ToObjectInternal(cx, &val)) {
     514           0 :     return false;
     515             :   }
     516           0 :   JS::Rooted<JSObject*> obj(cx, &val.toObject());
     517           0 :   return StringifyToJSON(cx, obj, aJSON);
     518             : }
     519             : 
     520             : void
     521           0 : NotificationBehavior::TraceDictionary(JSTracer* trc)
     522             : {
     523           0 : }
     524             : 
     525             : NotificationBehavior&
     526           0 : NotificationBehavior::operator=(const NotificationBehavior& aOther)
     527             : {
     528           0 :   mNoclear = aOther.mNoclear;
     529           0 :   mNoscreen = aOther.mNoscreen;
     530           0 :   mShowOnlyOnce = aOther.mShowOnlyOnce;
     531           0 :   mSoundFile = aOther.mSoundFile;
     532           0 :   mVibrationPattern.Reset();
     533           0 :   if (aOther.mVibrationPattern.WasPassed()) {
     534           0 :     mVibrationPattern.Construct(aOther.mVibrationPattern.Value());
     535             :   }
     536           0 :   return *this;
     537             : }
     538             : 
     539             : namespace binding_detail {
     540             : } // namespace binding_detail
     541             : 
     542             : 
     543             : 
     544           0 : NotificationOptions::NotificationOptions()
     545             :   : mData(JS::UndefinedValue()),
     546           0 :     mMozbehavior(FastDictionaryInitializer())
     547             : {
     548             :   // Safe to pass a null context if we pass a null value
     549           0 :   Init(nullptr, JS::NullHandleValue);
     550           0 : }
     551             : 
     552             : 
     553             : bool
     554           0 : NotificationOptions::InitIds(JSContext* cx, NotificationOptionsAtoms* atomsCache)
     555             : {
     556           0 :   MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
     557             : 
     558             :   // Initialize these in reverse order so that any failure leaves the first one
     559             :   // uninitialized.
     560           0 :   if (!atomsCache->tag_id.init(cx, "tag") ||
     561           0 :       !atomsCache->requireInteraction_id.init(cx, "requireInteraction") ||
     562           0 :       !atomsCache->mozbehavior_id.init(cx, "mozbehavior") ||
     563           0 :       !atomsCache->lang_id.init(cx, "lang") ||
     564           0 :       !atomsCache->icon_id.init(cx, "icon") ||
     565           0 :       !atomsCache->dir_id.init(cx, "dir") ||
     566           0 :       !atomsCache->data_id.init(cx, "data") ||
     567           0 :       !atomsCache->body_id.init(cx, "body")) {
     568           0 :     return false;
     569             :   }
     570           0 :   return true;
     571             : }
     572             : 
     573             : bool
     574           0 : NotificationOptions::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
     575             : {
     576             :   // Passing a null JSContext is OK only if we're initing from null,
     577             :   // Since in that case we will not have to do any property gets
     578             :   // Also evaluate isNullOrUndefined in order to avoid false-positive
     579             :   // checkers by static analysis tools
     580           0 :   MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
     581           0 :   NotificationOptionsAtoms* atomsCache = nullptr;
     582           0 :   if (cx) {
     583           0 :     atomsCache = GetAtomCache<NotificationOptionsAtoms>(cx);
     584           0 :     if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     585           0 :       return false;
     586             :     }
     587             :   }
     588             : 
     589           0 :   if (!IsConvertibleToDictionary(val)) {
     590           0 :     return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
     591             :   }
     592             : 
     593           0 :   bool isNull = val.isNullOrUndefined();
     594             :   // We only need these if !isNull, in which case we have |cx|.
     595           0 :   Maybe<JS::Rooted<JSObject *> > object;
     596           0 :   Maybe<JS::Rooted<JS::Value> > temp;
     597           0 :   if (!isNull) {
     598           0 :     MOZ_ASSERT(cx);
     599           0 :     object.emplace(cx, &val.toObject());
     600           0 :     temp.emplace(cx);
     601             :   }
     602           0 :   if (!isNull) {
     603           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->body_id, temp.ptr())) {
     604           0 :       return false;
     605             :     }
     606             :   }
     607           0 :   if (!isNull && !temp->isUndefined()) {
     608           0 :     if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mBody)) {
     609           0 :       return false;
     610             :     }
     611             :   } else {
     612             :     static const char16_t data[] = { 0 };
     613           0 :     mBody.Rebind(data, ArrayLength(data) - 1);
     614             :   }
     615           0 :   mIsAnyMemberPresent = true;
     616             : 
     617           0 :   if (!isNull) {
     618           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->data_id, temp.ptr())) {
     619           0 :       return false;
     620             :     }
     621             :   }
     622           0 :   if (!isNull && !temp->isUndefined()) {
     623             : #ifdef __clang__
     624             : #pragma clang diagnostic push
     625             : #pragma clang diagnostic ignored "-Wunreachable-code"
     626             : #pragma clang diagnostic ignored "-Wunreachable-code-return"
     627             : #endif // __clang__
     628           0 :     if ((passedToJSImpl) && !CallerSubsumes(temp.ref())) {
     629           0 :       ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "'data' member of NotificationOptions");
     630           0 :       return false;
     631             :     }
     632             : #ifdef __clang__
     633             : #pragma clang diagnostic pop
     634             : #endif // __clang__
     635           0 :     mData = temp.ref();
     636             :   } else {
     637           0 :     mData = JS::NullValue();
     638             :   }
     639           0 :   mIsAnyMemberPresent = true;
     640             : 
     641           0 :   if (!isNull) {
     642           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->dir_id, temp.ptr())) {
     643           0 :       return false;
     644             :     }
     645             :   }
     646           0 :   if (!isNull && !temp->isUndefined()) {
     647             :     {
     648             :       int index;
     649           0 :       if (!FindEnumStringIndex<true>(cx, temp.ref(), NotificationDirectionValues::strings, "NotificationDirection", "'dir' member of NotificationOptions", &index)) {
     650           0 :         return false;
     651             :       }
     652           0 :       MOZ_ASSERT(index >= 0);
     653           0 :       mDir = static_cast<NotificationDirection>(index);
     654             :     }
     655             :   } else {
     656           0 :     mDir = NotificationDirection::Auto;
     657             :   }
     658           0 :   mIsAnyMemberPresent = true;
     659             : 
     660           0 :   if (!isNull) {
     661           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->icon_id, temp.ptr())) {
     662           0 :       return false;
     663             :     }
     664             :   }
     665           0 :   if (!isNull && !temp->isUndefined()) {
     666           0 :     if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mIcon)) {
     667           0 :       return false;
     668             :     }
     669             :   } else {
     670             :     static const char16_t data[] = { 0 };
     671           0 :     mIcon.Rebind(data, ArrayLength(data) - 1);
     672             :   }
     673           0 :   mIsAnyMemberPresent = true;
     674             : 
     675           0 :   if (!isNull) {
     676           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->lang_id, temp.ptr())) {
     677           0 :       return false;
     678             :     }
     679             :   }
     680           0 :   if (!isNull && !temp->isUndefined()) {
     681           0 :     if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mLang)) {
     682           0 :       return false;
     683             :     }
     684             :   } else {
     685             :     static const char16_t data[] = { 0 };
     686           0 :     mLang.Rebind(data, ArrayLength(data) - 1);
     687             :   }
     688           0 :   mIsAnyMemberPresent = true;
     689             : 
     690           0 :   if (!isNull) {
     691           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->mozbehavior_id, temp.ptr())) {
     692           0 :       return false;
     693             :     }
     694             :   }
     695           0 :   if (!mMozbehavior.Init(cx, (!isNull && !temp->isUndefined()) ? temp.ref() : JS::NullHandleValue,  "'mozbehavior' member of NotificationOptions", passedToJSImpl)) {
     696           0 :     return false;
     697             :   }
     698           0 :   mIsAnyMemberPresent = true;
     699             : 
     700           0 :   if (!isNull) {
     701           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->requireInteraction_id, temp.ptr())) {
     702           0 :       return false;
     703             :     }
     704             :   }
     705           0 :   if (!isNull && !temp->isUndefined()) {
     706           0 :     if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mRequireInteraction)) {
     707           0 :       return false;
     708             :     }
     709             :   } else {
     710           0 :     mRequireInteraction = false;
     711             :   }
     712           0 :   mIsAnyMemberPresent = true;
     713             : 
     714           0 :   if (!isNull) {
     715           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->tag_id, temp.ptr())) {
     716           0 :       return false;
     717             :     }
     718             :   }
     719           0 :   if (!isNull && !temp->isUndefined()) {
     720           0 :     if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mTag)) {
     721           0 :       return false;
     722             :     }
     723             :   } else {
     724             :     static const char16_t data[] = { 0 };
     725           0 :     mTag.Rebind(data, ArrayLength(data) - 1);
     726             :   }
     727           0 :   mIsAnyMemberPresent = true;
     728           0 :   return true;
     729             : }
     730             : 
     731             : bool
     732           0 : NotificationOptions::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
     733             : {
     734           0 :   NotificationOptionsAtoms* atomsCache = GetAtomCache<NotificationOptionsAtoms>(cx);
     735           0 :   if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     736           0 :     return false;
     737             :   }
     738             : 
     739           0 :   JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
     740           0 :   if (!obj) {
     741           0 :     return false;
     742             :   }
     743           0 :   rval.set(JS::ObjectValue(*obj));
     744             : 
     745             :   do {
     746             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     747           0 :     JS::Rooted<JS::Value> temp(cx);
     748           0 :     nsString const & currentValue = mBody;
     749           0 :     if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
     750           0 :       return false;
     751             :     }
     752           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->body_id, temp, JSPROP_ENUMERATE)) {
     753           0 :       return false;
     754             :     }
     755           0 :     break;
     756             :   } while(0);
     757             : 
     758             :   do {
     759             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     760           0 :     JS::Rooted<JS::Value> temp(cx);
     761           0 :     JS::Value const & currentValue = mData;
     762           0 :     JS::ExposeValueToActiveJS(currentValue);
     763           0 :     temp.set(currentValue);
     764           0 :     if (!MaybeWrapValue(cx, &temp)) {
     765           0 :       return false;
     766             :     }
     767           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->data_id, temp, JSPROP_ENUMERATE)) {
     768           0 :       return false;
     769             :     }
     770           0 :     break;
     771             :   } while(0);
     772             : 
     773             :   do {
     774             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     775           0 :     JS::Rooted<JS::Value> temp(cx);
     776           0 :     NotificationDirection const & currentValue = mDir;
     777           0 :     if (!ToJSValue(cx, currentValue, &temp)) {
     778           0 :       return false;
     779             :     }
     780           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->dir_id, temp, JSPROP_ENUMERATE)) {
     781           0 :       return false;
     782             :     }
     783           0 :     break;
     784             :   } while(0);
     785             : 
     786             :   do {
     787             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     788           0 :     JS::Rooted<JS::Value> temp(cx);
     789           0 :     nsString const & currentValue = mIcon;
     790           0 :     if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
     791           0 :       return false;
     792             :     }
     793           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->icon_id, temp, JSPROP_ENUMERATE)) {
     794           0 :       return false;
     795             :     }
     796           0 :     break;
     797             :   } while(0);
     798             : 
     799             :   do {
     800             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     801           0 :     JS::Rooted<JS::Value> temp(cx);
     802           0 :     nsString const & currentValue = mLang;
     803           0 :     if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
     804           0 :       return false;
     805             :     }
     806           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->lang_id, temp, JSPROP_ENUMERATE)) {
     807           0 :       return false;
     808             :     }
     809           0 :     break;
     810             :   } while(0);
     811             : 
     812             :   do {
     813             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     814           0 :     JS::Rooted<JS::Value> temp(cx);
     815           0 :     NotificationBehavior const & currentValue = mMozbehavior;
     816           0 :     if (!currentValue.ToObjectInternal(cx, &temp)) {
     817           0 :       return false;
     818             :     }
     819           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->mozbehavior_id, temp, JSPROP_ENUMERATE)) {
     820           0 :       return false;
     821             :     }
     822           0 :     break;
     823             :   } while(0);
     824             : 
     825             :   do {
     826             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     827           0 :     JS::Rooted<JS::Value> temp(cx);
     828           0 :     bool const & currentValue = mRequireInteraction;
     829           0 :     temp.setBoolean(currentValue);
     830           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->requireInteraction_id, temp, JSPROP_ENUMERATE)) {
     831           0 :       return false;
     832             :     }
     833           0 :     break;
     834             :   } while(0);
     835             : 
     836             :   do {
     837             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     838           0 :     JS::Rooted<JS::Value> temp(cx);
     839           0 :     nsString const & currentValue = mTag;
     840           0 :     if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
     841           0 :       return false;
     842             :     }
     843           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->tag_id, temp, JSPROP_ENUMERATE)) {
     844           0 :       return false;
     845             :     }
     846           0 :     break;
     847             :   } while(0);
     848             : 
     849           0 :   return true;
     850             : }
     851             : 
     852             : void
     853           0 : NotificationOptions::TraceDictionary(JSTracer* trc)
     854             : {
     855           0 :   JS::UnsafeTraceRoot(trc, &mData, "NotificationOptions.mData");
     856           0 : }
     857             : 
     858             : namespace binding_detail {
     859             : } // namespace binding_detail
     860             : 
     861             : 
     862             : void
     863           0 : NotificationPermissionCallback::Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, NotificationPermission permission, ErrorResult& aRv)
     864             : {
     865           0 :   JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
     866           0 :   JS::AutoValueVector argv(cx);
     867           0 :   if (!argv.resize(1)) {
     868           0 :     aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
     869           0 :     return;
     870             :   }
     871           0 :   unsigned argc = 1;
     872             : 
     873             :   do {
     874           0 :     if (!ToJSValue(cx, permission, argv[0])) {
     875           0 :       aRv.Throw(NS_ERROR_UNEXPECTED);
     876           0 :       return;
     877             :     }
     878           0 :     break;
     879             :   } while (0);
     880             : 
     881           0 :   JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
     882           0 :   if (!JS::Call(cx, aThisVal, callable,
     883           0 :                 JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
     884           0 :     aRv.NoteJSContextException(cx);
     885           0 :     return;
     886             :   }
     887             : }
     888             : 
     889             : 
     890             : 
     891             : namespace binding_detail {
     892             : } // namespace binding_detail
     893             : 
     894             : 
     895             : namespace NotificationBinding {
     896             : 
     897             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTargetBinding::NativeType>::value,
     898             :               "Can't inherit from an interface with a different ownership model.");
     899             : 
     900             : static bool
     901           0 : get_permission(JSContext* cx, unsigned argc, JS::Value* vp)
     902             : {
     903           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     904           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     905             : 
     906           0 :   if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) {
     907             :       // Return false from the JSNative in order to trigger
     908             :       // an uncatchable exception.
     909           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
     910           0 :       return false;
     911             :   }
     912           0 :   GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
     913           0 :   if (global.Failed()) {
     914           0 :     return false;
     915             :   }
     916             : 
     917           0 :   binding_detail::FastErrorResult rv;
     918           0 :   NotificationPermission result(mozilla::dom::Notification::GetPermission(global, rv));
     919           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     920           0 :     return false;
     921             :   }
     922           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     923           0 :   if (!ToJSValue(cx, result, args.rval())) {
     924           0 :     return false;
     925             :   }
     926           0 :   return true;
     927             : }
     928             : 
     929             : static bool
     930           0 : requestPermission(JSContext* cx, unsigned argc, JS::Value* vp)
     931             : {
     932           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     933           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     934             : 
     935           0 :   if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) {
     936             :       // Return false from the JSNative in order to trigger
     937             :       // an uncatchable exception.
     938           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
     939           0 :       return false;
     940             :   }
     941           0 :   GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
     942           0 :   if (global.Failed()) {
     943           0 :     return false;
     944             :   }
     945             : 
     946           0 :   Optional<OwningNonNull<NotificationPermissionCallback>> arg0;
     947           0 :   if (args.hasDefined(0)) {
     948           0 :     arg0.Construct();
     949           0 :     if (args[0].isObject()) {
     950           0 :       if (JS::IsCallable(&args[0].toObject())) {
     951             :       { // scope for tempRoot
     952           0 :         JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
     953           0 :         arg0.Value() = new NotificationPermissionCallback(cx, tempRoot, GetIncumbentGlobal());
     954             :       }
     955             :       } else {
     956           0 :         ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "Argument 1 of Notification.requestPermission");
     957           0 :         return false;
     958             :       }
     959             :     } else {
     960           0 :       ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Notification.requestPermission");
     961           0 :       return false;
     962             :     }
     963             :   }
     964           0 :   binding_detail::FastErrorResult rv;
     965           0 :   auto result(StrongOrRawPtr<Promise>(mozilla::dom::Notification::RequestPermission(global, NonNullHelper(Constify(arg0)), rv)));
     966           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     967           0 :     return false;
     968             :   }
     969           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     970           0 :   if (!ToJSValue(cx, result, args.rval())) {
     971           0 :     return false;
     972             :   }
     973           0 :   return true;
     974             : }
     975             : 
     976             : 
     977             : static const JSJitInfo requestPermission_methodinfo = {
     978             :   { (JSJitGetterOp)requestPermission },
     979             :   { prototypes::id::_ID_Count }, { 0 }, JSJitInfo::StaticMethod,
     980             :   JSJitInfo::AliasEverything, JSVAL_TYPE_MISSING, false, false,
     981             :   false, false, 0
     982             : };
     983             : 
     984             : static bool
     985           0 : get(JSContext* cx, unsigned argc, JS::Value* vp)
     986             : {
     987           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     988           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     989             : 
     990           0 :   if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) {
     991             :       // Return false from the JSNative in order to trigger
     992             :       // an uncatchable exception.
     993           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
     994           0 :       return false;
     995             :   }
     996           0 :   GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
     997           0 :   if (global.Failed()) {
     998           0 :     return false;
     999             :   }
    1000             : 
    1001           0 :   binding_detail::FastGetNotificationOptions arg0;
    1002           0 :   if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue,  "Argument 1 of Notification.get", false)) {
    1003           0 :     return false;
    1004             :   }
    1005           0 :   binding_detail::FastErrorResult rv;
    1006           0 :   auto result(StrongOrRawPtr<Promise>(mozilla::dom::Notification::Get(global, Constify(arg0), rv)));
    1007           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    1008           0 :     return false;
    1009             :   }
    1010           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1011           0 :   if (!ToJSValue(cx, result, args.rval())) {
    1012           0 :     return false;
    1013             :   }
    1014           0 :   return true;
    1015             : }
    1016             : 
    1017             : 
    1018             : static const JSJitInfo get_methodinfo = {
    1019             :   { (JSJitGetterOp)get },
    1020             :   { prototypes::id::_ID_Count }, { 0 }, JSJitInfo::StaticMethod,
    1021             :   JSJitInfo::AliasEverything, JSVAL_TYPE_MISSING, false, false,
    1022             :   false, false, 0
    1023             : };
    1024             : 
    1025             : static bool
    1026           0 : get_onclick(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Notification* self, JSJitGetterCallArgs args)
    1027             : {
    1028           0 :   if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) {
    1029             :       // Return false from the JSNative in order to trigger
    1030             :       // an uncatchable exception.
    1031           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1032           0 :       return false;
    1033             :   }
    1034           0 :   RefPtr<EventHandlerNonNull> result(self->GetOnclick());
    1035           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1036           0 :   if (result) {
    1037           0 :     args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
    1038           0 :     if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
    1039           0 :       return false;
    1040             :     }
    1041           0 :     return true;
    1042             :   } else {
    1043           0 :     args.rval().setNull();
    1044           0 :     return true;
    1045             :   }
    1046             : }
    1047             : 
    1048             : static bool
    1049           0 : set_onclick(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Notification* self, JSJitSetterCallArgs args)
    1050             : {
    1051           0 :   if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) {
    1052             :       // Return false from the JSNative in order to trigger
    1053             :       // an uncatchable exception.
    1054           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1055           0 :       return false;
    1056             :   }
    1057           0 :   RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
    1058           0 :   if (args[0].isObject()) {
    1059             :     { // scope for tempRoot
    1060           0 :       JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
    1061           0 :       arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
    1062             :     }
    1063             :   } else {
    1064           0 :     arg0 = nullptr;
    1065             :   }
    1066           0 :   self->SetOnclick(Constify(arg0));
    1067           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1068             : 
    1069           0 :   return true;
    1070             : }
    1071             : 
    1072             : static const JSJitInfo onclick_getterinfo = {
    1073             :   { (JSJitGetterOp)get_onclick },
    1074             :   { prototypes::id::Notification },
    1075             :   { PrototypeTraits<prototypes::id::Notification>::Depth },
    1076             :   JSJitInfo::Getter,
    1077             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1078             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
    1079             :   false,  /* isInfallible. False in setters. */
    1080             :   false,  /* isMovable.  Not relevant for setters. */
    1081             :   false, /* isEliminatable.  Not relevant for setters. */
    1082             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1083             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1084             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1085             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1086             : };
    1087             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1088             : static_assert(0 < 1, "There is no slot for us");
    1089             : static const JSJitInfo onclick_setterinfo = {
    1090             :   { (JSJitGetterOp)set_onclick },
    1091             :   { prototypes::id::Notification },
    1092             :   { PrototypeTraits<prototypes::id::Notification>::Depth },
    1093             :   JSJitInfo::Setter,
    1094             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1095             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    1096             :   false,  /* isInfallible. False in setters. */
    1097             :   false,  /* isMovable.  Not relevant for setters. */
    1098             :   false, /* isEliminatable.  Not relevant for setters. */
    1099             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1100             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1101             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1102             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1103             : };
    1104             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1105             : static_assert(0 < 1, "There is no slot for us");
    1106             : 
    1107             : static bool
    1108           0 : get_onshow(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Notification* self, JSJitGetterCallArgs args)
    1109             : {
    1110           0 :   if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) {
    1111             :       // Return false from the JSNative in order to trigger
    1112             :       // an uncatchable exception.
    1113           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1114           0 :       return false;
    1115             :   }
    1116           0 :   RefPtr<EventHandlerNonNull> result(self->GetOnshow());
    1117           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1118           0 :   if (result) {
    1119           0 :     args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
    1120           0 :     if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
    1121           0 :       return false;
    1122             :     }
    1123           0 :     return true;
    1124             :   } else {
    1125           0 :     args.rval().setNull();
    1126           0 :     return true;
    1127             :   }
    1128             : }
    1129             : 
    1130             : static bool
    1131           0 : set_onshow(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Notification* self, JSJitSetterCallArgs args)
    1132             : {
    1133           0 :   if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) {
    1134             :       // Return false from the JSNative in order to trigger
    1135             :       // an uncatchable exception.
    1136           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1137           0 :       return false;
    1138             :   }
    1139           0 :   RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
    1140           0 :   if (args[0].isObject()) {
    1141             :     { // scope for tempRoot
    1142           0 :       JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
    1143           0 :       arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
    1144             :     }
    1145             :   } else {
    1146           0 :     arg0 = nullptr;
    1147             :   }
    1148           0 :   self->SetOnshow(Constify(arg0));
    1149           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1150             : 
    1151           0 :   return true;
    1152             : }
    1153             : 
    1154             : static const JSJitInfo onshow_getterinfo = {
    1155             :   { (JSJitGetterOp)get_onshow },
    1156             :   { prototypes::id::Notification },
    1157             :   { PrototypeTraits<prototypes::id::Notification>::Depth },
    1158             :   JSJitInfo::Getter,
    1159             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1160             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
    1161             :   false,  /* isInfallible. False in setters. */
    1162             :   false,  /* isMovable.  Not relevant for setters. */
    1163             :   false, /* isEliminatable.  Not relevant for setters. */
    1164             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1165             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1166             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1167             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1168             : };
    1169             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1170             : static_assert(0 < 1, "There is no slot for us");
    1171             : static const JSJitInfo onshow_setterinfo = {
    1172             :   { (JSJitGetterOp)set_onshow },
    1173             :   { prototypes::id::Notification },
    1174             :   { PrototypeTraits<prototypes::id::Notification>::Depth },
    1175             :   JSJitInfo::Setter,
    1176             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1177             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    1178             :   false,  /* isInfallible. False in setters. */
    1179             :   false,  /* isMovable.  Not relevant for setters. */
    1180             :   false, /* isEliminatable.  Not relevant for setters. */
    1181             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1182             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1183             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1184             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1185             : };
    1186             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1187             : static_assert(0 < 1, "There is no slot for us");
    1188             : 
    1189             : static bool
    1190           0 : get_onerror(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Notification* self, JSJitGetterCallArgs args)
    1191             : {
    1192           0 :   if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) {
    1193             :       // Return false from the JSNative in order to trigger
    1194             :       // an uncatchable exception.
    1195           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1196           0 :       return false;
    1197             :   }
    1198           0 :   RefPtr<EventHandlerNonNull> result(self->GetOnerror());
    1199           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1200           0 :   if (result) {
    1201           0 :     args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
    1202           0 :     if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
    1203           0 :       return false;
    1204             :     }
    1205           0 :     return true;
    1206             :   } else {
    1207           0 :     args.rval().setNull();
    1208           0 :     return true;
    1209             :   }
    1210             : }
    1211             : 
    1212             : static bool
    1213           0 : set_onerror(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Notification* self, JSJitSetterCallArgs args)
    1214             : {
    1215           0 :   if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) {
    1216             :       // Return false from the JSNative in order to trigger
    1217             :       // an uncatchable exception.
    1218           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1219           0 :       return false;
    1220             :   }
    1221           0 :   RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
    1222           0 :   if (args[0].isObject()) {
    1223             :     { // scope for tempRoot
    1224           0 :       JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
    1225           0 :       arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
    1226             :     }
    1227             :   } else {
    1228           0 :     arg0 = nullptr;
    1229             :   }
    1230           0 :   self->SetOnerror(Constify(arg0));
    1231           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1232             : 
    1233           0 :   return true;
    1234             : }
    1235             : 
    1236             : static const JSJitInfo onerror_getterinfo = {
    1237             :   { (JSJitGetterOp)get_onerror },
    1238             :   { prototypes::id::Notification },
    1239             :   { PrototypeTraits<prototypes::id::Notification>::Depth },
    1240             :   JSJitInfo::Getter,
    1241             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1242             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
    1243             :   false,  /* isInfallible. False in setters. */
    1244             :   false,  /* isMovable.  Not relevant for setters. */
    1245             :   false, /* isEliminatable.  Not relevant for setters. */
    1246             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1247             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1248             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1249             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1250             : };
    1251             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1252             : static_assert(0 < 1, "There is no slot for us");
    1253             : static const JSJitInfo onerror_setterinfo = {
    1254             :   { (JSJitGetterOp)set_onerror },
    1255             :   { prototypes::id::Notification },
    1256             :   { PrototypeTraits<prototypes::id::Notification>::Depth },
    1257             :   JSJitInfo::Setter,
    1258             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1259             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    1260             :   false,  /* isInfallible. False in setters. */
    1261             :   false,  /* isMovable.  Not relevant for setters. */
    1262             :   false, /* isEliminatable.  Not relevant for setters. */
    1263             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1264             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1265             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1266             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1267             : };
    1268             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1269             : static_assert(0 < 1, "There is no slot for us");
    1270             : 
    1271             : static bool
    1272           0 : get_onclose(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Notification* self, JSJitGetterCallArgs args)
    1273             : {
    1274           0 :   if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) {
    1275             :       // Return false from the JSNative in order to trigger
    1276             :       // an uncatchable exception.
    1277           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1278           0 :       return false;
    1279             :   }
    1280           0 :   RefPtr<EventHandlerNonNull> result(self->GetOnclose());
    1281           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1282           0 :   if (result) {
    1283           0 :     args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
    1284           0 :     if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
    1285           0 :       return false;
    1286             :     }
    1287           0 :     return true;
    1288             :   } else {
    1289           0 :     args.rval().setNull();
    1290           0 :     return true;
    1291             :   }
    1292             : }
    1293             : 
    1294             : static bool
    1295           0 : set_onclose(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Notification* self, JSJitSetterCallArgs args)
    1296             : {
    1297           0 :   if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) {
    1298             :       // Return false from the JSNative in order to trigger
    1299             :       // an uncatchable exception.
    1300           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1301           0 :       return false;
    1302             :   }
    1303           0 :   RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
    1304           0 :   if (args[0].isObject()) {
    1305             :     { // scope for tempRoot
    1306           0 :       JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
    1307           0 :       arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
    1308             :     }
    1309             :   } else {
    1310           0 :     arg0 = nullptr;
    1311             :   }
    1312           0 :   self->SetOnclose(Constify(arg0));
    1313           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1314             : 
    1315           0 :   return true;
    1316             : }
    1317             : 
    1318             : static const JSJitInfo onclose_getterinfo = {
    1319             :   { (JSJitGetterOp)get_onclose },
    1320             :   { prototypes::id::Notification },
    1321             :   { PrototypeTraits<prototypes::id::Notification>::Depth },
    1322             :   JSJitInfo::Getter,
    1323             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1324             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
    1325             :   false,  /* isInfallible. False in setters. */
    1326             :   false,  /* isMovable.  Not relevant for setters. */
    1327             :   false, /* isEliminatable.  Not relevant for setters. */
    1328             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1329             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1330             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1331             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1332             : };
    1333             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1334             : static_assert(0 < 1, "There is no slot for us");
    1335             : static const JSJitInfo onclose_setterinfo = {
    1336             :   { (JSJitGetterOp)set_onclose },
    1337             :   { prototypes::id::Notification },
    1338             :   { PrototypeTraits<prototypes::id::Notification>::Depth },
    1339             :   JSJitInfo::Setter,
    1340             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1341             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    1342             :   false,  /* isInfallible. False in setters. */
    1343             :   false,  /* isMovable.  Not relevant for setters. */
    1344             :   false, /* isEliminatable.  Not relevant for setters. */
    1345             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1346             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1347             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1348             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1349             : };
    1350             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1351             : static_assert(0 < 1, "There is no slot for us");
    1352             : 
    1353             : static bool
    1354           0 : get_title(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Notification* self, JSJitGetterCallArgs args)
    1355             : {
    1356           0 :   if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) {
    1357             :       // Return false from the JSNative in order to trigger
    1358             :       // an uncatchable exception.
    1359           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1360           0 :       return false;
    1361             :   }
    1362           0 :   DOMString result;
    1363           0 :   self->GetTitle(result);
    1364           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1365           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
    1366           0 :     return false;
    1367             :   }
    1368           0 :   return true;
    1369             : }
    1370             : 
    1371             : static const JSJitInfo title_getterinfo = {
    1372             :   { (JSJitGetterOp)get_title },
    1373             :   { prototypes::id::Notification },
    1374             :   { PrototypeTraits<prototypes::id::Notification>::Depth },
    1375             :   JSJitInfo::Getter,
    1376             :   JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
    1377             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    1378             :   false,  /* isInfallible. False in setters. */
    1379             :   true,  /* isMovable.  Not relevant for setters. */
    1380             :   true, /* isEliminatable.  Not relevant for setters. */
    1381             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1382             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1383             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1384             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1385             : };
    1386             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1387             : static_assert(0 < 1, "There is no slot for us");
    1388             : 
    1389             : static bool
    1390           0 : get_dir(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Notification* self, JSJitGetterCallArgs args)
    1391             : {
    1392           0 :   if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) {
    1393             :       // Return false from the JSNative in order to trigger
    1394             :       // an uncatchable exception.
    1395           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1396           0 :       return false;
    1397             :   }
    1398           0 :   NotificationDirection result(self->Dir());
    1399           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1400           0 :   if (!ToJSValue(cx, result, args.rval())) {
    1401           0 :     return false;
    1402             :   }
    1403           0 :   return true;
    1404             : }
    1405             : 
    1406             : static const JSJitInfo dir_getterinfo = {
    1407             :   { (JSJitGetterOp)get_dir },
    1408             :   { prototypes::id::Notification },
    1409             :   { PrototypeTraits<prototypes::id::Notification>::Depth },
    1410             :   JSJitInfo::Getter,
    1411             :   JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
    1412             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    1413             :   false,  /* isInfallible. False in setters. */
    1414             :   true,  /* isMovable.  Not relevant for setters. */
    1415             :   true, /* isEliminatable.  Not relevant for setters. */
    1416             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1417             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1418             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1419             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1420             : };
    1421             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1422             : static_assert(0 < 1, "There is no slot for us");
    1423             : 
    1424             : static bool
    1425           0 : get_lang(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Notification* self, JSJitGetterCallArgs args)
    1426             : {
    1427           0 :   if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) {
    1428             :       // Return false from the JSNative in order to trigger
    1429             :       // an uncatchable exception.
    1430           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1431           0 :       return false;
    1432             :   }
    1433           0 :   DOMString result;
    1434           0 :   self->GetLang(result);
    1435           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1436           0 :   if (!xpc::StringToJsval(cx, result, args.rval())) {
    1437           0 :     return false;
    1438             :   }
    1439           0 :   return true;
    1440             : }
    1441             : 
    1442             : static const JSJitInfo lang_getterinfo = {
    1443             :   { (JSJitGetterOp)get_lang },
    1444             :   { prototypes::id::Notification },
    1445             :   { PrototypeTraits<prototypes::id::Notification>::Depth },
    1446             :   JSJitInfo::Getter,
    1447             :   JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
    1448             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
    1449             :   false,  /* isInfallible. False in setters. */
    1450             :   true,  /* isMovable.  Not relevant for setters. */
    1451             :   true, /* isEliminatable.  Not relevant for setters. */
    1452             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1453             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1454             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1455             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1456             : };
    1457             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1458             : static_assert(0 < 1, "There is no slot for us");
    1459             : 
    1460             : static bool
    1461           0 : get_body(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Notification* self, JSJitGetterCallArgs args)
    1462             : {
    1463           0 :   if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) {
    1464             :       // Return false from the JSNative in order to trigger
    1465             :       // an uncatchable exception.
    1466           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1467           0 :       return false;
    1468             :   }
    1469           0 :   DOMString result;
    1470           0 :   self->GetBody(result);
    1471           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1472           0 :   if (!xpc::StringToJsval(cx, result, args.rval())) {
    1473           0 :     return false;
    1474             :   }
    1475           0 :   return true;
    1476             : }
    1477             : 
    1478             : static const JSJitInfo body_getterinfo = {
    1479             :   { (JSJitGetterOp)get_body },
    1480             :   { prototypes::id::Notification },
    1481             :   { PrototypeTraits<prototypes::id::Notification>::Depth },
    1482             :   JSJitInfo::Getter,
    1483             :   JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
    1484             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
    1485             :   false,  /* isInfallible. False in setters. */
    1486             :   true,  /* isMovable.  Not relevant for setters. */
    1487             :   true, /* isEliminatable.  Not relevant for setters. */
    1488             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1489             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1490             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1491             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1492             : };
    1493             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1494             : static_assert(0 < 1, "There is no slot for us");
    1495             : 
    1496             : static bool
    1497           0 : get_tag(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Notification* self, JSJitGetterCallArgs args)
    1498             : {
    1499           0 :   if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) {
    1500             :       // Return false from the JSNative in order to trigger
    1501             :       // an uncatchable exception.
    1502           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1503           0 :       return false;
    1504             :   }
    1505           0 :   DOMString result;
    1506           0 :   self->GetTag(result);
    1507           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1508           0 :   if (!xpc::StringToJsval(cx, result, args.rval())) {
    1509           0 :     return false;
    1510             :   }
    1511           0 :   return true;
    1512             : }
    1513             : 
    1514             : static const JSJitInfo tag_getterinfo = {
    1515             :   { (JSJitGetterOp)get_tag },
    1516             :   { prototypes::id::Notification },
    1517             :   { PrototypeTraits<prototypes::id::Notification>::Depth },
    1518             :   JSJitInfo::Getter,
    1519             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
    1520             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
    1521             :   false,  /* isInfallible. False in setters. */
    1522             :   true,  /* isMovable.  Not relevant for setters. */
    1523             :   true, /* isEliminatable.  Not relevant for setters. */
    1524             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1525             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1526             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1527             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1528             : };
    1529             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1530             : static_assert(0 < 1, "There is no slot for us");
    1531             : 
    1532             : static bool
    1533           0 : get_icon(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Notification* self, JSJitGetterCallArgs args)
    1534             : {
    1535           0 :   if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) {
    1536             :       // Return false from the JSNative in order to trigger
    1537             :       // an uncatchable exception.
    1538           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1539           0 :       return false;
    1540             :   }
    1541           0 :   DOMString result;
    1542           0 :   self->GetIcon(result);
    1543           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1544           0 :   if (!xpc::StringToJsval(cx, result, args.rval())) {
    1545           0 :     return false;
    1546             :   }
    1547           0 :   return true;
    1548             : }
    1549             : 
    1550             : static const JSJitInfo icon_getterinfo = {
    1551             :   { (JSJitGetterOp)get_icon },
    1552             :   { prototypes::id::Notification },
    1553             :   { PrototypeTraits<prototypes::id::Notification>::Depth },
    1554             :   JSJitInfo::Getter,
    1555             :   JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
    1556             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
    1557             :   false,  /* isInfallible. False in setters. */
    1558             :   true,  /* isMovable.  Not relevant for setters. */
    1559             :   true, /* isEliminatable.  Not relevant for setters. */
    1560             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1561             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1562             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1563             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1564             : };
    1565             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1566             : static_assert(0 < 1, "There is no slot for us");
    1567             : 
    1568             : static bool
    1569           0 : get_requireInteraction(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Notification* self, JSJitGetterCallArgs args)
    1570             : {
    1571           0 :   if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) {
    1572             :       // Return false from the JSNative in order to trigger
    1573             :       // an uncatchable exception.
    1574           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1575           0 :       return false;
    1576             :   }
    1577           0 :   bool result(self->RequireInteraction());
    1578           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1579           0 :   args.rval().setBoolean(result);
    1580           0 :   return true;
    1581             : }
    1582             : 
    1583             : static const JSJitInfo requireInteraction_getterinfo = {
    1584             :   { (JSJitGetterOp)get_requireInteraction },
    1585             :   { prototypes::id::Notification },
    1586             :   { PrototypeTraits<prototypes::id::Notification>::Depth },
    1587             :   JSJitInfo::Getter,
    1588             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
    1589             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
    1590             :   true,  /* isInfallible. False in setters. */
    1591             :   true,  /* isMovable.  Not relevant for setters. */
    1592             :   true, /* isEliminatable.  Not relevant for setters. */
    1593             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1594             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1595             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1596             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1597             : };
    1598             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1599             : static_assert(0 < 1, "There is no slot for us");
    1600             : 
    1601             : static bool
    1602           0 : get_data(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Notification* self, JSJitGetterCallArgs args)
    1603             : {
    1604           0 :   if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) {
    1605             :       // Return false from the JSNative in order to trigger
    1606             :       // an uncatchable exception.
    1607           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1608           0 :       return false;
    1609             :   }
    1610           0 :   JS::Rooted<JS::Value> result(cx);
    1611           0 :   self->GetData(cx, &result);
    1612           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1613           0 :   JS::ExposeValueToActiveJS(result);
    1614           0 :   args.rval().set(result);
    1615           0 :   if (!MaybeWrapValue(cx, args.rval())) {
    1616           0 :     return false;
    1617             :   }
    1618           0 :   return true;
    1619             : }
    1620             : 
    1621             : static const JSJitInfo data_getterinfo = {
    1622             :   { (JSJitGetterOp)get_data },
    1623             :   { prototypes::id::Notification },
    1624             :   { PrototypeTraits<prototypes::id::Notification>::Depth },
    1625             :   JSJitInfo::Getter,
    1626             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
    1627             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
    1628             :   false,  /* isInfallible. False in setters. */
    1629             :   true,  /* isMovable.  Not relevant for setters. */
    1630             :   true, /* isEliminatable.  Not relevant for setters. */
    1631             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1632             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1633             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1634             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1635             : };
    1636             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1637             : static_assert(0 < 1, "There is no slot for us");
    1638             : 
    1639             : static bool
    1640           0 : close(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Notification* self, const JSJitMethodCallArgs& args)
    1641             : {
    1642           0 :   if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) {
    1643             :       // Return false from the JSNative in order to trigger
    1644             :       // an uncatchable exception.
    1645           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1646           0 :       return false;
    1647             :   }
    1648           0 :   self->Close();
    1649           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1650           0 :   args.rval().setUndefined();
    1651           0 :   return true;
    1652             : }
    1653             : 
    1654             : static const JSJitInfo close_methodinfo = {
    1655             :   { (JSJitGetterOp)close },
    1656             :   { prototypes::id::Notification },
    1657             :   { PrototypeTraits<prototypes::id::Notification>::Depth },
    1658             :   JSJitInfo::Method,
    1659             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1660             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    1661             :   true,  /* isInfallible. False in setters. */
    1662             :   false,  /* isMovable.  Not relevant for setters. */
    1663             :   false, /* isEliminatable.  Not relevant for setters. */
    1664             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1665             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1666             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1667             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1668             : };
    1669             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1670             : static_assert(0 < 1, "There is no slot for us");
    1671             : 
    1672             : static bool
    1673           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
    1674             : {
    1675           0 :   mozilla::dom::Notification* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Notification>(obj);
    1676             :   // We don't want to preserve if we don't have a wrapper, and we
    1677             :   // obviously can't preserve if we're not initialized.
    1678           0 :   if (self && self->GetWrapperPreserveColor()) {
    1679           0 :     PreserveWrapper(self);
    1680             :   }
    1681           0 :   return true;
    1682             : }
    1683             : 
    1684             : static void
    1685           0 : _finalize(js::FreeOp* fop, JSObject* obj)
    1686             : {
    1687           0 :   mozilla::dom::Notification* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Notification>(obj);
    1688           0 :   if (self) {
    1689           0 :     ClearWrapper(self, self, obj);
    1690           0 :     AddForDeferredFinalization<mozilla::dom::Notification>(self);
    1691             :   }
    1692           0 : }
    1693             : 
    1694             : static void
    1695           0 : _objectMoved(JSObject* obj, const JSObject* old)
    1696             : {
    1697           0 :   mozilla::dom::Notification* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Notification>(obj);
    1698           0 :   if (self) {
    1699           0 :     UpdateWrapper(self, self, obj, old);
    1700             :   }
    1701           0 : }
    1702             : 
    1703             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1704             : #if defined(__clang__)
    1705             : #pragma clang diagnostic push
    1706             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1707             : #endif
    1708             : static const JSFunctionSpec sStaticMethods_specs[] = {
    1709             :   JS_FNSPEC("requestPermission", StaticMethodPromiseWrapper, &requestPermission_methodinfo, 0, JSPROP_ENUMERATE, nullptr),
    1710             :   JS_FS_END,
    1711             :   JS_FNSPEC("get", StaticMethodPromiseWrapper, &get_methodinfo, 0, JSPROP_ENUMERATE, nullptr),
    1712             :   JS_FS_END
    1713             : };
    1714             : #if defined(__clang__)
    1715             : #pragma clang diagnostic pop
    1716             : #endif
    1717             : 
    1718             : static PrefableDisablers sStaticMethods_disablers0 = {
    1719             :   true, false, 0, &mozilla::dom::Notification::RequestPermissionEnabledForScope
    1720             : };
    1721             : 
    1722             : static PrefableDisablers sStaticMethods_disablers2 = {
    1723             :   true, false, 0, &mozilla::dom::Notification::IsGetEnabled
    1724             : };
    1725             : 
    1726             : // Can't be const because the pref-enabled boolean needs to be writable
    1727             : static Prefable<const JSFunctionSpec> sStaticMethods[] = {
    1728             :   { &sStaticMethods_disablers0, &sStaticMethods_specs[0] },
    1729             :   { &sStaticMethods_disablers2, &sStaticMethods_specs[2] },
    1730             :   { nullptr, nullptr }
    1731             : };
    1732             : 
    1733             : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1734             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1735             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1736             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1737             : 
    1738             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1739             : #if defined(__clang__)
    1740             : #pragma clang diagnostic push
    1741             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1742             : #endif
    1743             : static const JSPropertySpec sStaticAttributes_specs[] = {
    1744             :   { "permission", JSPROP_SHARED | JSPROP_ENUMERATE, get_permission, nullptr, nullptr, nullptr },
    1745             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
    1746             : };
    1747             : #if defined(__clang__)
    1748             : #pragma clang diagnostic pop
    1749             : #endif
    1750             : 
    1751             : 
    1752             : // Can't be const because the pref-enabled boolean needs to be writable
    1753             : static Prefable<const JSPropertySpec> sStaticAttributes[] = {
    1754             :   { nullptr, &sStaticAttributes_specs[0] },
    1755             :   { nullptr, nullptr }
    1756             : };
    1757             : 
    1758             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1759             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1760             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1761             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1762             : 
    1763             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1764             : #if defined(__clang__)
    1765             : #pragma clang diagnostic push
    1766             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1767             : #endif
    1768             : static const JSFunctionSpec sMethods_specs[] = {
    1769             :   JS_FNSPEC("close", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&close_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    1770             :   JS_FS_END,
    1771             :   JS_FNSPEC("QueryInterface", QueryInterface, nullptr, 1, 0, nullptr),
    1772             :   JS_FS_END
    1773             : };
    1774             : #if defined(__clang__)
    1775             : #pragma clang diagnostic pop
    1776             : #endif
    1777             : 
    1778             : static PrefableDisablers sMethods_disablers2 = {
    1779             :   true, false, 0, &WantsQueryInterface<mozilla::dom::Notification>::Enabled
    1780             : };
    1781             : 
    1782             : // Can't be const because the pref-enabled boolean needs to be writable
    1783             : static Prefable<const JSFunctionSpec> sMethods[] = {
    1784             :   { nullptr, &sMethods_specs[0] },
    1785             :   { &sMethods_disablers2, &sMethods_specs[2] },
    1786             :   { nullptr, nullptr }
    1787             : };
    1788             : 
    1789             : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1790             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1791             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1792             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1793             : 
    1794             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1795             : #if defined(__clang__)
    1796             : #pragma clang diagnostic push
    1797             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1798             : #endif
    1799             : static const JSPropertySpec sAttributes_specs[] = {
    1800             :   { "onclick", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onclick_getterinfo, GenericBindingSetter, &onclick_setterinfo },
    1801             :   { "onshow", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onshow_getterinfo, GenericBindingSetter, &onshow_setterinfo },
    1802             :   { "onerror", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onerror_getterinfo, GenericBindingSetter, &onerror_setterinfo },
    1803             :   { "onclose", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onclose_getterinfo, GenericBindingSetter, &onclose_setterinfo },
    1804             :   { "title", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &title_getterinfo, nullptr, nullptr },
    1805             :   { "dir", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &dir_getterinfo, nullptr, nullptr },
    1806             :   { "lang", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &lang_getterinfo, nullptr, nullptr },
    1807             :   { "body", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &body_getterinfo, nullptr, nullptr },
    1808             :   { "tag", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &tag_getterinfo, nullptr, nullptr },
    1809             :   { "icon", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &icon_getterinfo, nullptr, nullptr },
    1810             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
    1811             :   { "requireInteraction", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &requireInteraction_getterinfo, nullptr, nullptr },
    1812             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
    1813             :   { "data", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &data_getterinfo, nullptr, nullptr },
    1814             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
    1815             : };
    1816             : #if defined(__clang__)
    1817             : #pragma clang diagnostic pop
    1818             : #endif
    1819             : 
    1820             : static PrefableDisablers sAttributes_disablers11 = {
    1821             :   true, false, 0, &mozilla::dom::Notification::RequireInteractionEnabled
    1822             : };
    1823             : 
    1824             : // Can't be const because the pref-enabled boolean needs to be writable
    1825             : static Prefable<const JSPropertySpec> sAttributes[] = {
    1826             :   { nullptr, &sAttributes_specs[0] },
    1827             :   { &sAttributes_disablers11, &sAttributes_specs[11] },
    1828             :   { nullptr, &sAttributes_specs[13] },
    1829             :   { nullptr, nullptr }
    1830             : };
    1831             : 
    1832             : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1833             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1834             : static_assert(10 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1835             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1836             : 
    1837             : 
    1838             : static uint16_t sNativeProperties_sortedPropertyIndices[17];
    1839             : static PropertyInfo sNativeProperties_propertyInfos[17];
    1840             : 
    1841             : static const NativePropertiesN<4> sNativeProperties = {
    1842             :   true,  0 /* sStaticMethods */,
    1843             :   true,  1 /* sStaticAttributes */,
    1844             :   true,  2 /* sMethods */,
    1845             :   true,  3 /* sAttributes */,
    1846             :   false, 0,
    1847             :   false, 0,
    1848             :   false, 0,
    1849             :   -1,
    1850             :   17,
    1851             :   sNativeProperties_sortedPropertyIndices,
    1852             :   {
    1853             :     { sStaticMethods, &sNativeProperties_propertyInfos[0] },
    1854             :     { sStaticAttributes, &sNativeProperties_propertyInfos[2] },
    1855             :     { sMethods, &sNativeProperties_propertyInfos[3] },
    1856             :     { sAttributes, &sNativeProperties_propertyInfos[5] }
    1857             :   }
    1858             : };
    1859             : static_assert(17 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
    1860             :     "We have a property info count that is oversized");
    1861             : 
    1862             : static bool
    1863           0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
    1864             : {
    1865           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
    1866           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
    1867           0 :   if (!args.isConstructing()) {
    1868             :     // XXXbz wish I could get the name from the callee instead of
    1869             :     // Adding more relocations
    1870           0 :     return ThrowConstructorWithoutNew(cx, "Notification");
    1871             :   }
    1872             : 
    1873           0 :   GlobalObject global(cx, obj);
    1874           0 :   if (global.Failed()) {
    1875           0 :     return false;
    1876             :   }
    1877             : 
    1878           0 :   JS::Rooted<JSObject*> desiredProto(cx);
    1879           0 :   if (!GetDesiredProto(cx, args, &desiredProto)) {
    1880           0 :     return false;
    1881             :   }
    1882             : 
    1883           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
    1884           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Notification");
    1885             :   }
    1886           0 :   if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) {
    1887             :       // Return false from the JSNative in order to trigger
    1888             :       // an uncatchable exception.
    1889           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1890           0 :       return false;
    1891             :   }
    1892           0 :   bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
    1893           0 :   binding_detail::FakeString arg0;
    1894           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
    1895           0 :     return false;
    1896             :   }
    1897           0 :   RootedDictionary<binding_detail::FastNotificationOptions> arg1(cx);
    1898           0 :   if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue,  "Argument 2 of Notification.constructor", false)) {
    1899           0 :     return false;
    1900             :   }
    1901           0 :   Maybe<JSAutoCompartment> ac;
    1902           0 :   if (objIsXray) {
    1903           0 :     obj = js::CheckedUnwrap(obj);
    1904           0 :     if (!obj) {
    1905           0 :       return false;
    1906             :     }
    1907           0 :     ac.emplace(cx, obj);
    1908           0 :     if (!JS_WrapObject(cx, &desiredProto)) {
    1909           0 :       return false;
    1910             :     }
    1911           0 :     if (!JS_WrapValue(cx, JS::MutableHandle<JS::Value>::fromMarkedLocation(&arg1.mData))) {
    1912           0 :       return false;
    1913             :     }
    1914             :   }
    1915           0 :   binding_detail::FastErrorResult rv;
    1916           0 :   auto result(StrongOrRawPtr<mozilla::dom::Notification>(mozilla::dom::Notification::Constructor(global, NonNullHelper(Constify(arg0)), Constify(arg1), rv)));
    1917           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    1918           0 :     return false;
    1919             :   }
    1920           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1921             :   static_assert(!IsPointer<decltype(result)>::value,
    1922             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
    1923           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
    1924           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    1925           0 :     return false;
    1926             :   }
    1927           0 :   return true;
    1928             : }
    1929             : 
    1930             : static const js::ClassOps sInterfaceObjectClassOps = {
    1931             :     nullptr,               /* addProperty */
    1932             :     nullptr,               /* delProperty */
    1933             :     nullptr,               /* getProperty */
    1934             :     nullptr,               /* setProperty */
    1935             :     nullptr,               /* enumerate */
    1936             :     nullptr,               /* newEnumerate */
    1937             :     nullptr,               /* resolve */
    1938             :     nullptr,               /* mayResolve */
    1939             :     nullptr,               /* finalize */
    1940             :     _constructor, /* call */
    1941             :     nullptr,               /* hasInstance */
    1942             :     _constructor, /* construct */
    1943             :     nullptr,               /* trace */
    1944             : };
    1945             : 
    1946             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
    1947             :   {
    1948             :     "Function",
    1949             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
    1950             :     &sInterfaceObjectClassOps,
    1951             :     JS_NULL_CLASS_SPEC,
    1952             :     JS_NULL_CLASS_EXT,
    1953             :     &sInterfaceObjectClassObjectOps
    1954             :   },
    1955             :   eInterface,
    1956             :   true,
    1957             :   prototypes::id::Notification,
    1958             :   PrototypeTraits<prototypes::id::Notification>::Depth,
    1959             :   sNativePropertyHooks,
    1960             :   "function Notification() {\n    [native code]\n}",
    1961             :   EventTargetBinding::GetConstructorObject
    1962             : };
    1963             : 
    1964             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
    1965             :   {
    1966             :     "NotificationPrototype",
    1967             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
    1968             :     JS_NULL_CLASS_OPS,
    1969             :     JS_NULL_CLASS_SPEC,
    1970             :     JS_NULL_CLASS_EXT,
    1971             :     JS_NULL_OBJECT_OPS
    1972             :   },
    1973             :   eInterfacePrototype,
    1974             :   false,
    1975             :   prototypes::id::Notification,
    1976             :   PrototypeTraits<prototypes::id::Notification>::Depth,
    1977             :   sNativePropertyHooks,
    1978             :   "[object NotificationPrototype]",
    1979             :   EventTargetBinding::GetProtoObject
    1980             : };
    1981             : 
    1982             : bool
    1983           1 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
    1984             : {
    1985           1 :   return mozilla::dom::Notification::PrefEnabled(aCx, aObj);
    1986             : }
    1987             : 
    1988             : JSObject*
    1989           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
    1990             : {
    1991           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
    1992             : }
    1993             : 
    1994             : static const js::ClassOps sClassOps = {
    1995             :   _addProperty, /* addProperty */
    1996             :   nullptr,               /* delProperty */
    1997             :   nullptr,               /* getProperty */
    1998             :   nullptr,               /* setProperty */
    1999             :   nullptr,               /* enumerate */
    2000             :   nullptr, /* newEnumerate */
    2001             :   nullptr, /* resolve */
    2002             :   nullptr, /* mayResolve */
    2003             :   _finalize, /* finalize */
    2004             :   nullptr, /* call */
    2005             :   nullptr,               /* hasInstance */
    2006             :   nullptr,               /* construct */
    2007             :   nullptr, /* trace */
    2008             : };
    2009             : 
    2010             : static const js::ClassExtension sClassExtension = {
    2011             :   nullptr, /* weakmapKeyDelegateOp */
    2012             :   _objectMoved /* objectMovedOp */
    2013             : };
    2014             : 
    2015             : static const DOMJSClass sClass = {
    2016             :   { "Notification",
    2017             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
    2018             :     &sClassOps,
    2019             :     JS_NULL_CLASS_SPEC,
    2020             :     &sClassExtension,
    2021             :     JS_NULL_OBJECT_OPS
    2022             :   },
    2023             :   { prototypes::id::EventTarget, prototypes::id::Notification, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
    2024             :   IsBaseOf<nsISupports, mozilla::dom::Notification >::value,
    2025             :   sNativePropertyHooks,
    2026             :   FindAssociatedGlobalForNative<mozilla::dom::Notification>::Get,
    2027             :   GetProtoObjectHandle,
    2028             :   GetCCParticipant<mozilla::dom::Notification>::Get()
    2029             : };
    2030             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
    2031             :               "Must have the right minimal number of reserved slots.");
    2032             : static_assert(1 >= 1,
    2033             :               "Must have enough reserved slots.");
    2034             : 
    2035             : const JSClass*
    2036           0 : GetJSClass()
    2037             : {
    2038           0 :   return sClass.ToJSClass();
    2039             : }
    2040             : 
    2041             : bool
    2042           0 : Wrap(JSContext* aCx, mozilla::dom::Notification* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
    2043             : {
    2044             :   MOZ_ASSERT(static_cast<mozilla::dom::Notification*>(aObject) ==
    2045             :              reinterpret_cast<mozilla::dom::Notification*>(aObject),
    2046             :              "Multiple inheritance for mozilla::dom::Notification is broken.");
    2047             :   MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
    2048             :              reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
    2049             :              "Multiple inheritance for mozilla::dom::EventTarget is broken.");
    2050           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
    2051           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
    2052           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
    2053             :              "You should probably not be using Wrap() directly; use "
    2054             :              "GetOrCreateDOMReflector instead");
    2055             : 
    2056           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
    2057             :              "nsISupports must be on our primary inheritance chain");
    2058             : 
    2059           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
    2060           0 :   if (!global) {
    2061           0 :     return false;
    2062             :   }
    2063           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
    2064           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
    2065             : 
    2066             :   // That might have ended up wrapping us already, due to the wonders
    2067             :   // of XBL.  Check for that, and bail out as needed.
    2068           0 :   aReflector.set(aCache->GetWrapper());
    2069           0 :   if (aReflector) {
    2070             : #ifdef DEBUG
    2071           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
    2072             : #endif // DEBUG
    2073           0 :     return true;
    2074             :   }
    2075             : 
    2076           0 :   JSAutoCompartment ac(aCx, global);
    2077           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
    2078           0 :   if (!canonicalProto) {
    2079           0 :     return false;
    2080             :   }
    2081           0 :   JS::Rooted<JSObject*> proto(aCx);
    2082           0 :   if (aGivenProto) {
    2083           0 :     proto = aGivenProto;
    2084             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    2085             :     // coming in, we changed compartments to that of "parent" so may need
    2086             :     // to wrap the proto here.
    2087           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    2088           0 :       if (!JS_WrapObject(aCx, &proto)) {
    2089           0 :         return false;
    2090             :       }
    2091             :     }
    2092             :   } else {
    2093           0 :     proto = canonicalProto;
    2094             :   }
    2095             : 
    2096           0 :   BindingJSObjectCreator<mozilla::dom::Notification> creator(aCx);
    2097           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
    2098           0 :   if (!aReflector) {
    2099           0 :     return false;
    2100             :   }
    2101             : 
    2102           0 :   aCache->SetWrapper(aReflector);
    2103           0 :   creator.InitializationSucceeded();
    2104             : 
    2105           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
    2106             :              aCache->GetWrapperPreserveColor() == aReflector);
    2107             :   // If proto != canonicalProto, we have to preserve our wrapper;
    2108             :   // otherwise we won't be able to properly recreate it later, since
    2109             :   // we won't know what proto to use.  Note that we don't check
    2110             :   // aGivenProto here, since it's entirely possible (and even
    2111             :   // somewhat common) to have a non-null aGivenProto which is the
    2112             :   // same as canonicalProto.
    2113           0 :   if (proto != canonicalProto) {
    2114           0 :     PreserveWrapper(aObject);
    2115             :   }
    2116             : 
    2117           0 :   return true;
    2118             : }
    2119             : 
    2120             : const NativePropertyHooks sNativePropertyHooks[] = { {
    2121             :   nullptr,
    2122             :   nullptr,
    2123             :   nullptr,
    2124             :   { sNativeProperties.Upcast(), nullptr },
    2125             :   prototypes::id::Notification,
    2126             :   constructors::id::Notification,
    2127             :   EventTargetBinding::sNativePropertyHooks,
    2128             :   &DefaultXrayExpandoObjectClass
    2129             : } };
    2130             : 
    2131             : void
    2132           1 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    2133             : {
    2134           1 :   JS::Handle<JSObject*> parentProto(EventTargetBinding::GetProtoObjectHandle(aCx));
    2135           1 :   if (!parentProto) {
    2136           0 :     return;
    2137             :   }
    2138             : 
    2139           1 :   JS::Handle<JSObject*> constructorProto(EventTargetBinding::GetConstructorObjectHandle(aCx));
    2140           1 :   if (!constructorProto) {
    2141           0 :     return;
    2142             :   }
    2143             : 
    2144             :   static bool sIdsInited = false;
    2145           1 :   if (!sIdsInited && NS_IsMainThread()) {
    2146           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    2147           0 :       return;
    2148             :     }
    2149           0 :     sIdsInited = true;
    2150             :   }
    2151             : 
    2152           1 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::Notification);
    2153           1 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::Notification);
    2154           1 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    2155             :                               &sPrototypeClass.mBase, protoCache,
    2156             :                               constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr,
    2157             :                               interfaceCache,
    2158             :                               sNativeProperties.Upcast(),
    2159             :                               nullptr,
    2160             :                               "Notification", aDefineOnGlobal,
    2161             :                               nullptr,
    2162           1 :                               false);
    2163             : }
    2164             : 
    2165             : JS::Handle<JSObject*>
    2166           0 : GetProtoObjectHandle(JSContext* aCx)
    2167             : {
    2168             :   /* Get the interface prototype object for this class.  This will create the
    2169             :      object as needed. */
    2170           0 :   bool aDefineOnGlobal = true;
    2171             : 
    2172             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    2173           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    2174           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    2175           0 :     return nullptr;
    2176             :   }
    2177             : 
    2178             :   /* Check to see whether the interface objects are already installed */
    2179           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    2180           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::Notification)) {
    2181           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    2182           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    2183             :   }
    2184             : 
    2185             :   /*
    2186             :    * The object might _still_ be null, but that's OK.
    2187             :    *
    2188             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    2189             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    2190             :    * changed after they have been set.
    2191             :    *
    2192             :    * Calling address() avoids the read read barrier that does gray
    2193             :    * unmarking, but it's not possible for the object to be gray here.
    2194             :    */
    2195             : 
    2196           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::Notification);
    2197           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    2198           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    2199             : }
    2200             : 
    2201             : JS::Handle<JSObject*>
    2202           1 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    2203             : {
    2204             :   /* Get the interface object for this class.  This will create the object as
    2205             :      needed. */
    2206             : 
    2207             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    2208           1 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    2209           1 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    2210           0 :     return nullptr;
    2211             :   }
    2212             : 
    2213             :   /* Check to see whether the interface objects are already installed */
    2214           1 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    2215           1 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::Notification)) {
    2216           2 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    2217           1 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    2218             :   }
    2219             : 
    2220             :   /*
    2221             :    * The object might _still_ be null, but that's OK.
    2222             :    *
    2223             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    2224             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    2225             :    * changed after they have been set.
    2226             :    *
    2227             :    * Calling address() avoids the read read barrier that does gray
    2228             :    * unmarking, but it's not possible for the object to be gray here.
    2229             :    */
    2230             : 
    2231           1 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::Notification);
    2232           1 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    2233           1 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    2234             : }
    2235             : 
    2236             : JSObject*
    2237           1 : GetConstructorObject(JSContext* aCx)
    2238             : {
    2239           1 :   return GetConstructorObjectHandle(aCx);
    2240             : }
    2241             : 
    2242             : } // namespace NotificationBinding
    2243             : 
    2244             : 
    2245             : 
    2246             : } // namespace dom
    2247             : } // namespace mozilla

Generated by: LCOV version 1.13