com.gargoylesoftware.htmlunit.javascript.host
Class Window

java.lang.Object
  extended by org.mozilla.javascript.ScriptableObject
      extended by com.gargoylesoftware.htmlunit.javascript.SimpleScriptable
          extended by com.gargoylesoftware.htmlunit.javascript.host.Window
All Implemented Interfaces:
ScriptableWithFallbackGetter, java.io.Serializable, org.mozilla.javascript.ConstProperties, org.mozilla.javascript.debug.DebuggableObject, org.mozilla.javascript.Scriptable

public class Window
extends SimpleScriptable
implements ScriptableWithFallbackGetter

A JavaScript object for a Window.

Version:
$Revision: 1.3 $
Author:
Mike Bowler, Chen Jun, David K. Taylor, Christian Sell, Darrell DeBoer, Marc Guillemot, Dierk Koenig, Daniel Gredler, David D. Kilzer, Chris Erskine, Ahmed Ashour
See Also:
MSDN documentation, Serialized Form

Field Summary
 
Fields inherited from class org.mozilla.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
 
Fields inherited from interface org.mozilla.javascript.Scriptable
NOT_FOUND
 
Constructor Summary
Window(JavaScriptEngine scriptEngine)
 Creates an instance.
 
Method Summary
 java.lang.Object custom_eval(java.lang.String scriptCode)
 Executes the specified script code in the scope of this window.
 java.lang.Object get(java.lang.String name, org.mozilla.javascript.Scriptable start)
 Get a named property from the object.
 JavaScriptEngine getJavaScriptEngine()
 Gets the Javascript Engine responsible for this object.
 org.mozilla.javascript.Scriptable getPrototype(java.lang.Class jsClass)
 Returns the prototype object corresponding to the specified HtmlUnit class inside the window scope.
 WebWindow getWebWindow()
 Return the WebWindow associated with this Window
 java.lang.Object getWithFallback(java.lang.String name)
 Looks at attributes with the given name Fallback called when no configured property is found with the given name on the Scriptable object.
 void initialize()
 Initialize the object.
 void initialize(Page enclosedPage)
 Initialize the object.
 void initialize(WebWindow webWindow)
 Initialize the object.
 void jsxFunction_addEventListener(java.lang.String type, org.mozilla.javascript.Function listener, boolean useCapture)
 Allows the registration of event listeners on the event target
 void jsxFunction_alert(java.lang.Object message)
 The javascript function "alert()"
 boolean jsxFunction_attachEvent(java.lang.String type, org.mozilla.javascript.Function listener)
 Allows the registration of event listeners on the event target
 void jsxFunction_blur()
 Remove focus from this element
 void jsxFunction_captureEvents(java.lang.String type)
 Does nothing special anymore... just like FF
 void jsxFunction_clearInterval(int intervalID)
 Cancels the interval previously started using the setInterval method.
 void jsxFunction_clearTimeout(int timeoutId)
 Cancels a time-out previously set with the setTimeout method.
 void jsxFunction_close()
 Close this window
 boolean jsxFunction_confirm(java.lang.String message)
 The javascript function "confirm()"
static Popup jsxFunction_createPopup(org.mozilla.javascript.Context context, org.mozilla.javascript.Scriptable scriptable, java.lang.Object[] args, org.mozilla.javascript.Function function)
 Creates a popup window Open a new window
 void jsxFunction_detachEvent(java.lang.String type, org.mozilla.javascript.Function listener)
 Allows the removal of event listeners on the event target
 java.lang.Object jsxFunction_execScript(java.lang.String script, java.lang.String language)
 Executes the specified script code as long as the laguage is JavaScript or JScript.
 void jsxFunction_focus()
 Set the focus to this element.
 java.lang.Object jsxFunction_getComputedStyle(NodeImpl element, java.lang.String pseudoElt)
 Returns computed style of the element.
 void jsxFunction_moveBy(int x, int y)
 Does nothing.
 void jsxFunction_moveTo(int x, int y)
 Does nothing.
