java.lang.Object
org.htmlunit.javascript.JavaScriptEngine
- All Implemented Interfaces:
AbstractJavaScriptEngine<org.htmlunit.corejs.javascript.Script>
public class JavaScriptEngine
extends Object
implements AbstractJavaScriptEngine<org.htmlunit.corejs.javascript.Script>
A wrapper for the Rhino JavaScript engine
that provides browser specific features.
Like all classes in this package, this class is not intended for direct use and may change without notice.
- Author:
- Mike Bowler, Chen Jun, David K. Taylor, Chris Erskine, Ben Curren, David D. Kilzer, Marc Guillemot, Daniel Gredler, Ahmed Ashour, Amit Manjhi, Ronald Brill, Frank Danek, Lai Quang Duong, Sven Strickroth
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionJavaScriptEngine(WebClient webClient) Creates an instance for the specifiedWebClient. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPostponedAction(PostponedAction action) Adds an action that should be executed first when the script currently being executed has finished.static voidapplyPolyfills(WebClient webClient, BrowserVersion browserVersion, org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, HtmlUnitScriptable scriptable) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.static org.htmlunit.corejs.javascript.RhinoExceptionasJavaScriptException(HtmlUnitScriptable scriptable, String message, int type) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Creates aDOMExceptionand encapsulates it into a Rhino-compatible exception.callFunction(HtmlPage page, org.htmlunit.corejs.javascript.Function javaScriptFunction, org.htmlunit.corejs.javascript.Scriptable thisObject, Object[] args, DomNode node) Calls a JavaScript function and return the result.callFunction(HtmlPage page, org.htmlunit.corejs.javascript.Function function, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObject, Object[] args) Calls the given function taking care of synchronization issues.final <T> TcallSecured(org.htmlunit.corejs.javascript.ContextAction<T> action, HtmlPage page) Forwards this to theHtmlUnitContextFactorybut with checking shutdown handling.org.htmlunit.corejs.javascript.Scriptcompile(HtmlPage owningPage, org.htmlunit.corejs.javascript.VarScope scope, String sourceCode, String sourceName, int startLine) Compiles the specified JavaScript code in the context of a given scope.static HtmlUnitScriptableconfigureClass(ClassConfiguration config, org.htmlunit.corejs.javascript.TopLevel scope) Configures the specified class for access via JavaScript.static voidconfigureGlobalThis(org.htmlunit.corejs.javascript.TopLevel scope, HtmlUnitScriptable globalThis, ClassConfiguration scopeConfig, org.htmlunit.corejs.javascript.FunctionObject scopeContructorFunctionObject, AbstractJavaScriptConfiguration jsConfig, BrowserVersion browserVersion, Map<Class<? extends org.htmlunit.corejs.javascript.Scriptable>, org.htmlunit.corejs.javascript.Scriptable> prototypes, Map<String, org.htmlunit.corejs.javascript.Scriptable> prototypesPerJSName) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.static voidconfigureRhino(WebClient webClient, BrowserVersion browserVersion, org.htmlunit.corejs.javascript.TopLevel scope, HtmlUnitScriptable globalThis) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.static org.htmlunit.corejs.javascript.EcmaErrorconstructError(String error, String message) static StringevaluateProxyAutoConfig(BrowserVersion browserVersion, String content, URL url) Evaluates theFindProxyForURLmethod of the specified content.execute(HtmlPage page, org.htmlunit.corejs.javascript.VarScope scope, String sourceCode, String sourceName, int startLine) Executes the specified JavaScript code in the context of a given page.execute(HtmlPage page, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Script script) Executes the specified JavaScript code in the context of a given page.Class<? extends HtmlUnitScriptable>getJavaScriptClass(Class<?> c) Gets the class of the JavaScript object for the node class.Gets the associated configuration.Returns the JavaScriptExecutor.longReturns the javascript timeout.static org.htmlunit.corejs.javascript.TopLevelprotected voidhandleJavaScriptException(ScriptException scriptException, boolean triggerOnError) Handles an exception that occurred during execution of JavaScript code.protected voidHandles an exception that occurred during execution of JavaScript code.voidINTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Indicates that no postponed action should be executed.voidinitialize(WebWindow webWindow, Page page) Performs initialization for the given webWindow.static booleanstatic booleanisArrayLike(org.htmlunit.corejs.javascript.Scriptable obj) static booleanbooleanIndicates if JavaScript is running in current thread.static booleanisUndefined(Object obj) static voiditerateArrayLike(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.Scriptable arrayLike, Consumer<Object> consumer) Iterates an arrayLikeScriptablecalling theConsumeron every item.static longlengthOfArrayLike(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.Scriptable obj) static org.htmlunit.corejs.javascript.ScriptablenewArray(org.htmlunit.corejs.javascript.VarScope scope, int length) Create an array with a specified initial length.static org.htmlunit.corejs.javascript.ScriptableCreate an array with a specified initial length.static org.htmlunit.corejs.javascript.ScriptablenewArrayIteratorTypeEntries(org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable arrayLike) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Create a new ArrayIterator of type NativeArrayIterator.ARRAY_ITERATOR_TYPE.ENTRIESstatic org.htmlunit.corejs.javascript.ScriptablenewArrayIteratorTypeKeys(org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable arrayLike) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Create a new ArrayIterator of type NativeArrayIterator.ARRAY_ITERATOR_TYPE.KEYSstatic org.htmlunit.corejs.javascript.ScriptablenewArrayIteratorTypeValues(org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable arrayLike) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Create a new ArrayIterator of type NativeArrayIterator.ARRAY_ITERATOR_TYPE.VALUESstatic org.htmlunit.corejs.javascript.ScriptablenewObject(org.htmlunit.corejs.javascript.VarScope scope) Create a new JavaScript object.static org.htmlunit.corejs.javascript.ScriptableCreate a new javascript object by calling the ctor with the provided args.static org.htmlunit.corejs.javascript.typedarrays.NativeUint8ArraynewUint8Array(org.htmlunit.corejs.javascript.VarScope scope, byte[] elements) Create an Uint8Array with a specified elements.voidDisable starting of new js threads.voidINTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Process postponed actions, if any.static org.htmlunit.corejs.javascript.EcmaErrorrangeError(String message) Report a runtime error using the error reporter for the current thread.voidregisterWindowAndMaybeStartEventLoop(WebWindow webWindow) Register WebWindow with the JavaScriptExecutor.static RuntimeExceptionreportRuntimeError(String message) Report a runtime error using the error reporter for the current thread.static voidsetFunctionProtoAndParent(org.htmlunit.corejs.javascript.BaseFunction fn, org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.VarScope scope) Todo.voidsetJavaScriptTimeout(long timeout) Sets the javascript timeout.voidshutdown()Shutdown the JavaScriptEngine.static org.htmlunit.corejs.javascript.EcmaErrorsyntaxError(String message) Report a runtime error using the error reporter for the current thread.static RuntimeExceptionRethrow the exception wrapping it as the script runtime exception.static booleanConvert the value to a JavaScript boolean value.static intstatic doublestatic doublestatic doubleConvert the value to a JavaScript Number value.static StringConvert the value to a JavaScript String value.static org.htmlunit.corejs.javascript.EcmaErrorReport a runtime error using the error reporter for the current thread.static org.htmlunit.corejs.javascript.EcmaErrorReport a TypeError with the message "Illegal constructor.".static StringuncompressJavaScript(String scriptSource, String scriptName) Tries to uncompress the JavaScript code in the provided response.
-
Field Details
-
EMPTY_ARGS
ScriptRuntime.emptyArgs. -
UNDEFINED
org.htmlunit.corejs.javascript.Undefined.instance. -
KEY_STARTING_PAGE
Key used to place theHtmlPagefor which the JavaScript code is executed as thread local attribute in current context.- See Also:
-
-
Constructor Details
-
JavaScriptEngine
Creates an instance for the specifiedWebClient.- Parameters:
webClient- the client that will own this engine
-
-
Method Details
-
getContextFactory
- Specified by:
getContextFactoryin interfaceAbstractJavaScriptEngine<org.htmlunit.corejs.javascript.Script>- Returns:
- this JavaScript engine's
HtmlUnitContextFactory
-
initialize
Performs initialization for the given webWindow.- Specified by:
initializein interfaceAbstractJavaScriptEngine<org.htmlunit.corejs.javascript.Script>- Parameters:
webWindow- the web window to initialize forpage- the page that will become the enclosing page
-
getJavaScriptExecutor
Returns the JavaScriptExecutor.- Returns:
- the JavaScriptExecutor or null if javascript is disabled or no executor was required so far.
-
configureGlobalThis
public static void configureGlobalThis(org.htmlunit.corejs.javascript.TopLevel scope, HtmlUnitScriptable globalThis, ClassConfiguration scopeConfig, org.htmlunit.corejs.javascript.FunctionObject scopeContructorFunctionObject, AbstractJavaScriptConfiguration jsConfig, BrowserVersion browserVersion, Map<Class<? extends org.htmlunit.corejs.javascript.Scriptable>, org.htmlunit.corejs.javascript.Scriptable> prototypes, Map<String, throws Exceptionorg.htmlunit.corejs.javascript.Scriptable> prototypesPerJSName) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.- Parameters:
scope- the scopeglobalThis- the globalThis to set upscopeConfig- theClassConfigurationthat is used for the scopescopeContructorFunctionObject- the (already registered) ctorjsConfig- the complete jsConfigbrowserVersion- theBrowserVersionprototypes- map of prototypesprototypesPerJSName- map of prototypes with the class name as key- Throws:
Exception- in case of error
-
configureRhino
public static void configureRhino(WebClient webClient, BrowserVersion browserVersion, org.htmlunit.corejs.javascript.TopLevel scope, HtmlUnitScriptable globalThis) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.- Parameters:
webClient- the WebClientbrowserVersion- the BrowserVersionscope- the scopeglobalThis- the window or the DedicatedWorkerGlobalScope
-
applyPolyfills
public static void applyPolyfills(WebClient webClient, BrowserVersion browserVersion, org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, HtmlUnitScriptable scriptable) throws IOException INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.- Parameters:
webClient- the WebClientbrowserVersion- the BrowserVersioncontext- the current contextscope- the scopescriptable- the window or the DedicatedWorkerGlobalScope- Throws:
IOException- in case of problems
-
configureClass
public static HtmlUnitScriptable configureClass(ClassConfiguration config, org.htmlunit.corejs.javascript.TopLevel scope) throws Exception Configures the specified class for access via JavaScript.- Parameters:
config- the configuration settings for the class to be configuredscope- the scope to configure within which to configure the class- Returns:
- the created prototype
- Throws:
InstantiationException- if the new class cannot be instantiatedIllegalAccessException- if we don't have access to create the new instanceException- in case of errors
-
registerWindowAndMaybeStartEventLoop
Register WebWindow with the JavaScriptExecutor.- Specified by:
registerWindowAndMaybeStartEventLoopin interfaceAbstractJavaScriptEngine<org.htmlunit.corejs.javascript.Script>- Parameters:
webWindow- the WebWindow to be registered.
-
prepareShutdown
public void prepareShutdown()Disable starting of new js threads.- Specified by:
prepareShutdownin interfaceAbstractJavaScriptEngine<org.htmlunit.corejs.javascript.Script>
-
shutdown
public void shutdown()Shutdown the JavaScriptEngine.- Specified by:
shutdownin interfaceAbstractJavaScriptEngine<org.htmlunit.corejs.javascript.Script>
-
compile
public org.htmlunit.corejs.javascript.Script compile(HtmlPage owningPage, org.htmlunit.corejs.javascript.VarScope scope, String sourceCode, String sourceName, int startLine) Compiles the specified JavaScript code in the context of a given scope.- Specified by:
compilein interfaceAbstractJavaScriptEngine<org.htmlunit.corejs.javascript.Script>- Parameters:
owningPage- the page from which the code startedscope- the scope in which to execute the javascript codesourceCode- the JavaScript code to executesourceName- the name that will be displayed on error conditionsstartLine- the line at which the script source starts- Returns:
- the result of executing the specified code
-
callSecured
public final <T> T callSecured(org.htmlunit.corejs.javascript.ContextAction<T> action, HtmlPage page) Forwards this to theHtmlUnitContextFactorybut with checking shutdown handling.- Type Parameters:
T- return type of the action- Parameters:
action- the contextActionpage- the page- Returns:
- the result of the call
-
execute
public Object execute(HtmlPage page, org.htmlunit.corejs.javascript.VarScope scope, String sourceCode, String sourceName, int startLine) Executes the specified JavaScript code in the context of a given page.- Specified by:
executein interfaceAbstractJavaScriptEngine<org.htmlunit.corejs.javascript.Script>- Parameters:
page- the page that the code will execute withinscope- the scope in which to executesourceCode- the JavaScript code to executesourceName- the name that will be displayed on error conditionsstartLine- the line at which the script source starts- Returns:
- the result of executing the specified code
-
execute
public Object execute(HtmlPage page, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Script script) Executes the specified JavaScript code in the context of a given page.- Specified by:
executein interfaceAbstractJavaScriptEngine<org.htmlunit.corejs.javascript.Script>- Parameters:
page- the page that the code will execute withinscope- the scope in which to executescript- the script to execute- Returns:
- the result of executing the specified code
-
callFunction
public Object callFunction(HtmlPage page, org.htmlunit.corejs.javascript.Function javaScriptFunction, org.htmlunit.corejs.javascript.Scriptable thisObject, Object[] args, DomNode node) Calls a JavaScript function and return the result.- Parameters:
page- the pagejavaScriptFunction- the function to callthisObject- the this object for class method callsargs- the list of arguments to pass to the functionnode- the HTML element that will act as the context- Returns:
- the result of the function call
-
callFunction
public Object callFunction(HtmlPage page, org.htmlunit.corejs.javascript.Function function, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObject, Object[] args) Calls the given function taking care of synchronization issues.- Parameters:
page- the interactive page that caused this script to executedfunction- the JavaScript function to executescope- the execution scopethisObject- the 'this' objectargs- the function's arguments- Returns:
- the function result
-
isScriptRunning
public boolean isScriptRunning()Indicates if JavaScript is running in current thread.This allows code to know if their own evaluation has been triggered by some JS code.
- Specified by:
isScriptRunningin interfaceAbstractJavaScriptEngine<org.htmlunit.corejs.javascript.Script>- Returns:
trueif JavaScript is running
-
addPostponedAction
Adds an action that should be executed first when the script currently being executed has finished.- Specified by:
addPostponedActionin interfaceAbstractJavaScriptEngine<org.htmlunit.corejs.javascript.Script>- Parameters:
action- the action
-
handleJavaScriptException
Handles an exception that occurred during execution of JavaScript code.- Parameters:
scriptException- the exceptiontriggerOnError- if true, this triggers the onerror handler
-
handleJavaScriptTimeoutError
Handles an exception that occurred during execution of JavaScript code.- Parameters:
page- the page in which the script causing this exception was executede- the timeout error that was thrown from the script engine
-
holdPosponedActions
public void holdPosponedActions()INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Indicates that no postponed action should be executed.- Specified by:
holdPosponedActionsin interfaceAbstractJavaScriptEngine<org.htmlunit.corejs.javascript.Script>
-
processPostponedActions
public void processPostponedActions()INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Process postponed actions, if any.- Specified by:
processPostponedActionsin interfaceAbstractJavaScriptEngine<org.htmlunit.corejs.javascript.Script>
-
getJavaScriptClass
Gets the class of the JavaScript object for the node class.- Parameters:
c- the node classDomNodeor some subclass.- Returns:
nullif none found
-
getJavaScriptConfiguration
Gets the associated configuration.- Specified by:
getJavaScriptConfigurationin interfaceAbstractJavaScriptEngine<org.htmlunit.corejs.javascript.Script>- Returns:
- the configuration
-
getJavaScriptTimeout
public long getJavaScriptTimeout()Returns the javascript timeout.- Specified by:
getJavaScriptTimeoutin interfaceAbstractJavaScriptEngine<org.htmlunit.corejs.javascript.Script>- Returns:
- the javascript timeout
-
setJavaScriptTimeout
public void setJavaScriptTimeout(long timeout) Sets the javascript timeout.- Specified by:
setJavaScriptTimeoutin interfaceAbstractJavaScriptEngine<org.htmlunit.corejs.javascript.Script>- Parameters:
timeout- the timeout
-
toNumber
Convert the value to a JavaScript Number value.- Parameters:
value- a JavaScript value- Returns:
- the corresponding double value converted using the ECMA rules
-
toString
Convert the value to a JavaScript String value.- Parameters:
value- a JavaScript value- Returns:
- the corresponding String value converted using the ECMA rules
-
toBoolean
Convert the value to a JavaScript boolean value.- Parameters:
value- a JavaScript value- Returns:
- the corresponding boolean value converted using the ECMA rules
-
throwAsScriptRuntimeEx
Rethrow the exception wrapping it as the script runtime exception.- Parameters:
e- the exception to rethrow- Returns:
- RuntimeException as dummy the method always throws
-
reportRuntimeError
Report a runtime error using the error reporter for the current thread.- Parameters:
message- the error message to report- Returns:
- RuntimeException as dummy the method always throws
-
syntaxError
Report a runtime error using the error reporter for the current thread.- Parameters:
message- the error message to report- Returns:
- EcmaError
-
typeError
Report a runtime error using the error reporter for the current thread.- Parameters:
message- the error message to report- Returns:
- EcmaError
-
typeErrorIllegalConstructor
public static org.htmlunit.corejs.javascript.EcmaError typeErrorIllegalConstructor()Report a TypeError with the message "Illegal constructor.".- Returns:
- EcmaError
-
rangeError
Report a runtime error using the error reporter for the current thread.- Parameters:
message- the error message to report- Returns:
- EcmaError
-
constructError
- Parameters:
error- the errormessage- the message- Returns:
- a new EcmaError
-
asJavaScriptException
public static org.htmlunit.corejs.javascript.RhinoException asJavaScriptException(HtmlUnitScriptable scriptable, String message, int type) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Creates aDOMExceptionand encapsulates it into a Rhino-compatible exception.- Parameters:
scriptable- the scriptable triggering thismessage- the exception messagetype- the exception type- Returns:
- the created exception
-
setFunctionProtoAndParent
public static void setFunctionProtoAndParent(org.htmlunit.corejs.javascript.BaseFunction fn, org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.VarScope scope) Todo.- Parameters:
fn- the functioncx- the contextscope- the scope
-
newObject
public static org.htmlunit.corejs.javascript.Scriptable newObject(org.htmlunit.corejs.javascript.VarScope scope, String constructorName, Object[] args) Create a new javascript object by calling the ctor with the provided args.- Parameters:
scope- the scope to create the object inconstructorName- the name of the ctor function to callargs- the args- Returns:
- the new object
-
newObject
public static org.htmlunit.corejs.javascript.Scriptable newObject(org.htmlunit.corejs.javascript.VarScope scope) Create a new JavaScript object.Equivalent to evaluating "new Object()".
- Parameters:
scope- the scope to search for the constructor and to evaluate against- Returns:
- the new object
-
newArray
public static org.htmlunit.corejs.javascript.Scriptable newArray(org.htmlunit.corejs.javascript.VarScope scope, int length) Create an array with a specified initial length.- Parameters:
scope- the scope to create the object inlength- the initial length (JavaScript arrays may have additional properties added dynamically).- Returns:
- the new array object
-
newArrayIteratorTypeKeys
public static org.htmlunit.corejs.javascript.Scriptable newArrayIteratorTypeKeys(org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable arrayLike) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Create a new ArrayIterator of type NativeArrayIterator.ARRAY_ITERATOR_TYPE.KEYS- Parameters:
scope- the scope to create the object inarrayLike- the backend- Returns:
- the new NativeArrayIterator
-
newArrayIteratorTypeValues
public static org.htmlunit.corejs.javascript.Scriptable newArrayIteratorTypeValues(org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable arrayLike) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Create a new ArrayIterator of type NativeArrayIterator.ARRAY_ITERATOR_TYPE.VALUES- Parameters:
scope- the scope to create the object inarrayLike- the backend- Returns:
- the new NativeArrayIterator
-
newArrayIteratorTypeEntries
public static org.htmlunit.corejs.javascript.Scriptable newArrayIteratorTypeEntries(org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable arrayLike) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Create a new ArrayIterator of type NativeArrayIterator.ARRAY_ITERATOR_TYPE.ENTRIES- Parameters:
scope- the scope to create the object inarrayLike- the backend- Returns:
- the new NativeArrayIterator
-
newArray
public static org.htmlunit.corejs.javascript.Scriptable newArray(org.htmlunit.corejs.javascript.VarScope scope, Object[] elements) Create an array with a specified initial length.- Parameters:
scope- the scope to create the object inelements- the initial elements. Each object in this array must be an acceptable JavaScript type and type of array should be exactly Object[], not SomeObjectSubclass[].- Returns:
- the new array object
-
newUint8Array
public static org.htmlunit.corejs.javascript.typedarrays.NativeUint8Array newUint8Array(org.htmlunit.corejs.javascript.VarScope scope, byte[] elements) Create an Uint8Array with a specified elements.- Parameters:
scope- the scope to create the object inelements- the initial elements..- Returns:
- the new Uint8Array
-
toInt32
- Parameters:
o- the object to convert- Returns:
- int value
-
toInteger
- Parameters:
o- the object to convert- Returns:
- double value
-
toInteger
- Parameters:
args- an arrayindex- the index in the array- Returns:
- double value
-
isUndefined
- Parameters:
obj- the value to check- Returns:
- whether obj is undefined
-
isNaN
- Parameters:
obj- the value to check- Returns:
- whether obj is NAN
-
isArray
- Parameters:
obj- the value to check- Returns:
- whether obj is an Array
-
isArrayLike
public static boolean isArrayLike(org.htmlunit.corejs.javascript.Scriptable obj) - Parameters:
obj- the value to check- Returns:
- true if the passed in
Scriptablelooks like an array
-
lengthOfArrayLike
public static long lengthOfArrayLike(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.Scriptable obj) - Parameters:
cx- the Contextobj- the value to check- Returns:
- the length of the array like
Scriptable
-
iterateArrayLike
public static void iterateArrayLike(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.Scriptable arrayLike, Consumer<Object> consumer) Iterates an arrayLikeScriptablecalling theConsumeron every item.- Parameters:
cx- the context orObjectUtils.NullarrayLike- theScriptableto iterateconsumer- theConsumerto call
-
getTopCallScope
public static org.htmlunit.corejs.javascript.TopLevel getTopCallScope()- Returns:
- the top call scope
-
uncompressJavaScript
Tries to uncompress the JavaScript code in the provided response.- Parameters:
scriptSource- the soucescriptName- the name- Returns:
- the uncompressed JavaScript code
-
evaluateProxyAutoConfig
public static String evaluateProxyAutoConfig(BrowserVersion browserVersion, String content, URL url) Evaluates theFindProxyForURLmethod of the specified content.- Parameters:
browserVersion- the browser version to usecontent- the JavaScript contenturl- the URL to be retrieved- Returns:
- semicolon-separated result
-