Class HtmlUnitScriptable

    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject

        org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String className_  
      private DomNode domNode_  
      private static org.apache.commons.logging.Log 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
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      HtmlUnitScriptable clone()
      protected java.lang.Object equivalentValues​(java.lang.Object value)
      java.lang.Object get​(java.lang.String name, org.htmlunit.corejs.javascript.Scriptable start)
      Gets a named property from the object.
      BrowserVersion getBrowserVersion()
      Gets the browser version currently used.
      java.lang.String getClassName()
      Returns the JavaScript class name.
      java.lang.Object getDefaultValue​(java.lang.Class<?> hint)
      Returns the JavaScript default value of this object.
      DomNode getDomNodeOrDie()
      Returns the DOM node that corresponds to this JavaScript object or throw an exception if one cannot be found.
      DomNode getDomNodeOrNull()
      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​(java.lang.Class<? extends HtmlUnitScriptable> javaScriptClass)
      Gets the prototype object for the given host class.
      protected HtmlUnitScriptable getScriptableFor​(java.lang.Object object)
      Returns the JavaScript object that corresponds to the specified object.
      protected org.htmlunit.corejs.javascript.Scriptable getStartingScope()
      Gets the scriptable used at starting scope for the execution of current script.
      Window getWindow()
      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 java.lang.Object getWithPreemption​(java.lang.String name)
      Called by get(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.
      HtmlUnitScriptable makeScriptableFor​(DomNode domNode)
      Builds a new the JavaScript object that corresponds to the specified object.
      void put​(java.lang.String name, org.htmlunit.corejs.javascript.Scriptable start, java.lang.Object value)
      void setClassName​(java.lang.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 java.lang.Object setupPromise​(org.apache.commons.lang3.function.FailableSupplier<java.lang.Object,​java.io.IOException> resolver)  
      protected java.lang.Object setupRejectedPromise​(java.util.function.Supplier<java.lang.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
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOG

        private static final org.apache.commons.logging.Log LOG
      • domNode_

        private DomNode domNode_
      • className_

        private java.lang.String className_
    • Constructor Detail

      • HtmlUnitScriptable

        public HtmlUnitScriptable()
    • Method Detail

      • getClassName

        public java.lang.String getClassName()
        Returns the JavaScript class name.
        Specified by:
        getClassName in interface org.htmlunit.corejs.javascript.Scriptable
        Specified by:
        getClassName in class org.htmlunit.corejs.javascript.ScriptableObject
        Returns:
        the JavaScript class name
      • setClassName

        public void setClassName​(java.lang.String className)
        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 interface org.htmlunit.corejs.javascript.Scriptable
        Overrides:
        setParentScope in class org.htmlunit.corejs.javascript.ScriptableObject
      • put

        public void put​(java.lang.String name,
                        org.htmlunit.corejs.javascript.Scriptable start,
                        java.lang.Object value)
        Specified by:
        put in interface org.htmlunit.corejs.javascript.Scriptable
        Overrides:
        put in class org.htmlunit.corejs.javascript.ScriptableObject
      • get

        public java.lang.Object get​(java.lang.String name,
                                    org.htmlunit.corejs.javascript.Scriptable start)
        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 utility getWithPreemption(String).
        Specified by:
        get in interface org.htmlunit.corejs.javascript.Scriptable
        Overrides:
        get in class org.htmlunit.corejs.javascript.ScriptableObject
      • getWithPreemption

        protected java.lang.Object getWithPreemption​(java.lang.String name)

        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 interface org.htmlunit.corejs.javascript.Scriptable
        Overrides:
        has in class org.htmlunit.corejs.javascript.ScriptableObject
      • getDomNodeOrDie

        public DomNode 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

        public DomNode 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

        public void setDomNode​(DomNode domNode)
        Sets the DOM node that corresponds to this JavaScript object.
        Parameters:
        domNode - the DOM node
      • setDomNode

        public 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.
        Parameters:
        domNode - the DOM node
        assignScriptObject - If true, call setScriptObject on domNode
      • getScriptableFor

        protected HtmlUnitScriptable getScriptableFor​(java.lang.Object object)
        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.
        Parameters:
        object - a DomNode or a WebWindow
        Returns:
        the JavaScript object or NOT_FOUND
      • makeScriptableFor

        public HtmlUnitScriptable makeScriptableFor​(DomNode domNode)
        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

        protected void initParentScope​(DomNode domNode,
                                       HtmlUnitScriptable scriptable)
        Initialize the parent scope of a newly created scriptable.
        Parameters:
        domNode - the DOM node for the script object
        scriptable - the script object to initialize
      • getPrototype

        public org.htmlunit.corejs.javascript.Scriptable getPrototype​(java.lang.Class<? extends HtmlUnitScriptable> javaScriptClass)
        Gets the prototype object for the given host class.
        Parameters:
        javaScriptClass - the host class
        Returns:
        the prototype
      • getDefaultValue

        public java.lang.Object getDefaultValue​(java.lang.Class<?> hint)
        Returns the JavaScript default value of this object. This is the JavaScript equivalent of a toString() in Java.
        Specified by:
        getDefaultValue in interface org.htmlunit.corejs.javascript.Scriptable
        Overrides:
        getDefaultValue in class org.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

        public Window getWindow()
                         throws java.lang.RuntimeException
        Gets the window that is the top scope for this object.
        Returns:
        the window associated with this object
        Throws:
        java.lang.RuntimeException - if the window cannot be found, which should never occur
      • getWindow

        protected static Window getWindow​(org.htmlunit.corejs.javascript.Scriptable s)
                                   throws java.lang.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:
        java.lang.RuntimeException - if the window cannot be found, which should never occur
      • getBrowserVersion

        public BrowserVersion 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 interface org.htmlunit.corejs.javascript.Scriptable
        Overrides:
        hasInstance in class org.htmlunit.corejs.javascript.ScriptableObject
      • equivalentValues

        protected java.lang.Object equivalentValues​(java.lang.Object value)
        Overrides:
        equivalentValues in class org.htmlunit.corejs.javascript.ScriptableObject
      • setupPromise

        protected java.lang.Object setupPromise​(org.apache.commons.lang3.function.FailableSupplier<java.lang.Object,​java.io.IOException> resolver)
      • setupRejectedPromise

        protected java.lang.Object setupRejectedPromise​(java.util.function.Supplier<java.lang.Object> resolver)