com.gargoylesoftware.htmlunit.javascript
Class HtmlUnitContextFactory

java.lang.Object
  extended by org.mozilla.javascript.ContextFactory
      extended by com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory

public class HtmlUnitContextFactory
extends org.mozilla.javascript.ContextFactory

ContextFactory that supports termination of scripts if they exceed a timeout. Based on example from ContextFactory.

Version:
$Revision: 1.3 $
Author:
Andre Soereng

Nested Class Summary
 
Nested classes/interfaces inherited from class org.mozilla.javascript.ContextFactory
org.mozilla.javascript.ContextFactory.Listener
 
Constructor Summary
HtmlUnitContextFactory(org.apache.commons.logging.Log log)
 Create a new instance of HtmlUnitContextFactory
 
Method Summary
static boolean getDebuggerEnabled()
 Returns true if the debugger is enabled, false otherwise.
static long getTimeout()
 Returns the number of milliseconds a script is allowed to execute before being terminated.
static void setDebuggerEnabled(boolean enabled)
 Enables or disables the debugger, which logs stack entries and exceptions.
static void setTimeout(long timeout)
 Set the number of milliseconds a script is allowed to execute before being terminated.
 
Methods inherited from class org.mozilla.javascript.ContextFactory
addListener, call, enter, enterContext, enterContext, exit, getApplicationClassLoader, getGlobal, hasExplicitGlobal, initApplicationClassLoader, initGlobal, isSealed, removeListener, seal
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HtmlUnitContextFactory

public HtmlUnitContextFactory(org.apache.commons.logging.Log log)
Create a new instance of HtmlUnitContextFactory

Parameters:
log - the log that the error reporter should use
Method Detail

getDebuggerEnabled

public static boolean getDebuggerEnabled()
Returns true if the debugger is enabled, false otherwise.

Returns:
true if the debugger is enabled, false otherwise
See Also:
DebuggerImpl, DebugFrameImpl

getTimeout

public static long getTimeout()
Returns the number of milliseconds a script is allowed to execute before being terminated. A value of 0 or less means no timeout.

Returns:
the timeout value. Default value is 0.

setDebuggerEnabled

public static void setDebuggerEnabled(boolean enabled)
Enables or disables the debugger, which logs stack entries and exceptions. Enabling the debugger may be useful if HtmlUnit is having trouble with JavaScript, especially if you are using some of the more advanced libraries like Dojo, Prototype or jQuery.

Parameters:
enabled - whether or not the debugger should be enabled
See Also:
DebuggerImpl, DebugFrameImpl

setTimeout

public static void setTimeout(long timeout)
Set the number of milliseconds a script is allowed to execute before being terminated. A value of 0 or less means no timeout.

Parameters:
timeout - the timeout value


Copyright © 2003-2016 AppPerfect Corporation. All Rights Reserved.