java.lang.Object
org.htmlunit.corejs.javascript.SlotMapOwner<org.htmlunit.corejs.javascript.Scriptable>
org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.javascript.HtmlUnitScriptable
- All Implemented Interfaces:
Serializable,Cloneable,org.htmlunit.corejs.javascript.ConstProperties<org.htmlunit.corejs.javascript.Scriptable>,org.htmlunit.corejs.javascript.debug.DebuggableObject,org.htmlunit.corejs.javascript.PropHolder<org.htmlunit.corejs.javascript.Scriptable>,org.htmlunit.corejs.javascript.Scriptable,org.htmlunit.corejs.javascript.SymbolScriptable
- Direct Known Subclasses:
AbortController,AbstractList,AbstractRange,Atomics,AudioBuffer,AudioListener,AudioParam,BarProp,Blob,Cache,CacheStorage,CanvasGradient,CanvasPattern,CanvasRenderingContext2D,CaretPosition,Collator,Credential,CredentialsContainer,Crypto,CryptoKey,CSS,CSSRule,CSSRuleList,CSSStyleDeclaration,CustomElementRegistry,DataTransfer,DataTransferItem,DataTransferItemList,DateTimeFormat,DOMError,DOMException,DOMImplementation,DOMMatrixReadOnly,DOMParser,DOMPointReadOnly,DOMRectList,DOMRectReadOnly,DOMStringList,DOMStringMap,DOMTokenList,Event,EventTarget,External,FileList,FileSystem,FileSystemDirectoryReader,FileSystemEntry,FontFace,FormData,Gamepad,GamepadButton,Geolocation,GeolocationCoordinates,GeolocationPosition,GeolocationPositionError,Headers,History,HTMLOptionsCollection,IDBCursor,IDBFactory,IDBIndex,IDBKeyRange,IDBObjectStore,IdleDeadline,ImageBitmap,ImageBitmapRenderingContext,ImageData,InputDeviceCapabilities,IntersectionObserver,IntersectionObserverEntry,Intl,KeyframeEffect,Locale,Location,MediaDeviceInfo,MediaError,MediaKeys,MediaKeyStatusMap,MediaKeySystemAccess,MediaList,MessageChannel,MIDIInputMap,MIDIOutputMap,MimeType,MimeTypeArray,MutationObserver,MutationRecord,NamedNodeMap,NativeXPathNSResolver,Navigator,Netscape,NodeFilter,NodeIterator,NumberFormat,Path2D,PaymentAddress,PerformanceEntry,PerformanceNavigation,PerformanceObserver,PerformanceObserverEntryList,PerformanceTiming,PeriodicSyncManager,PeriodicWave,Permissions,Plugin,PluginArray,Presentation,ProxyAutoConfig,PushManager,PushSubscription,PushSubscriptionOptions,ReadableStream,Request,Response,RTCCertificate,RTCIceCandidate,RTCSessionDescription,RTCStatsReport,Selection,SpeechGrammar,SpeechGrammarList,SpeechSynthesisVoice,Storage,StorageManager,StyleMedia,StyleSheet,StyleSheetList,SubtleCrypto,SVGAngle,SVGAnimatedAngle,SVGAnimatedBoolean,SVGAnimatedEnumeration,SVGAnimatedInteger,SVGAnimatedLength,SVGAnimatedLengthList,SVGAnimatedNumber,SVGAnimatedNumberList,SVGAnimatedPreserveAspectRatio,SVGAnimatedRect,SVGAnimatedString,SVGAnimatedTransformList,SVGLength,SVGLengthList,SVGMatrix,SVGNumber,SVGNumberList,SVGPoint,SVGPointList,SVGPreserveAspectRatio,SVGRect,SVGStringList,SVGTransform,SVGTransformList,SVGUnitTypes,SyncManager,TextDecoder,TextEncoder,TextMetrics,TextTrackCueList,TimeRanges,Touch,TouchList,TreeWalker,URL,URLSearchParams,V8BreakIterator,ValidityState,VideoPlaybackQuality,WebGL2RenderingContext,WebGLActiveInfo,WebGLBuffer,WebGLFramebuffer,WebGLProgram,WebGLQuery,WebGLRenderbuffer,WebGLRenderingContext,WebGLSampler,WebGLShader,WebGLShaderPrecisionFormat,WebGLSync,WebGLTexture,WebGLTransformFeedback,WebGLUniformLocation,WebGLVertexArrayObject,WorkerLocation,WorkerNavigator,XMLSerializer,XPathEvaluator,XPathExpression,XPathResult,XSLTProcessor
public class HtmlUnitScriptable
extends org.htmlunit.corejs.javascript.ScriptableObject
implements Cloneable
Base class for Rhino host objects in HtmlUnit (not bound to a DOM node).
- Author:
- Mike Bowler, David K. Taylor, Marc Guillemot, Chris Erskine, Daniel Gredler, Ahmed Ashour, Ronald Brill, Sven Strickroth
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.corejs.javascript.ScriptableObject.DescriptorInfo, org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator, org.htmlunit.corejs.javascript.ScriptableObject.LambdaGetterFunction, org.htmlunit.corejs.javascript.ScriptableObject.LambdaSetterFunction -
Field Summary
Fields inherited from class org.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONSTFields inherited from class org.htmlunit.corejs.javascript.SlotMapOwner
isSealedFields inherited from interface org.htmlunit.corejs.javascript.Scriptable
NOT_FOUND -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()protected ObjectequivalentValues(Object value) Gets a named property from the object.Gets the browser version currently used.Returns the JavaScript class name.getDefaultValue(Class<?> hint) Returns the JavaScript default value of this object.Returns the DOM node that corresponds to this JavaScript object or throw an exception if one cannot be found.Returns the DOM node that corresponds to this JavaScript object or null if a node hasn't been set.org.htmlunit.corejs.javascript.ScriptablegetPrototype(Class<? extends HtmlUnitScriptable> javaScriptClass) Gets the prototype object for the given host class.protected HtmlUnitScriptablegetScriptableFor(Object object) Returns the JavaScript object that corresponds to the specified object.Gets the window that is the top scope for this object.protected static WindowgetWindow(org.htmlunit.corejs.javascript.Scriptable s) Gets the window that is the top scope for the specified object.protected static WindowOrWorkerGlobalScopegetWindowOrWorkerGlobalScope(org.htmlunit.corejs.javascript.Scriptable s) protected ObjectgetWithPreemption(String name) Called byget(String, Scriptable)to allow retrieval of the property before the prototype chain is searched.booleanhas(int index, org.htmlunit.corejs.javascript.Scriptable start) booleanhasInstance(org.htmlunit.corejs.javascript.Scriptable instance) makeScriptableFor(DomNode domNode) Builds a new the JavaScript object that corresponds to the specified object.voidvoidsetClassName(String className) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Sets the class name.voidsetDomNode(DomNode domNode) Sets the DOM node that corresponds to this JavaScript object.voidsetDomNode(DomNode domNode, boolean assignScriptObject) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Sets the DOM node that corresponds to this JavaScript object.protected org.htmlunit.corejs.javascript.NativePromisesetupPromise(FailableSupplier<Object, IOException> resolver) protected org.htmlunit.corejs.javascript.NativePromisesetupRejectedPromise(Supplier<Object> resolver) Methods inherited from class org.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkNotSealed, checkPropertyChangeForSlot, checkPropertyChangeForSlot, checkPropertyDefinition, checkPropertyDefinition, checkSlotRemoval, defineBuiltinProperty, defineBuiltinProperty, defineBuiltInProperty, defineBuiltInProperty, defineBuiltInProperty, defineBuiltInProperty, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureScriptableObjectButNotSymbol, ensureSymbolScriptable, ensureType, get, get, getAllIds, getAncestor, getArrayPrototype, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getSuperProperty, getSuperProperty, getSuperProperty, getThis, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, hasProperty, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGenericDescriptor, isGetterOrSetter, isGetterOrSetter, isTrue, preventExtensions, put, put, putConst, putConstProperty, putConstProperty, putOwnProperty, putOwnProperty, putOwnProperty, putProperty, putProperty, putProperty, putProperty, putSuperProperty, putSuperProperty, putSuperProperty, querySlot, redefineProperty, redefineProperty, sameValue, sealObject, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, sizeMethods inherited from class org.htmlunit.corejs.javascript.SlotMapOwner
associateValue, checkNotSealed, copyAssociatedValue, createSlotMap, defineProperty, defineProperty, get, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getIds, has, has, isSealed, readMaps, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, writeMapsMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.htmlunit.corejs.javascript.Scriptable
get, getIds, has, hasMethods inherited from interface org.htmlunit.corejs.javascript.SymbolScriptable
get, has
-
Constructor Details
-
HtmlUnitScriptable
public HtmlUnitScriptable()
-
-
Method Details
-
getClassName
Returns the JavaScript class name.- Specified by:
getClassNamein interfaceorg.htmlunit.corejs.javascript.Scriptable- Specified by:
getClassNamein classorg.htmlunit.corejs.javascript.ScriptableObject- Returns:
- the JavaScript class name
-
setClassName
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Sets the class name.- Parameters:
className- the class name.
-
put
- Specified by:
putin interfaceorg.htmlunit.corejs.javascript.PropHolder<org.htmlunit.corejs.javascript.Scriptable>- Specified by:
putin interfaceorg.htmlunit.corejs.javascript.Scriptable- Overrides:
putin classorg.htmlunit.corejs.javascript.ScriptableObject
-
get
Gets a named property from the object. Normally HtmlUnit objects don't need to overwrite this method as properties are defined on the prototypes. In some cases where "content" of object has priority compared to the properties consider using utilitygetWithPreemption(String).- Specified by:
getin interfaceorg.htmlunit.corejs.javascript.PropHolder<org.htmlunit.corejs.javascript.Scriptable>- Specified by:
getin interfaceorg.htmlunit.corejs.javascript.Scriptable- Overrides:
getin classorg.htmlunit.corejs.javascript.ScriptableObject
-
getWithPreemption
Called by
get(String, Scriptable)to allow retrieval of the property before the prototype chain is searched.IMPORTANT: This method is invoked *very* often by Rhino. If you override this method, the implementation needs to be as fast as possible!
- Parameters:
name- the property name- Returns:
Scriptable.NOT_FOUNDif not found
-
has
public boolean has(int index, org.htmlunit.corejs.javascript.Scriptable start) - Specified by:
hasin interfaceorg.htmlunit.corejs.javascript.PropHolder<org.htmlunit.corejs.javascript.Scriptable>- Specified by:
hasin interfaceorg.htmlunit.corejs.javascript.Scriptable- Overrides:
hasin classorg.htmlunit.corejs.javascript.ScriptableObject
-
getDomNodeOrDie
Returns the DOM node that corresponds to this JavaScript object or throw an exception if one cannot be found.- Returns:
- the DOM node
-
getDomNodeOrNull
Returns the DOM node that corresponds to this JavaScript object or null if a node hasn't been set.- Returns:
- the DOM node or null
-
setDomNode
Sets the DOM node that corresponds to this JavaScript object.- Parameters:
domNode- the DOM node
-
setDomNode
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Sets the DOM node that corresponds to this JavaScript object.- Parameters:
domNode- the DOM nodeassignScriptObject- If true, callsetScriptObjecton domNode
-
getScriptableFor
Returns the JavaScript object that corresponds to the specified object. New JavaScript objects will be created as needed. If a JavaScript object cannot be created for a domNode then NOT_FOUND will be returned. -
makeScriptableFor
Builds a new the JavaScript object that corresponds to the specified object.- Parameters:
domNode- the DOM node for which a JS object should be created- Returns:
- the JavaScript object
-
getPrototype
public org.htmlunit.corejs.javascript.Scriptable getPrototype(Class<? extends HtmlUnitScriptable> javaScriptClass) Gets the prototype object for the given host class.- Parameters:
javaScriptClass- the host class- Returns:
- the prototype
-
getDefaultValue
Returns the JavaScript default value of this object. This is the JavaScript equivalent of a toString() in Java.- Specified by:
getDefaultValuein interfaceorg.htmlunit.corejs.javascript.Scriptable- Overrides:
getDefaultValuein classorg.htmlunit.corejs.javascript.ScriptableObject- Parameters:
hint- a hint as to the format of the default value (ignored in this case)- Returns:
- the default value
-
getWindow
Gets the window that is the top scope for this object.- Returns:
- the window associated with this object
- Throws:
RuntimeException- if the window cannot be found, which should never occur
-
getWindow
protected static Window getWindow(org.htmlunit.corejs.javascript.Scriptable s) throws RuntimeException Gets the window that is the top scope for the specified object.- Parameters:
s- the JavaScript object whose associated window is to be returned- Returns:
- the window associated with the specified JavaScript object
- Throws:
RuntimeException- if the window cannot be found, which should never occur
-
getWindowOrWorkerGlobalScope
protected static WindowOrWorkerGlobalScope getWindowOrWorkerGlobalScope(org.htmlunit.corejs.javascript.Scriptable s) throws RuntimeException - Throws:
RuntimeException
-
getBrowserVersion
Gets the browser version currently used.- Returns:
- the browser version
-
hasInstance
public boolean hasInstance(org.htmlunit.corejs.javascript.Scriptable instance) - Specified by:
hasInstancein interfaceorg.htmlunit.corejs.javascript.Scriptable- Overrides:
hasInstancein classorg.htmlunit.corejs.javascript.ScriptableObject
-
equivalentValues
- Overrides:
equivalentValuesin classorg.htmlunit.corejs.javascript.ScriptableObject
-
clone
-
setupPromise
protected org.htmlunit.corejs.javascript.NativePromise setupPromise(FailableSupplier<Object, IOException> resolver) -
setupRejectedPromise
-