Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM RTCIdentityProvider.webidl BY Codegen.py - DO NOT EDIT */
#include <type_traits>
#include "AtomList.h"
#include "MainThreadUtils.h"
#include "RTCIdentityProviderBinding.h"
#include "WrapperFactory.h"
#include "js/CallAndConstruct.h"
#include "js/Exception.h"
#include "js/MapAndSet.h"
#include "js/Object.h"
#include "js/PropertyAndElement.h"
#include "js/PropertyDescriptor.h"
#include "js/experimental/JitInfo.h"
#include "mozilla/Atomics.h"
#include "mozilla/OwningNonNull.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/dom/BindingCallContext.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/DOMJSClass.h"
#include "mozilla/dom/NonRefcountedDOMObject.h"
#include "mozilla/dom/PrimitiveConversions.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/RTCIdentityProviderRegistrar.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/SimpleGlobalObject.h"
#include "mozilla/dom/ToJSValue.h"
#include "mozilla/dom/XrayExpandoClass.h"
#include "nsContentUtils.h"
namespace mozilla::dom {
namespace binding_detail {}; // Just to make sure it's known as a namespace
using namespace mozilla::dom::binding_detail;
MOZ_CAN_RUN_SCRIPT already_AddRefed<Promise>
GenerateAssertionCallback::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, const nsAString& contents, const nsAString& origin, const RTCIdentityProviderOptions& options, ErrorResult& aRv)
{
JS::Rooted<JS::Value> rval(cx);
JS::RootedVector<JS::Value> argv(cx);
if (!argv.resize(3)) {
// That threw an exception on the JSContext, and our CallSetup will do
// the right thing with that.
return nullptr;
}
unsigned argc = 3;
do {
if (!options.ToObjectInternal(cx, argv[2])) {
// Convert exception to a rejected promise.
// step 10 and step 15.5.
return CreateRejectedPromiseFromThrownException(cx, aRv);
}
break;
} while (false);
do {
if (!xpc::NonVoidStringToJsval(cx, origin, argv[1])) {
// Convert exception to a rejected promise.
// step 10 and step 15.5.
return CreateRejectedPromiseFromThrownException(cx, aRv);
}
break;
} while (false);
do {
if (!xpc::NonVoidStringToJsval(cx, contents, argv[0])) {
// Convert exception to a rejected promise.
// step 10 and step 15.5.
return CreateRejectedPromiseFromThrownException(cx, aRv);
}
break;
} while (false);
JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
if (!JS::Call(cx, aThisVal, callable,
JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
// Convert exception to a rejected promise.
// step 12 and step 15.5.
return CreateRejectedPromiseFromThrownException(cx, aRv);
}
RefPtr<Promise> rvalDecl;
{ // Scope for our GlobalObject, FastErrorResult, JSAutoRealm,
// etc.
JS::Rooted<JSObject*> globalObj(cx);
// We basically want our entry global here. Play it safe
// and use GetEntryGlobal() to get it, with whatever
// principal-clamping it ends up doing.
globalObj = GetEntryGlobal()->GetGlobalJSObject();
JSAutoRealm ar(cx, globalObj);
GlobalObject promiseGlobal(cx, globalObj);
if (promiseGlobal.Failed()) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
JS::Rooted<JS::Value> valueToResolve(cx, rval);
if (!JS_WrapValue(cx, &valueToResolve)) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
binding_detail::FastErrorResult promiseRv;
nsCOMPtr<nsIGlobalObject> global =
do_QueryInterface(promiseGlobal.GetAsSupports());
if (!global) {
promiseRv.Throw(NS_ERROR_UNEXPECTED);
MOZ_ALWAYS_TRUE(promiseRv.MaybeSetPendingException(cx));
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
rvalDecl = Promise::Resolve(global, cx, valueToResolve,
promiseRv);
if (promiseRv.MaybeSetPendingException(cx)) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
}
return rvalDecl.forget();
}
RTCIdentityProvider::RTCIdentityProvider()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
RTCIdentityProvider::InitIds(JSContext* cx, RTCIdentityProviderAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->validateAssertion_id.init(cx, "validateAssertion") ||
!atomsCache->generateAssertion_id.init(cx, "generateAssertion")) {
return false;
}
return true;
}
bool
RTCIdentityProvider::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());
RTCIdentityProviderAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<RTCIdentityProviderAtoms>(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->generateAssertion_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (temp.ref().isObject()) {
if (JS::IsCallable(&temp.ref().toObject())) {
{ // scope for tempRoot and tempGlobalRoot if needed
JS::Rooted<JSObject*> tempRoot(cx, &temp.ref().toObject());
JS::Rooted<JSObject*> tempGlobalRoot(cx, JS::CurrentGlobalOrNull(cx));
mGenerateAssertion = new GenerateAssertionCallback(cx, tempRoot, tempGlobalRoot, GetIncumbentGlobal());
}
} else {
cx.ThrowErrorMessage<MSG_NOT_CALLABLE>("'generateAssertion' member of RTCIdentityProvider");
return false;
}
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("'generateAssertion' member of RTCIdentityProvider");
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>("'generateAssertion' member of RTCIdentityProvider");
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->validateAssertion_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (temp.ref().isObject()) {
if (JS::IsCallable(&temp.ref().toObject())) {
{ // scope for tempRoot and tempGlobalRoot if needed
JS::Rooted<JSObject*> tempRoot(cx, &temp.ref().toObject());
JS::Rooted<JSObject*> tempGlobalRoot(cx, JS::CurrentGlobalOrNull(cx));
mValidateAssertion = new ValidateAssertionCallback(cx, tempRoot, tempGlobalRoot, GetIncumbentGlobal());
}
} else {
cx.ThrowErrorMessage<MSG_NOT_CALLABLE>("'validateAssertion' member of RTCIdentityProvider");
return false;
}
} else {
cx.ThrowErrorMessage<MSG_NOT_OBJECT>("'validateAssertion' member of RTCIdentityProvider");
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>("'validateAssertion' member of RTCIdentityProvider");
}
return true;
}
bool
RTCIdentityProvider::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
RTCIdentityProvider::TraceDictionary(JSTracer* trc)
{
}
RTCIdentityProviderDetails::RTCIdentityProviderDetails()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
RTCIdentityProviderDetails::InitIds(JSContext* cx, RTCIdentityProviderDetailsAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->protocol_id.init(cx, "protocol") ||
!atomsCache->domain_id.init(cx, "domain")) {
return false;
}
return true;
}
bool
RTCIdentityProviderDetails::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());
RTCIdentityProviderDetailsAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<RTCIdentityProviderDetailsAtoms>(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->domain_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mDomain)) {
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>("'domain' member of RTCIdentityProviderDetails");
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->protocol_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mProtocol)) {
return false;
}
} else {
mProtocol.AssignLiteral(u"default");
}
mIsAnyMemberPresent = true;
return true;
}
bool
RTCIdentityProviderDetails::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
RTCIdentityProviderDetails::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
RTCIdentityProviderDetailsAtoms* atomsCache = GetAtomCache<RTCIdentityProviderDetailsAtoms>(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 = mDomain;
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->domain_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 = mProtocol;
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->protocol_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
return true;
}
void
RTCIdentityProviderDetails::TraceDictionary(JSTracer* trc)
{
}
RTCIdentityProviderDetails&
RTCIdentityProviderDetails::operator=(const RTCIdentityProviderDetails& aOther)
{
DictionaryBase::operator=(aOther);
mDomain = aOther.mDomain;
mProtocol = aOther.mProtocol;
return *this;
}
bool
RTCIdentityProviderDetails::operator==(const RTCIdentityProviderDetails& aOther) const
{
if (mDomain != aOther.mDomain) {
return false;
}
if (mProtocol != aOther.mProtocol) {
return false;
}
return true;
}
RTCIdentityProviderOptions::RTCIdentityProviderOptions()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
RTCIdentityProviderOptions::InitIds(JSContext* cx, RTCIdentityProviderOptionsAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->usernameHint_id.init(cx, "usernameHint") ||
!atomsCache->protocol_id.init(cx, "protocol") ||
!atomsCache->peerIdentity_id.init(cx, "peerIdentity")) {
return false;
}
return true;
}
bool
RTCIdentityProviderOptions::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());
RTCIdentityProviderOptionsAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<RTCIdentityProviderOptionsAtoms>(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->peerIdentity_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mPeerIdentity.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mPeerIdentity.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->protocol_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mProtocol)) {
return false;
}
} else {
mProtocol.AssignLiteral(u"default");
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->usernameHint_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mUsernameHint.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mUsernameHint.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
return true;
}
bool
RTCIdentityProviderOptions::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
RTCIdentityProviderOptions::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
RTCIdentityProviderOptionsAtoms* atomsCache = GetAtomCache<RTCIdentityProviderOptionsAtoms>(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 (mPeerIdentity.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mPeerIdentity.InternalValue();
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->peerIdentity_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 = mProtocol;
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->protocol_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
if (mUsernameHint.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mUsernameHint.InternalValue();
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->usernameHint_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
return true;
}
void
RTCIdentityProviderOptions::TraceDictionary(JSTracer* trc)
{
}
RTCIdentityProviderOptions&
RTCIdentityProviderOptions::operator=(const RTCIdentityProviderOptions& aOther)
{
DictionaryBase::operator=(aOther);
mPeerIdentity.Reset();
if (aOther.mPeerIdentity.WasPassed()) {
mPeerIdentity.Construct(aOther.mPeerIdentity.Value());
}
mProtocol = aOther.mProtocol;
mUsernameHint.Reset();
if (aOther.mUsernameHint.WasPassed()) {
mUsernameHint.Construct(aOther.mUsernameHint.Value());
}
return *this;
}
bool
RTCIdentityProviderOptions::operator==(const RTCIdentityProviderOptions& aOther) const
{
if (mPeerIdentity != aOther.mPeerIdentity) {
return false;
}
if (mProtocol != aOther.mProtocol) {
return false;
}
if (mUsernameHint != aOther.mUsernameHint) {
return false;
}
return true;
}
RTCIdentityValidationResult::RTCIdentityValidationResult()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
RTCIdentityValidationResult::InitIds(JSContext* cx, RTCIdentityValidationResultAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->identity_id.init(cx, "identity") ||
!atomsCache->contents_id.init(cx, "contents")) {
return false;
}
return true;
}
bool
RTCIdentityValidationResult::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());
RTCIdentityValidationResultAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<RTCIdentityValidationResultAtoms>(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->contents_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mContents)) {
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>("'contents' member of RTCIdentityValidationResult");
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->identity_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mIdentity)) {
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>("'identity' member of RTCIdentityValidationResult");
}
return true;
}
bool
RTCIdentityValidationResult::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
RTCIdentityValidationResult::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
RTCIdentityValidationResultAtoms* atomsCache = GetAtomCache<RTCIdentityValidationResultAtoms>(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 = mContents;
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->contents_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 = mIdentity;
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->identity_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
return true;
}
void
RTCIdentityValidationResult::TraceDictionary(JSTracer* trc)
{
}
RTCIdentityValidationResult&
RTCIdentityValidationResult::operator=(const RTCIdentityValidationResult& aOther)
{
DictionaryBase::operator=(aOther);
mContents = aOther.mContents;
mIdentity = aOther.mIdentity;
return *this;
}
bool
RTCIdentityValidationResult::operator==(const RTCIdentityValidationResult& aOther) const
{
if (mContents != aOther.mContents) {
return false;
}
if (mIdentity != aOther.mIdentity) {
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT already_AddRefed<Promise>
ValidateAssertionCallback::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, const nsAString& assertion, const nsAString& origin, ErrorResult& aRv)
{
JS::Rooted<JS::Value> rval(cx);
JS::RootedVector<JS::Value> argv(cx);
if (!argv.resize(2)) {
// That threw an exception on the JSContext, and our CallSetup will do
// the right thing with that.
return nullptr;
}
unsigned argc = 2;
do {
if (!xpc::NonVoidStringToJsval(cx, origin, argv[1])) {
// Convert exception to a rejected promise.
// step 10 and step 15.5.
return CreateRejectedPromiseFromThrownException(cx, aRv);
}
break;
} while (false);
do {
if (!xpc::NonVoidStringToJsval(cx, assertion, argv[0])) {
// Convert exception to a rejected promise.
// step 10 and step 15.5.
return CreateRejectedPromiseFromThrownException(cx, aRv);
}
break;
} while (false);
JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
if (!JS::Call(cx, aThisVal, callable,
JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
// Convert exception to a rejected promise.
// step 12 and step 15.5.
return CreateRejectedPromiseFromThrownException(cx, aRv);
}
RefPtr<Promise> rvalDecl;
{ // Scope for our GlobalObject, FastErrorResult, JSAutoRealm,
// etc.
JS::Rooted<JSObject*> globalObj(cx);
// We basically want our entry global here. Play it safe
// and use GetEntryGlobal() to get it, with whatever
// principal-clamping it ends up doing.
globalObj = GetEntryGlobal()->GetGlobalJSObject();
JSAutoRealm ar(cx, globalObj);
GlobalObject promiseGlobal(cx, globalObj);
if (promiseGlobal.Failed()) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
JS::Rooted<JS::Value> valueToResolve(cx, rval);
if (!JS_WrapValue(cx, &valueToResolve)) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
binding_detail::FastErrorResult promiseRv;
nsCOMPtr<nsIGlobalObject> global =
do_QueryInterface(promiseGlobal.GetAsSupports());
if (!global) {
promiseRv.Throw(NS_ERROR_UNEXPECTED);
MOZ_ALWAYS_TRUE(promiseRv.MaybeSetPendingException(cx));
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
rvalDecl = Promise::Resolve(global, cx, valueToResolve,
promiseRv);
if (promiseRv.MaybeSetPendingException(cx)) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
}
return rvalDecl.forget();
}
RTCIdentityAssertionResult::RTCIdentityAssertionResult()
: mIdp(FastDictionaryInitializer())
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
RTCIdentityAssertionResult::InitIds(JSContext* cx, RTCIdentityAssertionResultAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->idp_id.init(cx, "idp") ||
!atomsCache->assertion_id.init(cx, "assertion")) {
return false;
}
return true;
}
bool
RTCIdentityAssertionResult::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());
RTCIdentityAssertionResultAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<RTCIdentityAssertionResultAtoms>(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->assertion_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mAssertion)) {
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>("'assertion' member of RTCIdentityAssertionResult");
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->idp_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!mIdp.Init(cx, temp.ref(), "'idp' member of RTCIdentityAssertionResult", passedToJSImpl)) {
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>("'idp' member of RTCIdentityAssertionResult");
}
return true;
}
bool
RTCIdentityAssertionResult::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
RTCIdentityAssertionResult::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
RTCIdentityAssertionResultAtoms* atomsCache = GetAtomCache<RTCIdentityAssertionResultAtoms>(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 = mAssertion;
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->assertion_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);
RTCIdentityProviderDetails const & currentValue = mIdp;
if (!currentValue.ToObjectInternal(cx, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->idp_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
return true;
}
void
RTCIdentityAssertionResult::TraceDictionary(JSTracer* trc)
{
}
RTCIdentityAssertionResult&
RTCIdentityAssertionResult::operator=(const RTCIdentityAssertionResult& aOther)
{
DictionaryBase::operator=(aOther);
mAssertion = aOther.mAssertion;
mIdp = aOther.mIdp;
return *this;
}
namespace RTCIdentityProviderRegistrar_Binding {
MOZ_CAN_RUN_SCRIPT static bool
_register_(JSContext* cx_, JS::Handle<JSObject*> obj, void* void_self, const JSJitMethodCallArgs& args)
{
BindingCallContext cx(cx_, "RTCIdentityProviderRegistrar.register");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"RTCIdentityProviderRegistrar", "register", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::RTCIdentityProviderRegistrar*>(void_self);
if (!args.requireAtLeast(cx, "RTCIdentityProviderRegistrar.register", 1)) {
return false;
}
binding_detail::FastRTCIdentityProvider arg0;
if (!arg0.Init(cx, args[0], "Argument 1", false)) {
return false;
}
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(MOZ_KnownLive(self)->Register(Constify(arg0)))>, "Should be returning void here");
MOZ_KnownLive(self)->Register(Constify(arg0));
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setUndefined();
return true;
}
static const JSJitInfo register_methodinfo = {
{ (JSJitGetterOp)_register_ },
{ prototypes::id::RTCIdentityProviderRegistrar },
{ PrototypeTraits<prototypes::id::RTCIdentityProviderRegistrar>::Depth },
JSJitInfo::Method,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
false, /* isInfallible. False in setters. */
false, /* isMovable. Not relevant for setters. */
false, /* isEliminatable. Not relevant for setters. */
false, /* isAlwaysInSlot. Only relevant for getters. */
false, /* isLazilyCachedInSlot. Only relevant for getters. */
false, /* isTypedMethod. Only relevant for methods. */
0 /* Reserved slot index, if we're stored in a slot, else 0. */
};
MOZ_CAN_RUN_SCRIPT static bool
get_hasIdp(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, JSJitGetterCallArgs args)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"RTCIdentityProviderRegistrar", "hasIdp", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::RTCIdentityProviderRegistrar*>(void_self);
bool result(MOZ_KnownLive(self)->HasIdp());
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setBoolean(result);
return true;
}
static const JSJitInfo hasIdp_getterinfo = {
{ get_hasIdp },
{ prototypes::id::RTCIdentityProviderRegistrar },
{ PrototypeTraits<prototypes::id::RTCIdentityProviderRegistrar>::Depth },
JSJitInfo::Getter,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
true, /* isInfallible. False in setters. */
false, /* isMovable. Not relevant for setters. */
false, /* isEliminatable. Not relevant for setters. */
false, /* isAlwaysInSlot. Only relevant for getters. */
false, /* isLazilyCachedInSlot. Only relevant for getters. */
false, /* isTypedMethod. Only relevant for methods. */
0 /* Reserved slot index, if we're stored in a slot, else 0. */
};
MOZ_CAN_RUN_SCRIPT static bool
generateAssertion(JSContext* cx_, JS::Handle<JSObject*> obj, void* void_self, const JSJitMethodCallArgs& args)
{
BindingCallContext cx(cx_, "RTCIdentityProviderRegistrar.generateAssertion");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"RTCIdentityProviderRegistrar", "generateAssertion", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::RTCIdentityProviderRegistrar*>(void_self);
if (!args.requireAtLeast(cx, "RTCIdentityProviderRegistrar.generateAssertion", 2)) {
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;
}
binding_detail::FastRTCIdentityProviderOptions arg2;
if (!arg2.Init(cx, (args.hasDefined(2)) ? args[2] : JS::NullHandleValue, "Argument 3", false)) {
return false;
}
FastErrorResult rv;
auto result(StrongOrRawPtr<Promise>(MOZ_KnownLive(self)->GenerateAssertion(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), Constify(arg2), rv)));
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "RTCIdentityProviderRegistrar.generateAssertion"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
if (!ToJSValue(cx, result, args.rval())) {
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
generateAssertion_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, const JSJitMethodCallArgs& args)
{
bool ok = generateAssertion(cx, obj, void_self, args);
if (ok) {
return true;
}
return ConvertExceptionToPromise(cx, args.rval());
}
static const JSJitInfo generateAssertion_methodinfo = {
{ (JSJitGetterOp)generateAssertion_promiseWrapper },
{ prototypes::id::RTCIdentityProviderRegistrar },
{ PrototypeTraits<prototypes::id::RTCIdentityProviderRegistrar>::Depth },
JSJitInfo::Method,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
false, /* isInfallible. False in setters. */
false, /* isMovable. Not relevant for setters. */
false, /* isEliminatable. Not relevant for setters. */
false, /* isAlwaysInSlot. Only relevant for getters. */
false, /* isLazilyCachedInSlot. Only relevant for getters. */
false, /* isTypedMethod. Only relevant for methods. */
0 /* Reserved slot index, if we're stored in a slot, else 0. */
};
MOZ_CAN_RUN_SCRIPT static bool
validateAssertion(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, const JSJitMethodCallArgs& args)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"RTCIdentityProviderRegistrar", "validateAssertion", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::RTCIdentityProviderRegistrar*>(void_self);
if (!args.requireAtLeast(cx, "RTCIdentityProviderRegistrar.validateAssertion", 2)) {
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;
}
FastErrorResult rv;
auto result(StrongOrRawPtr<Promise>(MOZ_KnownLive(self)->ValidateAssertion(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), rv)));
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "RTCIdentityProviderRegistrar.validateAssertion"))) {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
if (!ToJSValue(cx, result, args.rval())) {
return false;
}
return true;
}
MOZ_CAN_RUN_SCRIPT static bool
validateAssertion_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, const JSJitMethodCallArgs& args)
{
bool ok = validateAssertion(cx, obj, void_self, args);
if (ok) {
return true;
}
return ConvertExceptionToPromise(cx, args.rval());
}
static const JSJitInfo validateAssertion_methodinfo = {
{ (JSJitGetterOp)validateAssertion_promiseWrapper },
{ prototypes::id::RTCIdentityProviderRegistrar },
{ PrototypeTraits<prototypes::id::RTCIdentityProviderRegistrar>::Depth },
JSJitInfo::Method,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
false, /* isInfallible. False in setters. */
false, /* isMovable. Not relevant for setters. */
false, /* isEliminatable. Not relevant for setters. */
false, /* isAlwaysInSlot. Only relevant for getters. */
false, /* isLazilyCachedInSlot. Only relevant for getters. */
false, /* isTypedMethod. Only relevant for methods. */
0 /* Reserved slot index, if we're stored in a slot, else 0. */
};
static bool
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
{
mozilla::dom::RTCIdentityProviderRegistrar* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::RTCIdentityProviderRegistrar>(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::RTCIdentityProviderRegistrar* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::RTCIdentityProviderRegistrar>(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::RTCIdentityProviderRegistrar>(self);
}
}
static nsWrapperCache*
_getWrapperCache(JS::Handle<JSObject*> obj)
{
mozilla::dom::RTCIdentityProviderRegistrar* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::RTCIdentityProviderRegistrar>(obj);
return self;
}
static size_t
_objectMoved(JSObject* obj, JSObject* old)
{
mozilla::dom::RTCIdentityProviderRegistrar* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::RTCIdentityProviderRegistrar>(obj);
if (self) {
UpdateWrapper(self, self, obj, old);
}
return 0;
}
static const JSFunctionSpec sMethods_specs[] = {
JS_FNSPEC("register", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&register_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
JS_FS_END
};
static const Prefable<const JSFunctionSpec> sMethods[] = {
{ nullptr, &sMethods_specs[0] },
{ nullptr, nullptr }
};
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
"We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
"We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
static const JSFunctionSpec sChromeMethods_specs[] = {
JS_FNSPEC("generateAssertion", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&generateAssertion_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("validateAssertion", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&validateAssertion_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
JS_FS_END
};
static const Prefable<const JSFunctionSpec> sChromeMethods[] = {
{ nullptr, &sChromeMethods_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 const JSPropertySpec sChromeAttributes_specs[] = {
JSPropertySpec::nativeAccessors("hasIdp", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &hasIdp_getterinfo, nullptr, nullptr),
JS_PS_END
};
static const Prefable<const JSPropertySpec> sChromeAttributes[] = {
{ nullptr, &sChromeAttributes_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[1];
static PropertyInfo sNativeProperties_propertyInfos[1];
static const NativePropertiesN<1> sNativeProperties = {
false, 0,
false, 0,
true, 0 /* sMethods */,
false, 0,
false, 0,
false, 0,
false, 0,
-1,
1,
sNativeProperties_sortedPropertyIndices,
{
{ sMethods, &sNativeProperties_propertyInfos[0] }
}
};
static_assert(1 < 1ull << (CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount)),
"We have a property info count that is oversized");
static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[3];
static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[3];
static const NativePropertiesN<2> sChromeOnlyNativeProperties = {
false, 0,
false, 0,
true, 0 /* sChromeMethods */,
true, 1 /* sChromeAttributes */,
false, 0,
false, 0,
false, 0,
-1,
3,
sChromeOnlyNativeProperties_sortedPropertyIndices,
{
{ sChromeMethods, &sChromeOnlyNativeProperties_propertyInfos[0] },
{ sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[2] }
}
};
static_assert(3 < 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::RTCIdentityProviderRegistrar,
constructors::id::_ID_Count,
&DefaultXrayExpandoObjectClass
};
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
{
"RTCIdentityProviderRegistrarPrototype",
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::RTCIdentityProviderRegistrar,
PrototypeTraits<prototypes::id::RTCIdentityProviderRegistrar>::Depth,
&sNativePropertyHooks,
JS::GetRealmObjectPrototype
};
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 = {
{ "RTCIdentityProviderRegistrar",
JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
&sClassOps,
JS_NULL_CLASS_SPEC,
&sClassExtension,
JS_NULL_OBJECT_OPS
},
{ prototypes::id::RTCIdentityProviderRegistrar, 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::RTCIdentityProviderRegistrar>,
&sNativePropertyHooks,
FindAssociatedGlobalForNative<mozilla::dom::RTCIdentityProviderRegistrar>::Get,
GetProtoObjectHandle,
GetCCParticipant<mozilla::dom::RTCIdentityProviderRegistrar>::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::RTCIdentityProviderRegistrar* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
{
static_assert(!std::is_base_of_v<NonRefcountedDOMObject, mozilla::dom::RTCIdentityProviderRegistrar>,
"Shouldn't have wrappercached things that are not refcounted.");
static_assert(std::is_same_v<decltype(aObject), mozilla::dom::RTCIdentityProviderRegistrar*>);
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::RTCIdentityProviderRegistrar> 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::RTCIdentityProviderRegistrar);
JS::Heap<JSObject*>* interfaceCache = nullptr;
JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
if (!parentProto) {
return;
}
dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
&sPrototypeClass, protoCache,
nullptr, nullptr, 0, false, Span<const LegacyFactoryFunction, 0>{},
interfaceCache,
sNativeProperties.Upcast(),
sChromeOnlyNativeProperties.Upcast(),
"RTCIdentityProviderRegistrar", aDefineOnGlobal,
nullptr,
false,
nullptr);
}
} // namespace RTCIdentityProviderRegistrar_Binding
} // namespace mozilla::dom