static java.lang.Object jsxFunction_open(org.mozilla.javascript.Context context, org.mozilla.javascript.Scriptable scriptable, java.lang.Object[] args, org.mozilla.javascript.Function function)
 Open a new window
 void jsxFunction_print()
 Prints the current page.
 java.lang.String jsxFunction_prompt(java.lang.String message)
 The javascript function "prompt()"
 void jsxFunction_removeEventListener(java.lang.String type, org.mozilla.javascript.Function listener, boolean useCapture)
 Allows the removal of event listeners on the event target
 void jsxFunction_resizeTo(int width, int height)
 Does nothing.
 void jsxFunction_scroll(int x, int y)
 Does nothing.
 void jsxFunction_scrollBy(int x, int y)
 Does nothing.
 void jsxFunction_scrollByLines(int lines)
 Does nothing.
 void jsxFunction_scrollByPages(int pages)
 Does nothing.
 void jsxFunction_scrollTo(int x, int y)
 Does nothing.
static int jsxFunction_setInterval(org.mozilla.javascript.Context context, org.mozilla.javascript.Scriptable scriptable, java.lang.Object[] args, org.mozilla.javascript.Function function)
 Set a chunk of javascript to be invoked each time a specified number of milliseconds has elapsed Current implementation does nothing.
static int jsxFunction_setTimeout(org.mozilla.javascript.Context context, org.mozilla.javascript.Scriptable scriptable, java.lang.Object[] args, org.mozilla.javascript.Function function)
 Set a chunk of javascript to be invoked at some specified time later.
 boolean jsxGet_closed()
 Indicates if this window is closed
 Document jsxGet_document()
 Return the javascript property "document"
 java.lang.Object jsxGet_event()
 Return the current event
 java.lang.Object jsxGet_frameElement()
 Return the (i)frame in which the window is contained.
 HTMLCollection jsxGet_frames()
 Return the value of the frames property.
 History jsxGet_history()
 Return the "history" property
 int jsxGet_innerHeight()
 Return the innerHeight.
 int jsxGet_innerWidth()
 Return the innerWidth.
 Location jsxGet_location()
 Return the location property
 java.lang.String jsxGet_name()
 Return the value of the name property
 Navigator jsxGet_navigator()
 Return the javascript property "navigator"
 java.lang.Object jsxGet_onclick()
 Return the onclick property (caution this is not necessary a function if something else has been set)
 java.lang.Object jsxGet_ondblclick()
 Return the ondblclick property (caution this is not necessary a function if something else has been set)
 java.lang.String jsxGet_onerror()
 Return the value of the onerror property
 java.lang.Object jsxGet_onload()
 Return the onload property (caution this is not necessary a function if something else has been set)
 java.lang.Object jsxGet_opener()
 Return the value of the opener property.
 int jsxGet_outerHeight()
 Return the outer height.
 int jsxGet_outerWidth()
 Return the outerWidth.
 SimpleScriptable jsxGet_parent()
 Return the value of the parent property
 Screen jsxGet_screen()
 Return the "screen" property
 Window jsxGet_self()
 Return the "self" property
 java.lang.String jsxGet_status()
 Return the text from the status line.
 SimpleScriptable jsxGet_top()
 Return the value of the top property
 Window jsxGet_window()
 Return the window property.
 void jsxSet_location(java.lang.String newLocation)
 Set the location property.
 void jsxSet_name(java.lang.String newName)
 Set the value of the newName property
 void jsxSet_onclick(java.lang.Object newOnload)
 Set the value of the onclick event handler.
 void jsxSet_ondblclick(java.lang.Object newHandler)
 Set the value of the ondblclick event handler.
 void jsxSet_onerror(java.lang.String newValue)
 Set the value of the onerror property
 void jsxSet_onload(java.lang.Object newOnload)
 Set the value of the onload event handler.
 void jsxSet_status(java.lang.String message)
 Set the text from the status line.
 void setEvent(java.lang.Object event)
 Sets the current event
 void setPrototypes(java.util.Map map)
 Sets the prototypes for HtmlUnit host classes
 
