Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM TelemetryStopwatch.webidl BY Codegen.py - DO NOT EDIT */
#include <type_traits>
#include "AtomList.h"
#include "MainThreadUtils.h"
#include "TelemetryStopwatchBinding.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/Atomics.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/Nullable.h"
#include "mozilla/dom/PrimitiveConversions.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/SimpleGlobalObject.h"
#include "mozilla/dom/XrayExpandoClass.h"
#include "mozilla/telemetry/Stopwatch.h"
#include "nsContentUtils.h"
namespace mozilla::dom {
namespace binding_detail {}; // Just to make sure it's known as a namespace
using namespace mozilla::dom::binding_detail;
TelemetryStopwatchOptions::TelemetryStopwatchOptions()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
TelemetryStopwatchOptions::InitIds(JSContext* cx, TelemetryStopwatchOptionsAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->inSeconds_id.init(cx, "inSeconds")) {
return false;
}
return true;
}
bool
TelemetryStopwatchOptions::Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
{
// Passing a null JSContext is OK only if we're initing from null,
// Since in that case we will not have to do any property gets
// Also evaluate isNullOrUndefined in order to avoid false-positive
// checkers by static analysis tools
MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
TelemetryStopwatchOptionsAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<TelemetryStopwatchOptionsAtoms>(cx);
if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
!InitIds(cx, atomsCache)) {
return false;
}
}
if (!IsConvertibleToDictionary(val)) {
return cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>(sourceDescription, "dictionary");
}
bool isNull = val.isNullOrUndefined();
// We only need these if !isNull, in which case we have |cx|.
Maybe<JS::Rooted<JSObject *> > object;
Maybe<JS::Rooted<JS::Value> > temp;
if (!isNull) {
MOZ_ASSERT(cx);
object.emplace(cx, &val.toObject());
temp.emplace(cx);
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->inSeconds_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), "'inSeconds' member of TelemetryStopwatchOptions", &mInSeconds)) {
return false;
}
} else {
mInSeconds = false;
}
mIsAnyMemberPresent = true;
return true;
}
bool
TelemetryStopwatchOptions::Init(JSContext* cx_, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
{
// We don't want to use sourceDescription for our context here;
// that's not really what it's formatted for.
BindingCallContext cx(cx_, nullptr);
return Init(cx, val, sourceDescription, passedToJSImpl);
}
void
TelemetryStopwatchOptions::TraceDictionary(JSTracer* trc)
{
}
TelemetryStopwatchOptions&
TelemetryStopwatchOptions::operator=(const TelemetryStopwatchOptions& aOther)
{
DictionaryBase::operator=(aOther);
mInSeconds = aOther.mInSeconds;
return *this;
}
bool
TelemetryStopwatchOptions::operator==(const TelemetryStopwatchOptions& aOther) const
{
if (mInSeconds != aOther.mInSeconds) {
return false;
}
return true;
}
namespace TelemetryStopwatch_Binding {
MOZ_CAN_RUN_SCRIPT static bool
start(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "TelemetryStopwatch.start");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"TelemetryStopwatch", "start", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::Rooted<JSObject*> obj(cx, &args.callee());
if (!args.requireAtLeast(cx, "TelemetryStopwatch.start", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
binding_detail::FakeString<char16_t> arg0;
if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
return false;
}
JS::Rooted<JSObject*> arg1(cx);
if (args.hasDefined(1)) {
if (args[1].isObject()) {
arg1 = &args[1].toObject();
} else if (args[1].isNullOrUndefined()) {
arg1 = nullptr;
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Argument 2");
return false;
}
} else {
arg1 = nullptr;
}
binding_detail::FastTelemetryStopwatchOptions arg2;
if (!arg2.Init(cx, (args.hasDefined(2)) ? args[2] : JS::NullHandleValue, "Argument 3", false)) {
return false;
}
bool result(mozilla::telemetry::Stopwatch::Start(global, NonNullHelper(Constify(arg0)), arg1, Constify(arg2)));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setBoolean(result);
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
running(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "TelemetryStopwatch.running");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"TelemetryStopwatch", "running", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::Rooted<JSObject*> obj(cx, &args.callee());
if (!args.requireAtLeast(cx, "TelemetryStopwatch.running", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
binding_detail::FakeString<char16_t> arg0;
if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
return false;
}
JS::Rooted<JSObject*> arg1(cx);
if (args.hasDefined(1)) {
if (args[1].isObject()) {
arg1 = &args[1].toObject();
} else if (args[1].isNullOrUndefined()) {
arg1 = nullptr;
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Argument 2");
return false;
}
} else {
arg1 = nullptr;
}
bool result(mozilla::telemetry::Stopwatch::Running(global, NonNullHelper(Constify(arg0)), arg1));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setBoolean(result);
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
cancel(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "TelemetryStopwatch.cancel");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"TelemetryStopwatch", "cancel", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::Rooted<JSObject*> obj(cx, &args.callee());
if (!args.requireAtLeast(cx, "TelemetryStopwatch.cancel", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
binding_detail::FakeString<char16_t> arg0;
if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
return false;
}
JS::Rooted<JSObject*> arg1(cx);
if (args.hasDefined(1)) {
if (args[1].isObject()) {
arg1 = &args[1].toObject();
} else if (args[1].isNullOrUndefined()) {
arg1 = nullptr;
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Argument 2");
return false;
}
} else {
arg1 = nullptr;
}
bool result(mozilla::telemetry::Stopwatch::Cancel(global, NonNullHelper(Constify(arg0)), arg1));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setBoolean(result);
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
timeElapsed(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "TelemetryStopwatch.timeElapsed");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"TelemetryStopwatch", "timeElapsed", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::Rooted<JSObject*> obj(cx, &args.callee());
if (!args.requireAtLeast(cx, "TelemetryStopwatch.timeElapsed", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
binding_detail::FakeString<char16_t> arg0;
if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
return false;
}
JS::Rooted<JSObject*> arg1(cx);
if (args.hasDefined(1)) {
if (args[1].isObject()) {
arg1 = &args[1].toObject();
} else if (args[1].isNullOrUndefined()) {
arg1 = nullptr;
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Argument 2");
return false;
}
} else {
arg1 = nullptr;
}
bool arg2;
if (args.hasDefined(2)) {
if (!ValueToPrimitive<bool, eDefault>(cx, args[2], "Argument 3", &arg2)) {
return false;
}
} else {
arg2 = false;
}
int32_t result(mozilla::telemetry::Stopwatch::TimeElapsed(global, NonNullHelper(Constify(arg0)), arg1, arg2));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setInt32(int32_t(result));
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
finish(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "TelemetryStopwatch.finish");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"TelemetryStopwatch", "finish", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::Rooted<JSObject*> obj(cx, &args.callee());
if (!args.requireAtLeast(cx, "TelemetryStopwatch.finish", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
binding_detail::FakeString<char16_t> arg0;
if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
return false;
}
JS::Rooted<JSObject*> arg1(cx);
if (args.hasDefined(1)) {
if (args[1].isObject()) {
arg1 = &args[1].toObject();
} else if (args[1].isNullOrUndefined()) {
arg1 = nullptr;
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Argument 2");
return false;
}
} else {
arg1 = nullptr;
}
bool arg2;
if (args.hasDefined(2)) {
if (!ValueToPrimitive<bool, eDefault>(cx, args[2], "Argument 3", &arg2)) {
return false;
}
} else {
arg2 = false;
}
bool result(mozilla::telemetry::Stopwatch::Finish(global, NonNullHelper(Constify(arg0)), arg1, arg2));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setBoolean(result);
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
startKeyed(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "TelemetryStopwatch.startKeyed");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"TelemetryStopwatch", "startKeyed", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::Rooted<JSObject*> obj(cx, &args.callee());
if (!args.requireAtLeast(cx, "TelemetryStopwatch.startKeyed", 2)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
binding_detail::FakeString<char16_t> arg0;
if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
return false;
}
binding_detail::FakeString<char16_t> arg1;
if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
return false;
}
JS::Rooted<JSObject*> arg2(cx);
if (args.hasDefined(2)) {
if (args[2].isObject()) {
arg2 = &args[2].toObject();
} else if (args[2].isNullOrUndefined()) {
arg2 = nullptr;
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Argument 3");
return false;
}
} else {
arg2 = nullptr;
}
binding_detail::FastTelemetryStopwatchOptions arg3;
if (!arg3.Init(cx, (args.hasDefined(3)) ? args[3] : JS::NullHandleValue, "Argument 4", false)) {
return false;
}
bool result(mozilla::telemetry::Stopwatch::StartKeyed(global, NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), arg2, Constify(arg3)));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setBoolean(result);
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
runningKeyed(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "TelemetryStopwatch.runningKeyed");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"TelemetryStopwatch", "runningKeyed", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::Rooted<JSObject*> obj(cx, &args.callee());
if (!args.requireAtLeast(cx, "TelemetryStopwatch.runningKeyed", 2)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
binding_detail::FakeString<char16_t> arg0;
if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
return false;
}
binding_detail::FakeString<char16_t> arg1;
if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
return false;
}
JS::Rooted<JSObject*> arg2(cx);
if (args.hasDefined(2)) {
if (args[2].isObject()) {
arg2 = &args[2].toObject();
} else if (args[2].isNullOrUndefined()) {
arg2 = nullptr;
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Argument 3");
return false;
}
} else {
arg2 = nullptr;
}
bool result(mozilla::telemetry::Stopwatch::RunningKeyed(global, NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), arg2));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setBoolean(result);
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
cancelKeyed(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "TelemetryStopwatch.cancelKeyed");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"TelemetryStopwatch", "cancelKeyed", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::Rooted<JSObject*> obj(cx, &args.callee());
if (!args.requireAtLeast(cx, "TelemetryStopwatch.cancelKeyed", 2)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
binding_detail::FakeString<char16_t> arg0;
if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
return false;
}
binding_detail::FakeString<char16_t> arg1;
if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
return false;
}
JS::Rooted<JSObject*> arg2(cx);
if (args.hasDefined(2)) {
if (args[2].isObject()) {
arg2 = &args[2].toObject();
} else if (args[2].isNullOrUndefined()) {
arg2 = nullptr;
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Argument 3");
return false;
}
} else {
arg2 = nullptr;
}
bool result(mozilla::telemetry::Stopwatch::CancelKeyed(global, NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), arg2));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setBoolean(result);
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
timeElapsedKeyed(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "TelemetryStopwatch.timeElapsedKeyed");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"TelemetryStopwatch", "timeElapsedKeyed", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::Rooted<JSObject*> obj(cx, &args.callee());
if (!args.requireAtLeast(cx, "TelemetryStopwatch.timeElapsedKeyed", 2)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
binding_detail::FakeString<char16_t> arg0;
if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
return false;
}
binding_detail::FakeString<char16_t> arg1;
if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
return false;
}
JS::Rooted<JSObject*> arg2(cx);
if (args.hasDefined(2)) {
if (args[2].isObject()) {
arg2 = &args[2].toObject();
} else if (args[2].isNullOrUndefined()) {
arg2 = nullptr;
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Argument 3");
return false;
}
} else {
arg2 = nullptr;
}
bool arg3;
if (args.hasDefined(3)) {
if (!ValueToPrimitive<bool, eDefault>(cx, args[3], "Argument 4", &arg3)) {
return false;
}
} else {
arg3 = false;
}
int32_t result(mozilla::telemetry::Stopwatch::TimeElapsedKeyed(global, NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), arg2, arg3));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setInt32(int32_t(result));
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
finishKeyed(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "TelemetryStopwatch.finishKeyed");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"TelemetryStopwatch", "finishKeyed", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::Rooted<JSObject*> obj(cx, &args.callee());
if (!args.requireAtLeast(cx, "TelemetryStopwatch.finishKeyed", 2)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
binding_detail::FakeString<char16_t> arg0;
if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
return false;
}
binding_detail::FakeString<char16_t> arg1;
if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
return false;
}
JS::Rooted<JSObject*> arg2(cx);
if (args.hasDefined(2)) {
if (args[2].isObject()) {
arg2 = &args[2].toObject();
} else if (args[2].isNullOrUndefined()) {
arg2 = nullptr;
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Argument 3");
return false;
}
} else {
arg2 = nullptr;
}
bool arg3;
if (args.hasDefined(3)) {
if (!ValueToPrimitive<bool, eDefault>(cx, args[3], "Argument 4", &arg3)) {
return false;
}
} else {
arg3 = false;
}
bool result(mozilla::telemetry::Stopwatch::FinishKeyed(global, NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), arg2, arg3));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setBoolean(result);
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
setTestModeEnabled(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"TelemetryStopwatch", "setTestModeEnabled", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::Rooted<JSObject*> obj(cx, &args.callee());
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
bool arg0;
if (args.hasDefined(0)) {
if (!ValueToPrimitive<bool, eDefault>(cx, args[0], "Argument 1", &arg0)) {
return false;
}
} else {
arg0 = true;
}
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::telemetry::Stopwatch::SetTestModeEnabled(global, arg0))>, "Should be returning void here");
mozilla::telemetry::Stopwatch::SetTestModeEnabled(global, arg0);
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setUndefined();
return true;
}
static const JSFunctionSpec sStaticMethods_specs[] = {
JS_FNSPEC("start", start, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("running", running, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("cancel", cancel, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("timeElapsed", timeElapsed, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("finish", finish, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("startKeyed", startKeyed, nullptr, 2, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("runningKeyed", runningKeyed, nullptr, 2, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("cancelKeyed", cancelKeyed, nullptr, 2, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("timeElapsedKeyed", timeElapsedKeyed, nullptr, 2, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("finishKeyed", finishKeyed, nullptr, 2, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("setTestModeEnabled", setTestModeEnabled, nullptr, 0, JSPROP_ENUMERATE, nullptr),
JS_FS_END
};
static const Prefable<const JSFunctionSpec> sStaticMethods[] = {
{ nullptr, &sStaticMethods_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(11 <= 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[11];
static PropertyInfo sNativeProperties_propertyInfos[11];
static const NativePropertiesN<1> sNativeProperties = {
true, 0 /* sStaticMethods */,
false, 0,
false, 0,
false, 0,
false, 0,
false, 0,
false, 0,
-1,
11,
sNativeProperties_sortedPropertyIndices,
{
{ sStaticMethods, &sNativeProperties_propertyInfos[0] }
}
};
static_assert(11 < 1ull << (CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount)),
"We have a property info count that is oversized");
bool sNativePropertiesInited = false;
const NativePropertyHooks sNativePropertyHooks = {
nullptr,
{ sNativeProperties.Upcast(), nullptr, &sNativePropertiesInited },
prototypes::id::_ID_Count,
constructors::id::TelemetryStopwatch,
&DefaultXrayExpandoObjectClass
};
static const DOMIfaceAndProtoJSClass sNamespaceObjectClass = {
{
"TelemetryStopwatch",
JSCLASS_IS_DOMIFACEANDPROTOJSCLASS,
JS_NULL_CLASS_OPS,
JS_NULL_CLASS_SPEC,
JS_NULL_CLASS_EXT,
JS_NULL_OBJECT_OPS
},
eNamespace,
prototypes::id::_ID_Count,
0,
&sNativePropertyHooks,
JS::GetRealmObjectPrototype
};
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
{
return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
}
void
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
{
JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmObjectPrototype(aCx));
if (!constructorProto) {
return;
}
JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::TelemetryStopwatch);
dom::CreateNamespaceObject(aCx, aGlobal, constructorProto,
sNamespaceObjectClass,
interfaceCache,
sNativeProperties.Upcast(),
nullptr,
"TelemetryStopwatch", aDefineOnGlobal);
}
JSObject*
GetConstructorObject(JSContext* aCx)
{
return GetConstructorObjectHandle(aCx);
}
} // namespace TelemetryStopwatch_Binding
} // namespace mozilla::dom