Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM IdentityCredential.webidl BY Codegen.py - DO NOT EDIT */
#include <type_traits>
#include "AtomList.h"
#include "CredentialManagementBinding.h"
#include "IdentityCredentialBinding.h"
#include "MainThreadUtils.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 "mozilla/Atomics.h"
#include "mozilla/OwningNonNull.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/StaticPrefs_dom.h"
#include "mozilla/dom/BindingCallContext.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/DOMJSClass.h"
#include "mozilla/dom/IdentityCredential.h"
#include "mozilla/dom/NonRefcountedDOMObject.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/dom/PrimitiveConversions.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/SimpleGlobalObject.h"
#include "mozilla/dom/ToJSValue.h"
#include "mozilla/dom/WebIDLPrefs.h"
#include "mozilla/dom/XrayExpandoClass.h"
namespace mozilla::dom {
namespace binding_detail {}; // Just to make sure it's known as a namespace
using namespace mozilla::dom::binding_detail;
IdentityCredentialLogoutRPsRequest::IdentityCredentialLogoutRPsRequest()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
IdentityCredentialLogoutRPsRequest::InitIds(JSContext* cx, IdentityCredentialLogoutRPsRequestAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->url_id.init(cx, "url") ||
!atomsCache->accountId_id.init(cx, "accountId")) {
return false;
}
return true;
}
bool
IdentityCredentialLogoutRPsRequest::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());
IdentityCredentialLogoutRPsRequestAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<IdentityCredentialLogoutRPsRequestAtoms>(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->accountId_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mAccountId)) {
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>("'accountId' member of IdentityCredentialLogoutRPsRequest");
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->url_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mUrl)) {
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>("'url' member of IdentityCredentialLogoutRPsRequest");
}
return true;
}
bool
IdentityCredentialLogoutRPsRequest::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
IdentityCredentialLogoutRPsRequest::TraceDictionary(JSTracer* trc)
{
}
IdentityCredentialLogoutRPsRequest&
IdentityCredentialLogoutRPsRequest::operator=(const IdentityCredentialLogoutRPsRequest& aOther)
{
DictionaryBase::operator=(aOther);
mAccountId = aOther.mAccountId;
mUrl = aOther.mUrl;
return *this;
}
bool
IdentityCredentialLogoutRPsRequest::operator==(const IdentityCredentialLogoutRPsRequest& aOther) const
{
if (mAccountId != aOther.mAccountId) {
return false;
}
if (mUrl != aOther.mUrl) {
return false;
}
return true;
}
IdentityProviderAccount::IdentityProviderAccount()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
IdentityProviderAccount::InitIds(JSContext* cx, IdentityProviderAccountAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->picture_id.init(cx, "picture") ||
!atomsCache->name_id.init(cx, "name") ||
!atomsCache->id_id.init(cx, "id") ||
!atomsCache->given_name_id.init(cx, "given_name") ||
!atomsCache->email_id.init(cx, "email") ||
!atomsCache->approved_clients_id.init(cx, "approved_clients")) {
return false;
}
return true;
}
bool
IdentityProviderAccount::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());
IdentityProviderAccountAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<IdentityProviderAccountAtoms>(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->approved_clients_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mApproved_clients.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>("'approved_clients' member of IdentityProviderAccount", "sequence");
return false;
}
Sequence<nsString> &arr = (mApproved_clients.Value());
JS::Rooted<JS::Value> temp(cx);
while (true) {
bool done;
if (!iter.next(&temp, &done)) {
return false;
}
if (done) {
break;
}
nsString* slotPtr = arr.AppendElement(mozilla::fallible);
if (!slotPtr) {
JS_ReportOutOfMemory(cx);
return false;
}
nsString& slot = *slotPtr;
if (!ConvertJSValueToString(cx, temp, eStringify, eStringify, slot)) {
return false;
}
if (!NormalizeUSVString(slot)) {
JS_ReportOutOfMemory(cx);
return false;
}
}
} else {
cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'approved_clients' member of IdentityProviderAccount", "sequence");
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->email_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mEmail)) {
return false;
}
if (!NormalizeUSVString(mEmail)) {
JS_ReportOutOfMemory(cx);
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>("'email' member of IdentityProviderAccount");
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->given_name_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mGiven_name.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mGiven_name.Value()))) {
return false;
}
if (!NormalizeUSVString((mGiven_name.Value()))) {
JS_ReportOutOfMemory(cx);
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->id_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mId)) {
return false;
}
if (!NormalizeUSVString(mId)) {
JS_ReportOutOfMemory(cx);
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>("'id' member of IdentityProviderAccount");
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->name_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mName)) {
return false;
}
if (!NormalizeUSVString(mName)) {
JS_ReportOutOfMemory(cx);
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>("'name' member of IdentityProviderAccount");
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->picture_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mPicture.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mPicture.Value()))) {
return false;
}
if (!NormalizeUSVString((mPicture.Value()))) {
JS_ReportOutOfMemory(cx);
return false;
}
mIsAnyMemberPresent = true;
}
return true;
}
bool
IdentityProviderAccount::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
IdentityProviderAccount::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
IdentityProviderAccountAtoms* atomsCache = GetAtomCache<IdentityProviderAccountAtoms>(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 (mApproved_clients.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
Sequence<nsString> const & currentValue = mApproved_clients.InternalValue();
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 (!xpc::NonVoidStringToJsval(cx, currentValue[sequenceIdx0], &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->approved_clients_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 = mEmail;
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->email_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
if (mGiven_name.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mGiven_name.InternalValue();
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->given_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);
nsString const & currentValue = mId;
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->id_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);
if (mPicture.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mPicture.InternalValue();
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->picture_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
return true;
}
void
IdentityProviderAccount::TraceDictionary(JSTracer* trc)
{
}
IdentityProviderAccount&
IdentityProviderAccount::operator=(const IdentityProviderAccount& aOther)
{
DictionaryBase::operator=(aOther);
mApproved_clients.Reset();
if (aOther.mApproved_clients.WasPassed()) {
mApproved_clients.Construct(aOther.mApproved_clients.Value());
}
mEmail = aOther.mEmail;
mGiven_name.Reset();
if (aOther.mGiven_name.WasPassed()) {
mGiven_name.Construct(aOther.mGiven_name.Value());
}
mId = aOther.mId;
mName = aOther.mName;
mPicture.Reset();
if (aOther.mPicture.WasPassed()) {
mPicture.Construct(aOther.mPicture.Value());
}
return *this;
}
IdentityProviderClientMetadata::IdentityProviderClientMetadata()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
IdentityProviderClientMetadata::InitIds(JSContext* cx, IdentityProviderClientMetadataAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->terms_of_service_url_id.init(cx, "terms_of_service_url") ||
!atomsCache->privacy_policy_url_id.init(cx, "privacy_policy_url")) {
return false;
}
return true;
}
bool
IdentityProviderClientMetadata::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());
IdentityProviderClientMetadataAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<IdentityProviderClientMetadataAtoms>(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->privacy_policy_url_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mPrivacy_policy_url.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mPrivacy_policy_url.Value()))) {
return false;
}
if (!NormalizeUSVString((mPrivacy_policy_url.Value()))) {
JS_ReportOutOfMemory(cx);
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->terms_of_service_url_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mTerms_of_service_url.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mTerms_of_service_url.Value()))) {
return false;
}
if (!NormalizeUSVString((mTerms_of_service_url.Value()))) {
JS_ReportOutOfMemory(cx);
return false;
}
mIsAnyMemberPresent = true;
}
return true;
}
bool
IdentityProviderClientMetadata::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
IdentityProviderClientMetadata::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
IdentityProviderClientMetadataAtoms* atomsCache = GetAtomCache<IdentityProviderClientMetadataAtoms>(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 (mPrivacy_policy_url.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mPrivacy_policy_url.InternalValue();
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->privacy_policy_url_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mTerms_of_service_url.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mTerms_of_service_url.InternalValue();
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->terms_of_service_url_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
return true;
}
void
IdentityProviderClientMetadata::TraceDictionary(JSTracer* trc)
{
}
IdentityProviderClientMetadata&
IdentityProviderClientMetadata::operator=(const IdentityProviderClientMetadata& aOther)
{
DictionaryBase::operator=(aOther);
mPrivacy_policy_url.Reset();
if (aOther.mPrivacy_policy_url.WasPassed()) {
mPrivacy_policy_url.Construct(aOther.mPrivacy_policy_url.Value());
}
mTerms_of_service_url.Reset();
if (aOther.mTerms_of_service_url.WasPassed()) {
mTerms_of_service_url.Construct(aOther.mTerms_of_service_url.Value());
}
return *this;
}
bool
IdentityProviderClientMetadata::operator==(const IdentityProviderClientMetadata& aOther) const
{
if (mPrivacy_policy_url != aOther.mPrivacy_policy_url) {
return false;
}
if (mTerms_of_service_url != aOther.mTerms_of_service_url) {
return false;
}
return true;
}
IdentityProviderConfig::IdentityProviderConfig()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
IdentityProviderConfig::InitIds(JSContext* cx, IdentityProviderConfigAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->nonce_id.init(cx, "nonce") ||
!atomsCache->configURL_id.init(cx, "configURL") ||
!atomsCache->clientId_id.init(cx, "clientId")) {
return false;
}
return true;
}
bool
IdentityProviderConfig::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());
IdentityProviderConfigAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<IdentityProviderConfigAtoms>(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->clientId_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mClientId)) {
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>("'clientId' member of IdentityProviderConfig");
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->configURL_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mConfigURL)) {
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>("'configURL' member of IdentityProviderConfig");
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->nonce_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mNonce.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mNonce.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
return true;
}
bool
IdentityProviderConfig::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
IdentityProviderConfig::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
IdentityProviderConfigAtoms* atomsCache = GetAtomCache<IdentityProviderConfigAtoms>(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);
nsCString const & currentValue = mClientId;
if (!NonVoidUTF8StringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->clientId_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 = mConfigURL;
if (!NonVoidUTF8StringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->configURL_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
if (mNonce.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsCString const & currentValue = mNonce.InternalValue();
if (!NonVoidUTF8StringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->nonce_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
return true;
}
void
IdentityProviderConfig::TraceDictionary(JSTracer* trc)
{
}
IdentityProviderConfig&
IdentityProviderConfig::operator=(const IdentityProviderConfig& aOther)
{
DictionaryBase::operator=(aOther);
mClientId = aOther.mClientId;
mConfigURL = aOther.mConfigURL;
mNonce.Reset();
if (aOther.mNonce.WasPassed()) {
mNonce.Construct(aOther.mNonce.Value());
}
return *this;
}
bool
IdentityProviderConfig::operator==(const IdentityProviderConfig& aOther) const
{
if (mClientId != aOther.mClientId) {
return false;
}
if (mConfigURL != aOther.mConfigURL) {
return false;
}
if (mNonce != aOther.mNonce) {
return false;
}
return true;
}
IdentityProviderIcon::IdentityProviderIcon()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
IdentityProviderIcon::InitIds(JSContext* cx, IdentityProviderIconAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->url_id.init(cx, "url") ||
!atomsCache->size_id.init(cx, "size")) {
return false;
}
return true;
}
bool
IdentityProviderIcon::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());
IdentityProviderIconAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<IdentityProviderIconAtoms>(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->size_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mSize.Construct();
if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp.ref(), "'size' member of IdentityProviderIcon", &(mSize.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->url_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mUrl)) {
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>("'url' member of IdentityProviderIcon");
}
return true;
}
bool
IdentityProviderIcon::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
IdentityProviderIcon::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
IdentityProviderIconAtoms* atomsCache = GetAtomCache<IdentityProviderIconAtoms>(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 (mSize.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
uint32_t const & currentValue = mSize.InternalValue();
temp.setNumber(currentValue);
if (!JS_DefinePropertyById(cx, obj, atomsCache->size_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 = mUrl;
if (!NonVoidUTF8StringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->url_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
return true;
}
void
IdentityProviderIcon::TraceDictionary(JSTracer* trc)
{
}
IdentityProviderIcon&
IdentityProviderIcon::operator=(const IdentityProviderIcon& aOther)
{
DictionaryBase::operator=(aOther);
mSize.Reset();
if (aOther.mSize.WasPassed()) {
mSize.Construct(aOther.mSize.Value());
}
mUrl = aOther.mUrl;
return *this;
}
bool
IdentityProviderIcon::operator==(const IdentityProviderIcon& aOther) const
{
if (mSize != aOther.mSize) {
return false;
}
if (mUrl != aOther.mUrl) {
return false;
}
return true;
}
IdentityProviderToken::IdentityProviderToken()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
IdentityProviderToken::InitIds(JSContext* cx, IdentityProviderTokenAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->token_id.init(cx, "token")) {
return false;
}
return true;
}
bool
IdentityProviderToken::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());
IdentityProviderTokenAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<IdentityProviderTokenAtoms>(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->token_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mToken)) {
return false;
}
if (!NormalizeUSVString(mToken)) {
JS_ReportOutOfMemory(cx);
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>("'token' member of IdentityProviderToken");
}
return true;
}
bool
IdentityProviderToken::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
IdentityProviderToken::TraceDictionary(JSTracer* trc)
{
}
IdentityProviderToken&
IdentityProviderToken::operator=(const IdentityProviderToken& aOther)
{
DictionaryBase::operator=(aOther);
mToken = aOther.mToken;
return *this;
}
bool
IdentityProviderToken::operator==(const IdentityProviderToken& aOther) const
{
if (mToken != aOther.mToken) {
return false;
}
return true;
}
IdentityProviderWellKnown::IdentityProviderWellKnown()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
IdentityProviderWellKnown::InitIds(JSContext* cx, IdentityProviderWellKnownAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->provider_urls_id.init(cx, "provider_urls")) {
return false;
}
return true;
}
bool
IdentityProviderWellKnown::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());
IdentityProviderWellKnownAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<IdentityProviderWellKnownAtoms>(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->provider_urls_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
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>("'provider_urls' member of IdentityProviderWellKnown", "sequence");
return false;
}
Sequence<nsCString> &arr = mProvider_urls;
JS::Rooted<JS::Value> temp(cx);
while (true) {
bool done;
if (!iter.next(&temp, &done)) {
return false;
}
if (done) {
break;
}
nsCString* slotPtr = arr.AppendElement(mozilla::fallible);
if (!slotPtr) {
JS_ReportOutOfMemory(cx);
return false;
}
nsCString& slot = *slotPtr;
if (!ConvertJSValueToString(cx, temp, eStringify, eStringify, slot)) {
return false;
}
}
} else {
cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'provider_urls' member of IdentityProviderWellKnown", "sequence");
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>("'provider_urls' member of IdentityProviderWellKnown");
}
return true;
}
bool
IdentityProviderWellKnown::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
IdentityProviderWellKnown::TraceDictionary(JSTracer* trc)
{
}
IdentityProviderWellKnown&
IdentityProviderWellKnown::operator=(const IdentityProviderWellKnown& aOther)
{
DictionaryBase::operator=(aOther);
mProvider_urls = aOther.mProvider_urls;
return *this;
}
IdentityCredentialRequestOptions::IdentityCredentialRequestOptions()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
IdentityCredentialRequestOptions::InitIds(JSContext* cx, IdentityCredentialRequestOptionsAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->providers_id.init(cx, "providers")) {
return false;
}
return true;
}
bool
IdentityCredentialRequestOptions::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());
IdentityCredentialRequestOptionsAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<IdentityCredentialRequestOptionsAtoms>(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->providers_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mProviders.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>("'providers' member of IdentityCredentialRequestOptions", "sequence");
return false;
}
Sequence<IdentityProviderConfig> &arr = (mProviders.Value());
JS::Rooted<JS::Value> temp(cx);
while (true) {
bool done;
if (!iter.next(&temp, &done)) {
return false;
}
if (done) {
break;
}
IdentityProviderConfig* slotPtr = arr.AppendElement(mozilla::fallible);
if (!slotPtr) {
JS_ReportOutOfMemory(cx);
return false;
}
IdentityProviderConfig& slot = *slotPtr;
if (!slot.Init(cx, temp, "Element of 'providers' member of IdentityCredentialRequestOptions", passedToJSImpl)) {
return false;
}
}
} else {
cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'providers' member of IdentityCredentialRequestOptions", "sequence");
return false;
}
mIsAnyMemberPresent = true;
}
return true;
}
bool
IdentityCredentialRequestOptions::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
IdentityCredentialRequestOptions::TraceDictionary(JSTracer* trc)
{
}
IdentityCredentialRequestOptions&
IdentityCredentialRequestOptions::operator=(const IdentityCredentialRequestOptions& aOther)
{
DictionaryBase::operator=(aOther);
mProviders.Reset();
if (aOther.mProviders.WasPassed()) {
mProviders.Construct(aOther.mProviders.Value());
}
return *this;
}
IdentityProviderAccountList::IdentityProviderAccountList()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
IdentityProviderAccountList::InitIds(JSContext* cx, IdentityProviderAccountListAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->accounts_id.init(cx, "accounts")) {
return false;
}
return true;
}
bool
IdentityProviderAccountList::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());
IdentityProviderAccountListAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<IdentityProviderAccountListAtoms>(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->accounts_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mAccounts.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>("'accounts' member of IdentityProviderAccountList", "sequence");
return false;
}
Sequence<IdentityProviderAccount> &arr = (mAccounts.Value());
JS::Rooted<JS::Value> temp(cx);
while (true) {
bool done;
if (!iter.next(&temp, &done)) {
return false;
}
if (done) {
break;
}
IdentityProviderAccount* slotPtr = arr.AppendElement(mozilla::fallible);
if (!slotPtr) {
JS_ReportOutOfMemory(cx);
return false;
}
IdentityProviderAccount& slot = *slotPtr;
if (!slot.Init(cx, temp, "Element of 'accounts' member of IdentityProviderAccountList", passedToJSImpl)) {
return false;
}
}
} else {
cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'accounts' member of IdentityProviderAccountList", "sequence");
return false;
}
mIsAnyMemberPresent = true;
}
return true;
}
bool
IdentityProviderAccountList::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
IdentityProviderAccountList::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
IdentityProviderAccountListAtoms* atomsCache = GetAtomCache<IdentityProviderAccountListAtoms>(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 (mAccounts.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
Sequence<IdentityProviderAccount> const & currentValue = mAccounts.InternalValue();
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->accounts_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
return true;
}
void
IdentityProviderAccountList::TraceDictionary(JSTracer* trc)
{
}
IdentityProviderAccountList&
IdentityProviderAccountList::operator=(const IdentityProviderAccountList& aOther)
{
DictionaryBase::operator=(aOther);
mAccounts.Reset();
if (aOther.mAccounts.WasPassed()) {
mAccounts.Construct(aOther.mAccounts.Value());
}
return *this;
}
IdentityProviderBranding::IdentityProviderBranding()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
IdentityProviderBranding::InitIds(JSContext* cx, IdentityProviderBrandingAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->name_id.init(cx, "name") ||
!atomsCache->icons_id.init(cx, "icons") ||
!atomsCache->color_id.init(cx, "color") ||
!atomsCache->background_color_id.init(cx, "background_color")) {
return false;
}
return true;
}
bool
IdentityProviderBranding::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());
IdentityProviderBrandingAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<IdentityProviderBrandingAtoms>(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->background_color_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mBackground_color.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mBackground_color.Value()))) {
return false;
}
if (!NormalizeUSVString((mBackground_color.Value()))) {
JS_ReportOutOfMemory(cx);
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->color_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mColor.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mColor.Value()))) {
return false;
}
if (!NormalizeUSVString((mColor.Value()))) {
JS_ReportOutOfMemory(cx);
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->icons_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mIcons.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>("'icons' member of IdentityProviderBranding", "sequence");
return false;
}
Sequence<IdentityProviderIcon> &arr = (mIcons.Value());
JS::Rooted<JS::Value> temp(cx);
while (true) {
bool done;
if (!iter.next(&temp, &done)) {
return false;
}
if (done) {
break;
}
IdentityProviderIcon* slotPtr = arr.AppendElement(mozilla::fallible);
if (!slotPtr) {
JS_ReportOutOfMemory(cx);
return false;
}
IdentityProviderIcon& slot = *slotPtr;
if (!slot.Init(cx, temp, "Element of 'icons' member of IdentityProviderBranding", passedToJSImpl)) {
return false;
}
}
} else {
cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'icons' member of IdentityProviderBranding", "sequence");
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->name_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mName.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mName.Value()))) {
return false;
}
if (!NormalizeUSVString((mName.Value()))) {
JS_ReportOutOfMemory(cx);
return false;
}
mIsAnyMemberPresent = true;
}
return true;
}
bool
IdentityProviderBranding::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
IdentityProviderBranding::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
IdentityProviderBrandingAtoms* atomsCache = GetAtomCache<IdentityProviderBrandingAtoms>(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 (mBackground_color.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mBackground_color.InternalValue();
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->background_color_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mColor.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mColor.InternalValue();
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->color_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mIcons.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
Sequence<IdentityProviderIcon> const & currentValue = mIcons.InternalValue();
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->icons_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mName.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mName.InternalValue();
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->name_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
return true;
}
void
IdentityProviderBranding::TraceDictionary(JSTracer* trc)
{
}
IdentityProviderBranding&
IdentityProviderBranding::operator=(const IdentityProviderBranding& aOther)
{
DictionaryBase::operator=(aOther);
mBackground_color.Reset();
if (aOther.mBackground_color.WasPassed()) {
mBackground_color.Construct(aOther.mBackground_color.Value());
}
mColor.Reset();
if (aOther.mColor.WasPassed()) {
mColor.Construct(aOther.mColor.Value());
}
mIcons.Reset();
if (aOther.mIcons.WasPassed()) {
mIcons.Construct(aOther.mIcons.Value());
}
mName.Reset();
if (aOther.mName.WasPassed()) {
mName.Construct(aOther.mName.Value());
}
return *this;
}
IdentityProviderAPIConfig::IdentityProviderAPIConfig()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
IdentityProviderAPIConfig::InitIds(JSContext* cx, IdentityProviderAPIConfigAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->id_assertion_endpoint_id.init(cx, "id_assertion_endpoint") ||
!atomsCache->client_metadata_endpoint_id.init(cx, "client_metadata_endpoint") ||
!atomsCache->branding_id.init(cx, "branding") ||
!atomsCache->accounts_endpoint_id.init(cx, "accounts_endpoint")) {
return false;
}
return true;
}
bool
IdentityProviderAPIConfig::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());
IdentityProviderAPIConfigAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<IdentityProviderAPIConfigAtoms>(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->accounts_endpoint_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mAccounts_endpoint)) {
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>("'accounts_endpoint' member of IdentityProviderAPIConfig");
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->branding_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mBranding.Construct();
if (!(mBranding.Value()).Init(cx, temp.ref(), "'branding' member of IdentityProviderAPIConfig", passedToJSImpl)) {
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->client_metadata_endpoint_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mClient_metadata_endpoint)) {
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>("'client_metadata_endpoint' member of IdentityProviderAPIConfig");
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->id_assertion_endpoint_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mId_assertion_endpoint)) {
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>("'id_assertion_endpoint' member of IdentityProviderAPIConfig");
}
return true;
}
bool
IdentityProviderAPIConfig::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
IdentityProviderAPIConfig::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
IdentityProviderAPIConfigAtoms* atomsCache = GetAtomCache<IdentityProviderAPIConfigAtoms>(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);
nsCString const & currentValue = mAccounts_endpoint;
if (!NonVoidUTF8StringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->accounts_endpoint_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
if (mBranding.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
IdentityProviderBranding const & currentValue = mBranding.InternalValue();
if (!currentValue.ToObjectInternal(cx, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->branding_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 = mClient_metadata_endpoint;
if (!NonVoidUTF8StringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->client_metadata_endpoint_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 = mId_assertion_endpoint;
if (!NonVoidUTF8StringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->id_assertion_endpoint_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
return true;
}
void
IdentityProviderAPIConfig::TraceDictionary(JSTracer* trc)
{
}
IdentityProviderAPIConfig&
IdentityProviderAPIConfig::operator=(const IdentityProviderAPIConfig& aOther)
{
DictionaryBase::operator=(aOther);
mAccounts_endpoint = aOther.mAccounts_endpoint;
mBranding.Reset();
if (aOther.mBranding.WasPassed()) {
mBranding.Construct(aOther.mBranding.Value());
}
mClient_metadata_endpoint = aOther.mClient_metadata_endpoint;
mId_assertion_endpoint = aOther.mId_assertion_endpoint;
return *this;
}
namespace IdentityCredential_Binding {
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<Credential_Binding::NativeType>::value,
"Can't inherit from an interface with a different ownership model.");
MOZ_CAN_RUN_SCRIPT static bool
get_token(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitGetterCallArgs args)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"IdentityCredential", "token", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::IdentityCredential*>(void_self);
DOMString result;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(MOZ_KnownLive(self)->GetToken(result))>, "Should be returning void here");
MOZ_KnownLive(self)->GetToken(result);
MOZ_ASSERT(!JS_IsExceptionPending(cx));
if (!xpc::StringToJsval(cx, result, args.rval())) {
return false;
}
return true;
}
static const JSJitInfo token_getterinfo = {
{ get_token },
{ prototypes::id::IdentityCredential },
{ PrototypeTraits<prototypes::id::IdentityCredential>::Depth },
JSJitInfo::Getter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
false, /* isInfallible. False in setters. */
false, /* isMovable. Not relevant for setters. */
false, /* isEliminatable. Not relevant for setters. */
false, /* isAlwaysInSlot. Only relevant for getters. */
false, /* isLazilyCachedInSlot. Only relevant for getters. */
false, /* isTypedMethod. Only relevant for methods. */
0 /* Reserved slot index, if we're stored in a slot, else 0. */
};
MOZ_CAN_RUN_SCRIPT static bool
logoutRPs(JSContext* cx_, unsigned argc, JS::Value* vp)
{
BindingCallContext cx(cx_, "IdentityCredential.logoutRPs");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"IdentityCredential", "logoutRPs", 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, "IdentityCredential.logoutRPs", 1)) {
return false;
}
GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
if (global.Failed()) {
return false;
}
binding_detail::AutoSequence<IdentityCredentialLogoutRPsRequest> 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<IdentityCredentialLogoutRPsRequest> &arr = arg0;
JS::Rooted<JS::Value> temp(cx);
while (true) {
bool done;
if (!iter.next(&temp, &done)) {
return false;
}
if (done) {
break;
}
IdentityCredentialLogoutRPsRequest* slotPtr = arr.AppendElement(mozilla::fallible);
if (!slotPtr) {
JS_ReportOutOfMemory(cx);
return false;
}
IdentityCredentialLogoutRPsRequest& slot = *slotPtr;
if (!slot.Init(cx, temp, "Element of argument 1", false)) {
return false;
}
}
} else {
cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("Argument 1", "sequence");
return false;
}
FastErrorResult rv;
auto result(StrongOrRawPtr<Promise>(mozilla::dom::IdentityCredential::LogoutRPs(global, Constify(arg0), rv)));
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "IdentityCredential.logoutRPs"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
if (!ToJSValue(cx, result, args.rval())) {
return false;
}
return true;
}
static const JSJitInfo logoutRPs_methodinfo = {
{ (JSJitGetterOp)logoutRPs },
{ prototypes::id::_ID_Count }, { 0 }, JSJitInfo::StaticMethod,
JSJitInfo::AliasEverything, JSVAL_TYPE_OBJECT, false, false,
false, false, 0
};
static bool
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
{
mozilla::dom::IdentityCredential* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IdentityCredential>(obj);
// We don't want to preserve if we don't have a wrapper, and we
// obviously can't preserve if we're not initialized.
if (self && self->GetWrapperPreserveColor()) {
PreserveWrapper(self);
}
return true;
}
static void
_finalize(JS::GCContext* gcx, JSObject* obj)
{
mozilla::dom::IdentityCredential* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IdentityCredential>(obj);
if (self) {
JS::SetReservedSlot(obj, DOM_OBJECT_SLOT, JS::UndefinedValue());
ClearWrapper(self, self, obj);
if (size_t mallocBytes = BindingJSObjectMallocBytes(self)) {
JS::RemoveAssociatedMemory(obj, mallocBytes,
JS::MemoryUse::DOMBinding);
}
AddForDeferredFinalization<mozilla::dom::IdentityCredential>(self);
}
}
static nsWrapperCache*
_getWrapperCache(JS::Handle<JSObject*> obj)
{
mozilla::dom::IdentityCredential* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IdentityCredential>(obj);
return self;
}
static size_t
_objectMoved(JSObject* obj, JSObject* old)
{
mozilla::dom::IdentityCredential* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IdentityCredential>(obj);
if (self) {
UpdateWrapper(self, self, obj, old);
}
return 0;
}
static const JSFunctionSpec sStaticMethods_specs[] = {
JS_FNSPEC("logoutRPs", StaticMethodPromiseWrapper, &logoutRPs_methodinfo, 1, JSPROP_ENUMERATE, nullptr),
JS_FS_END
};
static const PrefableDisablers sStaticMethods_disablers0 = {
WebIDLPrefIndex::NoPref, 0, true, OriginTrial(0), nullptr
};
static const Prefable<const JSFunctionSpec> sStaticMethods[] = {
{ &sStaticMethods_disablers0, &sStaticMethods_specs[0] },
{ nullptr, nullptr }
};
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
"We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
"We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
static const JSPropertySpec sAttributes_specs[] = {
JSPropertySpec::nativeAccessors("token", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &token_getterinfo, nullptr, nullptr),
JS_PS_END
};
static const PrefableDisablers sAttributes_disablers0 = {
WebIDLPrefIndex::NoPref, 0, true, OriginTrial(0), nullptr
};
static const Prefable<const JSPropertySpec> sAttributes[] = {
{ &sAttributes_disablers0, &sAttributes_specs[0] },
{ nullptr, nullptr }
};
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
"We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
"We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
static uint16_t sNativeProperties_sortedPropertyIndices[2];
static PropertyInfo sNativeProperties_propertyInfos[2];
static const NativePropertiesN<2> sNativeProperties = {
true, 0 /* sStaticMethods */,
false, 0,
false, 0,
true, 1 /* sAttributes */,
false, 0,
false, 0,
false, 0,
-1,
2,
sNativeProperties_sortedPropertyIndices,
{
{ sStaticMethods, &sNativeProperties_propertyInfos[0] },
{ sAttributes, &sNativeProperties_propertyInfos[1] }
}
};
static_assert(2 < 1ull << (CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount)),
"We have a property info count that is oversized");
bool sNativePropertiesInited = false;
const NativePropertyHooks sNativePropertyHooks = {
nullptr,
{ sNativeProperties.Upcast(), nullptr, &sNativePropertiesInited },
prototypes::id::IdentityCredential,
constructors::id::IdentityCredential,
&DefaultXrayExpandoObjectClass
};
static const DOMInterfaceInfo sInterfaceObjectInfo = {
{ ThrowingConstructor, &sNativePropertyHooks },
Credential_Binding::GetConstructorObject,
prototypes::id::IdentityCredential,
PrototypeTraits<prototypes::id::IdentityCredential>::Depth,
true,
};
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
{
"IdentityCredentialPrototype",
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::IdentityCredential,
PrototypeTraits<prototypes::id::IdentityCredential>::Depth,
&sNativePropertyHooks,
Credential_Binding::GetProtoObject
};
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
{
return StaticPrefs::dom_security_credentialmanagement_identity_enabled() &&
mozilla::dom::IsSecureContextOrObjectIsFromSecureContext(aCx, aObj);
}
static const JSClassOps sClassOps = {
_addProperty, /* addProperty */
nullptr, /* delProperty */
nullptr, /* enumerate */
nullptr, /* newEnumerate */
nullptr, /* resolve */
nullptr, /* mayResolve */
_finalize, /* finalize */
nullptr, /* call */
nullptr, /* construct */
nullptr, /* trace */
};
static const js::ClassExtension sClassExtension = {
_objectMoved /* objectMovedOp */
};
static const DOMJSClass sClass = {
{ "IdentityCredential",
JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
&sClassOps,
JS_NULL_CLASS_SPEC,
&sClassExtension,
JS_NULL_OBJECT_OPS
},
{ prototypes::id::Credential, prototypes::id::IdentityCredential, 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::IdentityCredential>,
&sNativePropertyHooks,
FindAssociatedGlobalForNative<mozilla::dom::IdentityCredential>::Get,
GetProtoObjectHandle,
GetCCParticipant<mozilla::dom::IdentityCredential>::Get(),
nullptr,
_getWrapperCache
};
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::IdentityCredential* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
{
static_assert(!std::is_base_of_v<NonRefcountedDOMObject, mozilla::dom::IdentityCredential>,
"Shouldn't have wrappercached things that are not refcounted.");
static_assert(std::is_same_v<decltype(aObject), mozilla::dom::IdentityCredential*>);
MOZ_ASSERT(static_cast<mozilla::dom::Credential*>(aObject) ==
reinterpret_cast<mozilla::dom::Credential*>(aObject),
"Multiple inheritance for mozilla::dom::Credential is broken.");
MOZ_ASSERT(ToSupportsIsCorrect(aObject));
MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
MOZ_ASSERT(!aCache->GetWrapper(),
"You should probably not be using Wrap() directly; use "
"GetOrCreateDOMReflector instead");
MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
"nsISupports must be on our primary inheritance chain");
// If the wrapper cache contains a dead reflector then finalize that
// now, ensuring that the finalizer for the old reflector always
// runs before the new reflector is created and attached. This
// avoids the awkward situation where there are multiple reflector
// objects that contain pointers to the same native.
if (JSObject* oldReflector = aCache->GetWrapperMaybeDead()) {
_finalize(nullptr /* unused */, oldReflector);
MOZ_ASSERT(!aCache->GetWrapperMaybeDead());
}
JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
if (!global) {
return false;
}
MOZ_ASSERT(JS_IsGlobalObject(global));
JS::AssertObjectIsNotGray(global);
// That might have ended up wrapping us already, due to the wonders
// of XBL. Check for that, and bail out as needed.
aReflector.set(aCache->GetWrapper());
if (aReflector) {
#ifdef DEBUG
AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
#endif // DEBUG
return true;
}
JSAutoRealm ar(aCx, global);
JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
if (!canonicalProto) {
return false;
}
JS::Rooted<JSObject*> proto(aCx);
if (aGivenProto) {
proto = aGivenProto;
// Unfortunately, while aGivenProto was in the compartment of aCx
// coming in, we changed compartments to that of "parent" so may need
// to wrap the proto here.
if (js::GetContextCompartment(aCx) != JS::GetCompartment(proto)) {
if (!JS_WrapObject(aCx, &proto)) {
return false;
}
}
} else {
proto = canonicalProto;
}
BindingJSObjectCreator<mozilla::dom::IdentityCredential> creator(aCx);
creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
if (!aReflector) {
return false;
}
aCache->SetWrapper(aReflector);
creator.InitializationSucceeded();
MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
aCache->GetWrapperPreserveColor() == aReflector);
// If proto != canonicalProto, we have to preserve our wrapper;
// otherwise we won't be able to properly recreate it later, since
// we won't know what proto to use. Note that we don't check
// aGivenProto here, since it's entirely possible (and even
// somewhat common) to have a non-null aGivenProto which is the
// same as canonicalProto.
if (proto != canonicalProto) {
PreserveWrapper(aObject);
}
return true;
}
void
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
{
JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::IdentityCredential);
JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::IdentityCredential);
JS::Handle<JSObject*> parentProto(Credential_Binding::GetProtoObjectHandle(aCx));
if (!parentProto) {
return;
}
JS::Handle<JSObject*> constructorProto(Credential_Binding::GetConstructorObjectHandle(aCx));
if (!constructorProto) {
return;
}
dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
&sPrototypeClass, protoCache,
constructorProto, &sInterfaceObjectInfo, 0, false, Span<const LegacyFactoryFunction, 0>{},
interfaceCache,
sNativeProperties.Upcast(),
nullptr,
"IdentityCredential", aDefineOnGlobal,
nullptr,
false,
nullptr);
}
JSObject*
GetConstructorObject(JSContext* aCx)
{
return GetConstructorObjectHandle(aCx);
}
} // namespace IdentityCredential_Binding
} // namespace mozilla::dom