Copy as Markdown
Other Tools
/* THIS FILE IS AUTOGENERATED FROM ChromeUtils.webidl BY Codegen.py - DO NOT EDIT */
#include <type_traits>
#include "AtomList.h"
#include "ChromeUtilsBinding.h"
#include "JSProcessActorBinding.h"
#include "JSWindowActorBinding.h"
#include "MainThreadUtils.h"
#include "WindowBinding.h"
#include "WrapperFactory.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 "jsapi.h"
#include "jsfriendapi.h"
#include "mozilla/Atomics.h"
#include "mozilla/FloatingPoint.h"
#include "mozilla/OwningNonNull.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/devtools/HeapSnapshot.h"
#include "mozilla/dom/BindingCallContext.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/ChromeUtils.h"
#include "mozilla/dom/DOMJSClass.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/MozQueryInterface.h"
#include "mozilla/dom/NonRefcountedDOMObject.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/dom/PrimitiveConversions.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/Record.h"
#include "mozilla/dom/RootedDictionary.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/SimpleGlobalObject.h"
#include "mozilla/dom/ToJSValue.h"
#include "mozilla/dom/TypedArray.h"
#include "mozilla/dom/UnionTypes.h"
#include "mozilla/dom/WebIDLPrefs.h"
#include "mozilla/dom/XrayExpandoClass.h"
#include "nsContentUtils.h"
#include "nsIDOMProcessChild.h"
#include "nsIDOMProcessParent.h"
#include "nsIPrincipal.h"
namespace mozilla {
namespace dom {
namespace binding_detail {}; // Just to make sure it's known as a namespace
using namespace mozilla::dom::binding_detail;
namespace binding_detail {
constexpr nsLiteralCString EnumStrings<WebIDLProcType>::Values[19];
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, WebIDLProcType aArgument, JS::MutableHandle<JS::Value> aValue)
{
MOZ_ASSERT(uint32_t(aArgument) < std::size(binding_detail::EnumStrings<WebIDLProcType>::Values));
JSString* resultStr =
JS_NewStringCopyN(aCx, binding_detail::EnumStrings<WebIDLProcType>::Values[uint32_t(aArgument)].BeginReading(),
binding_detail::EnumStrings<WebIDLProcType>::Values[uint32_t(aArgument)].Length());
if (!resultStr) {
return false;
}
aValue.setString(resultStr);
return true;
}
namespace binding_detail {
constexpr nsLiteralCString EnumStrings<WebIDLUtilityActorName>::Values[8];
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, WebIDLUtilityActorName aArgument, JS::MutableHandle<JS::Value> aValue)
{
MOZ_ASSERT(uint32_t(aArgument) < std::size(binding_detail::EnumStrings<WebIDLUtilityActorName>::Values));
JSString* resultStr =
JS_NewStringCopyN(aCx, binding_detail::EnumStrings<WebIDLUtilityActorName>::Values[uint32_t(aArgument)].BeginReading(),
binding_detail::EnumStrings<WebIDLUtilityActorName>::Values[uint32_t(aArgument)].Length());
if (!resultStr) {
return false;
}
aValue.setString(resultStr);
return true;
}
namespace binding_detail {
constexpr nsLiteralCString EnumStrings<ImportESModuleTargetGlobal>::Values[4];
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, ImportESModuleTargetGlobal aArgument, JS::MutableHandle<JS::Value> aValue)
{
MOZ_ASSERT(uint32_t(aArgument) < std::size(binding_detail::EnumStrings<ImportESModuleTargetGlobal>::Values));
JSString* resultStr =
JS_NewStringCopyN(aCx, binding_detail::EnumStrings<ImportESModuleTargetGlobal>::Values[uint32_t(aArgument)].BeginReading(),
binding_detail::EnumStrings<ImportESModuleTargetGlobal>::Values[uint32_t(aArgument)].Length());
if (!resultStr) {
return false;
}
aValue.setString(resultStr);
return true;
}
namespace binding_detail {
constexpr nsLiteralCString EnumStrings<Base64URLDecodePadding>::Values[3];
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, Base64URLDecodePadding aArgument, JS::MutableHandle<JS::Value> aValue)
{
MOZ_ASSERT(uint32_t(aArgument) < std::size(binding_detail::EnumStrings<Base64URLDecodePadding>::Values));
JSString* resultStr =
JS_NewStringCopyN(aCx, binding_detail::EnumStrings<Base64URLDecodePadding>::Values[uint32_t(aArgument)].BeginReading(),
binding_detail::EnumStrings<Base64URLDecodePadding>::Values[uint32_t(aArgument)].Length());
if (!resultStr) {
return false;
}
aValue.setString(resultStr);
return true;
}
namespace binding_detail {
constexpr nsLiteralCString EnumStrings<PopupBlockerState>::Values[5];
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, PopupBlockerState aArgument, JS::MutableHandle<JS::Value> aValue)
{
MOZ_ASSERT(uint32_t(aArgument) < std::size(binding_detail::EnumStrings<PopupBlockerState>::Values));
JSString* resultStr =
JS_NewStringCopyN(aCx, binding_detail::EnumStrings<PopupBlockerState>::Values[uint32_t(aArgument)].BeginReading(),
binding_detail::EnumStrings<PopupBlockerState>::Values[uint32_t(aArgument)].Length());
if (!resultStr) {
return false;
}
aValue.setString(resultStr);
return true;
}
namespace binding_detail {
constexpr nsLiteralCString EnumStrings<JSRFPTarget>::Values[3];
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, JSRFPTarget aArgument, JS::MutableHandle<JS::Value> aValue)
{
MOZ_ASSERT(uint32_t(aArgument) < std::size(binding_detail::EnumStrings<JSRFPTarget>::Values));
JSString* resultStr =
JS_NewStringCopyN(aCx, binding_detail::EnumStrings<JSRFPTarget>::Values[uint32_t(aArgument)].BeginReading(),
binding_detail::EnumStrings<JSRFPTarget>::Values[uint32_t(aArgument)].Length());
if (!resultStr) {
return false;
}
aValue.setString(resultStr);
return true;
}
Base64URLDecodeOptions::Base64URLDecodeOptions()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
Base64URLDecodeOptions::InitIds(JSContext* cx, Base64URLDecodeOptionsAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->padding_id.init(cx, "padding")) {
return false;
}
return true;
}
bool
Base64URLDecodeOptions::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());
Base64URLDecodeOptionsAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<Base64URLDecodeOptionsAtoms>(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->padding_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
{
int index;
if (!binding_detail::FindEnumStringIndex<true>(cx, temp.ref(),
binding_detail::EnumStrings<Base64URLDecodePadding>::Values,
"Base64URLDecodePadding", "'padding' member of Base64URLDecodeOptions",
&index)) {
return false;
}
MOZ_ASSERT(index >= 0);
mPadding = static_cast<Base64URLDecodePadding>(index);
}
mIsAnyMemberPresent = true;
} else if (cx) {
// Don't error out if we have no cx. In that
// situation the caller is default-constructing us and we'll
// just assume they know what they're doing.
return cx.ThrowErrorMessage<MSG_MISSING_REQUIRED_DICTIONARY_MEMBER>("'padding' member of Base64URLDecodeOptions");
}
return true;
}
bool
Base64URLDecodeOptions::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
Base64URLDecodeOptions::TraceDictionary(JSTracer* trc)
{
}
Base64URLDecodeOptions&
Base64URLDecodeOptions::operator=(const Base64URLDecodeOptions& aOther)
{
DictionaryBase::operator=(aOther);
mPadding = aOther.mPadding;
return *this;
}
Base64URLEncodeOptions::Base64URLEncodeOptions()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
Base64URLEncodeOptions::InitIds(JSContext* cx, Base64URLEncodeOptionsAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->pad_id.init(cx, "pad")) {
return false;
}
return true;
}
bool
Base64URLEncodeOptions::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());
Base64URLEncodeOptionsAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<Base64URLEncodeOptionsAtoms>(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->pad_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), "'pad' member of Base64URLEncodeOptions", &mPad)) {
return false;
}
mIsAnyMemberPresent = true;
} else if (cx) {
// Don't error out if we have no cx. In that
// situation the caller is default-constructing us and we'll
// just assume they know what they're doing.
return cx.ThrowErrorMessage<MSG_MISSING_REQUIRED_DICTIONARY_MEMBER>("'pad' member of Base64URLEncodeOptions");
}
return true;
}
bool
Base64URLEncodeOptions::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
Base64URLEncodeOptions::TraceDictionary(JSTracer* trc)
{
}
Base64URLEncodeOptions&
Base64URLEncodeOptions::operator=(const Base64URLEncodeOptions& aOther)
{
DictionaryBase::operator=(aOther);
mPad = aOther.mPad;
return *this;
}
CDMInformation::CDMInformation()
{
// Safe to pass a null context if we pass a null value
Init();
}
bool
CDMInformation::InitIds(JSContext* cx, CDMInformationAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->keySystemName_id.init(cx, "keySystemName") ||
!atomsCache->isHardwareDecryption_id.init(cx, "isHardwareDecryption") ||
!atomsCache->isHDCP22Compatible_id.init(cx, "isHDCP22Compatible") ||
!atomsCache->clearlead_id.init(cx, "clearlead") ||
!atomsCache->capabilities_id.init(cx, "capabilities")) {
return false;
}
return true;
}
bool
CDMInformation::Init(const char* sourceDescription, bool passedToJSImpl)
{
return true;
}
bool
CDMInformation::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
CDMInformationAtoms* atomsCache = GetAtomCache<CDMInformationAtoms>(cx);
if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
!InitIds(cx, atomsCache)) {
return false;
}
JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
if (!obj) {
return false;
}
rval.set(JS::ObjectValue(*obj));
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mCapabilities;
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->capabilities_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
bool const & currentValue = mClearlead;
temp.setBoolean(currentValue);
if (!JS_DefinePropertyById(cx, obj, atomsCache->clearlead_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
bool const & currentValue = mIsHDCP22Compatible;
temp.setBoolean(currentValue);
if (!JS_DefinePropertyById(cx, obj, atomsCache->isHDCP22Compatible_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
bool const & currentValue = mIsHardwareDecryption;
temp.setBoolean(currentValue);
if (!JS_DefinePropertyById(cx, obj, atomsCache->isHardwareDecryption_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mKeySystemName;
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->keySystemName_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
return true;
}
void
CDMInformation::TraceDictionary(JSTracer* trc)
{
}
CDMInformation&
CDMInformation::operator=(const CDMInformation& aOther)
{
DictionaryBase::operator=(aOther);
mCapabilities = aOther.mCapabilities;
mClearlead = aOther.mClearlead;
mIsHDCP22Compatible = aOther.mIsHDCP22Compatible;
mIsHardwareDecryption = aOther.mIsHardwareDecryption;
mKeySystemName = aOther.mKeySystemName;
return *this;
}
CompileScriptOptionsDictionary::CompileScriptOptionsDictionary()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
CompileScriptOptionsDictionary::InitIds(JSContext* cx, CompileScriptOptionsDictionaryAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->lazilyParse_id.init(cx, "lazilyParse") ||
!atomsCache->hasReturnValue_id.init(cx, "hasReturnValue") ||
!atomsCache->filename_id.init(cx, "filename") ||
!atomsCache->charset_id.init(cx, "charset")) {
return false;
}
return true;
}
bool
CompileScriptOptionsDictionary::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());
CompileScriptOptionsDictionaryAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<CompileScriptOptionsDictionaryAtoms>(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->charset_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mCharset)) {
return false;
}
} else {
mCharset.AssignLiteral(u"utf-8");
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->filename_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mFilename.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mFilename.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->hasReturnValue_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), "'hasReturnValue' member of CompileScriptOptionsDictionary", &mHasReturnValue)) {
return false;
}
} else {
mHasReturnValue = false;
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->lazilyParse_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), "'lazilyParse' member of CompileScriptOptionsDictionary", &mLazilyParse)) {
return false;
}
} else {
mLazilyParse = false;
}
mIsAnyMemberPresent = true;
return true;
}
bool
CompileScriptOptionsDictionary::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
CompileScriptOptionsDictionary::TraceDictionary(JSTracer* trc)
{
}
CompileScriptOptionsDictionary&
CompileScriptOptionsDictionary::operator=(const CompileScriptOptionsDictionary& aOther)
{
DictionaryBase::operator=(aOther);
mCharset = aOther.mCharset;
mFilename.Reset();
if (aOther.mFilename.WasPassed()) {
mFilename.Construct(aOther.mFilename.Value());
}
mHasReturnValue = aOther.mHasReturnValue;
mLazilyParse = aOther.mLazilyParse;
return *this;
}
FormAutofillConfidences::FormAutofillConfidences()
{
// Safe to pass a null context if we pass a null value
Init();
}
bool
FormAutofillConfidences::InitIds(JSContext* cx, FormAutofillConfidencesAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->ccNumber_id.init(cx, "ccNumber") ||
!atomsCache->ccName_id.init(cx, "ccName")) {
return false;
}
return true;
}
bool
FormAutofillConfidences::Init(const char* sourceDescription, bool passedToJSImpl)
{
{
// scope for any temporaries our default value setting needs.
mCcName = 0.0;
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
mCcNumber = 0.0;
}
mIsAnyMemberPresent = true;
return true;
}
bool
FormAutofillConfidences::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
FormAutofillConfidencesAtoms* atomsCache = GetAtomCache<FormAutofillConfidencesAtoms>(cx);
if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
!InitIds(cx, atomsCache)) {
return false;
}
JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
if (!obj) {
return false;
}
rval.set(JS::ObjectValue(*obj));
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
double const & currentValue = mCcName;
temp.set(JS_NumberValue(double(currentValue)));
if (!JS_DefinePropertyById(cx, obj, atomsCache->ccName_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
double const & currentValue = mCcNumber;
temp.set(JS_NumberValue(double(currentValue)));
if (!JS_DefinePropertyById(cx, obj, atomsCache->ccNumber_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
return true;
}
void
FormAutofillConfidences::TraceDictionary(JSTracer* trc)
{
}
FormAutofillConfidences&
FormAutofillConfidences::operator=(const FormAutofillConfidences& aOther)
{
DictionaryBase::operator=(aOther);
mCcName = aOther.mCcName;
mCcNumber = aOther.mCcNumber;
return *this;
}
HeapSnapshotBoundaries::HeapSnapshotBoundaries()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
HeapSnapshotBoundaries::InitIds(JSContext* cx, HeapSnapshotBoundariesAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->runtime_id.init(cx, "runtime") ||
!atomsCache->globals_id.init(cx, "globals") ||
!atomsCache->debugger_id.init(cx, "debugger")) {
return false;
}
return true;
}
bool
HeapSnapshotBoundaries::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());
HeapSnapshotBoundariesAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<HeapSnapshotBoundariesAtoms>(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->debugger_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mDebugger.Construct();
if (temp.ref().isObject()) {
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunreachable-code"
#pragma clang diagnostic ignored "-Wunreachable-code-return"
#endif // __clang__
if ((passedToJSImpl) && !CallerSubsumes(temp.ref())) {
cx.ThrowErrorMessage<MSG_PERMISSION_DENIED_TO_PASS_ARG>("'debugger' member of HeapSnapshotBoundaries");
return false;
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif // __clang__
(mDebugger.Value()) = &temp.ref().toObject();
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("'debugger' member of HeapSnapshotBoundaries");
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->globals_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mGlobals.Construct();
if (temp.ref().isObject()) {
JS::ForOfIterator iter(cx);
if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
return false;
}
if (!iter.valueIsIterable()) {
cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'globals' member of HeapSnapshotBoundaries", "sequence");
return false;
}
Sequence<JSObject*> &arr = (mGlobals.Value());
JS::Rooted<JS::Value> temp(cx);
while (true) {
bool done;
if (!iter.next(&temp, &done)) {
return false;
}
if (done) {
break;
}
JSObject** slotPtr = arr.AppendElement(nullptr, mozilla::fallible);
if (!slotPtr) {
JS_ReportOutOfMemory(cx);
return false;
}
JSObject*& slot = *slotPtr;
if (temp.isObject()) {
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunreachable-code"
#pragma clang diagnostic ignored "-Wunreachable-code-return"
#endif // __clang__
if ((passedToJSImpl) && !CallerSubsumes(temp)) {
cx.ThrowErrorMessage<MSG_PERMISSION_DENIED_TO_PASS_ARG>("element of 'globals' member of HeapSnapshotBoundaries");
return false;
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif // __clang__
slot = &temp.toObject();
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Element of 'globals' member of HeapSnapshotBoundaries");
return false;
}
}
} else {
cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'globals' member of HeapSnapshotBoundaries", "sequence");
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->runtime_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mRuntime.Construct();
if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), "'runtime' member of HeapSnapshotBoundaries", &(mRuntime.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
return true;
}
bool
HeapSnapshotBoundaries::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
HeapSnapshotBoundaries::TraceDictionary(JSTracer* trc)
{
if (mDebugger.WasPassed()) {
JS::TraceRoot(trc, &mDebugger.Value(), "HeapSnapshotBoundaries.mDebugger");
}
if (mGlobals.WasPassed()) {
DoTraceSequence(trc, mGlobals.Value());
}
}
ImportESModuleOptionsDictionary::ImportESModuleOptionsDictionary()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
ImportESModuleOptionsDictionary::InitIds(JSContext* cx, ImportESModuleOptionsDictionaryAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->global_id.init(cx, "global")) {
return false;
}
return true;
}
bool
ImportESModuleOptionsDictionary::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());
ImportESModuleOptionsDictionaryAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<ImportESModuleOptionsDictionaryAtoms>(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->global_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mGlobal.Construct();
{
int index;
if (!binding_detail::FindEnumStringIndex<true>(cx, temp.ref(),
binding_detail::EnumStrings<ImportESModuleTargetGlobal>::Values,
"ImportESModuleTargetGlobal", "'global' member of ImportESModuleOptionsDictionary",
&index)) {
return false;
}
MOZ_ASSERT(index >= 0);
(mGlobal.Value()) = static_cast<ImportESModuleTargetGlobal>(index);
}
mIsAnyMemberPresent = true;
}
return true;
}
bool
ImportESModuleOptionsDictionary::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
ImportESModuleOptionsDictionary::TraceDictionary(JSTracer* trc)
{
}
ImportESModuleOptionsDictionary&
ImportESModuleOptionsDictionary::operator=(const ImportESModuleOptionsDictionary& aOther)
{
DictionaryBase::operator=(aOther);
mGlobal.Reset();
if (aOther.mGlobal.WasPassed()) {
mGlobal.Construct(aOther.mGlobal.Value());
}
return *this;
}
InteractionData::InteractionData()
{
// Safe to pass a null context if we pass a null value
Init();
}
bool
InteractionData::InitIds(JSContext* cx, InteractionDataAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->scrollingDistanceInPixels_id.init(cx, "scrollingDistanceInPixels") ||
!atomsCache->interactionTimeInMilliseconds_id.init(cx, "interactionTimeInMilliseconds") ||
!atomsCache->interactionCount_id.init(cx, "interactionCount")) {
return false;
}
return true;
}
bool
InteractionData::Init(const char* sourceDescription, bool passedToJSImpl)
{
{
// scope for any temporaries our default value setting needs.
mInteractionCount = 0U;
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
mInteractionTimeInMilliseconds = 0U;
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
mScrollingDistanceInPixels = 0U;
}
mIsAnyMemberPresent = true;
return true;
}
bool
InteractionData::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
InteractionDataAtoms* atomsCache = GetAtomCache<InteractionDataAtoms>(cx);
if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
!InitIds(cx, atomsCache)) {
return false;
}
JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
if (!obj) {
return false;
}
rval.set(JS::ObjectValue(*obj));
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
uint32_t const & currentValue = mInteractionCount;
temp.setNumber(currentValue);
if (!JS_DefinePropertyById(cx, obj, atomsCache->interactionCount_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
uint32_t const & currentValue = mInteractionTimeInMilliseconds;
temp.setNumber(currentValue);
if (!JS_DefinePropertyById(cx, obj, atomsCache->interactionTimeInMilliseconds_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
uint32_t const & currentValue = mScrollingDistanceInPixels;
temp.setNumber(currentValue);
if (!JS_DefinePropertyById(cx, obj, atomsCache->scrollingDistanceInPixels_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
return true;
}
void
InteractionData::TraceDictionary(JSTracer* trc)
{
}
InteractionData&
InteractionData::operator=(const InteractionData& aOther)
{
DictionaryBase::operator=(aOther);
mInteractionCount = aOther.mInteractionCount;
mInteractionTimeInMilliseconds = aOther.mInteractionTimeInMilliseconds;
mScrollingDistanceInPixels = aOther.mScrollingDistanceInPixels;
return *this;
}
LibcConstants::LibcConstants()
{
// Safe to pass a null context if we pass a null value
Init();
}
bool
LibcConstants::InitIds(JSContext* cx, LibcConstantsAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->WNOHANG_id.init(cx, "WNOHANG") ||
!atomsCache->PR_CAPBSET_READ_id.init(cx, "PR_CAPBSET_READ") ||
!atomsCache->POLLOUT_id.init(cx, "POLLOUT") ||
!atomsCache->POLLNVAL_id.init(cx, "POLLNVAL") ||
!atomsCache->POLLIN_id.init(cx, "POLLIN") ||
!atomsCache->POLLHUP_id.init(cx, "POLLHUP") ||
!atomsCache->POLLERR_id.init(cx, "POLLERR") ||
!atomsCache->O_WRONLY_id.init(cx, "O_WRONLY") ||
!atomsCache->O_NONBLOCK_id.init(cx, "O_NONBLOCK") ||
!atomsCache->O_CREAT_id.init(cx, "O_CREAT") ||
!atomsCache->F_SETFL_id.init(cx, "F_SETFL") ||
!atomsCache->F_SETFD_id.init(cx, "F_SETFD") ||
!atomsCache->FD_CLOEXEC_id.init(cx, "FD_CLOEXEC") ||
!atomsCache->EPERM_id.init(cx, "EPERM") ||
!atomsCache->ENOSYS_id.init(cx, "ENOSYS") ||
!atomsCache->EINVAL_id.init(cx, "EINVAL") ||
!atomsCache->EINTR_id.init(cx, "EINTR") ||
!atomsCache->EAGAIN_id.init(cx, "EAGAIN") ||
!atomsCache->EACCES_id.init(cx, "EACCES") ||
!atomsCache->AT_EACCESS_id.init(cx, "AT_EACCESS")) {
return false;
}
return true;
}
bool
LibcConstants::Init(const char* sourceDescription, bool passedToJSImpl)
{
return true;
}
bool
LibcConstants::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
LibcConstantsAtoms* atomsCache = GetAtomCache<LibcConstantsAtoms>(cx);
if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
!InitIds(cx, atomsCache)) {
return false;
}
JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
if (!obj) {
return false;
}
rval.set(JS::ObjectValue(*obj));
if (mAT_EACCESS.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
int32_t const & currentValue = mAT_EACCESS.InternalValue();
temp.setInt32(int32_t(currentValue));
if (!JS_DefinePropertyById(cx, obj, atomsCache->AT_EACCESS_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mEACCES.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
int32_t const & currentValue = mEACCES.InternalValue();
temp.setInt32(int32_t(currentValue));
if (!JS_DefinePropertyById(cx, obj, atomsCache->EACCES_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mEAGAIN.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
int32_t const & currentValue = mEAGAIN.InternalValue();
temp.setInt32(int32_t(currentValue));
if (!JS_DefinePropertyById(cx, obj, atomsCache->EAGAIN_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mEINTR.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
int32_t const & currentValue = mEINTR.InternalValue();
temp.setInt32(int32_t(currentValue));
if (!JS_DefinePropertyById(cx, obj, atomsCache->EINTR_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mEINVAL.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
int32_t const & currentValue = mEINVAL.InternalValue();
temp.setInt32(int32_t(currentValue));
if (!JS_DefinePropertyById(cx, obj, atomsCache->EINVAL_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mENOSYS.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
int32_t const & currentValue = mENOSYS.InternalValue();
temp.setInt32(int32_t(currentValue));
if (!JS_DefinePropertyById(cx, obj, atomsCache->ENOSYS_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mEPERM.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
int32_t const & currentValue = mEPERM.InternalValue();
temp.setInt32(int32_t(currentValue));
if (!JS_DefinePropertyById(cx, obj, atomsCache->EPERM_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mFD_CLOEXEC.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
int32_t const & currentValue = mFD_CLOEXEC.InternalValue();
temp.setInt32(int32_t(currentValue));
if (!JS_DefinePropertyById(cx, obj, atomsCache->FD_CLOEXEC_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mF_SETFD.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
int32_t const & currentValue = mF_SETFD.InternalValue();
temp.setInt32(int32_t(currentValue));
if (!JS_DefinePropertyById(cx, obj, atomsCache->F_SETFD_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mF_SETFL.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
int32_t const & currentValue = mF_SETFL.InternalValue();
temp.setInt32(int32_t(currentValue));
if (!JS_DefinePropertyById(cx, obj, atomsCache->F_SETFL_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mO_CREAT.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
int32_t const & currentValue = mO_CREAT.InternalValue();
temp.setInt32(int32_t(currentValue));
if (!JS_DefinePropertyById(cx, obj, atomsCache->O_CREAT_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mO_NONBLOCK.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
int32_t const & currentValue = mO_NONBLOCK.InternalValue();
temp.setInt32(int32_t(currentValue));
if (!JS_DefinePropertyById(cx, obj, atomsCache->O_NONBLOCK_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mO_WRONLY.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
int32_t const & currentValue = mO_WRONLY.InternalValue();
temp.setInt32(int32_t(currentValue));
if (!JS_DefinePropertyById(cx, obj, atomsCache->O_WRONLY_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mPOLLERR.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
int32_t const & currentValue = mPOLLERR.InternalValue();
temp.setInt32(int32_t(currentValue));
if (!JS_DefinePropertyById(cx, obj, atomsCache->POLLERR_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mPOLLHUP.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
int32_t const & currentValue = mPOLLHUP.InternalValue();
temp.setInt32(int32_t(currentValue));
if (!JS_DefinePropertyById(cx, obj, atomsCache->POLLHUP_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mPOLLIN.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
int32_t const & currentValue = mPOLLIN.InternalValue();
temp.setInt32(int32_t(currentValue));
if (!JS_DefinePropertyById(cx, obj, atomsCache->POLLIN_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mPOLLNVAL.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
int32_t const & currentValue = mPOLLNVAL.InternalValue();
temp.setInt32(int32_t(currentValue));
if (!JS_DefinePropertyById(cx, obj, atomsCache->POLLNVAL_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mPOLLOUT.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
int32_t const & currentValue = mPOLLOUT.InternalValue();
temp.setInt32(int32_t(currentValue));
if (!JS_DefinePropertyById(cx, obj, atomsCache->POLLOUT_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mPR_CAPBSET_READ.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
int32_t const & currentValue = mPR_CAPBSET_READ.InternalValue();
temp.setInt32(int32_t(currentValue));
if (!JS_DefinePropertyById(cx, obj, atomsCache->PR_CAPBSET_READ_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mWNOHANG.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
int32_t const & currentValue = mWNOHANG.InternalValue();
temp.setInt32(int32_t(currentValue));
if (!JS_DefinePropertyById(cx, obj, atomsCache->WNOHANG_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
return true;
}
void
LibcConstants::TraceDictionary(JSTracer* trc)
{
}
LibcConstants&
LibcConstants::operator=(const LibcConstants& aOther)
{
DictionaryBase::operator=(aOther);
mAT_EACCESS.Reset();
if (aOther.mAT_EACCESS.WasPassed()) {
mAT_EACCESS.Construct(aOther.mAT_EACCESS.Value());
}
mEACCES.Reset();
if (aOther.mEACCES.WasPassed()) {
mEACCES.Construct(aOther.mEACCES.Value());
}
mEAGAIN.Reset();
if (aOther.mEAGAIN.WasPassed()) {
mEAGAIN.Construct(aOther.mEAGAIN.Value());
}
mEINTR.Reset();
if (aOther.mEINTR.WasPassed()) {
mEINTR.Construct(aOther.mEINTR.Value());
}
mEINVAL.Reset();
if (aOther.mEINVAL.WasPassed()) {
mEINVAL.Construct(aOther.mEINVAL.Value());
}
mENOSYS.Reset();
if (aOther.mENOSYS.WasPassed()) {
mENOSYS.Construct(aOther.mENOSYS.Value());
}
mEPERM.Reset();
if (aOther.mEPERM.WasPassed()) {
mEPERM.Construct(aOther.mEPERM.Value());
}
mFD_CLOEXEC.Reset();
if (aOther.mFD_CLOEXEC.WasPassed()) {
mFD_CLOEXEC.Construct(aOther.mFD_CLOEXEC.Value());
}
mF_SETFD.Reset();
if (aOther.mF_SETFD.WasPassed()) {
mF_SETFD.Construct(aOther.mF_SETFD.Value());
}
mF_SETFL.Reset();
if (aOther.mF_SETFL.WasPassed()) {
mF_SETFL.Construct(aOther.mF_SETFL.Value());
}
mO_CREAT.Reset();
if (aOther.mO_CREAT.WasPassed()) {
mO_CREAT.Construct(aOther.mO_CREAT.Value());
}
mO_NONBLOCK.Reset();
if (aOther.mO_NONBLOCK.WasPassed()) {
mO_NONBLOCK.Construct(aOther.mO_NONBLOCK.Value());
}
mO_WRONLY.Reset();
if (aOther.mO_WRONLY.WasPassed()) {
mO_WRONLY.Construct(aOther.mO_WRONLY.Value());
}
mPOLLERR.Reset();
if (aOther.mPOLLERR.WasPassed()) {
mPOLLERR.Construct(aOther.mPOLLERR.Value());
}
mPOLLHUP.Reset();
if (aOther.mPOLLHUP.WasPassed()) {
mPOLLHUP.Construct(aOther.mPOLLHUP.Value());
}
mPOLLIN.Reset();
if (aOther.mPOLLIN.WasPassed()) {
mPOLLIN.Construct(aOther.mPOLLIN.Value());
}
mPOLLNVAL.Reset();
if (aOther.mPOLLNVAL.WasPassed()) {
mPOLLNVAL.Construct(aOther.mPOLLNVAL.Value());
}
mPOLLOUT.Reset();
if (aOther.mPOLLOUT.WasPassed()) {
mPOLLOUT.Construct(aOther.mPOLLOUT.Value());
}
mPR_CAPBSET_READ.Reset();
if (aOther.mPR_CAPBSET_READ.WasPassed()) {
mPR_CAPBSET_READ.Construct(aOther.mPR_CAPBSET_READ.Value());
}
mWNOHANG.Reset();
if (aOther.mWNOHANG.WasPassed()) {
mWNOHANG.Construct(aOther.mWNOHANG.Value());
}
return *this;
}
OriginAttributesDictionary::OriginAttributesDictionary()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
OriginAttributesDictionary::InitIds(JSContext* cx, OriginAttributesDictionaryAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->userContextId_id.init(cx, "userContextId") ||
!atomsCache->privateBrowsingId_id.init(cx, "privateBrowsingId") ||
!atomsCache->partitionKey_id.init(cx, "partitionKey") ||
!atomsCache->geckoViewSessionContextId_id.init(cx, "geckoViewSessionContextId") ||
!atomsCache->firstPartyDomain_id.init(cx, "firstPartyDomain")) {
return false;
}
return true;
}
bool
OriginAttributesDictionary::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());
OriginAttributesDictionaryAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<OriginAttributesDictionaryAtoms>(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->firstPartyDomain_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mFirstPartyDomain)) {
return false;
}
} else {
mFirstPartyDomain.AssignLiteral(u"");
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->geckoViewSessionContextId_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mGeckoViewSessionContextId)) {
return false;
}
} else {
mGeckoViewSessionContextId.AssignLiteral(u"");
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->partitionKey_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mPartitionKey)) {
return false;
}
} else {
mPartitionKey.AssignLiteral(u"");
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->privateBrowsingId_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp.ref(), "'privateBrowsingId' member of OriginAttributesDictionary", &mPrivateBrowsingId)) {
return false;
}
} else {
mPrivateBrowsingId = 0U;
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->userContextId_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp.ref(), "'userContextId' member of OriginAttributesDictionary", &mUserContextId)) {
return false;
}
} else {
mUserContextId = 0U;
}
mIsAnyMemberPresent = true;
return true;
}
bool
OriginAttributesDictionary::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);
}
bool
OriginAttributesDictionary::Init(const nsAString& aJSON)
{
AutoJSAPI jsapi;
JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
if (!cleanGlobal) {
return false;
}
if (!jsapi.Init(cleanGlobal)) {
return false;
}
JSContext* cx = jsapi.cx();
JS::Rooted<JS::Value> json(cx);
bool ok = ParseJSON(cx, aJSON, &json);
NS_ENSURE_TRUE(ok, false);
return Init(cx, json);
}
bool
OriginAttributesDictionary::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
OriginAttributesDictionaryAtoms* atomsCache = GetAtomCache<OriginAttributesDictionaryAtoms>(cx);
if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
!InitIds(cx, atomsCache)) {
return false;
}
JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
if (!obj) {
return false;
}
rval.set(JS::ObjectValue(*obj));
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mFirstPartyDomain;
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->firstPartyDomain_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mGeckoViewSessionContextId;
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->geckoViewSessionContextId_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mPartitionKey;
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->partitionKey_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
uint32_t const & currentValue = mPrivateBrowsingId;
temp.setNumber(currentValue);
if (!JS_DefinePropertyById(cx, obj, atomsCache->privateBrowsingId_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
uint32_t const & currentValue = mUserContextId;
temp.setNumber(currentValue);
if (!JS_DefinePropertyById(cx, obj, atomsCache->userContextId_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
return true;
}
void
OriginAttributesDictionary::TraceDictionary(JSTracer* trc)
{
}
OriginAttributesDictionary&
OriginAttributesDictionary::operator=(const OriginAttributesDictionary& aOther)
{
DictionaryBase::operator=(aOther);
mFirstPartyDomain = aOther.mFirstPartyDomain;
mGeckoViewSessionContextId = aOther.mGeckoViewSessionContextId;
mPartitionKey = aOther.mPartitionKey;
mPrivateBrowsingId = aOther.mPrivateBrowsingId;
mUserContextId = aOther.mUserContextId;
return *this;
}
bool
OriginAttributesDictionary::operator==(const OriginAttributesDictionary& aOther) const
{
if (mFirstPartyDomain != aOther.mFirstPartyDomain) {
return false;
}
if (mGeckoViewSessionContextId != aOther.mGeckoViewSessionContextId) {
return false;
}
if (mPartitionKey != aOther.mPartitionKey) {
return false;
}
if (mPrivateBrowsingId != aOther.mPrivateBrowsingId) {
return false;
}
if (mUserContextId != aOther.mUserContextId) {
return false;
}
return true;
}
PartitionKeyPatternDictionary::PartitionKeyPatternDictionary()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
PartitionKeyPatternDictionary::InitIds(JSContext* cx, PartitionKeyPatternDictionaryAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->scheme_id.init(cx, "scheme") ||
!atomsCache->port_id.init(cx, "port") ||
!atomsCache->foreignByAncestorContext_id.init(cx, "foreignByAncestorContext") ||
!atomsCache->baseDomain_id.init(cx, "baseDomain")) {
return false;
}
return true;
}
bool
PartitionKeyPatternDictionary::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());
PartitionKeyPatternDictionaryAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<PartitionKeyPatternDictionaryAtoms>(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->baseDomain_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mBaseDomain.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mBaseDomain.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->foreignByAncestorContext_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mForeignByAncestorContext.Construct();
if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), "'foreignByAncestorContext' member of PartitionKeyPatternDictionary", &(mForeignByAncestorContext.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->port_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mPort.Construct();
if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), "'port' member of PartitionKeyPatternDictionary", &(mPort.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->scheme_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mScheme.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mScheme.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
return true;
}
bool
PartitionKeyPatternDictionary::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);
}
bool
PartitionKeyPatternDictionary::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
PartitionKeyPatternDictionaryAtoms* atomsCache = GetAtomCache<PartitionKeyPatternDictionaryAtoms>(cx);
if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
!InitIds(cx, atomsCache)) {
return false;
}
JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
if (!obj) {
return false;
}
rval.set(JS::ObjectValue(*obj));
if (mBaseDomain.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mBaseDomain.InternalValue();
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->baseDomain_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mForeignByAncestorContext.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
bool const & currentValue = mForeignByAncestorContext.InternalValue();
temp.setBoolean(currentValue);
if (!JS_DefinePropertyById(cx, obj, atomsCache->foreignByAncestorContext_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mPort.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
int32_t const & currentValue = mPort.InternalValue();
temp.setInt32(int32_t(currentValue));
if (!JS_DefinePropertyById(cx, obj, atomsCache->port_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mScheme.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mScheme.InternalValue();
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->scheme_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
return true;
}
void
PartitionKeyPatternDictionary::TraceDictionary(JSTracer* trc)
{
}
PartitionKeyPatternDictionary&
PartitionKeyPatternDictionary::operator=(const PartitionKeyPatternDictionary& aOther)
{
DictionaryBase::operator=(aOther);
mBaseDomain.Reset();
if (aOther.mBaseDomain.WasPassed()) {
mBaseDomain.Construct(aOther.mBaseDomain.Value());
}
mForeignByAncestorContext.Reset();
if (aOther.mForeignByAncestorContext.WasPassed()) {
mForeignByAncestorContext.Construct(aOther.mForeignByAncestorContext.Value());
}
mPort.Reset();
if (aOther.mPort.WasPassed()) {
mPort.Construct(aOther.mPort.Value());
}
mScheme.Reset();
if (aOther.mScheme.WasPassed()) {
mScheme.Construct(aOther.mScheme.Value());
}
return *this;
}
ProfilerMarkerOptions::ProfilerMarkerOptions()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
ProfilerMarkerOptions::InitIds(JSContext* cx, ProfilerMarkerOptionsAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->startTime_id.init(cx, "startTime") ||
!atomsCache->innerWindowId_id.init(cx, "innerWindowId") ||
!atomsCache->category_id.init(cx, "category") ||
!atomsCache->captureStack_id.init(cx, "captureStack")) {
return false;
}
return true;
}
bool
ProfilerMarkerOptions::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());
ProfilerMarkerOptionsAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<ProfilerMarkerOptionsAtoms>(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->captureStack_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), "'captureStack' member of ProfilerMarkerOptions", &mCaptureStack)) {
return false;
}
} else {
mCaptureStack = false;
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->category_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToByteString(cx, temp.ref(), false, "'category' member of ProfilerMarkerOptions", mCategory)) {
return false;
}
} else {
mCategory.AssignLiteral("JavaScript");
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->innerWindowId_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ValueToPrimitive<uint64_t, eDefault>(cx, temp.ref(), "'innerWindowId' member of ProfilerMarkerOptions", &mInnerWindowId)) {
return false;
}
} else {
mInnerWindowId = 0ULL;
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->startTime_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), "'startTime' member of ProfilerMarkerOptions", &mStartTime)) {
return false;
} else if (!std::isfinite(mStartTime)) {
cx.ThrowErrorMessage<MSG_NOT_FINITE>("'startTime' member of ProfilerMarkerOptions");
return false;
}
} else {
mStartTime = 0.0;
}
mIsAnyMemberPresent = true;
return true;
}
bool
ProfilerMarkerOptions::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
ProfilerMarkerOptions::TraceDictionary(JSTracer* trc)
{
}
ProfilerMarkerOptions&
ProfilerMarkerOptions::operator=(const ProfilerMarkerOptions& aOther)
{
DictionaryBase::operator=(aOther);
mCaptureStack = aOther.mCaptureStack;
mCategory = aOther.mCategory;
mInnerWindowId = aOther.mInnerWindowId;
mStartTime = aOther.mStartTime;
return *this;
}
ThreadInfoDictionary::ThreadInfoDictionary()
{
// Safe to pass a null context if we pass a null value
Init();
}
bool
ThreadInfoDictionary::InitIds(JSContext* cx, ThreadInfoDictionaryAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->tid_id.init(cx, "tid") ||
!atomsCache->name_id.init(cx, "name") ||
!atomsCache->cpuTime_id.init(cx, "cpuTime") ||
!atomsCache->cpuCycleCount_id.init(cx, "cpuCycleCount")) {
return false;
}
return true;
}
bool
ThreadInfoDictionary::Init(const char* sourceDescription, bool passedToJSImpl)
{
{
// scope for any temporaries our default value setting needs.
mCpuCycleCount = 0ULL;
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
mCpuTime = 0ULL;
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
mName.AssignLiteral(u"");
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
mTid = 0LL;
}
mIsAnyMemberPresent = true;
return true;
}
bool
ThreadInfoDictionary::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
ThreadInfoDictionaryAtoms* atomsCache = GetAtomCache<ThreadInfoDictionaryAtoms>(cx);
if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
!InitIds(cx, atomsCache)) {
return false;
}
JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
if (!obj) {
return false;
}
rval.set(JS::ObjectValue(*obj));
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
uint64_t const & currentValue = mCpuCycleCount;
temp.set(JS_NumberValue(double(currentValue)));
if (!JS_DefinePropertyById(cx, obj, atomsCache->cpuCycleCount_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
uint64_t const & currentValue = mCpuTime;
temp.set(JS_NumberValue(double(currentValue)));
if (!JS_DefinePropertyById(cx, obj, atomsCache->cpuTime_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mName;
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->name_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
int64_t const & currentValue = mTid;
temp.set(JS_NumberValue(double(currentValue)));
if (!JS_DefinePropertyById(cx, obj, atomsCache->tid_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
return true;
}
void
ThreadInfoDictionary::TraceDictionary(JSTracer* trc)
{
}
ThreadInfoDictionary&
ThreadInfoDictionary::operator=(const ThreadInfoDictionary& aOther)
{
DictionaryBase::operator=(aOther);
mCpuCycleCount = aOther.mCpuCycleCount;
mCpuTime = aOther.mCpuTime;
mName = aOther.mName;
mTid = aOther.mTid;
return *this;
}
UtilityActorsDictionary::UtilityActorsDictionary()
{
// Safe to pass a null context if we pass a null value
Init();
}
bool
UtilityActorsDictionary::InitIds(JSContext* cx, UtilityActorsDictionaryAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->actorName_id.init(cx, "actorName")) {
return false;
}
return true;
}
bool
UtilityActorsDictionary::Init(const char* sourceDescription, bool passedToJSImpl)
{
{
// scope for any temporaries our default value setting needs.
mActorName = WebIDLUtilityActorName::Unknown;
}
mIsAnyMemberPresent = true;
return true;
}
bool
UtilityActorsDictionary::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
UtilityActorsDictionaryAtoms* atomsCache = GetAtomCache<UtilityActorsDictionaryAtoms>(cx);
if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
!InitIds(cx, atomsCache)) {
return false;
}
JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
if (!obj) {
return false;
}
rval.set(JS::ObjectValue(*obj));
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
WebIDLUtilityActorName const & currentValue = mActorName;
if (!ToJSValue(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->actorName_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
return true;
}
void
UtilityActorsDictionary::TraceDictionary(JSTracer* trc)
{
}
UtilityActorsDictionary&
UtilityActorsDictionary::operator=(const UtilityActorsDictionary& aOther)
{
DictionaryBase::operator=(aOther);
mActorName = aOther.mActorName;
return *this;
}
WindowInfoDictionary::WindowInfoDictionary()
{
// Safe to pass a null context if we pass a null value
Init();
}
bool
WindowInfoDictionary::InitIds(JSContext* cx, WindowInfoDictionaryAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->outerWindowId_id.init(cx, "outerWindowId") ||
!atomsCache->isProcessRoot_id.init(cx, "isProcessRoot") ||
!atomsCache->isInProcess_id.init(cx, "isInProcess") ||
!atomsCache->documentURI_id.init(cx, "documentURI") ||
!atomsCache->documentTitle_id.init(cx, "documentTitle")) {
return false;
}
return true;
}
bool
WindowInfoDictionary::Init(const char* sourceDescription, bool passedToJSImpl)
{
{
// scope for any temporaries our default value setting needs.
mDocumentTitle.AssignLiteral(u"");
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
mDocumentURI = nullptr;
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
mIsInProcess = false;
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
mIsProcessRoot = false;
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
mOuterWindowId = 0ULL;
}
mIsAnyMemberPresent = true;
return true;
}
bool
WindowInfoDictionary::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
WindowInfoDictionaryAtoms* atomsCache = GetAtomCache<WindowInfoDictionaryAtoms>(cx);
if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
!InitIds(cx, atomsCache)) {
return false;
}
JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
if (!obj) {
return false;
}
rval.set(JS::ObjectValue(*obj));
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mDocumentTitle;
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->documentTitle_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
RefPtr<nsIURI> const & currentValue = mDocumentURI;
if (!currentValue) {
temp.setNull();
if (!JS_DefinePropertyById(cx, obj, atomsCache->documentURI_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
}
if (!WrapObject(cx, currentValue, &NS_GET_IID(nsIURI), &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->documentURI_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
bool const & currentValue = mIsInProcess;
temp.setBoolean(currentValue);
if (!JS_DefinePropertyById(cx, obj, atomsCache->isInProcess_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
bool const & currentValue = mIsProcessRoot;
temp.setBoolean(currentValue);
if (!JS_DefinePropertyById(cx, obj, atomsCache->isProcessRoot_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
uint64_t const & currentValue = mOuterWindowId;
temp.set(JS_NumberValue(double(currentValue)));
if (!JS_DefinePropertyById(cx, obj, atomsCache->outerWindowId_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
return true;
}
void
WindowInfoDictionary::TraceDictionary(JSTracer* trc)
{
}
WindowInfoDictionary&
WindowInfoDictionary::operator=(const WindowInfoDictionary& aOther)
{
DictionaryBase::operator=(aOther);
mDocumentTitle = aOther.mDocumentTitle;
mDocumentURI = aOther.mDocumentURI;
mIsInProcess = aOther.mIsInProcess;
mIsProcessRoot = aOther.mIsProcessRoot;
mOuterWindowId = aOther.mOuterWindowId;
return *this;
}
ChildProcInfoDictionary::ChildProcInfoDictionary()
{
// Safe to pass a null context if we pass a null value
Init();
}
bool
ChildProcInfoDictionary::InitIds(JSContext* cx, ChildProcInfoDictionaryAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->windows_id.init(cx, "windows") ||
!atomsCache->utilityActors_id.init(cx, "utilityActors") ||
!atomsCache->type_id.init(cx, "type") ||
!atomsCache->threads_id.init(cx, "threads") ||
!atomsCache->pid_id.init(cx, "pid") ||
!atomsCache->origin_id.init(cx, "origin") ||
!atomsCache->memory_id.init(cx, "memory") ||
!atomsCache->cpuTime_id.init(cx, "cpuTime") ||
!atomsCache->cpuCycleCount_id.init(cx, "cpuCycleCount") ||
!atomsCache->childID_id.init(cx, "childID")) {
return false;
}
return true;
}
bool
ChildProcInfoDictionary::Init(const char* sourceDescription, bool passedToJSImpl)
{
{
// scope for any temporaries our default value setting needs.
mChildID = 0ULL;
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
mCpuCycleCount = 0ULL;
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
mCpuTime = 0ULL;
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
mMemory = 0ULL;
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
mOrigin.AssignLiteral("");
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
mPid = 0LL;
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
/* mThreads array is already empty; nothing to do */
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
mType = WebIDLProcType::Web;
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
/* mUtilityActors array is already empty; nothing to do */
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
/* mWindows array is already empty; nothing to do */
}
mIsAnyMemberPresent = true;
return true;
}
bool
ChildProcInfoDictionary::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
ChildProcInfoDictionaryAtoms* atomsCache = GetAtomCache<ChildProcInfoDictionaryAtoms>(cx);
if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
!InitIds(cx, atomsCache)) {
return false;
}
JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
if (!obj) {
return false;
}
rval.set(JS::ObjectValue(*obj));
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
uint64_t const & currentValue = mChildID;
temp.set(JS_NumberValue(double(currentValue)));
if (!JS_DefinePropertyById(cx, obj, atomsCache->childID_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
uint64_t const & currentValue = mCpuCycleCount;
temp.set(JS_NumberValue(double(currentValue)));
if (!JS_DefinePropertyById(cx, obj, atomsCache->cpuCycleCount_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
uint64_t const & currentValue = mCpuTime;
temp.set(JS_NumberValue(double(currentValue)));
if (!JS_DefinePropertyById(cx, obj, atomsCache->cpuTime_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
uint64_t const & currentValue = mMemory;
temp.set(JS_NumberValue(double(currentValue)));
if (!JS_DefinePropertyById(cx, obj, atomsCache->memory_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsCString const & currentValue = mOrigin;
if (!NonVoidUTF8StringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->origin_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
int64_t const & currentValue = mPid;
temp.set(JS_NumberValue(double(currentValue)));
if (!JS_DefinePropertyById(cx, obj, atomsCache->pid_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
Sequence<ThreadInfoDictionary> const & currentValue = mThreads;
uint32_t length = currentValue.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 (!currentValue[sequenceIdx0].ToObjectInternal(cx, &tmp)) {
return false;
}
break;
} while (false);
if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
JSPROP_ENUMERATE)) {
return false;
}
}
}
temp.setObject(*returnArray);
if (!JS_DefinePropertyById(cx, obj, atomsCache->threads_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
WebIDLProcType const & currentValue = mType;
if (!ToJSValue(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->type_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
Sequence<UtilityActorsDictionary> const & currentValue = mUtilityActors;
uint32_t length = currentValue.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 (!currentValue[sequenceIdx0].ToObjectInternal(cx, &tmp)) {
return false;
}
break;
} while (false);
if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
JSPROP_ENUMERATE)) {
return false;
}
}
}
temp.setObject(*returnArray);
if (!JS_DefinePropertyById(cx, obj, atomsCache->utilityActors_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
Sequence<WindowInfoDictionary> const & currentValue = mWindows;
uint32_t length = currentValue.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 (!currentValue[sequenceIdx0].ToObjectInternal(cx, &tmp)) {
return false;
}
break;
} while (false);
if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
JSPROP_ENUMERATE)) {
return false;
}
}
}
temp.setObject(*returnArray);
if (!JS_DefinePropertyById(cx, obj, atomsCache->windows_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
return true;
}
void
ChildProcInfoDictionary::TraceDictionary(JSTracer* trc)
{
}
ChildProcInfoDictionary&
ChildProcInfoDictionary::operator=(const ChildProcInfoDictionary& aOther)
{
DictionaryBase::operator=(aOther);
mChildID = aOther.mChildID;
mCpuCycleCount = aOther.mCpuCycleCount;
mCpuTime = aOther.mCpuTime;
mMemory = aOther.mMemory;
mOrigin = aOther.mOrigin;
mPid = aOther.mPid;
mThreads = aOther.mThreads;
mType = aOther.mType;
mUtilityActors = aOther.mUtilityActors;
mWindows = aOther.mWindows;
return *this;
}
OriginAttributesPatternDictionary::OriginAttributesPatternDictionary()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
OriginAttributesPatternDictionary::InitIds(JSContext* cx, OriginAttributesPatternDictionaryAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->userContextId_id.init(cx, "userContextId") ||
!atomsCache->privateBrowsingId_id.init(cx, "privateBrowsingId") ||
!atomsCache->partitionKeyPattern_id.init(cx, "partitionKeyPattern") ||
!atomsCache->partitionKey_id.init(cx, "partitionKey") ||
!atomsCache->geckoViewSessionContextId_id.init(cx, "geckoViewSessionContextId") ||
!atomsCache->firstPartyDomain_id.init(cx, "firstPartyDomain")) {
return false;
}
return true;
}
bool
OriginAttributesPatternDictionary::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());
OriginAttributesPatternDictionaryAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<OriginAttributesPatternDictionaryAtoms>(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->firstPartyDomain_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mFirstPartyDomain.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mFirstPartyDomain.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->geckoViewSessionContextId_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mGeckoViewSessionContextId.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mGeckoViewSessionContextId.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->partitionKey_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mPartitionKey.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mPartitionKey.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->partitionKeyPattern_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mPartitionKeyPattern.Construct();
if (!(mPartitionKeyPattern.Value()).Init(cx, temp.ref(), "'partitionKeyPattern' member of OriginAttributesPatternDictionary", passedToJSImpl)) {
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->privateBrowsingId_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mPrivateBrowsingId.Construct();
if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp.ref(), "'privateBrowsingId' member of OriginAttributesPatternDictionary", &(mPrivateBrowsingId.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->userContextId_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mUserContextId.Construct();
if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp.ref(), "'userContextId' member of OriginAttributesPatternDictionary", &(mUserContextId.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
return true;
}
bool
OriginAttributesPatternDictionary::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);
}
bool
OriginAttributesPatternDictionary::Init(const nsAString& aJSON)
{
AutoJSAPI jsapi;
JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
if (!cleanGlobal) {
return false;
}
if (!jsapi.Init(cleanGlobal)) {
return false;
}
JSContext* cx = jsapi.cx();
JS::Rooted<JS::Value> json(cx);
bool ok = ParseJSON(cx, aJSON, &json);
NS_ENSURE_TRUE(ok, false);
return Init(cx, json);
}
bool
OriginAttributesPatternDictionary::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
OriginAttributesPatternDictionaryAtoms* atomsCache = GetAtomCache<OriginAttributesPatternDictionaryAtoms>(cx);
if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
!InitIds(cx, atomsCache)) {
return false;
}
JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
if (!obj) {
return false;
}
rval.set(JS::ObjectValue(*obj));
if (mFirstPartyDomain.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mFirstPartyDomain.InternalValue();
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->firstPartyDomain_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mGeckoViewSessionContextId.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mGeckoViewSessionContextId.InternalValue();
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->geckoViewSessionContextId_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mPartitionKey.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mPartitionKey.InternalValue();
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->partitionKey_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mPartitionKeyPattern.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
PartitionKeyPatternDictionary const & currentValue = mPartitionKeyPattern.InternalValue();
if (!currentValue.ToObjectInternal(cx, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->partitionKeyPattern_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mPrivateBrowsingId.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
uint32_t const & currentValue = mPrivateBrowsingId.InternalValue();
temp.setNumber(currentValue);
if (!JS_DefinePropertyById(cx, obj, atomsCache->privateBrowsingId_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mUserContextId.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
uint32_t const & currentValue = mUserContextId.InternalValue();
temp.setNumber(currentValue);
if (!JS_DefinePropertyById(cx, obj, atomsCache->userContextId_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
return true;
}
bool
OriginAttributesPatternDictionary::ToJSON(nsAString& aJSON) const
{
AutoJSAPI jsapi;
jsapi.Init();
JSContext *cx = jsapi.cx();
// It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
// because we'll only be creating objects, in ways that have no
// side-effects, followed by a call to JS::ToJSONMaybeSafely,
// which likewise guarantees no side-effects for the sorts of
// things we will pass it.
JSObject* scope = UnprivilegedJunkScopeOrWorkerGlobal(fallible);
if (!scope) {
JS_ReportOutOfMemory(cx);
return false;
}
JSAutoRealm ar(cx, scope);
JS::Rooted<JS::Value> val(cx);
if (!ToObjectInternal(cx, &val)) {
return false;
}
JS::Rooted<JSObject*> obj(cx, &val.toObject());
return StringifyToJSON(cx, obj, aJSON);
}
void
OriginAttributesPatternDictionary::TraceDictionary(JSTracer* trc)
{
}
OriginAttributesPatternDictionary&
OriginAttributesPatternDictionary::operator=(const OriginAttributesPatternDictionary& aOther)
{
DictionaryBase::operator=(aOther);
mFirstPartyDomain.Reset();
if (aOther.mFirstPartyDomain.WasPassed()) {
mFirstPartyDomain.Construct(aOther.mFirstPartyDomain.Value());
}
mGeckoViewSessionContextId.Reset();
if (aOther.mGeckoViewSessionContextId.WasPassed()) {
mGeckoViewSessionContextId.Construct(aOther.mGeckoViewSessionContextId.Value());
}
mPartitionKey.Reset();
if (aOther.mPartitionKey.WasPassed()) {
mPartitionKey.Construct(aOther.mPartitionKey.Value());
}
mPartitionKeyPattern.Reset();
if (aOther.mPartitionKeyPattern.WasPassed()) {
mPartitionKeyPattern.Construct(aOther.mPartitionKeyPattern.Value());
}
mPrivateBrowsingId.Reset();
if (aOther.mPrivateBrowsingId.WasPassed()) {
mPrivateBrowsingId.Construct(aOther.mPrivateBrowsingId.Value());
}
mUserContextId.Reset();
if (aOther.mUserContextId.WasPassed()) {
mUserContextId.Construct(aOther.mUserContextId.Value());
}
return *this;
}
bool
ProfilerMarkerOptionsOrDouble::TrySetToProfilerMarkerOptions(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
{
tryNext = false;
{ // scope for memberSlot
binding_detail::FastProfilerMarkerOptions& memberSlot = RawSetAsProfilerMarkerOptions();
if (!IsConvertibleToDictionary(value)) {
DestroyProfilerMarkerOptions();
tryNext = true;
return true;
}
if (!memberSlot.Init(cx, value, "ProfilerMarkerOptions branch of (ProfilerMarkerOptions or double)", passedToJSImpl)) {
return false;
}
}
return true;
}
bool
ProfilerMarkerOptionsOrDouble::TrySetToProfilerMarkerOptions(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
{
BindingCallContext cx(cx_, nullptr);
return TrySetToProfilerMarkerOptions(cx, value, tryNext, passedToJSImpl);
}
bool
ProfilerMarkerOptionsOrDouble::TrySetToDouble(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
{
tryNext = false;
{ // scope for memberSlot
double& memberSlot = RawSetAsDouble();
if (!ValueToPrimitive<double, eDefault>(cx, value, "Double branch of (ProfilerMarkerOptions or double)", &memberSlot)) {
return false;
} else if (!std::isfinite(memberSlot)) {
cx.ThrowErrorMessage<MSG_NOT_FINITE>("Double branch of (ProfilerMarkerOptions or double)");
return false;
}
}
return true;
}
bool
ProfilerMarkerOptionsOrDouble::TrySetToDouble(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
{
BindingCallContext cx(cx_, nullptr);
return TrySetToDouble(cx, value, tryNext, passedToJSImpl);
}
bool
ProfilerMarkerOptionsOrDouble::Init(BindingCallContext& cx, JS::Handle<JS::Value> value, const char* sourceDescription, bool passedToJSImpl)
{
MOZ_ASSERT(mType == eUninitialized);
bool done = false, failed = false, tryNext;
if (!done) {
done = (failed = !TrySetToProfilerMarkerOptions(cx, value, tryNext, passedToJSImpl)) || !tryNext;
}
if (!done) {
do {
done = (failed = !TrySetToDouble(cx, value, tryNext)) || !tryNext;
break;
} while (false);
}
if (failed) {
return false;
}
if (!done) {
cx.ThrowErrorMessage<MSG_NOT_IN_UNION>(sourceDescription, "ProfilerMarkerOptions");
return false;
}
return true;
}
bool
ProfilerMarkerOptionsOrDouble::Init(JSContext* cx_, JS::Handle<JS::Value> value, const char* sourceDescription, bool passedToJSImpl)
{
BindingCallContext cx(cx_, nullptr);
return Init(cx, value, sourceDescription, passedToJSImpl);
}
OwningProfilerMarkerOptionsOrDouble::OwningProfilerMarkerOptionsOrDouble(OwningProfilerMarkerOptionsOrDouble&& aOther)
: mType(eUninitialized)
{
switch (aOther.mType) {
case eUninitialized: {
MOZ_ASSERT(mType == eUninitialized,
"We need to destroy ourselves?");
break;
}
case eProfilerMarkerOptions: {
mType = eProfilerMarkerOptions;
mValue.mProfilerMarkerOptions.SetValue(std::move(aOther.mValue.mProfilerMarkerOptions.Value()));
break;
}
case eDouble: {
mType = eDouble;
mValue.mDouble.SetValue(std::move(aOther.mValue.mDouble.Value()));
break;
}
}
}
bool
OwningProfilerMarkerOptionsOrDouble::TrySetToProfilerMarkerOptions(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
{
tryNext = false;
{ // scope for memberSlot
ProfilerMarkerOptions& memberSlot = RawSetAsProfilerMarkerOptions();
if (!IsConvertibleToDictionary(value)) {
DestroyProfilerMarkerOptions();
tryNext = true;
return true;
}
if (!memberSlot.Init(cx, value, "ProfilerMarkerOptions branch of (ProfilerMarkerOptions or double)", passedToJSImpl)) {
return false;
}
}
return true;
}
bool
OwningProfilerMarkerOptionsOrDouble::TrySetToProfilerMarkerOptions(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
{
BindingCallContext cx(cx_, nullptr);
return TrySetToProfilerMarkerOptions(cx, value, tryNext, passedToJSImpl);
}
[[nodiscard]] ProfilerMarkerOptions&
OwningProfilerMarkerOptionsOrDouble::RawSetAsProfilerMarkerOptions()
{
if (mType == eProfilerMarkerOptions) {
return mValue.mProfilerMarkerOptions.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eProfilerMarkerOptions;
return mValue.mProfilerMarkerOptions.SetValue();
}
[[nodiscard]] ProfilerMarkerOptions&
OwningProfilerMarkerOptionsOrDouble::SetAsProfilerMarkerOptions()
{
if (mType == eProfilerMarkerOptions) {
return mValue.mProfilerMarkerOptions.Value();
}
Uninit();
mType = eProfilerMarkerOptions;
return mValue.mProfilerMarkerOptions.SetValue();
}
void
OwningProfilerMarkerOptionsOrDouble::DestroyProfilerMarkerOptions()
{
MOZ_RELEASE_ASSERT(IsProfilerMarkerOptions(), "Wrong type!");
mValue.mProfilerMarkerOptions.Destroy();
mType = eUninitialized;
}
bool
OwningProfilerMarkerOptionsOrDouble::TrySetToDouble(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
{
tryNext = false;
{ // scope for memberSlot
double& memberSlot = RawSetAsDouble();
if (!ValueToPrimitive<double, eDefault>(cx, value, "Double branch of (ProfilerMarkerOptions or double)", &memberSlot)) {
return false;
} else if (!std::isfinite(memberSlot)) {
cx.ThrowErrorMessage<MSG_NOT_FINITE>("Double branch of (ProfilerMarkerOptions or double)");
return false;
}
}
return true;
}
bool
OwningProfilerMarkerOptionsOrDouble::TrySetToDouble(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
{
BindingCallContext cx(cx_, nullptr);
return TrySetToDouble(cx, value, tryNext, passedToJSImpl);
}
[[nodiscard]] double&
OwningProfilerMarkerOptionsOrDouble::RawSetAsDouble()
{
if (mType == eDouble) {
return mValue.mDouble.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eDouble;
return mValue.mDouble.SetValue();
}
[[nodiscard]] double&
OwningProfilerMarkerOptionsOrDouble::SetAsDouble()
{
if (mType == eDouble) {
return mValue.mDouble.Value();
}
Uninit();
mType = eDouble;
return mValue.mDouble.SetValue();
}
void
OwningProfilerMarkerOptionsOrDouble::DestroyDouble()
{
MOZ_RELEASE_ASSERT(IsDouble(), "Wrong type!");
mValue.mDouble.Destroy();
mType = eUninitialized;
}
bool
OwningProfilerMarkerOptionsOrDouble::Init(BindingCallContext& cx, JS::Handle<JS::Value> value, const char* sourceDescription, bool passedToJSImpl)
{
MOZ_ASSERT(mType == eUninitialized);
bool done = false, failed = false, tryNext;
if (!done) {
done = (failed = !TrySetToProfilerMarkerOptions(cx, value, tryNext, passedToJSImpl)) || !tryNext;
}
if (!done) {
do {
done = (failed = !TrySetToDouble(cx, value, tryNext)) || !tryNext;
break;
} while (false);
}
if (failed) {
return false;
}
if (!done) {
cx.ThrowErrorMessage<MSG_NOT_IN_UNION>(sourceDescription, "ProfilerMarkerOptions");
return false;
}
return true;
}
bool
OwningProfilerMarkerOptionsOrDouble::Init(JSContext* cx_, JS::Handle<JS::Value> value, const char* sourceDescription, bool passedToJSImpl)
{
BindingCallContext cx(cx_, nullptr);
return Init(cx, value, sourceDescription, passedToJSImpl);
}
void
OwningProfilerMarkerOptionsOrDouble::Uninit()
{
switch (mType) {
case eUninitialized: {
break;
}
case eProfilerMarkerOptions: {
DestroyProfilerMarkerOptions();
break;
}
case eDouble: {
DestroyDouble();
break;
}
}
}
OwningProfilerMarkerOptionsOrDouble&
OwningProfilerMarkerOptionsOrDouble::operator=(OwningProfilerMarkerOptionsOrDouble&& aOther)
{
this->~OwningProfilerMarkerOptionsOrDouble();
new (this) OwningProfilerMarkerOptionsOrDouble (std::move(aOther));
return *this;
}
OwningProfilerMarkerOptionsOrDouble&
OwningProfilerMarkerOptionsOrDouble::operator=(const OwningProfilerMarkerOptionsOrDouble& aOther)
{
switch (aOther.mType) {
case eUninitialized: {
MOZ_ASSERT(mType == eUninitialized,
"We need to destroy ourselves?");
break;
}
case eProfilerMarkerOptions: {
SetAsProfilerMarkerOptions() = aOther.GetAsProfilerMarkerOptions();
break;
}
case eDouble: {
SetAsDouble() = aOther.GetAsDouble();
break;
}
}
return *this;
}
ParentProcInfoDictionary::ParentProcInfoDictionary()
{
// Safe to pass a null context if we pass a null value
Init();
}
bool
ParentProcInfoDictionary::InitIds(JSContext* cx, ParentProcInfoDictionaryAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->type_id.init(cx, "type") ||
!atomsCache->threads_id.init(cx, "threads") ||
!atomsCache->pid_id.init(cx, "pid") ||
!atomsCache->memory_id.init(cx, "memory") ||
!atomsCache->cpuTime_id.init(cx, "cpuTime") ||
!atomsCache->cpuCycleCount_id.init(cx, "cpuCycleCount") ||
!atomsCache->children_id.init(cx, "children")) {
return false;
}
return true;
}
bool
ParentProcInfoDictionary::Init(const char* sourceDescription, bool passedToJSImpl)
{
{
// scope for any temporaries our default value setting needs.
/* mChildren array is already empty; nothing to do */
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
mCpuCycleCount = 0ULL;
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
mCpuTime = 0ULL;
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
mMemory = 0ULL;
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
mPid = 0LL;
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
/* mThreads array is already empty; nothing to do */
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
mType = WebIDLProcType::Browser;
}
mIsAnyMemberPresent = true;
return true;
}
bool
ParentProcInfoDictionary::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
ParentProcInfoDictionaryAtoms* atomsCache = GetAtomCache<ParentProcInfoDictionaryAtoms>(cx);
if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
!InitIds(cx, atomsCache)) {
return false;
}
JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
if (!obj) {
return false;
}
rval.set(JS::ObjectValue(*obj));
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
Sequence<ChildProcInfoDictionary> const & currentValue = mChildren;
uint32_t length = currentValue.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 (!currentValue[sequenceIdx0].ToObjectInternal(cx, &tmp)) {
return false;
}
break;
} while (false);
if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
JSPROP_ENUMERATE)) {
return false;
}
}
}
temp.setObject(*returnArray);
if (!JS_DefinePropertyById(cx, obj, atomsCache->children_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
uint64_t const & currentValue = mCpuCycleCount;
temp.set(JS_NumberValue(double(currentValue)));
if (!JS_DefinePropertyById(cx, obj, atomsCache->cpuCycleCount_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
uint64_t const & currentValue = mCpuTime;
temp.set(JS_NumberValue(double(currentValue)));
if (!JS_DefinePropertyById(cx, obj, atomsCache->cpuTime_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
uint64_t const & currentValue = mMemory;
temp.set(JS_NumberValue(double(currentValue)));
if (!JS_DefinePropertyById(cx, obj, atomsCache->memory_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
int64_t const & currentValue = mPid;
temp.set(JS_NumberValue(double(currentValue)));
if (!JS_DefinePropertyById(cx, obj, atomsCache->pid_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
Sequence<ThreadInfoDictionary> const & currentValue = mThreads;
uint32_t length = currentValue.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 (!currentValue[sequenceIdx0].ToObjectInternal(cx, &tmp)) {
return false;
}
break;
} while (false);
if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
JSPROP_ENUMERATE)) {
return false;
}
}
}
temp.setObject(*returnArray);
if (!JS_DefinePropertyById(cx, obj, atomsCache->threads_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
WebIDLProcType const & currentValue = mType;
if (!ToJSValue(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->type_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
return true;
}
void
ParentProcInfoDictionary::TraceDictionary(JSTracer* trc)
{
}
ParentProcInfoDictionary&
ParentProcInfoDictionary::operator=(const ParentProcInfoDictionary& aOther)
{
DictionaryBase::operator=(aOther);
mChildren = aOther.mChildren;
mCpuCycleCount = aOther.mCpuCycleCount;
mCpuTime = aOther.mCpuTime;
mMemory = aOther.mMemory;
mPid = aOther.mPid;
mThreads = aOther.mThreads;
mType = aOther.mType;
return *this;
}
namespace ChromeUtils_Binding {
MOZ_CAN_RUN_SCRIPT static bool
getObjectNodeId(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.getObjectNodeId");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "getObjectNodeId", 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, "ChromeUtils.getObjectNodeId", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
JS::Rooted<JSObject*> arg0(cx);
if (args[0].isObject()) {
arg0 = &args[0].toObject();
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Argument 1");
return false;
}
uint64_t result(mozilla::dom::ChromeUtils::GetObjectNodeId(global, arg0));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().set(JS_NumberValue(double(result)));
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
saveHeapSnapshot(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.saveHeapSnapshot");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "saveHeapSnapshot", 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;
}
RootedDictionary<binding_detail::FastHeapSnapshotBoundaries> arg0(cx);
if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue, "Argument 1", false)) {
return false;
}
FastErrorResult rv;
DOMString result;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::SaveHeapSnapshot(global, Constify(arg0), result, rv))>, "Should be returning void here");
mozilla::dom::ChromeUtils::SaveHeapSnapshot(global, Constify(arg0), result, rv);
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.saveHeapSnapshot"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
saveHeapSnapshotGetId(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.saveHeapSnapshotGetId");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "saveHeapSnapshotGetId", 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;
}
RootedDictionary<binding_detail::FastHeapSnapshotBoundaries> arg0(cx);
if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue, "Argument 1", false)) {
return false;
}
FastErrorResult rv;
DOMString result;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::SaveHeapSnapshotGetId(global, Constify(arg0), result, rv))>, "Should be returning void here");
mozilla::dom::ChromeUtils::SaveHeapSnapshotGetId(global, Constify(arg0), result, rv);
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.saveHeapSnapshotGetId"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
readHeapSnapshot(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "readHeapSnapshot", 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, "ChromeUtils.readHeapSnapshot", 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;
}
FastErrorResult rv;
auto result(StrongOrRawPtr<mozilla::devtools::HeapSnapshot>(mozilla::dom::ChromeUtils::ReadHeapSnapshot(global, NonNullHelper(Constify(arg0)), rv)));
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.readHeapSnapshot"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
static_assert(!std::is_pointer_v<decltype(result)>,
"NewObject implies that we need to keep the object alive with a strong reference.");
if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
MOZ_ASSERT(JS_IsExceptionPending(cx));
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
isDevToolsOpened(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "isDevToolsOpened", 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 result(mozilla::dom::ChromeUtils::IsDevToolsOpened(global));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setBoolean(result);
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
notifyDevToolsOpened(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "notifyDevToolsOpened", 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;
}
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::NotifyDevToolsOpened(global))>, "Should be returning void here");
mozilla::dom::ChromeUtils::NotifyDevToolsOpened(global);
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setUndefined();
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
notifyDevToolsClosed(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "notifyDevToolsClosed", 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;
}
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::NotifyDevToolsClosed(global))>, "Should be returning void here");
mozilla::dom::ChromeUtils::NotifyDevToolsClosed(global);
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setUndefined();
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
nondeterministicGetWeakMapKeys(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "nondeterministicGetWeakMapKeys", 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, "ChromeUtils.nondeterministicGetWeakMapKeys", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
JS::Rooted<JS::Value> arg0(cx);
arg0 = args[0];
FastErrorResult rv;
JS::Rooted<JS::Value> result(cx);
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::NondeterministicGetWeakMapKeys(global, arg0, &result, rv))>, "Should be returning void here");
mozilla::dom::ChromeUtils::NondeterministicGetWeakMapKeys(global, arg0, &result, rv);
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.nondeterministicGetWeakMapKeys"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
JS::ExposeValueToActiveJS(result);
args.rval().set(result);
if (!MaybeWrapValue(cx, args.rval())) {
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
nondeterministicGetWeakSetKeys(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "nondeterministicGetWeakSetKeys", 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, "ChromeUtils.nondeterministicGetWeakSetKeys", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
JS::Rooted<JS::Value> arg0(cx);
arg0 = args[0];
FastErrorResult rv;
JS::Rooted<JS::Value> result(cx);
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::NondeterministicGetWeakSetKeys(global, arg0, &result, rv))>, "Should be returning void here");
mozilla::dom::ChromeUtils::NondeterministicGetWeakSetKeys(global, arg0, &result, rv);
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.nondeterministicGetWeakSetKeys"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
JS::ExposeValueToActiveJS(result);
args.rval().set(result);
if (!MaybeWrapValue(cx, args.rval())) {
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
base64URLEncode(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.base64URLEncode");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "base64URLEncode", 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, "ChromeUtils.base64URLEncode", 2)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
ArrayBufferViewOrArrayBuffer arg0;
if (!arg0.Init(cx, args[0], "Argument 1", false)) {
return false;
}
binding_detail::FastBase64URLEncodeOptions arg1;
if (!arg1.Init(cx, args[1], "Argument 2", false)) {
return false;
}
FastErrorResult rv;
nsAutoCString result;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::Base64URLEncode(global, Constify(arg0), Constify(arg1), result, rv))>, "Should be returning void here");
mozilla::dom::ChromeUtils::Base64URLEncode(global, Constify(arg0), Constify(arg1), result, rv);
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.base64URLEncode"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
if (!NonVoidByteStringToJsval(cx, result, args.rval())) {
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
base64URLDecode(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.base64URLDecode");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "base64URLDecode", 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, "ChromeUtils.base64URLDecode", 2)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
nsCString arg0;
if (!ConvertJSValueToByteString(cx, args[0], false, "argument 1", arg0)) {
return false;
}
binding_detail::FastBase64URLDecodeOptions arg1;
if (!arg1.Init(cx, args[1], "Argument 2", false)) {
return false;
}
FastErrorResult rv;
JS::Rooted<JSObject*> result(cx);
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::Base64URLDecode(global, Constify(arg0), Constify(arg1), &result, rv))>, "Should be returning void here");
mozilla::dom::ChromeUtils::Base64URLDecode(global, Constify(arg0), Constify(arg1), &result, rv);
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.base64URLDecode"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
JS::ExposeObjectToActiveJS(result);
args.rval().setObject(*result);
if (!MaybeWrapNonDOMObjectValue(cx, args.rval())) {
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
releaseAssert(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "releaseAssert", 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, "ChromeUtils.releaseAssert", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
bool arg0;
if (!ValueToPrimitive<bool, eDefault>(cx, args[0], "Argument 1", &arg0)) {
return false;
}
binding_detail::FakeString<char16_t> arg1;
if (args.hasDefined(1)) {
if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
return false;
}
} else {
arg1.AssignLiteral(u"<no message>");
}
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::ReleaseAssert(global, arg0, NonNullHelper(Constify(arg1))))>, "Should be returning void here");
mozilla::dom::ChromeUtils::ReleaseAssert(global, arg0, NonNullHelper(Constify(arg1)));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setUndefined();
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
get_recentJSDevError(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "recentJSDevError", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) |
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;
}
FastErrorResult rv;
JS::Rooted<JS::Value> result(cx);
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::GetRecentJSDevError(global, &result, rv))>, "Should be returning void here");
mozilla::dom::ChromeUtils::GetRecentJSDevError(global, &result, rv);
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.recentJSDevError getter"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
JS::ExposeValueToActiveJS(result);
args.rval().set(result);
if (!MaybeWrapValue(cx, args.rval())) {
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
clearRecentJSDevError(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "clearRecentJSDevError", 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;
}
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::ClearRecentJSDevError(global))>, "Should be returning void here");
mozilla::dom::ChromeUtils::ClearRecentJSDevError(global);
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setUndefined();
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
clearStyleSheetCacheBySite(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.clearStyleSheetCacheBySite");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "clearStyleSheetCacheBySite", 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, "ChromeUtils.clearStyleSheetCacheBySite", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
binding_detail::FakeString<char> arg0;
if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
return false;
}
binding_detail::FastOriginAttributesPatternDictionary arg1;
if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue, "Argument 2", false)) {
return false;
}
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::ClearStyleSheetCacheBySite(global, Constify(arg0), Constify(arg1)))>, "Should be returning void here");
mozilla::dom::ChromeUtils::ClearStyleSheetCacheBySite(global, Constify(arg0), Constify(arg1));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setUndefined();
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
clearStyleSheetCacheByPrincipal(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.clearStyleSheetCacheByPrincipal");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "clearStyleSheetCacheByPrincipal", 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, "ChromeUtils.clearStyleSheetCacheByPrincipal", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
nsIPrincipal* arg0;
RefPtr<nsIPrincipal> arg0_holder;
if (args[0].isObject()) {
JS::Rooted<JSObject*> source(cx, &args[0].toObject());
if (NS_FAILED(UnwrapArg<nsIPrincipal>(cx, source, getter_AddRefs(arg0_holder)))) {
cx.ThrowErrorMessage<MSG_DOES_NOT_IMPLEMENT_INTERFACE>("Argument 1", "Principal");
return false;
}
MOZ_ASSERT(arg0_holder);
arg0 = arg0_holder;
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Argument 1");
return false;
}
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::ClearStyleSheetCacheByPrincipal(global, MOZ_KnownLive(NonNullHelper(arg0))))>, "Should be returning void here");
mozilla::dom::ChromeUtils::ClearStyleSheetCacheByPrincipal(global, MOZ_KnownLive(NonNullHelper(arg0)));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setUndefined();
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
clearStyleSheetCache(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "clearStyleSheetCache", 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;
}
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::ClearStyleSheetCache(global))>, "Should be returning void here");
mozilla::dom::ChromeUtils::ClearStyleSheetCache(global);
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setUndefined();
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
clearScriptCacheBySite(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.clearScriptCacheBySite");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "clearScriptCacheBySite", 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, "ChromeUtils.clearScriptCacheBySite", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
binding_detail::FakeString<char> arg0;
if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
return false;
}
binding_detail::FastOriginAttributesPatternDictionary arg1;
if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue, "Argument 2", false)) {
return false;
}
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::ClearScriptCacheBySite(global, Constify(arg0), Constify(arg1)))>, "Should be returning void here");
mozilla::dom::ChromeUtils::ClearScriptCacheBySite(global, Constify(arg0), Constify(arg1));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setUndefined();
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
clearScriptCacheByPrincipal(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.clearScriptCacheByPrincipal");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "clearScriptCacheByPrincipal", 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, "ChromeUtils.clearScriptCacheByPrincipal", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
nsIPrincipal* arg0;
RefPtr<nsIPrincipal> arg0_holder;
if (args[0].isObject()) {
JS::Rooted<JSObject*> source(cx, &args[0].toObject());
if (NS_FAILED(UnwrapArg<nsIPrincipal>(cx, source, getter_AddRefs(arg0_holder)))) {
cx.ThrowErrorMessage<MSG_DOES_NOT_IMPLEMENT_INTERFACE>("Argument 1", "Principal");
return false;
}
MOZ_ASSERT(arg0_holder);
arg0 = arg0_holder;
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Argument 1");
return false;
}
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::ClearScriptCacheByPrincipal(global, MOZ_KnownLive(NonNullHelper(arg0))))>, "Should be returning void here");
mozilla::dom::ChromeUtils::ClearScriptCacheByPrincipal(global, MOZ_KnownLive(NonNullHelper(arg0)));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setUndefined();
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
clearScriptCache(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "clearScriptCache", 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;
}
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::ClearScriptCache(global))>, "Should be returning void here");
mozilla::dom::ChromeUtils::ClearScriptCache(global);
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setUndefined();
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
addProfilerMarker(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.addProfilerMarker");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "addProfilerMarker", 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, "ChromeUtils.addProfilerMarker", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
binding_detail::FakeString<char> arg0;
if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
return false;
}
ProfilerMarkerOptionsOrDouble arg1;
if (!(args.hasDefined(1))) {
if (!arg1.RawSetAsProfilerMarkerOptions().Init(cx, JS::NullHandleValue, "Member of (ProfilerMarkerOptions or double)")) {
return false;
}
} else {
if (!arg1.Init(cx, args[1], "Argument 2", false)) {
return false;
}
}
Optional<nsACString> arg2;
binding_detail::FakeString<char> arg2_holder;
if (args.hasDefined(2)) {
if (!ConvertJSValueToString(cx, args[2], eStringify, eStringify, arg2_holder)) {
return false;
}
arg2 = &arg2_holder;
}
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::AddProfilerMarker(global, Constify(arg0), Constify(arg1), Constify(arg2)))>, "Should be returning void here");
mozilla::dom::ChromeUtils::AddProfilerMarker(global, Constify(arg0), Constify(arg1), Constify(arg2));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setUndefined();
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
getXPCOMErrorName(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "getXPCOMErrorName", 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, "ChromeUtils.getXPCOMErrorName", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
uint32_t arg0;
if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], "Argument 1", &arg0)) {
return false;
}
nsAutoCString result;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::GetXPCOMErrorName(global, arg0, result))>, "Should be returning void here");
mozilla::dom::ChromeUtils::GetXPCOMErrorName(global, arg0, result);
MOZ_ASSERT(!JS_IsExceptionPending(cx));
if (!NonVoidUTF8StringToJsval(cx, result, args.rval())) {
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
dateNow(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "dateNow", 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;
}
double result(mozilla::dom::ChromeUtils::DateNow(global));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().set(JS_NumberValue(double(result)));
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
defineLazyGetter(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.defineLazyGetter");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "defineLazyGetter", 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, "ChromeUtils.defineLazyGetter", 3)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
JS::Rooted<JSObject*> arg0(cx);
if (args[0].isObject()) {
arg0 = &args[0].toObject();
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Argument 1");
return false;
}
JS::Rooted<JS::Value> arg1(cx);
arg1 = args[1];
JS::Rooted<JSObject*> arg2(cx);
if (args[2].isObject()) {
arg2 = &args[2].toObject();
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Argument 3");
return false;
}
FastErrorResult rv;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::DefineLazyGetter(global, arg0, arg1, arg2, rv))>, "Should be returning void here");
mozilla::dom::ChromeUtils::DefineLazyGetter(global, arg0, arg1, arg2, rv);
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.defineLazyGetter"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setUndefined();
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
getLibcConstants(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "getLibcConstants", 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;
}
LibcConstants result;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::GetLibcConstants(global, result))>, "Should be returning void here");
mozilla::dom::ChromeUtils::GetLibcConstants(global, result);
MOZ_ASSERT(!JS_IsExceptionPending(cx));
if (!result.ToObjectInternal(cx, args.rval())) {
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
getGMPContentDecryptionModuleInformation(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "getGMPContentDecryptionModuleInformation", 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;
}
FastErrorResult rv;
auto result(StrongOrRawPtr<Promise>(mozilla::dom::ChromeUtils::GetGMPContentDecryptionModuleInformation(global, rv)));
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.getGMPContentDecryptionModuleInformation"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
static_assert(!std::is_pointer_v<decltype(result)>,
"NewObject implies that we need to keep the object alive with a strong reference.");
if (!ToJSValue(cx, result, args.rval())) {
return false;
}
return true;
}
static const JSJitInfo getGMPContentDecryptionModuleInformation_methodinfo = {
{ (JSJitGetterOp)getGMPContentDecryptionModuleInformation },
{ prototypes::id::_ID_Count }, { 0 }, JSJitInfo::StaticMethod,
JSJitInfo::AliasEverything, JSVAL_TYPE_OBJECT, false, false,
false, false, 0
};
MOZ_CAN_RUN_SCRIPT static bool
importESModule(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.importESModule");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "importESModule", 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, "ChromeUtils.importESModule", 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;
}
binding_detail::FastImportESModuleOptionsDictionary arg1;
if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue, "Argument 2", false)) {
return false;
}
FastErrorResult rv;
JS::Rooted<JSObject*> result(cx);
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::ImportESModule(global, NonNullHelper(Constify(arg0)), Constify(arg1), &result, rv))>, "Should be returning void here");
mozilla::dom::ChromeUtils::ImportESModule(global, NonNullHelper(Constify(arg0)), Constify(arg1), &result, rv);
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.importESModule"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
JS::ExposeObjectToActiveJS(result);
args.rval().setObject(*result);
if (!MaybeWrapObjectValue(cx, args.rval())) {
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
defineESModuleGetters(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.defineESModuleGetters");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "defineESModuleGetters", 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, "ChromeUtils.defineESModuleGetters", 2)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
JS::Rooted<JSObject*> arg0(cx);
if (args[0].isObject()) {
arg0 = &args[0].toObject();
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Argument 1");
return false;
}
JS::Rooted<JSObject*> arg1(cx);
if (args[1].isObject()) {
arg1 = &args[1].toObject();
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Argument 2");
return false;
}
binding_detail::FastImportESModuleOptionsDictionary arg2;
if (!arg2.Init(cx, (args.hasDefined(2)) ? args[2] : JS::NullHandleValue, "Argument 3", false)) {
return false;
}
FastErrorResult rv;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::DefineESModuleGetters(global, arg0, arg1, Constify(arg2), rv))>, "Should be returning void here");
mozilla::dom::ChromeUtils::DefineESModuleGetters(global, arg0, arg1, Constify(arg2), rv);
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.defineESModuleGetters"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setUndefined();
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
originAttributesToSuffix(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.originAttributesToSuffix");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "originAttributesToSuffix", 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;
}
binding_detail::FastOriginAttributesDictionary arg0;
if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue, "Argument 1", false)) {
return false;
}
nsAutoCString result;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::OriginAttributesToSuffix(global, Constify(arg0), result))>, "Should be returning void here");
mozilla::dom::ChromeUtils::OriginAttributesToSuffix(global, Constify(arg0), result);
MOZ_ASSERT(!JS_IsExceptionPending(cx));
if (!NonVoidByteStringToJsval(cx, result, args.rval())) {
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
originAttributesMatchPattern(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.originAttributesMatchPattern");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "originAttributesMatchPattern", 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;
}
binding_detail::FastOriginAttributesDictionary arg0;
if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue, "Argument 1", false)) {
return false;
}
binding_detail::FastOriginAttributesPatternDictionary arg1;
if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue, "Argument 2", false)) {
return false;
}
bool result(mozilla::dom::ChromeUtils::OriginAttributesMatchPattern(global, Constify(arg0), Constify(arg1)));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setBoolean(result);
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
createOriginAttributesFromOrigin(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "createOriginAttributesFromOrigin", 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, "ChromeUtils.createOriginAttributesFromOrigin", 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;
}
FastErrorResult rv;
OriginAttributesDictionary result;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::CreateOriginAttributesFromOrigin(global, NonNullHelper(Constify(arg0)), result, rv))>, "Should be returning void here");
mozilla::dom::ChromeUtils::CreateOriginAttributesFromOrigin(global, NonNullHelper(Constify(arg0)), result, rv);
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.createOriginAttributesFromOrigin"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
if (!result.ToObjectInternal(cx, args.rval())) {
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
CreateOriginAttributesFromOriginSuffix(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "CreateOriginAttributesFromOriginSuffix", 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, "ChromeUtils.CreateOriginAttributesFromOriginSuffix", 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;
}
FastErrorResult rv;
OriginAttributesDictionary result;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::CreateOriginAttributesFromOriginSuffix(global, NonNullHelper(Constify(arg0)), result, rv))>, "Should be returning void here");
mozilla::dom::ChromeUtils::CreateOriginAttributesFromOriginSuffix(global, NonNullHelper(Constify(arg0)), result, rv);
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.CreateOriginAttributesFromOriginSuffix"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
if (!result.ToObjectInternal(cx, args.rval())) {
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
fillNonDefaultOriginAttributes(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.fillNonDefaultOriginAttributes");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "fillNonDefaultOriginAttributes", 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;
}
binding_detail::FastOriginAttributesDictionary arg0;
if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue, "Argument 1", false)) {
return false;
}
OriginAttributesDictionary result;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::FillNonDefaultOriginAttributes(global, Constify(arg0), result))>, "Should be returning void here");
mozilla::dom::ChromeUtils::FillNonDefaultOriginAttributes(global, Constify(arg0), result);
MOZ_ASSERT(!JS_IsExceptionPending(cx));
if (!result.ToObjectInternal(cx, args.rval())) {
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
isOriginAttributesEqual(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.isOriginAttributesEqual");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "isOriginAttributesEqual", 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;
}
binding_detail::FastOriginAttributesDictionary arg0;
if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue, "Argument 1", false)) {
return false;
}
binding_detail::FastOriginAttributesDictionary arg1;
if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue, "Argument 2", false)) {
return false;
}
bool result(mozilla::dom::ChromeUtils::IsOriginAttributesEqual(global, Constify(arg0), Constify(arg1)));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setBoolean(result);
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
getBaseDomainFromPartitionKey(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "getBaseDomainFromPartitionKey", 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, "ChromeUtils.getBaseDomainFromPartitionKey", 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;
}
FastErrorResult rv;
DOMString result;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::GetBaseDomainFromPartitionKey(global, NonNullHelper(Constify(arg0)), result, rv))>, "Should be returning void here");
mozilla::dom::ChromeUtils::GetBaseDomainFromPartitionKey(global, NonNullHelper(Constify(arg0)), result, rv);
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.getBaseDomainFromPartitionKey"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
getPartitionKeyFromURL(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "getPartitionKeyFromURL", 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, "ChromeUtils.getPartitionKeyFromURL", 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;
}
Optional<bool> arg2;
if (args.hasDefined(2)) {
arg2.Construct();
if (!ValueToPrimitive<bool, eDefault>(cx, args[2], "Argument 3", &arg2.Value())) {
return false;
}
}
FastErrorResult rv;
DOMString result;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::GetPartitionKeyFromURL(global, NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), Constify(arg2), result, rv))>, "Should be returning void here");
mozilla::dom::ChromeUtils::GetPartitionKeyFromURL(global, NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), Constify(arg2), result, rv);
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.getPartitionKeyFromURL"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
compileScript(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.compileScript");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "compileScript", 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, "ChromeUtils.compileScript", 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;
}
binding_detail::FastCompileScriptOptionsDictionary arg1;
if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue, "Argument 2", false)) {
return false;
}
FastErrorResult rv;
auto result(StrongOrRawPtr<Promise>(mozilla::dom::ChromeUtils::CompileScript(global, NonNullHelper(Constify(arg0)), Constify(arg1), rv)));
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.compileScript"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
static_assert(!std::is_pointer_v<decltype(result)>,
"NewObject implies that we need to keep the object alive with a strong reference.");
if (!ToJSValue(cx, result, args.rval())) {
return false;
}
return true;
}
static const JSJitInfo compileScript_methodinfo = {
{ (JSJitGetterOp)compileScript },
{ prototypes::id::_ID_Count }, { 0 }, JSJitInfo::StaticMethod,
JSJitInfo::AliasEverything, JSVAL_TYPE_OBJECT, false, false,
false, false, 0
};
MOZ_CAN_RUN_SCRIPT static bool
generateQI(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.generateQI");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "generateQI", 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, "ChromeUtils.generateQI", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
binding_detail::AutoSequence<JS::Value> arg0;
SequenceRooter<JS::Value> arg0_holder(cx, &arg0);
if (args[0].isObject()) {
JS::ForOfIterator iter(cx);
if (!iter.init(args[0], JS::ForOfIterator::AllowNonIterable)) {
return false;
}
if (!iter.valueIsIterable()) {
cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("Argument 1", "sequence");
return false;
}
binding_detail::AutoSequence<JS::Value> &arr = arg0;
JS::Rooted<JS::Value> temp(cx);
while (true) {
bool done;
if (!iter.next(&temp, &done)) {
return false;
}
if (done) {
break;
}
JS::Value* slotPtr = arr.AppendElement(mozilla::fallible);
if (!slotPtr) {
JS_ReportOutOfMemory(cx);
return false;
}
JS::Value& slot = *slotPtr;
slot = temp;
}
} else {
cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("Argument 1", "sequence");
return false;
}
auto result(StrongOrRawPtr<mozilla::dom::MozQueryInterface>(mozilla::dom::ChromeUtils::GenerateQI(global, Constify(arg0))));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
static_assert(!std::is_pointer_v<decltype(result)>,
"NewObject implies that we need to keep the object alive with a strong reference.");
if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval())) {
MOZ_ASSERT(JS_IsExceptionPending(cx));
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
waiveXrays(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "waiveXrays", 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, "ChromeUtils.waiveXrays", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
JS::Rooted<JS::Value> arg0(cx);
arg0 = args[0];
FastErrorResult rv;
JS::Rooted<JS::Value> result(cx);
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::WaiveXrays(global, arg0, &result, rv))>, "Should be returning void here");
mozilla::dom::ChromeUtils::WaiveXrays(global, arg0, &result, rv);
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.waiveXrays"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
JS::ExposeValueToActiveJS(result);
args.rval().set(result);
if (!MaybeWrapValue(cx, args.rval())) {
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
unwaiveXrays(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "unwaiveXrays", 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, "ChromeUtils.unwaiveXrays", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
JS::Rooted<JS::Value> arg0(cx);
arg0 = args[0];
FastErrorResult rv;
JS::Rooted<JS::Value> result(cx);
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::UnwaiveXrays(global, arg0, &result, rv))>, "Should be returning void here");
mozilla::dom::ChromeUtils::UnwaiveXrays(global, arg0, &result, rv);
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.unwaiveXrays"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
JS::ExposeValueToActiveJS(result);
args.rval().set(result);
if (!MaybeWrapValue(cx, args.rval())) {
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
getClassName(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.getClassName");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "getClassName", 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, "ChromeUtils.getClassName", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
JS::Rooted<JSObject*> arg0(cx);
if (args[0].isObject()) {
arg0 = &args[0].toObject();
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Argument 1");
return false;
}
bool arg1;
if (args.hasDefined(1)) {
if (!ValueToPrimitive<bool, eDefault>(cx, args[1], "Argument 2", &arg1)) {
return false;
}
} else {
arg1 = true;
}
DOMString result;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::GetClassName(global, arg0, arg1, result))>, "Should be returning void here");
mozilla::dom::ChromeUtils::GetClassName(global, arg0, arg1, result);
MOZ_ASSERT(!JS_IsExceptionPending(cx));
if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
isDOMObject(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.isDOMObject");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "isDOMObject", 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, "ChromeUtils.isDOMObject", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
JS::Rooted<JSObject*> arg0(cx);
if (args[0].isObject()) {
arg0 = &args[0].toObject();
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Argument 1");
return false;
}
bool arg1;
if (args.hasDefined(1)) {
if (!ValueToPrimitive<bool, eDefault>(cx, args[1], "Argument 2", &arg1)) {
return false;
}
} else {
arg1 = true;
}
bool result(mozilla::dom::ChromeUtils::IsDOMObject(global, arg0, arg1));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setBoolean(result);
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
isISOStyleDate(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "isISOStyleDate", 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, "ChromeUtils.isISOStyleDate", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
binding_detail::FakeString<char> arg0;
if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
return false;
}
bool result(mozilla::dom::ChromeUtils::IsISOStyleDate(global, Constify(arg0)));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setBoolean(result);
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
shallowClone(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.shallowClone");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "shallowClone", 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, "ChromeUtils.shallowClone", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
JS::Rooted<JSObject*> arg0(cx);
if (args[0].isObject()) {
arg0 = &args[0].toObject();
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Argument 1");
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;
}
FastErrorResult rv;
JS::Rooted<JSObject*> result(cx);
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::ShallowClone(global, arg0, arg1, &result, rv))>, "Should be returning void here");
mozilla::dom::ChromeUtils::ShallowClone(global, arg0, arg1, &result, rv);
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.shallowClone"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
JS::ExposeObjectToActiveJS(result);
args.rval().setObject(*result);
if (!MaybeWrapObjectValue(cx, args.rval())) {
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
idleDispatch(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.idleDispatch");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "idleDispatch", 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, "ChromeUtils.idleDispatch", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
RootedCallback<OwningNonNull<binding_detail::FastIdleRequestCallback>> arg0(cx);
if (args[0].isObject()) {
if (JS::IsCallable(&args[0].toObject())) {
{ // scope for tempRoot and tempGlobalRoot if needed
arg0 = new binding_detail::FastIdleRequestCallback(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
}
} else {
cx.ThrowErrorMessage<MSG_NOT_CALLABLE>("Argument 1");
return false;
}
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Argument 1");
return false;
}
binding_detail::FastIdleRequestOptions arg1;
if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue, "Argument 2", false)) {
return false;
}
FastErrorResult rv;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::IdleDispatch(global, MOZ_KnownLive(NonNullHelper(arg0)), Constify(arg1), rv))>, "Should be returning void here");
mozilla::dom::ChromeUtils::IdleDispatch(global, MOZ_KnownLive(NonNullHelper(arg0)), Constify(arg1), rv);
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.idleDispatch"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setUndefined();
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
import(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.import");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "import", 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, "ChromeUtils.import", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
binding_detail::FakeString<char> arg0;
if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
return false;
}
Optional<JS::Handle<JSObject*>> arg1;
if (args.hasDefined(1)) {
arg1.Construct(cx);
if (args[1].isObject()) {
arg1.Value() = &args[1].toObject();
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Argument 2");
return false;
}
}
FastErrorResult rv;
JS::Rooted<JSObject*> result(cx);
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::Import(global, Constify(arg0), Constify(arg1), &result, rv))>, "Should be returning void here");
mozilla::dom::ChromeUtils::Import(global, Constify(arg0), Constify(arg1), &result, rv);
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.import"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
JS::ExposeObjectToActiveJS(result);
args.rval().setObject(*result);
if (!MaybeWrapObjectValue(cx, args.rval())) {
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
defineModuleGetter(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.defineModuleGetter");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "defineModuleGetter", 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, "ChromeUtils.defineModuleGetter", 3)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
JS::Rooted<JSObject*> arg0(cx);
if (args[0].isObject()) {
arg0 = &args[0].toObject();
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Argument 1");
return false;
}
binding_detail::FakeString<char16_t> arg1;
if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
return false;
}
binding_detail::FakeString<char16_t> arg2;
if (!ConvertJSValueToString(cx, args[2], eStringify, eStringify, arg2)) {
return false;
}
FastErrorResult rv;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::DefineModuleGetter(global, arg0, NonNullHelper(Constify(arg1)), NonNullHelper(Constify(arg2)), rv))>, "Should be returning void here");
mozilla::dom::ChromeUtils::DefineModuleGetter(global, arg0, NonNullHelper(Constify(arg1)), NonNullHelper(Constify(arg2)), rv);
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.defineModuleGetter"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setUndefined();
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
getCallerLocation(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.getCallerLocation");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "getCallerLocation", 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, "ChromeUtils.getCallerLocation", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
nsIPrincipal* arg0;
RefPtr<nsIPrincipal> arg0_holder;
if (args[0].isObject()) {
JS::Rooted<JSObject*> source(cx, &args[0].toObject());
if (NS_FAILED(UnwrapArg<nsIPrincipal>(cx, source, getter_AddRefs(arg0_holder)))) {
cx.ThrowErrorMessage<MSG_DOES_NOT_IMPLEMENT_INTERFACE>("Argument 1", "Principal");
return false;
}
MOZ_ASSERT(arg0_holder);
arg0 = arg0_holder;
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Argument 1");
return false;
}
JS::Rooted<JSObject*> result(cx);
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::GetCallerLocation(global, MOZ_KnownLive(NonNullHelper(arg0)), &result))>, "Should be returning void here");
mozilla::dom::ChromeUtils::GetCallerLocation(global, MOZ_KnownLive(NonNullHelper(arg0)), &result);
MOZ_ASSERT(!JS_IsExceptionPending(cx));
if (result) {
JS::ExposeObjectToActiveJS(result);
}
args.rval().setObjectOrNull(result);
if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
createError(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.createError");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "createError", 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, "ChromeUtils.createError", 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;
}
FastErrorResult rv;
JS::Rooted<JSObject*> result(cx);
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::CreateError(global, NonNullHelper(Constify(arg0)), arg1, &result, rv))>, "Should be returning void here");
mozilla::dom::ChromeUtils::CreateError(global, NonNullHelper(Constify(arg0)), arg1, &result, rv);
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.createError"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
JS::ExposeObjectToActiveJS(result);
args.rval().setObject(*result);
if (!MaybeWrapObjectValue(cx, args.rval())) {
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
setPerfStatsCollectionMask(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "setPerfStatsCollectionMask", 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, "ChromeUtils.setPerfStatsCollectionMask", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
uint64_t arg0;
if (!ValueToPrimitive<uint64_t, eDefault>(cx, args[0], "Argument 1", &arg0)) {
return false;
}
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::SetPerfStatsCollectionMask(global, arg0))>, "Should be returning void here");
mozilla::dom::ChromeUtils::SetPerfStatsCollectionMask(global, arg0);
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setUndefined();
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
collectPerfStats(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "collectPerfStats", 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;
}
FastErrorResult rv;
auto result(StrongOrRawPtr<Promise>(mozilla::dom::ChromeUtils::CollectPerfStats(global, rv)));
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.collectPerfStats"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
static_assert(!std::is_pointer_v<decltype(result)>,
"NewObject implies that we need to keep the object alive with a strong reference.");
if (!ToJSValue(cx, result, args.rval())) {
return false;
}
return true;
}
static const JSJitInfo collectPerfStats_methodinfo = {
{ (JSJitGetterOp)collectPerfStats },
{ prototypes::id::_ID_Count }, { 0 }, JSJitInfo::StaticMethod,
JSJitInfo::AliasEverything, JSVAL_TYPE_OBJECT, false, false,
false, false, 0
};
MOZ_CAN_RUN_SCRIPT static bool
requestProcInfo(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "requestProcInfo", 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;
}
FastErrorResult rv;
auto result(StrongOrRawPtr<Promise>(mozilla::dom::ChromeUtils::RequestProcInfo(global, rv)));
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.requestProcInfo"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
static_assert(!std::is_pointer_v<decltype(result)>,
"NewObject implies that we need to keep the object alive with a strong reference.");
if (!ToJSValue(cx, result, args.rval())) {
return false;
}
return true;
}
static const JSJitInfo requestProcInfo_methodinfo = {
{ (JSJitGetterOp)requestProcInfo },
{ prototypes::id::_ID_Count }, { 0 }, JSJitInfo::StaticMethod,
JSJitInfo::AliasEverything, JSVAL_TYPE_OBJECT, false, false,
false, false, 0
};
MOZ_CAN_RUN_SCRIPT static bool
vsyncEnabled(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "vsyncEnabled", 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 result(mozilla::dom::ChromeUtils::VsyncEnabled(global));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setBoolean(result);
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
hasReportingHeaderForOrigin(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "hasReportingHeaderForOrigin", 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, "ChromeUtils.hasReportingHeaderForOrigin", 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;
}
FastErrorResult rv;
bool result(mozilla::dom::ChromeUtils::HasReportingHeaderForOrigin(global, NonNullHelper(Constify(arg0)), rv));
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.hasReportingHeaderForOrigin"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setBoolean(result);
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
getPopupControlState(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "getPopupControlState", 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;
}
PopupBlockerState result(mozilla::dom::ChromeUtils::GetPopupControlState(global));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
if (!ToJSValue(cx, result, args.rval())) {
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
lastExternalProtocolIframeAllowed(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "lastExternalProtocolIframeAllowed", 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;
}
double result(mozilla::dom::ChromeUtils::LastExternalProtocolIframeAllowed(global));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().set(JS_NumberValue(double(result)));
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
resetLastExternalProtocolIframeAllowed(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "resetLastExternalProtocolIframeAllowed", 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;
}
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::ResetLastExternalProtocolIframeAllowed(global))>, "Should be returning void here");
mozilla::dom::ChromeUtils::ResetLastExternalProtocolIframeAllowed(global);
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setUndefined();
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
endWheelTransaction(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "endWheelTransaction", 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;
}
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::EndWheelTransaction(global))>, "Should be returning void here");
mozilla::dom::ChromeUtils::EndWheelTransaction(global);
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setUndefined();
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
registerWindowActor(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.registerWindowActor");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "registerWindowActor", 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, "ChromeUtils.registerWindowActor", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
binding_detail::FakeString<char> arg0;
if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
return false;
}
binding_detail::FastWindowActorOptions arg1;
if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue, "Argument 2", false)) {
return false;
}
FastErrorResult rv;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::RegisterWindowActor(global, Constify(arg0), Constify(arg1), rv))>, "Should be returning void here");
mozilla::dom::ChromeUtils::RegisterWindowActor(global, Constify(arg0), Constify(arg1), rv);
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.registerWindowActor"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setUndefined();
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
unregisterWindowActor(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "unregisterWindowActor", 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, "ChromeUtils.unregisterWindowActor", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
binding_detail::FakeString<char> arg0;
if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
return false;
}
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::UnregisterWindowActor(global, Constify(arg0)))>, "Should be returning void here");
mozilla::dom::ChromeUtils::UnregisterWindowActor(global, Constify(arg0));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setUndefined();
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
registerProcessActor(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.registerProcessActor");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "registerProcessActor", 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, "ChromeUtils.registerProcessActor", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
binding_detail::FakeString<char> arg0;
if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
return false;
}
binding_detail::FastProcessActorOptions arg1;
if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue, "Argument 2", false)) {
return false;
}
FastErrorResult rv;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::RegisterProcessActor(global, Constify(arg0), Constify(arg1), rv))>, "Should be returning void here");
mozilla::dom::ChromeUtils::RegisterProcessActor(global, Constify(arg0), Constify(arg1), rv);
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.registerProcessActor"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setUndefined();
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
unregisterProcessActor(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "unregisterProcessActor", 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, "ChromeUtils.unregisterProcessActor", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
binding_detail::FakeString<char> arg0;
if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
return false;
}
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::UnregisterProcessActor(global, Constify(arg0)))>, "Should be returning void here");
mozilla::dom::ChromeUtils::UnregisterProcessActor(global, Constify(arg0));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setUndefined();
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
isClassifierBlockingErrorCode(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "isClassifierBlockingErrorCode", 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, "ChromeUtils.isClassifierBlockingErrorCode", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
uint32_t arg0;
if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], "Argument 1", &arg0)) {
return false;
}
bool result(mozilla::dom::ChromeUtils::IsClassifierBlockingErrorCode(global, arg0));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setBoolean(result);
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
privateNoteIntentionalCrash(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "privateNoteIntentionalCrash", 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;
}
FastErrorResult rv;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::PrivateNoteIntentionalCrash(global, rv))>, "Should be returning void here");
mozilla::dom::ChromeUtils::PrivateNoteIntentionalCrash(global, rv);
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.privateNoteIntentionalCrash"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setUndefined();
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
get_domProcessChild(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "domProcessChild", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) |
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;
}
auto result(StrongOrRawPtr<nsIDOMProcessChild>(mozilla::dom::ChromeUtils::GetDomProcessChild(global)));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
if (!result) {
args.rval().setNull();
return true;
}
if (!WrapObject(cx, result, &NS_GET_IID(nsIDOMProcessChild), args.rval())) {
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
getAllDOMProcesses(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "getAllDOMProcesses", 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;
}
FastErrorResult rv;
nsTArray<StrongPtrForMember<nsIDOMProcessParent>> result;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::GetAllDOMProcesses(global, result, rv))>, "Should be returning void here");
mozilla::dom::ChromeUtils::GetAllDOMProcesses(global, result, rv);
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.getAllDOMProcesses"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
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 (!WrapObject(cx, result[sequenceIdx0], &NS_GET_IID(nsIDOMProcessParent), &tmp)) {
return false;
}
break;
} while (false);
if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
JSPROP_ENUMERATE)) {
return false;
}
}
}
args.rval().setObject(*returnArray);
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
consumeInteractionData(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "consumeInteractionData", 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;
}
FastErrorResult rv;
Record<nsString, InteractionData> result;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::ConsumeInteractionData(global, result, rv))>, "Should be returning void here");
mozilla::dom::ChromeUtils::ConsumeInteractionData(global, result, rv);
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.consumeInteractionData"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
JS::Rooted<JSObject*> returnObj(cx, JS_NewPlainObject(cx));
if (!returnObj) {
return false;
}
// Scope for 'tmp'
{
JS::Rooted<JS::Value> tmp(cx);
for (auto& entry : result.Entries()) {
auto& recordValue0 = entry.mValue;
// Control block to let us common up the JS_DefineUCProperty calls when there
// are different ways to succeed at wrapping the value.
do {
if (!recordValue0.ToObjectInternal(cx, &tmp)) {
return false;
}
break;
} while (false);
if (!JS_DefineUCProperty(cx, returnObj,
entry.mKey.BeginReading(),
entry.mKey.Length(), tmp,
JSPROP_ENUMERATE)) {
return false;
}
}
}
args.rval().setObject(*returnObj);
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
collectScrollingData(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "collectScrollingData", 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;
}
FastErrorResult rv;
auto result(StrongOrRawPtr<Promise>(mozilla::dom::ChromeUtils::CollectScrollingData(global, rv)));
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.collectScrollingData"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
static_assert(!std::is_pointer_v<decltype(result)>,
"NewObject implies that we need to keep the object alive with a strong reference.");
if (!ToJSValue(cx, result, args.rval())) {
return false;
}
return true;
}
static const JSJitInfo collectScrollingData_methodinfo = {
{ (JSJitGetterOp)collectScrollingData },
{ prototypes::id::_ID_Count }, { 0 }, JSJitInfo::StaticMethod,
JSJitInfo::AliasEverything, JSVAL_TYPE_OBJECT, false, false,
false, false, 0
};
MOZ_CAN_RUN_SCRIPT static bool
getFormAutofillConfidences(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.getFormAutofillConfidences");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "getFormAutofillConfidences", 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, "ChromeUtils.getFormAutofillConfidences", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
binding_detail::AutoSequence<OwningNonNull<mozilla::dom::Element>> arg0;
if (args[0].isObject()) {
JS::ForOfIterator iter(cx);
if (!iter.init(args[0], JS::ForOfIterator::AllowNonIterable)) {
return false;
}
if (!iter.valueIsIterable()) {
cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("Argument 1", "sequence");
return false;
}
binding_detail::AutoSequence<OwningNonNull<mozilla::dom::Element>> &arr = arg0;
JS::Rooted<JS::Value> temp(cx);
while (true) {
bool done;
if (!iter.next(&temp, &done)) {
return false;
}
if (done) {
break;
}
OwningNonNull<mozilla::dom::Element>* slotPtr = arr.AppendElement(mozilla::fallible);
if (!slotPtr) {
JS_ReportOutOfMemory(cx);
return false;
}
OwningNonNull<mozilla::dom::Element>& slot = *slotPtr;
if (temp.isObject()) {
static_assert(IsRefcounted<mozilla::dom::Element>::value, "We can only store refcounted classes.");
{
// Our JSContext should be in the right global to do unwrapping in.
nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(&temp, slot, cx);
if (NS_FAILED(rv)) {
cx.ThrowErrorMessage<MSG_DOES_NOT_IMPLEMENT_INTERFACE>("Element of argument 1", "Element");
return false;
}
}
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Element of argument 1");
return false;
}
}
} else {
cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("Argument 1", "sequence");
return false;
}
FastErrorResult rv;
nsTArray<FormAutofillConfidences> result;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::GetFormAutofillConfidences(global, Constify(arg0), result, rv))>, "Should be returning void here");
mozilla::dom::ChromeUtils::GetFormAutofillConfidences(global, Constify(arg0), result, rv);
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "ChromeUtils.getFormAutofillConfidences"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
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 (!result[sequenceIdx0].ToObjectInternal(cx, &tmp)) {
return false;
}
break;
} while (false);
if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
JSPROP_ENUMERATE)) {
return false;
}
}
}
args.rval().setObject(*returnArray);
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
isDarkBackground(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.isDarkBackground");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "isDarkBackground", 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, "ChromeUtils.isDarkBackground", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
NonNull<mozilla::dom::Element> arg0;
if (args[0].isObject()) {
{
// Our JSContext should be in the right global to do unwrapping in.
nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(args[0], arg0, cx);
if (NS_FAILED(rv)) {
cx.ThrowErrorMessage<MSG_DOES_NOT_IMPLEMENT_INTERFACE>("Argument 1", "Element");
return false;
}
}
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Argument 1");
return false;
}
bool result(mozilla::dom::ChromeUtils::IsDarkBackground(global, MOZ_KnownLive(NonNullHelper(arg0))));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setBoolean(result);
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
ensureJSOracleStarted(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "ensureJSOracleStarted", 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;
}
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::EnsureJSOracleStarted(global))>, "Should be returning void here");
mozilla::dom::ChromeUtils::EnsureJSOracleStarted(global);
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setUndefined();
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
get_aliveUtilityProcesses(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "aliveUtilityProcesses", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) |
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;
}
uint32_t result(mozilla::dom::ChromeUtils::AliveUtilityProcesses(global));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setNumber(result);
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
getAllPossibleUtilityActorNames(JSContext* cx, unsigned argc, JS::Value* vp)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "getAllPossibleUtilityActorNames", 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;
}
nsTArray<nsCString> result;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(mozilla::dom::ChromeUtils::GetAllPossibleUtilityActorNames(global, result))>, "Should be returning void here");
mozilla::dom::ChromeUtils::GetAllPossibleUtilityActorNames(global, result);
MOZ_ASSERT(!JS_IsExceptionPending(cx));
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 (!NonVoidUTF8StringToJsval(cx, result[sequenceIdx0], &tmp)) {
return false;
}
break;
} while (false);
if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
JSPROP_ENUMERATE)) {
return false;
}
}
}
args.rval().setObject(*returnArray);
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
shouldResistFingerprinting(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "ChromeUtils.shouldResistFingerprinting");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"ChromeUtils", "shouldResistFingerprinting", 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, "ChromeUtils.shouldResistFingerprinting", 2)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
JSRFPTarget arg0;
{
int index;
if (!binding_detail::FindEnumStringIndex<true>(cx, args[0],
binding_detail::EnumStrings<JSRFPTarget>::Values,
"JSRFPTarget", "argument 1",
&index)) {
return false;
}
MOZ_ASSERT(index >= 0);
arg0 = static_cast<JSRFPTarget>(index);
}
Nullable<uint64_t> arg1;
if (args[1].isNullOrUndefined()) {
arg1.SetNull();
} else if (!ValueToPrimitive<uint64_t, eDefault>(cx, args[1], "Argument 2", &arg1.SetValue())) {
return false;
}
bool result(mozilla::dom::ChromeUtils::ShouldResistFingerprinting(global, arg0, Constify(arg1)));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setBoolean(result);
return true;
}
MOZ_GLOBINIT static const JSFunctionSpec sStaticMethods_specs[] = {
JS_FNSPEC("getObjectNodeId", getObjectNodeId, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("saveHeapSnapshot", saveHeapSnapshot, nullptr, 0, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("saveHeapSnapshotGetId", saveHeapSnapshotGetId, nullptr, 0, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("readHeapSnapshot", readHeapSnapshot, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("isDevToolsOpened", isDevToolsOpened, nullptr, 0, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("notifyDevToolsOpened", notifyDevToolsOpened, nullptr, 0, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("notifyDevToolsClosed", notifyDevToolsClosed, nullptr, 0, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("nondeterministicGetWeakMapKeys", nondeterministicGetWeakMapKeys, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("nondeterministicGetWeakSetKeys", nondeterministicGetWeakSetKeys, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("base64URLEncode", base64URLEncode, nullptr, 2, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("base64URLDecode", base64URLDecode, nullptr, 2, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("releaseAssert", releaseAssert, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("clearRecentJSDevError", clearRecentJSDevError, nullptr, 0, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("clearStyleSheetCacheBySite", clearStyleSheetCacheBySite, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("clearStyleSheetCacheByPrincipal", clearStyleSheetCacheByPrincipal, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("clearStyleSheetCache", clearStyleSheetCache, nullptr, 0, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("clearScriptCacheBySite", clearScriptCacheBySite, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("clearScriptCacheByPrincipal", clearScriptCacheByPrincipal, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("clearScriptCache", clearScriptCache, nullptr, 0, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("addProfilerMarker", addProfilerMarker, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("getXPCOMErrorName", getXPCOMErrorName, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("dateNow", dateNow, nullptr, 0, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("defineLazyGetter", defineLazyGetter, nullptr, 3, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("getLibcConstants", getLibcConstants, nullptr, 0, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("getGMPContentDecryptionModuleInformation", StaticMethodPromiseWrapper, &getGMPContentDecryptionModuleInformation_methodinfo, 0, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("importESModule", importESModule, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("defineESModuleGetters", defineESModuleGetters, nullptr, 2, JSPROP_ENUMERATE, nullptr),
JS_FS_END,
JS_FNSPEC("originAttributesToSuffix", originAttributesToSuffix, nullptr, 0, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("originAttributesMatchPattern", originAttributesMatchPattern, nullptr, 0, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("createOriginAttributesFromOrigin", createOriginAttributesFromOrigin, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("CreateOriginAttributesFromOriginSuffix", CreateOriginAttributesFromOriginSuffix, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("fillNonDefaultOriginAttributes", fillNonDefaultOriginAttributes, nullptr, 0, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("isOriginAttributesEqual", isOriginAttributesEqual, nullptr, 0, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("getBaseDomainFromPartitionKey", getBaseDomainFromPartitionKey, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("getPartitionKeyFromURL", getPartitionKeyFromURL, nullptr, 2, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("compileScript", StaticMethodPromiseWrapper, &compileScript_methodinfo, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("generateQI", generateQI, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("waiveXrays", waiveXrays, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("unwaiveXrays", unwaiveXrays, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("getClassName", getClassName, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("isDOMObject", isDOMObject, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("isISOStyleDate", isISOStyleDate, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("shallowClone", shallowClone, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("idleDispatch", idleDispatch, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("import", import, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("defineModuleGetter", defineModuleGetter, nullptr, 3, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("getCallerLocation", getCallerLocation, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("createError", createError, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("setPerfStatsCollectionMask", setPerfStatsCollectionMask, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("collectPerfStats", StaticMethodPromiseWrapper, &collectPerfStats_methodinfo, 0, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("requestProcInfo", StaticMethodPromiseWrapper, &requestProcInfo_methodinfo, 0, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("collectScrollingData", StaticMethodPromiseWrapper, &collectScrollingData_methodinfo, 0, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("getFormAutofillConfidences", getFormAutofillConfidences, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("isDarkBackground", isDarkBackground, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("ensureJSOracleStarted", ensureJSOracleStarted, nullptr, 0, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("shouldResistFingerprinting", shouldResistFingerprinting, nullptr, 2, JSPROP_ENUMERATE, nullptr),
JS_FS_END
};
static const PrefableDisablers sStaticMethods_disablers28 = {
WebIDLPrefIndex::NoPref, GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope, false, OriginTrial(0), nullptr
};
static const Prefable<const JSFunctionSpec> sStaticMethods[] = {
{ nullptr, &sStaticMethods_specs[0] },
{ &sStaticMethods_disablers28, &sStaticMethods_specs[28] },
{ 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(29 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
"We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
MOZ_GLOBINIT static const JSFunctionSpec sChromeStaticMethods_specs[] = {
JS_FNSPEC("vsyncEnabled", vsyncEnabled, nullptr, 0, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("hasReportingHeaderForOrigin", hasReportingHeaderForOrigin, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("getPopupControlState", getPopupControlState, nullptr, 0, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("lastExternalProtocolIframeAllowed", lastExternalProtocolIframeAllowed, nullptr, 0, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("resetLastExternalProtocolIframeAllowed", resetLastExternalProtocolIframeAllowed, nullptr, 0, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("endWheelTransaction", endWheelTransaction, nullptr, 0, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("registerWindowActor", registerWindowActor, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("unregisterWindowActor", unregisterWindowActor, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("registerProcessActor", registerProcessActor, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("unregisterProcessActor", unregisterProcessActor, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("isClassifierBlockingErrorCode", isClassifierBlockingErrorCode, nullptr, 1, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("privateNoteIntentionalCrash", privateNoteIntentionalCrash, nullptr, 0, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("getAllDOMProcesses", getAllDOMProcesses, nullptr, 0, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("consumeInteractionData", consumeInteractionData, nullptr, 0, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("getAllPossibleUtilityActorNames", getAllPossibleUtilityActorNames, nullptr, 0, JSPROP_ENUMERATE, nullptr),
JS_FS_END
};
static const PrefableDisablers sChromeStaticMethods_disablers0 = {
WebIDLPrefIndex::NoPref, GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope, false, OriginTrial(0), nullptr
};
static const Prefable<const JSFunctionSpec> sChromeStaticMethods[] = {
{ &sChromeStaticMethods_disablers0, &sChromeStaticMethods_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(15 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
"We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
MOZ_GLOBINIT static const JSPropertySpec sStaticAttributes_specs[] = {
JSPropertySpec::nativeAccessors("recentJSDevError", JSPROP_ENUMERATE, get_recentJSDevError, nullptr, nullptr, nullptr),
JS_PS_END
};
static const Prefable<const JSPropertySpec> sStaticAttributes[] = {
{ nullptr, &sStaticAttributes_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)");
MOZ_GLOBINIT static const JSPropertySpec sChromeStaticAttributes_specs[] = {
JSPropertySpec::nativeAccessors("domProcessChild", JSPROP_ENUMERATE, get_domProcessChild, nullptr, nullptr, nullptr),
JSPropertySpec::nativeAccessors("aliveUtilityProcesses", JSPROP_ENUMERATE, get_aliveUtilityProcesses, nullptr, nullptr, nullptr),
JS_PS_END
};
static const PrefableDisablers sChromeStaticAttributes_disablers0 = {
WebIDLPrefIndex::NoPref, GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope, false, OriginTrial(0), nullptr
};
static const Prefable<const JSPropertySpec> sChromeStaticAttributes[] = {
{ &sChromeStaticAttributes_disablers0, &sChromeStaticAttributes_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(2 <= 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[57];
static PropertyInfo sNativeProperties_propertyInfos[57];
static const NativePropertiesN<2> sNativeProperties = {
true, 0 /* sStaticMethods */,
true, 1 /* sStaticAttributes */,
false, 0,
false, 0,
false, 0,
false, 0,
false, 0,
-1,
57,
sNativeProperties_sortedPropertyIndices,
{
{ sStaticMethods, &sNativeProperties_propertyInfos[0] },
{ sStaticAttributes, &sNativeProperties_propertyInfos[56] }
}
};
static_assert(57 < 1ull << (CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount)),
"We have a property info count that is oversized");
static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[17];
static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[17];
static const NativePropertiesN<2> sChromeOnlyNativeProperties = {
true, 0 /* sChromeStaticMethods */,
true, 1 /* sChromeStaticAttributes */,
false, 0,
false, 0,
false, 0,
false, 0,
false, 0,
-1,
17,
sChromeOnlyNativeProperties_sortedPropertyIndices,
{
{ sChromeStaticMethods, &sChromeOnlyNativeProperties_propertyInfos[0] },
{ sChromeStaticAttributes, &sChromeOnlyNativeProperties_propertyInfos[15] }
}
};
static_assert(17 < 1ull << (CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount)),
"We have a property info count that is oversized");
bool sNativePropertiesInited = false;
const NativePropertyHooks sNativePropertyHooks = {
nullptr,
{ sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast(), &sNativePropertiesInited },
prototypes::id::_ID_Count,
constructors::id::ChromeUtils,
&DefaultXrayExpandoObjectClass
};
static const DOMIfaceAndProtoJSClass sNamespaceObjectClass = {
{
"ChromeUtils",
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,
// This isn't strictly following the spec (see
// but should be ok for Xrays.
JS::GetRealmObjectPrototype
};
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
{
return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
}
void
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, DefineInterfaceProperty aDefineOnGlobal)
{
JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmObjectPrototype(aCx));
if (!constructorProto) {
return;
}
JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::ChromeUtils);
dom::CreateNamespaceObject(aCx, aGlobal, constructorProto,
sNamespaceObjectClass,
interfaceCache,
sNativeProperties.Upcast(),
sChromeOnlyNativeProperties.Upcast(),
"ChromeUtils",
ShouldExpose<ChromeUtils_Binding::ConstructorEnabled>(aCx, aGlobal, aDefineOnGlobal));
}
JS::Handle<JSObject*>
GetConstructorObjectHandle(JSContext* aCx)
{
/* Get the interface object for this class. This will create the object as
needed. */
return GetPerInterfaceObjectHandle(aCx, constructors::id::ChromeUtils,
&CreateInterfaceObjects,
DefineInterfaceProperty::CheckExposure);
}
} // namespace ChromeUtils_Binding
namespace MozQueryInterface_Binding {
static void
_finalize(JS::GCContext* gcx, JSObject* obj)
{
mozilla::dom::MozQueryInterface* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MozQueryInterface>(obj);
if (self) {
JS::SetReservedSlot(obj, DOM_OBJECT_SLOT, JS::UndefinedValue());
if (size_t mallocBytes = BindingJSObjectMallocBytes(self)) {
JS::RemoveAssociatedMemory(obj, mallocBytes,
JS::MemoryUse::DOMBinding);
}
AddForDeferredFinalization<mozilla::dom::MozQueryInterface>(self);
}
}
bool sNativePropertiesInited = false;
const NativePropertyHooks sNativePropertyHooks = {
nullptr,
{ nullptr, nullptr, &sNativePropertiesInited },
prototypes::id::MozQueryInterface,
constructors::id::MozQueryInterface,
&DefaultXrayExpandoObjectClass
};
static const DOMInterfaceInfo sInterfaceObjectInfo = {
{ ThrowingConstructor, &sNativePropertyHooks },
JS::GetRealmFunctionPrototypeHandle,
PrototypeTraits<prototypes::id::MozQueryInterface>::Depth,
prototypes::id::MozQueryInterface,
true,
0,
"MozQueryInterface",
};
MOZ_CAN_RUN_SCRIPT static bool
_legacycaller(JSContext* cx, unsigned argc, JS::Value* vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::Rooted<JSObject*> obj(cx, &args.callee());
mozilla::dom::MozQueryInterface* self;
JS::Rooted<JS::Value> rootSelf(cx, JS::ObjectValue(*obj));
{
// Our JSContext should be in the right global to do unwrapping in.
nsresult rv = UnwrapObject<prototypes::id::MozQueryInterface, mozilla::dom::MozQueryInterface>(&rootSelf, self, cx);
if (NS_FAILED(rv)) {
MOZ_CRASH("Unexpected object in '_legacycaller' hook");
return false;
}
}
if (!args.requireAtLeast(cx, "MozQueryInterface legacy caller", 1)) {
return false;
}
JS::Rooted<JS::Value> arg0(cx);
arg0 = args[0];
FastErrorResult rv;
JS::Rooted<JS::Value> result(cx);
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(MOZ_KnownLive(self)->LegacyCall(cx, args.thisv(), arg0, &result, rv))>, "Should be returning void here");
MOZ_KnownLive(self)->LegacyCall(cx, args.thisv(), arg0, &result, rv);
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "MozQueryInterface legacy caller"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
JS::ExposeValueToActiveJS(result);
args.rval().set(result);
if (!MaybeWrapValue(cx, args.rval())) {
return false;
}
return true;
}
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
{
"MozQueryInterfacePrototype",
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::MozQueryInterface,
PrototypeTraits<prototypes::id::MozQueryInterface>::Depth,
&sNativePropertyHooks,
JS::GetRealmObjectPrototype
};
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
{
return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
}
static JS::Handle<JSObject*>
GetProtoObjectHandle(JSContext* aCx);
static const JSClassOps sClassOps = {
nullptr, /* addProperty */
nullptr, /* delProperty */
nullptr, /* enumerate */
nullptr, /* newEnumerate */
nullptr, /* resolve */
nullptr, /* mayResolve */
_finalize, /* finalize */
_legacycaller, /* call */
nullptr, /* construct */
nullptr, /* trace */
};
static const js::ClassExtension sClassExtension = {
nullptr /* objectMovedOp */
};
static const DOMJSClass sClass = {
{ "MozQueryInterface",
JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
&sClassOps,
JS_NULL_CLASS_SPEC,
&sClassExtension,
JS_NULL_OBJECT_OPS
},
{ prototypes::id::MozQueryInterface, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
std::is_base_of_v<nsISupports, mozilla::dom::MozQueryInterface>,
&sNativePropertyHooks,
FindAssociatedGlobalForNative<mozilla::dom::MozQueryInterface>::Get,
GetProtoObjectHandle,
GetCCParticipant<mozilla::dom::MozQueryInterface>::Get(),
nullptr,
nullptr
};
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
"Must have the right minimal number of reserved slots.");
static_assert(1 >= 1,
"Must have enough reserved slots.");
bool
Wrap(JSContext* aCx, mozilla::dom::MozQueryInterface* aObject, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
{
static_assert(std::is_same_v<decltype(aObject), mozilla::dom::MozQueryInterface*>);
MOZ_ASSERT(ToSupportsIsCorrect(aObject));
MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
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::MozQueryInterface> creator(aCx);
creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
if (!aReflector) {
return false;
}
creator.InitializationSucceeded();
return true;
}
void
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, DefineInterfaceProperty aDefineOnGlobal)
{
JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::MozQueryInterface);
JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::MozQueryInterface);
JS::Handle<JSObject*> parentProto(JS::GetRealmObjectPrototypeHandle(aCx));
if (!parentProto) {
return;
}
JS::Handle<JSObject*> constructorProto(JS::GetRealmFunctionPrototypeHandle(aCx));
if (!constructorProto) {
return;
}
dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
&sPrototypeClass, protoCache,
constructorProto, &sInterfaceObjectInfo, 0, false, Span<const LegacyFactoryFunction, 0>{},
interfaceCache,
nullptr,
nullptr,
"MozQueryInterface",
ShouldExpose<MozQueryInterface_Binding::ConstructorEnabled>(aCx, aGlobal, aDefineOnGlobal),
nullptr,
false,
nullptr);
}
static JS::Handle<JSObject*>
GetProtoObjectHandle(JSContext* aCx)
{
/* Get the interface prototype object for this class. This will create the
object as needed. */
return GetPerInterfaceObjectHandle(aCx, prototypes::id::MozQueryInterface,
&CreateInterfaceObjects,
DefineInterfaceProperty::CheckExposure);
}
JS::Handle<JSObject*>
GetConstructorObjectHandle(JSContext* aCx)
{
/* Get the interface object for this class. This will create the object as
needed. */
return GetPerInterfaceObjectHandle(aCx, constructors::id::MozQueryInterface,
&CreateInterfaceObjects,
DefineInterfaceProperty::CheckExposure);
}
} // namespace MozQueryInterface_Binding
} // namespace dom
} // namespace mozilla