Methods inherited from class com.gargoylesoftware.htmlunit.javascript.SimpleScriptable
getBooleanArg, getClassName, getDefaultValue, getDomNodeOrDie, getDomNodeOrNull, getHtmlElementOrDie, getHtmlElementOrNull, getIntArg, getObjectArg, getStringArg, makeScriptableFor, setDomNode, setHtmlElement
 
Methods inherited from class org.mozilla.javascript.ScriptableObject
associateValue, avoidObjectDetection, callMethod, callMethod, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, get, getAllIds, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, has, has, hasInstance, hasProperty, hasProperty, isConst, isSealed, put, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setGetterOrSetter, setParentScope, setPrototype
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mozilla.javascript.Scriptable
delete, delete, get, getClassName, getDefaultValue, getIds, getParentScope, getPrototype, has, has, hasInstance, put, put, setParentScope, setPrototype
 

Constructor Detail

Window

public Window(JavaScriptEngine scriptEngine)
Creates an instance.

Parameters:
scriptEngine - The JavaScript engine responsible for the new window instance.
Method Detail

custom_eval

public java.lang.Object custom_eval(java.lang.String scriptCode)
Executes the specified script code in the scope of this window. This is used only when eval() is called on a Window other than the starting scope

Parameters:
scriptCode - some javascript code
Returns:
the evaluation result

get

public java.lang.Object get(java.lang.String name,
                            org.mozilla.javascript.Scriptable start)
Get 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 SimpleScriptable.getWithPreemption(String). For fallback case just implement ScriptableWithFallbackGetter.

Specified by:
get in interface org.mozilla.javascript.Scriptable
Overrides:
get in class SimpleScriptable

getJavaScriptEngine

public JavaScriptEngine getJavaScriptEngine()
Gets the Javascript Engine responsible for this object.

Returns:
the javascript engine

getPrototype

public org.mozilla.javascript.Scriptable getPrototype(java.lang.Class jsClass)
Returns the prototype object corresponding to the specified HtmlUnit class inside the window scope.

Parameters:
jsClass - the class whose prototype is to be returned
Returns:
the prototype object corresponding to the specified class inside the specified scope

getWebWindow

public WebWindow getWebWindow()
Return the WebWindow associated with this Window

Returns:
The WebWindow

getWithFallback

public java.lang.Object getWithFallback(java.lang.String name)
Looks at attributes with the given name Fallback called when no configured property is found with the given name on the Scriptable object.

Specified by:
getWithFallback in interface ScriptableWithFallbackGetter
Parameters:
name - the name of the requested property
Returns:
the object value, Scriptable.NOT_FOUND if nothing is found

initialize

public void initialize()
Initialize the object. Only call for Windows with no contents.


initialize

public void initialize(Page enclosedPage)
Initialize the object.

Parameters:
enclosedPage - The page containing the javascript.

initialize

public void initialize(WebWindow webWindow)
                throws java.lang.Exception
Initialize the object.

Parameters:
webWindow - The web window containing the javascript.
Throws:
java.lang.Exception - If an error occurs.

jsxFunction_addEventListener

public void jsxFunction_addEventListener(java.lang.String type,
                                         org.mozilla.javascript.Function listener,
                                         boolean useCapture)
Allows the registration of event listeners on the event target

Parameters:
type - the event type to listen for (like "onload")
listener - the event listener
useCapture - If true, indicates that the user wishes to initiate capture (not yet implemented)
See Also:
Mozilla documentation

jsxFunction_alert

public void jsxFunction_alert(java.lang.Object message)
The javascript function "alert()"

Parameters:
message - The message

