Re: httpunit and Javascript

Russell Gold <[email protected]>
Newsgroups gmane.comp.web.httpunit.devel
Message-ID <[email protected]>
The DOM that HttpUnit uses should be fairly compliant with the  
standard. The difficulty right now is that the Javascript  
implementation at present is fairly cumbersome and requires a bunch of  
layers, so I have been refactoring towards a simpler one - but it's  
not there yet.

If you look at the top of HttpUnitOptions, you will see the following  
lines:


     private static final String ORIGINAL_SCRIPTING_ENGINE_FACTORY =  
"com.meterware.httpunit.javascript.JavaScriptEngineFactory";
     private static final String NEW_SCRIPTING_ENGINE_FACTORY =  
"com.meterware.httpunit.dom.DomBasedScriptingEngineFactory";

     final static public String DEFAULT_SCRIPT_ENGINE_FACTORY =  
ORIGINAL_SCRIPTING_ENGINE_FACTORY;

To switch to the new implementation, you need to change this last line  
to

     final static public String DEFAULT_SCRIPT_ENGINE_FACTORY =  
NEW_SCRIPTING_ENGINE_FACTORY;

A number of the Javascript tests will then fail. Once we have those  
working, the new factory will handle things like createElement  
naturally (in fact, it is already implemented). That does not mean  
that you cannot try adding things to the old implementation. As for  
documentation, I generally use the unit tests as operative  
documentation, as those are guaranteed to be correct; however, I can  
answer specific questions about the old implementation that you cannot  
figure out from the tests.


On Mar 27, 2008, at 3:17 AM, Wolfgang Fahl wrote:

> >
> > Now, what I want to do is to be able to have a javascript function  
> which
> > does a cloneNode() (which uses createElement()), updates some
> > properties (eg names and ids), called by a button click. Then, my  
> test
> > program would do a form submit, with parameters which include the  
> newly
> > created elements.
> >
> > To do this, we obviously need to add some methods in the JavaScript
> > class. I hacked around in there and added a  
> jsFunction_createElement()
> > method to Document, so that this test runs:
> >
> >  public void testCreateElement() throws Exception {
> >  defineResource("OnCommand.html",
> > "<html><head><title>Amazing!</title></head>" +
> > "<body onLoad='var
> > elem=document.createElement(\"input\");elem.id=\"hellothere 
> \";alert(elem
> > .id);'></body>" );
> >  WebConversation wc = new WebConversation();
> >  wc.getResponse( getHostPath() + "/OnCommand.html" );
> >  assertEquals( "Alert message", "hellothere", wc.popNextAlert()
> > );
> >  }
> >
> > I just made the createElement method create an HTMLElement for the
> > input. To make this work, I think I need to somehow connect this
> > HTMLElement to an HTMLInputElementImpl. Is there any overview
> > documentation on how the DOM works and how these things relate?
> >
> > If there is some documentation on this stuff I think I can play  
> around a
> > bit more before we talk. Otherwise, I will call you on Tuesday some
> > time.
>

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

_______________________________________________
Httpunit-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/httpunit-develop
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.