|
From: <Gou...@ne...> - 2003-08-08 11:32:03
|
Hello All!
Im trying to write tests for a pretty reach WebApp using HtmlUnit and i found out that there are a lot of things missing for JavaScript support. Currently I'm trying to add them: some I could do, some not.
The list of issues is here:
1: It is not possible to execute JavaScript function that takes href from an anchor, puts it as action of the form and submits the form than.
This I could fix: there was one (or two) method missing in com.gargoylesoftware.htmlunit.javascript.host.Anchor
I've added:
import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
/**
* Return the value of the href property.
* @return The href property.
*/
public String jsGet_href() {
return ((HtmlAnchor)getHtmlElementOrDie()).getHrefAttribute();
}
/**
* Set the href property.
* Attention - this method was never tested!
* @param href href attribute value.
*/
public void jsSet_href( final String href ) {
//((HtmlAnchor)getHtmlElementOrDie()).setHrefAttribute(href);
//method setHrefAttribute is missing in API - think of to add it!
((HtmlAnchor)getHtmlElementOrDie()).getElement()
.setAttribute("href", href);
//workaround for missing setHrefAttribute method
//please check if it works
}
I did not neen jsSet_href method, so I didn't test it. It seems to be right and it compiles:)
jsGet_href is working an makes JavaScript execute right.
2: WindowOpen does not work (at least when JavaScript tries to set focus to the newely opened window).
I could not fix it, but I found out where the problem is:
com.gargoylesoftware.htmlunit.javascript.host.Window
public static Object jsFunction_open(...) executes perfect till the last line, where it tries to do following:
return (Window)newWebWindow.getScriptObject();
newWebWindow is a valid Object, but its getScriptObject() method returns null. So nothing else can be executed on the object returned from jsFunction_open, even jsFunction_focus() that does nothing.
I'm looking for a solution to set ScriptObject that is not null, that will be returned than by getScriptObject(). I guess something must create it ans than set it to the Window newWebWindow calling its setScriptObject() method.
Any idea?
3: I have a following line in JavaScript:
parent.<frame_name>.location.href=<some_value>;
this would produce following method calls stack (all in package com.gargoylesoftware.htmlunit.javascript.host):
jsGet_parent in Window
a call to get a frame by name - fails
jsGet_location in Window
jsGet_href in Location
All jsGet_XXX methods are doing right - I'm pretty sure.
I found out that the call to get frames is handled by
public Object get( final String name, final Scriptable start )
method in com.gargoylesoftware.htmlunit.javascript.SimpleScriptable, and it would even return a requested frame, if it would be set as a property.
But it is not set: I have modified the get method to print out some debug infos and found out, that SimpleScriptable stores all declared JavaScript functions as properties, but does not contain properties for frames.
I hope it is not much work to do something similar with frames as it is done with JavaScript functions. I would be obliged if someone would give me any idea what exactly should be done to fix it!
Best regards
Alexei Goussev
__________________________________________________________________
McAfee VirusScan Online from the Netscape Network.
Comprehensive protection for your entire computer. Get your free trial today!
http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397
Get AOL Instant Messenger 5.1 free of charge. Download Now!
http://aim.aol.com/aimnew/Aim/register.adp?promo=380455
|