Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM PerformanceResourceTiming.webidl BY Codegen.py - DO NOT EDIT */
#include <type_traits>
#include "MainThreadUtils.h"
#include "PerformanceEntryBinding.h"
#include "PerformanceResourceTimingBinding.h"
#include "WrapperFactory.h"
#include "XrayWrapper.h"
#include "js/Array.h"
#include "js/CallAndConstruct.h"
#include "js/Exception.h"
#include "js/ForOfIterator.h"
#include "js/MapAndSet.h"
#include "js/Object.h"
#include "js/PropertyAndElement.h"
#include "js/PropertyDescriptor.h"
#include "js/experimental/JitInfo.h"
#include "mozilla/Atomics.h"
#include "mozilla/BasePrincipal.h"
#include "mozilla/FloatingPoint.h"
#include "mozilla/OwningNonNull.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/dom/BindingCallContext.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/DOMJSClass.h"
#include "mozilla/dom/NonRefcountedDOMObject.h"
#include "mozilla/dom/PerformanceResourceTiming.h"
#include "mozilla/dom/PerformanceServerTiming.h"
#include "mozilla/dom/PrimitiveConversions.h"
#include "mozilla/dom/WebIDLPrefs.h"
#include "mozilla/dom/XrayExpandoClass.h"
#include "nsJSPrincipals.h"
namespace mozilla::dom {
namespace binding_detail {}; // Just to make sure it's known as a namespace
using namespace mozilla::dom::binding_detail;
namespace PerformanceResourceTiming_Binding {
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<PerformanceEntry_Binding::NativeType>::value,
"Can't inherit from an interface with a different ownership model.");
MOZ_CAN_RUN_SCRIPT static bool
get_initiatorType(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitGetterCallArgs args)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"PerformanceResourceTiming", "initiatorType", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::PerformanceResourceTiming*>(void_self);
DOMString result;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(MOZ_KnownLive(self)->GetInitiatorType(result))>, "Should be returning void here");
MOZ_KnownLive(self)->GetInitiatorType(result);
MOZ_ASSERT(!JS_IsExceptionPending(cx));
if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
return false;
}
return true;
}
static const JSJitInfo initiatorType_getterinfo = {
{ get_initiatorType },
{ prototypes::id::PerformanceResourceTiming },
{ PrototypeTraits<prototypes::id::PerformanceResourceTiming>::Depth },
JSJitInfo::Getter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_STRING, /* 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_nextHopProtocol(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitGetterCallArgs args)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"PerformanceResourceTiming", "nextHopProtocol", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::PerformanceResourceTiming*>(void_self);
DOMString result;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(MOZ_KnownLive(self)->GetNextHopProtocol(result))>, "Should be returning void here");
MOZ_KnownLive(self)->GetNextHopProtocol(result);
MOZ_ASSERT(!JS_IsExceptionPending(cx));
if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
return false;
}
return true;
}
static const JSJitInfo nextHopProtocol_getterinfo = {
{ get_nextHopProtocol },
{ prototypes::id::PerformanceResourceTiming },
{ PrototypeTraits<prototypes::id::PerformanceResourceTiming>::Depth },
JSJitInfo::Getter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_STRING, /* 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_workerStart(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitGetterCallArgs args)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"PerformanceResourceTiming", "workerStart", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::PerformanceResourceTiming*>(void_self);
double result(MOZ_KnownLive(self)->WorkerStart());
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().set(JS_NumberValue(double(result)));
return true;
}
static const JSJitInfo workerStart_getterinfo = {
{ get_workerStart },
{ prototypes::id::PerformanceResourceTiming },
{ PrototypeTraits<prototypes::id::PerformanceResourceTiming>::Depth },
JSJitInfo::Getter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
true, /* 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_redirectStart(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitGetterCallArgs args)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"PerformanceResourceTiming", "redirectStart", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::PerformanceResourceTiming*>(void_self);
NonNull<nsIPrincipal> subjectPrincipal;
{
JS::Realm* realm = js::GetContextRealm(cx);
MOZ_ASSERT(realm);
JSPrincipals* principals = JS::GetRealmPrincipals(realm);
nsIPrincipal* principal = nsJSPrincipals::get(principals);
subjectPrincipal = principal;
}
double result(MOZ_KnownLive(self)->RedirectStart(MOZ_KnownLive(NonNullHelper(subjectPrincipal))));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().set(JS_NumberValue(double(result)));
return true;
}
static const JSJitInfo redirectStart_getterinfo = {
{ get_redirectStart },
{ prototypes::id::PerformanceResourceTiming },
{ PrototypeTraits<prototypes::id::PerformanceResourceTiming>::Depth },
JSJitInfo::Getter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
true, /* 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_redirectEnd(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitGetterCallArgs args)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"PerformanceResourceTiming", "redirectEnd", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::PerformanceResourceTiming*>(void_self);
NonNull<nsIPrincipal> subjectPrincipal;
{
JS::Realm* realm = js::GetContextRealm(cx);
MOZ_ASSERT(realm);
JSPrincipals* principals = JS::GetRealmPrincipals(realm);
nsIPrincipal* principal = nsJSPrincipals::get(principals);
subjectPrincipal = principal;
}
double result(MOZ_KnownLive(self)->RedirectEnd(MOZ_KnownLive(NonNullHelper(subjectPrincipal))));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().set(JS_NumberValue(double(result)));
return true;
}
static const JSJitInfo redirectEnd_getterinfo = {
{ get_redirectEnd },
{ prototypes::id::PerformanceResourceTiming },
{ PrototypeTraits<prototypes::id::PerformanceResourceTiming>::Depth },
JSJitInfo::Getter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
true, /* 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_fetchStart(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitGetterCallArgs args)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"PerformanceResourceTiming", "fetchStart", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::PerformanceResourceTiming*>(void_self);
double result(MOZ_KnownLive(self)->FetchStart());
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().set(JS_NumberValue(double(result)));
return true;
}
static const JSJitInfo fetchStart_getterinfo = {
{ get_fetchStart },
{ prototypes::id::PerformanceResourceTiming },
{ PrototypeTraits<prototypes::id::PerformanceResourceTiming>::Depth },
JSJitInfo::Getter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
true, /* 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_domainLookupStart(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitGetterCallArgs args)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"PerformanceResourceTiming", "domainLookupStart", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::PerformanceResourceTiming*>(void_self);
NonNull<nsIPrincipal> subjectPrincipal;
{
JS::Realm* realm = js::GetContextRealm(cx);
MOZ_ASSERT(realm);
JSPrincipals* principals = JS::GetRealmPrincipals(realm);
nsIPrincipal* principal = nsJSPrincipals::get(principals);
subjectPrincipal = principal;
}
double result(MOZ_KnownLive(self)->DomainLookupStart(MOZ_KnownLive(NonNullHelper(subjectPrincipal))));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().set(JS_NumberValue(double(result)));
return true;
}
static const JSJitInfo domainLookupStart_getterinfo = {
{ get_domainLookupStart },
{ prototypes::id::PerformanceResourceTiming },
{ PrototypeTraits<prototypes::id::PerformanceResourceTiming>::Depth },
JSJitInfo::Getter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
true, /* 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_domainLookupEnd(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitGetterCallArgs args)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"PerformanceResourceTiming", "domainLookupEnd", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::PerformanceResourceTiming*>(void_self);
NonNull<nsIPrincipal> subjectPrincipal;
{
JS::Realm* realm = js::GetContextRealm(cx);
MOZ_ASSERT(realm);
JSPrincipals* principals = JS::GetRealmPrincipals(realm);
nsIPrincipal* principal = nsJSPrincipals::get(principals);
subjectPrincipal = principal;
}
double result(MOZ_KnownLive(self)->DomainLookupEnd(MOZ_KnownLive(NonNullHelper(subjectPrincipal))));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().set(JS_NumberValue(double(result)));
return true;
}
static const JSJitInfo domainLookupEnd_getterinfo = {
{ get_domainLookupEnd },
{ prototypes::id::PerformanceResourceTiming },
{ PrototypeTraits<prototypes::id::PerformanceResourceTiming>::Depth },
JSJitInfo::Getter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
true, /* 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_connectStart(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitGetterCallArgs args)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"PerformanceResourceTiming", "connectStart", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::PerformanceResourceTiming*>(void_self);
NonNull<nsIPrincipal> subjectPrincipal;
{
JS::Realm* realm = js::GetContextRealm(cx);
MOZ_ASSERT(realm);
JSPrincipals* principals = JS::GetRealmPrincipals(realm);
nsIPrincipal* principal = nsJSPrincipals::get(principals);
subjectPrincipal = principal;
}
double result(MOZ_KnownLive(self)->ConnectStart(MOZ_KnownLive(NonNullHelper(subjectPrincipal))));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().set(JS_NumberValue(double(result)));
return true;
}
static const JSJitInfo connectStart_getterinfo = {
{ get_connectStart },
{ prototypes::id::PerformanceResourceTiming },
{ PrototypeTraits<prototypes::id::PerformanceResourceTiming>::Depth },
JSJitInfo::Getter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
true, /* 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_connectEnd(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitGetterCallArgs args)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"PerformanceResourceTiming", "connectEnd", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::PerformanceResourceTiming*>(void_self);
NonNull<nsIPrincipal> subjectPrincipal;
{
JS::Realm* realm = js::GetContextRealm(cx);
MOZ_ASSERT(realm);
JSPrincipals* principals = JS::GetRealmPrincipals(realm);
nsIPrincipal* principal = nsJSPrincipals::get(principals);
subjectPrincipal = principal;
}
double result(MOZ_KnownLive(self)->ConnectEnd(MOZ_KnownLive(NonNullHelper(subjectPrincipal))));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().set(JS_NumberValue(double(result)));
return true;
}
static const JSJitInfo connectEnd_getterinfo = {
{ get_connectEnd },
{ prototypes::id::PerformanceResourceTiming },
{ PrototypeTraits<prototypes::id::PerformanceResourceTiming>::Depth },
JSJitInfo::Getter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
true, /* 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_secureConnectionStart(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitGetterCallArgs args)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"PerformanceResourceTiming", "secureConnectionStart", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::PerformanceResourceTiming*>(void_self);
NonNull<nsIPrincipal> subjectPrincipal;
{
JS::Realm* realm = js::GetContextRealm(cx);
MOZ_ASSERT(realm);
JSPrincipals* principals = JS::GetRealmPrincipals(realm);
nsIPrincipal* principal = nsJSPrincipals::get(principals);
subjectPrincipal = principal;
}
double result(MOZ_KnownLive(self)->SecureConnectionStart(MOZ_KnownLive(NonNullHelper(subjectPrincipal))));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().set(JS_NumberValue(double(result)));
return true;
}
static const JSJitInfo secureConnectionStart_getterinfo = {
{ get_secureConnectionStart },
{ prototypes::id::PerformanceResourceTiming },
{ PrototypeTraits<prototypes::id::PerformanceResourceTiming>::Depth },
JSJitInfo::Getter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
true, /* 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_requestStart(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitGetterCallArgs args)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"PerformanceResourceTiming", "requestStart", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::PerformanceResourceTiming*>(void_self);
NonNull<nsIPrincipal> subjectPrincipal;
{
JS::Realm* realm = js::GetContextRealm(cx);
MOZ_ASSERT(realm);
JSPrincipals* principals = JS::GetRealmPrincipals(realm);
nsIPrincipal* principal = nsJSPrincipals::get(principals);
subjectPrincipal = principal;
}
double result(MOZ_KnownLive(self)->RequestStart(MOZ_KnownLive(NonNullHelper(subjectPrincipal))));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().set(JS_NumberValue(double(result)));
return true;
}
static const JSJitInfo requestStart_getterinfo = {
{ get_requestStart },
{ prototypes::id::PerformanceResourceTiming },
{ PrototypeTraits<prototypes::id::PerformanceResourceTiming>::Depth },
JSJitInfo::Getter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
true, /* 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_responseStart(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitGetterCallArgs args)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"PerformanceResourceTiming", "responseStart", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::PerformanceResourceTiming*>(void_self);
NonNull<nsIPrincipal> subjectPrincipal;
{
JS::Realm* realm = js::GetContextRealm(cx);
MOZ_ASSERT(realm);
JSPrincipals* principals = JS::GetRealmPrincipals(realm);
nsIPrincipal* principal = nsJSPrincipals::get(principals);
subjectPrincipal = principal;
}
double result(MOZ_KnownLive(self)->ResponseStart(MOZ_KnownLive(NonNullHelper(subjectPrincipal))));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().set(JS_NumberValue(double(result)));
return true;
}
static const JSJitInfo responseStart_getterinfo = {
{ get_responseStart },
{ prototypes::id::PerformanceResourceTiming },
{ PrototypeTraits<prototypes::id::PerformanceResourceTiming>::Depth },
JSJitInfo::Getter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
true, /* 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_responseEnd(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitGetterCallArgs args)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"PerformanceResourceTiming", "responseEnd", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::PerformanceResourceTiming*>(void_self);
double result(MOZ_KnownLive(self)->ResponseEnd());
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().set(JS_NumberValue(double(result)));
return true;
}
static const JSJitInfo responseEnd_getterinfo = {
{ get_responseEnd },
{ prototypes::id::PerformanceResourceTiming },
{ PrototypeTraits<prototypes::id::PerformanceResourceTiming>::Depth },
JSJitInfo::Getter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
true, /* 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_transferSize(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitGetterCallArgs args)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"PerformanceResourceTiming", "transferSize", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::PerformanceResourceTiming*>(void_self);
NonNull<nsIPrincipal> subjectPrincipal;
{
JS::Realm* realm = js::GetContextRealm(cx);
MOZ_ASSERT(realm);
JSPrincipals* principals = JS::GetRealmPrincipals(realm);
nsIPrincipal* principal = nsJSPrincipals::get(principals);
subjectPrincipal = principal;
}
uint64_t result(MOZ_KnownLive(self)->TransferSize(MOZ_KnownLive(NonNullHelper(subjectPrincipal))));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().set(JS_NumberValue(double(result)));
return true;
}
static const JSJitInfo transferSize_getterinfo = {
{ get_transferSize },
{ prototypes::id::PerformanceResourceTiming },
{ PrototypeTraits<prototypes::id::PerformanceResourceTiming>::Depth },
JSJitInfo::Getter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
true, /* 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_encodedBodySize(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitGetterCallArgs args)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"PerformanceResourceTiming", "encodedBodySize", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::PerformanceResourceTiming*>(void_self);
NonNull<nsIPrincipal> subjectPrincipal;
{
JS::Realm* realm = js::GetContextRealm(cx);
MOZ_ASSERT(realm);
JSPrincipals* principals = JS::GetRealmPrincipals(realm);
nsIPrincipal* principal = nsJSPrincipals::get(principals);
subjectPrincipal = principal;
}
uint64_t result(MOZ_KnownLive(self)->EncodedBodySize(MOZ_KnownLive(NonNullHelper(subjectPrincipal))));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().set(JS_NumberValue(double(result)));
return true;
}
static const JSJitInfo encodedBodySize_getterinfo = {
{ get_encodedBodySize },
{ prototypes::id::PerformanceResourceTiming },
{ PrototypeTraits<prototypes::id::PerformanceResourceTiming>::Depth },
JSJitInfo::Getter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
true, /* 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_decodedBodySize(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitGetterCallArgs args)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"PerformanceResourceTiming", "decodedBodySize", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::PerformanceResourceTiming*>(void_self);
NonNull<nsIPrincipal> subjectPrincipal;
{
JS::Realm* realm = js::GetContextRealm(cx);
MOZ_ASSERT(realm);
JSPrincipals* principals = JS::GetRealmPrincipals(realm);
nsIPrincipal* principal = nsJSPrincipals::get(principals);
subjectPrincipal = principal;
}
uint64_t result(MOZ_KnownLive(self)->DecodedBodySize(MOZ_KnownLive(NonNullHelper(subjectPrincipal))));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().set(JS_NumberValue(double(result)));
return true;
}
static const JSJitInfo decodedBodySize_getterinfo = {
{ get_decodedBodySize },
{ prototypes::id::PerformanceResourceTiming },
{ PrototypeTraits<prototypes::id::PerformanceResourceTiming>::Depth },
JSJitInfo::Getter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
true, /* 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_serverTiming(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitGetterCallArgs args)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"PerformanceResourceTiming", "serverTiming", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::PerformanceResourceTiming*>(void_self);
// Have to either root across the getter call or reget after.
bool isXray;
JS::Rooted<JSObject*> slotStorage(cx, GetCachedSlotStorageObject(cx, obj, &isXray));
if (!slotStorage) {
return false;
}
const size_t slotIndex = isXray ? (xpc::JSSLOT_EXPANDO_COUNT + 0) : (DOM_INSTANCE_RESERVED_SLOTS + 0);
MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(JS::GetClass(slotStorage)) > slotIndex);
{
// Scope for cachedVal
JS::Value cachedVal = JS::GetReservedSlot(slotStorage, slotIndex);
if (!cachedVal.isUndefined()) {
args.rval().set(cachedVal);
// The cached value is in the compartment of slotStorage,
// so wrap into the caller compartment as needed.
return MaybeWrapNonDOMObjectValue(cx, args.rval());
}
}
NonNull<nsIPrincipal> subjectPrincipal;
{
JS::Realm* realm = js::GetContextRealm(cx);
MOZ_ASSERT(realm);
JSPrincipals* principals = JS::GetRealmPrincipals(realm);
nsIPrincipal* principal = nsJSPrincipals::get(principals);
subjectPrincipal = principal;
}
nsTArray<StrongPtrForMember<mozilla::dom::PerformanceServerTiming>> result;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(MOZ_KnownLive(self)->GetServerTiming(result, MOZ_KnownLive(NonNullHelper(subjectPrincipal))))>, "Should be returning void here");
MOZ_KnownLive(self)->GetServerTiming(result, MOZ_KnownLive(NonNullHelper(subjectPrincipal)));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
{
JS::Rooted<JSObject*> conversionScope(cx, isXray ? JS::CurrentGlobalOrNull(cx) : slotStorage);
JSAutoRealm ar(cx, conversionScope);
do { // block we break out of when done wrapping
uint32_t length = result.Length();
JS::Rooted<JSObject*> returnArray(cx, JS::NewArrayObject(cx, length));
if (!returnArray) {
return false;
}
// Scope for 'tmp'
{
JS::Rooted<JS::Value> tmp(cx);
for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
// Control block to let us common up the JS_DefineElement calls when there
// are different ways to succeed at wrapping the object.
do {
if (!GetOrCreateDOMReflector(cx, result[sequenceIdx0], &tmp)) {
MOZ_ASSERT(JS_IsExceptionPending(cx));
return false;
}
break;
} while (false);
if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
JSPROP_ENUMERATE)) {
return false;
}
}
}
args.rval().setObject(*returnArray);
break;
} while (false);
JS::Rooted<JSObject*> rvalObj(cx, &args.rval().toObject());
if (!JS_FreezeObject(cx, rvalObj)) {
return false;
}
}
{ // And now store things in the realm of our slotStorage.
JSAutoRealm ar(cx, slotStorage);
// Make a copy so that we don't do unnecessary wrapping on args.rval().
JS::Rooted<JS::Value> storedVal(cx, args.rval());
if (!MaybeWrapNonDOMObjectValue(cx, &storedVal)) {
return false;
}
JS::SetReservedSlot(slotStorage, slotIndex, storedVal);
if (!isXray) {
// In the Xray case we don't need to do this, because getting the
// expando object already preserved our wrapper.
PreserveWrapper(self);
}
}
// And now make sure args.rval() is in the caller realm.
return MaybeWrapNonDOMObjectValue(cx, args.rval());
}
static const JSJitInfo serverTiming_getterinfo = {
{ get_serverTiming },
{ prototypes::id::PerformanceResourceTiming },
{ PrototypeTraits<prototypes::id::PerformanceResourceTiming>::Depth },
JSJitInfo::Getter,
JSJitInfo::AliasDOMSets, /* 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. */
true, /* isLazilyCachedInSlot. Only relevant for getters. */
false, /* isTypedMethod. Only relevant for methods. */
(DOM_INSTANCE_RESERVED_SLOTS + 0) /* Reserved slot index, if we're stored in a slot, else 0. */
};
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 0) <= JSJitInfo::maxSlotIndex, "We won't fit");
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 0) < 2, "There is no slot for us");
MOZ_CAN_RUN_SCRIPT static bool
toJSON(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, const JSJitMethodCallArgs& args)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"PerformanceResourceTiming", "toJSON", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::PerformanceResourceTiming*>(void_self);
JS::Rooted<JSObject*> result(cx, JS_NewPlainObject(cx));
if (!result) {
return false;
}
if (!PerformanceEntry_Binding::CollectJSONAttributes(cx, obj, MOZ_KnownLive(self), result)) {
return false;
}
if (!PerformanceResourceTiming_Binding::CollectJSONAttributes(cx, obj, MOZ_KnownLive(self), result)) {
return false;
}
args.rval().setObject(*result);
return true;
}
static const JSJitInfo toJSON_methodinfo = {
{ (JSJitGetterOp)toJSON },
{ prototypes::id::PerformanceResourceTiming },
{ PrototypeTraits<prototypes::id::PerformanceResourceTiming>::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. */
};
static bool
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
{
mozilla::dom::PerformanceResourceTiming* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PerformanceResourceTiming>(obj);
// We don't want to preserve if we don't have a wrapper, and we
// obviously can't preserve if we're not initialized.
if (self && self->GetWrapperPreserveColor()) {
PreserveWrapper(self);
}
return true;
}
static void
_finalize(JS::GCContext* gcx, JSObject* obj)
{
mozilla::dom::PerformanceResourceTiming* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PerformanceResourceTiming>(obj);
if (self) {
JS::SetReservedSlot(obj, DOM_OBJECT_SLOT, JS::UndefinedValue());
ClearWrapper(self, self, obj);
if (size_t mallocBytes = BindingJSObjectMallocBytes(self)) {
JS::RemoveAssociatedMemory(obj, mallocBytes,
JS::MemoryUse::DOMBinding);
}
AddForDeferredFinalization<mozilla::dom::PerformanceResourceTiming>(self);
}
}
static nsWrapperCache*
_getWrapperCache(JS::Handle<JSObject*> obj)
{
mozilla::dom::PerformanceResourceTiming* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PerformanceResourceTiming>(obj);
return self;
}
static size_t
_objectMoved(JSObject* obj, JSObject* old)
{
mozilla::dom::PerformanceResourceTiming* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PerformanceResourceTiming>(obj);
if (self) {
UpdateWrapper(self, self, obj, old);
}
return 0;
}
static const JSFunctionSpec sMethods_specs[] = {
JS_FNSPEC("toJSON", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&toJSON_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
JS_FS_END
};
static const Prefable<const JSFunctionSpec> sMethods[] = {
{ nullptr, &sMethods_specs[0] },
{ nullptr, nullptr }
};
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
"We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
"We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
static const JSPropertySpec sAttributes_specs[] = {
JSPropertySpec::nativeAccessors("initiatorType", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &initiatorType_getterinfo, nullptr, nullptr),
JSPropertySpec::nativeAccessors("nextHopProtocol", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &nextHopProtocol_getterinfo, nullptr, nullptr),
JSPropertySpec::nativeAccessors("workerStart", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &workerStart_getterinfo, nullptr, nullptr),
JSPropertySpec::nativeAccessors("redirectStart", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &redirectStart_getterinfo, nullptr, nullptr),
JSPropertySpec::nativeAccessors("redirectEnd", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &redirectEnd_getterinfo, nullptr, nullptr),
JSPropertySpec::nativeAccessors("fetchStart", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &fetchStart_getterinfo, nullptr, nullptr),
JSPropertySpec::nativeAccessors("domainLookupStart", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &domainLookupStart_getterinfo, nullptr, nullptr),
JSPropertySpec::nativeAccessors("domainLookupEnd", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &domainLookupEnd_getterinfo, nullptr, nullptr),
JSPropertySpec::nativeAccessors("connectStart", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &connectStart_getterinfo, nullptr, nullptr),
JSPropertySpec::nativeAccessors("connectEnd", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &connectEnd_getterinfo, nullptr, nullptr),
JSPropertySpec::nativeAccessors("secureConnectionStart", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &secureConnectionStart_getterinfo, nullptr, nullptr),
JSPropertySpec::nativeAccessors("requestStart", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &requestStart_getterinfo, nullptr, nullptr),
JSPropertySpec::nativeAccessors("responseStart", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &responseStart_getterinfo, nullptr, nullptr),
JSPropertySpec::nativeAccessors("responseEnd", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &responseEnd_getterinfo, nullptr, nullptr),
JSPropertySpec::nativeAccessors("transferSize", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &transferSize_getterinfo, nullptr, nullptr),
JSPropertySpec::nativeAccessors("encodedBodySize", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &encodedBodySize_getterinfo, nullptr, nullptr),
JSPropertySpec::nativeAccessors("decodedBodySize", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &decodedBodySize_getterinfo, nullptr, nullptr),
JS_PS_END,
JSPropertySpec::nativeAccessors("serverTiming", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &serverTiming_getterinfo, nullptr, nullptr),
JS_PS_END
};
static const PrefableDisablers sAttributes_disablers18 = {
WebIDLPrefIndex::NoPref, 0, true, OriginTrial(0), nullptr
};
static const Prefable<const JSPropertySpec> sAttributes[] = {
{ nullptr, &sAttributes_specs[0] },
{ &sAttributes_disablers18, &sAttributes_specs[18] },
{ nullptr, nullptr }
};
static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
"We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
static_assert(17 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
"We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
static uint16_t sNativeProperties_sortedPropertyIndices[19];
static PropertyInfo sNativeProperties_propertyInfos[19];
static const NativePropertiesN<2> sNativeProperties = {
false, 0,
false, 0,
true, 0 /* sMethods */,
true, 1 /* sAttributes */,
false, 0,
false, 0,
false, 0,
-1,
19,
sNativeProperties_sortedPropertyIndices,
{
{ sMethods, &sNativeProperties_propertyInfos[0] },
{ sAttributes, &sNativeProperties_propertyInfos[1] }
}
};
static_assert(19 < 1ull << (CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount)),
"We have a property info count that is oversized");
MOZ_CAN_RUN_SCRIPT bool
CollectJSONAttributes(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PerformanceResourceTiming* self, JS::Rooted<JSObject*>& result)
{
JS::Rooted<JSObject*> unwrappedObj(cx, js::CheckedUnwrapStatic(obj));
if (!unwrappedObj) {
// How did that happen? We managed to get called with that
// object as "this"! Just give up on sanity.
return false;
}
{ // scope for "temp"
JS::Rooted<JS::Value> temp(cx);
if (!get_initiatorType(cx, obj, self, JSJitGetterCallArgs(&temp))) {
return false;
}
if (!JS_DefineProperty(cx, result, "initiatorType", temp, JSPROP_ENUMERATE)) {
return false;
}
}
{ // scope for "temp"
JS::Rooted<JS::Value> temp(cx);
if (!get_nextHopProtocol(cx, obj, self, JSJitGetterCallArgs(&temp))) {
return false;
}
if (!JS_DefineProperty(cx, result, "nextHopProtocol", temp, JSPROP_ENUMERATE)) {
return false;
}
}
{ // scope for "temp"
JS::Rooted<JS::Value> temp(cx);
if (!get_workerStart(cx, obj, self, JSJitGetterCallArgs(&temp))) {
return false;
}
if (!JS_DefineProperty(cx, result, "workerStart", temp, JSPROP_ENUMERATE)) {
return false;
}
}
{ // scope for "temp"
JS::Rooted<JS::Value> temp(cx);
if (!get_redirectStart(cx, obj, self, JSJitGetterCallArgs(&temp))) {
return false;
}
if (!JS_DefineProperty(cx, result, "redirectStart", temp, JSPROP_ENUMERATE)) {
return false;
}
}
{ // scope for "temp"
JS::Rooted<JS::Value> temp(cx);
if (!get_redirectEnd(cx, obj, self, JSJitGetterCallArgs(&temp))) {
return false;
}
if (!JS_DefineProperty(cx, result, "redirectEnd", temp, JSPROP_ENUMERATE)) {
return false;
}
}
{ // scope for "temp"
JS::Rooted<JS::Value> temp(cx);
if (!get_fetchStart(cx, obj, self, JSJitGetterCallArgs(&temp))) {
return false;
}
if (!JS_DefineProperty(cx, result, "fetchStart", temp, JSPROP_ENUMERATE)) {
return false;
}
}
{ // scope for "temp"
JS::Rooted<JS::Value> temp(cx);
if (!get_domainLookupStart(cx, obj, self, JSJitGetterCallArgs(&temp))) {
return false;
}
if (!JS_DefineProperty(cx, result, "domainLookupStart", temp, JSPROP_ENUMERATE)) {
return false;
}
}
{ // scope for "temp"
JS::Rooted<JS::Value> temp(cx);
if (!get_domainLookupEnd(cx, obj, self, JSJitGetterCallArgs(&temp))) {
return false;
}
if (!JS_DefineProperty(cx, result, "domainLookupEnd", temp, JSPROP_ENUMERATE)) {
return false;
}
}
{ // scope for "temp"
JS::Rooted<JS::Value> temp(cx);
if (!get_connectStart(cx, obj, self, JSJitGetterCallArgs(&temp))) {
return false;
}
if (!JS_DefineProperty(cx, result, "connectStart", temp, JSPROP_ENUMERATE)) {
return false;
}
}
{ // scope for "temp"
JS::Rooted<JS::Value> temp(cx);
if (!get_connectEnd(cx, obj, self, JSJitGetterCallArgs(&temp))) {
return false;
}
if (!JS_DefineProperty(cx, result, "connectEnd", temp, JSPROP_ENUMERATE)) {
return false;
}
}
{ // scope for "temp"
JS::Rooted<JS::Value> temp(cx);
if (!get_secureConnectionStart(cx, obj, self, JSJitGetterCallArgs(&temp))) {
return false;
}
if (!JS_DefineProperty(cx, result, "secureConnectionStart", temp, JSPROP_ENUMERATE)) {
return false;
}
}
{ // scope for "temp"
JS::Rooted<JS::Value> temp(cx);
if (!get_requestStart(cx, obj, self, JSJitGetterCallArgs(&temp))) {
return false;
}
if (!JS_DefineProperty(cx, result, "requestStart", temp, JSPROP_ENUMERATE)) {
return false;
}
}
{ // scope for "temp"
JS::Rooted<JS::Value> temp(cx);
if (!get_responseStart(cx, obj, self, JSJitGetterCallArgs(&temp))) {
return false;
}
if (!JS_DefineProperty(cx, result, "responseStart", temp, JSPROP_ENUMERATE)) {
return false;
}
}
{ // scope for "temp"
JS::Rooted<JS::Value> temp(cx);
if (!get_responseEnd(cx, obj, self, JSJitGetterCallArgs(&temp))) {
return false;
}
if (!JS_DefineProperty(cx, result, "responseEnd", temp, JSPROP_ENUMERATE)) {
return false;
}
}
{ // scope for "temp"
JS::Rooted<JS::Value> temp(cx);
if (!get_transferSize(cx, obj, self, JSJitGetterCallArgs(&temp))) {
return false;
}
if (!JS_DefineProperty(cx, result, "transferSize", temp, JSPROP_ENUMERATE)) {
return false;
}
}
{ // scope for "temp"
JS::Rooted<JS::Value> temp(cx);
if (!get_encodedBodySize(cx, obj, self, JSJitGetterCallArgs(&temp))) {
return false;
}
if (!JS_DefineProperty(cx, result, "encodedBodySize", temp, JSPROP_ENUMERATE)) {
return false;
}
}
{ // scope for "temp"
JS::Rooted<JS::Value> temp(cx);
if (!get_decodedBodySize(cx, obj, self, JSJitGetterCallArgs(&temp))) {
return false;
}
if (!JS_DefineProperty(cx, result, "decodedBodySize", temp, JSPROP_ENUMERATE)) {
return false;
}
}
// This is unfortunately a linear scan through sAttributes, but we
// only do it for things which _might_ be disabled, which should
// help keep the performance problems down.
if (IsGetterEnabled(cx, unwrappedObj, (JSJitGetterOp)get_serverTiming, sAttributes)) {
JS::Rooted<JS::Value> temp(cx);
if (!get_serverTiming(cx, obj, self, JSJitGetterCallArgs(&temp))) {
return false;
}
if (!JS_DefineProperty(cx, result, "serverTiming", temp, JSPROP_ENUMERATE)) {
return false;
}
}
return true;
}
// This may allocate too many slots, because we only really need
// slots for our non-interface-typed members that we cache. But
// allocating slots only for those would make the slot index
// computations much more complicated, so let's do this the simple
// way for now.
DEFINE_XRAY_EXPANDO_CLASS(static, sXrayExpandoObjectClass, 1);
bool sNativePropertiesInited = false;
const NativePropertyHooks sNativePropertyHooks = {
nullptr,
{ sNativeProperties.Upcast(), nullptr, &sNativePropertiesInited },
prototypes::id::PerformanceResourceTiming,
constructors::id::PerformanceResourceTiming,
&sXrayExpandoObjectClass
};
static const DOMInterfaceInfo sInterfaceObjectInfo = {
{ ThrowingConstructor, &sNativePropertyHooks },
PerformanceEntry_Binding::GetConstructorObject,
prototypes::id::PerformanceResourceTiming,
PrototypeTraits<prototypes::id::PerformanceResourceTiming>::Depth,
true,
};
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
{
"PerformanceResourceTimingPrototype",
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
},
eInterfacePrototype,
prototypes::id::PerformanceResourceTiming,
PrototypeTraits<prototypes::id::PerformanceResourceTiming>::Depth,
&sNativePropertyHooks,
PerformanceEntry_Binding::GetProtoObject
};
static const JSClassOps sClassOps = {
_addProperty, /* addProperty */
nullptr, /* delProperty */
nullptr, /* enumerate */
nullptr, /* newEnumerate */
nullptr, /* resolve */
nullptr, /* mayResolve */
_finalize, /* finalize */
nullptr, /* call */
nullptr, /* construct */
nullptr, /* trace */
};
static const js::ClassExtension sClassExtension = {
_objectMoved /* objectMovedOp */
};
static const DOMJSClass sClass = {
{ "PerformanceResourceTiming",
JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(2),
&sClassOps,
JS_NULL_CLASS_SPEC,
&sClassExtension,
JS_NULL_OBJECT_OPS
},
{ prototypes::id::PerformanceEntry, prototypes::id::PerformanceResourceTiming, prototypes::id::_ID_Count, 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<nsISupports, mozilla::dom::PerformanceResourceTiming>,
&sNativePropertyHooks,
FindAssociatedGlobalForNative<mozilla::dom::PerformanceResourceTiming>::Get,
GetProtoObjectHandle,
GetCCParticipant<mozilla::dom::PerformanceResourceTiming>::Get(),
nullptr,
_getWrapperCache
};
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
"Must have the right minimal number of reserved slots.");
static_assert(2 >= 2,
"Must have enough reserved slots.");
bool
Wrap(JSContext* aCx, mozilla::dom::PerformanceResourceTiming* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
{
static_assert(!std::is_base_of_v<NonRefcountedDOMObject, mozilla::dom::PerformanceResourceTiming>,
"Shouldn't have wrappercached things that are not refcounted.");
static_assert(std::is_same_v<decltype(aObject), mozilla::dom::PerformanceResourceTiming*>);
MOZ_ASSERT(static_cast<mozilla::dom::PerformanceEntry*>(aObject) ==
reinterpret_cast<mozilla::dom::PerformanceEntry*>(aObject),
"Multiple inheritance for mozilla::dom::PerformanceEntry is broken.");
MOZ_ASSERT(ToSupportsIsCorrect(aObject));
MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
MOZ_ASSERT(!aCache->GetWrapper(),
"You should probably not be using Wrap() directly; use "
"GetOrCreateDOMReflector instead");
MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
"nsISupports must be on our primary inheritance chain");
// If the wrapper cache contains a dead reflector then finalize that
// now, ensuring that the finalizer for the old reflector always
// runs before the new reflector is created and attached. This
// avoids the awkward situation where there are multiple reflector
// objects that contain pointers to the same native.
if (JSObject* oldReflector = aCache->GetWrapperMaybeDead()) {
_finalize(nullptr /* unused */, oldReflector);
MOZ_ASSERT(!aCache->GetWrapperMaybeDead());
}
JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
if (!global) {
return false;
}
MOZ_ASSERT(JS_IsGlobalObject(global));
JS::AssertObjectIsNotGray(global);
// That might have ended up wrapping us already, due to the wonders
// of XBL. Check for that, and bail out as needed.
aReflector.set(aCache->GetWrapper());
if (aReflector) {
#ifdef DEBUG
AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
#endif // DEBUG
return true;
}
JSAutoRealm ar(aCx, global);
JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
if (!canonicalProto) {
return false;
}
JS::Rooted<JSObject*> proto(aCx);
if (aGivenProto) {
proto = aGivenProto;
// Unfortunately, while aGivenProto was in the compartment of aCx
// coming in, we changed compartments to that of "parent" so may need
// to wrap the proto here.
if (js::GetContextCompartment(aCx) != JS::GetCompartment(proto)) {
if (!JS_WrapObject(aCx, &proto)) {
return false;
}
}
} else {
proto = canonicalProto;
}
BindingJSObjectCreator<mozilla::dom::PerformanceResourceTiming> creator(aCx);
creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
if (!aReflector) {
return false;
}
aCache->SetWrapper(aReflector);
creator.InitializationSucceeded();
MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
aCache->GetWrapperPreserveColor() == aReflector);
// If proto != canonicalProto, we have to preserve our wrapper;
// otherwise we won't be able to properly recreate it later, since
// we won't know what proto to use. Note that we don't check
// aGivenProto here, since it's entirely possible (and even
// somewhat common) to have a non-null aGivenProto which is the
// same as canonicalProto.
if (proto != canonicalProto) {
PreserveWrapper(aObject);
}
return true;
}
void
ClearCachedServerTimingValue(mozilla::dom::PerformanceResourceTiming* aObject)
{
JSObject* obj;
obj = aObject->GetWrapper();
if (!obj) {
return;
}
JS::SetReservedSlot(obj, (DOM_INSTANCE_RESERVED_SLOTS + 0), JS::UndefinedValue());
xpc::ClearXrayExpandoSlots(obj, (xpc::JSSLOT_EXPANDO_COUNT + 0));
}
void
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
{
JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::PerformanceResourceTiming);
JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::PerformanceResourceTiming);
JS::Handle<JSObject*> parentProto(PerformanceEntry_Binding::GetProtoObjectHandle(aCx));
if (!parentProto) {
return;
}
JS::Handle<JSObject*> constructorProto(PerformanceEntry_Binding::GetConstructorObjectHandle(aCx));
if (!constructorProto) {
return;
}
dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
&sPrototypeClass, protoCache,
constructorProto, &sInterfaceObjectInfo, 0, false, Span<const LegacyFactoryFunction, 0>{},
interfaceCache,
sNativeProperties.Upcast(),
nullptr,
"PerformanceResourceTiming", aDefineOnGlobal,
nullptr,
false,
nullptr);
}
JSObject*
GetProtoObject(JSContext* aCx)
{
return GetProtoObjectHandle(aCx);
}
JSObject*
GetConstructorObject(JSContext* aCx)
{
return GetConstructorObjectHandle(aCx);
}
} // namespace PerformanceResourceTiming_Binding
} // namespace mozilla::dom