Package org.htmlunit.javascript
Interface AbstractJavaScriptEngine<SCRIPT>
-
- Type Parameters:
SCRIPT- the script type
- All Known Implementing Classes:
JavaScriptEngine
public interface AbstractJavaScriptEngine<SCRIPT>An interface forJavaScriptEngine.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description voidaddPostponedAction(PostponedAction action)Adds an action that should be executed first when the script currently being executed has finished.SCRIPTcompile(HtmlPage page, java.lang.String sourceCode, java.lang.String sourceName, int startLine)Deprecated.as of version 3.12.0; usecompile(HtmlPage, Scriptable, String, String, int)insteadSCRIPTcompile(HtmlPage owningPage, org.htmlunit.corejs.javascript.Scriptable scope, java.lang.String sourceCode, java.lang.String sourceName, int startLine)Compiles the specified JavaScript code in the context of a given scope.java.lang.Objectexecute(HtmlPage page, java.lang.String sourceCode, java.lang.String sourceName, int startLine)Deprecated.as of version 3.12.0; useexecute(HtmlPage, Scriptable, String, String, int)insteadjava.lang.Objectexecute(HtmlPage page, org.htmlunit.corejs.javascript.Scriptable scope, java.lang.String sourceCode, java.lang.String sourceName, int startLine)Executes the specified JavaScript code in the context of a given page.java.lang.Objectexecute(HtmlPage page, org.htmlunit.corejs.javascript.Scriptable scope, SCRIPT script)Executes the specified JavaScript code in the context of a given page.java.lang.Objectexecute(HtmlPage page, SCRIPT script)Deprecated.as of version 3.12.0; useexecute(HtmlPage, Scriptable, Object)insteadHtmlUnitContextFactorygetContextFactory()JavaScriptConfigurationgetJavaScriptConfiguration()Gets the associated configuration.longgetJavaScriptTimeout()Returns the number of milliseconds that a script is allowed to execute before being terminated.voidholdPosponedActions()INTERNAL 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 and page.booleanisScriptRunning()Indicates if JavaScript is running in current thread.voidprepareShutdown()Disable starting of new js threads.voidprocessPostponedActions()INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Process postponed actions, if any.voidregisterWindowAndMaybeStartEventLoop(WebWindow webWindow)Register WebWindow with the JavaScriptExecutor.voidsetJavaScriptTimeout(long timeout)Sets the number of milliseconds that a script is allowed to execute before being terminated.voidshutdown()Shutdown the JavaScriptEngine.
-
-
-
Method Detail
-
getJavaScriptConfiguration
JavaScriptConfiguration getJavaScriptConfiguration()
Gets the associated configuration.- Returns:
- the configuration
-
addPostponedAction
void addPostponedAction(PostponedAction action)
Adds an action that should be executed first when the script currently being executed has finished.- Parameters:
action- the action
-
processPostponedActions
void processPostponedActions()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Process postponed actions, if any.
-
registerWindowAndMaybeStartEventLoop
void registerWindowAndMaybeStartEventLoop(WebWindow webWindow)
Register WebWindow with the JavaScriptExecutor.- Parameters:
webWindow- the WebWindow to be registered.
-
initialize
void initialize(WebWindow webWindow, Page page)
Performs initialization for the given webWindow and page.- Parameters:
webWindow- the web window to initialize forpage- the page that will become the enclosing page
-
setJavaScriptTimeout
void setJavaScriptTimeout(long timeout)
Sets the number of milliseconds that a script is allowed to execute before being terminated. A value of 0 or less means no timeout.- Parameters:
timeout- the timeout value, in milliseconds
-
getJavaScriptTimeout
long getJavaScriptTimeout()
Returns the number of milliseconds that a script is allowed to execute before being terminated. A value of 0 or less means no timeout.- Returns:
- the timeout value, in milliseconds
-
prepareShutdown
void prepareShutdown()
Disable starting of new js threads.
-
shutdown
void shutdown()
Shutdown the JavaScriptEngine.
-
isScriptRunning
boolean isScriptRunning()
Indicates if JavaScript is running in current thread. This allows code to know if their own evaluation is has been triggered by some JS code.- Returns:
trueif JavaScript is running
-
holdPosponedActions
void holdPosponedActions()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Indicates that no postponed action should be executed.
-
compile
SCRIPT compile(HtmlPage owningPage, org.htmlunit.corejs.javascript.Scriptable scope, java.lang.String sourceCode, java.lang.String sourceName, int startLine)
Compiles the specified JavaScript code in the context of a given scope.- 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
-
compile
@Deprecated SCRIPT compile(HtmlPage page, java.lang.String sourceCode, java.lang.String sourceName, int startLine)
Deprecated.as of version 3.12.0; usecompile(HtmlPage, Scriptable, String, String, int)insteadCompiles the specified JavaScript code in the context of a given HTML page.- Parameters:
page- the page that the code will execute withinsourceCode- 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
java.lang.Object execute(HtmlPage page, org.htmlunit.corejs.javascript.Scriptable scope, SCRIPT script)
Executes the specified JavaScript code in the context of a given page.- 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
-
execute
@Deprecated java.lang.Object execute(HtmlPage page, SCRIPT script)
Deprecated.as of version 3.12.0; useexecute(HtmlPage, Scriptable, Object)insteadExecutes the specified JavaScript code in the context of a given page.- Parameters:
page- the page that the code will execute withinscript- the script to execute- Returns:
- the result of executing the specified code
-
execute
java.lang.Object execute(HtmlPage page, org.htmlunit.corejs.javascript.Scriptable scope, java.lang.String sourceCode, java.lang.String sourceName, int startLine)
Executes the specified JavaScript code in the context of a given page.- 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
@Deprecated java.lang.Object execute(HtmlPage page, java.lang.String sourceCode, java.lang.String sourceName, int startLine)
Deprecated.as of version 3.12.0; useexecute(HtmlPage, Scriptable, String, String, int)insteadExecutes the specified JavaScript code in the context of a given page.- Parameters:
page- the page that the code will execute withinsourceCode- 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
-
getContextFactory
HtmlUnitContextFactory getContextFactory()
- Returns:
- this JavaScript engine's
HtmlUnitContextFactory
-
-