/* THIS FILE IS AUTOGENERATED FROM ServiceWorkerGlobalScope.webidl BY Codegen.py - DO NOT EDIT */ #include #include "EventHandlerBinding.h" #include "MainThreadUtils.h" #include "ServiceWorkerGlobalScopeBinding.h" #include "WorkerGlobalScopeBinding.h" #include "WrapperFactory.h" #include "js/CallAndConstruct.h" #include "js/Exception.h" #include "js/MapAndSet.h" #include "js/Object.h" #include "js/PropertyAndElement.h" #include "js/PropertyDescriptor.h" #include "js/experimental/JitInfo.h" #include "mozilla/OwningNonNull.h" #include "mozilla/ProfilerLabels.h" #include "mozilla/dom/BindingCallContext.h" #include "mozilla/dom/BindingUtils.h" #include "mozilla/dom/Clients.h" #include "mozilla/dom/CookieStore.h" #include "mozilla/dom/DOMJSClass.h" #include "mozilla/dom/NonRefcountedDOMObject.h" #include "mozilla/dom/Nullable.h" #include "mozilla/dom/Promise.h" #include "mozilla/dom/ServiceWorkerRegistration.h" #include "mozilla/dom/ToJSValue.h" #include "mozilla/dom/WebIDLPrefs.h" #include "mozilla/dom/WorkerScope.h" #include "mozilla/extensions/ExtensionBrowser.h" #include "nsThreadUtils.h" namespace mozilla::dom { namespace binding_detail {}; // Just to make sure it's known as a namespace using namespace mozilla::dom::binding_detail; namespace ServiceWorkerGlobalScope_Binding { static_assert(IsRefcounted::value == IsRefcounted::value, "Can't inherit from an interface with a different ownership model."); MOZ_CAN_RUN_SCRIPT static bool get_clients(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "ServiceWorkerGlobalScope", "clients", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); auto result(StrongOrRawPtr(MOZ_KnownLive(self)->GetClients())); MOZ_ASSERT(!JS_IsExceptionPending(cx)); if (!GetOrCreateDOMReflector(cx, result, args.rval())) { MOZ_ASSERT(JS_IsExceptionPending(cx)); return false; } return true; } static const JSJitInfo clients_getterinfo = { { get_clients }, { prototypes::id::ServiceWorkerGlobalScope }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ true, /* isMovable. Not relevant for setters. */ true, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool get_registration(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "ServiceWorkerGlobalScope", "registration", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); auto result(StrongOrRawPtr(MOZ_KnownLive(self)->Registration())); MOZ_ASSERT(!JS_IsExceptionPending(cx)); if (!GetOrCreateDOMReflector(cx, result, args.rval())) { MOZ_ASSERT(JS_IsExceptionPending(cx)); return false; } return true; } static const JSJitInfo registration_getterinfo = { { get_registration }, { prototypes::id::ServiceWorkerGlobalScope }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ true, /* isMovable. Not relevant for setters. */ true, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool skipWaiting(JSContext* cx, JS::Handle obj, void* void_self, const JSJitMethodCallArgs& args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "ServiceWorkerGlobalScope", "skipWaiting", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); FastErrorResult rv; auto result(StrongOrRawPtr(MOZ_KnownLive(self)->SkipWaiting(rv))); if (rv.MaybeSetPendingException(cx, "ServiceWorkerGlobalScope.skipWaiting")) [[unlikely]] { return false; } MOZ_ASSERT(!JS_IsExceptionPending(cx)); static_assert(!std::is_pointer_v, "NewObject implies that we need to keep the object alive with a strong reference."); if (!ToJSValue(cx, result, args.rval())) { return false; } return true; } MOZ_CAN_RUN_SCRIPT static bool skipWaiting_promiseWrapper(JSContext* cx, JS::Handle obj, void* void_self, const JSJitMethodCallArgs& args) { bool ok = skipWaiting(cx, obj, void_self, args); if (ok) { return true; } return ConvertExceptionToPromise(cx, args.rval()); } static const JSJitInfo skipWaiting_methodinfo = { { (JSJitGetterOp)skipWaiting_promiseWrapper }, { prototypes::id::ServiceWorkerGlobalScope }, { PrototypeTraits::Depth }, JSJitInfo::Method, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool get_oninstall(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "ServiceWorkerGlobalScope", "oninstall", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); RefPtr result(MOZ_KnownLive(self)->GetOninstall()); MOZ_ASSERT(!JS_IsExceptionPending(cx)); if (result) { args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { return false; } return true; } else { args.rval().setNull(); return true; } } MOZ_CAN_RUN_SCRIPT static bool set_oninstall(JSContext* cx, JS::Handle obj, void* void_self, JSJitSetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "ServiceWorkerGlobalScope", "oninstall", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_SETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); RootedCallback> arg0(cx); if (args[0].isObject()) { { // scope for tempRoot and tempGlobalRoot if needed arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); } } else { arg0 = nullptr; } // NOTE: This assert does NOT call the function. static_assert(std::is_void_vSetOninstall(MOZ_KnownLive(Constify(arg0))))>, "Should be returning void here"); MOZ_KnownLive(self)->SetOninstall(MOZ_KnownLive(Constify(arg0))); MOZ_ASSERT(!JS_IsExceptionPending(cx)); return true; } static const JSJitInfo oninstall_getterinfo = { { get_oninstall }, { prototypes::id::ServiceWorkerGlobalScope }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; static const JSJitInfo oninstall_setterinfo = { { (JSJitGetterOp)set_oninstall }, { prototypes::id::ServiceWorkerGlobalScope }, { PrototypeTraits::Depth }, JSJitInfo::Setter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool get_onactivate(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "ServiceWorkerGlobalScope", "onactivate", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); RefPtr result(MOZ_KnownLive(self)->GetOnactivate()); MOZ_ASSERT(!JS_IsExceptionPending(cx)); if (result) { args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { return false; } return true; } else { args.rval().setNull(); return true; } } MOZ_CAN_RUN_SCRIPT static bool set_onactivate(JSContext* cx, JS::Handle obj, void* void_self, JSJitSetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "ServiceWorkerGlobalScope", "onactivate", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_SETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); RootedCallback> arg0(cx); if (args[0].isObject()) { { // scope for tempRoot and tempGlobalRoot if needed arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); } } else { arg0 = nullptr; } // NOTE: This assert does NOT call the function. static_assert(std::is_void_vSetOnactivate(MOZ_KnownLive(Constify(arg0))))>, "Should be returning void here"); MOZ_KnownLive(self)->SetOnactivate(MOZ_KnownLive(Constify(arg0))); MOZ_ASSERT(!JS_IsExceptionPending(cx)); return true; } static const JSJitInfo onactivate_getterinfo = { { get_onactivate }, { prototypes::id::ServiceWorkerGlobalScope }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; static const JSJitInfo onactivate_setterinfo = { { (JSJitGetterOp)set_onactivate }, { prototypes::id::ServiceWorkerGlobalScope }, { PrototypeTraits::Depth }, JSJitInfo::Setter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool get_onfetch(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "ServiceWorkerGlobalScope", "onfetch", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); RefPtr result(MOZ_KnownLive(self)->GetOnfetch()); MOZ_ASSERT(!JS_IsExceptionPending(cx)); if (result) { args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { return false; } return true; } else { args.rval().setNull(); return true; } } MOZ_CAN_RUN_SCRIPT static bool set_onfetch(JSContext* cx, JS::Handle obj, void* void_self, JSJitSetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "ServiceWorkerGlobalScope", "onfetch", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_SETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); RootedCallback> arg0(cx); if (args[0].isObject()) { { // scope for tempRoot and tempGlobalRoot if needed arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); } } else { arg0 = nullptr; } // NOTE: This assert does NOT call the function. static_assert(std::is_void_vSetOnfetch(MOZ_KnownLive(Constify(arg0))))>, "Should be returning void here"); MOZ_KnownLive(self)->SetOnfetch(MOZ_KnownLive(Constify(arg0))); MOZ_ASSERT(!JS_IsExceptionPending(cx)); return true; } static const JSJitInfo onfetch_getterinfo = { { get_onfetch }, { prototypes::id::ServiceWorkerGlobalScope }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; static const JSJitInfo onfetch_setterinfo = { { (JSJitGetterOp)set_onfetch }, { prototypes::id::ServiceWorkerGlobalScope }, { PrototypeTraits::Depth }, JSJitInfo::Setter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool get_onmessage(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "ServiceWorkerGlobalScope", "onmessage", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); RefPtr result(MOZ_KnownLive(self)->GetOnmessage()); MOZ_ASSERT(!JS_IsExceptionPending(cx)); if (result) { args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { return false; } return true; } else { args.rval().setNull(); return true; } } MOZ_CAN_RUN_SCRIPT static bool set_onmessage(JSContext* cx, JS::Handle obj, void* void_self, JSJitSetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "ServiceWorkerGlobalScope", "onmessage", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_SETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); RootedCallback> arg0(cx); if (args[0].isObject()) { { // scope for tempRoot and tempGlobalRoot if needed arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); } } else { arg0 = nullptr; } // NOTE: This assert does NOT call the function. static_assert(std::is_void_vSetOnmessage(MOZ_KnownLive(Constify(arg0))))>, "Should be returning void here"); MOZ_KnownLive(self)->SetOnmessage(MOZ_KnownLive(Constify(arg0))); MOZ_ASSERT(!JS_IsExceptionPending(cx)); return true; } static const JSJitInfo onmessage_getterinfo = { { get_onmessage }, { prototypes::id::ServiceWorkerGlobalScope }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; static const JSJitInfo onmessage_setterinfo = { { (JSJitGetterOp)set_onmessage }, { prototypes::id::ServiceWorkerGlobalScope }, { PrototypeTraits::Depth }, JSJitInfo::Setter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool get_onmessageerror(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "ServiceWorkerGlobalScope", "onmessageerror", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); RefPtr result(MOZ_KnownLive(self)->GetOnmessageerror()); MOZ_ASSERT(!JS_IsExceptionPending(cx)); if (result) { args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { return false; } return true; } else { args.rval().setNull(); return true; } } MOZ_CAN_RUN_SCRIPT static bool set_onmessageerror(JSContext* cx, JS::Handle obj, void* void_self, JSJitSetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "ServiceWorkerGlobalScope", "onmessageerror", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_SETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); RootedCallback> arg0(cx); if (args[0].isObject()) { { // scope for tempRoot and tempGlobalRoot if needed arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); } } else { arg0 = nullptr; } // NOTE: This assert does NOT call the function. static_assert(std::is_void_vSetOnmessageerror(MOZ_KnownLive(Constify(arg0))))>, "Should be returning void here"); MOZ_KnownLive(self)->SetOnmessageerror(MOZ_KnownLive(Constify(arg0))); MOZ_ASSERT(!JS_IsExceptionPending(cx)); return true; } static const JSJitInfo onmessageerror_getterinfo = { { get_onmessageerror }, { prototypes::id::ServiceWorkerGlobalScope }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; static const JSJitInfo onmessageerror_setterinfo = { { (JSJitGetterOp)set_onmessageerror }, { prototypes::id::ServiceWorkerGlobalScope }, { PrototypeTraits::Depth }, JSJitInfo::Setter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool get_onpush(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "ServiceWorkerGlobalScope", "onpush", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); RefPtr result(MOZ_KnownLive(self)->GetOnpush()); MOZ_ASSERT(!JS_IsExceptionPending(cx)); if (result) { args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { return false; } return true; } else { args.rval().setNull(); return true; } } MOZ_CAN_RUN_SCRIPT static bool set_onpush(JSContext* cx, JS::Handle obj, void* void_self, JSJitSetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "ServiceWorkerGlobalScope", "onpush", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_SETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); RootedCallback> arg0(cx); if (args[0].isObject()) { { // scope for tempRoot and tempGlobalRoot if needed arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); } } else { arg0 = nullptr; } // NOTE: This assert does NOT call the function. static_assert(std::is_void_vSetOnpush(MOZ_KnownLive(Constify(arg0))))>, "Should be returning void here"); MOZ_KnownLive(self)->SetOnpush(MOZ_KnownLive(Constify(arg0))); MOZ_ASSERT(!JS_IsExceptionPending(cx)); return true; } static const JSJitInfo onpush_getterinfo = { { get_onpush }, { prototypes::id::ServiceWorkerGlobalScope }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; static const JSJitInfo onpush_setterinfo = { { (JSJitGetterOp)set_onpush }, { prototypes::id::ServiceWorkerGlobalScope }, { PrototypeTraits::Depth }, JSJitInfo::Setter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool get_onpushsubscriptionchange(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "ServiceWorkerGlobalScope", "onpushsubscriptionchange", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); RefPtr result(MOZ_KnownLive(self)->GetOnpushsubscriptionchange()); MOZ_ASSERT(!JS_IsExceptionPending(cx)); if (result) { args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { return false; } return true; } else { args.rval().setNull(); return true; } } MOZ_CAN_RUN_SCRIPT static bool set_onpushsubscriptionchange(JSContext* cx, JS::Handle obj, void* void_self, JSJitSetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "ServiceWorkerGlobalScope", "onpushsubscriptionchange", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_SETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); RootedCallback> arg0(cx); if (args[0].isObject()) { { // scope for tempRoot and tempGlobalRoot if needed arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); } } else { arg0 = nullptr; } // NOTE: This assert does NOT call the function. static_assert(std::is_void_vSetOnpushsubscriptionchange(MOZ_KnownLive(Constify(arg0))))>, "Should be returning void here"); MOZ_KnownLive(self)->SetOnpushsubscriptionchange(MOZ_KnownLive(Constify(arg0))); MOZ_ASSERT(!JS_IsExceptionPending(cx)); return true; } static const JSJitInfo onpushsubscriptionchange_getterinfo = { { get_onpushsubscriptionchange }, { prototypes::id::ServiceWorkerGlobalScope }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; static const JSJitInfo onpushsubscriptionchange_setterinfo = { { (JSJitGetterOp)set_onpushsubscriptionchange }, { prototypes::id::ServiceWorkerGlobalScope }, { PrototypeTraits::Depth }, JSJitInfo::Setter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool get_onnotificationclick(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "ServiceWorkerGlobalScope", "onnotificationclick", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); RefPtr result(MOZ_KnownLive(self)->GetOnnotificationclick()); MOZ_ASSERT(!JS_IsExceptionPending(cx)); if (result) { args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { return false; } return true; } else { args.rval().setNull(); return true; } } MOZ_CAN_RUN_SCRIPT static bool set_onnotificationclick(JSContext* cx, JS::Handle obj, void* void_self, JSJitSetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "ServiceWorkerGlobalScope", "onnotificationclick", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_SETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); RootedCallback> arg0(cx); if (args[0].isObject()) { { // scope for tempRoot and tempGlobalRoot if needed arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); } } else { arg0 = nullptr; } // NOTE: This assert does NOT call the function. static_assert(std::is_void_vSetOnnotificationclick(MOZ_KnownLive(Constify(arg0))))>, "Should be returning void here"); MOZ_KnownLive(self)->SetOnnotificationclick(MOZ_KnownLive(Constify(arg0))); MOZ_ASSERT(!JS_IsExceptionPending(cx)); return true; } static const JSJitInfo onnotificationclick_getterinfo = { { get_onnotificationclick }, { prototypes::id::ServiceWorkerGlobalScope }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; static const JSJitInfo onnotificationclick_setterinfo = { { (JSJitGetterOp)set_onnotificationclick }, { prototypes::id::ServiceWorkerGlobalScope }, { PrototypeTraits::Depth }, JSJitInfo::Setter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool get_onnotificationclose(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "ServiceWorkerGlobalScope", "onnotificationclose", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); RefPtr result(MOZ_KnownLive(self)->GetOnnotificationclose()); MOZ_ASSERT(!JS_IsExceptionPending(cx)); if (result) { args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { return false; } return true; } else { args.rval().setNull(); return true; } } MOZ_CAN_RUN_SCRIPT static bool set_onnotificationclose(JSContext* cx, JS::Handle obj, void* void_self, JSJitSetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "ServiceWorkerGlobalScope", "onnotificationclose", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_SETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); RootedCallback> arg0(cx); if (args[0].isObject()) { { // scope for tempRoot and tempGlobalRoot if needed arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); } } else { arg0 = nullptr; } // NOTE: This assert does NOT call the function. static_assert(std::is_void_vSetOnnotificationclose(MOZ_KnownLive(Constify(arg0))))>, "Should be returning void here"); MOZ_KnownLive(self)->SetOnnotificationclose(MOZ_KnownLive(Constify(arg0))); MOZ_ASSERT(!JS_IsExceptionPending(cx)); return true; } static const JSJitInfo onnotificationclose_getterinfo = { { get_onnotificationclose }, { prototypes::id::ServiceWorkerGlobalScope }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; static const JSJitInfo onnotificationclose_setterinfo = { { (JSJitGetterOp)set_onnotificationclose }, { prototypes::id::ServiceWorkerGlobalScope }, { PrototypeTraits::Depth }, JSJitInfo::Setter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool get_cookieStore(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "ServiceWorkerGlobalScope", "cookieStore", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); auto result(StrongOrRawPtr(MOZ_KnownLive(self)->CookieStore())); MOZ_ASSERT(!JS_IsExceptionPending(cx)); if (!GetOrCreateDOMReflector(cx, result, args.rval())) { MOZ_ASSERT(JS_IsExceptionPending(cx)); return false; } return true; } static const JSJitInfo cookieStore_getterinfo = { { get_cookieStore }, { prototypes::id::ServiceWorkerGlobalScope }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ true, /* isMovable. Not relevant for setters. */ true, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool get_oncookiechange(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "ServiceWorkerGlobalScope", "oncookiechange", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); RefPtr result(MOZ_KnownLive(self)->GetOncookiechange()); MOZ_ASSERT(!JS_IsExceptionPending(cx)); if (result) { args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { return false; } return true; } else { args.rval().setNull(); return true; } } MOZ_CAN_RUN_SCRIPT static bool set_oncookiechange(JSContext* cx, JS::Handle obj, void* void_self, JSJitSetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "ServiceWorkerGlobalScope", "oncookiechange", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_SETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); RootedCallback> arg0(cx); if (args[0].isObject()) { { // scope for tempRoot and tempGlobalRoot if needed arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); } } else { arg0 = nullptr; } // NOTE: This assert does NOT call the function. static_assert(std::is_void_vSetOncookiechange(MOZ_KnownLive(Constify(arg0))))>, "Should be returning void here"); MOZ_KnownLive(self)->SetOncookiechange(MOZ_KnownLive(Constify(arg0))); MOZ_ASSERT(!JS_IsExceptionPending(cx)); return true; } static const JSJitInfo oncookiechange_getterinfo = { { get_oncookiechange }, { prototypes::id::ServiceWorkerGlobalScope }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; static const JSJitInfo oncookiechange_setterinfo = { { (JSJitGetterOp)set_oncookiechange }, { prototypes::id::ServiceWorkerGlobalScope }, { PrototypeTraits::Depth }, JSJitInfo::Setter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool get_browser(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "ServiceWorkerGlobalScope", "browser", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); auto result(StrongOrRawPtr(MOZ_KnownLive(self)->AcquireExtensionBrowser())); MOZ_ASSERT(!JS_IsExceptionPending(cx)); if (!GetOrCreateDOMReflector(cx, result, args.rval())) { MOZ_ASSERT(JS_IsExceptionPending(cx)); return false; } return true; } MOZ_CAN_RUN_SCRIPT static bool set_browser(JSContext* cx, JS::Handle obj, void* void_self, JSJitSetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "ServiceWorkerGlobalScope", "browser", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_SETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); return JS_DefineProperty(cx, obj, "browser", args[0], JSPROP_ENUMERATE); } static const JSJitInfo browser_getterinfo = { { get_browser }, { prototypes::id::ServiceWorkerGlobalScope }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ true, /* isMovable. Not relevant for setters. */ true, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; static const JSJitInfo browser_setterinfo = { { (JSJitGetterOp)set_browser }, { prototypes::id::ServiceWorkerGlobalScope }, { PrototypeTraits::Depth }, JSJitInfo::Setter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; static void _finalize(JS::GCContext* gcx, JSObject* obj) { mozilla::dom::ServiceWorkerGlobalScope* self = UnwrapPossiblyNotInitializedDOMObject(obj); if (self) { JS::SetNativeObjectReservedSlot(obj, DOM_OBJECT_SLOT, JS::UndefinedValue()); ClearWrapper(self, self, obj); mozilla::dom::FinalizeGlobal(gcx, obj); if (size_t mallocBytes = BindingJSObjectMallocBytes(self)) { JS::RemoveAssociatedMemory(obj, mallocBytes, JS::MemoryUse::DOMBinding); } AddForDeferredFinalization(self); } } MOZ_GLOBINIT static const JSFunctionSpec sMethods_specs[] = { JS_FNSPEC("skipWaiting", (GenericMethod), reinterpret_cast(&skipWaiting_methodinfo), 0, JSPROP_ENUMERATE, nullptr), JS_FS_END }; static const Prefable sMethods[] = { { nullptr, &sMethods_specs[0] }, { nullptr, nullptr } }; MOZ_GLOBINIT static const JSPropertySpec sAttributes_specs[] = { JSPropertySpec::nativeAccessors("clients", JSPROP_ENUMERATE, GenericGetter, &clients_getterinfo, nullptr, nullptr), JSPropertySpec::nativeAccessors("registration", JSPROP_ENUMERATE, GenericGetter, ®istration_getterinfo, nullptr, nullptr), JSPropertySpec::nativeAccessors("oninstall", JSPROP_ENUMERATE, GenericGetter, &oninstall_getterinfo, GenericSetter, &oninstall_setterinfo), JSPropertySpec::nativeAccessors("onactivate", JSPROP_ENUMERATE, GenericGetter, &onactivate_getterinfo, GenericSetter, &onactivate_setterinfo), JSPropertySpec::nativeAccessors("onfetch", JSPROP_ENUMERATE, GenericGetter, &onfetch_getterinfo, GenericSetter, &onfetch_setterinfo), JSPropertySpec::nativeAccessors("onmessage", JSPROP_ENUMERATE, GenericGetter, &onmessage_getterinfo, GenericSetter, &onmessage_setterinfo), JSPropertySpec::nativeAccessors("onmessageerror", JSPROP_ENUMERATE, GenericGetter, &onmessageerror_getterinfo, GenericSetter, &onmessageerror_setterinfo), JSPropertySpec::nativeAccessors("onpush", JSPROP_ENUMERATE, GenericGetter, &onpush_getterinfo, GenericSetter, &onpush_setterinfo), JSPropertySpec::nativeAccessors("onpushsubscriptionchange", JSPROP_ENUMERATE, GenericGetter, &onpushsubscriptionchange_getterinfo, GenericSetter, &onpushsubscriptionchange_setterinfo), JSPropertySpec::nativeAccessors("onnotificationclick", JSPROP_ENUMERATE, GenericGetter, &onnotificationclick_getterinfo, GenericSetter, &onnotificationclick_setterinfo), JSPropertySpec::nativeAccessors("onnotificationclose", JSPROP_ENUMERATE, GenericGetter, &onnotificationclose_getterinfo, GenericSetter, &onnotificationclose_setterinfo), JS_PS_END, JSPropertySpec::nativeAccessors("cookieStore", JSPROP_ENUMERATE, GenericGetter, &cookieStore_getterinfo, nullptr, nullptr), JSPropertySpec::nativeAccessors("oncookiechange", JSPROP_ENUMERATE, GenericGetter, &oncookiechange_getterinfo, GenericSetter, &oncookiechange_setterinfo), JS_PS_END, JSPropertySpec::nativeAccessors("browser", JSPROP_ENUMERATE, GenericGetter, &browser_getterinfo, GenericSetter, &browser_setterinfo), JSPropertySpec::nativeAccessors("chrome", JSPROP_ENUMERATE, GenericGetter, &browser_getterinfo, GenericSetter, &browser_setterinfo), JS_PS_END }; static const PrefableDisablers sAttributes_disablers12 = { WebIDLPrefIndex::dom_cookieStore_enabled, 0, false, OriginTrial(0), nullptr }; static const PrefableDisablers sAttributes_disablers15 = { WebIDLPrefIndex::NoPref, 0, false, OriginTrial(0), &extensions::ExtensionAPIAllowed }; static const Prefable sAttributes[] = { { nullptr, &sAttributes_specs[0] }, { &sAttributes_disablers12, &sAttributes_specs[12] }, { &sAttributes_disablers15, &sAttributes_specs[15] }, { nullptr, nullptr } }; static const NativePropertiesN<2> sNativeProperties = { false, 0, false, 0, true, 0 /* sMethods */, true, 1 /* sAttributes */, false, 0, false, 0, false, 0, -1, 0, nullptr, { { sMethods, nullptr }, { sAttributes, nullptr } } }; static const DOMInterfaceInfo sInterfaceObjectInfo = { { ThrowingConstructor, &sEmptyNativePropertyHooks }, WorkerGlobalScope_Binding::GetConstructorObjectHandle, PrototypeTraits::Depth, prototypes::id::ServiceWorkerGlobalScope, true, 0, "ServiceWorkerGlobalScope", }; static const DOMIfaceAndProtoJSClass sPrototypeClass = { { "ServiceWorkerGlobalScopePrototype", JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), JS_NULL_CLASS_OPS, JS_NULL_CLASS_SPEC, JS_NULL_CLASS_EXT, JS_NULL_OBJECT_OPS }, eGlobalInterfacePrototype, prototypes::id::ServiceWorkerGlobalScope, PrototypeTraits::Depth, &sEmptyNativePropertyHooks, WorkerGlobalScope_Binding::GetProtoObject }; bool ConstructorEnabled(JSContext* aCx, JS::Handle aObj) { MOZ_ASSERT(!NS_IsMainThread(), "Why did we even get called?"); const char* name = JS::GetClass(aObj)->name; if (strcmp(name, "ServiceWorkerGlobalScope")) { return false; } return true; } static JS::Handle GetProtoObjectHandle(JSContext* aCx); static const JSClassOps sClassOps = { nullptr, /* addProperty */ nullptr, /* delProperty */ nullptr, /* enumerate */ mozilla::dom::EnumerateGlobal, /* newEnumerate */ mozilla::dom::ResolveGlobal, /* resolve */ mozilla::dom::MayResolveGlobal, /* mayResolve */ _finalize, /* finalize */ nullptr, /* call */ nullptr, /* construct */ JS_GlobalObjectTraceHook, /* trace */ }; static const DOMJSClass sClass = { { "ServiceWorkerGlobalScope", JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_DOM_GLOBAL | JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(DOM_GLOBAL_SLOTS), &sClassOps, JS_NULL_CLASS_SPEC, &NativeTypeHelpers::sClassExtension, JS_NULL_OBJECT_OPS }, { prototypes::id::EventTarget, prototypes::id::WorkerGlobalScope, prototypes::id::ServiceWorkerGlobalScope, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, std::is_base_of_v, &sEmptyNativePropertyHooks, GetProtoObjectHandle, GetCCParticipant::Get(), nullptr, nullptr }; static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, "Must have the right minimal number of reserved slots."); static_assert(JSCLASS_GLOBAL_APPLICATION_SLOTS >= 3, "Must have enough reserved slots."); bool Wrap(JSContext* aCx, mozilla::dom::ServiceWorkerGlobalScope* aObject, nsWrapperCache* aCache, JS::RealmOptions& aOptions, JSPrincipals* aPrincipal, JS::MutableHandle aReflector) { static_assert(std::is_same_v); MOZ_ASSERT(static_cast(aObject) == reinterpret_cast(aObject), "Multiple inheritance for mozilla::dom::WorkerGlobalScope is broken."); MOZ_ASSERT(static_cast(aObject) == reinterpret_cast(aObject), "Multiple inheritance for mozilla::dom::EventTarget is broken."); MOZ_ASSERT(ToSupportsIsCorrect(aObject)); MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), "nsISupports must be on our primary inheritance chain"); if (!CreateGlobal(aCx, aObject, aCache, sClass.ToJSClass(), aOptions, aPrincipal, aReflector)) { aCache->ReleaseWrapper(aObject); aCache->ClearWrapper(); return false; } // aReflector is a new global, so has a new realm. Enter it // before doing anything with it. JSAutoRealm ar(aCx, aReflector); if (!DefineProperties(aCx, aReflector, sNativeProperties.Upcast(), nullptr)) { aCache->ReleaseWrapper(aObject); aCache->ClearWrapper(); return false; } return true; } void CreateInterfaceObjects(JSContext* aCx, JS::Handle aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, DefineInterfaceProperty aDefineOnGlobal) { JS::Heap* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::ServiceWorkerGlobalScope); JS::Heap* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::ServiceWorkerGlobalScope); JS::Handle parentProto(WorkerGlobalScope_Binding::GetProtoObjectHandle(aCx)); if (!parentProto) { return; } JS::Handle constructorProto(WorkerGlobalScope_Binding::GetConstructorObjectHandle(aCx)); if (!constructorProto) { return; } dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, &sPrototypeClass, protoCache, constructorProto, &sInterfaceObjectInfo, 0, false, Span{}, interfaceCache, sNativeProperties.Upcast(), nullptr, "ServiceWorkerGlobalScope", ShouldExpose(aCx, aGlobal, aDefineOnGlobal), nullptr, true, nullptr); JS::AssertObjectIsNotGray(*protoCache); JS::Handle proto = JS::Handle::fromMarkedLocation(protoCache->unsafeAddress()); if (!proto) { *protoCache = nullptr; if (interfaceCache) { *interfaceCache = nullptr; } return; } { bool succeeded; if (!JS_SetImmutablePrototype(aCx, proto, &succeeded)) { *protoCache = nullptr; if (interfaceCache) { *interfaceCache = nullptr; } return; } MOZ_ASSERT(succeeded, "making a fresh prototype object's [[Prototype]] " "immutable can internally fail, but it should " "never be unsuccessful"); } } static JS::Handle GetProtoObjectHandle(JSContext* aCx) { /* Get the interface prototype object for this class. This will create the object as needed. */ return GetPerInterfaceObjectHandle(aCx, prototypes::id::ServiceWorkerGlobalScope, &CreateInterfaceObjects, DefineInterfaceProperty::CheckExposure); } JS::Handle GetConstructorObjectHandle(JSContext* aCx) { /* Get the interface object for this class. This will create the object as needed. */ return GetPerInterfaceObjectHandle(aCx, constructors::id::ServiceWorkerGlobalScope, &CreateInterfaceObjects, DefineInterfaceProperty::CheckExposure); } } // namespace ServiceWorkerGlobalScope_Binding } // namespace mozilla::dom