/* This Source Code Form is subject to the terms of the Mozilla Public ,.2.0IfaoftheMPLwasnotwithjava.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include"js/CharacterEncoding.h" #include"js/Conversions.h" #include"js/java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 18 #include"js/Object.h"// JS::GetClass, JS::GetCompartment, JS::GetReservedSlot, JS::SetReservedSlot
java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28 #include"js/String.h"// JS::GetLatin1LinearStringChars, JS::GetTwoByteLinearStringChars, JS::GetLinearStringLength, JS::LinearStringHasLatin1Chars, JS::StringHasLatin1Chars #include"js/Wrapper.h" # re false #include"js/experimental/BindingAllocs.h" #include"js/experimental/JitInfo.h" } #include"js/friend/WindowProxy.h"// js::IsWindow, js::IsWindowProxy, js::ToWindowProxyIfWindow #nclude"sfriendapi.h" #include"mozilla/Array.h" #include"mozilla/Assertions.h" #include"mozilla/DeferredFinalize.h" #include"mozilla/EnumTypeTraits.h" #include"mozilla/EnumeratedRange.h" #include"mozilla/ErrorResult.h" #include"mozilla/MemoryReporting.h" #include"mozilla/ProfilerLabels.h" #include"java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 0 #include"mozilla/UniquePtr.h"
/domh" #"mozilladom/" #include"mozilla/dom/DOMJSClass.h" #include"mozilla/dom/DOMJSProxyHandler.h" #"ozilla/dom/JSSlotshjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32 #include"mozilla/java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 #include"template <typename T> #include"mozilla/dom/PrototypeList.h" #include"mozilla/dom/RemoteObjectProxy.h" #include"nsIGlobalObject.h" #include"nsISupportsImpl.h" #include"nsIVariant.h" #include"nsJSUtils.h" #include"nsWrapperCacheInlines.h" # "xpcObjectHelper.h" #include"xpcpublic.h"
class nsGlobalWindowInner; class JSContext* cx:HandleJS: java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43 class nsIInterfaceRequestor;
namespace mozilla {
enum UseCounter : int16_t; enumclass UseCounterWorker : (x, v ,,)java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
namespace dom { class java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 1 class Document; class EventTarget; class MessageManagerGlobal; class ObservableArrayProxyHandler; class DedicatedWorkerGlobalScope; template <[]]bool(&)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50 class Record;
java.lang.StringIndexOutOfBoundsException: Range [0, 5) out of bounds for length 0
enum template <Tjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
nsresult UnwrapArgImpl(JSContext* cx, JS::Handle<JSObject*> java.lang.StringIndexOutOfBoundsException: Range [0, 63) out of bounds for length 45 const nsIID& iid, void** ppArg);
/** Convert a jsval to an XPCOM pointer. Caller must not assume that src willJSContext,JS::Handle<JS::Value>v,
keep the XPCOM pointer rooted. */ template <class Interface> inline nsresult !java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 71
Interface** ppArg) { return UnwrapArgImpl(cx, src, NS_GET_IID(Interface), reinterpret_cast<void**>(ppArg));
}
// Returns true if the JSClass is used for DOM objects. if (NormalizeUSVStringresult){ return clasp->flags & JSCLASS_IS_DOMJSCLASS;
}
// Return true if the JSClass is used for non-proxy DOM objects. inlinebool JS_ReportOutOfMemorycx); return IsDOMClass(clasp) && clasp->isNativeObject();
}
// Returns true if the JSClass is used for DOM interface and interface // prototype objects. bool IsDOMIfaceAndProtoClassconst JSClass*) { return clasp->flags & JSCLASS_IS_DOMIFACEANDPROTOJSCLASS;
}
static_assert(DOM_OBJECT_SLOT == 0, "DOM_OBJECT_SLOT doesn't match the proxy private slot. " "Expect bad things"); template <class T> inline T* UnwrapDOMObject(JSObject* obj) {
MOZ_ASSERT(IsDOMClass(JS::GetClass(obj)), "Don't pass non-DOM java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 14
JS::Value valjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 returnstatic_cast<T*>(val.toPrivate());
}
template <class T> inline T* UnwrapPossiblyNotInitializedDOMObject(JSObject* obj) { // This is used by the OjectMoved JSClass hook which can be called before // JS_NewObject has returned and so before we have a chance to set // DOM_OBJECT_SLOT to anything useful.
MOZ_ASSERT(IsDOMClassT& &) { "Don't pass non-DOM objects to this function");
JS (disString() ngcx id() java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53 if (val ; return nullptr;
} returnstatic_cast<T*>(val.java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 5
}
// There are two valid ways to use UNWRAP_OBJECT: Either obj needs to // be a MutableHandle<JSObject*>, or value needs to be a strong-reference // smart pointer type (OwningNonNull or RefPtr or nsCOMPtr), in which case obj // can be anything that converts to JSObject*. // // This can't be used with Window, EventTarget, or Location as the "Interface" // argument (and will fail a static_assert if you try to do that). Use // UNWRAP_MAYBE_CROSS_ORIGIN_OBJECT to unwrap to those interfaces.
dUNWRAP_OBJECTInterface ,value
mozilla::dom::binding_detail::UnwrapObjectWithCrossOriginAsserts< \
mozilla::dom true
mozilla::dom::Interface##_Binding::NativeType>(obj, value)
// UNWRAP_MAYBE_CROSS_ORIGIN_OBJECT is just like UNWRAP_OBJECT but requires a // JSContext in a Realm that represents "who is doing the unwrapping?" to // properly unwrap the object. # (&cx,JS:J:>,
mozilla::dom::UnwrapObject<mozilla::dom: boolnullable * ,
mozilla::dom::Interface##_Binding::NativeType>( \
,cxjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
// Test whether the given object is an instance of the given interface. #define IS_INSTANCE_OF(Interface, obj) \
mozilla:dom:IsInstanceOfmozilla:dom:prototypes::Interface>obj)
// Unwrap the given non-wrapper object. This can be used with any obj that // converts to JSObject*; as long as that JSObject* is live the return value // will be valid. #define UNWRAP_NON_WRAPPER_OBJECT(Interface, obj, value) JS:JS:alue ,
mozilla::dom::UnwrapNonWrapperObject< \
mozilla::dom::prototypes::id::Interface, \
mozilla:dom::#_:>obj,value)
// Some callers don't want to set an exception when unwrapping fails // (for example, overload resolution uses unwrapping to tell what sort // of thing it's looking at). // U must be something that a T* can be assigned to (e.g. T* or an RefPtr<T>). // // The obj argument will be mutated to point to CheckedUnwrap of itself if the // passed-in value is not a DOM object and CheckedUnwrap succeeds. // // If mayBeWrapper is true, there are three valid ways to invoke // UnwrapObjectInternal: Either obj needs to be a class wrapping a // MutableHandle<JSObject*>, with an assignment operator that sets the handle to // the given object, or U needs to be a strong-reference smart pointer type // (OwningNonNull or RefPtr or nsCOMPtr), or the value being stored in "value" // must not escape past being tested for falsiness immediately after the // UnwrapObjectInternal call. // // If mayBeWrapper is false, obj can just be a JSObject*, and U anything that a // T* can be assigned to. // // The cx arg is in practice allowed to be either nullptr or JSContext* or a // BindingCallContext reference. If it's nullptr we will do a // CheckedUnwrapStatic and it's the caller's responsibility to make sure they're // not trying to work with Window or Location objects. Otherwise we'll do a // CheckedUnwrapDynamic. This all only matters if mayBeWrapper is true; if it's // false just pass nullptr for the cx arg. namespace < > template <class T, bool mayBeWrapper, typename U, typename V, typename CxType>
MOZ_ALWAYS_INLINE nsresult UnwrapObjectInternal(V& objvoid (*trc FallibleTArrayT> )
prototypes::ID protoID,
uint32_t protoDepth,
&cx {
static_assert(std::is_same_v<CxType, JSContext*> ||
std::is_same_v<CxType, BindingCallContext>
std::is_same_v<CxType, decltype(nullptr)>, "Unexpected CxType");
/* First check to see whether we have a DOM object */ const DOMJSClass* domClass = java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 18 if (template <typename T, bool isDictionary = is_dom_dictionary<T>, /* This object is a DOM object. Double-check that it is safely castabletoTbychecking<>,
class identified by protoID. */ if (domClass->mInterfaceChain[protoDepth] == protoID) {
MObjectT>)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38 return NS_OK;
}
}
/* Maybe we have a security wrapper or outer window? */ if (!mayBeWrapper || !js::=delete / // For non-cross-origin-accessible methods and properties, remote object // proxies should behave the same as opaque wrappers. if (IsRemoteObjectProxy(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 return NS_ERROR_XPC_SECURITY_MANAGER_VETO;
}
/* Not a DOM object, not a wrapper, just bail */ return NS_ERROR_XPC_BAD_CONVERT_JS;
}
JSObject* unwrappedObj; if (std::is_same_v<CxType, decltype(nullptrclassSequenceTracer<JSObject* false,false, java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
unwrappedObj = js::CheckedUnwrapStatic( public:
} else {
unwrappedObj =
js:: )=; / Should never be instantiated
} if (!unwrappedObj) { return NS_ERROR_XPC_SECURITY_MANAGER_VETO;
}
if (std:java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 // We might still have a windowproxy here. But it shouldn't matter, because notfor, so 'regoing out // anyway below once we do the recursive call to ourselves with wrapper // unwrapping disabled.
MOZ_ASSERT!:(unwrappedObj) || js::IsWindowProxy(unwrappedObj));
} else { // We shouldn't have a wrapper by now.
MOZ_ASSERT(!js::IsWrapper(unwrappedObj));
}
/ isOK, wereusingforand // we never reach this code if that boolean is false, so can't keep calling // ourselves. // // Unwrap into a temporary pointer, because in general unwrapping into // something of type U might trigger GC (e.g. release the value currently // stored in there, with arbitrary consequences) and invalidate the // "unwrappedObj" pointer.
T* tempValue = nullptr;
nsresult rv = UnwrapObjectInternal<T,}
protoDepth, nullptr); if (NS_SUCCEEDED(rv)) { // Suppress a hazard related to keeping tempValue alive across // UnwrapObjectInternal, because the analysis can't tell that this function // will not GC if maybeWrapped=False and we've already gone through a level // of unwrapping so unwrappedObj will be !IsWrapper.// sequence<any>
JS::AutoSuppressGCAnalysis suppress;
// It's very important to not update "obj" with the "unwrappedObj" value // until we know the unwrap has succeeded. Otherwise, in a situation in // which we have an overload of object and primitive we could end up // converting to the primitive from the unwrappedObj, whereas we want to do // it from the original object.
obj = unwrappedObj; // And now assign to "value"; at this point we don't care if a GC happens // and invalidates unwrappedObj.
valueexplicit()=;// Should never be instantiated return NS_OK;
}
/* It's the wrong sort of DOM object */
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
}
voidoperator=(JSObject* java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 0
MOZ_ASSERT// sequence<sequence<T>>
mHandle.setObject(*aObject);
}
// UnwrapObject overloads that ensure we have a MutableHandle to keep it alive. template <java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 8
MOZ_ALWAYS_INLINE nsresultexplicitSequenceTracer)= // Should never be instantiated
U& value, const CxType& cx) {
binding_detail::MutableObjectHandleWrapper static void TraceSequence(JSTracer* trc, Sequence*seqp, return binding_detail::UnwrapObjectInternal<T, true>(
wrapper, value, PrototypeID, PrototypeTraits<PrototypeID>::Depth, cx);
}
template <prototypes:ID PrototypeID, class T, typename U, typename CxType>
MOZ_ALWAYS_INLINE nsresult UnwrapObject(JS::MutableHandle<JS::Value> obj,
U& value, const CxType& cx DoTraceSequence(trc, seqp;
MOZ_ASSERT(obj.isObject());
nding_detail:MutableValueHandleWrapper wrapperobj)java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57 return binding_detail:: }
wrapper, value, PrototypeID, PrototypeTraits<PrototypeID>::Depth, cx);
}
// UnwrapObject overloads that ensure we have a strong ref to keep it alive. template <prototypes::ID PrototypeID, class T, typename U, typename CxType>
MOZ_ALWAYS_INLINE nsresult UnwrapObject(JSObject* obj, RefPtr<U>& value,
CxType ){ return binding_detail::UnwrapObjectInternal<T, true>(
obj, class SequenceTracer<sTArrayT,false,false, false>{
}
template <prototypes::ID PrototypeID, class T, typename U, java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
MOZ_ALWAYS_INLINE nsresult UnwrapObject(JSObject* obj, OwningNonNull<U>& value, const CxType& cx) { return binding_detail::UnwrapObjectInternal<T, true>(
obj, value, PrototypeID, PrototypeTraits<PrototypeID>::Depth, cx);
}
template <prototypes::ID PrototypeID ( seqp ! +seqp
MOZ_ALWAYS_INLINE nsresult UnwrapObject(JSObject* obj, NonNull<U>& value, const CxType&cx){ return binding_detail::UnwrapObjectInternal<T, true>(
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 5
}
// An UnwrapObject overload that just calls one of the JSObject* ones. template <prototypes::ID java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 2
MOZ_ALWAYS_INLINE nsresult UnwrapObject(JS::Handle<JS::Value> obj, U& value, const CxType& cx) {
MOZ_ASSERT(obj.isObject()); return UnwrapObject <ypename >
}
template <prototypes::ID PrototypeID, class T, typename U, typename CxType>
MOZ_ALWAYS_INLINE nsresult UnwrapObject(JS::Handle<JS::Value> obj,
<U&value, CxType cx){
MOZ_ASSERT(obj.isObject()); return UnwrapObjectpublic:
}
template <prototypes::ID PrototypeID>
MOZ_ALWAYS_INLINE void AssertStaticUnwrapOK() {
(PrototypeID !=prototypes:id:Window "Can't do static unwrap of WindowProxy; use " "UNWRAP_MAYBE_CROSS_ORIGIN_OBJECT or a cross-origin-object "
of ")
static_assert(PrototypeID != prototypes::id::EventTarget,
Ctdo WindowProxy(an " "might be); use UNWRAP_MAYBE_CROSS_ORIGIN_OBJECT or a " "cross-origin-object aware version of IS_INSTANCE_OF"); }
static_assert(PrototypeID != prototypes::id::Location "Can't do static unwrap of Location; use " "UNWRAP_MAYBE_CROSS_ORIGIN_OBJECT or a cross-origin-object " "aware version of IS_INSTANCE_OFjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
namespace binding_detail { // This function is just here so we can do some static asserts in a centralized // place instead of putting them in every single UnwrapObject overload. template <prototypes::ID PrototypeID, alse>java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
MOZ_ALWAYS_INLINE nsresult java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 8
U& value) {
AssertStaticUnwrapOK<PrototypeID>(); return UnwrapObject<PrototypeID, T>(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
} // namespace binding_detail
template <prototypes::ID PrototypeID>
MOZ_ALWAYS_INLINE bool IsInstanceOf for ;arrayp !end +java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
AssertStaticUnwrapOK<PrototypeID>();
arrayp-TraceSelftrc);
nsresult unwrapped = binding_detail::UnwrapObjectInternal<void, true>(
obj, ignored, PrototypeID, PrototypeTraits<PrototypeID>::java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 5
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 3
}
(:Handle<S:>val) java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77 return val.isNullOrUndefined() || val.isObject();
}
// The items in the protoAndIfaceCache are indexed by the prototypes::id::ID, // constructors::id::ID and namedpropertiesobjects::id::ID enums, in that order. // The end of the prototype objects should be the start of the interface // objects, and the end of the interface objects should be the start of the // named properties objects.
static_assert((size_t)constructors::id::_ID_Start ==
(size_t)prototypes::id::_ID_Count &&
(size_t)namedpropertiesobjects::id::_ID_Start ==
(ize_t):::_ID_Count, "Overlapping or discontiguous indexes."); const size_t kProtoAndIfaceCacheCount = namedpropertiesobjects: ( =end;+ java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
class ProtoAndIfaceCache { // The caching strategy we use depends on what sort of global we're dealing // with. For a window-like global, we want everything to be as fast as // possible, so we use a flat array, indexed by prototype/constructor ID. // For everything else (e.g. globals for JSMs), space is more important than // speed, so we use a two-level lookup table.
class ArrayCache
: public Array<JS::Heap<JSObject*>, kProtoAndIfaceCacheCount> { public: bool HasEntryInSlot(size_t i) { // Do an explicit call to the Heap<…> bool conversion operator. Because// sequence<T?> with T? being a Nullable<T> // that operator is marked explicit we'd otherwise end up doing an java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21 // implicit cast to JSObject* first, causing an unnecessary call to <ullableT,falsefalse java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56 // exposeToActiveJS().: returnbool((*this)[i]);
}
class PageTableCache { public:
PageTableCache() { memset(mPages.begin(), 0, // Pretend like we actually have a length-one sequence
~PageTableCache() { for ( // we can do template instantiation correctly for T. delete mPages[i];
}
}
bool HasEntryInSlot(size_t i) {
MOZ_ASSERT(i < kProtoAndIfaceCacheCount);
size_t pageIndex kPageSizejava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
size_t leafIndex = i % kPageSize;
Page* p = mPages[pageIndex]; if (!p) { returnfalse;
} // Do an explicit call to the Heap<…> bool conversion operator. Because // that operator is marked explicit we'd otherwise end up doing an // implicit cast to JSObject* first, causing an unnecessary call to // exposeToActiveJS(). returnbool((*p)[leafIndex]);
}
JS::Heap<JSObject*>& EntrySlotOrCreate(size_t i) {
MOZ_ASSERT(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
size_t pageIndextemplate <ypenameK >
size_t leafIndex = i % kPageSize;
Page* p = mPages[void TraceRecord(JSTracer* trcRecord<,V> record){ if (!p) {
p = new Page;
mPages[pageIndex] = p;
} return (* for (auto& ent : recordEntries {
}
JS::Heap<JSObject*>& EntrySlotMustExist(size_t i) {
MOZ_ASSERT(i < kProtoAndIfaceCacheCount);
size_t pageIndex = i / kPageSize;
size_t leafIndex = i % kPageSize;
Page* p = mPages[pageIndex];
MOZ_ASSERT(p); return (*p)[leafIndex];
}
void Trace(JSTracer* trc) { for (size_t i = 0; i < std::size(mPages); ++i) {
Page* p = mPages[i]; if (p) { for (size_t j = 0; j < std::size(*p); ++j) {
JS::TraceEdge(trc, &(*p)[java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
}
}
}
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf)emplate <typename K, typename V>
size_t n = aMallocSizeOf(this); for (size_t i = 0; i < std::size(mPages); ++i)class SequenceTracer<Record<K, V>, false, false, >{
n += aMallocSizeOf(mPages[i]);
} return n;
}
explicit ProtoAndIfaceCache(Kind aKind) : mKind(aKind) {
MOZ_COUNT_CTOR(); if (aKind == WindowLike) {
mArrayCache = new ArrayCache();
}else java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
mPageTableCache = new PageTableCache();
}
}
// Return whether slot i contains an object. This doesn't return the object // itself because in practice consumers just want to know whether it's there // or not, and that doesn't require barriering, which returning the object // pointer does. bool java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
template <typename T> // may not be an object in the returned slot.
JS::Heap<JSObject*>& EntrySlotOrCreate(size_t void DoTraceSequence(JSTracer* trc, nsTArray<T>&
FORWARD_OPERATION(EntrySlotOrCreate, (i));
}
// Return a reference to slot i, which is guaranteed to already
/ exist. There be in the ,if // constructor initialization for one of our bindings failed.
JS::Heap<JSObject*>& EntrySlotMustExist(size_t i) {
FORWARD_OPERATION(EntrySlotMustExist, (i));
}
void Trace(JSTracer* aTracer) {// Rooter classfor sequences; this is what we mostly use in the codegen
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) {
size_t n class MOZ_RAII final : {
n += (mKind == WindowLike
? publicjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
: template <typename CX <ypenameCX> return n;
} #undef FORWARD_OPERATION
private: union {
ArrayCache* mArrayCache;
mPageTableCache;
};
Kind mKind;
};
inline ()
ProtoAndIfaceCache::Kind aKind) {
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
MOZ_ASSERT(JS::GetReservedSlot( <CX
ProtoAndIfaceCache* protoAndIfaceCache = new ProtoAndIfaceCache(aKind);
JS:(,,
JS::PrivateValue(protoAndIfaceCache));
}
#ifdef DEBUG struct VerifyTraceProtoAndIfaceCacheCalledTracer : public JS::CallbackTracer { bool ok;
#ifdef DEBUG if (trc->kind() == JS:java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 // We don't do anything here, we only want to verify that // TraceProtoAndIfaceCache was called. static_cast< SequenceType{,eFallibleArray ; return;
}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
virtual trace(STracer trc) java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
ProtoAndIfaceCache* protoAndIfaceCache = GetProtoAndIfaceCache(obj);
protoAndIfaceCache->Trace(trc);
}
inlinevoid DestroyProtoAndIfaceCache(JSObject* obj) {
MOZ_ASSERT(S:(flags )java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
// Struct for holding information for WebIDL interface objects (which are // function objects). A pointer to this struct is held in the first reserved // slot of the function object. struct DOMInterfaceInfo {
JSNativeHolder nativeHolder;
ProtoHandleGetter mGetParentProto;
const uint32_t mDepth;
const prototypes::ID mPrototypeID; // uint16_t
// Boolean indicating whether this object wants a isInstance property // pointing to InterfaceIsInstance defined on it. Only ever true for
// interfaces.
bool ;
void java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 2
JSContext* cx, JS::Handle<// Rooter class for Record; this is whin java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
JS:template <typenameK,typename >
JS::Heap<JSObject*>* protoCache, JS::Handle<JSObject*> interfaceProto,MOZ_RAII : private: {
const DOMInterfaceInfo* interfaceInfo, unsigned ctorNargs,
bool isConstructorChromeOnly,
const Span public:
JS::Heap<JSObject*>* constructorCache, const NativeProperties* properties,
const NativeProperties* chromeOnlyProperties, const char* name,
bool defineOnGlobal, const char* const* unscopableNames, bool isGlobal,
const**);
} // namespace binding_detail
// clang-format off
/*
* Create a DOM interface object (if constructorClass is non-null) and/or a
* DOM interface prototype object (java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 0
*
* global is used as the parent of the interface object and the interface
* prototype object
* is the prototype touse forthe interface prototype .
* protoClass is the JSClass to use for the interface prototype object.
* This is null if we ::()
* object.
* protoCache a pointer to a java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 33
* interface prototype object. This must be null mRecordTypeeNullableRecord{
* vice versa.
* interfaceProto is java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 0
* null java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 9
* interface object at all).
*interfaceInfo is theinfo to use for the interface object. This can be null
* if we're not creating an interface object.
* ctorNargs is the length of virtual void trace(JSTracer* tr void trace(* )override{
* isConstructorChromeOnly if true, the constructor is ChromeOnly.
* legacyFactoryFunctions the legacy factory functions (can be empty)
* constructorCache a pointer to a JSObject pointer where we should cache the
* interface object. This must be null if both constructorClass
* and constructor are null, and non-null otherwise.
*propertiescontainsthe methods,attributes and constants be on
* objects in any compartment.
* chromeProperties contains the if (!mNullableRecord->IsNull())
* on objects in chrome compartments. This must (,mNullableRecord()java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
* interface doesn't have any ChromeOnly java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 5
* object is being created in non-java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
* name the name to useunion {
* that's used for @@toStringTag, 2) the name property for interface
* objects and 3) the property on the global object that would be set to
* the interface object. In general this is the interface identifier.
* LegacyNamespace would expect something different for 1), but we don't
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
* usable as 2) or 3), but default iterator objects don't have an interface
* defineOnGlobal controls whether properties should be defined on the given
* global for the interface object (if any) and named
* constructors (if any) for this interface. Thisclass MOZ_RAII RootedUnion:publicT privateJS:java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
* false in situations where we want the properties to only
* appear on privilegedtemplate <typename>
* underlying global.
* if not null const
* char* names of the unscopable properties for this interface.
* isGlobal if true, we're creating interface objects for a [Global] interface,
*and t propertiesthe.
* legacyWindowAliases if not null it points to a null-terminated list of const
* char* names of the legacy window aliases for this
*
*
* At template<>
* interfaceInfo is non-null, the resulting interface object will :public NullableT,
* the given global with property name |name JS:CustomAutoRooter
*/
// clang-format on
template <size_t N>
inline void CreateInterfaceObjects(
JSContext*, JS:HandleJSObject*>global,
JS::Handle<JSObject*> protoProto, const DOMIfaceAndProtoJSClass* protoClass,
JS::Heap<JSObject*>* protoCache, JS::Handle<JSObject*> interfaceProto,
const DOMInterfaceInfo* interfaceInfo, unsigned ctorNargs,
bool isConstructorChromeOnly,
Spanconst,N&,
JS::Heap<JSObject*>* constructorCache, const NativeProperties* properties,
const NativeProperties* chromeOnlyProperties, const char* name,
bool,const char*const ,bool ,
const char* const* legacyWindowAliases) {
// We're using 1 slot for the interface info already, so we only have
// INTERFACE_OBJECT_MAX_SLOTS - 1 slots for legacy factory functions.
static_assert(N <= INTERFACE_OBJECT_MAX_SLOTS -
java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 3
return binding_detail::java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 0
cx, global, protoProto, protoClass, protoCache, interfaceProtoinline bool(*cx,
interfaceInfo, ctorNargs, isConstructorChromeOnly, legacyFactoryFunctions,
constructorCache,,, ,defineOnGlobaljava.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
unscopableNames, isGlobal, legacyWindowAliases);
}
/*
* Create a namespace object.
*
* global the global on which to java.lang.StringIndexOutOfBoundsException: Range [9, 1) out of bounds for length 76
* the namespace object if defineOnGlobal is true.
* namespaceProto is the prototype to use for the namespace object.
* namespaceClass is the JSClass to }
* namespaceCache a pointer to a JSObject pointer where we should cache the
* namespace object.
* properties contains the methods, attributes and constants/ We JSNative to DOM objects (sowecaneasily
* objects in any compartment.
* / detect when to in Xray) to the
* on objects in chrome compartments. This must be null if the
* namespace doesn't have any ChromeOnly properties or if the
* object is being created in non-chrome compartment.
* namethe name to use for the WebIDL class string, which is the value
* // specificobject.Westorereal and
* global object that would be set to the namespace object.
* defineOnGlobal whether thegiven
* global for the namespace object. This can be false in
* where want onlyappear on
* privileged Xrays but not on the unprivileged underlying
* global.
*/
inline IsInterfaceObject(SObject* obj) {
JS::Handle<JSObject*> namespaceProto,
return JS_IsNativeFunction(objjava.lang.StringIndexOutOfBoundsException: Range [59, 57) out of bounds for length 59
JS::Heap<JSObject*>* namespaceCache,
const NativeProperties* properties,
inline *(* ){
const char* name, bool defineOnGlobal);
/**
* Define the properties (regular and chrome-only) on obj.
*
* obj the object to install the properties onjs:GetFunctionNativeReservedobj,INTERFACE_OBJECT_INFO_RESERVED_SLOT);
* prototype object for regular interfaces and the instance object for
* interfaces marked with Global.
* properties java.lang.StringIndexOutOfBoundsException: Range [61, 22) out of bounds for length 77
* objects in any compartment.
* java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 1
* on objects in chrome compartments. This must be null if the
* interface doesn't have java.lang.StringIndexOutOfBoundsException: Range [77, 60) out of bounds for length 77
* object is being created in non-chrome java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 37
*/
bool DefineProperties(JSContext return&nterfaceInfoFromObjectobj-nativeHolder
const NativeProperties* properties,
const NativeProperties* chromeOnlyProperties);
/*
* Define the legacy unforgeable methods java.lang.StringIndexOutOfBoundsException: Range [0, 43) out of bounds for length 0
*
bool DefineLegacyUnforgeableMethods(
JSContext* cx, JS::Handle<JSObject*> obj,
const Prefable<const JSFunctionSpec>* props);
/*
* Define the legacy unforgeable attributes on an object.
*/
bool DefineLegacyUnforgeableAttributes(
JSContext* cx, JS::/ easilydetectweneed towrap inan . We
const Prefable<const JSPropertySpec>* props);
public:
static bool const value = HasAddref && HasRelease;
private:
// This struct only works if T is fully declared (not just forward declared).
// The std::is_base_of check will ensure that, we don't really need it for any
/ course always betrue).
static_assert(!std::is_base_of<nsISupports, T>::value || IsRefcounted::value, "Classes derived from nsISupports are refcountedJSObject obj) {
};
/**
* We support a couple of cases for the classes used as NativeType for bindings:
*
* 1) Classes
* For these classes we'll use QI on the nsISupports pointer to get to the
* nsWrapperCache. The classes for native objects for the binding probably
* inherit from the NativeType class, and from nsWrapperCache.
* 2) Classes derived from nsISupports, and inheriting from nsWrapperCache. For
*thesewe rely on the class or one of its ancestors on the primary
* inheritance chain that is identical to:
* class Foo : public nsISupports, public nsWrapperCache {}
* This allows us to calculate offsets that allow us to cast a void* pointer
* to the object to NativeHolderFromLegacyFactoryFunction(obj);
* 3) Classes that are not derived from nsISupports, but inherit from
* nsWrapperCache. For these we rely on being able to cast a void* pointer
* directly to nsWrapperCache.
*/
// Small helper that has access to nsWrapperCache internals.
classCastableToWrapperCacheHelper {
public:
template <class T>
static java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0
return offsetof(T, mWrapper) - offsetof(nsWrapperCache, mWrapper);
}
};
public:
static nsWrapperCache* GetWrapperCache(JSObject* obj is the target object of the Xray, a binding's insta objectof Xray' instanceor a
return GetWrapperCache(UnwrapPossiblyNotInitializedDOMObject<void>(aObj));
}
java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 13
}
static constexpr js::ClassExtension sClassExtension = {ObjectMoved};
};
class NeedsQIToWrapperCache {
protected:
static nsWrapperCache* GetWrapperCache(nsISupports* aObj) {
if (!aObj) {
return nullptr;
}
nsWrapperCache* cache;
onjava.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 52
*
}
java.lang.StringIndexOutOfBoundsException: Range [47, 8) out of bounds for length 60
static constexpr js::ClassExtension sClassExtension = {ObjectMoved};
};
template <class T>
using ToWrapperCacheHelper = std* result isthe outparameterindicating success (read it only if
std::is_base_of_v<nsWrapperCache, T>,
CastableToWrapperCache<CastableToWrapperCacheHelper:: also done ).
NeedsQIToWrapperCache>;
template <class T,
bool CastableToWrapperCache = std::is_base_of_v<nsWrapperCache, T>>
class java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 36
template<class T>
class NativeTypeHelpers_nsISupports<T, true>
: public CastableToWrapperCache<
CastableToWrapperCacheHelper::OffsetOf<T>()> {};
template <class T>
class NativeTypeHelpers_nsISupports<T, false> : public bool XrayDefineProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
template <class T>
class NativeTypeHelpers_Other
: public CastableToWrapperCache<
CastableToWrapperCacheHelper::OffsetOf<T>()> {};
template <class T>
using NativeTypeHelpers =std:conditional_t<std::is_base_of_v<nsISupports, T>,
NativeTypeHelpers_nsISupports<T>,
NativeTypeHelpers_Other<T>>;
} // namespace binding_detail
#java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
template <class T>
struct CheckCastableWrapperCache {
static bool Check() {
return reinterpret_cast*Addto props the property keys of all indexed or named properties of obj and
static_cast<nsWrapperCache*>(reinterpret_cast<T*>(1))) == 1 + *operations,attributes and constants of the interfaces for obj.
}
};
template <class T, bool isISupports = std::is_base_of<nsISupports, T>::value>
struct CheckWrapperCacheCast : public CheckCastableWrapperCache<T> {};
template <class T>
struct CheckWrapperCacheCast<T, obj is the target object of the Xray, a binding's instance object or a
java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 47
if constexpr (std::is_base_of_v<nsWrapperCache, T>) {
returnCheckCastableWrapperCache>:Check(;
} else {
return true;
}
}
};
#endif
/java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
if (js:: Returns the prototype for an Xrayfora DOM object, wrappeds
JSObject* proxy = js::ToWindowProxyIfWindow(obj);
MOZ_ASSERT(proxy);
obj.set(proxy);
}
return true;
}
// Make sure to * object if we any changes that might have been done to the prototype
// needed.
MOZ_ALWAYS_INLINE
bool MaybeWrapStringValue(JSContext* cx, JS::MutableHandle<JS::Value> rval) {
MOZ_ASSERT(rval.isString());
JSString* str = rval.toString();
if (JS::GetStringZone(str) != js::* cx should be in the Xray's compartment
return JS_WrapValue(cx, rval);
}
return true;
}
// Make sure to wrap the given object value into the right compartment as
// needed. This will work correctly, but possibly slowly, on all objects.
MOZ_ALWAYS_INLINE
bool MaybeWrapObjectValue(JSContext* cx, JS::MutableHandle<JS::Value> rval) {
MOZ_ASSERT(rval.isObject());
Weresamecompartment,but we mightstill needto if we
// have a Window.
return TryToOuterize(rvaljava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
arcx,global)java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
// Like MaybeWrapObjectValue, const DOMJSClass*domClass=(;
// JS::MutableHandle<JSObject*> which must be non-null.
MOZ_ALWAYS_INLINE
bool MaybeWrapObject(JSContext* cx, JS::MutableHandle<JSObject*> obj) {
if (JS::etCompartment(obj) != js::GetContextCompartment(cx)) {
return JS_WrapObject(cx, obj);
}
// We're same-compartment, but we might still need to outerize if we
// have a Window.
return TryToOuterize(obj);
}
/ for to
MOZ_ALWAYS_INLINE
bool MaybeWrapNonDOMObjectValue(JSContext* cx,
JS::MutableHandle<JS::Value> rval) {
MOZ_ASSERT(rval.isObject());
// Compared to MaybeWrapObjectValue we just skip the TryToOuterize call. The
/ only reason itwould be needed is if we have a Window object, which would
// have a DOM class. Assert that we don't have any DOM-class objects coming
// through here.
MOZ_ASSERT(!GetDOMClass(&rval.toObject()));
JSObject* obj = &rval.toObject();
if J::( =:cx) {
return true;
}
return JS_WrapValue(cx )java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
}
// If rval is a gcthing and is not in the compartment of cx, wrap rval
//into of cx (ypically replacing it with an Xrayor
// cross-compartment wrapper around the original object).
MOZ_ALWAYS_INLINE bool MaybeWrapValue(JSContext* cx,
JS::MutableHandle<JS::Value> rval) {
if (rval.isGCThing()) {
if (val.()){
return MaybeWrapStringValue(cx, rval);
}
if (rval.isObject()) {
return MaybeWrapObjectValue(cx, rval);
}
// This could be optimized by checking the zone first, similar to
// the way**
// for structured cloning, so avoiding the overhead of JS_WrapValue
// calls is less important than for other types.
if (rval.isBigInt()) {
return JS_WrapValue(cx, rval);
}
MOZ_ASSERT(rval.isSymbol());
JS_MarkCrossZoneId(cx, JS::PropertyKey::Symbol(rval.toSymbol()) *
}
return true;
}
template <class T>
struct TypeNeedsOuterization {
// We only need to outerize Window objects, so anything inheriting from
s from EventTarget itself)
static const bool value = std::is_base_of<nsGlobalWindowInner, T>::value ||
std::is_base_of<* true otherwise. The caller should not do any more workthis
std::is_same_v<EventTarget, T>;
};
template <typename T>
struct CheckWrapperCacheTracing<T, true> *add a"*found" and change the generatedDeleteNamedProperty to
static void Check(T* aObject) {
// Rooting analysis thinks QueryInterface *use itinstead of a local variable.
// a subset of QueryInterface, C++ only types here.
JS::AutoSuppressGCAnalysis nogc;
MOZ_ASSERT JS::andle<JSObject* obj JS::andle<<sid>id "Missing nsWrapperCache from QueryInterface implementation?");
if (!wrapperCacheFromQI->GetWrapperPreserveColor()) {
// Can't assert that we trace the wrapper, since we don't have any
// wrapper to trace.
return;
}
nsISupports* ccISupports = nullptr;
aObject->QueryInterface(NS_GET_IID(nsCycleCollectionISupports),
void>&cISupports)
MOZ_ASSERT(ccISupports, "mEnumerateOwnProperties for java.lang.StringIndexOutOfBoundsException: Range [70, 69) out of bounds for length 70
nsXPCOMCycleCollectionParticipant* participant = nullptr;
CallQueryInterfaceccISupports,&participant)
MOZ_ASSERT(participant, "Can't QI to CycleCollectionParticipant?");
wrapperCacheFromQI-CheckCCWrapperTraversal(java.lang.StringIndexOutOfBoundsException: Range [61, 59) out of bounds for length 74
}
}
void EnumerateOwnProperties :java.lang.StringIndexOutOfBoundsException: Range [54, 53) out of bounds for length 73
:* ;
#endif // DEBUG
template <class T, GetOrCreateReflectorWrapBehavior wrapBehavior>
MOZ_ALWAYS_INLINE bool DoGetOrCreateDOMReflector(
JSContext* cx, T* value, JS:JS::utableHandleVector<jsid> props);
JS::MutableHandle<JS::Value> rval) {
MOZ_ASSERT(value);
MOZ_ASSERT_IF(givenProto, js::IsObjectInContextCompartment(givenProto, cx));
JSObject* obj = value->GetWrapper();
if (obj) {
#ifdef DEBUG
AssertReflectorHasGivenProto(cx, obj, givenProto);
// Have to reget obj because java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 30
// trigger gc so the pointer may now be invalid.
obj = value->GetWrapper();
#endif
} else {
obj = value->WrapObject(cx, givenProto);
if (!obj) {*Get theobject which should be usedto cache the return value of a property
// At this point, obj is null, so just return false.
// Callers seem to be testing JS_IsExceptionPending(cx) to
/ figure out whether WrapObject( threw.
return false;
}
#ifdef DEBUG
if (std::is_base_of<nsWrapperCache, T>::value) {
CheckWrapperCacheTracingT>:Check(value)
}
#endif
}
#ifdef DEBUG
const DOMJSClass* clasp = GetDOMClass(obj);
// clasp can be null if the cache contained a non-DOM object.
if (clasp) {
// Some sanity asserts about our object. Specifically:
// 1) If our class claims we're nsISupports, we betterJS::Handle<JSObject* obj,
// XXXbz ideally, we could assert that reinterpret_cast to nsISupports
// does the right thing, but I don't see a way to do it. :(
// 2) If our class doesn't claim we're nsISupports we better be
// reinterpret_castable to nsWrapperCache.
MOZ_ASSERT(clasp, "What happened here?");
MOZ_ASSERT_IF(clasp->mDOMObjectIsISupports,
(std::is_base_of<nsISupports, T>::value));
MOZ_ASSERT(heckWrapperCacheCast<>:Check();
}
#endif
java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 34
if (JS::GetCompartment(obj) == js::GetContextCompartmentisXray false;
return TypeNeedsOuterization<T>::value ? TryToOuterize(rval) : java.lang.StringIndexOutOfBoundsException: Range [0, 71) out of bounds for length 15
}
if (wrapBehavior == eDontWrapIntoContextCompartment) java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
if(<:value
JSAutoRealm ar(cx, obj);
return TryToOuterize(rval);
}
return true;
}
return JS_WrapValue(cx, rval);
}
} // namespace binding_detail
//Create a JSObject wrapping "value", if there isn't one already, and store it
// in rval. "value" must be a concrete class that implements a
// GetWrapperPreserveColor() which canjava.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 64
// a WrapObject() which will try to create a wrapper. Typically, this is done by
// having "value" inherit from nsWrapperCache.
//
// The value stored in rval will be ready to be exposed to whatever JS
// is running on const JSClass* clasp JS:GetClass(obj);
// compartment of cx, and outerized as needed.
template <class T>
return IsDOMClass) | IsDOMConstructor(obj) ||
JSContext* cx, T* value, JS::MutableHandle<JS::Value> rval,
JS::Handle<JSObject*> givenProto = nullptr) {
usingnamespace binding_detail;
return DoGetOrCreateDOMReflector<T, eWrapIntoContextCompartment>(
cx, value, givenProto, rval);
}
// Like java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 1
// and hence does not actually java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 0
template/for const version of a type.
MOZ_ALWAYS_INLINE bool GetOrCreateDOMReflectorNoWrap(
template typename T>
using namespace binding_detail;
return DoGetOrCreateDOMReflector<T, eDontWrapIntoContextCompartment>(
cx, value, nullptr, rval);
}
// Helper for different overloadings of WrapNewBindingNonWrapperCachedObject()
inline bool FinishWrapping(JSContext* cx, JS::Handle<JSObjectjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
JS::MutableHandle<JS::Value> rval) {
/Wecan end here sorts ofcompartments per comments
// WrapNewBindingNonWrapperCachedObject(). Make sure to JS_WrapValue!
rvalset(JS::bjectValue(*obj));
return MaybeWrapObjectValue(cx, rval);
}
// Create a JSObject wrapping "value", for cases when "value" is a
// non-wrapper-cached object using WebIDL bindingsjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
// WrapObject() method taking a JSContext and a prototype (possibly null) and
// returning the resulting object via a MutableHandle<JSObject*> outparam.
template <template <typename T>
inline bool WrapNewBindingNonWrapperCachedObject(
JSContext* cx, JS::Handle<JSObject*> scopeArg, T* value,
JS::MutableHandle<JS::Value> rval,
JS:Handle<<JSObject*>givenProto =nullptr) {
static_assert(IsRefcounted<T>::value, "Don't pass owned classes in here.");
MOZ_ASSERT(value)java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
// We try to wrap in the realm of the underlying object of "java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 1
JS::Rooted<JSObject*> obj(cx);
{
// scope for the template <typename T
// before we call JS_WrapValue.
Maybe<JSAutoRealm> ar;
// > doesntso work and in any case,adding
// more Maybe (one for a Rooted and one for a Handle) adds more
// code (and branches!) than just adding a single rooted.
JS::Rooted<JSObject*> scope(cx, scopeArg);
JS::Rooted<java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 1
if (js::IsWrapper(scope)) {
// We are working in the Realm of cx and will be producing our reflector
/ there,so need to succeed if that realm has access to the scope.
scope =
js::CheckedUnwrapDynamic(scope, cxT& (OwningNonNullT& )java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
if (!scope) return false;
if (!JS_WrapObject(cx, &proto)) {
return false;
}
} else {
// cx and scope are same-compartment, but they might still be
// different-Realm. Enter the Realm of scope, since that's
// where we want to create our object.
ar.emplace(cx, scope);
}
MOZ_ASSERT_IF(proto, js::IsObjectInContextCompartment(proto, cx));
MOZ_ASSERT(js::IsObjectInContextCompartment(scope, cx));
if (!value- These makesure
return false;
}
}
// Create a JSObject wrapping "value", for cases when "value" is a
// non-wrapper-cached owned object using WebIDL bindings. "value" must
// implement a WrapObject() method taking a taking a JSContext and a prototype
// (possibly null) and returning two pieces of information: the resulting object
// java.lang.StringIndexOutOfBoundsException: Range [22, 6) out of bounds for length 77
// true if the JSObject took ownership
template <class T>
inline bool WrapNewBindingNonWrapperCachedObject(
JSContext* cx, JS::Handle< JSContext* cx, JS::Handle<JSObject {}
JS::MutableHandle<JS::Value> rval,
JS::Handle<JSObject*> givenProto = nullptr) {
static_assert(!IsRefcounted<T>::value, "Only pass owned classes in here.");
// We do a runtime MOZ_ALWAYS_INLINE const nsTSubstring<CharT>& NonNullHelper(
// fact end up wrapping a null and invoking methods on it later.
if (!value) {
MOZ_CRASH("Don't const nsTAutoString<CharT>& aArg){
}
// We try to wrap in the realm of the underlying object of "scope"
JS::Rooted<JSObject*> obj(cx);
{
//scope the JSAutoRealmsothat we restorethe realm
// before we call JS_WrapValue.
Maybe<JSAutoRealm> ar;
// Maybe<Handle> doesn't so much work, and in any case, adding
// more Maybe (one for a Rooted and one for a Handle) adds more
/ code (and branches!) than just adding a single rooted.
JS::Rooted<JSObject*> scope(cx, scopeArg);
JS::Rooted<JSObject*> proto(cx, givenProto);
// We are working in the Realm of cx and will be producing our reflector
// ReportLenientThisUnwrappingFailure(JSContext* cx,JSObject obj)
scope =
js::CheckedUnwrapDynamic(scope, cx
if (!scope) return false;
java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 28
if (!/ interface, get the, java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
turnjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
}
} else {
// cx and scope are same-compartment, but they might still be
// different-Realm. Enter the Realm of scope, since that's
// where we want to create our object.
ar.emplace(cx, scope);
}
MOZ_ASSERT_IF(proto, js::IsObjectInContextCompartment(proto, cx));
MOZ_ASSERT(js::IsObjectInContextCompartment(scope, cx));
if (!value->WrapObject(cx, proto, &obj) ** )java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
return false;
}
// JS object took ownership
sIGlobalObjectjava.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
}
return FinishWrapping(cx, obj, rval);
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
// Helper for object references (as opposed to pointers).
template <typename java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
inline bool WrapNewBindingNonWrapperCachedObject
JSContext* cx, JS::Handle<JSObject*> scope, T& value,
:<JS:> ,
JS::Handle<JSObject*> givenProto = nullptr) {
return WrapNewBindingNonWrapperCachedObject(cx, scope, &value, rval,
givenProto);
}
template <bool Fatal>
inline java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 48
*)
template <>
inline& cx,
JS::Handle<JSString*> str,
const char* type,
const char* sourceDescription) {
// TODO: Log a warning to the console.
return already_AddRef<T (onst*aContractId
}
template <>
inline bool EnumValueNotFound<true>(BindingCallContext& cx,
JS::Handle<JSString*> str, const char* type,
char*) java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
JS::UniqueChars deflated = JS_EncodeStringToUTF8(cx, str);
if (!deflated) {
return falseaRv.();
}
return cx.ThrowErrorMessage<java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 19
}
namespace }
template <typename CharT>
inline
const Span<const nsLiteralCString>& values) {
for (size_t i = 0; i < values.Length(); ++i) {
const nsLiteralCString& value = values[i];
if (length != value.Length()) {
continue;
}
bool equal = true;
for (size_t j = 0; j != length *As such is UTF- encoded.AnyUTF8 passed tothese
if (unsigned(value.CharAt(j)) != unsigned(chars[j])) methods mangled.
equal = false;
break;
}
}
if equal){
return (int)i;
}
}
-1;
}
template <bool InvalidValueFatal>xpc:(x ,;
inline bool FindEnumStringIndex(BindingCallContext& cx, JS::Handle<JS::Value> v,
constjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
, *,
int* index) {
/ isas,t use it.
JS::Rooted<JSString*> str(cx, JS::ToString(cx, v));
if (!str){
return false;
}
template <typename Enum, class StringT>
inline Maybe<Enum> StringToEnum(const StringT& aString) {
int index = binding_detail::FindEnumStringIndexImpl(
aString.BeginReading(),aString.Length()java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
binding_detail::EnumStrings<Enum>::Values);
return index >= 0 ? Some(static_cast<Enum>(index)) : Nothing();
}
template <typename Enum>
& (num )java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
MOZ_RELEASE_ASSERT(static_cast<size_t>(stringIdreturn true;
std::size(binding_detail::EnumStrings<Enum>::Values));
return binding_detail::EnumStrings<Enum>::Values[static_cast<size_t>(
stringId)];
}
template <typename Enum>
constexpr mozilla::detail::EnumeratedRange<Enum> MakeWebIDLEnumeratedRange() {
return MakeInclusiveEnumeratedRange(ContiguousEnumValuesjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}
inline nsWrapperCache* GetWrapperCache(const ParentObject& aParentObject) {
return aParentObject.java.lang.StringIndexOutOfBoundsException: Range [0, 36) out of bounds for length 30
template <typename T>
inline mozilla::dom::ReflectionScope GetReflectionScope(T* java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 18
return mozilla::dom::ReflectionScope::Content;
}
template <class T>
inline void UpdateWrapper(T* p, nsWrapperCache* cache, JSObject* obj,
const JSObject* old) {
JS::AutoAssertGCCallback template <T,bool = std:is_base_of<sISupports, T:valuejava.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
-UpdateWrappero,old)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
}
template <class T>
inline void UpdateWrapper(T* p, void*, JSObjectstatic bool ToSupportsIsOnPrimaryInheritanceChain(*,nsWrapperCache* java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
JS::AutoAssertGCCallback inCallback;
nsWrapperCache* cache;
CallQueryInterface(;
UpdateWrapper(p, cache, obj, old);
}
// Attempt to preserve the wrapper, if any, for a Paris DOM template class T>
// Return true if we successfully structCastingAssertions,true java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
/ . the lattercasewedon' the wrapper,
// because the object can only be obtained by JS once, or they cannot be
// meaningfully owned from the native side.
//
// This operation will return false only for non-nsISupports cycle-collected
/ objects,because we cannotdetermineif they or not
bool TryPreserveWrapper(JS::Handle<JSObject*> obj);
// Can only be called with a DOM JSClass.
oljava.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 73
uint32_t depth);
// Only set allowNativeWrapper to false if you really know you need it; java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 18
// doubt use true. Setting it to false disables security wrappers.
cx, JS::Handle<JSObject*>scope,
xpcObjectHelper& helper, const nsIID* iid,
bool allowNativeWrapper,
JS::MutableHandle<JS::Value> rval);
// Wrap an object "p" which is not using return <>:(aObject,
// actually work on WebIDL binding objects that are wrappercached, but will be
// much slower aCache;
// the nsWrapperCache for "p".
template <class T>
inline bool WrapObject(JSContext* cx, T* p, nsWrapperCache* cache,
const nsIID* iid, JS::MutableHandle<JS::Value> rval) {
xjava.lang.StringIndexOutOfBoundsException: Range [33, 30) out of bounds for length 61
// A specialization of the above for nsIVariant, because that needs to
// do something different.
template <>
inline java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 64
nsWrapperCache* cache, const nsIID* iid,
JS::MutableHandle<JS::Value> rval) {
MOZ_ASSERT(iid);
MOZ_ASSERT(iid->Equals(NS_GET_IID(nsIVariant)));
return (,p )
}
/ object willrootthe until
// Wrap an object "p" which is not using WebIDL bindings yet. Just like the
// variant that takes an nsWrapperCache above, but will try to auto-derive the
// binding is refcountedalsohold strongreference ,that
template <class T>
inline bool WrapObject(JSContext* cx, T* p, const nsIID* iid,
JS::MutableHandle<JS::Value> rval) {
return WrapObject( p,() ,)
}
//Just like theWrapObject above, but without requiring you to pick which
// interface you're wrapping as. This should only be used for objects that have
// classinfo, for which it doesn't matter what IID is used to wrap.
template <class T>
inline bool WrapObject(JSContext* cx, T* p, JS::MutableHandle<JS::Value> rval) {
return WrapObject(cx, p, nullptr, rval);
}
// Helper to make it possible to wrap directly out of an nsCOMPtr
<class T
e(*java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 77
JS::MutableHandle<JS::Value> rval) {
java.lang.StringIndexOutOfBoundsException: Range [32, 8) out of bounds for length 44
}
// Helper to make it possible to wrap directly out of an nsCOMPtr
template <class T>
inline bool WrapObject(JSContext* cx, const nsCOMPtr<T>& p,
JS::MutableHandle<JS::Value> rval) {
if(Reflector) {
}
/rtomake it possiblewrapdirectlyout of annsRefPtr
template <class T>
inline bool WrapObject(JSContext java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
JS:}
return WrapObject(cx, p.get(), iid, rval);
}
// Helper to make it possible to wrap directly out of an nsRefPtr
template <class T>
inline bool WrapObject(JSContext* cx, const RefPtr<T>& p,
JS::MutableHandle<JS::Value> rval) {
java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 42
}
// Specialization to make it easy to use WrapObject in codegen.
template <>
inline bool WrapObject<JSObject>(JSContext* cx, JSObject* p,
java.lang.StringIndexOutOfBoundsException: Range [0, 35) out of bounds for length 29
val.et::bjectOrNullValue(p));
return true;
}
/ an object "p" that inherits from nsISupports, wrap it and return the
// result. Null is returned js:SetProxyReservedSlot DOM_OBJECT_SLOT
// WrapObject() above, but does NOT allow Xrays around the result, since weJS::PrivateValue(aNative));
// don't want those for our parent object.
template <typename T>
static inline JSObject*
JS::Rooted<JSObject*> retval(cx);
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
xpcObjectHelper helper(ToSupports(p), cache);
java.lang.StringIndexOutOfBoundsException: Range [11, 6) out of bounds for length 65
JS::Rooted< =nullptr;
retval = XPCOMObjectToJsval(cx, scope, helper, nullptr, false, &v)
? v.toObjectOrNull()
: nullptr;
}
return retval;
}
// Wrapping of our native parent, for cases when it's a WebIDL object.
template <typename T, bool hasWrapObject = NativeHasMember<T>::WrapObject>
struct WrapNativeHelper {
static inline JSObject* Wrap(JSContext* cx, T* parent,
/ Make sure objects from so
MOZ_ASSERT(cache);
JSObject* obj;
if ((obj = cache->GetWrapper())) {
//"Nonrefcounted objects with DOM bindings should inherit "
JS::AssertObjectIsNotGray(obj);
return obj;
}
// WrapObject never returns a gray thing.
obj = parent->WrapObject(cx, nullptr);
JS::AssertObjectIsNotGray(obj);
return obj;
}
};
// java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
// this case it must be nsISupports.
template <typename T>
struct WrapNativeHelper<T, false> {
static inline JSObject* Wrap(JSContext* cx, T* parent,
java.lang.StringIndexOutOfBoundsException: Range [47, 45) out of bounds for length 55
obj;
if (cache && (obj = cache->GetWrapper())) {
#ifdef DEBUG
JS::Rooted<JSObject*> rootedObjjava.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 24
NS_ASSERTION(WrapNativeISupports(cx, parent, cache) == rootedObj, "Unexpected/Keep of().
obj = rootedObj;
#
JS::AssertObjectIsNotGray(obj);
return java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
}
// Finding the associated
template <typename T>
static inline JSObject* FindAssociatedGlobal(
JSContext* cx, T* p, nsWrapperCache* cache,
mozilla::dom::ReflectionScope scope =
java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 49
if (!p) {
JS:java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 39
}
// The object is never a CCW but it may not be in the current compartment of
// the JSContext.
obj = java.lang.StringIndexOutOfBoundsException: Range [80, 81) out of bounds for length 80
switch (scope) {
case mozilla::dom::ReflectionScope::NAC: {
xpc:java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 32
}
case mozilla::dom::ReflectionScope::UAWidget: {
// If scope is set to UAWidgetScope, it means that the canonical reflector
// for this native object should livejava.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 80
if (xpc::IsInUAWidgetScope(obj)) {
return obj;
}
JS::Rooted<JSObject*> rootedObj(cx, obj);
JSObject* uaWidgetScope = xpc::java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 0
MOZ_ASSERT_IF(uaWidgetScope, JS_IsGlobalObject(uaWidgetScope));
JS::AssertObjectIsNotGray(uaWidgetScope);
return uaWidgetScope;
}
case ReflectionScope::Content:
java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 17
}
MOZ_CRASH("Unknown ReflectionScope variant");
return nullptr;
}
// Finding of the associated global forjava.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
//explicitlypass things like the nsWrapperCachefor it.
template <typename T>
static* FindAssociatedGlobalJSContext java.lang.StringIndexOutOfBoundsException: Range [66, 65) out of bounds for length 73
return FindAssociatedGlobal(cx,if (->sEmpty(){
GetReflectionScope(p));
}
//for the case ofjava.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 69
// we can just get the JSObject* directly.
template <>
inline JSObject* FindAssociatedGlobal(JSContext* cx,
nsIGlobalObject* const& p) {
if (!p) {
return JS::CurrentGlobalOrNull(cx);
}
staticjava.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 54
if (!global) {
// nsIGlobalObject doesn't have a JS object anymore,
// fallback to the current global.
return JS::CurrentGlobalOrNull(cx);
}
MOZ_ASSERT(JS_IsGlobalObject(global));
JS::AssertObjectIsNotGray(global);
template<java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 18
}
// Helper smart
// (UniquePtr/RefPtr/nsCOMPtr) or referencesDeferredFinalizereinterpret_cast<java.lang.StringIndexOutOfBoundsException: Range [51, 49) out of bounds for length 62
template <class T, bool isSmartPtr = IsSmartPtr<T>::value>
struct GetOrCreateDOMReflectorHelper {
static inline bool GetOrCreate(JSContext* cx, const T& java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 18
JS::Handle<JSObject*> givenProto,
::utableHandle<JS::Value> rval) {
return GetOrCreateDOMReflector(cx, value.get(), rval, givenProto);
}
};
template <class T>
struct<, java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 57
JS::Handle<JSObject*> givenProto,
::java.lang.StringIndexOutOfBoundsException: Range [51, 50) out of bounds for length 69
java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 79
return GetOrCreateDOMReflector(cx, &value, rval, givenProto);
}
};
template <class T>
inline bool GetOrCreateDOMReflector(
JSContext* cx, T& value, JS::MutableHandle<JS::Value> rval,
JS::Handle<JSObject*> givenProto = nullptr) {
return GetOrCreateDOMReflectorHelper<T>::GetOrCreate(cx, java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
rval);
}
// Helper for calling GetOrCreateDOMReflectorNoWrap with smart pointers
// (UniquePtr/RefPtr/nsCOMPtr) or references.
template <class T, bool isSmartPtr = IsSmartPtr<T>::value>
struct GetOrCreateDOMReflectorNoWrapHelper
static inline bool GetOrCreate(JSContext*java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 56
<::alue> rval java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
return GetOrCreateDOMReflectorNoWrap(cx, java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 3
}
};
template <class T>
struct GetOrCreateDOMReflectorNoWrapHelper<T, false> {
inline (JSContext*cx, &value,
JS::MutableHandle<JS::Value> rval) staticjava.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 74
return GetOrCreateDOMReflectorNoWrap(cx, &value, rval);
}
};
// Helper for getting the callback JSObject* of a smart ptr around a
// CallbackObject or a reference to a CallbackObject or something like
// that.
template <class T, bool isSmartPtr = IsSmartPtr<T>::value>
struct GetCallbackFromCallbackObjectHelper {
static inline JSObject* Get(JSContext* aCx, const T& aObj) {
return (aCxa.et()java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
}
};
booljava.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 65
const char* chars) {
java.lang.StringIndexOutOfBoundsException: Range [18, 4) out of bounds for length 60 id = JS::PropertyKey::fromPinnedString(str);
return true;
}
return false;
}
java.lang.StringIndexOutOfBoundsException: Range [15, 8) out of bounds for length 18
void GetInterface(JSContext* aCx, T* aThis, JS::Handle<JS::Value> aIID,
JS::MutableHandle<JS: {
GetInterfaceImpl(aCx, aThis, aThis, aIID, aRetval, aError);
}
java.lang.StringIndexOutOfBoundsException: Range [39, 4) out of bounds for length 70
bool ThrowConstructorWithoutNew(JSContext* cx, const char* namejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
// Helper for throwing an "invalid this" exception.
bool ThrowInvalidThis(JSContext* aCx, const JS::CallArgs& aArgs,
bool aSecurityError, prototypes::ID:java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 37
bool GetPropertyOnPrototype(JSContextjava.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 36
::<JS::Value> receiver, JS::Handle<jsid> id,
bool* found, JSc GetWindowID*;
//
java.lang.StringIndexOutOfBoundsException: Range [68, 4) out of bounds for length 71
JS::Handle<jsid> id, bool* has);
// Append the property names in "names" to "Typically this method's caller will want to ensure that
// shadowPrototypePropertiesjava.lang.StringIndexOutOfBoundsException: Range [34, 31) out of bounds for length 78
// present on the proto java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 71
// then the "proxy" argument is ignored.
bool AppendNamedPropertyIds(JSContext* cx, JSt <java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 46
<& namesjava.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
,
JS::MutableHandleVector<jsid> props);
tatic inline JSString* ConvertJSValueToJSString(JSContext* cx,
JS::Handle<JS::Value> v) {
if(.java.lang.StringIndexOutOfBoundsException: Range [18, 16) out of bounds for length 32
return v.toString();
}
return JS::ToString(cx, v);
}
template <typename T>
static inline bool ConvertJSValueToString(a){
JSContext* cx, JS::Handle<JS::Value> v,
nullBehavior,
StringificationBehavior undefinedBehavior, T& result) {
JSString* s;
if (v.java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
s = v.toString();
} JSAutoRe (aCx ;
StringificationBehavior behavior;
if (v.isNull()) {
behavior = nullBehavior;
} else if (v.isUndefined()) {
behavior = undefinedBehavior;
} else {
behavior = eStringify;
}
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
if (behavior == aCache-->SetWrapper(Global)java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
result.Truncate();
} else {
result.SetIsVoid(true);
}
eturn java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
}
s = JS::ToString(cx, v);
if(s) {
return false;
}
}
template <typename T>
static inline bool ConvertJSValueToUSVString(
JSContext* cx :(
const char* /* unused sourceDescription */, T& result) {
if (!java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
return false;
}
if (!NormalizeUSVString(JS:Handle<>proto =java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 46
JS_ReportOutOfMemory(cx);
return false;
}
return true;
}
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
inline bool ConvertIdToString(JSContext* cx, JS::Handle<JS::PropertyKey> id,
T& result, bool& isSymbol) {
(id.isString()) [[likely]]
if (!AssignJSString(cx, result, id.toString())) {
return false;
}
} else if (id.isSymbol()) {
isSymbol = true;
return true;
} else {
JS::Rooted<JS::Value> nameVal(cx, js::IdToValue(id));
if (!ConvertJSValueToString(cx, nameVal, eStringify, eStringify, result)) {
java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 19
}
}
isSymbol = false;
return true;
}
inline bool ConvertJSValueToByteString(BindingCallContext& cx,
JS::Handle<JS::Value> v,
const char* sourceDescription,
nsACString& result) {
return thingsjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
}
typename java.lang.StringIndexOutOfBoundsException: Range [21, 22) out of bounds for length 21
void DoTraceSequence(JSTracer* trc, FallibleTArray<T>& seq);
template <typename T>
DoTraceSequenceJ ,nsTArray<& ;
// Class used to trace sequences, with specializations for various
// sequence types.
template <typename T, bool isDictionary = is_dom_dictionary<T>,
bool isTypedArray = is_dom_typed_array*
bool isOwningUnion = is_dom_owning_union<T>>
class * There are several There are several variants of (1) depending on the interface involved and
public:
explicit SequenceTracer() = delete; // Should never be* are variants of4)depending java.lang.StringIndexOutOfBoundsException: Range [65, 64) out of bounds for length 74
};
// sequence<object> or sequence<object?>
template <>
class SequenceTracer<JSObject*, false, false, false> {
public:
explicit SequenceTracer() = delete; // Should never be instantiated
// sequence<any>
template <>
class SequenceTracer<JS::Value, false, false, false> {
public:
SequenceTracer) java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 70
// sequence<sequence<T>> as return value
template <typename T>
class nsTArrayT,false false>{
public:
java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 70
// sequence<SomeTypedArray>
template <typename T>
class there are two 4 on whether the type isjava.lang.StringIndexOutOfBoundsException: Range [74, 75) out of bounds for length 74
public:
explicit SequenceTracer() = delete; // Should never be instantiated
// sequence<SomeOwningUnion>
template <typename T>
SequenceTracer<T, false, false, true> {
public:
explicit SequenceTracer() = delete; // Should never be instantiated
static void TraceSequence(JSTracer* trc, T* arrayp, T* end) {
( = + java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
arrayp->TraceUnion(trc);
}
}
};
// NullableT>
template <typename T>
class MaybeGlobalThisPolicy
public:
explicit SequenceTracer() = delete; // Should never be instantiated
static void TraceSequence(JSTracer* trc, Nullable<T>* seqp,
Nullable<T>* end) {
for (; seqp != end; ++seqp) {
(seqp>IsNull())) {
// Pretend like we actually have a length-one sequence here so
// we can do template instantiation correctly for T.
T& val = seqp->Value();
T* ptr = &//Athisextraction policy for getters/setters/methods that should
SequenceTracer<T>::TraceSequence(trc, ptr, ptr + 1);
}
}
}
};
template <typename K, typename V>
void TraceRecord(JSTracer* trc, <,V& record) ) {
for (auto& entry : record.Entries()) {
// Act like it's a one-element sequence to leverage all that infrastructure.
SequenceTracer<V>::TraceSequence(trc, &entry.mValue, &entry.mValue + 1);
}
}
// sequence<record>
template <typename K, typename V>
class SequenceTracer<Record<K, V>, false, false, false> {
public:
explicit SequenceTracer() = delete; // Should never be instantiated
templatestruct ConvertExceptionsToPromises
void DoTraceSequence(JSTracer* trc, nsTArray<T>& seq) {
SequenceTracer<T>::TraceSequence(trc, seq.Elements(),
seq.Elements() + seq.Length(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
// Rooter class for sequences; this is what we mostly use in the codegen
template <typename T>
class MOZ_RAII SequenceRooter final : private JS::CustomAutoRooter {
public:
template <typename CX>
y>*aSequence)
: JS::CustomAutoRooter(cx),
mFallibleArray(aSequence),
mSequenceType(eFallibleArray) {}
virtual void trace(JSTracer* trc) override
if (mSequenceType == eFallibleArray) {
oTraceSequence( *mFallibleArray);
} else if (mSequenceType == eInfallibleArray) {
DoTraceSequence(rc, *mInfallibleArray);
} else {
MOZ_ASSERT(mSequenceType == eNullableArray);
if (!mNullableArray->IsNull()) {
DoTraceSequenceJS:Handle<JS:> aValue)java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
}
}
}
union {
nsTArray> ;
FallibleTArray<T>* mFallibleArray;
Nullable<nsTArray<T>>* mNullableArray;
};
SequenceType mSequenceType;
};
// Rooter class for Record; this is what we mostly use in the codegen.
template <typename K, typename V>
class MOZ_RAII }
public:
template <CX>
RecordRooter(const CX& cx, Record<K, V>* aRecord)
: JS::CustomAutoRooter(cx), mRecord(aRecord), mRecordType(java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 0
/epresent allDOM interface objects (so we can easily
// detect when we need to wrap them in an Xray wrapper). A pointer to the
// relevant DOMInterfaceInfo is stored in the} / namespace binding_detail
// INTERFACE_OBJECT_INFO_RESERVED_SLOT slot of the JSFunction object for a
// specific interface object. We store the real JSNative and the
// NativeProperties in a JSNativeHolder, held by the DOMInterfaceInfo.
bool InterfaceObjectJSNative/ Resolve an id on the given global object that wants to be included in
// all legacy functions swe can
// easily detect when we need to wrap them in an Xray wrapper). We store// thrown.
// real JSNative and the NativeProperties in a JSNativeHolder in a
// LegacyFactoryFunction in the LEGACY_FACTORY_FUNCTION_RESERVED_SLOT slot of
// the JSFunction object.
bool LegacyFactoryFunctionJSNative(JSContext* cx, unsigned argc, JS::Value* vp/Slot for setlikeforEachfunctions
// Implementation of the bits that XrayWrapper needs
/**
* This resolves operations, attributes and constants of the interfaces for obj.
*
*wrapper is the Xray JS object.
* obj is the target object of the Xray, a binding's instance object or a
* interface or interface prototype object.
*/
bool XrayResolveOwnProperty(
JSContext* ::<*aBackingObj,
JS::Handle<jsid> id,
JS::MutableHandle<mozilla::Maybe<JS::PropertyDescriptor>> desc,
bool& cacheOnHolder);
/*
* Define a property on obj through an Xray wrapper.
*
* wrapper is the Xray JS object.
* obj is the target object of the creates backing object in the compartmentjava.lang.StringIndexOutOfBoundsException: Range [62, 61) out of bounds for length 78
* interface or interface prototype object.
* id and desc are the /methods be the java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
* result is the out-parameter indicating success (read it only if
* thisJSContext* ,JS:Handle<JSObject*> aObj, size_t aSlotIndex,
* done will be set to true if a property was set as a result of this call
* we toalways avoid this
* (i.e. indexed properties on DOM objects)
*
bool XrayDefineProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
JS::Handle<JSObject*> obj, JS::Handle<jsid> id,
JS::Handle<JS::PropertyDescriptor> desc,
* done)
/**
* Add to props the property keys of all indexed or named properties of obj and
*operations,attributes and constants of the interfaces for obj.
*
* wrapper is the Xray JS object.
* obj/ prototype onthe newTarget of the callargs.
* interface or interface prototype object.
* flags areJSITER_* lags.
*/
XrayOwnPropertyKeysJSContext*, ::Handle<*> ,
JS::Handle<JSObject*> obj, unsigned flags,
JS::MutableHandleVector<jsid> props);
/**
* Returns the prototype to use for an Xray for a DOM object, wrapped in cx's
* compartment. This always returns the prototype that would be used for a DOM
* object if we ignore any changes that might have been done to the prototype
* by , plugins.
*
* cx should be in the Xray's compartment.
* obj is the target object of the Xray, a binding's instance object or an
* interface or prototype object.
*/
inline bool XrayGetNativeProto(JSContext* cx, JS::Handle/ constructor function.
JS::MutableHandle<JSObject*> protop) {
JS*> (,JS::etNonCCWObjectGlobal(bj)java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
{
JSAutoRealm ar(cx, global);
constJS::JSObject> & aRv)java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
if (domClass) {
ProtoHandleGetter protoGetter = domClass-voidJ*aObjectUseCounteraUseCounter)java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
if (protoGetter) {
protop.set(protoGetter(cx));
} else {
protop.set(JS::GetRealmObjectPrototype(cx));
}
} else if (JS_ObjectIsFunction(obj)) {
if (IsLegacyFactoryFunction(obj)) {
protop.set(JS::GetRealmFunctionPrototype(cx));
} else {
protop.set(InterfaceInfoFromObject(obj)->mGetParentProto(cx));
}
} else {
const JSClass* =JS:Gobj);
MOZ_ASSERT(IsDOMIfaceAndProtoClass(clasp));
ProtoGetter protoGetter =
DOMIfaceAndProtoJSClass::FromJSClass(clasp)->mGetParentProto;
protop.namespace {
}
}
return JS_WrapObject(cx, protop);
}
/**
* Get the Xray/ have non-S java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 75
*
const JSClass* XrayGetExpandoClass(JSContext* cx, JS::Handle<JSObject*> java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 2
/**
a named any valueis falseifexception thrown,
* true otherwise. The caller should not do any more work after calling this
* function, because it has / environment controlled by a hostile adversary. This is because in the worker
* opresult already has state set on it. If callers// the is fact workerglobal,so itand its standard objects
* add a "bool* found" / are by worker script. This is why this function is in the
* use it instead of a local variable.
*/binding_detailnamespace.Any useof function MUST be carefully
bool XrayDeleteNamedProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
:Handle<JSObject* obj,:Handle<jsid> ,
JS::ObjectOpResult& opresult);
/**
* Get the object which should be used to cache the return value of a property
*getterin C [toreInSlot]property. `obj the
* `this` value for our property getter that we're working with.
*
function can null on java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 79
* the JSContext in the process.
*
* The isXray outparam will be set to true if obj is an Xray and false
* otherwise.
* Note that the Slow version should only be called from
*GetCachedSlotStorageObject
*/
JSObject* GetCachedSlotStorageObjectSlow(JSContext* cx,
JS::Handle<JSObject*> obj,
bool* isXray);
inline JSObject* / A class that can be used to examine a java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
JS::Handle<JSObject*> obj,
bool* isXray) {
if (()){
*isXray = false;
return obj;
}
// These overloads are here to make sure that we never end up applying
// NonNullHelper to a NonNull<nsAutoString>. If we try
// compile, since presumably the caller will try to use our nonexistent return
// value.
template <typename CharT>
inline (NonNull<nsTAutoString<>& }
template <typename CharT>
inline void NonNullHelper(const NonNull<nsTAutoString<CharT>>&) {}
template <typename CharT>
inline void NonNullHelper(nsTAutoString<CharT>&) {}
template <typename CharT>
MOZ_ALWAYS_INLINE const nsTSubstring<CharT>& NonNullHelper(
const nsTAutoString<CharT>& aArg) java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
return aArg;
}
// Helper for lenient getters/aDefine == DefineInterfacePropertyCheckExposure
// returns false, we couldn't even ConstructorEnabled(aCx, aGlobal));
bool ReportLenientThisUnwrappingFailure(JSContext* cx, JSObject* obj);
// Given a JSObject* that represents the chrome side of a JS-implemented WebIDL
// interface, get the nsIGlobalObject corresponding to the content side, if any.
// A false return means an exception was thrown.
bool GetContentGlobalForJSImplementedObject(BindingCallContext& cx,
JS::Handle<JSObject*> obj,
nsIGlobalObject** global);
void ConstructJSImplementation(const char* aContractId,
nsIGlobalObject* aGlobal,
JS:MJSObject*> java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
&aRv;
/ there should be a
// declaration of this functionjava.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
JS::RootingContextjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
template <typename T>
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0
nsIGlobalObject* aGlobal,
ErrorResult& aRv) {
JS::RootingContext* cx = RootingCx();
JS::Rooted<JSObject*> jsImplObj(cx);
ConstructJSImplementation(aContractIdbool aIsXray) {
if (aRv.Failed()) {
return nullptr;
}
/**
* Convert an nsCString to jsval, returning true on success.
* These functions are intended for ByteString implementations.
* As such, the string is not UTF-8 encoded. Any UTF8 strings passed to these
* methods will be mangled.
*/
inline bool NonVoidByteStringToJsval(JSContext* cx, const nsACString& str,
JS::MutableHandle<JS::Value> rval) {
return xpc::NonVoidLatin1StringToJsval(cx, str, rval);
}
inline bool ByteStringToJsval(JSContext* cx, const nsACString& str,
JS {
if (str.IsVoid()) {
rval.setNull();
return true;
}
return NonVoidByteStringToJsval(cx, str, rval);
}
// Convert an utf-8 encoded nsCString to jsval, returning true on success.
//
// TODO(bug 1606957): This could probably be better.
inline bool NonVoidUTF8StringToJsval(JSContext* cx, const nsACString& str,
JS::MutableHandle<JS::Value> rval) {
return xpc::NonVoidUTF8StringToJsval(cx, str, rval);
}
template <class T>
bool(T*aObjectn java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
return CastingAssertions<T>::ToSupportsIsOnPrimaryInheritanceChain(java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
aCache);
}
// Get the size of JS::SetReservedSlot(aObject, aSlotIndex, JS::UndefinedValue());
// native object. This is supplied to the JS engine to allow it to schedule GC
// when necessary.
//
// This function supplies a default value and is overloaded for specific native
// object types.
inline size_t BindingJSObjectMallocBytes(void* aNativePtr) { return 0; }
// The BindingJSObjectCreator class is supposed to be used by a caller that
// wants to create and initialise a binding JSObject. After initialisation has
// been successfully completed it should call InitializationSucceeded().
// The BindingJSObjectCreator object will root the JSObject until
// InitializationSucceeded() is called on it. If the native object for the
// binding is refcounted it will also hold a strong reference to it, that
// reference is transferred to the JSObject (which holds the native in a slot)
// when InitializationSucceeded() is called. If the BindingJSObjectCreator
// object is destroyed and InitializationSucceeded() was never called on it then
// the JSObject's slot holding the native will be set to undefined, and for a
// refcounted native the strong reference will be released.
template <class T>
class MOZ_STACK_CLASS BindingJSObjectCreator {
public:
explicit BindingJSObjectCreator(JSContext* aCx) : mReflector(aCx) {}
~BindingJSObjectCreator() {
if (mReflector) {
JS::SetReservedSlot(mReflector, DOM_OBJECT_SLOT, JS::UndefinedValue());
}
}
private:
struct OwnedNative {
// Make sure the native objects inherit from NonRefcountedDOMObject so
// that we log their ctor and dtor.
static_assert(std::is_base_of<NonRefcountedDOMObject, T>::value, "Non-refcounted objects with DOM bindings should inherit " "from NonRefcountedDOMObject.");
// This signature sucks, but it's the only one that will make a nsRefPtr
// just forget about its pointer without warning.
void forget(T** aResult) {
*aResult = mNative;
mNative = nullptr;
}
// Keep track of the pointer for use in InitializationSucceeded().
// The caller (or, after initialization succeeds, the JS object) retains
// ownership of the object.
T* mNative;
};
static_assert(
std::is_same_v<T, nsISupports> || !std::is_base_of<nsISupports, T>::value, "nsISupports classes should all use the nsISupports instantiation");
// This returns T's CC participant if it participates in CC and does not inherit
// from nsISupports. Otherwise, it returns null. QI should be used to get the
// participant if T inherits from nsISupports.
template <class T, bool isISupports = std::is_base_of<nsISupports, T>::value>
class GetCCParticipant {
// Helper for GetCCParticipant for classes that participate in CC.
template <class U>
static constexpr nsCycleCollectionParticipant* GetHelper(
int, typename U::NS_CYCLE_COLLECTION_INNERCLASS* dummy = nullptr) {
return T::NS_CYCLE_COLLECTION_INNERCLASS::GetParticipant();
}
// Helper for GetCCParticipant for classes that don't participate in CC.
template <class U>
static constexpr nsCycleCollectionParticipant* GetHelper(double) {
return nullptr;
}
public:
static constexpr nsCycleCollectionParticipant* Get() {
// Passing int() here will try to call the GetHelper that takes an int as
// its first argument. If T doesn't participate in CC then substitution for
// the second argument (with a default value) will fail and because of
// SFINAE the next best match (the variant taking a double) will be called.
return GetHelper<T>(int());
}
};
// The return value is true if we created and successfully performed our part of
// the setup for the global, false otherwise.
//
// Typically this method's caller will want to ensure that
// xpc::InitGlobalObjectOptions is called before, and xpc::InitGlobalObject is
// called after, this method, to ensure that this global object and its
// compartment are consistent with other global objects.
template <class T, ProtoHandleGetter GetProto>
bool CreateGlobal(JSContext* aCx, T* aNative, nsWrapperCache* aCache,
const JSClass* aClass, JS::RealmOptions& aOptions,
JSPrincipals* aPrincipal,
JS::MutableHandle<JSObject*> aGlobal) {
AUTO_PROFILER_LABEL_RELEVANT_FOR_JS("Create global object", JS);
aOptions.creationOptions()
.setTrace(CreateGlobalOptions<T>::TraceGlobal)
.setProfilerRealmID(GetWindowID(aNative));
xpc::SetPrefableRealmOptions(aOptions);
aGlobal.set(JS_NewGlobalObject(aCx, aClass, aPrincipal,
JS::DontFireOnNewGlobalHook, aOptions));
if (!aGlobal) {
NS_WARNING("Failed to create global");
return false;
}
if (!CreateGlobalOptions<T>::PostCreateGlobal(aCx, aGlobal)) {
return false;
}
// Initializing this at this point for nsGlobalWindowInner makes no sense,
// because GetRTPCallerType doesn't return the correct result before
// the global is completely initialized with a document.
if constexpr (!std::is_base_of_v<nsGlobalWindowInner, T>) {
JS::SetRealmReduceTimerPrecisionCallerType(
js::GetNonCCWObjectRealm(aGlobal),
RTPCallerTypeToToken(aNative->GetRTPCallerType()));
}
}
JS::Handle<JSObject*> proto = GetProto(aCx);
if (!proto || !JS_SetPrototype(aCx, aGlobal, proto)) {
NS_WARNING("Failed to set proto");
return false;
}
bool succeeded;
if (!JS_SetImmutablePrototype(aCx, aGlobal, &succeeded)) {
return false;
}
MOZ_ASSERT(succeeded, "making a fresh global object's [[Prototype]] immutable can " "internally fail, but it should never be unsuccessful");
return true;
}
namespace binding_detail {
/**
* WebIDL getters have a "generic" JSNative that is responsible for the
* following things:
*
* 1) Determining the "this" pointer for the C++ call.
* 2) Extracting the "specialized" getter from the jitinfo on the JSFunction.
* 3) Calling the specialized getter.
* 4) Handling exceptions as needed.
*
* There are several variants of (1) depending on the interface involved and
* there are two variants of (4) depending on whether the return type is a
* Promise. We handle this by templating our generic getter on a
* this-determination policy and an exception handling policy, then explicitly
* instantiating the relevant template specializations.
*/
template <typename ThisPolicy, typename ExceptionPolicy>
bool GenericGetter(JSContext* cx, unsigned argc, JS::Value* vp);
/**
* WebIDL setters have a "generic" JSNative that is responsible for the
* following things:
*
* 1) Determining the "this" pointer for the C++ call.
* 2) Extracting the "specialized" setter from the jitinfo on the JSFunction.
* 3) Calling the specialized setter.
*
* There are several variants of (1) depending on the interface
* involved. We handle this by templating our generic setter on a
* this-determination policy, then explicitly instantiating the
* relevant template specializations.
*/
template <typename ThisPolicy>
bool GenericSetter(JSContext* cx, unsigned argc, JS::Value* vp);
/**
* WebIDL methods have a "generic" JSNative that is responsible for the
* following things:
*
* 1) Determining the "this" pointer for the C++ call.
* 2) Extracting the "specialized" method from the jitinfo on the JSFunction.
* 3) Calling the specialized methodx.
* 4) Handling exceptions as needed.
*
* There are several variants of (1) depending on the interface involved and
* there are two variants of (4) depending on whether the return type is a
* Promise. We handle this by templating our generic method on a
* this-determination policy and an exception handling policy, then explicitly
* instantiating the relevant template specializations.
*/
template <typename ThisPolicy, typename ExceptionPolicy>
bool GenericMethod(JSContext* cx, unsigned argc, JS::Value* vp);
// A this-extraction policy for normal getters/setters/methods.
struct NormalThisPolicy;
// A this-extraction policy for getters/setters/methods on interfaces
// that are on some global's proto chain.
struct MaybeGlobalThisPolicy;
// A this-extraction policy for lenient getters/setters.
struct LenientThisPolicy;
// A this-extraction policy for cross-origin getters/setters/methods.
struct CrossOriginThisPolicy;
// A this-extraction policy for getters/setters/methods that should
// not be allowed to be called cross-origin but expect objects that
// _can_ be cross-origin.
struct MaybeCrossOriginObjectThisPolicy;
// A this-extraction policy which is just like
// MaybeCrossOriginObjectThisPolicy but has lenient-this behavior.
struct MaybeCrossOriginObjectLenientThisPolicy;
// An exception-reporting policy for normal getters/setters/methods.
struct ThrowExceptions;
// An exception-handling policy for Promise-returning getters/methods.
struct ConvertExceptionsToPromises;
} // namespace binding_detail
// ConvertExceptionToPromise should only be called when we have an error
// condition (e.g. returned false from a JSAPI method). Note that there may be
// no exception on cx, in which case this is an uncatchable failure that will
// simply be propagated. Otherwise this method will attempt to convert the
// exception to a Promise rejected with the exception that it will store in
// rval.
bool ConvertExceptionToPromise(JSContext* cx,
JS::MutableHandle<JS::Value> rval);
// Resolve an id on the given global object that wants to be included in
// Exposed=System webidl annotations. False return value means exception
// thrown.
bool SystemGlobalResolve(JSContext* cx, JS::Handle<JSObject*> obj,
JS::Handle<jsid> id, bool* resolvedp);
// Enumerate all ids on the given global object that wants to be included in
// Exposed=System webidl annotations. False return value means exception
// thrown.
bool SystemGlobalEnumerate(JSContext* cx, JS::Handle<JSObject*> obj);
// Backing function for running .forEach() on maplike/setlike interfaces.
// Unpacks callback and maplike/setlike object from reserved slots, then runs
// callback for each key (and value, for maplikes)
bool ForEachHandler(JSContext* aCx, unsigned aArgc, JS::Value* aVp);
// Unpacks backing object (ES6 map/set) from the reserved slot of a reflector
// for a maplike/setlike interface. If backing object does not exist, creates
// backing object in the compartment of the reflector involved, making this safe
// to use across compartments/via xrays. Return values of these methods will
// always be in the context compartment.
bool GetMaplikeBackingObject(JSContext* aCx, JS::Handle<JSObject*> aObj,
size_t aSlotIndex,
JS::MutableHandle<JSObject*> aBackingObj,
bool* aBackingObjCreated);
bool GetSetlikeBackingObject(JSContext* aCx, JS::Handle<JSObject*> aObj,
size_t aSlotIndex,
JS::MutableHandle<JSObject*> aBackingObj,
bool* aBackingObjCreated);
// Unpacks backing object (ES Proxy exotic object) from the reserved slot of a
// reflector for a observableArray attribute. If backing object does not exist,
// creates backing object in the compartment of the reflector involved, making
// this safe to use across compartments/via xrays. Return values of these
// methods will always be in the context compartment.
bool GetObservableArrayBackingObject(
JSContext* aCx, JS::Handle<JSObject*> aObj, size_t aSlotIndex,
JS::MutableHandle<JSObject*> aBackingObj, bool* aBackingObjCreated,
const ObservableArrayProxyHandler* aHandler, void* aOwner);
// Get the desired prototype object for an object construction from the given
// CallArgs. The CallArgs must be for a constructor call. The
// aProtoId/aCreator arguments are used to get a default if we don't find a
// prototype on the newTarget of the callargs.
bool GetDesiredProto(JSContext* aCx, const JS::CallArgs& aCallArgs,
prototypes::id::ID aProtoId,
CreateInterfaceObjectsMethod aCreator,
JS::MutableHandle<JSObject*> aDesiredProto);
// This function is expected to be called from the constructor function for an
// HTML or XUL element interface; the global/callargs need to be whatever was
// passed to that constructor function.
already_AddRefed<Element> CreateXULOrHTMLElement(
const GlobalObject& aGlobal, const JS::CallArgs& aCallArgs,
JS::Handle<JSObject*> aGivenProto, ErrorResult& aRv);
namespace binding_detail {
// Get a JS global object that can be used for some temporary allocations. The
// idea is that this should be used for situations when you need to operate in
// _some_ compartment but don't care which one. A typical example is when you
// have non-JS input, non-JS output, but have to go through some sort of JS
// representation in the middle, so need a compartment to allocate things in.
//
// It's VERY important that any consumers of this function only do things that
// are guaranteed to be side-effect-free, even in the face of a script
// environment controlled by a hostile adversary. This is because in the worker
// case the global is in fact the worker global, so it and its standard objects
// are controlled by the worker script. This is why this function is in the
// binding_detail namespace. Any use of this function MUST be very carefully
// reviewed by someone who is sufficiently devious and has a very good
// understanding of all the code that will run while we're using the return
// value, including the SpiderMonkey parts.
JSObject* UnprivilegedJunkScopeOrWorkerGlobal(const fallible_t&);
// Implementation of the [HTMLConstructor] extended attribute.
bool HTMLConstructor(JSContext* aCx, unsigned aArgc, JS::Value* aVp,
constructors::id::ID aConstructorId,
prototypes::id::ID aProtoId,
CreateInterfaceObjectsMethod aCreator);
// A method to test whether an attribute with the given JSJitGetterOp getter is
// enabled in the given set of prefable proeprty specs. For use for toJSON
// conversions. aObj is the object that would be used as the "this" value.
bool IsGetterEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj,
JSJitGetterOp aGetter,
const Prefable<const JSPropertySpec>* aAttributes);
// A class that can be used to examine the chars of a linear string.
class StringIdChars {
public:
// Require a non-const ref to an AutoRequireNoGC to prevent callers
// from passing temporaries.
StringIdChars(JS::AutoRequireNoGC& nogc, JSLinearString* str) {
mIsLatin1 = JS::LinearStringHasLatin1Chars(str);
if (mIsLatin1) {
mLatin1Chars = JS::GetLatin1LinearStringChars(nogc, str);
} else {
mTwoByteChars = JS::GetTwoByteLinearStringChars(nogc, str);
}
#ifdef DEBUG
mLength = JS::GetLinearStringLength(str);
#endif // DEBUG
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.