jsxFunction_attachEvent

public boolean jsxFunction_attachEvent(java.lang.String type,
                                       org.mozilla.javascript.Function listener)
Allows the registration of event listeners on the event target

Parameters:
type - the event type to listen for (like "load")
listener - the event listener
Returns:
true if the listener has been added
See Also:
MSDN documentation

jsxFunction_blur

public void jsxFunction_blur()
Remove focus from this element


jsxFunction_captureEvents

public void jsxFunction_captureEvents(java.lang.String type)
Does nothing special anymore... just like FF

Parameters:
type - the type of events

jsxFunction_clearInterval

public void jsxFunction_clearInterval(int intervalID)
Cancels the interval previously started using the setInterval method. Current implementation does nothing.

Parameters:
intervalID - specifies the interval to cancel as returned by the setInterval method.
See Also:
MSDN documentation

jsxFunction_clearTimeout

public void jsxFunction_clearTimeout(int timeoutId)
Cancels a time-out previously set with the setTimeout method.

Parameters:
timeoutId - identifier for the timeout to clear (returned by setTimeout)

jsxFunction_close

public void jsxFunction_close()
Close this window


jsxFunction_confirm

public boolean jsxFunction_confirm(java.lang.String message)
The javascript function "confirm()"

Parameters:
message - The message
Returns:
true if ok was pressed, false if cancel was pressed

jsxFunction_createPopup

public static Popup jsxFunction_createPopup(org.mozilla.javascript.Context context,
                                            org.mozilla.javascript.Scriptable scriptable,
                                            java.lang.Object[] args,
                                            org.mozilla.javascript.Function function)
Creates a popup window Open a new window

Parameters:
context - The javascript Context
scriptable - The object that the function was called on.
args - The arguments passed to the function.
function - The function object that was invoked.
Returns:
The created popup
See Also:
MSDN documentation

jsxFunction_detachEvent

public void jsxFunction_detachEvent(java.lang.String type,
                                    org.mozilla.javascript.Function listener)
Allows the removal of event listeners on the event target

Parameters:
type - the event type to listen for (like "onload")
listener - the event listener
See Also:
MSDN documentation

jsxFunction_execScript

public java.lang.Object jsxFunction_execScript(java.lang.String script,
                                               java.lang.String language)
Executes the specified script code as long as the laguage is JavaScript or JScript. Does nothing if the language specified is VBScript.

Parameters:
script - the script code to execute
language - the language of the specified code ("JavaScript", "JScript" or "VBScript")
Returns:
this method always returns null, like Internet Explorer
See Also:
MSDN documentation

jsxFunction_focus

public void jsxFunction_focus()
Set the focus to this element.


jsxFunction_getComputedStyle

public java.lang.Object jsxFunction_getComputedStyle(NodeImpl element,
                                                     java.lang.String pseudoElt)
Returns computed style of the element. Computed style represents the final computed values of all CSS properties for the element. The current implementation returns the element 'style' property.

Parameters:
element - the element
pseudoElt - is a string specifying the pseudo-element to match, can be null.
Returns:
the computed style.

jsxFunction_moveBy

public void jsxFunction_moveBy(int x,
                               int y)
Does nothing.

Parameters:
x - The horizontal position
y - The vertical position

jsxFunction_moveTo

public void jsxFunction_moveTo(int x,
                               int y)
Does nothing.

Parameters:
x - The horizontal position
y - The vertical position

jsxFunction_open

public static java.lang.Object jsxFunction_open(org.mozilla.javascript.Context context,
                                                org.mozilla.javascript.Scriptable scriptable,
                                                java.lang.Object[] args,
                                                org.mozilla.javascript.Function function)
Open a new window

Parameters:
context - The javascript Context
scriptable - The object that the function was called on.
args - The arguments passed to the function.
function - The function object that was invoked.
Returns:
The newly opened window

jsxFunction_print

