httpunit-commit Mailing List for httpunit (Page 58)
Brought to you by:
russgold
You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(5) |
Sep
(31) |
Oct
(39) |
Nov
(18) |
Dec
(6) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(8) |
Feb
(5) |
Mar
(8) |
Apr
(25) |
May
(20) |
Jun
(23) |
Jul
(28) |
Aug
(10) |
Sep
(3) |
Oct
(32) |
Nov
(61) |
Dec
(24) |
2002 |
Jan
(50) |
Feb
(34) |
Mar
(35) |
Apr
(3) |
May
(25) |
Jun
(25) |
Jul
(30) |
Aug
(146) |
Sep
(49) |
Oct
(156) |
Nov
(121) |
Dec
(54) |
2003 |
Jan
(12) |
Feb
(79) |
Mar
(88) |
Apr
(26) |
May
(67) |
Jun
(29) |
Jul
(8) |
Aug
(16) |
Sep
(20) |
Oct
(17) |
Nov
|
Dec
(5) |
2004 |
Jan
|
Feb
(40) |
Mar
(30) |
Apr
(5) |
May
|
Jun
(83) |
Jul
(34) |
Aug
(20) |
Sep
(44) |
Oct
(46) |
Nov
|
Dec
(14) |
2005 |
Jan
(4) |
Feb
|
Mar
(5) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(4) |
Oct
|
Nov
|
Dec
(1) |
2006 |
Jan
|
Feb
|
Mar
(26) |
Apr
(8) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(5) |
Nov
|
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
(36) |
May
(38) |
Jun
(1) |
Jul
(1) |
Aug
|
Sep
(4) |
Oct
|
Nov
(18) |
Dec
(4) |
2009 |
Jan
|
Feb
(2) |
Mar
(3) |
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
(35) |
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
(9) |
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(21) |
Oct
(18) |
Nov
(1) |
Dec
|
From: Russell G. <rus...@us...> - 2002-08-06 21:42:11
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv1938/src/com/meterware/httpunit Modified Files: HTMLPage.java WebTable.java Log Message: Hans-Joerg Hessmann: Speed up table searches Index: HTMLPage.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLPage.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- HTMLPage.java 5 Aug 2002 17:34:25 -0000 1.4 +++ HTMLPage.java 6 Aug 2002 21:42:08 -0000 1.5 @@ -84,7 +84,6 @@ * <code> * <link type="text/css" rel="stylesheet" href="/mystyle.css" /> * </code> - * @author <a href="mailto:bx...@bi...">Benoit Xhenseval</a> **/ public String getExternalStyleSheet() throws SAXException { NodeList nl = ((Document) getOriginalDOM()).getElementsByTagName( "link" ); Index: WebTable.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebTable.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- WebTable.java 1 Aug 2002 14:58:59 -0000 1.17 +++ WebTable.java 6 Aug 2002 21:42:08 -0000 1.18 @@ -395,10 +395,13 @@ static void processChildren( Element root, String childTag, String avoidingParentTag, ElementHandler handler ) { - NodeList nl = root.getElementsByTagName( childTag ); - for (int i = 0; i < nl.getLength(); i++) { - if (isMoreCloselyNested( nl.item(i), root, avoidingParentTag )) { - handler.handleElement( (Element) nl.item(i) ); + + for (Node child = root.getFirstChild(); child != null; child = child.getNextSibling()) { + if (child instanceof Element) { + Element element = (Element) child; + String name = child.getNodeName(); + if (name.equalsIgnoreCase( childTag )) handler.handleElement( element ); + if (!name.equalsIgnoreCase( avoidingParentTag )) processChildren( element, childTag, avoidingParentTag, handler ); } } } |
From: Russell G. <rus...@us...> - 2002-08-06 21:42:11
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory usw-pr-cvs1:/tmp/cvs-serv1938/test/com/meterware/httpunit/javascript Modified Files: ScriptingTest.java Log Message: Hans-Joerg Hessmann: Speed up table searches Index: ScriptingTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- ScriptingTest.java 6 Aug 2002 19:14:59 -0000 1.8 +++ ScriptingTest.java 6 Aug 2002 21:42:08 -0000 1.9 @@ -304,6 +304,4 @@ } - - } |
From: Russell G. <rus...@us...> - 2002-08-06 21:42:11
|
Update of /cvsroot/httpunit/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv1938 Modified Files: build.xml Log Message: Hans-Joerg Hessmann: Speed up table searches Index: build.xml =================================================================== RCS file: /cvsroot/httpunit/httpunit/build.xml,v retrieving revision 1.44 retrieving revision 1.45 diff -u -r1.44 -r1.45 --- build.xml 24 Jul 2002 21:05:51 -0000 1.44 +++ build.xml 6 Aug 2002 21:42:08 -0000 1.45 @@ -27,7 +27,7 @@ <property name="archive.dir" value="${dist.dir}/${name}-${version}" /> <property name="classpath" value="" /> <property name="web.dir" value="web" /> - <property name="packages" value="com.meterware.*" /> + <property name="packages" value="com.meterware.httpunit,com.meterware.servletunit" /> <property name="test.class" value="com.meterware.httpunit.HttpUnitSuite" /> <property name="servlet.test.class" value="com.meterware.servletunit.ServletUnitSuite" /> |
From: Russell G. <rus...@us...> - 2002-08-06 21:42:11
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv1938/doc Modified Files: Javascript-support.html release_notes.txt Log Message: Hans-Joerg Hessmann: Speed up table searches Index: Javascript-support.html =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/Javascript-support.html,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Javascript-support.html 6 Aug 2002 19:39:17 -0000 1.1 +++ Javascript-support.html 6 Aug 2002 21:42:08 -0000 1.2 @@ -89,4 +89,7 @@ <li>checked - read/write - the state of the checkbox</li> </ul> +</body> +</html> + Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.130 retrieving revision 1.131 diff -u -r1.130 -r1.131 --- release_notes.txt 6 Aug 2002 19:14:53 -0000 1.130 +++ release_notes.txt 6 Aug 2002 21:42:08 -0000 1.131 @@ -13,6 +13,12 @@ Revision History: 6-Aug-2002 +Acknowledgements: + Thanks to Hans-Joerg Hessmann for a faster algorithm for the table lookups + +Problems fixed: + 1. Table lookups should be faster, especially for complex and large tables + Additions: 1. JavaScript: the link.onClick event is now supported 2. JavaScript: the form.onSubmit event is now supported |
From: Russell G. <rus...@us...> - 2002-08-06 19:39:21
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv4669/doc Added Files: Javascript-support.html Log Message: Added documentation on JavaScript support --- NEW FILE --- <html> <head><title>JavaScript Support</title></head> <body> <p> JavaScript support is very basic at present. Inline deferred scripts (which define functions) are supported, as are the following DOM elements: <h3>Window</h3> <h4>properties</h4> <ul> <li>document - the associated Document object</li> <li>self - the Window itself</li> <li>window - a synonym for self</li> </ul> <h4>events</h4> <ul> <li>onLoad - invoked when the page is loaded</li> </ul> <h4>methods</h4> <ul> <li>alert() - queues up an alert message, accessible via WebResponse.getNextAlert() or popNextAlert()</li> </ul> <h3>Document</h3> <h4>properties</h4> <ul> <li>forms - an array of Form objects</li> <li>images - an array of Image objects</li> <li>links - an array of Link objects</li> <li>title - readonly. The title of the page</li> <li><name> - the name of a form, image, or link</li> </ul> <h3>Form</h3> <h4>properties</h4> <ul> <li>document - the enclosing document</li> <li><name> - the name of a control in the form</li> </ul> <h4>events</h4> <ul> <li>onSubmit - invoked when the form.submit() is invoked</li> </ul> <h3>Image</h3> <h4>properties</h4> <ul> <li>src - read/write - the relative URL of the image</li> </ul> <h3>Link</h3> <h4>properties</h4> <ul> <li>href - readonly - the URL associated with the link</li> </ul> <h4>events</h4> <ul> <li>onClick - invoked when link.click() is invoked</li> <li>onMouseOver - invoked when link.mouseOver() is invoked<li> </ul> <h3>Text</h3> <h4>properties</h4> <ul> <li>value - read/write - the current text value</li> </ul> <h3>TextArea</h3> <h4>properties</h4> <ul> <li>value - read/write - the current text value</li> </ul> <h3>Hidden</h3> <h4>properties</h4> <ul> <li>value - read/write - the current text value</li> </ul> <h3>Password</h3> <h4>properties</h4> <ul> <li>value - read/write - the current text value</li> </ul> <h3>Checkbox</h3> <h4>properties</h4> <ul> <li>checked - read/write - the state of the checkbox</li> </ul> |
From: Russell G. <rus...@us...> - 2002-08-06 19:15:28
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv24182/doc Modified Files: release_notes.txt Log Message: Added support for link.onClick and form.onSubmit events Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.129 retrieving revision 1.130 diff -u -r1.129 -r1.130 --- release_notes.txt 5 Aug 2002 19:42:52 -0000 1.129 +++ release_notes.txt 6 Aug 2002 19:14:53 -0000 1.130 @@ -12,6 +12,11 @@ Revision History: + 6-Aug-2002 +Additions: + 1. JavaScript: the link.onClick event is now supported + 2. JavaScript: the form.onSubmit event is now supported + 5-Aug-2002 Additions: 1. The JavaScript link.href attribute is now readable. |
From: Russell G. <rus...@us...> - 2002-08-06 19:15:05
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory usw-pr-cvs1:/tmp/cvs-serv24182/test/com/meterware/httpunit/javascript Modified Files: ScriptingTest.java Log Message: Added support for link.onClick and form.onSubmit events Index: ScriptingTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- ScriptingTest.java 5 Aug 2002 19:42:52 -0000 1.7 +++ ScriptingTest.java 6 Aug 2002 19:14:59 -0000 1.8 @@ -146,8 +146,8 @@ defineResource( "OnCommand.html", "<html><head></head>" + "<body>" + "<form name='realform'><input type='checkbox' name='ready'></form>" + - "<a href='#' name='clear' onMouseOver=\"document.realform.ready.checked=false;\">clear</a>" + - "<a href='#' name='set' onMouseOver=\"document.realform.ready.checked=true;\">set</a>" + + "<a href='#' name='clear' onMouseOver='document.realform.ready.checked=false;'>clear</a>" + + "<a href='#' name='set' onMouseOver='document.realform.ready.checked=true;'>set</a>" + "</body></html>" ); WebConversation wc = new WebConversation(); WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); @@ -164,7 +164,7 @@ defineResource( "OnCommand.html", "<html><head></head>" + "<body>" + "<form name='realform'><input name='color' value='blue'></form>" + - "<a href='#' onMouseOver=\"document.realform.color.value='green';\">green</a>" + + "<a href='#' onMouseOver=\"document.realform.color.value='green';return false;\">green</a>" + "</body></html>" ); WebConversation wc = new WebConversation(); WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); @@ -176,6 +176,67 @@ } + public void testLinkClickEvent() throws Exception { + defineResource( "OnCommand.html", "<html><head></head>" + + "<body>" + + "<form name='realform'><input name='color' value='blue'></form>" + + "<a href='nothing.html' onClick=\"document.realform.color.value='green';return false;\">green</a>" + + "</body></html>" ); + WebConversation wc = new WebConversation(); + WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); + WebForm form = response.getFormWithName( "realform" ); + WebLink link = response.getLinks()[0]; + assertEquals( "initial parameter value", "blue", form.getParameterValue( "color" ) ); + link.click(); + assertEquals( "changed parameter value", "green", form.getParameterValue( "color" ) ); + } + + + public void testHashDestinationOnEvent() throws Exception { + defineResource( "OnCommand.html", "<html><head></head>" + + "<body>" + + "<form name='realform'><input name='color' value='blue'></form>" + + "<a href='#' onClick=\"document.realform.color.value='green';\">green</a>" + + "</body></html>" ); + WebConversation wc = new WebConversation(); + WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); + WebForm form = response.getFormWithName( "realform" ); + WebLink link = response.getLinks()[0]; + assertEquals( "initial parameter value", "blue", form.getParameterValue( "color" ) ); + response = link.click(); + assertEquals( "changed parameter value", "green", response.getFormWithName( "realform" ).getParameterValue( "color" ) ); + } + + + public void testFormValidationOnSubmit() throws Exception { + defineResource( "doIt?color=pink", "You got it!", "text/plain" ); + defineResource( "OnCommand.html", "<html><head><script language='JavaScript'>" + + "function verifyForm() { " + + " if (document.realform.color.value == 'pink') {" + + " return true;" + + " } else {" + + " alert( 'wrong color' );" + + " return false;" + + " }" + + "}" + + "</script></head>" + + "<body>" + + "<form name='realform' action='doIt' onSubmit='return verifyForm();'>" + + " <input name='color' value='blue'>" + + "</form>" + + "</body></html>" ); + WebConversation wc = new WebConversation(); + WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); + WebForm form = response.getFormWithName( "realform" ); + form.submit(); + assertEquals( "Alert message", "wrong color", response.popNextAlert() ); + assertSame( "Current response", response, wc.getCurrentPage() ); + form.setParameter( "color", "pink" ); + WebResponse newResponse = form.submit(); + assertEquals( "Result of submit", "You got it!", newResponse.getText() ); + } + + public void testLinkIndexes() throws Exception { defineResource( "OnCommand.html", "<html><head><script language='JavaScript'>" + "function alertLinks() { " + @@ -225,6 +286,7 @@ assertEquals( "Alert message", "2nd image is pict2.gif", response.popNextAlert() ); assertNull( "Alert should have been removed", response.getNextAlert() ); } + public void testImageSwap() throws Exception { defineResource( "OnCommand.html", "<html><head></head>" + |
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv24182/src/com/meterware/httpunit Modified Files: ScriptEngine.java ScriptableObject.java WebForm.java WebLink.java WebRequestSource.java WebResponse.java Log Message: Added support for link.onClick and form.onSubmit events Index: ScriptEngine.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ScriptEngine.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ScriptEngine.java 24 Jul 2002 20:54:31 -0000 1.1 +++ ScriptEngine.java 6 Aug 2002 19:14:54 -0000 1.2 @@ -31,4 +31,7 @@ public void executeScript( String script ); + + public boolean performEvent( String eventScript ); + } Index: ScriptableObject.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ScriptableObject.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ScriptableObject.java 24 Jul 2002 20:54:31 -0000 1.2 +++ ScriptableObject.java 6 Aug 2002 19:14:55 -0000 1.3 @@ -33,9 +33,19 @@ /** * Executes the specified scripted event. **/ - public void doEvent( String eventScript ) { + public boolean doEvent( String eventScript ) { if (_scriptEngine == null) throw new IllegalStateException( "Script engine must be defined before running an event" ); - _scriptEngine.executeScript( eventScript ); + if (eventScript.length() == 0) return true; + return _scriptEngine.performEvent( eventScript ); + } + + + /** + * Executes the specified script. + **/ + public void runScript( String script ) { + if (_scriptEngine == null) throw new IllegalStateException( "Script engine must be defined before running an event" ); + _scriptEngine.executeScript( script ); } Index: WebForm.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v retrieving revision 1.53 retrieving revision 1.54 diff -u -r1.53 -r1.54 --- WebForm.java 5 Aug 2002 15:20:50 -0000 1.53 +++ WebForm.java 6 Aug 2002 19:14:55 -0000 1.54 @@ -47,7 +47,9 @@ * Submits this form using the web client from which it was originally obtained. **/ public WebResponse submit() throws IOException, SAXException { - return submitRequest(); + String event = NodeUtils.getNodeAttribute( getNode(), "onsubmit" ); + if (event.length() == 0 || getScriptableObject().doEvent( event )) return submitRequest(); + return getBaseResponse(); } @@ -285,7 +287,8 @@ * Returns an object which provides scripting access to this form. **/ public Scriptable getScriptableObject() { - return new Scriptable(); + if (_scriptable == null) _scriptable = new Scriptable(); + return _scriptable; } //---------------------------------- WebRequestSource methods -------------------------------- @@ -452,6 +455,9 @@ /** A map of parameter names to form parameter objects. **/ private Map _formParameters; + + /** The Scriptable object associated with this form. **/ + private Scriptable _scriptable; private Vector _buttonVector; Index: WebLink.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebLink.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- WebLink.java 5 Aug 2002 15:21:19 -0000 1.22 +++ WebLink.java 6 Aug 2002 19:14:56 -0000 1.23 @@ -79,7 +79,9 @@ * Submits a request as though the user had clicked on this link. Will also fire the 'onClick' event if defined. **/ public WebResponse click() throws IOException, SAXException { - return submitRequest(); + String event = NodeUtils.getNodeAttribute( getNode(), "onclick" ); + if (event.length() == 0 || getScriptableObject().doEvent( event )) return submitRequest(); + return getBaseResponse(); } Index: WebRequestSource.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequestSource.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- WebRequestSource.java 5 Aug 2002 15:20:51 -0000 1.10 +++ WebRequestSource.java 6 Aug 2002 19:14:56 -0000 1.11 @@ -174,7 +174,18 @@ **/ final protected WebResponse submitRequest() throws IOException, SAXException { - return _baseResponse.getClient().sendRequest( getRequest() ); + return getDestination().equals( "#" ) + ? _baseResponse + : _baseResponse.getClient().sendRequest( getRequest() ); + } + + + /** + * Returns the web response containing this request source. + */ + final + protected WebResponse getBaseResponse() { + return _baseResponse; } Index: WebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v retrieving revision 1.71 retrieving revision 1.72 diff -u -r1.71 -r1.72 --- WebResponse.java 5 Aug 2002 17:34:25 -0000 1.71 +++ WebResponse.java 6 Aug 2002 19:14:57 -0000 1.72 @@ -501,7 +501,7 @@ public void load() throws SAXException { - doEvent( getReceivedPage().getScripts() ); + runScript( getReceivedPage().getScripts() ); doEvent( getReceivedPage().getOnLoadEvent() ); } } |
From: Russell G. <rus...@us...> - 2002-08-06 19:15:03
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript In directory usw-pr-cvs1:/tmp/cvs-serv24182/src/com/meterware/httpunit/javascript Modified Files: JavaScript.java Log Message: Added support for link.onClick and form.onSubmit events Index: JavaScript.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- JavaScript.java 5 Aug 2002 18:58:43 -0000 1.5 +++ JavaScript.java 6 Aug 2002 19:14:59 -0000 1.6 @@ -29,13 +29,7 @@ import java.lang.reflect.InvocationTargetException; import java.util.Arrays; -import org.mozilla.javascript.ClassDefinitionException; -import org.mozilla.javascript.Context; -import org.mozilla.javascript.JavaScriptException; -import org.mozilla.javascript.NotAFunctionException; -import org.mozilla.javascript.PropertyException; -import org.mozilla.javascript.Scriptable; -import org.mozilla.javascript.ScriptableObject; +import org.mozilla.javascript.*; import org.xml.sax.SAXException; @@ -45,6 +39,9 @@ **/ public class JavaScript { + private final static Object[] NO_ARGS = new Object[0]; + + /** * Initiates JavaScript execution for the specified web response. */ @@ -86,10 +83,24 @@ } + public boolean performEvent( String eventScript ) { + try { + final Context context = Context.getCurrentContext(); + Function f = context.compileFunction( this, "function x() { " + eventScript + "}", "httpunit", 0, null ); + Object result = f.call( context, this, null, NO_ARGS ); + return (result instanceof Boolean) ? ((Boolean) result).booleanValue() : true; + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException( "Script '" + eventScript + "' failed: " + e ); + } + } + + void initialize( JavaScriptEngine parent, com.meterware.httpunit.ScriptableObject scriptable ) throws JavaScriptException, NotAFunctionException, PropertyException, SAXException { _scriptable = scriptable; _scriptable.setScriptEngine( this ); + if (parent != null) setParentScope( parent ); } @@ -170,7 +181,7 @@ void initialize( JavaScriptEngine parent, com.meterware.httpunit.ScriptableObject scriptable ) throws JavaScriptException, NotAFunctionException, PropertyException, SAXException { - super.initialize( this, scriptable ); + super.initialize( parent, scriptable ); _document = (Document) Context.getCurrentContext().newObject( this, "Document" ); _document.initialize( this, getDelegate().getDocument() ); @@ -208,7 +219,7 @@ void initialize( JavaScriptEngine parent, com.meterware.httpunit.ScriptableObject scriptable ) throws JavaScriptException, NotAFunctionException, PropertyException, SAXException { - super.initialize( this, scriptable ); + super.initialize( parent, scriptable ); initializeLinks(); initializeForms(); initializeImages(); |
From: Russell G. <rus...@us...> - 2002-08-05 19:42:57
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory usw-pr-cvs1:/tmp/cvs-serv11224/test/com/meterware/httpunit/javascript Modified Files: ScriptingTest.java Log Message: Added support for checkbox.clicked property Index: ScriptingTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- ScriptingTest.java 5 Aug 2002 18:58:43 -0000 1.6 +++ ScriptingTest.java 5 Aug 2002 19:42:52 -0000 1.7 @@ -142,6 +142,24 @@ } + public void testCheckboxSetChecked() throws Exception { + defineResource( "OnCommand.html", "<html><head></head>" + + "<body>" + + "<form name='realform'><input type='checkbox' name='ready'></form>" + + "<a href='#' name='clear' onMouseOver=\"document.realform.ready.checked=false;\">clear</a>" + + "<a href='#' name='set' onMouseOver=\"document.realform.ready.checked=true;\">set</a>" + + "</body></html>" ); + WebConversation wc = new WebConversation(); + WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); + WebForm form = response.getFormWithName( "realform" ); + assertEquals( "initial parameter value", null, form.getParameterValue( "ready" ) ); + response.getLinkWithName( "set" ).mouseOver(); + assertEquals( "changed parameter value", "on", form.getParameterValue( "ready" ) ); + response.getLinkWithName( "clear" ).mouseOver(); + assertEquals( "final parameter value", null, form.getParameterValue( "ready" ) ); + } + + public void testLinkMouseOverEvent() throws Exception { defineResource( "OnCommand.html", "<html><head></head>" + "<body>" + |
From: Russell G. <rus...@us...> - 2002-08-05 19:42:57
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv11224/src/com/meterware/httpunit Modified Files: FormControl.java Log Message: Added support for checkbox.clicked property Index: FormControl.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/FormControl.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- FormControl.java 1 Aug 2002 20:23:15 -0000 1.13 +++ FormControl.java 5 Aug 2002 19:42:52 -0000 1.14 @@ -449,6 +449,32 @@ } + public ScriptableObject getScriptableObject() { + return new Scriptable(); + } + + + class Scriptable extends FormControl.Scriptable { + + public Object get( String propertyName ) { + if (propertyName.equalsIgnoreCase( "checked" )) { + return isChecked() ? Boolean.TRUE : Boolean.FALSE; + } else { + return super.get( propertyName ); + } + } + + + public void set( String propertyName, Object value ) { + if (propertyName.equalsIgnoreCase( "checked" )) { + setChecked( value instanceof Boolean && ((Boolean) value).booleanValue() ); + } else { + super.set( propertyName, value ); + } + } + } + + String getQueryValue() { final String value = getValueAttribute(); return value.length() == 0 ? "on" : value; |
From: Russell G. <rus...@us...> - 2002-08-05 19:42:57
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv11224/doc Modified Files: release_notes.txt Log Message: Added support for checkbox.clicked property Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.128 retrieving revision 1.129 diff -u -r1.128 -r1.129 --- release_notes.txt 5 Aug 2002 18:58:41 -0000 1.128 +++ release_notes.txt 5 Aug 2002 19:42:52 -0000 1.129 @@ -19,6 +19,7 @@ 3. JavaScript: The image.src property is read-write 4. WebResponse now has a getImageWithName method 5. JavaScript execution is now automatic. It may be enabled or disable via HttpUnitOptions + 6. JavaScript: the checkbox.clicked property is read-write Problems fixed: A form request created after a call to getScriptableObject().setAction() now correctly uses the new action. |
From: Russell G. <rus...@us...> - 2002-08-05 18:58:47
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory usw-pr-cvs1:/tmp/cvs-serv24279/test/com/meterware/httpunit/javascript Modified Files: ScriptingTest.java Log Message: Initiate JavaScript automatically Index: ScriptingTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ScriptingTest.java 5 Aug 2002 17:34:25 -0000 1.5 +++ ScriptingTest.java 5 Aug 2002 18:58:43 -0000 1.6 @@ -56,7 +56,6 @@ "<body onLoad='alert(\"Ouch!\")'></body>" ); WebConversation wc = new WebConversation(); WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); - JavaScript.run( response ); assertNotNull( "No alert detected", response.getNextAlert() ); assertEquals( "Alert message", "Ouch!", response.popNextAlert() ); assertNull( "Alert should have been removed", response.getNextAlert() ); @@ -72,7 +71,6 @@ "<body onLoad='sayCheese()'></body>" ); WebConversation wc = new WebConversation(); WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); - JavaScript.run( response ); assertEquals( "Alert message", "Cheese!", response.popNextAlert() ); } @@ -82,7 +80,6 @@ "<body onLoad='alert(\"Window title is \" + document.title)'></body>" ); WebConversation wc = new WebConversation(); WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); - JavaScript.run( response ); assertEquals( "Alert message", "Window title is Amazing!", response.popNextAlert() ); } @@ -102,7 +99,6 @@ "</body></html>" ); WebConversation wc = new WebConversation(); WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); - JavaScript.run( response ); assertEquals( "Alert message", "found 1 form(s)", response.popNextAlert() ); assertEquals( "Alert message", "found form 'realform'", response.popNextAlert() ); assertEquals( "Alert message", "did not find form 'noform'", response.popNextAlert() ); @@ -127,7 +123,6 @@ "</body></html>" ); WebConversation wc = new WebConversation(); WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); - JavaScript.run( response ); assertEquals( "Alert message", "found 2 link(s)", response.popNextAlert() ); assertEquals( "Alert message", "found link 'reallink'", response.popNextAlert() ); assertEquals( "Alert message", "did not find link 'nolink'", response.popNextAlert() ); @@ -142,7 +137,6 @@ "</body></html>" ); WebConversation wc = new WebConversation(); WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); - JavaScript.run( response ); WebForm form = response.getFormWithName( "realform" ); assertEquals( "color parameter value", "green", form.getParameterValue( "color" ) ); } @@ -156,7 +150,6 @@ "</body></html>" ); WebConversation wc = new WebConversation(); WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); - JavaScript.run( response ); WebForm form = response.getFormWithName( "realform" ); WebLink link = response.getLinks()[0]; assertEquals( "initial parameter value", "blue", form.getParameterValue( "color" ) ); @@ -183,7 +176,6 @@ "</body></html>" ); WebConversation wc = new WebConversation(); WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); - JavaScript.run( response ); assertEquals( "Alert message", getHostPath() + "/demo.html", response.popNextAlert() ); assertEquals( "Alert message", getHostPath() + "/guide.html", response.popNextAlert() ); assertEquals( "Alert message", getHostPath() + "/search.html", response.popNextAlert() ); @@ -209,7 +201,6 @@ "</body></html>" ); WebConversation wc = new WebConversation(); WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); - JavaScript.run( response ); assertEquals( "Alert message", "found 2 images(s)", response.popNextAlert() ); assertEquals( "Alert message", "found image 'realimage'", response.popNextAlert() ); assertEquals( "Alert message", "did not find image 'noimage'", response.popNextAlert() ); @@ -225,7 +216,6 @@ "</body></html>" ); WebConversation wc = new WebConversation(); WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); - JavaScript.run( response ); WebImage image = response.getImageWithName( "theImage" ); WebLink link = response.getLinks()[0]; assertEquals( "initial image source", "initial.gif", image.getSource() ); |
From: Russell G. <rus...@us...> - 2002-08-05 18:58:47
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv24279/src/com/meterware/httpunit Modified Files: FrameHolder.java HttpUnitOptions.java Added Files: ScriptingEngineFactory.java Log Message: Initiate JavaScript automatically ***** Error reading new file[Errno 2] No such file or directory: 'ScriptingEngineFactory.java' Index: FrameHolder.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/FrameHolder.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- FrameHolder.java 1 Aug 2002 14:58:59 -0000 1.2 +++ FrameHolder.java 5 Aug 2002 18:58:43 -0000 1.3 @@ -72,6 +72,7 @@ createSubFrames( response.getTarget(), response.getFrameNames() ); WebRequest[] requests = response.getFrameRequests(); for (int i = 0; i < requests.length; i++) _client.getResponse( requests[ i ] ); + HttpUnitOptions.getScriptingEngine().associate( response ); } } Index: HttpUnitOptions.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpUnitOptions.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- HttpUnitOptions.java 26 Jun 2002 15:48:56 -0000 1.21 +++ HttpUnitOptions.java 5 Aug 2002 18:58:43 -0000 1.22 @@ -31,6 +31,9 @@ **/ public abstract class HttpUnitOptions { + final static public String DEFAULT_SCRIPT_ENGINE_FACTORY = "com.meterware.httpunit.javascript.JavaScriptEngineFactory"; + + /** * Resets all options to their default values. */ @@ -50,6 +53,8 @@ _postIncludesCharset = false; _acceptGzip = true; _acceptCookies = true; + setScriptEngineClassName( DEFAULT_SCRIPT_ENGINE_FACTORY ); + setScriptingEnabled( true ); } @@ -351,11 +356,69 @@ return _listeners; } + + public static String getScriptEngineClassName() { + return _scriptEngineClassName; + } + + + public static void setScriptEngineClassName( String scriptEngineClassName ) { + if (_scriptEngineClassName == null || !_scriptEngineClassName.equals( scriptEngineClassName )) { + _scriptingEngine = null; + } + _scriptEngineClassName = scriptEngineClassName; + } + + + public static ScriptingEngineFactory getScriptingEngine() { + if (_scriptingEngine == null) { + try { + Class factoryClass = Class.forName( _scriptEngineClassName ); + _scriptingEngine = (ScriptingEngineFactory) factoryClass.newInstance(); + } catch (ClassNotFoundException e) { + disableScripting( e, "Unable to find scripting engine factory class " ); + } catch (InstantiationException e) { + disableScripting( e, "Unable to instantiate scripting engine factory class " ); + } catch (IllegalAccessException e) { + disableScripting( e, "Unable to create scripting engine factory class " ); + } + } + return _scriptingEngine; + } + + + public static void setScriptingEnabled( boolean scriptingEnabled ) { + if (scriptingEnabled != _scriptingEnabled) { + _scriptingEngine = scriptingEnabled ? null : NULL_SCRIPTING_ENGINE_FACTORY; + } + _scriptingEnabled = scriptingEnabled; + } + + + public static boolean isScriptingEnabled() { + return _scriptingEnabled; + } + + + private static void disableScripting( Exception e, String errorMessage ) { + System.err.println( errorMessage + _scriptEngineClassName ); + System.err.println( "" + e ); + System.err.println( "JavaScript execution disabled"); + _scriptingEngine = NULL_SCRIPTING_ENGINE_FACTORY; + } + + //--------------------------------- private members -------------------------------------- private static final String DEFAULT_CONTENT_TYPE = "text/plain"; + private static final ScriptingEngineFactory NULL_SCRIPTING_ENGINE_FACTORY = new ScriptingEngineFactory() { + public void associate( WebResponse response ) { + } + }; + + private static boolean _acceptGzip = true; private static boolean _acceptCookies = true; @@ -388,7 +451,15 @@ private static Vector _listeners; + private static String _scriptEngineClassName; + + private static ScriptingEngineFactory _scriptingEngine; + + private static boolean _scriptingEnabled = true; + + static { _listeners = new Vector(); + reset(); } } |
From: Russell G. <rus...@us...> - 2002-08-05 18:58:47
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript In directory usw-pr-cvs1:/tmp/cvs-serv24279/src/com/meterware/httpunit/javascript Modified Files: JavaScript.java Added Files: JavaScriptEngineFactory.java Log Message: Initiate JavaScript automatically ***** Error reading new file[Errno 2] No such file or directory: 'JavaScriptEngineFactory.java' Index: JavaScript.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- JavaScript.java 5 Aug 2002 17:34:25 -0000 1.4 +++ JavaScript.java 5 Aug 2002 18:58:43 -0000 1.5 @@ -48,10 +48,20 @@ /** * Initiates JavaScript execution for the specified web response. */ - static public void run( WebResponse response ) throws IllegalAccessException, InstantiationException, InvocationTargetException, - ClassDefinitionException, NotAFunctionException, PropertyException, SAXException, JavaScriptException { + static void run( WebResponse response ) throws IllegalAccessException, InstantiationException, + InvocationTargetException, ClassDefinitionException, NotAFunctionException, + PropertyException, SAXException, JavaScriptException { Context context = Context.enter(); Scriptable scope = context.initStandardObjects( null ); + initHTMLObjects( scope ); + + Window w = (Window) context.newObject( scope, "Window" ); + w.initialize( null, response.getScriptableObject() ); + } + + + private static void initHTMLObjects( Scriptable scope ) throws IllegalAccessException, InstantiationException, + InvocationTargetException, ClassDefinitionException, PropertyException { ScriptableObject.defineClass( scope, Window.class ); ScriptableObject.defineClass( scope, Document.class ); ScriptableObject.defineClass( scope, Link.class ); @@ -59,9 +69,6 @@ ScriptableObject.defineClass( scope, Control.class ); ScriptableObject.defineClass( scope, Link.class ); ScriptableObject.defineClass( scope, Image.class ); - Window w = (Window) context.newObject( scope, "Window" ); - - w.initialize( null, response.getScriptableObject() ); } |
From: Russell G. <rus...@us...> - 2002-08-05 18:58:46
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv24279/doc Modified Files: release_notes.txt Log Message: Initiate JavaScript automatically Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.127 retrieving revision 1.128 diff -u -r1.127 -r1.128 --- release_notes.txt 5 Aug 2002 17:34:24 -0000 1.127 +++ release_notes.txt 5 Aug 2002 18:58:41 -0000 1.128 @@ -18,6 +18,7 @@ 2. JavaScript: document.images and document.<image-name> are now supported 3. JavaScript: The image.src property is read-write 4. WebResponse now has a getImageWithName method + 5. JavaScript execution is now automatic. It may be enabled or disable via HttpUnitOptions Problems fixed: A form request created after a call to getScriptableObject().setAction() now correctly uses the new action. |
From: Russell G. <rus...@us...> - 2002-08-05 17:34:28
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory usw-pr-cvs1:/tmp/cvs-serv19892/test/com/meterware/httpunit/javascript Modified Files: ScriptingTest.java Log Message: Added support for Javascript image object Index: ScriptingTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ScriptingTest.java 5 Aug 2002 15:21:19 -0000 1.4 +++ ScriptingTest.java 5 Aug 2002 17:34:25 -0000 1.5 @@ -24,6 +24,7 @@ import com.meterware.httpunit.WebResponse; import com.meterware.httpunit.WebForm; import com.meterware.httpunit.WebLink; +import com.meterware.httpunit.WebImage; import junit.framework.TestSuite; import junit.textui.TestRunner; @@ -151,7 +152,7 @@ defineResource( "OnCommand.html", "<html><head></head>" + "<body>" + "<form name='realform'><input name='color' value='blue'></form>" + - "<a href='#' onMouseOver=\"document.realform.color.value='green'\">green</a>" + + "<a href='#' onMouseOver=\"document.realform.color.value='green';\">green</a>" + "</body></html>" ); WebConversation wc = new WebConversation(); WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); @@ -189,6 +190,50 @@ assertEquals( "Alert message", getHostPath() + "/sample.html", response.popNextAlert() ); assertNull( "Alert should have been removed", response.getNextAlert() ); } + + + public void testDocumentFindImages() throws Exception { + defineResource( "OnCommand.html", "<html><head><script language='JavaScript'>" + + "function getFound( object ) {\n" + + " return (object == null) ? \"did not find \" : \"found \";\n" + + " }\n" + + "function viewImages() { \n" + + " alert( \"found \" + document.images.length + \" images(s)\" );\n" + + " alert( getFound( document.realimage ) + \"image 'realimage'\" )\n;" + + " alert( getFound( document.noimage ) + \"image 'noimage'\" );\n" + + " alert( '2nd image is ' + document.images[1].src ); }\n" + + "</script></head>\n" + + "<body onLoad='viewImages()'>\n" + + "<img name='realimage' src='pict1.gif'>\n" + + "<img name='2ndimage' src='pict2.gif'>\n" + + "</body></html>" ); + WebConversation wc = new WebConversation(); + WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); + JavaScript.run( response ); + assertEquals( "Alert message", "found 2 images(s)", response.popNextAlert() ); + assertEquals( "Alert message", "found image 'realimage'", response.popNextAlert() ); + assertEquals( "Alert message", "did not find image 'noimage'", response.popNextAlert() ); + assertEquals( "Alert message", "2nd image is pict2.gif", response.popNextAlert() ); + assertNull( "Alert should have been removed", response.getNextAlert() ); + } + + public void testImageSwap() throws Exception { + defineResource( "OnCommand.html", "<html><head></head>" + + "<body>" + + "<img name='theImage' src='initial.gif'>" + + "<a href='#' onMouseOver=\"document.theImage.src='new.jpg';\">green</a>" + + "</body></html>" ); + WebConversation wc = new WebConversation(); + WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); + JavaScript.run( response ); + WebImage image = response.getImageWithName( "theImage" ); + WebLink link = response.getLinks()[0]; + assertEquals( "initial image source", "initial.gif", image.getSource() ); + link.mouseOver(); + assertEquals( "changed image source", "new.jpg", image.getSource() ); + } + + } |
From: Russell G. <rus...@us...> - 2002-08-05 17:34:28
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv19892/src/com/meterware/httpunit Modified Files: HTMLPage.java ParsedHTML.java WebImage.java WebResponse.java Log Message: Added support for Javascript image object Index: HTMLPage.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLPage.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- HTMLPage.java 2 Aug 2002 16:26:15 -0000 1.3 +++ HTMLPage.java 5 Aug 2002 17:34:25 -0000 1.4 @@ -137,6 +137,9 @@ WebLink wl = getLinkWithName( propertyName ); if (wl != null) return wl.getScriptableObject(); + WebImage wi = getImageWithName( propertyName ); + if (wi != null) return wi.getScriptableObject(); + return super.get( propertyName ); } @@ -161,6 +164,16 @@ WebForm.Scriptable[] result = new WebForm.Scriptable[ forms.length ]; for (int i = 0; i < forms.length; i++) { result[i] = forms[i].getScriptableObject(); + } + return result; + } + + + public WebImage.Scriptable[] getImages() { + WebImage[] images = HTMLPage.this.getImages(); + WebImage.Scriptable[] result = new WebImage.Scriptable[ images.length ]; + for (int i = 0; i < images.length; i++) { + result[i] = images[i].getScriptableObject(); } return result; } Index: ParsedHTML.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ParsedHTML.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- ParsedHTML.java 5 Aug 2002 15:21:19 -0000 1.23 +++ ParsedHTML.java 5 Aug 2002 17:34:25 -0000 1.24 @@ -197,6 +197,19 @@ /** + * Returns the image found in the page with the specified name. + **/ + public WebImage getImageWithName( String name ) { + WebImage[] images = getImages(); + for (int i = 0; i < images.length; i++) { + if (images[i].getName().equals( name )) return images[i]; + else if (HttpUnitOptions.getMatchesIgnoreCase() && images[i].getName().equalsIgnoreCase( name )) return images[i]; + } + return null; + } + + + /** * Returns the image found in the page with the specified src attribute. **/ public WebImage getImageWithSource( String source ) { Index: WebImage.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebImage.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- WebImage.java 15 Jul 2002 14:30:32 -0000 1.1 +++ WebImage.java 5 Aug 2002 17:34:25 -0000 1.2 @@ -33,17 +33,25 @@ private URL _baseURL; private Node _node; private ParsedHTML _parsedHTML; + private Scriptable _scriptable; + private String _src; WebImage( ParsedHTML parsedHTML, URL baseURL, Node node ) { _baseURL = baseURL; _node = node; _parsedHTML = parsedHTML; + _src = NodeUtils.getNodeAttribute( _node, "src" ); + } + + + public String getName() { + return NodeUtils.getNodeAttribute( _node, "name" ); } public String getSource() { - return NodeUtils.getNodeAttribute( _node, "src" ); + return _src; } @@ -58,4 +66,36 @@ } } ); } + + + /** + * Returns an object which provides scripting access to this link. + **/ + public Scriptable getScriptableObject() { + if (_scriptable == null) _scriptable = new Scriptable(); + return _scriptable; + } + + + public class Scriptable extends ScriptableObject { + + public Object get( String propertyName ) { + if (propertyName.equalsIgnoreCase( "src" )) { + return getSource(); + } else { + return super.get( propertyName ); + } + } + + + public void set( String propertyName, Object value ) { + if (propertyName.equalsIgnoreCase( "src" )) { + if (value != null) _src = value.toString(); + } else { + super.set( propertyName, value ); + } + } + } + + } Index: WebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v retrieving revision 1.70 retrieving revision 1.71 diff -u -r1.70 -r1.71 --- WebResponse.java 1 Aug 2002 14:58:59 -0000 1.70 +++ WebResponse.java 5 Aug 2002 17:34:25 -0000 1.71 @@ -370,6 +370,15 @@ /** + * Returns the image found in the page with the specified name attribute. + * @exception SAXException thrown if there is an error parsing the response. + **/ + public WebImage getImageWithName( String source ) throws SAXException { + return getReceivedPage().getImageWithName( source ); + } + + + /** * Returns the image found in the page with the specified src attribute. * @exception SAXException thrown if there is an error parsing the response. **/ |
From: Russell G. <rus...@us...> - 2002-08-05 17:34:28
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript In directory usw-pr-cvs1:/tmp/cvs-serv19892/src/com/meterware/httpunit/javascript Modified Files: JavaScript.java Log Message: Added support for Javascript image object Index: JavaScript.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- JavaScript.java 2 Aug 2002 16:26:15 -0000 1.3 +++ JavaScript.java 5 Aug 2002 17:34:25 -0000 1.4 @@ -24,6 +24,7 @@ import com.meterware.httpunit.WebForm; import com.meterware.httpunit.WebResponse; import com.meterware.httpunit.WebLink; +import com.meterware.httpunit.WebImage; import java.lang.reflect.InvocationTargetException; import java.util.Arrays; @@ -57,6 +58,7 @@ ScriptableObject.defineClass( scope, Form.class ); ScriptableObject.defineClass( scope, Control.class ); ScriptableObject.defineClass( scope, Link.class ); + ScriptableObject.defineClass( scope, Image.class ); Window w = (Window) context.newObject( scope, "Window" ); w.initialize( null, response.getScriptableObject() ); @@ -189,6 +191,7 @@ private Scriptable _forms; private Scriptable _links; + private Scriptable _images; public String getClassName() { @@ -201,6 +204,7 @@ super.initialize( this, scriptable ); initializeLinks(); initializeForms(); + initializeImages(); } @@ -209,6 +213,11 @@ } + public Scriptable jsGet_images() { + return _images; + } + + public Scriptable jsGet_links() { return _links; } @@ -219,6 +228,16 @@ } + private void initializeImages() throws PropertyException, NotAFunctionException, JavaScriptException, SAXException { + WebImage.Scriptable scriptables[] = getDelegate().getImages(); + Image[] images = new Image[ scriptables.length ]; + for (int i = 0; i < images.length; i++) { + images[ i ] = (Image) toScriptable( scriptables[ i ] ); + } + _images = Context.getCurrentContext().newArray( this, images ); + } + + private void initializeLinks() throws PropertyException, NotAFunctionException, JavaScriptException, SAXException { WebLink.Scriptable scriptables[] = getDelegate().getLinks(); Link[] links = new Link[ scriptables.length ]; @@ -252,6 +271,8 @@ return "Form"; } else if (delegate instanceof WebLink.Scriptable) { return "Link"; + } else if (delegate instanceof WebImage.Scriptable) { + return "Image"; } else { throw new IllegalArgumentException( "Unknown ScriptableObject class: " + delegate.getClass() ); } @@ -281,6 +302,14 @@ _document = (Document) parent; } + } + + + static public class Image extends HTMLElement { + + public String getClassName() { + return "Image"; + } } |
From: Russell G. <rus...@us...> - 2002-08-05 17:34:28
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv19892/doc Modified Files: release_notes.txt Log Message: Added support for Javascript image object Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.126 retrieving revision 1.127 diff -u -r1.126 -r1.127 --- release_notes.txt 5 Aug 2002 15:21:19 -0000 1.126 +++ release_notes.txt 5 Aug 2002 17:34:24 -0000 1.127 @@ -15,6 +15,10 @@ 5-Aug-2002 Additions: 1. The JavaScript link.href attribute is now readable. + 2. JavaScript: document.images and document.<image-name> are now supported + 3. JavaScript: The image.src property is read-write + 4. WebResponse now has a getImageWithName method + Problems fixed: A form request created after a call to getScriptableObject().setAction() now correctly uses the new action. |
From: Russell G. <rus...@us...> - 2002-08-05 15:21:26
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv29000/doc Modified Files: Cookbook.html release_notes.txt Log Message: Correct ordering of links array, support read of link.href Index: Cookbook.html =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/Cookbook.html,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Cookbook.html 19 Jun 2001 14:43:49 -0000 1.3 +++ Cookbook.html 5 Aug 2002 15:21:19 -0000 1.4 @@ -5,41 +5,41 @@ <H2>Obtaining a web page response</H2> -The center of HttpUnit is the <A HREF="api/com/meterware/httpunit/WebConversation.html">WebConversation</A> class, -which takes the place of a browser talking to a single site. It is responsible for maintaining session context, -which it does via cookies returned by the server. To use it, one must create a -<A HREF="api/com/meterware/httpunit/WebRequest.html">request</A> and ask the WebConversation for a response.<BR> +The center of HttpUnit is the <A HREF="api/com/meterware/httpunit/WebConversation.html">WebConversation</A> class, +which takes the place of a browser talking to a single site. It is responsible for maintaining session context, +which it does via cookies returned by the server. To use it, one must create a +<A HREF="api/com/meterware/httpunit/WebRequest.html">request</A> and ask the WebConversation for a response.<BR> For example: <PRE><CODE> WebConversation wc = new WebConversation(); WebRequest req = new GetMethodWebRequest( "http://www.meterware.com/testpage.html" ); WebResponse resp = wc.getResponse( req ); </CODE></PRE> -The <A HREF="api/com/meterware/httpunit/WebResponse.html">response</A> may now be manipulated either as -pure text (via the <CODE>toString()</CODE> method), as a DOM (via the <CODE>getDOM()</CODE> method), +The <A HREF="api/com/meterware/httpunit/WebResponse.html">response</A> may now be manipulated either as +pure text (via the <CODE>getText()</CODE> method), as a DOM (via the <CODE>getDOM()</CODE> method), or by using the various other methods described below. Because the above sequence is so common, it can be abbreviated to: <PRE><CODE> WebConversation wc = new WebConversation(); WebResponse resp = wc.getResponse( "http://www.meterware.com/testpage.html" ); </CODE></PRE> <H2>Examining and following links</H2> -The simplest and most common form of navigation among web pages is via links. HttpUnit allows users to find links +The simplest and most common form of navigation among web pages is via links. HttpUnit allows users to find links by the text within them, and to use those links as new page requests. For example, this page contains a link to the JavaDoc for the <CODE>WebResponse</CODE> class, above. That page could therefore be obtained as follows: <PRE><CODE> WebConversation wc = new WebConversation(); - WebResponse resp = wc.getResponse( "http://httpunit.sourceforge.net/doc/Cookbook.html" ); // read this page - WebLink link = resp.getLinkWith( "response" ); // find the link - WebRequest req = link.getRequest(); // convert it to a request - WebResponse jdoc = wc.getResponse( req ); // retrieve the referenced page + WebResponse resp = wc.getResponse( "http://www.httpunit.org/doc/Cookbook.html" ); // read this page + WebLink link = resp.getLinkWith( "response" ); // find the link + link.click(); // follow it + WebResponse jdoc = wc.getCurrentPage(); // retrieve the referenced page </CODE></PRE> Image links can be found as well. The <CODE>WebResponse.getLinkWithImageText()</CODE> method can look up links by examining the ALT text, or the <CODE>HttpUnitOptions.setImagesTreatedAsAltText</CODE> method can cause ALT text to be treated as -ordinary searchable text. +ordinary searchable text. <H2>Using the table structure of a web page</H2> -Many web designers make heavy use of tables to control the page formatting. You can take advantage of this by looking +Many web designers make heavy use of tables to control the page formatting. You can take advantage of this by looking at the tables in the page as discrete elements. The :<CODE>getTables()</CODE> method will return an array of the top-level -tables in the page (that is, those which are not nested within other tables), in the order in which they appear in the +tables in the page (that is, those which are not nested within other tables), in the order in which they appear in the document. Given a table, you can ask for one of its cells, and treat the result either as text or a DOM or ask for and tables, links, or forms nested within it. For example, the following code will confirm that the first table in the page has 4 rows and 3 columns, and that there is a single link in the last cell of the first row: @@ -82,10 +82,10 @@ <H2>Working with forms</H2> <P>A dynamic web site tends to have many html forms, each of which contains various kinds of controls: text boxes, pull-down menus, -radio buttons, and so on. The HTML for these controls vary widely; however, the intent is roughly the same, so HttpUnit +radio buttons, and so on. The HTML for these controls vary widely; however, the intent is roughly the same, so HttpUnit makes them look the same.</P> -<P>There are a few basic things that a tester is likely to want to do with a form. The most obvious first step is to verify the +<P>There are a few basic things that a tester is likely to want to do with a form. The most obvious first step is to verify the controls and their default values; if they are correct, the tester will generally make some changes and submit the form to see how the system responds. HttpUnit makes both tasks easy.</P> @@ -113,22 +113,22 @@ </PRE> Note that all controls are treated alike, with the exception of the checkbox. -<P>Simulating the submission of the form will involve asking the WebConversation for a response to a request which was -defined by the form, possibly modifying the form parameters beforehand. For example, to correct the restaurant type and +<P>Simulating the submission of the form can be done most simply by obtaining the form object and calling its 'submit' +method, possibly modifying the form parameters beforehand. For example, to correct the restaurant type and indicate that it does not accept credit cards: -<PRE> request = form.getRequest(); - request.setParameter( "Food", "Italian" ); - request.removeParameter( "CreditCard" ); - response = wc.getResponse( request ); +<PRE> form.setParameter( "Food", "Italian" ); // select one of the permitted values for food + form.removeParameter( "CreditCard" ); // clear the check box + form.submit(); // submit the form </PRE> -And of course the test would then proceed to examine the response to this submission as well. +And of course the test could then proceed to examine the response to this submission as well, +obtaining it from <code>wc.getCurrentPage()</code>. <H2>Working with frames</H2> <P>Without frames, web interaction tends to be straightforward and sequential. There is one current active page at a time, and each new page replaces the old one that referenced it. Frames change that, allowing multiple active pages simultaneously, and allowing for the possibility that a link from one active page could result in the replacement of a different page.</P> -<P>HttpUnit supports frames by providing methods on the WebConversation class to examine those frames +<P>HttpUnit supports frames by providing methods on the WebConversation class to examine those frames which are currently active. Each response replaces the contents of the appropriate frame, which is not necessarily the topmost frame ("_top"). In the following scenation, there are two active subframes, named "overview" and "details": @@ -136,14 +136,13 @@ WebResponse top = wc.getResponse( "http://www.meterware.com/Frames.html" ); // read a page with two frames WebResponse summary = wc.getFrameContents( "summary" ); // read the summary frame WebLink link = summary.getLinkWith( "Cake Recipe" ); // find the link (which targets "details" ); - WebResponse details = wc.getResponse( link.getRequest() ); // retrieve the referenced page + link.click(); // click on it WebResponse response= wc.getFrameContents( "details" ); // retrieve the details frame </CODE></PRE> -At the end of this sequence, <CODE>details</CODE> and <CODE>response</CODE> should point to the same object. </BODY> </HTML> - + Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.125 retrieving revision 1.126 diff -u -r1.125 -r1.126 --- release_notes.txt 2 Aug 2002 16:26:15 -0000 1.125 +++ release_notes.txt 5 Aug 2002 15:21:19 -0000 1.126 @@ -12,6 +12,12 @@ Revision History: + 5-Aug-2002 +Additions: + 1. The JavaScript link.href attribute is now readable. +Problems fixed: + A form request created after a call to getScriptableObject().setAction() now correctly uses the new action. + 2-Aug-2002 Additions: 1. Added JavaScript support for document.links and document.<link name> and the link 'onMouseOver' event. |
From: Russell G. <rus...@us...> - 2002-08-05 15:21:25
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory usw-pr-cvs1:/tmp/cvs-serv29000/test/com/meterware/httpunit/javascript Modified Files: ScriptingTest.java Log Message: Correct ordering of links array, support read of link.href Index: ScriptingTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ScriptingTest.java 2 Aug 2002 16:26:15 -0000 1.3 +++ ScriptingTest.java 5 Aug 2002 15:21:19 -0000 1.4 @@ -164,4 +164,31 @@ } + public void testLinkIndexes() throws Exception { + defineResource( "OnCommand.html", "<html><head><script language='JavaScript'>" + + "function alertLinks() { " + + " for (var i=0; i < document.links.length; i++) {" + + " alert( document.links[i].href );" + + " }" + + "}" + + "</script></head>" + + "<body onLoad='alertLinks()'>" + + "<a href='demo.html'>green</a>" + + "<map name='map1'>" + + " <area href='guide.html' alt='Guide' shape='rect' coords='0,0,118,28'>" + + " <area href='search.html' alt='Search' shape='circle' coords='184,200,60'>" + + "</map>" + + "<a href='sample.html'>green</a>" + + "</body></html>" ); + WebConversation wc = new WebConversation(); + WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); + JavaScript.run( response ); + assertEquals( "Alert message", getHostPath() + "/demo.html", response.popNextAlert() ); + assertEquals( "Alert message", getHostPath() + "/guide.html", response.popNextAlert() ); + assertEquals( "Alert message", getHostPath() + "/search.html", response.popNextAlert() ); + assertEquals( "Alert message", getHostPath() + "/sample.html", response.popNextAlert() ); + assertNull( "Alert should have been removed", response.getNextAlert() ); + } + + } |
From: Russell G. <rus...@us...> - 2002-08-05 15:21:25
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv29000/src/com/meterware/httpunit Modified Files: NodeUtils.java ParsedHTML.java WebLink.java Log Message: Correct ordering of links array, support read of link.href Index: NodeUtils.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/NodeUtils.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- NodeUtils.java 4 Mar 2002 02:10:49 -0000 1.11 +++ NodeUtils.java 5 Aug 2002 15:21:19 -0000 1.12 @@ -73,31 +73,32 @@ return node.getAttributes().getNamedItem( attributeName ) != null; } + + interface NodeAction { + /** + * Does appropriate processing on specified element. Will return false if the subtree below the element + * should be skipped. + */ + public boolean processElement( Element element ); + + /** + * Processes a text node. + */ + public void processTextNodeValue( String value ); + } + /** * Converts the DOM trees rooted at the specified nodes to text, ignoring * any HTML tags. **/ public static String asText( NodeList rootNodes ) { - StringBuffer sb = new StringBuffer(HttpUnitUtils.DEFAULT_TEXT_BUFFER_SIZE); - Stack pendingNodes = new Stack(); - pushNodeList( rootNodes, pendingNodes ); - - while (!pendingNodes.empty()) { - Object pending = pendingNodes.pop(); - if (pending instanceof String) { - sb.append( pending ); - } else { - Node node = (Node) pending; - - if (node.getNodeType() == Node.TEXT_NODE) { - sb.append( convertNBSP( node.getNodeValue() ) ); - } else if (node.getNodeType() != Node.ELEMENT_NODE) { - continue; - } else if (node.getNodeName().equalsIgnoreCase( "p" )) { + final StringBuffer sb = new StringBuffer(HttpUnitUtils.DEFAULT_TEXT_BUFFER_SIZE); + processNodes( rootNodes, new NodeAction() { + public boolean processElement( Element node ) { + if (node.getNodeName().equalsIgnoreCase( "p" )) { sb.append( "\n" ); } else if (node.getNodeName().equalsIgnoreCase( "tr" )) { sb.append( "\n" ); - pendingNodes.push( " |" ); } else if (node.getNodeName().equalsIgnoreCase( "td" )) { sb.append( " | " ); } else if (node.getNodeName().equalsIgnoreCase( "th" )) { @@ -105,11 +106,36 @@ } else if (node.getNodeName().equalsIgnoreCase( "img" ) && HttpUnitOptions.getImagesTreatedAsAltText()) { sb.append( getNodeAttribute( node, "alt" ) ); } - - pushNodeList( node.getChildNodes(), pendingNodes ); + return true; } - } + public void processTextNodeValue( String value ) { + sb.append( convertNBSP( value ) ); + } + } ); return sb.toString(); + } + + + /** + * Converts the DOM trees rooted at the specified nodes to text, ignoring + * any HTML tags. + **/ + public static void processNodes( NodeList rootNodes, NodeAction action ) { + Stack pendingNodes = new Stack(); + pushNodeList( rootNodes, pendingNodes ); + + while (!pendingNodes.empty()) { + Node node = (Node) pendingNodes.pop(); + + if (node.getNodeType() == Node.TEXT_NODE) { + action.processTextNodeValue( node.getNodeValue() ); + } else if (node.getNodeType() != Node.ELEMENT_NODE) { + continue; + } else + action.processElement( (Element) node ); + + pushNodeList( node.getChildNodes(), pendingNodes ); + } } Index: ParsedHTML.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ParsedHTML.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- ParsedHTML.java 1 Aug 2002 14:58:59 -0000 1.22 +++ ParsedHTML.java 5 Aug 2002 15:21:19 -0000 1.23 @@ -22,6 +22,7 @@ import java.net.URL; import java.util.Vector; +import java.util.ArrayList; import org.w3c.dom.*; @@ -94,23 +95,26 @@ **/ public WebLink[] getLinks() { if (_links == null) { - Vector list = new Vector(); - addLinkAnchors( list, NodeUtils.getElementsByTagName( _rootNode, "a" ) ); - addLinkAnchors( list, NodeUtils.getElementsByTagName( _rootNode, "area" ) ); - _links = new WebLink[ list.size() ]; - list.copyInto( _links ); + final ArrayList list = new ArrayList(); + NodeUtils.processNodes( _rootNode.getChildNodes(), new NodeUtils.NodeAction() { + public boolean processElement( Element element ) { + if (element.getNodeName().equalsIgnoreCase( "a" )) addLinkAnchor( list, element ); + else if (element.getNodeName().equalsIgnoreCase( "area" )) addLinkAnchor( list, element ); + return true; + } + public void processTextNodeValue( String value ) { + } + } ); + _links = (WebLink[]) list.toArray( new WebLink[ list.size() ] ); } return _links; } - private void addLinkAnchors(Vector list, NodeList nl) { - for (int i = 0; i < nl.getLength(); i++) { - Node child = nl.item(i); - if (isLinkAnchor( child )) { - list.addElement( new WebLink( _response, _baseURL, _baseTarget, child ) ); - } + private void addLinkAnchor( ArrayList list, Node child ) { + if (isLinkAnchor( child )) { + list.add( new WebLink( _response, _baseURL, _baseTarget, child ) ); } } Index: WebLink.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebLink.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- WebLink.java 2 Aug 2002 16:26:15 -0000 1.21 +++ WebLink.java 5 Aug 2002 15:21:19 -0000 1.22 @@ -20,6 +20,7 @@ * *******************************************************************************************************************/ import java.net.URL; +import java.net.MalformedURLException; import java.util.ArrayList; import java.util.HashMap; @@ -77,8 +78,8 @@ /** * Submits a request as though the user had clicked on this link. Will also fire the 'onClick' event if defined. **/ - public void click() throws IOException, SAXException { - submitRequest(); + public WebResponse click() throws IOException, SAXException { + return submitRequest(); } @@ -228,6 +229,23 @@ public class Scriptable extends ScriptableObject { + + public Object get( String propertyName ) { + if (propertyName.equalsIgnoreCase( "href" )) { + return getReference().toExternalForm(); + } else { + return super.get( propertyName ); + } + } + + + private URL getReference() { + try { + return getRequest().getURL(); + } catch (MalformedURLException e) { + return WebLink.this.getBaseURL(); + } + } } |
From: Russell G. <rus...@us...> - 2002-08-05 15:20:55
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv28820/test/com/meterware/httpunit Modified Files: FormSubmitTest.java Log Message: Correct handling of settable form action Index: FormSubmitTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FormSubmitTest.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- FormSubmitTest.java 17 Jun 2002 18:43:15 -0000 1.18 +++ FormSubmitTest.java 5 Aug 2002 15:20:51 -0000 1.19 @@ -110,6 +110,19 @@ } + public void testSubmitStringAfterSetAction() throws Exception { + defineWebPage( "Default", "<form method=GET action = \"/ask\">" + + "<Input type=text name=age>" + + "<Input type=submit value=Go>" + + "</form>" ); + WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); + page.getForms()[0].getScriptableObject().setAction( "tell" ); + WebRequest request = page.getForms()[0].getRequest(); + request.setParameter( "age", "23" ); + assertEquals( getHostPath() + "/tell?age=23", request.getURL().toExternalForm() ); + } + + public void testNoNameSubmitString() throws Exception { defineWebPage( "Default", "<form method=GET action = \"/ask\">" + "<Input type=text value=dontSend>" + |
From: Russell G. <rus...@us...> - 2002-08-05 15:20:54
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv28820/src/com/meterware/httpunit Modified Files: WebForm.java WebRequestSource.java Log Message: Correct handling of settable form action Index: WebForm.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v retrieving revision 1.52 retrieving revision 1.53 diff -u -r1.52 -r1.53 --- WebForm.java 1 Aug 2002 20:23:16 -0000 1.52 +++ WebForm.java 5 Aug 2002 15:20:50 -0000 1.53 @@ -46,8 +46,8 @@ /** * Submits this form using the web client from which it was originally obtained. **/ - public void submit() throws IOException, SAXException { - submitRequest(); + public WebResponse submit() throws IOException, SAXException { + return submitRequest(); } @@ -63,8 +63,7 @@ * Returns the action defined for this form. **/ public String getAction() { - if (_action == null) _action = getDestination(); - return _action; + return getDestination(); } @@ -411,7 +410,7 @@ public class Scriptable extends ScriptableObject { public String getAction() { return WebForm.this.getAction(); } - public void setAction( String newAction ) { _action = newAction; } + public void setAction( String newAction ) { setDestination( newAction ); } public Object get( String propertyName ) { @@ -458,8 +457,6 @@ private FormControl[] _presetParameters; private ArrayList _presets; - - private String _action; private Object getObject( String name ) { Index: WebRequestSource.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequestSource.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- WebRequestSource.java 1 Aug 2002 14:58:59 -0000 1.9 +++ WebRequestSource.java 5 Aug 2002 15:20:51 -0000 1.10 @@ -145,6 +145,11 @@ } + protected void setDestination( String destination ) { + _destination = destination; + } + + /** * Returns the actual DOM for this request source, not a copy. **/ @@ -168,8 +173,8 @@ * Submits a request to the web client from which this request source was originally obtained. **/ final - protected void submitRequest() throws IOException, SAXException { - _baseResponse.getClient().sendRequest( getRequest() ); + protected WebResponse submitRequest() throws IOException, SAXException { + return _baseResponse.getClient().sendRequest( getRequest() ); } |