/* THIS FILE IS AUTOGENERATED FROM FailedCertSecurityInfo.webidl BY Codegen.py - DO NOT EDIT */ #include #include "AtomList.h" #include "FailedCertSecurityInfoBinding.h" #include "MainThreadUtils.h" #include "js/Array.h" #include "js/CallAndConstruct.h" #include "js/Exception.h" #include "js/ForOfIterator.h" #include "js/MapAndSet.h" #include "js/Object.h" #include "js/PropertyAndElement.h" #include "js/PropertyDescriptor.h" #include "js/experimental/JitInfo.h" #include "jsapi.h" #include "mozilla/OwningNonNull.h" #include "mozilla/dom/BindingCallContext.h" #include "mozilla/dom/BindingUtils.h" #include "mozilla/dom/NonRefcountedDOMObject.h" #include "mozilla/dom/PrimitiveConversions.h" #include "mozilla/dom/ScriptSettings.h" #include "mozilla/dom/SimpleGlobalObject.h" namespace mozilla { namespace dom { namespace binding_detail {}; // Just to make sure it's known as a namespace using namespace mozilla::dom::binding_detail; namespace binding_detail { constexpr nsLiteralCString EnumStrings::Values[4]; } // namespace binding_detail bool ToJSValue(JSContext* aCx, OverridableErrorCategory aArgument, JS::MutableHandle aValue) { MOZ_ASSERT(uint32_t(aArgument) < std::size(binding_detail::EnumStrings::Values)); JSString* resultStr = JS_NewStringCopyN(aCx, binding_detail::EnumStrings::Values[uint32_t(aArgument)].BeginReading(), binding_detail::EnumStrings::Values[uint32_t(aArgument)].Length()); if (!resultStr) { return false; } aValue.setString(resultStr); return true; } FailedCertSecurityInfo::FailedCertSecurityInfo() { // Safe to pass a null context if we pass a null value Init(); } bool FailedCertSecurityInfo::InitIds(JSContext* cx, FailedCertSecurityInfoAtoms* atomsCache) { MOZ_ASSERT(reinterpret_cast(atomsCache)->isVoid()); // Initialize these in reverse order so that any failure leaves the first one // uninitialized. if (!atomsCache->validNotBefore_id.init(cx, "validNotBefore") || !atomsCache->validNotAfter_id.init(cx, "validNotAfter") || !atomsCache->overridableErrorCategory_id.init(cx, "overridableErrorCategory") || !atomsCache->issuerCommonName_id.init(cx, "issuerCommonName") || !atomsCache->hasHSTS_id.init(cx, "hasHSTS") || !atomsCache->hasHPKP_id.init(cx, "hasHPKP") || !atomsCache->errorMessage_id.init(cx, "errorMessage") || !atomsCache->errorIsOverridable_id.init(cx, "errorIsOverridable") || !atomsCache->errorCodeString_id.init(cx, "errorCodeString") || !atomsCache->channelStatus_id.init(cx, "channelStatus") || !atomsCache->certValidityRangeNotBefore_id.init(cx, "certValidityRangeNotBefore") || !atomsCache->certValidityRangeNotAfter_id.init(cx, "certValidityRangeNotAfter") || !atomsCache->certChainStrings_id.init(cx, "certChainStrings")) { return false; } return true; } bool FailedCertSecurityInfo::Init(const char* sourceDescription, bool passedToJSImpl) { { // scope for any temporaries our default value setting needs. mCertValidityRangeNotAfter = 0ULL; } { // scope for any temporaries our default value setting needs. mCertValidityRangeNotBefore = 0ULL; } { // scope for any temporaries our default value setting needs. mChannelStatus = 0U; } { // scope for any temporaries our default value setting needs. mErrorCodeString.AssignLiteral(u""); } { // scope for any temporaries our default value setting needs. mErrorIsOverridable = false; } { // scope for any temporaries our default value setting needs. mErrorMessage.AssignLiteral(u""); } { // scope for any temporaries our default value setting needs. mHasHPKP = true; } { // scope for any temporaries our default value setting needs. mHasHSTS = true; } { // scope for any temporaries our default value setting needs. mIssuerCommonName.AssignLiteral(u""); } { // scope for any temporaries our default value setting needs. mOverridableErrorCategory = OverridableErrorCategory::Unset; } { // scope for any temporaries our default value setting needs. mValidNotAfter = 0ULL; } { // scope for any temporaries our default value setting needs. mValidNotBefore = 0ULL; } return true; } bool FailedCertSecurityInfo::ToObjectInternal(JSContext* cx, JS::MutableHandle rval) const { FailedCertSecurityInfoAtoms* atomsCache = GetAtomCache(cx); if (reinterpret_cast(atomsCache)->isVoid() && !InitIds(cx, atomsCache)) { return false; } JS::Rooted obj(cx, JS_NewPlainObject(cx)); if (!obj) { return false; } rval.setObject(*obj); if (mCertChainStrings.WasPassed()) { do { // block for our 'break' successCode and scope for 'temp' and 'currentValue' JS::Rooted temp(cx); Sequence const & currentValue = mCertChainStrings.InternalValue(); uint32_t length = currentValue.Length(); JS::Rooted returnArray(cx, JS::NewArrayObject(cx, length)); if (!returnArray) { return false; } // Scope for 'tmp' { JS::Rooted 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->certChainStrings_id, temp, JSPROP_ENUMERATE)) { return false; } break; } while(false); } do { // block for our 'break' successCode and scope for 'temp' and 'currentValue' JS::Rooted temp(cx); uint64_t const & currentValue = mCertValidityRangeNotAfter; temp.set(JS::NumberValue(double(currentValue))); if (!JS_DefinePropertyById(cx, obj, atomsCache->certValidityRangeNotAfter_id, temp, JSPROP_ENUMERATE)) { return false; } break; } while(false); do { // block for our 'break' successCode and scope for 'temp' and 'currentValue' JS::Rooted temp(cx); uint64_t const & currentValue = mCertValidityRangeNotBefore; temp.set(JS::NumberValue(double(currentValue))); if (!JS_DefinePropertyById(cx, obj, atomsCache->certValidityRangeNotBefore_id, temp, JSPROP_ENUMERATE)) { return false; } break; } while(false); do { // block for our 'break' successCode and scope for 'temp' and 'currentValue' JS::Rooted temp(cx); uint32_t const & currentValue = mChannelStatus; temp.setNumber(currentValue); if (!JS_DefinePropertyById(cx, obj, atomsCache->channelStatus_id, temp, JSPROP_ENUMERATE)) { return false; } break; } while(false); do { // block for our 'break' successCode and scope for 'temp' and 'currentValue' JS::Rooted temp(cx); nsString const & currentValue = mErrorCodeString; if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { return false; } if (!JS_DefinePropertyById(cx, obj, atomsCache->errorCodeString_id, temp, JSPROP_ENUMERATE)) { return false; } break; } while(false); do { // block for our 'break' successCode and scope for 'temp' and 'currentValue' JS::Rooted temp(cx); bool const & currentValue = mErrorIsOverridable; temp.setBoolean(currentValue); if (!JS_DefinePropertyById(cx, obj, atomsCache->errorIsOverridable_id, temp, JSPROP_ENUMERATE)) { return false; } break; } while(false); do { // block for our 'break' successCode and scope for 'temp' and 'currentValue' JS::Rooted temp(cx); nsString const & currentValue = mErrorMessage; if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { return false; } if (!JS_DefinePropertyById(cx, obj, atomsCache->errorMessage_id, temp, JSPROP_ENUMERATE)) { return false; } break; } while(false); do { // block for our 'break' successCode and scope for 'temp' and 'currentValue' JS::Rooted temp(cx); bool const & currentValue = mHasHPKP; temp.setBoolean(currentValue); if (!JS_DefinePropertyById(cx, obj, atomsCache->hasHPKP_id, temp, JSPROP_ENUMERATE)) { return false; } break; } while(false); do { // block for our 'break' successCode and scope for 'temp' and 'currentValue' JS::Rooted temp(cx); bool const & currentValue = mHasHSTS; temp.setBoolean(currentValue); if (!JS_DefinePropertyById(cx, obj, atomsCache->hasHSTS_id, temp, JSPROP_ENUMERATE)) { return false; } break; } while(false); do { // block for our 'break' successCode and scope for 'temp' and 'currentValue' JS::Rooted temp(cx); nsString const & currentValue = mIssuerCommonName; if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { return false; } if (!JS_DefinePropertyById(cx, obj, atomsCache->issuerCommonName_id, temp, JSPROP_ENUMERATE)) { return false; } break; } while(false); do { // block for our 'break' successCode and scope for 'temp' and 'currentValue' JS::Rooted temp(cx); OverridableErrorCategory const & currentValue = mOverridableErrorCategory; if (!ToJSValue(cx, currentValue, &temp)) { return false; } if (!JS_DefinePropertyById(cx, obj, atomsCache->overridableErrorCategory_id, temp, JSPROP_ENUMERATE)) { return false; } break; } while(false); do { // block for our 'break' successCode and scope for 'temp' and 'currentValue' JS::Rooted temp(cx); uint64_t const & currentValue = mValidNotAfter; temp.set(JS::NumberValue(double(currentValue))); if (!JS_DefinePropertyById(cx, obj, atomsCache->validNotAfter_id, temp, JSPROP_ENUMERATE)) { return false; } break; } while(false); do { // block for our 'break' successCode and scope for 'temp' and 'currentValue' JS::Rooted temp(cx); uint64_t const & currentValue = mValidNotBefore; temp.set(JS::NumberValue(double(currentValue))); if (!JS_DefinePropertyById(cx, obj, atomsCache->validNotBefore_id, temp, JSPROP_ENUMERATE)) { return false; } break; } while(false); return true; } void FailedCertSecurityInfo::TraceDictionary(JSTracer* trc) { } FailedCertSecurityInfo& FailedCertSecurityInfo::operator=(const FailedCertSecurityInfo& aOther) { DictionaryBase::operator=(aOther); mCertChainStrings.Reset(); if (aOther.mCertChainStrings.WasPassed()) { mCertChainStrings.Construct(aOther.mCertChainStrings.Value()); } mCertValidityRangeNotAfter = aOther.mCertValidityRangeNotAfter; mCertValidityRangeNotBefore = aOther.mCertValidityRangeNotBefore; mChannelStatus = aOther.mChannelStatus; mErrorCodeString = aOther.mErrorCodeString; mErrorIsOverridable = aOther.mErrorIsOverridable; mErrorMessage = aOther.mErrorMessage; mHasHPKP = aOther.mHasHPKP; mHasHSTS = aOther.mHasHSTS; mIssuerCommonName = aOther.mIssuerCommonName; mOverridableErrorCategory = aOther.mOverridableErrorCategory; mValidNotAfter = aOther.mValidNotAfter; mValidNotBefore = aOther.mValidNotBefore; return *this; } } // namespace dom } // namespace mozilla