public void jsxFunction_print()
Prints the current page. Current implementation does nothing.

See Also:
Mozilla documentation, MSDN documentation

jsxFunction_prompt

public java.lang.String jsxFunction_prompt(java.lang.String message)
The javascript function "prompt()"

Parameters:
message - The message
Returns:
true if ok was pressed, false if cancel was pressed

jsxFunction_removeEventListener

public void jsxFunction_removeEventListener(java.lang.String type,
                                            org.mozilla.javascript.Function listener,
                                            boolean useCapture)
Allows the removal of event listeners on the event target

Parameters:
type - the event type to listen for (like "load")
listener - the event listener
useCapture - If true, indicates that the user wishes to initiate capture (not yet implemented)
See Also:
Mozilla documentation

jsxFunction_resizeTo

public void jsxFunction_resizeTo(int width,
                                 int height)
Does nothing.

Parameters:
width - The width of the Window in pixel after resize.
height - The height of the Window in pixel after resize.

jsxFunction_scroll

public void jsxFunction_scroll(int x,
                               int y)
Does nothing.

Parameters:
x - The horizontal position to scroll to
y - The vertical position to scroll to

jsxFunction_scrollBy

public void jsxFunction_scrollBy(int x,
                                 int y)
Does nothing.

Parameters:
x - The horizontal distance to scroll by
y - The vertical distance to scroll by

jsxFunction_scrollByLines

public void jsxFunction_scrollByLines(int lines)
Does nothing.

Parameters:
lines - The number of lines to scroll down

jsxFunction_scrollByPages

public void jsxFunction_scrollByPages(int pages)
Does nothing.

Parameters:
pages - The number of pages to scroll down

jsxFunction_scrollTo

public void jsxFunction_scrollTo(int x,
                                 int y)
Does nothing.

Parameters:
x - The horizontal position to scroll to
y - The vertical position to scroll to

jsxFunction_setInterval

public static int jsxFunction_setInterval(org.mozilla.javascript.Context context,
                                          org.mozilla.javascript.Scriptable scriptable,
                                          java.lang.Object[] args,
                                          org.mozilla.javascript.Function function)
Set a chunk of javascript to be invoked each time a specified number of milliseconds has elapsed Current implementation does nothing. JavaScript param 1: The code to execute, either a String or a Function. JavaScript param 2: the delay in milliseconds to wait before executing the code.

Parameters:
context - The javascript Context
scriptable - The object that the function was called on.
args - The arguments passed to the function.
function - The function object that was invoked.
Returns:
the id of the created interval
See Also:
MSDN documentation

jsxFunction_setTimeout

public static int jsxFunction_setTimeout(org.mozilla.javascript.Context context,
                                         org.mozilla.javascript.Scriptable scriptable,
                                         java.lang.Object[] args,
                                         org.mozilla.javascript.Function function)
Set a chunk of javascript to be invoked at some specified time later. The invocation occurs only if the window is opened after the delay and does not contain an other page than the one that originated the setTimeout. JavaScript param 1: The code to execute, either a String or a Function. JavaScript param 2: the delay in milliseconds to wait before executing the code.

Parameters:
context - The javascript Context
scriptable - The object that the function was called on.
args - The arguments passed to the function.
function - The function object that was invoked.
Returns:
the id of the created timer

jsxGet_closed

public boolean jsxGet_closed()
Indicates if this window is closed

Returns:
true if this window is closed

jsxGet_document

public Document jsxGet_document()
Return the javascript property "document"

Returns:
The document

jsxGet_event

public java.lang.Object jsxGet_event()
Return the current event

Returns:
null if no event is currently available

jsxGet_frameElement

public java.lang.Object jsxGet_frameElement()
Return the (i)frame in which the window is contained.

Returns:
null for a top level window

jsxGet_frames

public HTMLCollection jsxGet_frames()
Return the value of the frames property.

Returns:
The live collection of frames

