Package org.htmlunit.javascript
Class HtmlUnitScriptable
java.lang.Object
org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.javascript.HtmlUnitScriptable
- All Implemented Interfaces:
Serializable
,Cloneable
,org.htmlunit.corejs.javascript.ConstProperties
,org.htmlunit.corejs.javascript.debug.DebuggableObject
,org.htmlunit.corejs.javascript.Scriptable
,org.htmlunit.corejs.javascript.SymbolScriptable
- Direct Known Subclasses:
AbstractList
,AbstractRange
,Atomics
,AudioBuffer
,AudioListener
,AudioParam
,BarProp
,Blob
,Cache
,CacheStorage
,CanvasGradient
,CanvasPattern
,CanvasRenderingContext2D
,CaretPosition
,ClientRect
,ClientRectList
,Collator
,Credential
,CredentialsContainer
,Crypto
,CryptoKey
,CSS
,CSSRule
,CSSRuleList
,CSSStyleDeclaration
,CustomElementRegistry
,DataTransfer
,DataTransferItem
,DataTransferItemList
,DateTimeFormat
,DOMError
,DOMException
,DOMImplementation
,DOMMatrixReadOnly
,DOMParser
,DOMPointReadOnly
,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
,Location
,MediaDeviceInfo
,MediaError
,MediaKeys
,MediaKeyStatusMap
,MediaKeySystemAccess
,MediaList
,MessageChannel
,MIDIInputMap
,MIDIOutputMap
,MimeType
,MutationObserver
,MutationRecord
,NamedNodeMap
,Navigator
,Netscape
,NodeFilter
,NodeIterator
,NumberFormat
,Path2D
,PaymentAddress
,PerformanceEntry
,PerformanceNavigation
,PerformanceObserver
,PerformanceObserverEntryList
,PerformanceTiming
,PeriodicSyncManager
,PeriodicWave
,Permissions
,Presentation
,ProxyAutoConfig
,PushManager
,PushSubscription
,PushSubscriptionOptions
,ReadableStream
,Request
,Response
,RTCCertificate
,RTCIceCandidate
,RTCSessionDescription
,RTCStatsReport
,Selection
,SimpleArray
,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
,WebkitSpeechGrammar
,WebkitSpeechGrammarList
,XMLSerializer
,XPathEvaluator
,XPathExpression
,XPathNSResolver
,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).
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String
private DomNode
private static final org.apache.commons.logging.Log
Fields inherited from class org.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
Fields inherited from interface org.htmlunit.corejs.javascript.Scriptable
NOT_FOUND
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()
protected Object
equivalentValues
(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.Scriptable
getPrototype
(Class<? extends HtmlUnitScriptable> javaScriptClass) Gets the prototype object for the given host class.protected HtmlUnitScriptable
getScriptableFor
(Object object) Returns the JavaScript object that corresponds to the specified object.protected org.htmlunit.corejs.javascript.Scriptable
Gets the scriptable used at starting scope for the execution of current script.Gets the window that is the top scope for this object.protected static Window
getWindow
(org.htmlunit.corejs.javascript.Scriptable s) Gets the window that is the top scope for the specified object.protected Object
getWithPreemption
(String name) Called byget(String, Scriptable)
to allow retrieval of the property before the prototype chain is searched.boolean
has
(int index, org.htmlunit.corejs.javascript.Scriptable start) boolean
hasInstance
(org.htmlunit.corejs.javascript.Scriptable instance) protected void
initParentScope
(DomNode domNode, HtmlUnitScriptable scriptable) Initialize the parent scope of a newly created scriptable.makeScriptableFor
(DomNode domNode) Builds a new the JavaScript object that corresponds to the specified object.void
void
setClassName
(String className) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Sets the class name.void
setDomNode
(DomNode domNode) Sets the DOM node that corresponds to this JavaScript object.void
setDomNode
(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.void
setParentScope
(org.htmlunit.corejs.javascript.Scriptable m) protected Object
setupPromise
(org.apache.commons.lang3.function.FailableSupplier<Object, IOException> resolver) protected Object
setupRejectedPromise
(Supplier<Object> resolver) Methods inherited from class org.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, get, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, putProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setPrototype, size
-
Field Details
-
LOG
private static final org.apache.commons.logging.Log LOG -
domNode_
-
className_
-
-
Constructor Details
-
HtmlUnitScriptable
public HtmlUnitScriptable()
-
-
Method Details
-
getClassName
Returns the JavaScript class name.- Specified by:
getClassName
in interfaceorg.htmlunit.corejs.javascript.Scriptable
- Specified by:
getClassName
in 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.
-
setParentScope
public void setParentScope(org.htmlunit.corejs.javascript.Scriptable m) - Specified by:
setParentScope
in interfaceorg.htmlunit.corejs.javascript.Scriptable
- Overrides:
setParentScope
in classorg.htmlunit.corejs.javascript.ScriptableObject
-
put
- Specified by:
put
in interfaceorg.htmlunit.corejs.javascript.Scriptable
- Overrides:
put
in 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 from the XML configuration. In some cases where "content" of object has priority compared to the properties consider using utilitygetWithPreemption(String)
.- Specified by:
get
in interfaceorg.htmlunit.corejs.javascript.Scriptable
- Overrides:
get
in 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_FOUND
if not found
-
has
public boolean has(int index, org.htmlunit.corejs.javascript.Scriptable start) - Specified by:
has
in interfaceorg.htmlunit.corejs.javascript.Scriptable
- Overrides:
has
in 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, callsetScriptObject
on 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
-
initParentScope
Initialize the parent scope of a newly created scriptable.- Parameters:
domNode
- the DOM node for the script objectscriptable
- the script object to initialize
-
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:
getDefaultValue
in interfaceorg.htmlunit.corejs.javascript.Scriptable
- Overrides:
getDefaultValue
in 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
-
getStartingScope
protected org.htmlunit.corejs.javascript.Scriptable getStartingScope()Gets the scriptable used at starting scope for the execution of current script.- Returns:
- the scope as defined in
JavaScriptEngine.callFunction(org.htmlunit.html.HtmlPage, org.htmlunit.corejs.javascript.Function, org.htmlunit.corejs.javascript.Scriptable, java.lang.Object[], org.htmlunit.html.DomNode)
orJavaScriptEngine.execute(org.htmlunit.html.HtmlPage, org.htmlunit.corejs.javascript.Scriptable, java.lang.String, java.lang.String, int)
.
-
getBrowserVersion
Gets the browser version currently used.- Returns:
- the browser version
-
hasInstance
public boolean hasInstance(org.htmlunit.corejs.javascript.Scriptable instance) - Specified by:
hasInstance
in interfaceorg.htmlunit.corejs.javascript.Scriptable
- Overrides:
hasInstance
in classorg.htmlunit.corejs.javascript.ScriptableObject
-
equivalentValues
- Overrides:
equivalentValues
in classorg.htmlunit.corejs.javascript.ScriptableObject
-
clone
-
setupPromise
protected Object setupPromise(org.apache.commons.lang3.function.FailableSupplier<Object, IOException> resolver) -
setupRejectedPromise
-