jsxGet_history

public History jsxGet_history()
Return the "history" property

Returns:
the "history" property

jsxGet_innerHeight

public int jsxGet_innerHeight()
Return the innerHeight.

Returns:
a dummy value
See Also:
Mozilla doc

jsxGet_innerWidth

public int jsxGet_innerWidth()
Return the innerWidth.

Returns:
a dummy value
See Also:
Mozilla doc

jsxGet_location

public Location jsxGet_location()
Return the location property

Returns:
The location property

jsxGet_name

public java.lang.String jsxGet_name()
Return the value of the name property

Returns:
The window name

jsxGet_navigator

public Navigator jsxGet_navigator()
Return the javascript property "navigator"

Returns:
The document

jsxGet_onclick

public java.lang.Object jsxGet_onclick()
Return the onclick property (caution this is not necessary a function if something else has been set)

Returns:
the onclick property

jsxGet_ondblclick

public java.lang.Object jsxGet_ondblclick()
Return the ondblclick property (caution this is not necessary a function if something else has been set)

Returns:
the ondblclick property

jsxGet_onerror

public java.lang.String jsxGet_onerror()
Return the value of the onerror property

Returns:
The value

jsxGet_onload

public java.lang.Object jsxGet_onload()
Return the onload property (caution this is not necessary a function if something else has been set)

Returns:
the onload property

jsxGet_opener

public java.lang.Object jsxGet_opener()
Return the value of the opener property.

Returns:
the value of window.opener, null for a top level window

jsxGet_outerHeight

public int jsxGet_outerHeight()
Return the outer height.

Returns:
a dummy value
See Also:
Mozilla doc

jsxGet_outerWidth

public int jsxGet_outerWidth()
Return the outerWidth.

Returns:
a dummy value
See Also:
Mozilla doc

jsxGet_parent

public SimpleScriptable jsxGet_parent()
Return the value of the parent property

Returns:
the value of window.parent

jsxGet_screen

public Screen jsxGet_screen()
Return the "screen" property

Returns:
the screen property

jsxGet_self

public Window jsxGet_self()
Return the "self" property

Returns:
this

jsxGet_status

public java.lang.String jsxGet_status()
Return the text from the status line.

Returns:
the status line text

jsxGet_top

public SimpleScriptable jsxGet_top()
Return the value of the top property

Returns:
The value of "top"

jsxGet_window

public Window jsxGet_window()
Return the window property. This is a synonym for "self"

Returns:
A reference to this

jsxSet_location

public void jsxSet_location(java.lang.String newLocation)
                     throws java.io.IOException
Set the location property. This will cause a reload of the window.

Parameters:
newLocation - The url of the new content.
Throws:
java.io.IOException - when location loading fails

jsxSet_name

public void jsxSet_name(java.lang.String newName)
Set the value of the newName property

Parameters:
newName - The new window name

jsxSet_onclick

public void jsxSet_onclick(java.lang.Object newOnload)
Set the value of the onclick event handler.

Parameters:
newOnload - The new handler

jsxSet_ondblclick

public void jsxSet_ondblclick(java.lang.Object newHandler)
Set the value of the ondblclick event handler.

Parameters:
newHandler - The new handler

jsxSet_onerror

public void jsxSet_onerror(java.lang.String newValue)
Set the value of the onerror property

Parameters:
newValue - The value

jsxSet_onload

public void jsxSet_onload(java.lang.Object newOnload)
Set the value of the onload event handler.

Parameters:
newOnload - The new handler

jsxSet_status

public void jsxSet_status(java.lang.String message)
Set the text from the status line.

Parameters:
message - the status line text

setEvent

public void setEvent(java.lang.Object event)
Sets the current event

Parameters:
event - the event

setPrototypes

public void setPrototypes(java.util.Map map)
Sets the prototypes for HtmlUnit host classes

Parameters:
map - a Map of (Class, Scriptable)


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